1234

Important notes
There are 3 deployment points:
 * devel.challngr.com (development environment)
 * beta.challngr.com (to test new features and comercial use)
 * www.challngr.com (production)

Each deployment point have 3 symfony environments:
 * devel - for development. Debug, log and web debug ON
 * test - for automatic testing. Not used.
 * production - Debug, log and web debug OFF

Common info
In all requests phone apps should always pass one or two parameters:
 * ssid: An unique string platform identifier (see below to know wich one use)
 * hash: An string with the auth string info returned for user with the method login (ONLY WHEN NEEDED)


 * Example call rapi: http://devel.challngr.com/rapi.php/login

SSID Aplicacions

 * Test: 172eee54aa664e9dd0536b063796e54e
 * Iphone: 141aff1bfb749f52d024ba5cbcdaeeb5
 * Android: 84c0c64bdc9cbe5649322b459794837b

User methods

 * 1) Login - User login
 * 2) * method: method/login
 * 3) * params:
 * 4) ** email: string (REQUIRED)
 * 5) ** password: string (REQUIRED)
 * 6) * returns: JSON Array of User on success, error code if user/mail combination is incorrect.
 * 7) * example responses:
 * 8) Logout - User logout
 * 9) * method: method/logout
 * 10) * params: none
 * 11) * returns: JSON true on success, error code if user is incorrect OR not logged in.
 * 12) * example responses:
 * 13) Remember password
 * 14) * method: method/rememberPassword
 * 15) * params:
 * 16) ** email: string (REQUIRED)
 * 17) * returns: JSON true on success, error code if email is incorrect.
 * 18) * example responses:
 * 19) Register and save new user
 * 20) * method: method/registerUser
 * 21) * params:
 * 22) ** email: string (REQUIRED)
 * 23) ** name: string (REQUIRED)
 * 24) ** surname: string (REQUIRED)
 * 25) ** password: string (REQUIRED)
 * 26) ** phone: string
 * 27) ** postal_code: string
 * 28) ** city: string
 * 29) ** gender: numeric (0 male 1 female)
 * 30) ** birth_date: date
 * 31) * returns: JSON user array on success, error code if incorrect.
 * 32) * example responses:
 * 33) ** {"id":"1","email":"marc@teclliure.net","name":"User1","surname":"","photo":"","phone":"","postal_code":"","city":"","gender":"","birth_date":"","facebook_id":"","country_id":"","state_id":"","user_status":"active","created_at":"2011-11-28 09:26:56","updated_at":"2011-11-28 09:26:56"}
 * 34) ** {"error":{"code":"101","message":"Invalid user"}}
 * 35) Save changed user data
 * 36) * method: method/setUser
 * 37) * params:
 * 38) ** name: string
 * 39) ** surname: string
 * 40) ** password: string
 * 41) ** phone: string
 * 42) ** postal_code: string
 * 43) ** city: string
 * 44) ** gender: numeric (0 male 1 female)
 * 45) ** birth_date: date
 * 46) * returns: JSON user array on success, error code if incorrect.
 * 47) * example responses:
 * 48) ** {"id":"1","email":"marc@teclliure.net","name":"User1","surname":"","photo":"","phone":"","postal_code":"","city":"","gender":"","birth_date":"","facebook_id":"","country_id":"","state_id":"","user_status":"active","created_at":"2011-11-28 09:26:56","updated_at":"2011-11-28 09:26:56"}
 * 49) ** {"error":{"code":"101","message":"Invalid user"}}
 * 50) Upload and change user profile image (SHOULD be 130x130 jpg)
 * 51) * method: method/setUserImage
 * 52) * params:
 * 53) ** image: string (REQUIRED) -> base64_encoded image file
 * 54) * returns: JSON user array on success, error code if incorrect.
 * 55) * example responses:
 * 56) ** {"id":"1","email":"marc@teclliure.net","name":"User1","surname":"","photo":"","phone":"","postal_code":"","city":"","gender":"","birth_date":"","facebook_id":"","country_id":"","state_id":"","user_status":"active","created_at":"2011-11-28 09:26:56","updated_at":"2011-11-28 09:26:56"}
 * 57) ** {"error":{"code":"101","message":"Invalid user"}}
 * 58) Get current user data
 * 59) * method: method/getUser
 * 60) * params:
 * 61) * returns: JSON user array on success, error code if incorrect.
 * 62) * example responses:
 * 63) ** {"id":"1","email":"marc@teclliure.net","name":"User1","surname":"","photo":"","phone":"","postal_code":"","city":"","gender":"","birth_date":"","facebook_id":"","country_id":"","state_id":"","user_status":"active","created_at":"2011-11-28 09:26:56","updated_at":"2011-11-28 09:26:56"}
 * 64) ** {"error":{"code":"101","message":"Invalid user"}}
 * 65) Get current user history
 * 66) * method: method/getUserHistory
 * 67) * params:
 * 68) * returns: JSON history array on success, error code if incorrect.
 * 69) * example responses:
 * 70) ** {"id":"1","email":"marc@teclliure.net","name":"User1","surname":"","photo":"","phone":"","postal_code":"","city":"","gender":"","birth_date":"","facebook_id":"","country_id":"","state_id":"","user_status":"active","created_at":"2011-11-28 09:26:56","updated_at":"2011-11-28 09:26:56"}
 * 71) ** {"error":{"code":"101","message":"Invalid user"}}
 * 1) * method: method/getUserHistory
 * 2) * params:
 * 3) * returns: JSON history array on success, error code if incorrect.
 * 4) * example responses:
 * 5) ** {"id":"1","email":"marc@teclliure.net","name":"User1","surname":"","photo":"","phone":"","postal_code":"","city":"","gender":"","birth_date":"","facebook_id":"","country_id":"","state_id":"","user_status":"active","created_at":"2011-11-28 09:26:56","updated_at":"2011-11-28 09:26:56"}
 * 6) ** {"error":{"code":"101","message":"Invalid user"}}

Company methods

 * 1) listCompanies - List Companies
 * 2) * method: method/listCompanies
 * 3) * params:
 * 4) ** offset: numeric
 * 5) * returns: JSON Array of Public Venues.
 * 6) * example responses:
 * 7) getCompany - Obtain a Company
 * 8) * method: method/getCompany
 * 9) * params:
 * 10) ** id: numeric
 * 11) * returns: JSON Array of Venue.
 * 12) * example responses:
 * 13) **{"id":"8","name":"CHALLNGR","fiscal_id":"A58818501","description":"CHALLNGR DESCRIPTION","address":"C\/ PLACA BARANGE, 12 2.","postal_code":"256","city_id":"8","state_id":"8","country_id":"8","bank_account":"21000813610123456789","payment_bank_account":"21000813610123456789","created_at":"2011-12-02 10:49:22","updated_at":"2011-12-02 10:49:22"}
 * 14) getCompanyProducts - Obtain the Company Products
 * 15) * method: method/getCompanyProducts
 * 16) * params:
 * 17) ** id: numeric
 * 18) * returns: JSON Array of Venue.
 * 19) * example responses:
 * 20) getCompanyVenues - Obtain the Company Venues
 * 21) * method: method/getCompanyVenues
 * 22) * params:
 * 23) ** id: numeric
 * 24) * returns: JSON Array of Venue.
 * 25) * example responses:
 * 26) getCompanyChallenges - Obtain the Company Challenges
 * 27) * method: method/getCompanyChallenges
 * 28) * params:
 * 29) ** id: numeric
 * 30) * returns: JSON Array of Venue.
 * 31) * example responses:
 * 32) getProductVenues - Obtain the product Venues
 * 33) * method: method/getProductVenues
 * 34) * params:
 * 35) ** id: numeric
 * 36) * returns: JSON Array of venues or error if not exist product.
 * 37) * example responses:
 * 38) getProductChallenges - Obtain the product Challenges
 * 39) * method: method/getProductChallenges
 * 40) * params:
 * 41) ** id: numeric
 * 42) * returns: JSON Array of challenges or error if not exist product.
 * 43) * example responses:
 * 1) * method: method/getProductChallenges
 * 2) * params:
 * 3) ** id: numeric
 * 4) * returns: JSON Array of challenges or error if not exist product.
 * 5) * example responses:

Venue methods

 * 1) listPrivateVenues - List Private Venues
 * 2) * method: method/listPrivateVenues
 * 3) * params:
 * 4) ** near: string
 * 5) ** state: numeric
 * 6) ** search: string
 * 7) ** category: string
 * 8) ** prominent: integer (1 or 0)
 * 9) ** offset: numeric
 * 10) * returns: JSON Array of Private Venues.
 * 11) * example responses:
 * 12) ** [{"id":"32","name":"7","address":"1","postal_code":"1","phone":"","venue_category_id":"","venue_sub_category_id":"","image":"","latitude":"1","longitude":"1","state_id":"1","country_id":"1","city_id":"1","company_id":"1","created_at":"2011-11-30 00:00:00","updated_at":"2011-11-30 00:00:00"},{"id":"31","name":"6","address":"1","postal_code":"1","phone":"","venue_category_id":"","venue_sub_category_id":"","image":"","latitude":"1","longitude":"1","state_id":"1","country_id":"1","city_id":"1","company_id":"1","created_at":"2011-11-30 00:00:00","updated_at":"2011-11-30 00:00:00"}]
 * 13) listPublicVenues - List Public Venues
 * 14) * method: method/listPublicVenues
 * 15) * params:
 * 16) ** near: string
 * 17) ** state: numeric
 * 18) ** search: string
 * 19) ** category: string
 * 20) ** prominent: integer (1 or 0)
 * 21) ** offset: numeric
 * 22) * returns: JSON Array of Public Venues.
 * 23) * example responses:
 * 24) ** [{"id":"32","name":"7","address":"1","postal_code":"1","phone":"","venue_category_id":"","venue_sub_category_id":"","image":"","latitude":"1","longitude":"1","state_id":"1","country_id":"1","city_id":"1","company_id":"1","created_at":"2011-11-30 00:00:00","updated_at":"2011-11-30 00:00:00"},{"id":"31","name":"6","address":"1","postal_code":"1","phone":"","venue_category_id":"","venue_sub_category_id":"","image":"","latitude":"1","longitude":"1","state_id":"1","country_id":"1","city_id":"1","company_id":"1","created_at":"2011-11-30 00:00:00","updated_at":"2011-11-30 00:00:00"}]
 * 25) findFoursquareVenues - Find and save foursquare Venues
 * 26) * method: method/findFoursquareVenues
 * 27) * params:
 * 28) ** near: string (REQUIRED)
 * 29) * returns: JSON Array of Venues.
 * 30) * example responses:
 * 31) ** [{"id":"32","name":"7","address":"1","postal_code":"1","phone":"","venue_category_id":"","venue_sub_category_id":"","image":"","latitude":"1","longitude":"1","state_id":"1","country_id":"1","city_id":"1","company_id":"1","created_at":"2011-11-30 00:00:00","updated_at":"2011-11-30 00:00:00"},{"id":"31","name":"6","address":"1","postal_code":"1","phone":"","venue_category_id":"","venue_sub_category_id":"","image":"","latitude":"1","longitude":"1","state_id":"1","country_id":"1","city_id":"1","company_id":"1","created_at":"2011-11-30 00:00:00","updated_at":"2011-11-30 00:00:00"}]
 * 32) getVenue - Obtain a Venue
 * 33) * method: method/getVenue
 * 34) * params:
 * 35) ** id: numeric
 * 36) * returns: JSON Array of Venue.
 * 37) * example responses:
 * 38) ** {"id": "12","name": "PORXADA_12","address": "Carrer del Sastre, 3","postal_code": "256","phone": "","venue_category_id": "","venue_sub_category_id": "","image": "","latitude": "41.608229","longitude": "2.287914","state_id": "1","country_id": "1","city_id": "1","company_id": "1","created_at": "2011-11-30 11:56:09","updated_at": "2011-11-30 11:56:09"}
 * 39) getVenueImages - Obtain a Images of Venue
 * 40) * method: method/getVenueImages
 * 41) * params:
 * 42) ** id: numeric
 * 43) * returns: JSON Array of Venue.
 * 44) * example responses:
 * 45) ** [{"id":"1","filename":"PORXADA_IMAGE_1.png","extension":"png","size":"3000","location":"noxe","object_class":"Venue","object_id":"1"},{"id":"2","filename":"PORXADA_IMAGE_2.png","extension":"png","size":"3000","location":"noxe","object_class":"Venue","object_id":"1"},{"id":"3","filename":"PORXADA_IMAGE_3.png","extension":"png","size":"3000","location":"noxe","object_class":"Venue","object_id":"1"},{"id":"4","filename":"PORXADA_IMAGE_4.png","extension":"png","size":"3000","location":"noxe","object_class":"Venue","object_id":"1"},{"id":"5","filename":"PORXADA_IMAGE_5.png","extension":"png","size":"3000","location":"noxe","object_class":"Venue","object_id":"1"},{"id":"6","filename":"PORXADA_IMAGE_6.png","extension":"png","size":"3000","location":"noxe","object_class":"Venue","object_id":"1"},{"id":"7","filename":"PORXADA_IMAGE_7.png","extension":"png","size":"3000","location":"noxe","object_class":"Venue","object_id":"1"},{"id":"8","filename":"PORXADA_IMAGE_8.png","extension":"png","size":"3000","location":"noxe","object_class":"Venue","object_id":"1"},{"id":"9","filename":"PORXADA_IMAGE_9.png","extension":"png","size":"3000","location":"noxe","object_class":"Venue","object_id":"1"},{"id":"10","filename":"PORXADA_IMAGE_10.png","extension":"png","size":"3000","location":"noxe","object_class":"Venue","object_id":"1"}]
 * 46) getVenueVideos - Obtain a Video of Venue
 * 47) * method: method/getVenueVideos
 * 48) * params:
 * 49) ** id: numeric
 * 50) * returns: JSON Array of Venue.
 * 51) * example responses:
 * 52) ** [{"id":"1","title":"PORXADA_VIDEO_1.png","url":"url video","description":"descripcio","object_class":"Venue","object_id":"1"},{"id":"2","title":"PORXADA_VIDEO_2.png","url":"url video","description":"descripcio","object_class":"Venue","object_id":"1"},{"id":"3","title":"PORXADA_VIDEO_3.png","url":"url video","description":"descripcio","object_class":"Venue","object_id":"1"},{"id":"4","title":"PORXADA_VIDEO_4.png","url":"url video","description":"descripcio","object_class":"Venue","object_id":"1"},{"id":"5","title":"PORXADA_VIDEO_5.png","url":"url video","description":"descripcio","object_class":"Venue","object_id":"1"},{"id":"6","title":"PORXADA_VIDEO_6.png","url":"url video","description":"descripcio","object_class":"Venue","object_id":"1"},{"id":"7","title":"PORXADA_VIDEO_7.png","url":"url video","description":"descripcio","object_class":"Venue","object_id":"1"},{"id":"8","title":"PORXADA_VIDEO_8.png","url":"url video","description":"descripcio","object_class":"Venue","object_id":"1"},{"id":"9","title":"PORXADA_VIDEO_9.png","url":"url video","description":"descripcio","object_class":"Venue","object_id":"1"},{"id":"10","title":"PORXADA_VIDEO_10.png","url":"url video","description":"descripcio","object_class":"Venue","object_id":"1"}]
 * 53) addChallengeMeToVenue - Create a new ChallengeMe
 * 54) * method: method/addChallengeMeToVenue
 * 55) * params:
 * 56) ** id: numeric
 * 57) * returns: JSON Array of Venue.
 * 58) * example responses:
 * 59) ** true
 * 60) ** {"error":{"code":"100","message":"request is required and json formated"}}

Product methods

 * 1) listProducts - List Products
 * 2) * method: method/listProducts
 * 3) * params:
 * 4) ** state: numeric
 * 5) ** search: string
 * 6) ** category: string
 * 7) ** prominent: integer (1 or 0)
 * 8) ** offset: numeric
 * 9) * returns: JSON Array of Private Products.
 * 10) * example responses:
 * 11) ** [{"id":"10","name":"PRODUCT_10.png","barcode":"","image":"","product_category_id":"","product_sub_category_id":"","company_id":"1","created_at":"2011-12-02 10:57:40","updated_at":"2011-12-02 10:57:40"},{"id":"9","name":"PRODUCT_9.png","barcode":"","image":"","product_category_id":"","product_sub_category_id":"","company_id":"1","created_at":"2011-12-02 10:57:40","updated_at":"2011-12-02 10:57:40"},{"id":"8","name":"PRODUCT_8.png","barcode":"","image":"","product_category_id":"","product_sub_category_id":"","company_id":"1","created_at":"2011-12-02 10:57:40","updated_at":"2011-12-02 10:57:40"},{"id":"7","name":"PRODUCT_7.png","barcode":"","image":"","product_category_id":"","product_sub_category_id":"","company_id":"1","created_at":"2011-12-02 10:57:40","updated_at":"2011-12-02 10:57:40"},{"id":"6","name":"PRODUCT_6.png","barcode":"","image":"","product_category_id":"","product_sub_category_id":"","company_id":"1","created_at":"2011-12-02 10:57:40","updated_at":"2011-12-02 10:57:40"},{"id":"5","name":"PRODUCT_5.png","barcode":"","image":"","product_category_id":"","product_sub_category_id":"","company_id":"1","created_at":"2011-12-02 10:57:39","updated_at":"2011-12-02 10:57:39"},{"id":"4","name":"PRODUCT_4.png","barcode":"","image":"","product_category_id":"","product_sub_category_id":"","company_id":"1","created_at":"2011-12-02 10:57:39","updated_at":"2011-12-02 10:57:39"},{"id":"3","name":"PRODUCT_3.png","barcode":"","image":"","product_category_id":"","product_sub_category_id":"","company_id":"1","created_at":"2011-12-02 10:57:39","updated_at":"2011-12-02 10:57:39"},{"id":"2","name":"PRODUCT_2.png","barcode":"","image":"","product_category_id":"","product_sub_category_id":"","company_id":"1","created_at":"2011-12-02 10:57:39","updated_at":"2011-12-02 10:57:39"},{"id":"1","name":"PRODUCT_1.png","barcode":"","image":"","product_category_id":"","product_sub_category_id":"","company_id":"1","created_at":"2011-12-02 10:57:39","updated_at":"2011-12-02 10:57:39"}]
 * 12) getProduct - Obtain a Product
 * 13) * method: method/getProduct
 * 14) * params:
 * 15) ** id: numeric
 * 16) * returns: JSON Array of Venue.
 * 17) * example responses:
 * 18) ** {"id":"1","name":"PRODUCT_1.png","barcode":"","image":"","product_category_id":"","product_sub_category_id":"","company_id":"1","created_at":"2011-12-02 10:57:39","updated_at":"2011-12-02 10:57:39"}
 * 19) ** {"error":{"code":"100","message":"request is required and json formated"}}
 * 20) getProductImages - Obtain a Images of Product
 * 21) * method: method/getProductImages
 * 22) * params:
 * 23) ** id: numeric
 * 24) * returns: JSON Array of Product.
 * 25) * example responses:
 * 26) ** [{"id":"11","filename":"PRODUCT_IMAGE_1.png","extension":"png","size":"3000","location":"noxe","object_class":"Product","object_id":"1"},{"id":"12","filename":"PRODUCT_IMAGE_2.png","extension":"png","size":"3000","location":"noxe","object_class":"Product","object_id":"1"},{"id":"13","filename":"PRODUCT_IMAGE_3.png","extension":"png","size":"3000","location":"noxe","object_class":"Product","object_id":"1"},{"id":"14","filename":"PRODUCT_IMAGE_4.png","extension":"png","size":"3000","location":"noxe","object_class":"Product","object_id":"1"},{"id":"15","filename":"PRODUCT_IMAGE_5.png","extension":"png","size":"3000","location":"noxe","object_class":"Product","object_id":"1"},{"id":"16","filename":"PRODUCT_IMAGE_6.png","extension":"png","size":"3000","location":"noxe","object_class":"Product","object_id":"1"},{"id":"17","filename":"PRODUCT_IMAGE_7.png","extension":"png","size":"3000","location":"noxe","object_class":"Product","object_id":"1"},{"id":"18","filename":"PRODUCT_IMAGE_8.png","extension":"png","size":"3000","location":"noxe","object_class":"Product","object_id":"1"},{"id":"19","filename":"PRODUCT_IMAGE_9.png","extension":"png","size":"3000","location":"noxe","object_class":"Product","object_id":"1"},{"id":"20","filename":"PRODUCT_IMAGE_10.png","extension":"png","size":"3000","location":"noxe","object_class":"Product","object_id":"1"}]
 * 27) ** {"error":{"code":"100","message":"request is required and json formated"}}
 * 28) getProductVideos - Obtain a Videos of Product.
 * 29) * method: method/getProductVideos
 * 30) * params:
 * 31) ** id: numeric
 * 32) * returns: JSON Array of Venue.
 * 33) * example responses:
 * 34) ** [{"id":"11","title":"AJUNTAMENT_VIDEO_1.png","url":"url video","description":"descripcio","object_class":"Product","object_id":"1"},{"id":"12","title":"AJUNTAMENT_VIDEO_2.png","url":"url video","description":"descripcio","object_class":"Product","object_id":"1"},{"id":"13","title":"AJUNTAMENT_VIDEO_3.png","url":"url video","description":"descripcio","object_class":"Product","object_id":"1"},{"id":"14","title":"AJUNTAMENT_VIDEO_4.png","url":"url video","description":"descripcio","object_class":"Product","object_id":"1"},{"id":"15","title":"AJUNTAMENT_VIDEO_5.png","url":"url video","description":"descripcio","object_class":"Product","object_id":"1"},{"id":"16","title":"AJUNTAMENT_VIDEO_6.png","url":"url video","description":"descripcio","object_class":"Product","object_id":"1"},{"id":"17","title":"AJUNTAMENT_VIDEO_7.png","url":"url video","description":"descripcio","object_class":"Product","object_id":"1"},{"id":"18","title":"AJUNTAMENT_VIDEO_8.png","url":"url video","description":"descripcio","object_class":"Product","object_id":"1"},{"id":"19","title":"AJUNTAMENT_VIDEO_9.png","url":"url video","description":"descripcio","object_class":"Product","object_id":"1"},{"id":"20","title":"AJUNTAMENT_VIDEO_10.png","url":"url video","description":"descripcio","object_class":"Product","object_id":"1"}]
 * 35) ** {"error":{"code":"100","message":"request is required and json formated"}}
 * 36) addChallengeMeToProduct - Create a new ChallengeMe
 * 37) * method: method/addChallengeMeToProduct
 * 38) * params:
 * 39) ** id: numeric
 * 40) * returns: JSON Array of Venue.
 * 41) * example responses:
 * 42) ** true
 * 43) ** {"error":{"code":"100","message":"request is required and json formated"}}

Challenge methods

 * 1) listChallenges - List challenges
 * 2) * method: method/listChallenges
 * 3) * params:
 * 4) ** near: string  REQUIRED
 * 5) ** state: numeric  REQUIRED
 * 6) ** prominent: numeric
 * 7) ** last: numeric
 * 8) ** search: string
 * 9) ** category: string
 * 10) ** offset: numeric
 * 11) * returns: JSON Array of challenges
 * 12) * Notice: near or state is required
 * 13) * example responses:
 * 14) getChallenge - Get challenge info
 * 15) * method: method/getChallenge
 * 16) * params:
 * 17) ** id: numeric (REQUIRED)
 * 18) * returns: JSON Challenge Array or error if not exists
 * 19) * example responses:
 * 20) ** {"id":"2","name":"Play and win 2","info":"Catch all the codes and win a cycle 2","private":false,"photo":"","qrfile":"","start_date":"0000-00-00","end_date":"0000-00-00","sent_emails":"0","challenge_type":"virtual_hunt","geolocalization_type":"","status":"active","company_id":"1","created_at":"2011-12-02 12:12:02","updated_at":"2011-12-02 12:12:02"}
 * 21) getUserChallenge - Get current user challenge if exists
 * 22) * method: method/getUserChallenge
 * 23) * params:
 * 24) ** id: numeric (REQUIRED)
 * 25) * returns: JSON User Challenge Array or JSON false if not exists
 * 26) * example responses:
 * 27) ** {"user_id":"1","challenge_id":"2","start":"2011-12-12","end":"","user_challenge_status":"started"}
 * 28) ** false
 * 29) startChallenge - User starts playing a challenge
 * 30) * method: method/startChallenge
 * 31) * params:
 * 32) ** id: numeric (REQUIRED)
 * 33) * returns: JSON User Challenge Array or error if not exists
 * 34) * example responses:
 * 35) ** {"user_id":"1","challenge_id":"2","start":"2011-12-12","end":"","user_challenge_status":"started"}
 * 36) ** {"error":{"code":"201","message":"UserChallenge is finished"}}
 * 37) getSteps - Get challenge steps info
 * 38) * method: method/getSteps
 * 39) * params:
 * 40) ** id: numeric (REQUIRED)
 * 41) * returns: JSON Steps Array or error if not exists
 * 42) * example responses:
 * 43) ** [{"id":"4","name":"Step 1","position":"1","challenge_id":"2","created_at":"2011-12-12 09:40:58","updated_at":"2011-12-12 09:40:58"},{"id":"5","name":"Step 2","position":"2","challenge_id":"2","created_at":"2011-12-12 09:40:58","updated_at":"2011-12-12 09:40:58"}]
 * 44) ** {"error":{"code":"201","message":"Challenge is not found or is not active"}}
 * 45) getUserStep - Get user challenge step info to check it is alreadey done, started, ...
 * 46) * method: method/getUserStep
 * 47) * params:
 * 48) ** step_id: numeric (REQUIRED)
 * 49) * returns: JSON User Step or error if not exists
 * 50) * example responses:
 * 51) ** {"user_id":"1","step_id":4,"step_status":"started"}
 * 52) ** {"error":{"code":"201","message":"User step not exists"}}
 * 53) startStep - Start user step
 * 54) * method: method/startStep
 * 55) * params:
 * 56) ** step_id: numeric (REQUIRED)
 * 57) * returns: JSON User Step or error
 * 58) * example responses:
 * 59) ** {"user_id":"1","step_id":4,"step_status":"started"}
 * 60) ** {"error":{"code":"201","message":"User challenge is not created"}}
 * 61) endStep - Close user step (closes user challenge and generates user reward when needed)
 * 62) * method: method/endStep
 * 63) * params:
 * 64) ** step_id: numeric (REQUIRED)
 * 65) * returns: JSON User Step or error
 * 66) * example responses:
 * 67) ** {"user_id":"1","step_id":"4","step_status":"finished","Step":{"id":"4","name":"Step 1","position":"1","challenge_id":"2","created_at":"2011-12-12 10:42:45","updated_at":"2011-12-12 10:42:45","Challenge":{"id":"2","name":"Play and win 2","info":"Catch all the codes and win a cycle 2","private":false,"photo":"","qrfile":"","start_date":"0000-00-00","end_date":"0000-00-00","sent_emails":"0","challenge_type":"virtual_hunt","geolocalization_type":"","status":"active","company_id":"1","created_at":"2011-12-12 10:42:41","updated_at":"2011-12-12 10:42:41","Reward":{"id":"1","name":"Climb harness - Reward challenge 2","description":"This harness is very light and comfortable ... scan the codes and win","image":"","reward_type":"coupon","redemption_type":"code","redemption_location":"","payment_method_type":"type1","reward_limit":"1","reward_real_limit":"1","challenge_id":"2","product_id":"","created_at":"2011-12-12 10:42:45","updated_at":"2011-12-12 10:42:45"}}}}
 * 68) getChallengeReward - Get challenge reward info
 * 69) * method: method/getChallengeReward
 * 70) * params:
 * 71) ** id: numeric (REQUIRED)
 * 72) * returns: JSON Reward array or error
 * 73) * example responses:
 * 74) ** {"id":"1","name":"Climb harness - Reward challenge 2","description":"This harness is very light and comfortable ... scan the codes and win","image":"","reward_type":"coupon","redemption_type":"code","redemption_location":"","payment_method_type":"type1","reward_limit":"1","reward_real_limit":"1","challenge_id":"2","venue_id":"","product_id":"","created_at":"2011-12-12 10:42:45","updated_at":"2011-12-12 10:42:45"}
 * 75) getUserChallengeReward - Get user challenge reward info
 * 76) * method: method/getUserChallengeReward
 * 77) * params:
 * 78) ** id: numeric (REQUIRED)
 * 79) * returns: JSON User Reward array or false if the user does not have pending reward
 * 80) * example responses:
 * 81) ** {"id":"1","reward_id":"1","user_id":"1","user_reward_status":"pending","expire_at":""}
 * 82) ** {"error":{"code":"201","message":"Reward is not found"}}
 * 83) ** {"error":{"code":"201","message":"Reward already reedemed"}}
 * 84) redeem - Redeem user reward
 * 85) * method: method/redeem
 * 86) * params:
 * 87) ** id: numeric (REQUIRED)
 * 88) * returns: JSON User Reward array or false if the user does not have pending reward
 * 89) * example responses:
 * 90) ** {"id":"1","reward_id":"1","user_id":"1","user_reward_status":"reedemed","expire_at":""}
 * 91) ** {"error":{"code":"201","message":"User reward already reedemed"}}
 * 92) checkQuestionAnswer - Check user question answer and saves user answers
 * 93) * method: method/checkQuestionAnswer
 * 94) * params:
 * 95) ** step_id: numeric (REQUIRED)
 * 96) ** answer: string (REQUIRED)
 * 97) * returns: JSON User Question Response if already resplyed, JSON True if the answer is correct or JSON false if not. JSON error if the question step not exists.
 * 98) * example responses:
 * 99) ** true
 * 100) ** false
 * 101) ** {"error":{"code":"201","message":"Question step not exists"}}
 * 102) validateScanQr - Validate a scanned QR on scan challenge  -> It automagically close step when correct response
 * 103) * method: method/validateScanQr
 * 104) * params:
 * 105) ** step_id: numeric (REQUIRED)
 * 106) ** url: string (REQUIRED)
 * 107) * returns: JSON True if the URL is correct or JSON false if not. JSON error if the question step not exists.
 * 108) * example responses:
 * 109) ** true
 * 110) ** false
 * 111) ** {"error":{"code":"201","message":"Question step not exists"}}
 * 1) ** {"error":{"code":"201","message":"Question step not exists"}}

Utilities methods

 * 1) getCountriesStatesCities - Get all countries, states and cities
 * 2) * method: method/getCountriesStatesCities
 * 3) * params:
 * 4) * returns: JSON array
 * 5) * example responses:
 * 6) checkChallengeMe - Check if object has challenge me
 * 7) * method: method/checkChallengeMe
 * 8) * params:
 * 9) ** id: numeric (REQUIRED)
 * 10) ** object: string (REQUIRED) Possibilities = Venue, Product, Company
 * 11) * returns: JSON true if already challenged, false if not. Error if object not exists
 * 12) * example responses:
 * 13) ** true
 * 14) ** false
 * 15) ** {"error":{"code":"100","message":"request is required and json formated"}}
 * 16) removeChallengeMe - Remove if object has challenge me
 * 17) * method: method/removeChallengeMe
 * 18) * params:
 * 19) ** id: numeric (REQUIRED)
 * 20) ** object: string (REQUIRED) Possibilities = Venue, Product, Company
 * 21) * returns: JSON true
 * 22) * example responses:
 * 23) ** true
 * 24) ** {"error":{"code":"100","message":"request is required and json formated"}}
 * 25) countChallengeMe - Count object has challenge me
 * 26) * method: method/countChallengeMe
 * 27) * params:
 * 28) ** id: numeric (REQUIRED)
 * 29) ** object: string (REQUIRED) Possibilities = Venue, Product, Company
 * 30) * returns: JSON integer
 * 31) * example responses:
 * 32) ** false
 * 33) chekQr - Check if url contains a reference to a Challngr object
 * 34) * method: method/checkQr
 * 35) * params:
 * 36) ** url: string (REQUIRED)
 * 37) * returns: JSON Object array or error if could not find a Challngr object
 * 38) * example responses:
 * 39) ***  NOTE : What happens with old URLS ???
 * 40) explore - Add a explore to the object
 * 41) * method: method/explore
 * 42) * params:
 * 43) ** id: numeric (REQUIRED)
 * 44) ** object: string (REQUIRED) Possibilities = Venue, Product, Company, Challenge
 * 45) * returns: JSON true if already challenged, false if not. Error if object not exists
 * 46) * example responses:
 * 47) ** true
 * 48) ** {"error":{"code":"100","message":"request is required and json formated"}}
 * 1) * method: method/explore
 * 2) * params:
 * 3) ** id: numeric (REQUIRED)
 * 4) ** object: string (REQUIRED) Possibilities = Venue, Product, Company, Challenge
 * 5) * returns: JSON true if already challenged, false if not. Error if object not exists
 * 6) * example responses:
 * 7) ** true
 * 8) ** {"error":{"code":"100","message":"request is required and json formated"}}

Wallet methods

 * 1) Count challenge me done by user
 * 2) * method: method/getNumChallengeMe
 * 3) * params:
 * 4) * returns: JSON integer
 * 5) Get challenge me objects challenges
 * 6) * method: method/getChallengeMe
 * 7) * params:
 * 8) ** offset: 0 (default) # in multiples of 10 because the limit is 10
 * 9) * returns: JSON array with object challenged me
 * 10) Count started user challenges
 * 11) * method: method/getNumStartedChallenges
 * 12) * params:
 * 13) * returns: JSON integer
 * 14) Get unfinished user challenges
 * 15) * method: method/getStartedChallenges
 * 16) * params:
 * 17) ** offset: 0 (default) # in multiples of 10 because the limit is 10
 * 18) * returns: JSON Array of Challenges. Empty array if none.
 * 19) * exemple response:
 * 20) Count finished user challenges
 * 21) * method: method/getNumFinishedChallenges
 * 22) * params:
 * 23) * returns: JSON integer
 * 24) Get finished user challenges
 * 25) * method: method/getFinishedChallenges
 * 26) * params:
 * 27) ** offset: 0 (default) # in multiples of 10 because the limit is 10
 * 28) * returns: JSON Array of Challenges. Empty array if none.
 * 29) * exemple response:
 * 30) Get wallet count info
 * 31) * method: method/getWalletCountAsArray
 * 32) * params:
 * 33) * returns: JSON Array with numbers of challenges me, started challenges and finished challenges
 * 34) * exemple response:

FriendShare methods

 * 1) Get facebook message
 * 2) * method: method/getFacebookMessage
 * 3) * params:
 * 4) ** challenge_id: integer (REQUIRED)
 * 5) * returns: JSON String
 * 6) Get twitter message
 * 7) * method: method/getTwitterMessage
 * 8) * params:
 * 9) ** challenge_id: integer (REQUIRED)
 * 10) * returns: JSON String

Deal methods

 * 1) Get deal info
 * 2) * method: method/getDealInfo
 * 3) * params:
 * 4) ** reward_id: integer (REQUIRED)
 * 5) * returns: JSON Array or JSON string when there is an error (no deal info)
 * 6) Get user reward from challenge
 * 7) * method: method/getByChallenge
 * 8) * params:
 * 9) ** challenge_id: integer (REQUIRED)
 * 10) * returns: JSON Array or JSON string when there is an error
 * 11) Start deal transaction
 * 12) * method: method/startDealTransaction
 * 13) * params:
 * 14) ** user_reward_id: integer (REQUIRED)
 * 15) ** qty: integer (default 1)
 * 16) ** amount_paid: double
 * 17) ** payment_type: string ("paypal" for paypal, in future others)
 * 18) * returns: JSON array or JSON string on error.
 * 19) * example:
 * 20) End deal transaction
 * 21) * method: method/endDealTransaction
 * 22) * params:
 * 23) ** user_reward_id: integer (REQUIRED)
 * 24) ** deal_transaction_code: string (REQUIRED) -> Paypal or whatever system unique trasaction Id
 * 25) * returns: JSON array or JSON string on error
 * 26) * example:
 * 27) Get deal transaction data info
 * 28) * method: method/getDealTransactionInfo
 * 29) * params:
 * 30) ** user_reward_id: integer (REQUIRED)
 * 31) * returns: JSON array or JSON string on error
 * 32) * example:
 * 33) Get default or previous entered deal transaction send address data
 * 34) * method: method/getDealTransactionAddress
 * 35) * params:
 * 36) ** user_reward_id: integer (REQUIRED)
 * 37) * returns: JSON array with default user address data or JSON string on error
 * 38) * example:
 * 39) Set deal transaction send address data (ONLY NEEDED WHEN REWARD NEEDS ADDRESS INFO)
 * 40) * method: method/setDealTransactionAddress
 * 41) * params:
 * 42) ** user_reward_id: integer (REQUIRED)
 * 43) ** identifier: string (REQUIRED)
 * 44) ** name: string (REQUIRED)
 * 45) ** surname: string (REQUIRED)
 * 46) ** address: string (REQUIRED)
 * 47) ** city: string (REQUIRED)
 * 48) ** zip: number (REQUIRED)
 * 49) ** country: string (REQUIRED)
 * 50) * returns: JSON array or JSON string on error
 * 51) * example:
 * 1) ** zip: number (REQUIRED)
 * 2) ** country: string (REQUIRED)
 * 3) * returns: JSON array or JSON string on error
 * 4) * example:

Stats methods

 * 1) Adds a view to challenge
 * 2) * method: method/viewChallenge
 * 3) * params:
 * 4) ** challenge_id: integer (REQUIRED)
 * 5) * returns: JSON true if OK or JSON string when there is an error

Facebook login methods

 * 1) Check if user exists
 * 2) * method: method/userExists
 * 3) * params:
 * 4) ** email: string (REQUIRED)
 * 5) * returns: JSON true if user exists or JSON false if user not exists
 * 6) Login with facebook
 * 7) * method: method/validateUserFb
 * 8) * params:
 * 9) ** email: string (REQUIRED)
 * 10) ** password: string (if not specified and user is null it autogenerates one)
 * 11) ** name: string
 * 12) ** phone: string
 * 13) ** culture: string (example "es_ES")
 * 14) * returns: JSON array with user/hash data if OK or JSON string when there is an error
 * 15) * example:

Development notes
Challngr V2 is developed using git branches system on the branch called challngr_v2. To get a clean working copy of a branch you should do:


 * git clone git@github.com:surenso/Codishare-web.git yourprojectname
 * git branch --track challngr_v2 origin/challngr_v2
 * git checkout challngr_v2
 * git push origin challngr_v2