{"_id":"5835efc63165a52f0087784e","parentDoc":null,"project":"56cacb1bc675f50b00a4b619","user":"56caca84245b841300806def","version":{"_id":"56cacb1cc675f50b00a4b61c","project":"56cacb1bc675f50b00a4b619","__v":14,"createdAt":"2016-02-22T08:47:24.528Z","releaseDate":"2016-02-22T08:47:24.528Z","categories":["56cacb1dc675f50b00a4b61d","56cc10aaca43550b0028125a","56cc10b7b4cbcf0b004a5df9","56cc1bb2272aa4130002ccd2","56cc5834b4cbcf0b004a5f8b","56cda18bface161300dae13b","56d51f2873dcd20b00fb87bb","56fbe0610023171700b96105","57658310c176520e00ea9076","5772bdd48c48e00e00503638","577c1dfe87acf617003c3fcd","579525172979790e00771a15","582b4661cdfdc125000c8684","586365cedfe6cc3700a7be63"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1"},"category":{"_id":"56cc10b7b4cbcf0b004a5df9","project":"56cacb1bc675f50b00a4b619","__v":5,"pages":["56cd503649abf10b0036a1f0","56cd585aa2a95b0b00c6ec0b","56cd591224f28913009575c4","56cd772dd98d851d00c0c447","56d5267b1c4de4130005d804"],"version":"56cacb1cc675f50b00a4b61c","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-23T07:56:39.448Z","from_sync":false,"order":2,"slug":"sdk","title":"PHP SDK"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-11-23T19:36:38.857Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"You can either use the [PHP SDK](https://github.com/codemojo-dr/startkit-php-sdk/archive/master.zip)  or the **Composer plugin** as below\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Usage\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"require\\\": {\\n    \\\"codemojo/startkit\\\": \\\"0.1.*\\\"\\n  }\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Composer plugin\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(AuthenticationService authenticationService, YOUR_APP_ID)\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\n  use CodeMojo\\\\Client\\\\Endpoints;\\n  use CodeMojo\\\\Client\\\\Exceptions\\\\Exceptions;\\n  use CodeMojo\\\\Client\\\\Services\\\\AuthenticationService;\\n\\tuse CodeMojo\\\\Client\\\\Services\\\\RewardsService;\\n\\n\\n  const CLIENT_ID     = 'YOUR_CLIENT_ID';\\n  const CLIENT_SECRET = 'YOUR_CLIENT_SECRET';\\n\\n  $authService = new AuthenticationService(CLIENT_ID, CLIENT_SECRET, Endpoints::ENV_SANDBOX, function($type){\\n      // Handle the exceptions appropriately\\n  });\\n\\n\\t$rewardsService = new RewardsService($authService, YOUR_APP_ID);\\n\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"getAvailableRewards\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(String user_email_phone, Array filters = array())\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n**Returns** Array **Throws** Exception, InvalidArgumentException, RewardsExhaustedException\n\nGet available rewards\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"user_email_phone\",\n    \"0-1\": \"String\",\n    \"0-2\": \"Email ID of the user\",\n    \"1-0\": \"filters\",\n    \"1-1\": \"String Array\",\n    \"1-2\": \"Filters include **lat, lon, locale, testing**\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Array\\n(\\n    [0] => Array\\n        (\\n            [id] => \\n            [brand_name] => \\n            [logo] => \\n            [offer] => \\n            [value_formatted] => \\n            [value_numeric] => \\n            [fineprint] => \\n            [redemption_process] => \\n            [support] => \\n            [currency] => \\n            [value_ratio] =>\\n            [valid_till] => \\n        )\\n\\n    [1] => Array ..\\n    ..\\n    ..\\n    ..\\n)\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"grabReward\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Emails & SMS\",\n  \"body\": \"When your app is in Pending Approval / Testing mode, you won't receive any emails / sms when you grab rewards. Rest assured, these will start working when the app id has been moved to production page & testing flag has been removed\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(String customer_id, String deliver_to, String reward_id, Array additional_info = array())\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n**Returns** Array Object **Throws** Exception, InvalidArgumentException, RewardsExhaustedException\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"1-0\": \"deliver_to\",\n    \"1-1\": \"String\",\n    \"1-2\": \"Email / Phone communication channel where the reward is to be delivered to\",\n    \"2-0\": \"reward_id\",\n    \"2-1\": \"String\",\n    \"2-2\": \"ID of the reward to be grabbedThis co\",\n    \"3-0\": \"additional_details\",\n    \"3-1\": \"Array\",\n    \"3-2\": \"These include **lat, lon, locale, gender, age,\\ntesting, communicate**\",\n    \"0-0\": \"customer_id\",\n    \"0-1\": \"String\",\n    \"0-2\": \"Customer ID of the logged in user\"\n  },\n  \"cols\": 3,\n  \"rows\": 4\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Array\\n(\\n    [txn_id] => \\n    [coupon_code] => \\n    [brand_name] => \\n    [logo] => \\n    [title] => \\n    [fineprint] => \\n    [redemption_process] => \\n    [support] =>\\n)\",\n      \"language\": \"json\",\n      \"name\": \"Array Object\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Filter details\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Value\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"lat\",\n    \"0-1\": \"Double\",\n    \"0-2\": \"Latitude\",\n    \"1-0\": \"lon\",\n    \"2-0\": \"locale\",\n    \"3-0\": \"testing\",\n    \"4-0\": \"communicate\",\n    \"5-0\": \"gender\",\n    \"6-0\": \"age\",\n    \"1-1\": \"Double\",\n    \"1-2\": \"Longitude\",\n    \"2-1\": \"String\",\n    \"2-2\": \"Short code country format. Example IN, US, GB\",\n    \"3-1\": \"Int\",\n    \"3-2\": \"**1** to indicate testing **0** to indicate production\",\n    \"4-2\": \"1 to indicate auto send communication about the Reward to the user via email/sms to the user - 0 for otherwise\",\n    \"5-2\": \"Optional user detail\",\n    \"6-2\": \"Optional user detail\",\n    \"4-1\": \"Int\",\n    \"5-1\": \"String\",\n    \"6-1\": \"Int\"\n  },\n  \"cols\": 3,\n  \"rows\": 7\n}\n[/block]\n## [Callback & Web hooks](http://docs.codemojo.io/docs/grab-a-reward#webhook-callback)","excerpt":"","slug":"rewards-service","type":"basic","title":"Rewards Service"}

Rewards Service


You can either use the [PHP SDK](https://github.com/codemojo-dr/startkit-php-sdk/archive/master.zip) or the **Composer plugin** as below [block:api-header] { "type": "basic", "title": "Usage" } [/block] [block:code] { "codes": [ { "code": "{\n \"require\": {\n \"codemojo/startkit\": \"0.1.*\"\n }\n}", "language": "json", "name": "Composer plugin" } ] } [/block] [block:code] { "codes": [ { "code": "(AuthenticationService authenticationService, YOUR_APP_ID)", "language": "java", "name": "Signature" } ] } [/block] [block:code] { "codes": [ { "code": "<?php\n\n use CodeMojo\\Client\\Endpoints;\n use CodeMojo\\Client\\Exceptions\\Exceptions;\n use CodeMojo\\Client\\Services\\AuthenticationService;\n\tuse CodeMojo\\Client\\Services\\RewardsService;\n\n\n const CLIENT_ID = 'YOUR_CLIENT_ID';\n const CLIENT_SECRET = 'YOUR_CLIENT_SECRET';\n\n $authService = new AuthenticationService(CLIENT_ID, CLIENT_SECRET, Endpoints::ENV_SANDBOX, function($type){\n // Handle the exceptions appropriately\n });\n\n\t$rewardsService = new RewardsService($authService, YOUR_APP_ID);\n", "language": "php" } ] } [/block] [block:api-header] { "type": "fn", "title": "getAvailableRewards" } [/block] [block:code] { "codes": [ { "code": "(String user_email_phone, Array filters = array())", "language": "java", "name": "Signature" } ] } [/block] **Returns** Array **Throws** Exception, InvalidArgumentException, RewardsExhaustedException Get available rewards [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "user_email_phone", "0-1": "String", "0-2": "Email ID of the user", "1-0": "filters", "1-1": "String Array", "1-2": "Filters include **lat, lon, locale, testing**" }, "cols": 3, "rows": 2 } [/block] [block:code] { "codes": [ { "code": "Array\n(\n [0] => Array\n (\n [id] => \n [brand_name] => \n [logo] => \n [offer] => \n [value_formatted] => \n [value_numeric] => \n [fineprint] => \n [redemption_process] => \n [support] => \n [currency] => \n [value_ratio] =>\n [valid_till] => \n )\n\n [1] => Array ..\n ..\n ..\n ..\n)", "language": "text" } ] } [/block] [block:api-header] { "type": "fn", "title": "grabReward" } [/block] [block:callout] { "type": "info", "title": "Emails & SMS", "body": "When your app is in Pending Approval / Testing mode, you won't receive any emails / sms when you grab rewards. Rest assured, these will start working when the app id has been moved to production page & testing flag has been removed" } [/block] [block:code] { "codes": [ { "code": "(String customer_id, String deliver_to, String reward_id, Array additional_info = array())", "language": "java", "name": "Signature" } ] } [/block] **Returns** Array Object **Throws** Exception, InvalidArgumentException, RewardsExhaustedException [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "1-0": "deliver_to", "1-1": "String", "1-2": "Email / Phone communication channel where the reward is to be delivered to", "2-0": "reward_id", "2-1": "String", "2-2": "ID of the reward to be grabbedThis co", "3-0": "additional_details", "3-1": "Array", "3-2": "These include **lat, lon, locale, gender, age,\ntesting, communicate**", "0-0": "customer_id", "0-1": "String", "0-2": "Customer ID of the logged in user" }, "cols": 3, "rows": 4 } [/block] [block:code] { "codes": [ { "code": "Array\n(\n [txn_id] => \n [coupon_code] => \n [brand_name] => \n [logo] => \n [title] => \n [fineprint] => \n [redemption_process] => \n [support] =>\n)", "language": "json", "name": "Array Object" } ] } [/block] [block:api-header] { "type": "basic", "title": "Filter details" } [/block] [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Value", "h-2": "Description", "0-0": "lat", "0-1": "Double", "0-2": "Latitude", "1-0": "lon", "2-0": "locale", "3-0": "testing", "4-0": "communicate", "5-0": "gender", "6-0": "age", "1-1": "Double", "1-2": "Longitude", "2-1": "String", "2-2": "Short code country format. Example IN, US, GB", "3-1": "Int", "3-2": "**1** to indicate testing **0** to indicate production", "4-2": "1 to indicate auto send communication about the Reward to the user via email/sms to the user - 0 for otherwise", "5-2": "Optional user detail", "6-2": "Optional user detail", "4-1": "Int", "5-1": "String", "6-1": "Int" }, "cols": 3, "rows": 7 } [/block] ## [Callback & Web hooks](http://docs.codemojo.io/docs/grab-a-reward#webhook-callback)