{"_id":"56d5267b1c4de4130005d804","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"},"user":"56caca84245b841300806def","parentDoc":null,"__v":7,"project":"56cacb1bc675f50b00a4b619","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"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-03-01T05:19:55.166Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":5,"body":"The configuration of this can be made in the CodeMojo dashboard\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"( AuthenticationService authenticationService, WalletService walletService )\",\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\\\\GamificationService;\\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$loyaltyService = new GamificationService($authService);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Parameters\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"authenticationService\",\n    \"0-1\": \"AuthenticationService\",\n    \"0-2\": \"An instance of authentication service. This also determines which server to connect to\",\n    \"1-0\": \"walletService\",\n    \"1-1\": \"WalletService\",\n    \"1-2\": \"An instance of wallet service.\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"addAchievements\"\n}\n[/block]\nSets the counter to the particular action id and also assigns an achievement badge if the criteria is met\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(String user_id, String action_id, String category_id)\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n**Returns** Array Object\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"New Badge Alert\",\n  \"body\": \"You will received a **new_bagde_earned** variable whenever a new badge is assigned\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"user_id\",\n    \"0-1\": \"String\",\n    \"0-2\": \"User ID to which the balance has to be added\",\n    \"1-0\": \"action_id\",\n    \"1-1\": \"String\",\n    \"1-2\": \"Action ID of the achievement performed by the user\",\n    \"2-0\": \"category_id\",\n    \"2-1\": \"String\",\n    \"2-2\": \"Group the achievement based on the based on the category id.\\n\\nUse this to create buckets for same or different types of categories under each achievement\"\n  },\n  \"cols\": 3,\n  \"rows\": 3\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Array\\n(\\n    [reader] => Array\\n        (\\n            [total] => 19\\n            [last_achieved] => 1466500747\\n        )\\n\\n    [adventurer] => Array\\n        (\\n            [total] => 9\\n            [last_achieved] => 1466500747\\n            [new_bagde_earned] => 1\\n        )\\n\\n)\",\n      \"language\": \"json\",\n      \"name\": \"Sample Output\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"getUserStatus\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(String user_id)\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n**Returns** Boolean **Throws** BalanceExhaustedException, Exception, InvalidArgumentException\n\nGet user gamification status\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"user_id\",\n    \"0-1\": \"String\",\n    \"0-2\": \"User ID for which the gamification status needs to be retrieved\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]","excerpt":"","slug":"gamification-service","type":"basic","title":"Gamification Service"}

Gamification Service


The configuration of this can be made in the CodeMojo dashboard [block:code] { "codes": [ { "code": "( AuthenticationService authenticationService, WalletService walletService )", "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\\GamificationService;\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$loyaltyService = new GamificationService($authService);", "language": "php" } ] } [/block] [block:api-header] { "type": "basic", "title": "Parameters" } [/block] [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "authenticationService", "0-1": "AuthenticationService", "0-2": "An instance of authentication service. This also determines which server to connect to", "1-0": "walletService", "1-1": "WalletService", "1-2": "An instance of wallet service." }, "cols": 3, "rows": 2 } [/block] [block:api-header] { "type": "fn", "title": "addAchievements" } [/block] Sets the counter to the particular action id and also assigns an achievement badge if the criteria is met [block:code] { "codes": [ { "code": "(String user_id, String action_id, String category_id)", "language": "java", "name": "Signature" } ] } [/block] **Returns** Array Object [block:callout] { "type": "info", "title": "New Badge Alert", "body": "You will received a **new_bagde_earned** variable whenever a new badge is assigned" } [/block] [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "user_id", "0-1": "String", "0-2": "User ID to which the balance has to be added", "1-0": "action_id", "1-1": "String", "1-2": "Action ID of the achievement performed by the user", "2-0": "category_id", "2-1": "String", "2-2": "Group the achievement based on the based on the category id.\n\nUse this to create buckets for same or different types of categories under each achievement" }, "cols": 3, "rows": 3 } [/block] [block:code] { "codes": [ { "code": "Array\n(\n [reader] => Array\n (\n [total] => 19\n [last_achieved] => 1466500747\n )\n\n [adventurer] => Array\n (\n [total] => 9\n [last_achieved] => 1466500747\n [new_bagde_earned] => 1\n )\n\n)", "language": "json", "name": "Sample Output" } ] } [/block] [block:api-header] { "type": "fn", "title": "getUserStatus" } [/block] [block:code] { "codes": [ { "code": "(String user_id)", "language": "java", "name": "Signature" } ] } [/block] **Returns** Boolean **Throws** BalanceExhaustedException, Exception, InvalidArgumentException Get user gamification status [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "user_id", "0-1": "String", "0-2": "User ID for which the gamification status needs to be retrieved" }, "cols": 3, "rows": 1 } [/block]