Listing coupons

In this tutorial we will show how to list the coupons registered on a specific advertisement.

Prerequisities

To perform this tutorial you will need to get an authentication token for your company from SMOC.AI. At this time there is no direct way to get this yourself but it’s being worked on.

In this tutorial we will use the token

XDaNkCDLpUcY4OVWBkAwyOdn

as the value to simulate having a real token available.

All data returned in this tutorial is test data only.

Finally you are going to need the command line curl, a similar GUI tool or your favorite programming language to perform the calls. In our examples we will lean on the use of curl for our examples.

Retriving the available campaigns

To fetch the list of campaigns you can perform the following curl operation.

curl -X GET "http://localhost:8080/api/company/campaign" -H "accept: */*" -H "token: XDaNkCDLpUcY4OVWBkAwyOdn"

This will fetch the list of campaigns available for your company. After executing the operation we get the following results.

{
  "status": true,
  "entries": [
    {
      "id": "180",
      "title": "Fleks Referral",
      "description": null,
      "imageUrl": "/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBdU1CIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--53c6c9d3bba130f942d64a4da08d51c6353e6b4b/jorge-saavedra-94qZsII4kN8-unsplash.jpg",
      "multipleReferrals": false,
      "operatorOnly": true,
      "startDate": "2020-08-23T22:00:00.000+0000",
      "endDate": "2020-12-30T23:00:00.000+0000",
      "createdOn": "2020-08-24T08:08:31.915+0000",
      "updatedOn": "2020-08-24T08:08:31.938+0000"
    }
  ]
}

This tells us we have a campaign called Fleks Referral with the id 180. Next we need to fetch the list of advertisements associated with the specific campaign with id 180.

Retrieve the list of Campaign advertisements

Lets fetch the list of advertisements.

curl -X GET "http://localhost:8080/api/company/campaign/181/advertisement" -H "accept: */*" -H "token: XDaNkCDLpUcY4OVWBkAwyOdn"

This returns the following results.

{
  "status": true,
  "entries": [
    {
      "id": "494",
      "title": "Get friends to join and you'll earn more points",
      "category": "view_display",
      "active": true,
      "dailyBudget": 0,
      "costThreshold": 0,
      "currency": null,
      "bidCents": 1000,
      "bidCurrency": "NOK",
      "createdOn": "2020-08-24T08:12:33.244+0000",
      "updatedOn": "2020-12-02T08:02:56.716+0000"
    }
  ]
}

Finally we can use the combination of the campaign id 181 and the advertisement id 494 to fetch the list of associated coupons.

Retrieve the list of coupons

Lets fetch the list of coupons.

curl -X GET "http://localhost:8080/api/company/campaign/181/advertisement/494/coupon" -H "accept: */*" -H "token: XDaNkCDLpUcY4OVWBkAwyOdn"

This returns the following coupon results.

{
  "status": true,
  "entries": [
    {
      "id": "6530",
      "advertisementId": "494",
      "operatorId": "14",
      "reward": {
        "id": "583",
        "value": 10,
        "currency": {
          "id": "11",
          "operatorId": "14",
          "key": "fleks points",
          "universal": false,
          "title": "Fleks points",
          "conversionRate": 1,
          "category": "cars"
        }
      },
      "user": null,
      "expiresOn": "2020-11-24T00:00:00.000+0000",
      "category": "automatic_after_view",
      "code": "79",
      "redeemed": true,
      "createdOn": "2020-11-16T00:00:00.000+0000",
      "updatedOn": "2020-11-16T00:00:00.000+0000"
    }
  ]
}

The coupons represents rewards for end users given specific platform interactions or referral interactions.