Validate and consume code
From ePrize Developers Wiki
(9 intermediate revisions not shown.) | |||
Line 1: | Line 1: | ||
- | <font style="color: red; font-style: italic;">Code Services API calls will not be available until September 2009.</font> | ||
{{RESTfulAPI | {{RESTfulAPI | ||
|crumbs=[[API Home Page]] :: [[Code Services]] | |crumbs=[[API Home Page]] :: [[Code Services]] | ||
- | |summary= | + | |summary=Code Services allows promotion builders to take advantage of HelloWorld's robust Code Services platform. When submitting a new promotion request, you may specify certain code configurations that will take effect in your promotion. These codes may be used for many different scenarios -- a code may be required on registration, for example, or a user may be awarded a game play if they give a valid code. The code configurations are quite extensible, please contact us if you have any questions. |
- | + | ||
+ | This resource will not respond correctly if your [[API Key]] is not configured for codes. | ||
+ | |resource=/v1/{apikey}/codes/{codeClass}/{code} | ||
+ | |methods=POST | ||
+ | |resourceargs='''apikey''': Your [[API Key]]. | ||
+ | |||
+ | '''codeClass''': there may be multiple code classes in an [[API Key]] | ||
+ | |||
+ | '''code''': the code provided by the user. | ||
+ | |paramsrequired=None. | ||
+ | |||
+ | ''Note: some user agents have trouble with blank POST request. Please try adding a name/value pair into the request representation if you you are having trouble (i.e. foo=bar)'' | ||
+ | }} | ||
{{RESTfulExample | {{RESTfulExample | ||
|title=Successfully Validate & Consume a Code | |title=Successfully Validate & Consume a Code | ||
|summary=This demonstrates successfully validating and consuming a code. | |summary=This demonstrates successfully validating and consuming a code. | ||
|request=profile: http://{client}.api.promo.eprize.com/v1/{apikey}/profile/{uid} | |request=profile: http://{client}.api.promo.eprize.com/v1/{apikey}/profile/{uid} | ||
- | codeClass: {codeClass} | ||
|responsecode=200 OK | |responsecode=200 OK | ||
|response=<?xml version="1.0" encoding="UTF-8" ?> | |response=<?xml version="1.0" encoding="UTF-8" ?> | ||
Line 16: | Line 25: | ||
<code>{code}</code> | <code>{code}</code> | ||
<codeClass>{codeClass}</codeClass> | <codeClass>{codeClass}</codeClass> | ||
- | <metadata>{metadata}</metadata> | ||
</codeResponse> | </codeResponse> | ||
</result> | </result> | ||
Line 32: | Line 40: | ||
</result> | </result> | ||
}} | }} | ||
+ | |||
{{RESTfulExample | {{RESTfulExample | ||
- | |title=Attempting to Validate & Consume a Code | + | |title=Attempting to Validate & Consume a Code that doesn't exist |
- | |summary=This demonstrates an unsuccessful attempt at validating & consuming a code | + | |summary=This demonstrates an unsuccessful attempt at validating & consuming a code that doesn't exist, or a code for a code class that doesn't exist. These scenarios both return the same error to avoid giving too much information to possibly malicious users. |
- | + | |responsecode=404 Not Found | |
- | + | ||
- | |responsecode= | + | |
|response=<?xml version="1.0" encoding="UTF-8"?> | |response=<?xml version="1.0" encoding="UTF-8"?> | ||
<result ver="1.0"> | <result ver="1.0"> | ||
- | <reason>The specified code | + | <reason>The specified code does not exist.</reason> |
</result> | </result> | ||
}} | }} | ||
+ | |||
+ | |||
{{RESTfulExample | {{RESTfulExample | ||
- | |title=Attempting to Validate & Consume a Code that | + | |title=Attempting to Validate & Consume a Code that has already been used |
- | |summary=This demonstrates an unsuccessful attempt at validating & consuming a code that | + | |summary=This demonstrates an unsuccessful attempt at validating & consuming a unique code that has already been used. |
- | |responsecode= | + | |responsecode=403 Permission Denied |
|response=<?xml version="1.0" encoding="UTF-8"?> | |response=<?xml version="1.0" encoding="UTF-8"?> | ||
<result ver="1.0"> | <result ver="1.0"> | ||
- | <reason>The specified code | + | <reason>The specified code has already been used.</reason> |
+ | </result> | ||
+ | }} | ||
+ | |||
+ | |||
+ | |||
+ | {{RESTfulExample | ||
+ | |title=Attempting to Validate & Consume a Code whose limit has been reached | ||
+ | |summary=This demonstrates an unsuccessful attempt at validating & consuming a code belonging to a class for which the limit has already been reached(e.g. "the user may enter up to 3 codes per day"). | ||
+ | |responsecode=403 Permission Denied | ||
+ | |response=<?xml version="1.0" encoding="UTF-8"?> | ||
+ | <result ver="1.0"> | ||
+ | <reason>The limit has been reached.</reason> | ||
</result> | </result> | ||
}} | }} |
Current revision
API Home Page :: Code Services
Summary
Code Services allows promotion builders to take advantage of HelloWorld's robust Code Services platform. When submitting a new promotion request, you may specify certain code configurations that will take effect in your promotion. These codes may be used for many different scenarios -- a code may be required on registration, for example, or a user may be awarded a game play if they give a valid code. The code configurations are quite extensible, please contact us if you have any questions.
This resource will not respond correctly if your API Key is not configured for codes.
Resource
/v1/{apikey}/codes/{codeClass}/{code}
Valid Methods
POST
Resource Arguments
Note: resource arguments are always required.
apikey: Your API Key.
codeClass: there may be multiple code classes in an API Key
code: the code provided by the user.
Parameters Required
None.
Note: some user agents have trouble with blank POST request. Please try adding a name/value pair into the request representation if you you are having trouble (i.e. foo=bar)
Example: Successfully Validate & Consume a Code
Summary
This demonstrates successfully validating and consuming a code.
Request
profile: http://{client}.api.promo.eprize.com/v1/{apikey}/profile/{uid}
Response
HTTP Status Code: 200 OK
<?xml version="1.0" encoding="UTF-8" ?> <result ver="1.0"> <codeResponse> <code>{code}</code> <codeClass>{codeClass}</codeClass> </codeResponse> </result>
Notes
The {profile} value that is seen in the request and response of this call is the canonical URL of the profile that the token should be awarded to.
Example: Attempting to Validate & Consume a Code with no Profile
Summary
This demonstrates an unsuccessful attempt at validating & consuming a code without providing a profile (or providing a bad one).
Request
profile: foo
Response
HTTP Status Code: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?> <result ver="1.0"> <reason>Unable to validate the provided profile.</reason> </result>
Example: Attempting to Validate & Consume a Code that doesn't exist
Summary
This demonstrates an unsuccessful attempt at validating & consuming a code that doesn't exist, or a code for a code class that doesn't exist. These scenarios both return the same error to avoid giving too much information to possibly malicious users.
Response
HTTP Status Code: 404 Not Found
<?xml version="1.0" encoding="UTF-8"?> <result ver="1.0"> <reason>The specified code does not exist.</reason> </result>
Example: Attempting to Validate & Consume a Code that has already been used
Summary
This demonstrates an unsuccessful attempt at validating & consuming a unique code that has already been used.
Response
HTTP Status Code: 403 Permission Denied
<?xml version="1.0" encoding="UTF-8"?> <result ver="1.0"> <reason>The specified code has already been used.</reason> </result>
Example: Attempting to Validate & Consume a Code whose limit has been reached
Summary
This demonstrates an unsuccessful attempt at validating & consuming a code belonging to a class for which the limit has already been reached(e.g. "the user may enter up to 3 codes per day").
Response
HTTP Status Code: 403 Permission Denied
<?xml version="1.0" encoding="UTF-8"?> <result ver="1.0"> <reason>The limit has been reached.</reason> </result>