Customer Campaign API

These endpoints will allow you to see and use Reward Campaigns for a customer.

Get all campaigns bought by a customer

To retrieve list of bought rewards by a specific customer use api/admin/customer/{customer}/campaign/bought endpoint with the GET method.

Definition

GET /api/admin/customer/{customer}/campaign/bought
Parameter Parameter type Description
Authorization header Token received during authentication
customer request Customer UUID
includeDetails query (optional) Include details about bought campaign For example 1
page query (optional) Start from page, by default 1
perPage query (optional) Number of items to display per page, by default = 10
sort query (optional) Sort by column name, by default = firstName
direction query (optional) Direction of sorting [ASC, DESC], by default = ASC

Example

curl http://localhost:8181/api/admin/customer/00000000-0000-474c-b092-b0dd880c07e1/campaign/bought \
    -X "GET" \
    -H "Accept:application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization:\ Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..."

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an exemplary value. Your value can be different. Read more about Authorization in the.

Note

The customer = 00000000-0000-474c-b092-b0dd880c07e1 id is an exemplary value. Your value can be different. Check in the list of all customers if you are not sure which id should be used.

Exemplary Response

STATUS: 200 OK
{
  "campaigns": [],
  "total": 0
}

Exemplary Response

STATUS: 200 OK
{
  "campaigns": [
    {
      "purchaseAt": "2018-01-30T18:23:24+0100",
      "costInPoints": 20,
      "campaignId": {
        "campaignId": "000096cf-32a3-43bd-9034-4df343e5fd93"
      },
      "used": false,
      "coupon": {
        "code": "123"
      }
    }
  ],
  "total": 1
}

Example

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an exemplary value. Your value can be different. Read more about Authorization in the.

Note

The customer = 00000000-0000-474c-b092-b0dd880c07e1 id is an exemplary value. Your value can be different. Check in the list of all customers if you are not sure which id should be used.

Exemplary Response

STATUS: 200 OK
{
  "campaigns": [
    {
      "purchaseAt": "2018-01-30T18:23:24+0100",
      "costInPoints": 20,
      "campaignId": {
        "campaignId": "000096cf-32a3-43bd-9034-4df343e5fd93"
      },
      "campaign": {
        "levels": [
          "000096cf-32a3-43bd-9034-4df343e5fd93",
          "e82c96cf-32a3-43bd-9034-4df343e5fd94",
          "000096cf-32a3-43bd-9034-4df343e5fd94",
          "0f0d346e-9fd0-492a-84aa-2a2b61419c97"
        ],
        "segments": [],
        "coupons": [
          "123"
        ],
        "campaignId": "000096cf-32a3-43bd-9034-4df343e5fd93",
        "reward": "discount_code",
        "name": "tests",
        "active": true,
        "costInPoints": 20,
        "singleCoupon": false,
        "unlimited": false,
        "limit": 10,
        "limitPerUser": 2,
        "campaignActivity": {
          "allTimeActive": true
        },
        "campaignVisibility": {
          "allTimeVisible": true
        },
        "segmentNames": [],
        "levelNames": {
          "000096cf-32a3-43bd-9034-4df343e5fd93": "level0",
          "e82c96cf-32a3-43bd-9034-4df343e5fd94": "level1",
          "000096cf-32a3-43bd-9034-4df343e5fd94": "level2",
          "0f0d346e-9fd0-492a-84aa-2a2b61419c97": "level3"
        },
        "usageLeft": 0,
        "visibleForCustomersCount": 6,
        "usersWhoUsedThisCampaignCount": 1
      },
      "used": false,
      "coupon": {
        "code": "123"
      }
    }
  ],
  "total": 1
}

Mark specific coupon as used / not used by a customer

To mark a specific coupon as used / nor used call /api/admin/customer/{customer}/campaign/{campaign}/coupon/{coupon} endpoint with the POST method.

Definition

POST /api/admin/customer/{customer}/campaign/{campaign}/coupon/{coupon}
Parameter Parameter type Description
Authorization header Token received during authentication
customer request Customer UUID
campaign request Campaign UUI
coupon request Coupon UUID
used request Set 1 if used, otherwise 0

Example

curl http://localhost:8181/api/admin/customer/00000000-0000-474c-b092-b0dd880c07e1/campaign/000096cf-32a3-43bd-9034-4df343e5fd93/coupon/123 \
    -X "POST" \
    -d "used=1" \
    -H "Accept: application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..."

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an exemplary value. Your value can be different. Read more about Authorization in the.

Note

The customer = 00000000-0000-474c-b092-b0dd880c07e1 id is an exemplary value. Your value can be different. Check in the list of all customers if you are not sure which id should be used.

Note

The campaign = 000096cf-32a3-43bd-9034-4df343e5fd93 id is an exemplary value. Your value can be different. Check in the list of all campaigns if you are not sure which id should be used.

Note

The coupon = 123 id is an exemplary value. Your value can be different. Check in the list of all customer’s coupons if you are not sure which id should be used.

Exemplary Response

STATUS: 200 OK
{
  "used": "1"
}

Exemplary Response

STATUS: 200 OK
{
  "used": false
}

Get all campaigns available for logged in customer

To get all campaign available for logged in customer use /api/customer/campaign/available endpoint with the POST method.

Definition

GET /api/customer/campaign/available
Parameter Parameter type Description
Authorization header Token received during authentication
page query (optional) Start from page, by default 1
perPage query (optional) Number of items to display per page, by default = 10
sort query (optional) Sort by column name, by default = firstName
direction query (optional) Direction of sorting [ASC, DESC], by default = ASC

Example

curl http://localhost:8181/api/customer/campaign/available \
    -X "GET" \
    -H "Accept: application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..."

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an exemplary value. Your value can be different. Read more about Authorization in the.

Warning

Calling this endpoint is meaningful only when you call it with authorization token that belongs to the logged in customer. Otherwise it will return 403 Forbidden error response.

Exemplary Response

STATUS: 200 OK
{
  "campaigns": [
    {
      "campaignId": "000096cf-32a3-43bd-9034-4df343e5fd92",
      "reward": "discount_code",
      "name": "for test",
      "active": true,
      "costInPoints": 10,
      "singleCoupon": false,
      "unlimited": false,
      "limit": 10,
      "limitPerUser": 2,
      "campaignActivity": {
        "allTimeActive": true
      },
      "campaignVisibility": {
        "allTimeVisible": true
      },
      "segmentNames": [],
      "levelNames": {
        "000096cf-32a3-43bd-9034-4df343e5fd93": "level0",
        "e82c96cf-32a3-43bd-9034-4df343e5fd94": "level1",
        "000096cf-32a3-43bd-9034-4df343e5fd94": "level2",
        "0f0d346e-9fd0-492a-84aa-2a2b61419c97": "level3"
      },
      "usageLeft": 1,
      "usageLeftForCustomer": 1,
      "canBeBoughtByCustomer": true,
      "visibleForCustomersCount": 6,
      "usersWhoUsedThisCampaignCount": 0
    }
  ],
  "total": 1
}

Get all campaigns bought by logged in customer

To get all campaign bought by logged in customer use /api/customer/campaign/bought endpoint with the POST method.

Definition

GET /api/customer/campaign/bought
Parameter Parameter type Description
Authorization header Token received during authentication
includeDetails query (optional) Include details about bought campaign For example 1
page query (optional) Start from page, by default 1
perPage query (optional) Number of items to display per page, by default = 10
sort query (optional) Sort by column name, by default = firstName
direction query (optional) Direction of sorting [ASC, DESC], by default = ASC

Example

curl http://localhost:8181/api/customer/campaign/bought \
    -X "GET" \
    -H "Accept: application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..."

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an exemplary value. Your value can be different. Read more about Authorization in the.

Warning

Calling this endpoint is meaningful only when you call it with authorization token that belongs to the logged in customer. Otherwise it will return 403 Forbidden error response.

Exemplary Response

STATUS: 200 OK
{
  "campaigns": [
    {
      "purchaseAt": "2018-01-30T18:23:24+0100",
      "costInPoints": 20,
      "campaignId": {
        "campaignId": "000096cf-32a3-43bd-9034-4df343e5fd93"
      },
      "used": false,
      "coupon": {
        "code": "123"
      }
    }
  ],
  "total": 1
}

Example

curl http://localhost:8181/api/customer/campaign/bought \
    -X "GET" \
    -H "Accept: application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..." \
    -d "includeDetails=1"

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an exemplary value. Your value can be different. Read more about Authorization in the.

Warning

Calling this endpoint is meaningful only when you call it with authorization token that belongs to the logged in customer. Otherwise it will return 403 Forbidden error response.

Exemplary Response

STATUS: 200 OK
{
  "campaigns": [
    {
      "purchaseAt": "2018-01-30T18:23:24+0100",
      "costInPoints": 20,
      "campaignId": {
        "campaignId": "000096cf-32a3-43bd-9034-4df343e5fd93"
      },
      "campaign": {
        "campaignId": "000096cf-32a3-43bd-9034-4df343e5fd93",
        "reward": "discount_code",
        "name": "tests",
        "active": true,
        "costInPoints": 20,
        "singleCoupon": false,
        "unlimited": false,
        "limit": 10,
        "limitPerUser": 2,
        "campaignActivity": {
          "allTimeActive": true
        },
        "campaignVisibility": {
          "allTimeVisible": true
        },
        "segmentNames": [],
        "levelNames": {
          "000096cf-32a3-43bd-9034-4df343e5fd93": "level0",
          "e82c96cf-32a3-43bd-9034-4df343e5fd94": "level1",
          "000096cf-32a3-43bd-9034-4df343e5fd94": "level2",
          "0f0d346e-9fd0-492a-84aa-2a2b61419c97": "level3"
        },
        "usageLeft": 0,
        "visibleForCustomersCount": 6,
        "usersWhoUsedThisCampaignCount": 1
      },
      "used": false,
      "coupon": {
        "code": "123"
      }
    }
  ],
  "total": 1
}

Buy campaign by logged in customer

Buy campaign bought by logged in customer use /api/customer/campaign/{campaign}/buy endpoint with the POST method.

Definition

POST /api/customer/campaign/{campaign}/buy
Parameter Parameter type Description
Authorization header Token received during authentication
campaign request Campaign UUID

Example

curl http://localhost:8181/api/customer/campaign/000096cf-32a3-43bd-9034-4df343e5fd92/buy
    -X "POST" \
    -H "Accept: application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..."

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an exemplary value. Your value can be different. Read more about Authorization in the.

Warning

Calling this endpoint is meaningful only when you call it with authorization token that belongs to the logged in customer. Otherwise it will return 403 Forbidden error response.

Exemplary Response

STATUS: 200 OK
{
  "coupon": {
    "code": "123"
  }
}

Exemplary Error Response

If there is no more coupons left, you’ll receive follow responses.

STATUS: 400 Bad Request
{
  "error": "No coupons left"
}

Exemplary Error Response

If you don’t have enough points to buy a reward, you’ll receive follow responses.

STATUS: 400 Bad Request
{
  "error": "Not enough points"
}

Mark specific coupon as used / not used by a logged in customer

To mark a specific coupon as used / nor used by a logged in customer call /api/admin/campaign/{campaign}/coupon/{coupon} endpoint with the POST method.

Definition

POST /api/admin/campaign/{campaign}/coupon/{coupon}
Parameter Parameter type Description
Authorization header Token received during authentication
campaign request Campaign UUI
coupon request Coupon UUID
used request Set 1 if used, otherwise 0

Example

curl http://localhost:8181/api/admin/campaign/000096cf-32a3-43bd-9034-4df343e5fd93/coupon/123 \
    -X "POST" \
    -d "used=1" \
    -H "Accept: application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..."

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an exemplary value. Your value can be different. Read more about Authorization in the.

Warning

Calling this endpoint is meaningful only when you call it with authorization token that belongs to the logged in customer. Otherwise it will return 403 Forbidden error response.

Note

The campaign = 000096cf-32a3-43bd-9034-4df343e5fd93 id is an exemplary value. Your value can be different. Check in the list of all campaigns if you are not sure which id should be used.

Note

The coupon = 123 id is an exemplary value. Your value can be different. Check in the list of all customer’s coupons if you are not sure which id should be used.

Exemplary Response

STATUS: 200 OK
{
  "used": "1"
}

Exemplary Response

STATUS: 200 OK
{
  "used": false
}

Get all campaigns bought by a customer (seller)

To retrieve list of bought rewards by a specific customer use api/seller/customer/{customer}/campaign/bought endpoint with the GET method.

Definition

GET /api/seller/customer/{customer}/campaign/bought
Parameter Parameter type Description
Authorization header Token received during authentication
customer request Customer UUID
includeDetails query (optional) Include details about bought campaign For example 1
page query (optional) Start from page, by default 1
perPage query (optional) Number of items to display per page, by default = 10
sort query (optional) Sort by column name, by default = firstName
direction query (optional) Direction of sorting [ASC, DESC], by default = ASC

Example

curl http://localhost:8181/api/seller/customer/00000000-0000-474c-b092-b0dd880c07e1/campaign/bought \
    -X "GET" \
    -H "Accept:application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization:\ Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..."

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an exemplary value. Your value can be different. Read more about Authorization in the.

Note

The customer = 00000000-0000-474c-b092-b0dd880c07e1 id is an exemplary value. Your value can be different. Check in the list of all customers if you are not sure which id should be used.

Note

When you will use endpoints starting with /api/seller you need to authorize using seller account credentials.

Note

As a seller you will receive less amount of information about campaign than an administrator.

Exemplary Response

STATUS: 200 OK
{
  "campaigns": [],
  "total": 0
}

Exemplary Response

STATUS: 200 OK
{
  "campaigns": [
    {
      "purchaseAt": "2018-01-30T18:23:24+0100",
      "costInPoints": 20,
      "campaignId": {
        "campaignId": "000096cf-32a3-43bd-9034-4df343e5fd93"
      },
      "used": false,
      "coupon": {
        "code": "123"
      }
    }
  ],
  "total": 1
}

Example

curl http://localhost:8181/api/seller/customer/00000000-0000-474c-b092-b0dd880c07e1/campaign/bought \
    -X "GET" -H "Accept: application/json" \
    -H "Content-type: application/x-www-form-urlencoded" \
    -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6..." \
    -d "includeDetails=1" \
    -d "page=1" \
    -d "perPage=1" \
    -d "sort=used" \
    -d "direction=DESC"

Note

The eyJhbGciOiJSUzI1NiIsInR5cCI6… authorization token is an exemplary value. Your value can be different. Read more about Authorization in the.

Note

The customer = 00000000-0000-474c-b092-b0dd880c07e1 id is an exemplary value. Your value can be different. Check in the list of all customers if you are not sure which id should be used.

Note

When you will use endpoints starting with /api/seller you need to authorize using seller account credentials.

Note

As a seller you will receive less amount of information about campaign than an administrator.

Exemplary Response

STATUS: 200 OK
{
  "campaigns": [
    {
      "purchaseAt": "2018-01-30T18:23:24+0100",
      "costInPoints": 20,
      "campaignId": {
        "campaignId": "000096cf-32a3-43bd-9034-4df343e5fd93"
      },
      "campaign": {
        "levels": [
          "000096cf-32a3-43bd-9034-4df343e5fd93",
          "e82c96cf-32a3-43bd-9034-4df343e5fd94",
          "000096cf-32a3-43bd-9034-4df343e5fd94",
          "0f0d346e-9fd0-492a-84aa-2a2b61419c97"
        ],
        "segments": [],
        "coupons": [
          "123"
        ],
        "campaignId": "000096cf-32a3-43bd-9034-4df343e5fd93",
        "reward": "discount_code",
        "name": "tests",
        "active": true,
        "costInPoints": 20,
        "singleCoupon": false,
        "unlimited": false,
        "limit": 10,
        "limitPerUser": 2,
        "campaignActivity": {
          "allTimeActive": true
        },
        "campaignVisibility": {
          "allTimeVisible": true
        },
        "segmentNames": [],
        "levelNames": {
          "000096cf-32a3-43bd-9034-4df343e5fd93": "level0",
          "e82c96cf-32a3-43bd-9034-4df343e5fd94": "level1",
          "000096cf-32a3-43bd-9034-4df343e5fd94": "level2",
          "0f0d346e-9fd0-492a-84aa-2a2b61419c97": "level3"
        },
        "usageLeft": 0,
        "visibleForCustomersCount": 6,
        "usersWhoUsedThisCampaignCount": 1
      },
      "used": false,
      "coupon": {
        "code": "123"
      }
    }
  ],
  "total": 1
}