{"__v":1,"_id":"56fc12900256470e005253ea","category":{"__v":5,"_id":"56cc10b7b4cbcf0b004a5df9","pages":["56cd503649abf10b0036a1f0","56cd585aa2a95b0b00c6ec0b","56cd591224f28913009575c4","56cd772dd98d851d00c0c447","56d5267b1c4de4130005d804"],"project":"56cacb1bc675f50b00a4b619","version":"56cacb1cc675f50b00a4b61c","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-23T07:56:39.448Z","from_sync":false,"order":1,"slug":"sdk","title":"PHP SDK"},"parentDoc":null,"project":"56cacb1bc675f50b00a4b619","user":"56caca84245b841300806def","version":{"__v":12,"_id":"56cacb1cc675f50b00a4b61c","project":"56cacb1bc675f50b00a4b619","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"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1"},"updates":[],"createdAt":"2016-03-30T17:53:20.796Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"Referral service provides a fully managed 3 step implementation of a otherwise complex referral system multiple. The configuration of this can be made in the CodeMojo dashboard\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"( AuthenticationService authenticationService )\",\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\\\\LoyaltyService;\\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$referralService = new ReferralService($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  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"getReferralCode\"\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** String **Throws** Exception, InvalidArgumentException\n\nGenerates a unique referral code for the provided user id\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 referral code needs to be generated\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"fn\",\n  \"title\": \"useReferralCode\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"(String user_id, String referral_code)\",\n      \"language\": \"java\",\n      \"name\": \"Signature\"\n    }\n  ]\n}\n[/block]\n**Returns** Boolean **Throws** Exception, InvalidArgumentException\n\nUse the generated referral code\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 which will be consuming the referral code\",\n    \"1-0\": \"referral_code\",\n    \"1-1\": \"String\",\n    \"1-2\": \"Referral code obtained from other users\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"markActivityComplete\"\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** Exception, InvalidArgumentException\n\nMark/Trigger the secondary flow for referral. This is usually in cases where User 2 has to complete a task for User 1 to received the referral commission\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 (User 2) which received & consumed the referral id generated by User 1\"\n  },\n  \"cols\": 3,\n  \"rows\": 1\n}\n[/block]","excerpt":"","slug":"referral-service","type":"basic","title":"Referral Service"}

Referral Service


Referral service provides a fully managed 3 step implementation of a otherwise complex referral system multiple. The configuration of this can be made in the CodeMojo dashboard [block:code] { "codes": [ { "code": "( AuthenticationService authenticationService )", "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\\LoyaltyService;\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$referralService = new ReferralService($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" }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "fn", "title": "getReferralCode" } [/block] [block:code] { "codes": [ { "code": "(String user_id)", "language": "java", "name": "Signature" } ] } [/block] **Returns** String **Throws** Exception, InvalidArgumentException Generates a unique referral code for the provided user id [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 referral code needs to be generated" }, "cols": 3, "rows": 1 } [/block] [block:api-header] { "type": "fn", "title": "useReferralCode" } [/block] [block:code] { "codes": [ { "code": "(String user_id, String referral_code)", "language": "java", "name": "Signature" } ] } [/block] **Returns** Boolean **Throws** Exception, InvalidArgumentException Use the generated referral code [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "user_id", "0-1": "String", "0-2": "User ID which will be consuming the referral code", "1-0": "referral_code", "1-1": "String", "1-2": "Referral code obtained from other users" }, "cols": 3, "rows": 2 } [/block] [block:api-header] { "type": "basic", "title": "markActivityComplete" } [/block] [block:code] { "codes": [ { "code": "(String user_id)", "language": "java", "name": "Signature" } ] } [/block] **Returns** Boolean **Throws** Exception, InvalidArgumentException Mark/Trigger the secondary flow for referral. This is usually in cases where User 2 has to complete a task for User 1 to received the referral commission [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "user_id", "0-1": "String", "0-2": "User ID (User 2) which received & consumed the referral id generated by User 1" }, "cols": 3, "rows": 1 } [/block]