# Coupon APIs
# Create Coupon Template API
Method: POST
Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/templates
Description: Create new template for a coupon, each coupon contains one template code (which is campaign code) and can have multiple coupon batches, each batch have multiple coupon codes.
There are 2 places to store coupon template information, one in coupon service, another one is in CMS service
- Scope:
- coupon.temp.c
- coupon.temp.a
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
Path Variable | ||||||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
Body | ||||||
campaignCode | Campaign code when we set up new coupon template | String | Y | PRO-20001 | ||
externalCampaignCode | Campaign code from the merchant who created by themselves | String | N | MERCHANT-00001 | ||
title | The campaign title | String | Y | TrueCoffee buy 1 get 1 for free | ||
description | The campaign description | String | N | Can be used before 6:00 PM | ||
termsAndConditions | Term and conditions for the campaign | String | N | Term & Conditions apply | ||
channel | The channel that coupon is going to sell. e.g TSM, WeMall | String | Y | WeMall | ||
price | The coupon price | Double | N | 100.0 | ||
priceUnit | The coupon price currency | String | N | THB, USD | ||
startDateTime | The coupon start date time. The coupon can't mark use before coupon template start date. | ZonedDateTime | Y | 2020-01-01T00:00:00.088Z | ||
endDateTime | The coupon end date time. The coupon can't mark use after coupon template end date. | ZonedDateTime | Y | 2020-02-01T00:00:00.088Z | ||
icon | An Icon for display on TSM appplication which is public file. It's store on CMS. | Object | N | | ||
image | An image for display on TSM application which is public file. It's store on CMS. | Object | N | | ||
owner | Map of merchantId, outletId, terminalId information | Map<String, Object> | Y | | ||
attributes | Map of custom attributes with arbitrary string keys and object values | Map<String, Object> | N | |
Example Request:
curl --location --request POST 'https://alpha-platform.weomni-test.com/coupon/api/projects/5de626d53d901d0001823a6a/coupons/templates' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJjbXMuY3QudyIsImNvdXBvbi50ZW1wLmEiLCJjb3Vwb24uYmF0Y2guYSIsImNvdXBvbi5jb2RlLmEiLCJjb3Vwb24uY29kZS5yIiwiY291cG9uLnRlbXAudSIsImNvdXBvbi50ZW1wLnIiLCJjb3Vwb24uY29kZS5jIiwiY291cG9uLnRlbXAuYyIsImNvdXBvbi5jb2RlLnUiLCJjbXMuY3QuKiJdLCJleHAiOjE1OTIyOTM1NTUsImlhdCI6MTU5MjI5Mjk1NSwianRpIjoiYzI0NWU1M2ItOTAzYi00Mjc0LTgyYzAtN2U3MDkxYTg5OWJlIiwiY2xpZW50X2lkIjoiY291cG9uX2ludGVybmFsIn0.VUcQkljrfkNMK5iTaGPLX3HJuSKJXy5rGKEy3tKAqW6OGsZSvhtOWq8BNMkMJURiUC-qd5gVZCk-Hm-9W3tdO-C-1HauA26GyD1WisF_iY_65tfCBtIlrkeikT0h9uK94FNistXIVHemnfnVzfV9_51ktf1eQU5pI36t0Q3KY47K2TMlEU7j3pwiP0EINq_oaHF29eqL7NEVtmptz-ivFqBTG8algmCmkqvLbofRkzc1WPKDkHjHpUM4gMSqx_Fkd5dUIox8kpvl1JxPGHkest6KKTe_oZmh-8I5dfq2cXc1PXrpuxmOeRJWlNI0hMZOB2wUFDR7Mkdv-SvK_9DF0Q' \
--data-raw '{
"image": {
"dataContentType": "image/jpeg",
"type": "PUBLIC_FILE",
"url": "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5e7072611d13bf0001f14de9/image.jpeg?version=0"
},
"icon": {
"dataContentType": "image/jpeg",
"type": "PUBLIC_FILE",
"url": "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5e7072611d13bf0001f14de9/image.jpeg?version=0"
},
"attributes": {
"status":"DRAFT"
},
"owner": {
"merchantId":"000001"
},
"channel": "TSM",
"description": "New customer can buy 1 and get 1 free",
"outletIdOwner": "00001",
"title": "Buy 1 get 1 free",
"endDateTime": "2021-01-01T00:00:00.088Z",
"productOriginalPriceAttribute": 20,
"termsAndConditions": "Apply for 00001",
"merchantIdOwner": "0361787",
"branchNameAttribute": "string",
"startDateTime":"2020-01-01T00:00:00.088Z",
"productSalePriceAttribute": 30,
"price":10,
"priceUnit": "THB",
"campaignCode": "WOLV-441",
"externalCampaignCode": "TEST-EX-01"
}'
Response Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
createdBy | The system will get auditing information from client id | String | Y | coupon-internal | ||
createdDate | Coupon template create date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.074Z | ||
lastModifiedBy | The system will get the lastest auditing information from client id | String | Y | coupon-internal | ||
lastModifiedDate | Coupon template last modified date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.904459Z | ||
id | This is mongo object id of coupon template in WeCoupon service. | String | Y | 5ee8768c7eeb510001874695 | ||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
campaignCode | Campaign code when we set up new coupon template | String | Y | PRO-20001 | ||
externalCampaignCode | Campaign code from the merchant who created by themselves | String | Y | MERCHANT-00001 | ||
title | The campaign title | String | Y | TrueCoffee buy 1 get 1 for free | ||
description | The campaign description | String | Y | Can be used before 6:00 PM | ||
contentId | This is mongo object id of coupon template content in CMS service. | String | Y | 5eaa55d11bee2b00019d7e27 | ||
termsAndConditions | Term and conditions for the campaign | String | Y | Term & Conditions apply | ||
channel | The channel that coupon is going to sell. e.g TSM, WeMall | String | Y | WeMall | ||
price | The coupon price | Double | Y | 100.0 | ||
priceUnit | The coupon price currency | String | Y | THB, USD | ||
startDateTime | The coupon start date time. The coupon can't mark use before coupon template start date. | ZonedDateTime | Y | 2020-01-01T00:00:00.088Z | ||
endDateTime | The coupon end date time. The coupon can't mark use after coupon template end date. | ZonedDateTime | Y | 2020-02-01T00:00:00.088Z | ||
icon | An Icon for display on TSM appplication which is public file. It's store on CMS. | String | Y | "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/image.jpeg?version=0" | ||
image | An image for display on TSM application which is public file. It's store on CMS. | String | Y | "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/image.jpeg?version=0" | ||
owner | Map of merchantId, outletId, terminalId information | Map<String, Object> | Y | | ||
attributes | Map of custom attributes with arbitrary string keys and object values | Map<String, Object> | Y | | ||
remark | The remark of coupon template | String | Y | coupon template remark |
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Create coupon template successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during create coupon template |
Example Response:
{
"createdBy": "coupon_internal",
"createdDate": "2020-06-16T07:36:44.074Z",
"lastModifiedBy": "coupon_internal",
"lastModifiedDate": "2020-06-16T07:36:44.904459Z",
"id": "5ee8768c7eeb510001874695",
"projectId": "5de626d53d901d0001823a6a",
"campaignCode": "WOLV-441",
"externalCampaignCode": "TEST-EX-01",
"channel": "TSM",
"title": "Buy 1 get 1 free",
"description": "New customer can buy 1 and get 1 free",
"termsAndConditions": "Apply for 00001",
"contentId": "5ee8768c08ad020001a2a2a8",
"startDateTime": "2020-01-01T00:00:00.088Z",
"endDateTime": "2021-01-01T00:00:00.088Z",
"owner": {
"merchantId": "000001"
},
"price": 10.0,
"priceUnit": "THB",
"attributes": {
"status": "DRAFT"
},
"image": "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/image.jpeg?version=0",
"icon": "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/icon.jpeg?version=0",
"remark": null
}
Example Response for error cases:
{
"entityName": "CouponTemplate",
"errorKey": "COUPON_TEMPLATE_CREATE_ERROR",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Error during create coupon template. Please retry",
"status": 404,
"message": "error.COUPON_TEMPLATE_CREATE_ERROR",
"params": "CouponTemplate"
}
# Create Coupon Batch And Generate Coupon Codes API
Method: POST
Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/templates/{templateCode}/codes
Description: Create a new batch for a coupon template and generate coupon codes for that batch. One coupon template can have multiple batches
When create a batch, we can specify option for generating coupon codes by the system or import coupon codes from CSV file.
- Scope:
- coupon.code.c
- coupon.code.a
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body
Param | Description | Type | Required | Default | Example | ||
---|---|---|---|---|---|---|---|
Path Variable | |||||||
projectId | The project id when create a project on WePlatform | String | Y | . | 5de626d53d901d0001823a6a | ||
templateCode | Template code value is the same with campaign code | String | Y | . | PRO-20001 | ||
Body | |||||||
amount | Amount of coupon codes that you're want to generate | Integer | Y | . | 10 | ||
couponMaxUse | The number of coupons can be used per coupon. | Integer | N | 1 | 1 | ||
length | Length of coupon code | Integer | N | 8 | 10 | ||
remark | The remark of coupon batch | String | N | . | "generate 100 coupons" | ||
pattern | The pattern of coupon code | String | N | . | "" | ||
prefix | The prefix of coupon code | String | N | . | "" | ||
suffix | The suffix of coupon code | String | N | . | "" | ||
generatorOption | Character set for generating codes | Enum | N | NUMERIC | IMPORT | ||
couponCodeFile | CSV file convert to base64 | Object | N | . | | ||
generateCode | For generating code by the system can choose to generate immediately or not. | Boolean | N | true | true | ||
generatorType | Generate coupon codes by the system or import coupon codes from the CSV file.
| Enum | N | SYSTEM_GENERATOR | IMPORT |
Example Request:
curl --location --request POST 'https://alpha-platform.weomni-test.com/coupon/api/projects/5de626d53d901d0001823a6a/coupons/templates/PRIV-153887/codes' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJjbXMuY3QudyIsImNvdXBvbi50ZW1wLmEiLCJjb3Vwb24uYmF0Y2guYSIsImNvdXBvbi5jb2RlLmEiLCJjb3Vwb24uY29kZS5yIiwiY291cG9uLnRlbXAudSIsImNvdXBvbi50ZW1wLnIiLCJjb3Vwb24uY29kZS5jIiwiY291cG9uLnRlbXAuYyIsImNvdXBvbi5jb2RlLnUiLCJjbXMuY3QuKiJdLCJleHAiOjE1OTIzNjI2MTgsImlhdCI6MTU5MjM2MjAxOCwianRpIjoiNTA4Y2IzN2UtOTg4Mi00Y2ViLWI5ZmEtMGQxYmM2ZTFiYjk1IiwiY2xpZW50X2lkIjoiY291cG9uX2ludGVybmFsIn0.Abmy9L1hr2ukCKBY9_ytXbsU5LpwxrUhIvegg-zCcqU-8-Y9DyGVqY3KCdJmLjw8rdTrrXacXRAKE1k9dK8d-xfPKQDm_jB08H7xbKVI9WE14dvnenn6ezuLIeJQJtamcJpadAqQ-PKNLxhXlhl8uemGP0RsTyBwqgSxoSBLG4BSumUhi3vN8hrFzsTNY_wLrs_9EeQlk7oCbpQmfpm5XT44UPAfMe01q5EnbNLV9O5FsyyeYaf1pBqvC7trfa0BQ0_YBQ-EaxohKIuHgMfqH7etocVkbK2M71cX0j42RnY8D6AwgB0DNmbz4Xf4IxWMcucYs_pbN-Sx4FS9YDmvCg' \
--data-raw '{
"amount": 0,
"couponMaxUse": 1,
"length": 0,
"pattern":"",
"prefix": "",
"suffix": "",
"generatorOption": "IMPORT",
"couponCodeFile": {
"fileName":"testcsv.csv",
"data": "Y29kZSx1c3NkQ29kZQoxMDAwMDAxLCo4OTgqMDAwMDAxIwoxMDAwMDAyLCo4OTgqMDAwMDAyIwoxMDAwMDAzLCo4OTgqMDAwMDAxIwoxMDAwMDA0LCo4OTgqMDAwMDAyIwoxMDAwMDA1LCo4OTgqMDAwMDAxIwoxMDAwMDA2LCo4OTgqMDAwMDAyIwoxMDAwMDA3LCo4OTgqMDAwMDAxIwoxMDAwMDA4LCo4OTgqMDAwMDAyIwoxMDAwMDA5LCo4OTgqMDAwMDAxIwoxMDAwMDEwLCo4OTgqMDAwMDAyIwoxMDAwMDExLCo4OTgqMDAwMDAxIwoxMDAwMDEyLCo4OTgqMDAwMDAxIwoxMDAwMDEzLCo4OTgqMDAwMDAyIwoxMDAwMDE0LCo4OTgqMDAwMDAxIwoxMDAwMDE1LCo4OTgqMDAwMDAyIwoxMDAwMDE2LCo4OTgqMDAwMDAxIwoxMDAwMDE3LCo4OTgqMDAwMDAyIwoxMDAwMDE4LCo4OTgqMDAwMDAxIwoxMDAwMDE5LCo4OTgqMDAwMDAyIwoxMDAwMDIwLCo4OTgqMDAwMDAxIwoxMDAwMDIxLCo4OTgqMDAwMDAyIwoxMDAwMDIyLCo4OTgqMDAwMDAxIwoxMDAwMDIzLCo4OTgqMDAwMDAxIwoxMDAwMDI0LCo4OTgqMDAwMDAyIwoxMDAwMDI1LCo4OTgqMDAwMDAxIwoxMDAwMDI2LCo4OTgqMDAwMDAyIwoxMDAwMDI3LCo4OTgqMDAwMDAxIwoxMDAwMDI4LCo4OTgqMDAwMDAyIwoxMDAwMDI5LCo4OTgqMDAwMDAxIwoxMDAwMDMwLCo4OTgqMDAwMDAyIwoxMDAwMDMxLCo4OTgqMDAwMDAxIwoxMDAwMDMyLCo4OTgqMDAwMDAyIwoxMDAwMDMzLCo4OTgqMDAwMDAxIwoxMDAwMDM0LCo4OTgqMDAwMDAxIwoxMDAwMDM1LCo4OTgqMDAwMDAyIwoxMDAwMDM2LCo4OTgqMDAwMDAxIwoxMDAwMDM3LCo4OTgqMDAwMDAyIwoxMDAwMDM4LCo4OTgqMDAwMDAxIwoxMDAwMDM5LCo4OTgqMDAwMDAyIwoxMDAwMDQwLCo4OTgqMDAwMDAxIwoxMDAwMDQxLCo4OTgqMDAwMDAyIwoxMDAwMDQyLCo4OTgqMDAwMDAxIwoxMDAwMDQzLCo4OTgqMDAwMDAyIwoxMDAwMDQ0LCo4OTgqMDAwMDAxIwoxMDAwMDQ1LCo4OTgqMDAwMDAxIwoxMDAwMDQ2LCo4OTgqMDAwMDAyIwoxMDAwMDQ3LCo4OTgqMDAwMDAxIwoxMDAwMDQ4LCo4OTgqMDAwMDAyIwoxMDAwMDQ5LCo4OTgqMDAwMDAxIwoxMDAwMDUwLCo4OTgqMDAwMDAyIwoxMDAwMDUxLCo4OTgqMDAwMDAxIwoxMDAwMDUyLCo4OTgqMDAwMDAyIwoxMDAwMDUzLCo4OTgqMDAwMDAxIwoxMDAwMDU0LCo4OTgqMDAwMDAyIwoxMDAwMDU1LCo4OTgqMDAwMDAxIwoxMDAwMDU2LCo4OTgqMDAwMDAxIwoxMDAwMDU3LCo4OTgqMDAwMDAyIwoxMDAwMDU4LCo4OTgqMDAwMDAxIwoxMDAwMDU5LCo4OTgqMDAwMDAyIwoxMDAwMDYwLCo4OTgqMDAwMDAxIwoxMDAwMDYxLCo4OTgqMDAwMDAyIwoxMDAwMDYyLCo4OTgqMDAwMDAxIwoxMDAwMDYzLCo4OTgqMDAwMDAyIwoxMDAwMDY0LCo4OTgqMDAwMDAxIwoxMDAwMDY1LCo4OTgqMDAwMDAyIwoxMDAwMDY2LCo4OTgqMDAwMDAxIwoxMDAwMDY3LCo4OTgqMDAwMDAxIwoxMDAwMDY4LCo4OTgqMDAwMDAyIwoxMDAwMDY5LCo4OTgqMDAwMDAxIwoxMDAwMDcwLCo4OTgqMDAwMDAyIwoxMDAwMDcxLCo4OTgqMDAwMDAxIwoxMDAwMDcyLCo4OTgqMDAwMDAyIwoxMDAwMDczLCo4OTgqMDAwMDAxIwoxMDAwMDc0LCo4OTgqMDAwMDAyIwoxMDAwMDc1LCo4OTgqMDAwMDAxIwoxMDAwMDc2LCo4OTgqMDAwMDAyIwoxMDAwMDc3LCo4OTgqMDAwMDAxIwoxMDAwMDc4LCo4OTgqMDAwMDAxIwoxMDAwMDc5LCo4OTgqMDAwMDAyIwoxMDAwMDgwLCo4OTgqMDAwMDAxIwoxMDAwMDgxLCo4OTgqMDAwMDAyIwoxMDAwMDgyLCo4OTgqMDAwMDAxIwoxMDAwMDgzLCo4OTgqMDAwMDAyIwoxMDAwMDg0LCo4OTgqMDAwMDAxIwoxMDAwMDg1LCo4OTgqMDAwMDAyIwoxMDAwMDg2LCo4OTgqMDAwMDAxIwoxMDAwMDg3LCo4OTgqMDAwMDAyIwoxMDAwMDg4LCo4OTgqMDAwMDAxIwoxMDAwMDg5LCo4OTgqMDAwMDAxIwoxMDAwMDkwLCo4OTgqMDAwMDAyIwoxMDAwMDkxLCo4OTgqMDAwMDAxIwoxMDAwMDkyLCo4OTgqMDAwMDAyIwoxMDAwMDkzLCo4OTgqMDAwMDAxIwoxMDAwMDk0LCo4OTgqMDAwMDAyIwoxMDAwMDk1LCo4OTgqMDAwMDAxIwoxMDAwMDk2LCo4OTgqMDAwMDAyIwoxMDAwMDk3LCo4OTgqMDAwMDAxIwoxMDAwMDk4LCo4OTgqMDAwMDAyIwoxMDAwMDk5LCo4OTgqMDAwMDAxIwoxMDAwMTAwLCo4OTgqMDAwMDAxIw==",
"dataContentType": "text/csv",
"type": "CSV"
},
"generateCode":true,
"generatorType": "IMPORT"
}'
Response Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
createdBy | The system will get auditing information from client id | String | Y | coupon-internal | ||
createdDate | Coupon template create date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.074Z | ||
lastModifiedBy | The system will get the lastest auditing information from client id | String | Y | coupon-internal | ||
lastModifiedDate | Coupon template last modified date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.904459Z | ||
id | This is mongo object id of coupon template in WeCoupon service. | String | Y | 5e95315697abbc00018e56e3 | ||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
campaignCode | Campaign code when we set up new coupon template | String | Y | PRO-20001 | ||
externalCampaignCode | Campaign code from the merchant who created by themselves | String | Y | MERCHANT-00001 | ||
title | The campaign title | String | Y | TrueCoffee buy 1 get 1 for free | ||
description | The campaign description | String | Y | Can be used before 6:00 PM | ||
contentId | This is mongo object id of coupon template content in CMS service. | String | Y | 5eaa55d11bee2b00019d7e27 | ||
termsAndConditions | Term and conditions for the campaign | String | Y | Term & Conditions apply | ||
channel | The channel that coupon is going to sell. e.g TSM, WeMall | String | Y | WeMall | ||
price | The coupon price | Double | Y | 100.0 | ||
priceUnit | The coupon price currency | String | Y | THB, USD | ||
startDateTime | The coupon start date time. The coupon can't mark use before coupon template start date. | ZonedDateTime | Y | 2020-01-01T00:00:00.088Z | ||
endDateTime | The coupon end date time. The coupon can't mark use after coupon template end date. | ZonedDateTime | Y | 2020-02-01T00:00:00.088Z | ||
icon | An Icon for display on TSM appplication which is public file. It's store on CMS. | String | Y | "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/image.jpeg?version=0" | ||
image | An image for display on TSM application which is public file. It's store on CMS. | String | Y | "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/image.jpeg?version=0" | ||
owner | Map of merchantId, outletId, terminalId information | Map<String, Object> | Y | | ||
attributes | Map of custom attributes with arbitrary string keys and object values | Map<String, Object> | Y | | ||
batches | List of coupon batch that already generated. They were belong to that coupon template | Array | Y | |||
createdBy | The system will get auditing information from client id | String | Y | coupon-internal | ||
createdDate | Coupon template create date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.074Z | ||
lastModifiedBy | The system will get the lastest auditing information from client id | String | Y | coupon-internal | ||
lastModifiedDate | Coupon template last modified date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.904459Z | ||
id | This is mongo object id of coupon batch in WeCoupon service. | String | Y | 5ee9842d7eeb51000187469d | ||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
campaignCode | Campaign code when we set up new coupon template | String | Y | PRO-20001 | ||
templateId | This is mongo object id of coupon template in WeCoupon service. | String | Y | 5e95315697abbc00018e56e3 | ||
amount | Amount of coupon codes that you're want to generate. | Integer | Y | 100 | ||
couponMaxUse | The number of coupons can be used per coupon. | Integer | Y | 1 | ||
length | Length of coupon code | Integer | Y | 10 | ||
pattern | The pattern of coupon code | String | Y | "" | ||
prefix | The prefix of coupon code | String | Y | "" | ||
suffix | The suffix of coupon code | String | Y | "" | ||
remark | The remark of coupon batch | String | Y | "generate 100 coupons" | ||
generatorOption | Character set for generating codes | Enum | Y | IMPORT | ||
attributes | If you use generator option as "IMPORT", the CSV file name will display here. | Object | Y | | ||
startDateTime | The coupon start date time. The coupon can't mark use before coupon template start date. | ZonedDateTime | Y | 2020-01-01T00:00:00.088Z | ||
endDateTime | The coupon end date time. The coupon can't mark use after coupon template end date. | ZonedDateTime | Y | 2020-02-01T00:00:00.088Z | ||
systemStatus | The system status that indicate the coupon is generating or generated. | String | Y | ['GENERATING', 'GENERATED'] |
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Create coupon batch successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during create coupon batch |
Example Response:
{
"createdBy": "coupon_internal",
"createdDate": "2020-04-14T03:43:18.716Z",
"lastModifiedBy": "coupon_internal",
"lastModifiedDate": "2020-04-21T08:31:23.563Z",
"id": "5e95315697abbc00018e56e3",
"projectId": "5de626d53d901d0001823a6a",
"campaignCode": "PRIV-153887",
"channel": "TSM",
"title": "Buy 1 get 1 free",
"description": "New customer can buy 1 and get 1 free",
"termsAndConditions": "Apply for 00001",
"contentId": "5e9531565e5f600001bfe233",
"startDateTime": "2020-01-01T00:00:00.088Z",
"endDateTime": "2021-01-01T00:00:00.088Z",
"attributes": {
"type": "MEMBERSHIP_REWARD",
"status": "APPROVED"
},
"image": "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5e9531565e5f600001bfe233/image.jpeg?version=0",
"batches": [
{
"createdBy": "coupon_internal",
"createdDate": "2020-06-17T02:47:09.766125Z",
"lastModifiedBy": "coupon_internal",
"lastModifiedDate": "2020-06-17T02:47:09.766125Z",
"id": "5ee9842d7eeb51000187469d",
"projectId": "5de626d53d901d0001823a6a",
"campaignCode": "PRIV-153887",
"templateId": "5e95315697abbc00018e56e3",
"suffix": "",
"prefix": "",
"pattern": "",
"generatorOption": "IMPORT",
"length": 7,
"amount": 100,
"couponMaxUse": 1,
"attributes": {
"importedFileName": "testcsv.csv"
},
"remark": null,
"startDateTime": "2020-01-01T00:00:00.088Z",
"endDateTime": "2021-01-01T00:00:00.088Z",
"systemStatus": null
}
]
}
Example Response for error cases:
- Invalid file or format
{
"errorKey": "FILE_INVALID",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "File is invalid",
"status": 400,
"message": "error.FILE_INVALID",
"params": ""
}
- Coupon length is zero
{
"entityName": "CouponBatch",
"errorKey": "COUPON_CODE_LENGTH_ZERO",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Length of Coupon Code cannot be zero",
"status": 400,
"message": "error.COUPON_CODE_LENGTH_ZERO",
"params": "CouponBatch"
}
- Coupon template not found
{
"entityName": "CouponTemplate",
"errorKey": "COUPON_TEMPLATE_NOT_FOUND",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Coupon Template not found",
"status": 404,
"message": "error.COUPON_TEMPLATE_NOT_FOUND",
"params": "CouponTemplate"
}
# Update Coupon Template API
Method: PUT
Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/templates
Description: Update information of a coupon template. System will automatically update data into CMS system.
- Scope:
- coupon.temp.u
- coupon.temp.a
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
Path Variable | ||||||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
Body | ||||||
id | This is mongo object id of coupon template in WeCoupon service. | String | Y | 5e95315697abbc00018e56e3 | ||
campaignCode | Campaign code when we set up new coupon template | String | Y | PRO-20001 | ||
externalCampaignCode | Campaign code from the merchant who created by themselves | String | N | MERCHANT-00001 | ||
title | The campaign title | String | N | TrueCoffee buy 1 get 1 for free | ||
description | The campaign description | String | N | Can be used before 6:00 PM | ||
termsAndConditions | Term and conditions for the campaign | String | N | Term & Conditions apply | ||
channel | The channel that coupon is going to sell. e.g TSM, WeMall | String | N | WeMall | ||
price | The coupon price | Double | N | 100.0 | ||
priceUnit | The coupon price currency | String | N | THB, USD | ||
startDateTime | The coupon start date time. The coupon can't mark use before coupon template start date. | ZonedDateTime | N | 2020-01-01T00:00:00.088Z | ||
endDateTime | The coupon end date time. The coupon can't mark use after coupon template end date. | ZonedDateTime | N | 2020-02-01T00:00:00.088Z | ||
icon | An Icon for display on TSM appplication which is public file. It's store on CMS. | Object | N | | ||
image | An image for display on TSM application which is public file. It's store on CMS. | Object | N | | ||
owner | Map of merchantId, outletId, terminalId information | Map<String, Object> | N | | ||
attributes | Map of custom attributes with arbitrary string keys and object values | Map<String, Object> | N | | ||
remark | The remark of coupon template | String | N | coupon template remark updated |
Example Request:
curl --location --request PUT 'https://alpha-platform.weomni-test.com/coupon/api/projects/5de626d53d901d0001823a6a/coupons/templates' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJjbXMuY3QudyIsImNvdXBvbi50ZW1wLmEiLCJjb3Vwb24uYmF0Y2guYSIsImNvdXBvbi5jb2RlLmEiLCJjb3Vwb24uY29kZS5yIiwiY291cG9uLnRlbXAudSIsImNvdXBvbi50ZW1wLnIiLCJjb3Vwb24uY29kZS5jIiwiY291cG9uLnRlbXAuYyIsImNvdXBvbi5jb2RlLnUiLCJjbXMuY3QuKiJdLCJleHAiOjE1OTIzNjc5ODcsImlhdCI6MTU5MjM2NzM4NywianRpIjoiNzJhOTk1ZWYtMjhhYS00ZTNiLTg3MDQtZDk2NTQ4OWY2NGYzIiwiY2xpZW50X2lkIjoiY291cG9uX2ludGVybmFsIn0.ogRw9bxcpDfu2QYDQCJwrtrRDXJxTZBC3qe-_Lh6R7Czuvuf1X0AsuMNuX28foOHCncKxUS00y-ZTnlGHTh40GxnLd0-LRZqHiLDLg_ISFr8DuHxk9uwHjGsxP8e4sfXqzpegglA3XcQ8C6IirXTLjUfF7xIFuXSYRxlS7BlTMaE57p5sDkj6WzH-emxVZLu_1seRflGa_OZ9t56q7Xtww0JtHQqxTu5r8oveZD3JAz7AH2bv-yg5Eii_LwheVVP6wLcdsFRqsmQnxH-se1ENg0HWcNkObsRKyUuLIbtqkBXaYuR669BZ-CnWiPz8xHUL-QqG1pHttpHW2J8uShikA' \
--data-raw '{
"id":"5e95315697abbc00018e56e3",
"campaignCode": "PRIV-153887",
"title": "updated title",
"externalCampaignCode": "TEST-0001",
"description": "updated description",
"termsAndConditions": "updated termsAndConditions",
"price": 100,
"priceUnit": "THB",
"remark": "updated remark",
"attributes": {
"status": "APPROVED"
},
"channel": "TSM",
"startDateTime": "2020-01-01T00:00:00.088Z",
"endDateTime": "2021-01-01T00:00:00.088Z"
}'
Response Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
createdBy | The system will get auditing information from client id | String | Y | coupon-internal | ||
createdDate | Coupon template create date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.074Z | ||
lastModifiedBy | The system will get the lastest auditing information from client id | String | Y | coupon-internal | ||
lastModifiedDate | Coupon template last modified date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.904459Z | ||
id | This is mongo object id of coupon template in WeCoupon service. | String | Y | PRO-20001 | ||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
campaignCode | Campaign code when we set up new coupon template | String | Y | PRO-20001 | ||
externalCampaignCode | Campaign code from the merchant who created by themselves | String | Y | MERCHANT-00001 | ||
title | The campaign title | String | Y | TrueCoffee buy 1 get 1 for free | ||
description | The campaign description | String | Y | Can be used before 6:00 PM | ||
contentId | This is mongo object id of coupon template content in CMS service. | String | Y | 5eaa55d11bee2b00019d7e27 | ||
termsAndConditions | Term and conditions for the campaign | String | Y | Term & Conditions apply | ||
channel | The channel that coupon is going to sell. e.g TSM, WeMall | String | Y | WeMall | ||
price | The coupon price | Double | Y | 100.0 | ||
priceUnit | The coupon price currency | String | Y | THB, USD | ||
startDateTime | The coupon start date time. The coupon can't mark use before coupon template start date. | ZonedDateTime | Y | 2020-01-01T00:00:00.088Z | ||
endDateTime | The coupon end date time. The coupon can't mark use after coupon template end date. | ZonedDateTime | Y | 2020-02-01T00:00:00.088Z | ||
icon | An Icon for display on TSM appplication which is public file. It's store on CMS. | String | Y | "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/image.jpeg?version=0" | ||
image | An image for display on TSM application which is public file. It's store on CMS. | String | Y | "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/image.jpeg?version=0" | ||
owner | Map of merchantId, outletId, terminalId information | Map<String, Object> | Y | | ||
attributes | Map of custom attributes with arbitrary string keys and object values | Map<String, Object> | Y | | ||
remark | The remark of coupon template | String | Y | coupon template remark updated |
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Update coupon template successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during update coupon template |
Example Response:
{
"createdBy": "coupon_internal",
"createdDate": "2020-04-14T03:43:18.716Z",
"lastModifiedBy": "coupon_internal",
"lastModifiedDate": "2020-06-17T04:19:45.842027Z",
"id": "5e95315697abbc00018e56e3",
"projectId": "5de626d53d901d0001823a6a",
"campaignCode": "PRIV-153887",
"externalCampaignCode": "TEST-0001",
"channel": "TSM",
"title": "updated title",
"description": "updated description",
"termsAndConditions": "updated termsAndConditions",
"contentId": "5e9531565e5f600001bfe233",
"startDateTime": "2020-01-01T00:00:00.088Z",
"endDateTime": "2021-01-01T00:00:00.088Z",
"owner": null,
"price": 100.0,
"priceUnit": "THB",
"attributes": {
"status": "APPROVED"
},
"image": null,
"icon": null,
"remark": "updated remark"
}
Example Response for error cases:
{
"entityName": "CouponTemplate",
"errorKey": "COUPON_TEMPLATE_UPDATE_ERROR",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Error during update coupon template. Please retry",
"status": 404,
"message": "error.COUPON_TEMPLATE_UPDATE_ERROR",
"params": "CouponTemplate"
}
# Update Coupon Template Attributes API
Method: PUT
Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/templates/{templateCode}/attributes
Description: Update attributes of a coupon template, attributes must defined by BFF.
- Scope:
- coupon.temp.u
- coupon.temp.a
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
Path Variable | ||||||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
templateCode | Template code is equal to campaign code, get this value from when we set up new coupon template | String | Y | PRO-20001 | ||
Body | ||||||
attributes |
Dynamic attributes want to update or remove. To remove an existing attribute, set that attribute to null.
Data type of each attribute in attribute will be automatically convert to proper type based on the format provided. Note: For Date type, system will check and convert to ZonedDateTime if provided format match with yyyy-MM-dd'T'HH:mm:ss.SSSz | Object | Y | |
Example Request:
curl --location --request PUT 'https://alpha-platform.weomni-test.com/coupon/api/projects/5de626d53d901d0001823a6a/coupons/templates/TSM-00415/attributes' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJjbXMuY3QudyIsImNvdXBvbi50ZW1wLmEiLCJjb3Vwb24uYmF0Y2guYSIsImNvdXBvbi5jb2RlLmEiLCJjb3Vwb24uY29kZS5yIiwiY291cG9uLnRlbXAudSIsImNvdXBvbi50ZW1wLnIiLCJjb3Vwb24uY29kZS5jIiwiY291cG9uLnRlbXAuYyIsImNvdXBvbi5jb2RlLnUiLCJjbXMuY3QuKiJdLCJleHAiOjE1OTIzNzEyMDcsImlhdCI6MTU5MjM3MDYwNywianRpIjoiNmFiMzY4YTktMDMyNC00YTkwLTgxZDUtZjRiM2JkOGFhOWY3IiwiY2xpZW50X2lkIjoiY291cG9uX2ludGVybmFsIn0.mrvzSKEFY5f5BvUfgZFaGx9UystieZ-7EBBQcJm0qU8ENgX3-sPEAn_UPTvHDUtq7vwbCto_l5VaykJIGyea8ClreIIPhlQrDIrV6AeDf9MwOg6tfjyEJa_NJiOfKVDGpWVqs17vuDhKAEmCChBevHujt5vqvuWbZhWc6dtxw6Qal5LKxpmxqrFd_WLy5Hkb9MarAb6DvUOh217tnmkmNywABsvxAz-CvrC2GWDGuptOBYwqY25bjaxEecgG9ZGp2AdwqF7b-jbq7fqwQlmiBfjs4YXGGpDgIqYZm1P4_BAZR3WNDG-NnEqyo2ebu3542QDo0ECTIq_zu_ZcnVxjIQ' \
--data-raw '{
"attributes": {
"status": "APPROVED"
}
}'
Response Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
createdBy | The system will get auditing information from client id | String | Y | coupon-internal | ||
createdDate | Coupon template create date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.074Z | ||
lastModifiedBy | The system will get the lastest auditing information from client id | String | Y | coupon-internal | ||
lastModifiedDate | Coupon template last modified date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.904459Z | ||
id | This is mongo object id of coupon template in WeCoupon service. | String | Y | 5ee8768c7eeb510001874695 | ||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
campaignCode | Campaign code when we set up new coupon template | String | Y | PRO-20001 | ||
externalCampaignCode | Campaign code from the merchant who created by themselves | String | Y | MERCHANT-00001 | ||
title | The campaign title | String | Y | TrueCoffee buy 1 get 1 for free | ||
description | The campaign description | String | Y | Can be used before 6:00 PM | ||
contentId | This is mongo object id of coupon template content in CMS service. | String | Y | 5eaa55d11bee2b00019d7e27 | ||
termsAndConditions | Term and conditions for the campaign | String | Y | Term & Conditions apply | ||
channel | The channel that coupon is going to sell. e.g TSM, WeMall | String | Y | WeMall | ||
price | The coupon price | Double | Y | 100.0 | ||
priceUnit | The coupon price currency | String | Y | THB, USD | ||
startDateTime | The coupon start date time. The coupon can't mark use before coupon template start date. | ZonedDateTime | Y | 2020-01-01T00:00:00.088Z | ||
endDateTime | The coupon end date time. The coupon can't mark use after coupon template end date. | ZonedDateTime | Y | 2020-02-01T00:00:00.088Z | ||
icon | An Icon for display on TSM appplication which is public file. It's store on CMS. | String | Y | "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/image.jpeg?version=0" | ||
image | An image for display on TSM application which is public file. It's store on CMS. | String | Y | "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/image.jpeg?version=0" | ||
owner | Map of merchantId, outletId, terminalId information | Map<String, Object> | Y | | ||
attributes | Map of custom attributes with arbitrary string keys and object values | Map<String, Object> | Y | | ||
remark | The remark of coupon template | String | Y | coupon template remark |
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Update coupon template attributes successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during update coupon template attributes |
Example Response:
{
"createdBy": "coupon_internal",
"createdDate": "2020-04-14T03:43:18.716Z",
"lastModifiedBy": "coupon_internal",
"lastModifiedDate": "2020-06-17T04:19:45.842027Z",
"id": "5e95315697abbc00018e56e3",
"projectId": "5de626d53d901d0001823a6a",
"campaignCode": "PRIV-153887",
"externalCampaignCode": "TEST-0001",
"channel": "TSM",
"title": "updated title",
"description": "updated description",
"termsAndConditions": "updated termsAndConditions",
"contentId": "5e9531565e5f600001bfe233",
"startDateTime": "2020-01-01T00:00:00.088Z",
"endDateTime": "2021-01-01T00:00:00.088Z",
"owner": null,
"price": 100.0,
"priceUnit": "THB",
"attributes": {
"status": "APPROVED"
},
"image": null,
"icon": null,
"remark": "updated remark"
}
Example Response for error cases:
- Coupon template Not found
{
"entityName": "CouponTemplate",
"errorKey": "COUPON_TEMPLATE_NOT_FOUND",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Coupon Template not found",
"status": 404,
"message": "error.COUPON_TEMPLATE_NOT_FOUND",
"params": "CouponTemplate"
}
# Update Coupon Batch Attributes API
Method: PUT
Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/batch/{batchId}/attributes
Description: Update attributes for a coupon batch
- Scope:
- coupon.batch.u
- coupon.batch.a
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
Path Variable | ||||||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
batchId | This is mongo object id of coupon batch in WeCoupon service. | String | Y | 5ee98def7eeb51000187469f | ||
Body | ||||||
attributes | Dynamic attributes want to update or remove. To remove an existing attribute, set that attribute to null. | Object | Y | |
Example Request:
curl --location --request PUT 'https://alpha-platform.weomni-test.com/coupon/api/projects/5cfa27bc2c97280001d40765/coupons/batch/5e68a3ea84b4ce0001192883/attributes' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJjbXMuY3QudyIsImNvdXBvbi50ZW1wLmEiLCJjb3Vwb24uYmF0Y2guYSIsImNvdXBvbi5jb2RlLmEiLCJjb3Vwb24uY29kZS5yIiwiY291cG9uLnRlbXAudSIsImNvdXBvbi50ZW1wLnIiLCJjb3Vwb24uY29kZS5jIiwiY291cG9uLnRlbXAuYyIsImNvdXBvbi5jb2RlLnUiLCJjbXMuY3QuKiJdLCJleHAiOjE1OTIzNzE5ODUsImlhdCI6MTU5MjM3MTM4NSwianRpIjoiZmRkMDdmYmQtMDBlNy00YjAxLWFjYjgtMGYwZGUzY2M0NWNlIiwiY2xpZW50X2lkIjoiY291cG9uX2ludGVybmFsIn0.iNC6mB7G9-qh-JiXZMpz06WNiKN0khHdkL_w9Rsr4khohz5gRPxf3DzFh3QQVsXr4qgWJireXOlpGcl3HVZ4OMQyTU3JACaUbSL-PDY0jPRwgfP4fMzm_fdBK2EXZK6q-18hDbOrv354l9ybUkoXjcQ4DalVcatpHhW2bZ9UrXpzniw2iHjSyOJj3S0rYwPOvgDqMcjPvVPqhLfrIJv-Yi4b3sgTuDQLswJW7fhtsiUBZOKeZ5BwWKChFd9NOD0_JRG1oZ65vlLR9Afc5Z0yJU6iQQLYjdnlzodlGl78TVkwKLhp7HSD5qnvIrqx6W6LFjsAbJDzw4gJmYQZg0EXbA' \
--data-raw '{
"attributes": {
"testAttr": "test"
}
}'
Response Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
createdBy | The system will get auditing information from client id | String | Y | coupon-internal | ||
createdDate | Coupon template create date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.074Z | ||
lastModifiedBy | The system will get the lastest auditing information from client id | String | Y | coupon-internal | ||
lastModifiedDate | Coupon template last modified date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.904459Z | ||
id | This is mongo object id of coupon batch in WeCoupon service. | String | Y | 5ee8768c7eeb510001874695 | ||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
templateId | This is mongo object id of coupon template in WeCoupon service. | String | Y | 5e95315697abbc00018e56e3 | ||
campaignCode | Campaign code when we set up new coupon template | String | Y | PRO-20001 | ||
amount | Amount of coupon codes that you're want to generate. | Integer | Y | 100 | ||
couponMaxUse | The number of coupons can be used per coupon. | Integer | Y | 1 | ||
length | Length of coupon code | Integer | Y | 10 | ||
pattern | The pattern of coupon code | String | N | "" | ||
prefix | The prefix of coupon code | String | Y | "" | ||
suffix | The suffix of coupon code | String | Y | "" | ||
remark | The remark of coupon batch | String | Y | "generate 100 coupons" | ||
generatorOption | Character set for generating codes | Enum | Y | NUMERIC | ||
attributes | Dynamic attributes want to update or remove. To remove an existing attribute, set that attribute to null. | Object | Y | | ||
startDateTime | The coupon start date time. The coupon can't mark use before coupon template start date. | ZonedDateTime | Y | 2020-01-01T00:00:00.088Z | ||
endDateTime | The coupon end date time. The coupon can't mark use after coupon template end date. | ZonedDateTime | Y | 2020-02-01T00:00:00.088Z | ||
systemStatus | The system status that indicate the coupon is generating or generated. | String | Y | ['GENERATING', 'GENERATED'] |
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Update coupon batch attributes successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during update coupon batch attributes |
Example Response:
{
"createdBy": "coupon_internal",
"createdDate": "2020-03-11T08:40:10.111Z",
"lastModifiedBy": "coupon_internal",
"lastModifiedDate": "2020-06-17T05:23:13.214771Z",
"id": "5e68a3ea84b4ce0001192883",
"templateId": "5e6880c384b4ce0001192876",
"projectId": "5cfa27bc2c97280001d40765",
"campaignCode": "T-200309-4",
"suffix": "",
"prefix": "",
"pattern": "",
"generatorOption": "NUMERIC",
"length": 3,
"amount": 10,
"startDateTime": "2020-03-05T07:21:17.101Z",
"endDateTime": "2020-07-05T07:21:17.101Z",
"couponMaxUse": 1,
"attributes": {
"testAttr": "test"
},
"remark": null,
"systemStatus": "GENERATED"
}
Example Response for error cases:
- Coupon Batch Not found
{
"entityName": "Coupon",
"errorKey": "COUPON_NOT_FOUND",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Cannot found data based on given information",
"status": 404,
"message": "error.COUPON_NOT_FOUND",
"params": "Coupon"
}
# Update Coupon Codes Attributes API
Method: PUT
Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/codes/{code}/attributes
Description: Update attributes for a coupon codes
- Scope:
- coupon.code.u
- coupon.code.a
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
Path Variable | ||||||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
code | Coupon code | String | Y | 153 | ||
Body | ||||||
attributes | Dynamic attributes want to update or remove. To remove an existing attribute, set that attribute to null. | Object | Y | |
Example Request:
curl --location --request PUT 'https://alpha-platform.weomni-test.com/coupon/api/projects/5cfa27bc2c97280001d40765/coupons/codes/153/attributes' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJjbXMuY3QudyIsImNvdXBvbi50ZW1wLmEiLCJjb3Vwb24uYmF0Y2guYSIsImNvdXBvbi5jb2RlLmEiLCJjb3Vwb24uY29kZS5yIiwiY291cG9uLnRlbXAudSIsImNvdXBvbi50ZW1wLnIiLCJjb3Vwb24uY29kZS5jIiwiY291cG9uLnRlbXAuYyIsImNvdXBvbi5jb2RlLnUiLCJjbXMuY3QuKiJdLCJleHAiOjE1OTIzNzM2NjksImlhdCI6MTU5MjM3MzA2OSwianRpIjoiNGVlYjFjYjctMGE4Ni00ZjFiLWI3YTYtODBkODlmMTRkMjZhIiwiY2xpZW50X2lkIjoiY291cG9uX2ludGVybmFsIn0.AwsftrI6aZrq9_i9r9B3iWF4nBYj_WldePhZRzSvoNaEvtJtUvGp1BVJcYC-thbKeUyih8mUFLTIHJaHA55F-HZIV5yYFVeW_x7_EqE3ops4VatyMZy4FgfFf8uxWGrUsNwt8vbnR6NAt3qj3tboTImphoaLkwcHu-gzYoYvUq8dY9_KVAFuBoekNXYpnHo1JsdcMwzA0lVCuib--nax09jrlMWWP6qPXPz57FcU7-AiawP4hEdq-UyQmHhaufxOwY9dQnfOsz2y8axlWJ6mM1gKxG-SN-4EJ9FQs2MOzk8OjzKlfJWrQhB-W5F27uISwj87Rywgri-KYloFzoaL6Q' \
--data-raw '{
"campaignCode": "TEST-110022001",
"attributes": {
"testAttr": "test"
}
}'
Response Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
createdBy | The system will get auditing information from client id | String | Y | coupon-internal | ||
createdDate | Coupon template create date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.074Z | ||
lastModifiedBy | The system will get the lastest auditing information from client id | String | Y | coupon-internal | ||
lastModifiedDate | Coupon template last modified date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.904459Z | ||
id | This is mongo object id of coupon in WeCoupon service. | String | Y | 5e4514389e13a300017598e1 | ||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
templateId | This is mongo object id of coupon template in WeCoupon service. | String | Y | 5e95315697abbc00018e56e3 | ||
batchId | This is mongo object id of coupon batch in WeCoupon service. | String | Y | 5e4514379e13a300017598e0 | ||
campaignCode | Campaign code when we set up new coupon template | String | Y | PRO-20001 | ||
code | Coupon code | String | Y | 153 | ||
rawCode | Coupon raw code | String | Y | 153 | ||
couponMaxUse | The number of coupons can be used per coupon. | Integer | Y | 1 | ||
used | The number of coupons that already mark-used | Integer | Y | 1 | ||
owner | The owner of that coupon. | String | Y | Firstname Lastname | ||
attributes | Dynamic attributes want to update or remove. To remove an existing attribute, set that attribute to null. | Object | Y | |
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Update coupon codes attributes successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during update coupon codes attributes |
Example Response:
{
"createdBy": "system",
"createdDate": "2020-02-13T09:17:44.229Z",
"lastModifiedBy": "coupon_internal",
"lastModifiedDate": "2020-06-17T06:04:07.061586Z",
"id": "5e4514389e13a300017598e1",
"templateId": "5e4514379e13a300017598df",
"batchId": "5e4514379e13a300017598e0",
"projectId": "5cfa27bc2c97280001d40765",
"campaignCode": "TEST-110022001",
"code": "153",
"rawCode": "153",
"couponMaxUse": 1,
"used": 0,
"owner": null,
"attributes": {
"test": "test",
"isActive": true,
"customField": "value",
"testAttr": "test"
}
}
Example Response for error cases:
- Coupon not found
{
"entityName": "Coupon",
"errorKey": "COUPON_NOT_FOUND",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Cannot found data based on given information",
"status": 404,
"message": "error.COUPON_NOT_FOUND",
"params": "Coupon"
}
# Get List of Coupon Template Based On The Filter Condition API
Method: GET
Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/templates
Description: Get list of coupon batch based on filter condition
- Scope:
- coupon.temp.r
- coupon.temp.a
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body
Filter Attributes | Method | Support type | Required | Example | ||
---|---|---|---|---|---|---|
Path Variable | ||||||
projectId | String | Y | 5de626d53d901d0001823a6a | |||
Parameter | ||||||
String, Map | N | |||||
Date/time, Integer, Double, Long | N |
Example Request:
curl --location --request GET 'https://alpha-platform.weomni-test.com/coupon/api/projects/5de626d53d901d0001823a6a/coupons/templates?owner[merchantId].equals=0022796&attributes[status].equals=APPROVED' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJjbXMuY3QudyIsImNvdXBvbi50ZW1wLmEiLCJjb3Vwb24uYmF0Y2guYSIsImNvdXBvbi5jb2RlLmEiLCJjb3Vwb24uY29kZS5yIiwiY291cG9uLnRlbXAudSIsImNvdXBvbi50ZW1wLnIiLCJjb3Vwb24uY29kZS5jIiwiY291cG9uLnRlbXAuYyIsImNvdXBvbi5jb2RlLnUiLCJjbXMuY3QuKiJdLCJleHAiOjE1OTIzNzY5MzMsImlhdCI6MTU5MjM3NjMzMywianRpIjoiZThkZjgwYTctYjU1OS00MjgyLWJlMzEtODAzZTgwNGZhOTIzIiwiY2xpZW50X2lkIjoiY291cG9uX2ludGVybmFsIn0.P2PJCX7GTblamDulcok8q_YioWnE3ajMj9pxJu4Xbsw0--PGsMrDTetJpwHVlaRNlh39CYOmzb-A0J988HkOoaCU8IGcwRX6DRa4skXF0VCLjEstmQzHwuTaxtMiAZPQvWMvxjOggk-JV2byQQMnmj9puE7_q_gp7OL1Ph3m6LjC8b8bQWud4Px6W01dlW89j3nvFw-XXIoxmyrq7muHVVx4RtH2vaxiMPasqeF1T8sQ6AhQ3rFqJFTbuXd_UrnZyxT_kWe4McoCf7F5LcoEB1dknFm7cOC1EuNq8B8qImJPLlfooJetMFtHNHJ1TX3owZhNAEYMRAJnB_Db5lFs5Q'
Response Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
createdBy | The system will get auditing information from client id | String | Y | coupon-internal | ||
createdDate | Coupon template create date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.074Z | ||
lastModifiedBy | The system will get the lastest auditing information from client id | String | Y | coupon-internal | ||
lastModifiedDate | Coupon template last modified date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.904459Z | ||
id | This is mongo object id of coupon template in WeCoupon service. | String | Y | 5ee8768c7eeb510001874695 | ||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
campaignCode | Campaign code when we set up new coupon template | String | Y | PRO-20001 | ||
externalCampaignCode | Campaign code from the merchant who created by themselves | String | Y | MERCHANT-00001 | ||
title | The campaign title | String | Y | TrueCoffee buy 1 get 1 for free | ||
description | The campaign description | String | Y | Can be used before 6:00 PM | ||
contentId | This is mongo object id of coupon template content in CMS service. | String | Y | 5eaa55d11bee2b00019d7e27 | ||
termsAndConditions | Term and conditions for the campaign | String | Y | Term & Conditions apply | ||
channel | The channel that coupon is going to sell. e.g TSM, WeMall | String | Y | WeMall | ||
price | The coupon price | Double | Y | 100.0 | ||
priceUnit | The coupon price currency | String | Y | THB, USD | ||
startDateTime | The coupon start date time. The coupon can't mark use before coupon template start date. | ZonedDateTime | Y | 2020-01-01T00:00:00.088Z | ||
endDateTime | The coupon end date time. The coupon can't mark use after coupon template end date. | ZonedDateTime | Y | 2020-02-01T00:00:00.088Z | ||
icon | An Icon for display on TSM appplication which is public file. It's store on CMS. | String | Y | "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/image.jpeg?version=0" | ||
image | An image for display on TSM application which is public file. It's store on CMS. | String | Y | "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/image.jpeg?version=0" | ||
owner | Map of merchantId, outletId, terminalId information | Map<String, Object> | Y | | ||
attributes | Map of custom attributes with arbitrary string keys and object values | Map<String, Object> | Y | | ||
remark | The remark of coupon template | String | Y | coupon template remark |
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Get coupon template successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during get coupon template |
Example Response:
[
{
"createdBy": "createdByTesting",
"createdDate": "2020-05-11T08:51:27.587Z",
"lastModifiedBy": "createdByTesting",
"lastModifiedDate": "2020-05-11T08:51:27.869Z",
"id": "5eb9120fe5fd310001b0f7e0",
"projectId": "5de626d53d901d0001823a6a",
"campaignCode": "DEV-0506-8",
"externalCampaignCode": null,
"channel": "TSM",
"title": "Discount 10% on total build",
"description": "Buy everything and get 10% discount",
"contentId": "5eb9120f0872f10001be3f8c",
"startDateTime": "2020-04-01T10:59:00Z",
"endDateTime": "2020-05-10T10:59:00Z",
"owner": {
"merchantId": "0022796",
"outletId": "00001"
},
"price": null,
"priceUnit": null,
"attributes": {
"productOriginalPrice": 20.1,
"amount": 10,
"productSalePrice": 30.0,
"branchName": "hello",
"status": "APPROVED"
},
"remark": null,
"termsAndConditions": "สุดสัปดาห์นี้ ทรูโฟร์ยู ช่อง 24 ชวนคุณมาร่วมลุ้นแมตช์สุดมันส์กับ ซีพี วอลเลย์บอล ไทยแล",
"image": "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5eb9120f0872f10001be3f8c/image.jpeg?version=0",
"icon": null
}
]
- Coupon Template Not Found
[]
# Get Coupon Template Details by Template Code API
Method: GET
Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/templates/{templateCode}
Description: Get details of a coupon template by template code. If “details” query parameter is “true”, system will get all batches of that coupon and return response.
- Scope:
- coupon.temp.r
- coupon.temp.a
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
Path Variable | ||||||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
templateCode | Template code value is the same with campaign code | String | Y | PRO-2051 | ||
Request Param | ||||||
detail | If “details” query parameter is “true”, system will get all batches of that coupon and return response. | Boolean | N | detail=true |
Example Request:
curl --location --request GET 'https://alpha-platform.weomni-test.com/coupon/api/projects/5de626d53d901d0001823a6a/coupons/templates/PRIV-153887?details=true' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJjbXMuY3QudyIsImNvdXBvbi50ZW1wLmEiLCJjb3Vwb24uYmF0Y2guYSIsImNvdXBvbi5jb2RlLmEiLCJjb3Vwb24uY29kZS5yIiwiY291cG9uLnRlbXAudSIsImNvdXBvbi50ZW1wLnIiLCJjb3Vwb24uY29kZS5jIiwiY291cG9uLnRlbXAuYyIsImNvdXBvbi5jb2RlLnUiLCJjbXMuY3QuKiJdLCJleHAiOjE1OTIzNzc3MDYsImlhdCI6MTU5MjM3NzEwNiwianRpIjoiOGI2YjRkOGQtNWY0Mi00ZTg5LWFjYjgtYjgwNjc3ZWUyYzBjIiwiY2xpZW50X2lkIjoiY291cG9uX2ludGVybmFsIn0.YLzbNcm2y0A4IVSsyHQuegajvC6N1feBwq4pVhGT56-oUnI30NJnvK1adXangexDT9Phf4f-G-trBJIKZGoqNHZL6YYkN9u6UXYR65RS38ab_RCbNoEh90XSrVNgYcO9FDUYXygPxL1j0sE4-Xi6aTZRe3L_4Fq4fwocPSQFxunMk-j4_2TYzRJ4P1jOWQHE9-5UvwAu9x1vaPA4XfRkp9j7JBIRywYa3nbvwdn5HQ4dAYrbAzk1ZiBo7SyMRSqwCm_IY7sf7jNHI7GGLCkkU967wU01eyYEgwnih4HnemOnq4rGQA4saDcway76TKq9MImX1MC3CxgLWWSJJw6v3g'
Response Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
createdBy | The system will get auditing information from client id | String | Y | coupon-internal | ||
createdDate | Coupon template create date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.074Z | ||
lastModifiedBy | The system will get the lastest auditing information from client id | String | Y | coupon-internal | ||
lastModifiedDate | Coupon template last modified date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.904459Z | ||
id | This is mongo object id of coupon template in WeCoupon service. | String | Y | 5ee8768c7eeb510001874695 | ||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
campaignCode | Campaign code when we set up new coupon template | String | Y | PRO-20001 | ||
externalCampaignCode | Campaign code from the merchant who created by themselves | String | Y | MERCHANT-00001 | ||
title | The campaign title | String | Y | TrueCoffee buy 1 get 1 for free | ||
description | The campaign description | String | Y | Can be used before 6:00 PM | ||
contentId | This is mongo object id of coupon template content in CMS service. | String | Y | 5eaa55d11bee2b00019d7e27 | ||
termsAndConditions | Term and conditions for the campaign | String | Y | Term & Conditions apply | ||
channel | The channel that coupon is going to sell. e.g TSM, WeMall | String | Y | WeMall | ||
price | The coupon price | Double | Y | 100.0 | ||
priceUnit | The coupon price currency | String | Y | THB, USD | ||
startDateTime | The coupon start date time. The coupon can't mark use before coupon template start date. | ZonedDateTime | Y | 2020-01-01T00:00:00.088Z | ||
endDateTime | The coupon end date time. The coupon can't mark use after coupon template end date. | ZonedDateTime | Y | 2020-02-01T00:00:00.088Z | ||
icon | An Icon for display on TSM appplication which is public file. It's store on CMS. | String | Y | "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/image.jpeg?version=0" | ||
image | An image for display on TSM application which is public file. It's store on CMS. | String | Y | "https://alpha-cms.weomni-test.com/projects/5de626d53d901d0001823a6a/content-types/5e218179e2aaa200014898fa/contents/5ee8768c08ad020001a2a2a8/image.jpeg?version=0" | ||
owner | Map of merchantId, outletId, terminalId information | Map<String, Object> | Y | | ||
attributes | Map of custom attributes with arbitrary string keys and object values | Map<String, Object> | Y | | ||
remark | The remark of coupon template | String | Y | coupon template remark | ||
batches | List of coupon batch that generated. It's belong to that coupon template. | Array | N | |||
createdBy | The system will get auditing information from client id | String | N | coupon-internal | ||
createdDate | Coupon template create date/time | ZonedDateTime | N | 2020-06-16T07:36:44.074Z | ||
lastModifiedBy | The system will get the lastest auditing information from client id | String | N | coupon-internal | ||
lastModifiedDate | Coupon template last modified date/time | ZonedDateTime | N | 2020-06-16T07:36:44.904459Z | ||
id | This is mongo object id of coupon batch in WeCoupon service. | String | N | 5ee9842d7eeb51000187469d | ||
projectId | The project id when create a project on WePlatform | String | N | 5de626d53d901d0001823a6a | ||
campaignCode | Campaign code when we set up new coupon template | String | N | PRO-20001 | ||
templateId | This is mongo object id of coupon template in WeCoupon service. | String | N | 5e95315697abbc00018e56e3 | ||
amount | Amount of coupon codes that you're want to generate. | Integer | N | 100 | ||
couponMaxUse | The number of coupons can be used per coupon. | Integer | N | 1 | ||
length | Length of coupon code | Integer | N | 10 | ||
pattern | The pattern of coupon code | String | N | "" | ||
prefix | The prefix of coupon code | String | N | "" | ||
suffix | The suffix of coupon code | String | N | "" | ||
remark | The remark of coupon batch | String | N | "generate 100 coupons" | ||
generatorOption | Character set for generating codes | Enum | N | IMPORT | ||
attributes | If you use generator option as "IMPORT", the CSV file name will display here. | Object | N | | ||
startDateTime | The coupon start date time. The coupon can't mark use before coupon template start date. | ZonedDateTime | N | 2020-01-01T00:00:00.088Z | ||
endDateTime | The coupon end date time. The coupon can't mark use after coupon template end date. | ZonedDateTime | N | 2020-02-01T00:00:00.088Z | ||
systemStatus | The system status that indicate the coupon is generating or generated. | String | N | ['GENERATING', 'GENERATED'] |
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Get coupon template detail successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during get coupon template detail |
Example Response:
{
"createdBy": "coupon_internal",
"createdDate": "2020-04-14T03:43:18.716Z",
"lastModifiedBy": "coupon_internal",
"lastModifiedDate": "2020-06-17T04:19:45.842Z",
"id": "5e95315697abbc00018e56e3",
"projectId": "5de626d53d901d0001823a6a",
"campaignCode": "PRIV-153887",
"externalCampaignCode": "TEST-0001",
"channel": "TSM",
"title": "updated title",
"description": "updated description",
"termsAndConditions": "updated termsAndConditions",
"contentId": "5e9531565e5f600001bfe233",
"startDateTime": "2020-01-01T00:00:00.088Z",
"endDateTime": "2021-01-01T00:00:00.088Z",
"price": 100.0,
"priceUnit": "THB",
"attributes": {
"status": "APPROVED"
},
"remark": "updated remark",
"batches": [
{
"createdBy": "coupon_internal",
"createdDate": "2020-04-14T03:46:52.249Z",
"lastModifiedBy": "system",
"lastModifiedDate": "2020-04-14T03:46:52.502Z",
"id": "5e95322c97abbc00018e56e4",
"projectId": "5de626d53d901d0001823a6a",
"campaignCode": "PRIV-153887",
"templateId": "5e95315697abbc00018e56e3",
"suffix": "",
"prefix": "",
"pattern": "",
"generatorOption": "IMPORT",
"length": 7,
"amount": 100,
"couponMaxUse": 1,
"attributes": {
"importedFileName": "testcsv.csv"
},
"remark": null,
"startDateTime": "2020-01-01T00:00:00.088Z",
"endDateTime": "2021-01-01T00:00:00.088Z",
"systemStatus": "GENERATED"
},
{
"createdBy": "coupon_internal",
"createdDate": "2020-06-17T02:47:09.766Z",
"lastModifiedBy": "coupon_internal",
"lastModifiedDate": "2020-06-17T02:47:09.864Z",
"id": "5ee9842d7eeb51000187469d",
"projectId": "5de626d53d901d0001823a6a",
"campaignCode": "PRIV-153887",
"templateId": "5e95315697abbc00018e56e3",
"suffix": "",
"prefix": "",
"pattern": "",
"generatorOption": "IMPORT",
"length": 7,
"amount": 0,
"couponMaxUse": 1,
"attributes": {
"importedFileName": "testcsv.csv"
},
"remark": "Requested 100 codes, imported 0 codes successful, ignore 100 codes duplicated [1000001, 1000002, 1000003, 1000004, 1000005, 1000006, 1000007, 1000008, 1000009, 1000010, 1000011, 1000012, 1000013, 1000014, 1000015, 1000016, 1000017, 1000018, 1000019, 1000020, 1000021, 1000022, 1000023, 1000024, 1000025, 1000026, 1000027, 1000028, 1000029, 1000030, 1000031, 1000032, 1000033, 1000034, 1000035, 1000036, 1000037, 1000038, 1000039, 1000040, 1000041, 1000042, 1000043, 1000044, 1000045, 1000046, 1000047, 1000048, 1000049, 1000050, 1000051, 1000052, 1000053, 1000054, 1000055, 1000056, 1000057, 1000058, 1000059, 1000060, 1000061, 1000062, 1000063, 1000064, 1000065, 1000066, 1000067, 1000068, 1000069, 1000070, 1000071, 1000072, 1000073, 1000074, 1000075, 1000076, 1000077, 1000078, 1000079, 1000080, 1000081, 1000082, 1000083, 1000084, 1000085, 1000086, 1000087, 1000088, 1000089, 1000090, 1000091, 1000092, 1000093, 1000094, 1000095, 1000096, 1000097, 1000098, 1000099, 1000100]",
"startDateTime": "2020-01-01T00:00:00.088Z",
"endDateTime": "2021-01-01T00:00:00.088Z",
"systemStatus": "GENERATED"
},
{
"createdBy": "coupon_internal",
"createdDate": "2020-06-17T03:26:31.246Z",
"lastModifiedBy": "coupon_internal",
"lastModifiedDate": "2020-06-17T03:26:31.292Z",
"id": "5ee98d677eeb51000187469e",
"projectId": "5de626d53d901d0001823a6a",
"campaignCode": "PRIV-153887",
"templateId": "5e95315697abbc00018e56e3",
"suffix": "",
"prefix": "",
"pattern": "",
"generatorOption": "IMPORT",
"length": 7,
"amount": 0,
"couponMaxUse": 1,
"attributes": {
"importedFileName": "testcsv.csv"
},
"remark": "Requested 100 codes, imported 0 codes successful, ignore 100 codes duplicated [1000001, 1000002, 1000003, 1000004, 1000005, 1000006, 1000007, 1000008, 1000009, 1000010, 1000011, 1000012, 1000013, 1000014, 1000015, 1000016, 1000017, 1000018, 1000019, 1000020, 1000021, 1000022, 1000023, 1000024, 1000025, 1000026, 1000027, 1000028, 1000029, 1000030, 1000031, 1000032, 1000033, 1000034, 1000035, 1000036, 1000037, 1000038, 1000039, 1000040, 1000041, 1000042, 1000043, 1000044, 1000045, 1000046, 1000047, 1000048, 1000049, 1000050, 1000051, 1000052, 1000053, 1000054, 1000055, 1000056, 1000057, 1000058, 1000059, 1000060, 1000061, 1000062, 1000063, 1000064, 1000065, 1000066, 1000067, 1000068, 1000069, 1000070, 1000071, 1000072, 1000073, 1000074, 1000075, 1000076, 1000077, 1000078, 1000079, 1000080, 1000081, 1000082, 1000083, 1000084, 1000085, 1000086, 1000087, 1000088, 1000089, 1000090, 1000091, 1000092, 1000093, 1000094, 1000095, 1000096, 1000097, 1000098, 1000099, 1000100]",
"startDateTime": "2020-01-01T00:00:00.088Z",
"endDateTime": "2021-01-01T00:00:00.088Z",
"systemStatus": "GENERATED"
},
{
"createdBy": "coupon_internal",
"createdDate": "2020-06-17T03:28:47.83Z",
"lastModifiedBy": "coupon_internal",
"lastModifiedDate": "2020-06-17T03:28:48.059Z",
"id": "5ee98def7eeb51000187469f",
"projectId": "5de626d53d901d0001823a6a",
"campaignCode": "PRIV-153887",
"templateId": "5e95315697abbc00018e56e3",
"suffix": "t",
"prefix": "s",
"pattern": "",
"generatorOption": "NUMERIC",
"length": 8,
"amount": 1,
"couponMaxUse": 1,
"attributes": null,
"remark": null,
"startDateTime": "2020-01-01T00:00:00.088Z",
"endDateTime": "2021-01-01T00:00:00.088Z",
"systemStatus": "GENERATED"
}
]
}
- Coupon Template Not Found
{
"entityName": "CouponTemplate",
"errorKey": "COUPON_TEMPLATE_NOT_FOUND",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Coupon Template not found",
"status": 404,
"message": "error.COUPON_TEMPLATE_NOT_FOUND",
"params": "CouponTemplate"
}
# Get List of Coupon Codes Based On The Filter Condition API
Method: GET
Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/templates
Description: Get list of coupon batch based on filter condition
- Scope:
- coupon.code.r
- coupon.code.a
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body
Filter Attributes | Method | Support type | Required | Example | ||
---|---|---|---|---|---|---|
Path Variable | ||||||
projectId | String | Y | 5de626d53d901d0001823a6a | |||
Parameter | ||||||
String, Map | N | |||||
Date/time, Integer, Double, Long | N |
Example Request:
curl --location --request GET 'https://alpha-platform.weomni-test.com/coupon/api/projects/5cfa27bc2c97280001d40765/coupons/codes' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJjbXMuY3QudyIsImNvdXBvbi50ZW1wLmEiLCJjb3Vwb24uYmF0Y2guYSIsImNvdXBvbi5jb2RlLmEiLCJjb3Vwb24uY29kZS5yIiwiY291cG9uLnRlbXAudSIsImNvdXBvbi50ZW1wLnIiLCJjb3Vwb24uY29kZS5jIiwiY291cG9uLnRlbXAuYyIsImNvdXBvbi5jb2RlLnUiLCJjbXMuY3QuKiJdLCJleHAiOjE1OTIzNzk4NjQsImlhdCI6MTU5MjM3OTI2NCwianRpIjoiZmE1YTZlYzgtMjVkNy00YTg4LTgxNzgtMWFhY2VkMTU3N2E0IiwiY2xpZW50X2lkIjoiY291cG9uX2ludGVybmFsIn0.eHKIw8s0RUVIYhEJ8ox71-Amd3hhmbDtcz_0qf19leADzI--6vhgoPPo8e6E8VTIgRnAyRDbOmgwGnlGk9EF0VYe7kl8YbmAs4vxQtEJ6kbtfi60Pa5TacO_xdb8vqXx4jJFsw5xxUozx5twpNw64M4CcWddsuwpzVlHyQIIb2K6R6AYxVcLkjuzWbpmABj81_Umgqfi4tIqMmn9jBkPmW0FbmqAlxh7uNp1fe_4Gh0Qmun9oRez83tw4LhQuAJ3ZzzMbqEWkWUTHPOFkpS5QkjKg7nx7Fb6mnm8lzGM59sB2GlQXbFClPthKBc3XIBSC_vd-koFQjPyzWqgE8AS0A' \
--header 'Cookie: AWSALB=EgRmcBpidg/2sUayxzUNP2XTdDlgU7n0g6wmF8EAmJ+uRloROHECBWH3p3vcBLnuYpiR5uBubwdoY3mpjJq3zggEBGgXI5ZzLJ4BVw27e3WIw6mOSWHsccEFPeKF; AWSALBCORS=EgRmcBpidg/2sUayxzUNP2XTdDlgU7n0g6wmF8EAmJ+uRloROHECBWH3p3vcBLnuYpiR5uBubwdoY3mpjJq3zggEBGgXI5ZzLJ4BVw27e3WIw6mOSWHsccEFPeKF; XSRF-TOKEN=a41a6cbe-c26f-45fd-826e-1c47b3ffb13b'
Response Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
createdBy | The system will get auditing information from client id | String | Y | coupon-internal | ||
createdDate | Coupon template create date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.074Z | ||
lastModifiedBy | The system will get the lastest auditing information from client id | String | Y | coupon-internal | ||
lastModifiedDate | Coupon template last modified date/time | ZonedDateTime | Y | 2020-06-16T07:36:44.904459Z | ||
id | This is mongo object id of coupon in WeCoupon service. | String | Y | 5e4514389e13a300017598e1 | ||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
templateId | This is mongo object id of coupon template in WeCoupon service. | String | Y | 5e95315697abbc00018e56e3 | ||
batchId | This is mongo object id of coupon batch in WeCoupon service. | String | Y | 5e4514379e13a300017598e0 | ||
campaignCode | Campaign code when we set up new coupon template | String | Y | PRO-20001 | ||
code | Coupon code | String | Y | 153 | ||
rawCode | Coupon raw code | String | Y | 153 | ||
couponMaxUse | The number of coupons can be used per coupon. | Integer | Y | 1 | ||
used | The number of coupons that already mark-used | Integer | Y | 1 | ||
owner | The owner of that coupon. | String | Y | Firstname Lastname | ||
attributes | Dynamic attributes, any custom fields will display here | Object | Y | |
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Get coupon code successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during get coupon code |
Example Response:
[
{
"createdBy": "system",
"createdDate": "2020-02-14T08:35:55.229Z",
"lastModifiedBy": "system",
"lastModifiedDate": "2020-02-14T08:35:55.229Z",
"id": "5e465beb9e13a30001cd8178",
"templateId": "5e465beb9e13a30001cd8115",
"batchId": "5e465beb9e13a30001cd8116",
"projectId": "5cfa27bc2c97280001d40765",
"campaignCode": "",
"code": "00050223",
"rawCode": "00050223",
"couponMaxUse": 1,
"used": 0,
"owner": null,
"attributes": null
},
{
"createdBy": "system",
"createdDate": "2020-02-14T08:35:55.321Z",
"lastModifiedBy": "system",
"lastModifiedDate": "2020-02-14T08:35:55.321Z",
"id": "5e465beb9e13a30001cd82a2",
"templateId": "5e465beb9e13a30001cd8115",
"batchId": "5e465beb9e13a30001cd8116",
"projectId": "5cfa27bc2c97280001d40765",
"campaignCode": "",
"code": "00130511",
"rawCode": "00130511",
"couponMaxUse": 1,
"used": 0,
"owner": null,
"attributes": null
}
]
- Coupon Code Not Found
[]
# Mark Used Coupon Code API
Method: POST
Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/codes/mark-used
Description: mark-used api will do two things:
Update used quota for that coupon code
Add new tracking record in to coupon-tracking table for that coupon code
- Scope:
- coupon.temp.c
- coupon.temp.a
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
Path Variable | ||||||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
Body | ||||||
templateCode | Template code value is the same with campaign code | String | Y | PRO-20001 | ||
couponCode | The coupon code that you want to mark used | String | N | 015 | ||
usedAt | Mark used by using these MOT information (Merchant, Outlet, Terminal) | Map<String, String> | Y | |
Example Request:
curl --location --request POST 'https://alpha-platform.weomni-test.com/coupon/api/projects/5de626d53d901d0001823a6a/coupons/codes/mark-used' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJjbXMuY3QudyIsImNvdXBvbi50ZW1wLmEiLCJjb3Vwb24uYmF0Y2guYSIsImNvdXBvbi5jb2RlLmEiLCJjb3Vwb24uY29kZS5yIiwiY291cG9uLnRlbXAudSIsImNvdXBvbi50ZW1wLnIiLCJjb3Vwb24uY29kZS5jIiwiY291cG9uLnRlbXAuYyIsImNvdXBvbi5jb2RlLnUiLCJjbXMuY3QuKiJdLCJleHAiOjE1OTIzODIwMDQsImlhdCI6MTU5MjM4MTQwNCwianRpIjoiZWYzNjI5N2MtYzI1NS00N2M0LTgxOGItZmI0ZGFkNjc4Yzg3IiwiY2xpZW50X2lkIjoiY291cG9uX2ludGVybmFsIn0.LBep9eN3dJzuBfZrInnC2cHhmSHflv0aFf_Kmp7QlKQ-U0_v6HCjh9OVOHJ-4M0zKQziURT9VV5-klUDWPnASWMb_L4W4lOrRHxOWRp1CmB6O4-RQwWE9N0YXYvzf1XN-Qp6vO9dFKbN3HaZSaXx-MDK2Yawl4iqZDfih6bTaKrrfh2zd5HnIeYcZls2Fp_KUKawRaD-0HkvNhP9a_Jra0e1CQ1hyfsdE-G6fTkyWcEa9SW_ZlhDe28KtxBV2ZRO-zG6D2T0nFCRf8mNh1vhgmD7uDUoSyxtQ9z4TOjb_fWk4q8Kw0t7nJKIp11-V4uKU3V8LEo4CircYNf2eluI_Q' \
--data-raw '{
"templateCode": "PRIV-153887",
"couponCode": "1000001",
"usedAt": {
"merchantId": "0022796",
"outletId": "00001",
"terminalId": "69000712"
}
}'
Response Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
id | This is mongo object id of coupon code in WeCoupon service. | String | Y | 5ee9d0d77eeb5100018746a1 | ||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
campaignCode | Campaign code when we set up new coupon template | String | Y | PRO-20001 | ||
batchId | This is mongo object id of coupon batch in WeCoupon service. | String | Y | 5ee98def7eeb51000187469f | ||
couponCode | The coupon code that already mark used | String | Y | 015 | ||
usedAt | Mark used by using these MOT information (Merchant, Outlet, Terminal) | Map<String, String> | Y | | ||
usedDate | Coupon mark used date | ZonedDateTime | Y | 2020-06-17T08:14:15.422775Z | ||
createdBy | The system will get auditing information from client id | String | Y | coupon-internal |
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Create coupon template successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during create coupon template |
Example Response:
{
"id": "5ee9d0d77eeb5100018746a1",
"projectId": "5de626d53d901d0001823a6a",
"campaignCode": "PRIV-153887",
"batchId": "5e95322c97abbc00018e56e4",
"code": "1000001",
"usedAt": {
"merchantId": "0022796",
"outletId": "00001",
"terminalId": "69000712"
},
"usedDate": "2020-06-17T08:14:15.422775Z",
"createdBy": "coupon_internal"
}
Example Response for error cases:
- Coupon template expired
{
"entityName": "CouponTemplate",
"errorKey": "COUPON_TEMPLATE_EXPIRED",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Coupon template expired",
"status": 400,
"message": "error.COUPON_TEMPLATE_EXPIRED",
"params": "CouponTemplate"
}
- Coupon code cannot use
{
"entityName": "coupon",
"errorKey": "COUPON_CODE_CANNOT_USE",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "This coupon code cannot use at this time. Please retry.",
"status": 400,
"message": "error.COUPON_CODE_CANNOT_USE",
"params": "coupon"
}
- Coupon code was already used
{
"entityName": "coupon",
"errorKey": "COUPON_CODE_USED",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Coupon code already used or over limit quota",
"status": 400,
"message": "error.COUPON_CODE_USED",
"params": "coupon"
}
- Coupon code is not start yet
{
"entityName": "CouponTemplate",
"errorKey": "COUPON_TEMPLATE_NOT_START",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Coupon template did not start yet",
"status": 400,
"message": "error.COUPON_TEMPLATE_NOT_START",
"params": "CouponTemplate"
}
- Coupon code not found
{
"entityName": "Coupon",
"errorKey": "COUPON_CODE_NOT_FOUND",
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Coupon code not found",
"status": 404,
"message": "error.COUPON_CODE_NOT_FOUND",
"params": "Coupon"
}
# Coupon Template Summary API
Method: POST
Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/summary/templates
Description: Counting information of coupon template based on grouping information
- Scope:
- coupon.sum.r
- coupon.temp.a
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
Path Variable | ||||||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
Body | ||||||
filters.attributes | Template code value is the same with campaign code | Map<String, StringFilter> | N | PRO-20001 | ||
filters.campaignCode | The coupon code that you want to mark used | StringFilter | N | 015 | ||
filters.channel | Mark used by using these MOT information (Merchant, Outlet, Terminal) | StringFilter | N | |||
filters.createdBy | Mark used by using these MOT information (Merchant, Outlet, Terminal) | StringFilter | N | |||
filters.createdDate | Start of range of created date user want to filter Format: ZonedDateTimeFormat (UTC +0) | StringFilter | N | 2020-05-14T09:30:54.573Z | ||
filters.lastModifiedBy | Mark used by using these MOT information (Merchant, Outlet, Terminal) | StringFilter | N | |||
filters.lastModifiedDate | Start of range of created date user want to filter Format: ZonedDateTimeFormat (UTC +0) | StringFilter | N | 2020-05-14T09:30:54.573Z | ||
filters.startDateTime | Start of range of created date user want to filter Format: ZonedDateTimeFormat (UTC +0) | StringFilter | N | 2020-05-14T09:30:54.573Z | ||
filters.endDateTime | Start of range of created date user want to filter Format: ZonedDateTimeFormat (UTC +0) | StringFilter | N | 2020-05-14T09:30:54.573Z | ||
filters.owner | Template code value is the same with campaign code | Map<String, StringFilter> | N | PRO-20001 | ||
filters.title | Template code value is the same with campaign code | StringFilter | N | PRO-20001 | ||
groupFields | Specify attributes that will be grouped and counted./td> | List<String> | Y | groupFields: [attributes.status, channel] |
Example Request:
curl --location --request POST 'https://alpha-platform.weomni-test.com/coupon/api/projects/5de626d53d901d0001823a6a/coupons/summary/templates' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJjbXMuY3QudyIsImNvdXBvbi50ZW1wLmEiLCJjb3Vwb24uYmF0Y2guYSIsImNvdXBvbi5jb2RlLmEiLCJjb3Vwb24uY29kZS5yIiwiY291cG9uLnRlbXAudSIsImNvdXBvbi50ZW1wLnIiLCJjb3Vwb24uY29kZS5jIiwiY291cG9uLnRlbXAuYyIsImNvdXBvbi5jb2RlLnUiLCJjbXMuY3QuKiJdLCJleHAiOjE1OTIzODMzNjIsImlhdCI6MTU5MjM4Mjc2MiwianRpIjoiOTk5MDg3N2EtZDJmMi00ZTI4LTgzYzItMWFlZTEzOTJhNDkxIiwiY2xpZW50X2lkIjoiY291cG9uX2ludGVybmFsIn0.j0HuuqdBqTx6ixX8Da7pSN9x-gZzFqEO3vHcnzLB8CkBL_wVd_m659X7LeZZipzJIz2weHV8XNyorZr1M7mg_54UFyCSebfC3ZMqoTu5i3eogYAoPf1jUBUFi2ijIAhxN-6ckwDvsoR7GQX12_ZwhIm2KRSA4APEXF5dyC5drRz5-JflpEuigsftuTs8yCQFFxpIGRDZoTifCd3pKOSVds167_eyMf2R5sC59dI7V39fE_N6KAidWXBgpsoB6nedgGapjxG2vpJ18nGebSW83DP0_1taBpUv0uXWc8knaQiI4Wmqbsa9U6yQTnFRiJSL8rG5Y1fsEp4z2mD5j_tHgw' \
--data-raw '{
"filters":{
"attributes":{
"status":{
"in":[
"DRAFT",
"APPROVE"
]
}
},
"createdDate":{
"notEquals":"2020-05-01T04:06:16.137Z"
}
},
"groupFields":[
"attributes.status"
]
}'
Response Body
Param | Description | Type | Required | Example | ||
---|---|---|---|---|---|---|
total | The total count number of coupon template which belong to each project id and status | String | Y | 153 | ||
projectId | The project id when create a project on WePlatform | String | Y | 5de626d53d901d0001823a6a | ||
status | The coupon status | String | Y | APPROVED |
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Get coupon template summary successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during get coupon template summary |
Example Response:
[
{
"total": 163,
"attributes.status": "DRAFT"
}
]
Example Response for error cases:
- Coupon template not found
[]
# Coupon Apply API
Method: POST Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/codes/apply-coupon
Description: Checking coupon code that available use.
- Scope:
- coupon.code.a
- coupon.code.r
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body:
Param | Description | Type | Required |
---|---|---|---|
couponCode | Code of coupon for apply. | String | Y |
attribute | Attribute for campaign to search campaign condition. | Map<String, String> | Y |
cart | Cart for campaign to search campaign condition. | Object | N |
cart.items | Item in cart | String | N |
cart.items.sku | Sku of item for identify this item. | String | Y |
cart.items.tags | Tags that list of tag name of this item. | Array | Y |
cart.items.name | Name of item. | String | N |
cart.items.amount | Amount of item. | Number | N |
cart.items.price | Price of this item. | Double | N |
Example Request:
curl --location --request POST 'https://alpha-platform.weomni-test.com/coupon/api/projects/6088ecd806b0ab000182e538/coupons/codes/apply-coupon' \
--header 'Authorization: Bearer {Bearer Token} '\
--header 'Content-Type: application/json' \
--data-raw '{
"couponCode": "JOKER_DISCOUNT_usAMi",
"attribute": {
"mobile": "081111111",
"action": "purchase",
"customerGrading": "diamond"
},
"cart": {
"items": [
{
"name": "Ipad Pro 12.9",
"sku": "IPAD-2019",
"amount": 4,
"price": 39000,
"tags": [
"gadget",
"apple"
]
}
]
}
}'
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Get coupon template summary successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during get coupon template summary |
Example Response:
"couponTemplateId": "4e5b313b-15c5-4703-a822-7e74ed0243b2",
"actions": [
{
"rule": {
"id": "4f5b313b-15c5-4703-a822-7e74ed0243a5",
"name": "Rule1",
"thenOperator": "AND"
},
"campaign": {
"id": "5d819473b44cb50001ee3c5b",
"name": "Test001",
"startDate": "2019-09-17T17:00:00Z",
"endDate": null,
"refCode": "Test001",
"imageUrl": null
},
"action": {
"action": "DISCOUNT",
"internalAction": false,
"actionRef": "eeabe9e5-4e25-4e1b-8b11-462f38f329e6",
"data": [
{
"type": null,
"attribute": "sku",
"op": null,
"value": "A001",
"valueType": "STRING",
"note": null,
"resolveAction": false
},
{
"type": null,
"attribute": "amount",
"op": null,
"value": "1",
"valueType": "STRING",
"note": null,
"resolveAction": false
}
]
}
}
]
}
Example Response for error cases:
- Invalid coupon
{
"type": "https://www.jhipster.tech/problem/problem-with-message",
"status": 400,
"path": "/api/projects/project-id-test/coupons/codes/apply-coupon",
"errors": [
{
"code": "COUPON_NOT_VALID",
"name": "The coupon is not valid due to incorrect code or conditions or time period doesn't match"
}
],
"message": "error.http.400"
}
- Exceed usage limit
STATUS_CODE:400
{
"type": "https://www.jhipster.tech/problem/problem-with-message",
"status": 400,
"path": "/api/projects/project-id-test/coupons/codes/apply-coupon",
"errors": [
{
"code": "EXCEED_LIMIT_COUPON",
"name": "The coupon is not valid due to incorrect code or conditions or time period doesn't match"
}
],
"message": "error.http.400"
}
- Exceed campaign quota limit
{
"type": "https://www.jhipster.tech/problem/problem-with-message",
"status": 400,
"path": "/api/projects/project-id-test/coupons/codes/apply-coupon",
"errors": [
{
"code": "EXCEED_CAMPAIGN_QUOTA_LIMIT",
"name": "The coupon is exceed quota limit to use for this campaign"
}
],
"message": "error.http.400"
}
# Coupon Redeem API
Method: POST Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/codes/redeem
Description: Redeem benefit from coupon code.
- Scope:
- coupon.code.a
- coupon.code.u
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body:
Param | Description | Type | Required |
---|---|---|---|
couponCode | Code of coupon for redeem. | String | Y |
channel | Channel for redeem. | String | Y |
usedAt | Dynamic field for keep transaction redeem that use by whom | Map<String, String> | N |
orderRef | Reference for tracking order and coupon. | String | N |
attribute | Attribute for campaign to search campaign condition. | Map<String, String> | Y |
cart | Cart for campaign to search campaign condition. | Object | N |
cart.items | Item in cart | String | N |
cart.items.sku | Sku of item for identify this item. | String | Y |
cart.items.tags | Tags that list of tag name of this item. | Array | Y |
cart.items.name | Name of item. | String | N |
cart.items.amount | Amount of item. | Number | N |
cart.items.price | Price of this item. | Double | N |
Example Request:
curl --location --request POST 'https://alpha-platform.weomni-test.com/coupon/api/projects/6088ecd806b0ab000182e538/coupons/codes/redeem' \
--header 'Authorization: Bearer {Bearer token} ' \
--header 'Content-Type: application/json' \
--data-raw '{
"couponCode": "FAME_tmvDGDxmiT",
"channel": "Joker",
"orderRef": "purchase-43243d-34dd",
"usedAt" : {
"merchantId": "EGG_POS_1234565"
},
"attribute": {
"mobile": "081111111",
"action": "purchase",
"customerGrading": "diamond"
},
"cart": {
"items": [
{
"name": "Ipad Pro 12.9",
"sku": "IPAD-2019",
"amount": 4,
"price": 39000,
"tags": [
"gadget",
"apple"
]
}
]
}
}'
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Get coupon template summary successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during get coupon template summary |
Example Response:
{
"id": "6094edc1477756000142abc2",
"couponCode": "JOKER_DISCOUNT_IXumR",
"usedDate": "2021-05-07T07:35:29.064385Z",
"usedAt" : {
"merchantId": "EGG_POS_1234565"
},
"actionTxs": [
{
"createdBy": "coupon_campaign",
"createdDate": "2021-05-07T07:35:29.009Z",
"lastModifiedBy": "coupon_campaign",
"lastModifiedDate": "2021-05-07T07:35:29.009Z",
"id": "6094edc11631ed000179221b",
"externalTxRef": null,
"status": "COMPLETE",
"then": {
"action": "DISCOUNT",
"internalAction": false,
"actionRef": "24a4eaef-671a-415e-b779-6911e84c7b36",
"data": [
{
"type": null,
"attribute": "amount",
"op": null,
"value": "100",
"valueType": "STRING",
"note": null,
"resolveAction": false
},
{
"type": null,
"attribute": "unit",
"op": null,
"value": "Baht",
"valueType": "STRING",
"note": null,
"resolveAction": false
}
]
},
"projectId": "6088ecd806b0ab000182e538",
"errors": []
}
]
}
Example Response for error cases:
- Invalid coupon
{
"type": "https://www.jhipster.tech/problem/problem-with-message",
"status": 400,
"path": "/api/projects/project-id-test/coupons/codes/redeem",
"errors": [
{
"code": "COUPON_NOT_VALID",
"name": "The coupon is not valid due to incorrect code or conditions or time period doesn't match"
}
],
"message": "error.http.400"
}
- Exceed usage limit
STATUS_CODE:400
{
"type": "https://www.jhipster.tech/problem/problem-with-message",
"status": 400,
"path": "/api/projects/project-id-test/coupons/codes/redeem",
"errors": [
{
"code": "EXCEED_LIMIT_COUPON",
"name": "The coupon is not valid due to incorrect code or conditions or time period doesn't match"
}
],
"message": "error.http.400"
}
- Exceed campaign quota limit
{
"type": "https://www.jhipster.tech/problem/problem-with-message",
"status": 400,
"path": "/api/projects/project-id-test/coupons/codes/redeem",
"errors": [
{
"code": "EXCEED_CAMPAIGN_QUOTA_LIMIT",
"name": "The coupon is exceed quota limit to use for this campaign"
}
],
"message": "error.http.400"
}
# Coupon Void API
Method: POST Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/codes/void
Description: Void coupon by redemption id.
- Scope:
- coupon.code.a
- coupon.code.u
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Request Body:
Param | Description | Type | Required |
---|---|---|---|
redemptionId | Id from redeem coupon | String | Y |
voidBy | Keep transacation for void by whom | String | N |
Example Request:
curl --location --request POST 'https://alpha-platform.weomni-test.com/coupon/api/projects/6088ecd806b0ab000182e538/coupons/codes/void' \
--header 'Authorization: Bearer {Bearer Token} \
--header 'Content-Type: application/json' \
--data-raw '{
"redemptionId": "60a1e778ebcd0b00015a6048",
"voidBy": "EGG_POS_ADMIN_001"
}'
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Get coupon template summary successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during get coupon template summary |
Example Response:
{
"id": "60a1e778ebcd0b00015a6048",
"voidDate": "2021-05-17T03:48:28.067996Z",
"isVoid": true,
"voidBy": "EGG_POS_ADMIN_001"
}
Example Response for error cases:
- Invalid redemption id
STATUS_CODE:400
{
"type": "https://www.jhipster.tech/problem/problem-with-message",
"status": 400,
"path": "/api/projects/6088ecd806b0ab000182e538/coupons/codes/void",
"errors": [
{
"code": "INVALID_REDEMPTION_ID",
"name": "The redemption id is not valid"
}
],
"message": "error.http.400"
}
- Voided redemption id
STATUS_CODE:400
{
"type": "https://www.jhipster.tech/problem/problem-with-message",
"status": 400,
"path": "/api/projects/6088ecd806b0ab000182e538/coupons/codes/void",
"errors": [
{
"code": "VOIDED_REDEMPTION_ID",
"name": "Redemption id has been already voided"
}
],
"message": "error.http.400"
}
# Export Coupon API
Method: POST Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/codes/export
Description: Export coupon with or without the criteria
- Scope:
- coupon.code.r
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Request Body:
Filter Attributes | Method | Support type | Required | Example | ||
---|---|---|---|---|---|---|
Path Variable | ||||||
projectId | String | Y | 5de626d53d901d0001823a6a | |||
Body | ||||||
String, Map | N | |||||
type | String | Y | csv |
Example Request:
curl --location --request POST 'https://alpha-platform.weomni-test.com/coupon/api/projects/5de626d53d901d0001823a6a/coupons/codes/export' \
--header 'Authorization: Bearer {Bearer token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"campaignCode": {
"equals": "CAMPAIGN_CODE"
},
"type": "CSV",
"code": {
"in": ["COUPON_CODE_1", "COUPON_CODE_2"]
},
"batchId": {
"equals": "BATCH_ID",
}
}'
Response Codes:
HTTP Status Code | Description | Remark |
---|---|---|
200 | OK | Export coupon(s) successfully |
500 | Internal server error | Required fields is not defined or invalid value format |
400 | Bad request | When given the unsupported type |
401 | Unauthorized | Access Token is invalid or expired |
403 | Forbidden | No Permission |
404 | Not found | There is an error during get coupons |
415 | Unsupported Media Type | The content type is in an unsupported format |
Example Response:
This will return a file as a format coupons_YYYYMMddHHmmss.{type}
e.g. coupons_20210510164011.csv
Example Response for error cases:
- Unsupported export type
{
"type": "https://www.jhipster.tech/problem/problem-with-message",
"status": 400,
"path": "/api/projects/project-id-test/coupons/codes/export",
"errors": [
{
"code": "COUPON_EXPORT_TYPE_UNSUPPORTED",
"name": "This export type is unsupported"
}
],
"message": "error.http.400"
}
- Writing file error
{
"type": "https://www.jhipster.tech/problem/problem-with-message",
"status": 500,
"path": "/api/projects/project-id-test/coupons/codes/redeem",
"errors": [
{
"code": "WRITING_CSV_ERROR",
"name": "Error during writing to a csv file"
}
],
"message": "error.http.500"
}
- Internal server error
{
"type": "https://www.jhipster.tech/problem/problem-with-message",
"status": 500,
"path": "/api/projects/project-id-test/coupons/codes/redeem",
"errors": [
{
"code": "EXPORT_COUPON_INTERNAL_SERVER_ERROR",
"name": "Export coupon internal server error"
}
],
"message": "error.http.500"
}
# Get List of Coupon Tracking Based On The Filter Condition API
Method: GET Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/trackings
Description: Get list of coupon tracking based on filter condition
- Scope:
- coupon.tracking.a
- coupon.tracking.r
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Params :
Param | Method | Type | Required |
---|---|---|---|
batchId | String | N | |
campaignCode | equals | String | N |
code | in | String | N |
usedAt | contains | Map | N |
campaignRedemptionId | doesNotContain | String | N |
orderRef | notEquals | String | N |
createdBy | specified | String | N |
voidBy | String | N | |
isVoid | equals notEquals in specified | boolean | N |
voidDate usedDate | equals lessThan lessThanOrEqual greaterThan greaterThanOrEqual | Date | N |
Example Request:
curl --location --request GET 'https://alpha-platform.weomni-test.com/coupon/api/projects/6088ecd806b0ab000182e538/coupons/trackings?code.equals=JOKER_00092' \
--header 'Authorization: Bearer {bearer token}
Example Response:
[
{
"id": "608bdb92129f3d000141b608",
"projectId": "6088ecd806b0ab000182e538",
"campaignCode": "JOKER-DISCOUT-100-BAHT",
"batchId": "608bda8a129f3d000141b5d5",
"code": "JOKER_00092",
"usedAt": {
"terminalId": "69000712",
"merchantId": "0022796",
"outletId": "00001"
},
"usedDate": "2021-04-30T10:27:30.073Z",
"campaignRedemptionId": null,
"orderRef": null,
"isVoid": false,
"voidDate": null
}
]
# Get Detail of Coupon Tracking API
Method: GET Path: {WeOmni_Platform_Domain}/coupon/api/projects/{projectId}/coupons/trackings/{id}
Description: Get detail of coupon tracking by id.
- Scope:
- coupon.tracking.a
- coupon.tracking.r
Request Header:
Param | Description | Required | Example |
---|---|---|---|
Authorization | The OAuth2 authentication with the O2O System | Y | Bearer {O2O Access Token} |
Content-Type | The MIME type of this content | Y | application/json |
Example Request:
curl --location --request GET 'https://alpha-platform.weomni-test.com/coupon/api/projects/6088ecd806b0ab000182e538/coupons/trackings/60a36cc61b56860001164356' \
--header 'Authorization: Bearer {bearer token}
Example Response:
{
"id": "60a36cc61b56860001164356",
"projectId": "6088ecd806b0ab000182e538",
"campaignCode": "JOKER-DISCOUT-100=-BAHT",
"batchId": "609cad72f41bed0001c26591",
"code": "DUP2_1",
"usedAt": null,
"usedDate": "2021-05-18T07:29:10.398Z",
"campaignRedemptionId": "8678e57f-e6eb-46d0-94de-d9660c4fd4eb",
"orderRef": "purchase-43243d-34dd",
"isVoid": true,
"voidDate": "2021-05-18T07:29:26.025Z"
}
Example Response for error cases:
- Not found tracking id
STATUS_CODE:400
{
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Not Found",
"status": 404,
"detail": "404 NOT_FOUND",
"path": "/api/projects/6088ecd806b0ab000182e538/coupons/trackings/60a36cc61b568600011643563",
"message": "error.http.404"
}