This can be hard to understand all those data at first usage, so we recommend using Kweeri's web platform to create and manage your first promotion campaigns, as the UI is far more understandable.
Creating a promotion campaign
We will detail the next workflow schema by 2 step-by-step guides, one for creating campaigns and rules from the web platform and another one for API requests.
Step by step guide
-
Creating rules and Campaigns
We will create a separate JSON file for posting this one, as it can quickly get complex to write / read large json object onto the command line.
See the "How to set rules" article to understand how to craft rules for a campaignfile:
body.json
{ "name" : "My first campaign", "rules" : { "name": "Labeyrie", "uid": "123", "dateRule": { "min": "2019-01-01", "max": "2019-11-01" }, "priceRule": { "eligibleOnly": 20.25, "totalAmount": 40 }, "signRule": { "signList": [ "Cora", "Auchan", "Carrefour" ] }, "itemRule": { "or": [{ "term": "Labeyrie" },{ "term": "Blini" }], "quantityRequired": 2,
"strategy":"QUANTITY", "not": [{ "term": "Auchan" },{ "term": "Cora" }] } }, "dominantLanguage" : "fr-FR" }And then post the json to the right route to create the campaign:
http POST /campaigns < body.json
This will create a new campaign with the provided name and the set of rules you wrote. Then we will send you back some useful information for the next steps like the campaign ID and some reminders of what you have input to the API.
You will get a response looking like this:
HTTP/1.1 200 OK { "uid": "{campaign_UID}", //Save this somewhere for the next step "rules": [...], "name": "My first campaign", "dominantLanguage": "fr-FR" , [...] //More metadata }
You can also retrieve any of your campaign by using this route.
-
Sending a receipt to a campaign.
Now that you have the campaign
uid
that you gathered from the previous request, you can send a receipt to this very campaign in order to launch the analysis and validate the rules set-up against the receipt.http -f POST /campaigns/{campaign_uid}/documents?name={document_identifier} @./image.jpg
Note: The
document_identifier
field is a way for you to retrieve this specific document later for further usage.
And you will get in response something similar to this:
HTTP/1.1 200 OK { [...] "name": "document_identifier", "campaignUid": "campaign_UID", "status" : "PROCESSING", //Means that your receipt is currently being processed [...] }
-
Getting back results and understanding validation
When you receive back the results of the analysed receipt against the set of rules you will get this kind of data format:HTTP/1.1 200 OK "rules" : { "name": "MyPromotionRule", "uid": "123", "dateRule": { "min": "2019-01-01", "max": "2019-11-01", "isMatched" : true //This particular rule has matched }, "priceRule": { "eligibleOnly": 20.25, "totalAmount": 40, "isMatched": true //This particular rule has matched }, "signRule": { "signList": [ "Cora", "Auchan", "Carrefour" ], "isMatched" : true //This particular rule has matched }, "allRulesMatched": true //Indicate whether or not all rules have matched }
In this case each rule has matched, but you will probably get different results depending on the rules you set when creating the campaign.
For more details about all possible rules and responses please read carefully the following API documentation.
Rules and next steps
Next steps are:
Comments
0 comments
Please sign in to leave a comment.