iReward REST API
Endpoint URL
All request should be sent to
http://beta.superghs.com/api
Request Pattern
Node List
GET /{node} HTTP/1.1
Return a list of node data.
Sample Request
GET /hotel HTTP/1.1
Node Data
GET /{node}/{node_id} HTTP/1.1
Return data set of the node.
Sample Request
GET /hotel/102 HTTP/1.1
Node Feature
GET /{node}/{node_id}/{feature} HTTP/1.1
Return information of a child node.
Sample Request
GET /hotel/103/promotion HTTP/1.1
Ouput Options
fields : field set for output data, seperated by comma.
format : format of output data, could be JSON or XML, default to JSON.
Sample Request
GET /hotel/102/?fields=id,name,logo&format=xml HTTP/1.1
Error Exception
Exception should be returned on unvalid request or runtime error
Example
{
"error": {
"code": "301",
"message": "Unvalid node request"
}
}
Appendix
GET ### HTTP/1.1
- /hotel/
- /hotel/{hotel_id}
- /hotel/{hotel_id}/promotion
- /hotel/{hotel_id}/product
- /member/{member_id}
- /member/{member_id}/reward
- /member/{member_id}/redeem
- /member/{member_id}/voucher
- /member/{member_id}/reservation
- /promotion/{promotion_id}
- /product/{product_id}
- /reward/{reward_id}
- /redeem/{redeem_id}
- /voucher/{voucher_id}
- /reservation/{reservation_id}
POST
- /auth
- /auth/facebook
- /auth/twitter
- /member/{member_id}/connect
- /member/{member_id}/subscription
Hotel
Hotel List
Request
GET /hotel/ HTTP/1.1
Sample response
{"data": [
{
"id": 102,
"name": "Rex Preferred Guest",
"logo": "http://beta.superghs.com/public/logo/234er.png"
},
{
"id": 103,
"name": "Caravelle Book & Win",
"logo": "http://beta.superghs.com/public/logo/23rfd.png"
},
{
"id": 104,
"name": "Centara 1 Card",
"logo": "http://beta.superghs.com/public/logo/fghy7.png"
},
...
]}
Hotel Information
Request
GET /hotel/{hotel_id} HTTP/1.1
Example Request
GET /hotel/103 HTTP/1.1
Sample response
{
"id": "103",
"name": "Cavarel Book & Win",
"logo": "http://beta.superghs.com/public/logo/fghy7.png",
"default_view": "dashboard",
"menu": [
{
"name": "dashboard",
"title": "Dashboard"
},
{
"name": "promotion",
"title": "Explore"
},
{
"name": "voucher",
"title": "Voucher Wallet"
},
...
]
}
Promotion
Retrieve promotion list of a hotel
GET /hotel/{hotel_id}/promotion HTTP/1.1
Sample request
GET /hotel/101/promotion HTTP/1.1
Sample response
{
"data": [
{
"id": "401",
"name": "Sassy promotion name",
"start_date": "2014-09-15",
"end_date": "2014-10-20",
"photo": "http://beta.superghs.com/resource/promotion/345fgg.jpg"
},
{
"id": "402",
"name": "Sassy promotion name",
"start_date": "2014-09-15",
"end_date": "2014-10-20",
"photo": "http://beta.superghs.com/resource/promotion/345fgg.jpg"
},
{
"id": "403",
"name": "Sassy promotion name",
"start_date": "2014-09-15",
"end_date": "2014-10-20",
"photo": "http://beta.superghs.com/resource/promotion/345fgg.jpg"
}
...
]
}
Retrive detail information of a promotion
GET /promotion/{promotion_id} HTTP/1.1
Sample request
GET /promotion/401 HTTP/1.1
Sample response
{
{
"id": "403",
"name": "Sassy promotion name",
"start_date": "2014-09-15",
"end_date": "2014-10-20",
"photo": "http://beta.superghs.com/resource/promotion/345fgg.jpg",
"description": "This is a sample desciption of sassy promotion"
}
}
Redeem product
Retrive product list of a hotel
GET /hotel/{hotel_id}/product HTTP/1.1
Sample request
GET /hotel/101/product HTTP/1.1
Sample response
{
"data": [
{
"id": "801"
"name": "Sassy product name",
"photo": "http://beta.superghs.com/resource/product/12asds.jpg"
"point": "250"
},
{
"id": "802"
"name": "Sassy product name",
"photo": "http://beta.superghs.com/resource/product/12asds.jpg"
"point": "250"
},
{
"id": "803"
"name": "Sassy product name",
"photo": "http://beta.superghs.com/resource/product/12asds.jpg"
"point": "250"
},
...
]
}
Detail information of a product
GET /product/{product_id} HTTP/1.1
Sample request
GET /product/801 HTTP/1.1
Sample response
{
"id": "803"
"name": "Sassy product name",
"photo": "http://beta.superghs.com/resource/product/12asds.jpg"
"point": "250",
"remain": "100"
}
Member
Member Information
GET /member/{member_id} HTTP/1.1
Sample Request
GET /member/202 HTTP/1.1
Sample response
{
"id": "202",
"name": " Jonh H. Smith",
"first_name": "Joth",
"last_name": "Smith",
"birthday": "1988-02-10",
"addresss": "Lorencia Road",
"city": "Noria City",
"country": "US",
"email": "vantiepnt@gmail.com"
"connect": [
{
"name": "facebook",
"id": "123456"
},
{
"name": "twitter",
"id": "987654"
},
...
],
"subscription": [
"monthly_resport",
"news_updates"
]
}
Update Member Information
Request
POST /member/{member_id} HTTP/1.1
Parameters
Parameter | Description | Type |
---|---|---|
name | Name on card | string |
birthday | Member's birhday | date |
Sample request
POST /member/202 HTTP/1.1
name: Tiep Nguyen
birthday: 1988-12-30
Sample response
{
"result": "success"
}
Change member email
POST /member/{member_id}/auth HTTP/1.1
email: {new email}
Change member password
POST /member/{member_id}/auth HTTP/1.1
old_password: {old password}
password: {new password}
Reward
Reward list of a member
GET /member/{member_id}/reward HTTP/1.1
Sample request
GET /member/202/reward HTTP/1.1
Sample response
{
"data": [
{
"id": "301",
"point": "90",
"update_time": "2014-09-30 06:30:00 GMT+7"
},
{
"id": "302",
"point": "90",
"update_time": "2014-09-30 06:30:00 GMT+7"
},
{
"id": "303",
"point": "90",
"update_time": "2014-09-30 06:30:00 GMT+7"
},
...
]
}
Retrieve detail information of a reward
GET /reward/{reward_id} HTTP/1.1
Sample request
GET /reward/301 HTTP/1.1
Sample response
{
"id": "303",
"point": "90",
"update_time": "2014-09-30 06:30:00 GMT+7",
"arrival_date": "2014-08-14",
"deprature_date": "2014-08-19",
"guest_name": "Joth Smith"
}
Redeem
Redeem list of a member
GET /member/{member_id}/redeem HTTP/1.1
Sample request
GET /member/201/redeem HTTP/1.1
Sample response
{
"data": [
{
"id": "501",
"point": "250",
"update_time": "2014-09-20 12:45:00 GMT+8"
},
{
"id": "502",
"point": "250",
"update_time": "2014-09-20 12:45:00 GMT+8"
},
{
"id": "503",
"point": "250",
"update_time": "2014-09-20 12:45:00 GMT+8"
},
...
]
}
Detail information of a redeem
GET /redeem/{redeem_id} HTTP/1.1
Sample request
GET /redeem/501 HTTP/1.1
Sample response
{
"id": "501",
"point": "250",
"product": "Sassy product name",
"quantity": "1",
"update_time": "2014-09-20 12:45:00 GMT+8"
}
Voucher
Voucher list of a member
GET /member/{member_id}/voucher HTTP/1.1
Sample request
GET /member/201/voucher HTTP/1.1
Sample response
{
"data": [
{
"id": "601",
"name": "Sassy voucher name",
"photo": "http://beta/superghs.com/resource/voucher/234dsfs.jpg",
"value": "50% Off"
},
{
"id": "602",
"name": "Sassy voucher name",
"photo": "http://beta/superghs.com/resource/voucher/234dsfs.jpg",
"value": "50% Off"
},
{
"id": "603",
"name": "Sassy voucher name",
"photo": "http://beta/superghs.com/resource/voucher/234dsfs.jpg",
"value": "50% Off"
},
...
]
}
Redeem a voucher
POST /voucher/{voucher_id} HTTP/1.1
action: redeem
code: {redemption_code}
Detail information of a voucher
GET /voucher/{voucher_id} HTTP/1.1
Sample request
GET /voucher/601 HTTP/1.1
Sample response
{
"id": "603",
"name": "Sassy voucher name",
"photo": "http://beta/superghs.com/resource/voucher/234dsfs.jpg",
"value": "50% Off",
"code": "IBE3456",
"expiry": "2014-10-30 00:00:00 GMT+8"
}
Reservation
Retrieve reservation list of a member
GET /member/{member_id}/reservation HTTP/1.1
Sample request
GET /member/201/reservation HTTP/1.1
Sample response
{
"data": [
{
"id": "701",
"code": "IBE3456",
"name": "Mr John Smith",
"arrival_date": "2014-09-12",
"departure_date": "2014-09-20"
},
{
"id": "702",
"code": "IBE3456",
"name": "Mr John Smith",
"arrival_date": "2014-09-12",
"departure_date": "2014-09-20"
},
{
"id": "703",
"code": "IBE3456",
"name": "Mr John Smith",
"arrival_date": "2014-09-12",
"departure_date": "2014-09-20"
},
...
]
}
Detail information of a reservation
GET /reservation/{reservation_id} HTTP/1.1
Sample request
GET /reservation/701 HTTP/1.1
Sample response
{
"id": "703",
"code": "IBE3456",
"name": "Mr John Smith",
"arrival_date": "2014-09-12",
"departure_date": "2014-09-20",
"rooms": "1",
"persons": "2",
"spent": "$134"
}
Authorization
Member login via email and password
POST /auth HTTP/1.1
username: {email address}
password: {password}
Sample request
POST /auth HTTP/1.1
username: tiep@myghs.com
password: 123456
Sample response
{
"result": "success",
"client_token": "1234567890"
}
Sample negative response
{
"result": "fail",
"error": {
"code": "001",
"message": "Wrong user or password"
}
}
Member connect via facebook account
POST /auth/facebook HTTP/1.1
access_token: {facebook access token}
Member connect via twitter account
POST /auth/twitter HTTP/1.1
access_token: {twitter access token}
Social connect
Social connect list of a member
GET /member/{member_id}/connect HTTP/1.1
Sample request
GET /member/201/connect HTTP/1.1
Sample response
{
"data": [
{
"name": "facebook",
"id": "123456789"
},
{
"name": "twitter",
"id": "123456789"
},
...
]
}
Add social connect to a member
POST /member/{member_id}/connect HTTP/1.1
name: {social name}
id: {social_id}
Sample request
POST /member/201/connect HTTP/1.1
name: facebook
id: 1234567890
Sample response
{
"result": "success"
}
sample negative response
{
"result": "fail",
"error": {
"code": "002",
"message": "Invalid facebook access token"
}
}
Remove a social connect of a member
DELETE /member/{member_id}/connect/{connection}
or alternative method for clients that does not support DELETE method
POST /member/{member_id}/connect/{connection} HTTP/1.1
method: delete
Subscription
Retrive subscription list of a member
GET /member/{member_id}/subscription HTTP/1.1
Sample request
GET /member/201/subscription HTTP/1.1
Sample response
{
"data": [
"monthly_resport",
"news_updates"
]
}
Update a subscription of a member
POST /member/{member_id}/subscription HTTP/1.1
{subscription}: {true/false}
Sample request
POST /member/{member_id}/subscription HTTP/1.1
monthly_report: true
Sample response
{
"result": "success"
}
Signin / Signup via Social Networks
POST /connect/{social_name} HTTP/1.1
access_token: {access_token}
Example
POST /connect/facebook HTTP/1.1
access_token: 123456
Result
{
"client_token: "123456abcdft"
}
Error message
{
"error": {
"code": 0,
"message": "Invalid facebook access token"
}
}