Redeem token
From ePrize Developers Wiki
Line 1: | Line 1: | ||
- | + | {{RESTfulAPI | |
- | + | |crumbs=[[API Home Page]] :: [[Games and Awards]] | |
+ | |summary=TODO: Write me. | ||
+ | }} | ||
- | + | {{RESTfulExample | |
- | 200 OK | + | |title=Redeem Token / Earn Prize |
- | + | |summary=This demonstrates a good request to redeem a token that exists, and the user wins a prize as a result. | |
+ | |responsecode=200 OK | ||
+ | |response=<?xml version="1.0" encoding="UTF-8"?> | ||
+ | <result ver="ePrize Web Services 1.0"> | ||
+ | <result> | ||
+ | <token> | ||
+ | <id>{token}</id> | ||
+ | <profile>{profile}</profile> | ||
+ | <game>{game}</game> | ||
+ | <redeemed>true</redeemed> | ||
+ | <awards> | ||
+ | <prizes> | ||
+ | <prize>/v1/{apikey}/game/{game}/prize/{prize}</prize> | ||
+ | </prizes> | ||
+ | </awards> | ||
+ | </token> | ||
+ | </result> | ||
+ | <status>1</status> | ||
+ | </result> | ||
+ | }} | ||
+ | {{RESTfulExample | ||
+ | |title=Redeem Token / Earn New Token | ||
+ | |summary=This demonstrates a good request to redeem a token that exists, and the user wins another token as a result. | ||
+ | |responsecode=200 OK | ||
+ | |response=<?xml version="1.0" encoding="UTF-8"?> | ||
+ | <result ver="ePrize Web Services 1.0"> | ||
+ | <result> | ||
+ | <token> | ||
+ | <id>{token}</id> | ||
+ | <profile>{profile}</profile> | ||
+ | <game>{game}</game> | ||
+ | <redeemed>true</redeemed> | ||
+ | <awards> | ||
+ | <tokens> | ||
+ | <token>/v1/{apikey}/game/{game}/token/{token2}</prize> | ||
+ | </tokens> | ||
+ | </awards> | ||
+ | </token> | ||
+ | </result> | ||
+ | <status>1</status> | ||
+ | </result> | ||
+ | }} | ||
+ | |||
+ | {{RESTfulExample | ||
+ | |title=Redeem Token / Earn Nothing :( | ||
+ | |summary=This demonstrates a good request to redeem a token that exists, and the user wins nothing as a result. | ||
+ | |responsecode=200 OK | ||
+ | |response=<?xml version="1.0" encoding="UTF-8"?> | ||
+ | <result ver="ePrize Web Services 1.0"> | ||
+ | <result> | ||
+ | <token> | ||
+ | <id>{token}</id> | ||
+ | <profile>{profile}</profile> | ||
+ | <game>{game}</game> | ||
+ | <redeemed>true</redeemed> | ||
+ | <awards/> | ||
+ | </token> | ||
+ | </result> | ||
+ | <status>1</status> | ||
+ | </result> | ||
+ | }} | ||
+ | |||
+ | {{RESTfulExample | ||
+ | |title=Redeem Token That Doesn't Exist | ||
+ | |summary=This demonstrates a good request to redeem a token that doesn't exist. | ||
+ | |responsecode=404 Not Found | ||
+ | |response=<?xml version="1.0" encoding="UTF-8"?> | ||
+ | <result ver="ePrize Web Services 1.0"> | ||
+ | <result/> | ||
+ | <status>0</status> | ||
+ | </result> | ||
+ | }} | ||
+ | |||
+ | == Extra Notes == | ||
+ | A successful redemption changes the representation of the token. The list of awards is immediately available on the resource /v1/{apikey}/profile/{profile}/awards. Tokens awarded are available on the resource /v1/{apikey}/profile/{profile}/tokens until they are redeemed. | ||
+ | |||
+ | <pre> | ||
Response if request invalid: | Response if request invalid: | ||
400 Bad Request | 400 Bad Request | ||
Line 16: | Line 94: | ||
403 Forbidden | 403 Forbidden | ||
</pre> | </pre> | ||
- | |||
- | A successful redemption changes the representation of the token. This shows a redeemed token that resulted the awarding of a prize and a token to another game: | ||
- | |||
- | <pre>game:{game}, | ||
- | profile:{profile}, | ||
- | redeemed:true, | ||
- | awards: [ | ||
- | prizes: [ | ||
- | /v1/{apikey}/game/{game1}/prize/{prize}, | ||
- | ... | ||
- | ], | ||
- | tokens: [ | ||
- | /v1/{apikey}/game/{game2}/token/{token}, | ||
- | ... | ||
- | ] | ||
- | ] | ||
- | </pre> | ||
- | |||
- | A redeemed token that resulted in no awards: | ||
- | |||
- | <pre>game:{game}, | ||
- | profile:{profile}, | ||
- | redeemed:true, | ||
- | awards: [] | ||
- | </pre> | ||
- | |||
- | The list of awards is immediately available on the resource {profile}/awards. Tokens awarded are available on the resource {profile}/tokens until they are redeemed. |
Revision as of 18:54, 9 April 2009
API Home Page :: Games and Awards
Summary
TODO: Write me.
Example: Redeem Token / Earn Prize
Summary
This demonstrates a good request to redeem a token that exists, and the user wins a prize as a result.
Response
HTTP Status Code: 200 OK
<?xml version="1.0" encoding="UTF-8"?> <result ver="ePrize Web Services 1.0"> <result> <token> <id>{token}</id> <profile>{profile}</profile> <game>{game}</game> <redeemed>true</redeemed> <awards> <prizes> <prize>/v1/{apikey}/game/{game}/prize/{prize}</prize> </prizes> </awards> </token> </result> <status>1</status> </result>
Example: Redeem Token / Earn New Token
Summary
This demonstrates a good request to redeem a token that exists, and the user wins another token as a result.
Response
HTTP Status Code: 200 OK
<?xml version="1.0" encoding="UTF-8"?> <result ver="ePrize Web Services 1.0"> <result> <token> <id>{token}</id> <profile>{profile}</profile> <game>{game}</game> <redeemed>true</redeemed> <awards> <tokens> <token>/v1/{apikey}/game/{game}/token/{token2}</prize> </tokens> </awards> </token> </result> <status>1</status> </result>
Example: Redeem Token / Earn Nothing :(
Summary
This demonstrates a good request to redeem a token that exists, and the user wins nothing as a result.
Response
HTTP Status Code: 200 OK
<?xml version="1.0" encoding="UTF-8"?> <result ver="ePrize Web Services 1.0"> <result> <token> <id>{token}</id> <profile>{profile}</profile> <game>{game}</game> <redeemed>true</redeemed> <awards/> </token> </result> <status>1</status> </result>
Example: Redeem Token That Doesn't Exist
Summary
This demonstrates a good request to redeem a token that doesn't exist.
Response
HTTP Status Code: 404 Not Found
<?xml version="1.0" encoding="UTF-8"?> <result ver="ePrize Web Services 1.0"> <result/> <status>0</status> </result>
Extra Notes
A successful redemption changes the representation of the token. The list of awards is immediately available on the resource /v1/{apikey}/profile/{profile}/awards. Tokens awarded are available on the resource /v1/{apikey}/profile/{profile}/tokens until they are redeemed.
Response if request invalid: 400 Bad Request Entity body describing failed validations Response if token already redeemed: 405 Conflict Response if limit reached: 403 Forbidden