Appearance
Creating a promotion campaign
WARNING
This feature is not available in the Free trial.
INFO
If you missed it, see what we mean by campaigns here.
It can be hard to understand all these concepts at first glance, 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
1. 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 objects onto the command line. See our "Optimizing and mastering rules" article to understand how to craft rules for a campaign.
File: body.json
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"
}{
"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:
shell
POST https://api.omen-data.io/v2/campaigns
Content-Type: application/json
Authorization: Bearer {your_access_token}
./body.jsonPOST https://api.omen-data.io/v2/campaigns
Content-Type: application/json
Authorization: Bearer {your_access_token}
./body.jsonThe API Documentation for campaign creation can be found here.
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:
shell
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
}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.
2. 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.
shell
POST https://api.omen-data.io/v2/campaigns/{campaign_uid}/documents?name={document_identifier}
Authorization: Bearer {your_access_token}
{path_to_your_file.jpg}POST https://api.omen-data.io/v2/campaigns/{campaign_uid}/documents?name={document_identifier}
Authorization: Bearer {your_access_token}
{path_to_your_file.jpg}The document_identifier field is a way for you to retrieve this specific document later.
And you will get in response something similar to this:
shell
HTTP/1.1 200 OK
{
[...]
"name": "document_identifier",
"campaignUid": "campaign_UID",
"status" : "PROCESSING", //Means that your receipt is currently being processed
[...]
}HTTP/1.1 200 OK
{
[...]
"name": "document_identifier",
"campaignUid": "campaign_UID",
"status" : "PROCESSING", //Means that your receipt is currently being processed
[...]
}3. 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:
shell
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
}
}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.
Kweeri