NAV Navbar
cUrl NodeJS PHP Ruby

Introduction

The Footprints Omnichannel CRM is a SaaS platform that collects leads, meaning that it exposes an API that allows external applications to push leads into the system.

Authentication

To authorize, use this code:

    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/token")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request["Authorization"] = 'Basic base64('{{key}}:{{secret}}')'
    request.body = "grant_type=client_credentials&pin=1234567890"
    
    response = http.request(request)
    puts response.read_body
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/api/token", 
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "grant_type=client_credentials&pin=1234567890",
    CURLOPT_HTTPHEADER => array(
      "Authorization: Basic base64('{{key}}:{{secret}}')",
      "Content-Type: application/x-www-form-urlencoded"
    ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

curl --request POST \
--url 'http://{{base_url}}/api/token' \
--header 'Authorization: Basic base64('\''{{key}}:{{secret}}'\'')' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=client_credentials&pin=1234567890
    var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "token"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded",
        "Authorization": "Basic base64('{{key}}:{{secret}}')"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ grant_type: 'client_credentials', pin=1234567890 }));
    req.end();  

The above command returns JSON structured like this:

{
      "access_token": "3a53f15f7382f61564e3b16a3b81a37354c88f391263adf31be953e80b3f3",
      "token_type": "bearer",
      "expires_in": 31535999,
      "refresh_token": "903173e6a53ae2d6c238ed50ccd1db5b42cb967ce408d370b3f3257eh7e0e295",
      "scope": [
          "app_scope",
          "hostess_scope"
      ],
      "hostess_name": "Test Hostess",
      "hostess_id": "5b30cb85e1267446c5784b75" 
}

You can ask for an API key at office@footprintsforretail.com.

Headers

Content-Type application/x-www-form-urlencoded
 Authorization Basic base64('{{key}}:{{secret}}')

HTTP Request

POST {{base_url}}/api/token

Query Parameters

Parameter Description
grant_type values: client_credentials, pin
pin string

Leads

Add Lead

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/offerCategory/{{offerCategoryId}}/lead?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "userFirstName=Test&userLastName=Test&userEmail=test@test.com&userPhone=0700000000"
    
    response = http.request(request)
    puts response.read_body

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/offerCategory/{{offerCategoryId}}/lead?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "userFirstName=Test&userLastName=Test&userEmail=test@test.com&userPhone=0700000000",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request POST \
    --url 'http://{{base_url}}/api/offerCategory/{{offerCategoryId}}/lead?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'userFirstName=Test&userLastName=Test&userEmail=test@test.com&userPhone=0700000000'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "offerCategory",
        "{{offerCategoryId}}",
        "lead"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ userFirstName: 'Test',
      userLastName: 'Test',
      userEmail: 'test@test.com',
      userPhone: '0700000000' }));
    req.end();

The above command returns JSON structured like this:

 {
      "_id": "6h7adfb9f58363518b370051"
 }

Add new lead method

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/offerCategory/{{offerCategoryId}}/lead

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
offlineCampaignIdoffline campaign id
offerIdoffer id
locationIdlocation id
userFirstNameuser's first name
userLastNameuser's last name
userCNPuser's address
userEmailuser's email address
userPhoneuser's phone
npsmin:0 max:10 - net promoter score - user's rating
userSexpossible values: male, female
userCityuser's city
userCountyuser's county
userCountryuser's country
userAddressuser's address
userFamilyDetalispossible values: "single","married"
userChildrenuser's number of children
userIndustryuser's industry
userCompanyNameuser's company
userCompanyAddressuser's company address
userJobuser's job
userJobDescriptionuser's job description
userIncomeuser's income
userBirthdayuser's birthday, accepted format Y-m-d
userExternalIduser's id from the primary database
userDistrictuser's district
facebookUrlFacebook user profile
imageUrluser profile picture
createdAtdate, accepted format Y-m-d H:i:s
marketingChannelsarray containing objects like channel ('sms', 'email', 'notification', 'dm', 'socialMedia'), type ('owner', 'group', 'partners'), agreed ("true", "false")
customDetails
userCommentsstring containing user comments
hasKidspossible values: "true", "false"
noOfKidsnumber of kids
kidsAgearray of numbers - Ex: [6, 14]
agreeTandcTerms & Conditions Agreement, possible values: "true", "false"
agreePrivacyPrivacy Policy Agreement, possible values: "true", "false"
agreedTargetedMessagesPersonalized Messages Agreement possible values: "true", "false"
isAdultpossible values: "true", "false"

Add prospect

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/prospect?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "avandorUserId=&avandorSession=&userFirstName=Mihai&userLastName=Popescu&userEmail=mihai@popescu.com&userPhone=%2B075364628484&userCountry="
    
    response = http.request(request)
    puts response.read_body

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/prospect?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "avandorUserId=&avandorSession=&userFirstName=Test&userLastName=Test&userEmail=test@test.com&userPhone=0700000000&userCountry=",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request POST \
    --url 'http://{{base_url}}/api/prospect?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'avandorUserId=&avandorSession=userFirstName=Test&userLastName=Test&userEmail=test@test.com&userPhone=0700000000&userCountry='
   var qs = require("querystring");
    var http = require("http");
    
    var options = { 
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "prospect"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ avandorUserId: '',
      avandorSession: '',
      userFirstName: 'Test',
      userLastName: 'Test',
      userEmail: 'test@test.com',
      userPhone: '0700000000',
      userCountry: '' }));
    req.end();

The above command returns JSON structured like this:

 {
      "_id": "6e7adfb9f56363518f370151"
 }

Add new prospect method

HTTP Request

POST {{base_url}}/api/prospect

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
avandorUserIdavandor user id
avandorSessionavandor session (can be sent as a JSON object using an application/json request type)
userFirstNameuser's first name
userLastNameuser's last name
companyNameuser's company name
companyTypeuser's company type
userCountryuser's country
userAddressuser's address
userPositionuser's position
userPhoneuser's phone
userEmailuser's email address
companyWebsiteuser's company website
potentialScoreuser's potential score

Update NPS

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/api/lead/{{lead_id}}/nps?access_token={{access_token}}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Put.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "nps=10&comment%20=test"

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/lead/{{lead_id}}/nps?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "PUT",
      CURLOPT_POSTFIELDS => "nps=10&comment=test",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request PUT \
    --url 'http://{{base_url}}/api/lead/{{lead_id}}/nps?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'nps=10&comment%20=test'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "PUT",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "lead",
        "{{lead_id}}",
        "nps"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ nps: '10', 'comment ': 'test' }));
    req.end();

The above command returns JSON structured like this:


{
  "status": "success"
}

Updates the NPS data for a lead.

HTTP Request

POST {{base_url}}/api/lead/{{lead_id}}/nps

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
nps number min:1, max: 10
comment string

Clients

Get client

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/client?access_token={{access_token}}&userEmail=test@test.ro&userPhone=0700000000")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    
    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/client?access_token={{access_token}}&userEmail=test@test.ro&userPhone=0700000000",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request GET \
    --url 'http://{{base_url}}/api/client?access_token={{access_token}}&userEmail=test@test.ro&userPhone=0700000000' \
    --header 'Content-Type: application/x-www-form-urlencoded'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "client"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

The above command returns JSON structured like this:

 {
      "_id": "5e7adfb9f583635122272a45",
      "userFirstName": "Test",
      "userLastName": "Test",
      "userEmail": "test@test.com",
      "userPhone": "0700000000",
      "timestamp": "2018-08-20T15:35:22.024Z",
      "createdAt": "2018-08-20T15:35:21.962Z",
      "type": "B2C",
      "__v": 2,
      "kidsAge": [],
      "interests": [],
      "preferences": [],
      "employees": [],
      "marketingChannels": [],
      "pointsOfPresence": [],
      "interactionsTimeline": [
          {
              "createdAt": "2018-08-20T15:35:22.024Z",
              "timestamp": "2018-08-20T15:35:22.024Z",
              "icon": "icon-location-city",
              "offlineCampaignId": null,
              "offerCategoryId": {
                  "applicationKeys": [],
                  "consultants": [],
                  "locations": [
                      "59f8385a65157484ba1d11d",
                      "55f838e128a157484ba1d230"
                  ],
                  "offers": [
                      {
                          "_id": "5a05eafff1fa75415cc21f7d",
                          "name": "Contests and prizes",
                          "description": "",
                          "price": "",
                          "offerCategoryId": "5a053cc5b425fe79a0a51254",
                          "userId": "59f855060e3f1a7c9247c4b1",
                          "timestamp": "2017-11-08T11:31:11.633Z",
                          "createdAt": "2017-11-08T11:31:11.633Z",
                          "__v": "0"
                      }
                  ],
                  "__v": 2,
                  "createdAt": "2017-11-06T10:43:17.124Z",
                  "timestamp": "2017-11-08T11:32:32.304Z",
                  "description": "",
                  "name": "Offline campaigns",
                  "_id": "5a103cc5b425fe79a0a41253"
              },
              "leadId": "5b7adfb9f58383518b332a46"
          }
      ],
      "personalAssistance": [],
      "leads": [
          {
              "history": [
                  {
                      "__v": 0,
                      "leadId": "5b7adfb9f58383518b332a46",
                      "userFirstName": "Test",
                      "userLastName": "Test",
                      "userEmail": "test@test.com",
                      "userPhone": "0700000000",
                      "offerCategoryId": "5a003cc5b425fe79a0a41254",
                      "status": "lead",
                      "applicationKey": "072f34176f42a855da5ff3b1",
                      "isMultipart": false,
                      "isComplete": true,
                      "timestamp": "2018-08-20T15:35:22.012Z",
                      "createdAt": "2018-08-20T15:35:22.012Z",
                      "_id": "5b7adfbaf58363518b372a47"
                  }
              ],
              "interactions": [],
              "comments": [],
              "kidsAge": [],
              "__v": 1,
              "type": "B2C",
              "actionRequired": true,
              "createdAt": "2018-08-20T15:35:21.973Z",
              "timestampStatusChange": "2018-08-20T15:35:21.973Z",
              "timestamp": "2018-08-20T15:35:21.973Z",
              "isComplete": true,
              "isMultipart": false,
              "offerCategory": {
                  "consultants": [],
                  "id": "5a003aa5b425aa79a0a41254"
              },
              "application": {
                  "name": "CRM Application",
                  "id": "67a6ff12cf74a7140931626c"
              },
              "applicationKey": "071f34176f42a143da5ff3b1",
              "status": "lead",
              "clientId": "5b7vvfb9f58363518b37r345",
              "offerCategoryId": "5a113cc5b425fe79a0a41254",
              "userPhone": "0700000000",
              "userEmail": "test@test.com",
              "userLastName": "Test",
              "userFirstName": "Test",
              "_id": "5b7adfb9f58363518b372a43",
              "channelId": "5a3e2bac8720349d675c97c9"
          }
      ]
  }

Get a profile based on client's email and phone (mandatory fields) or client's CNP

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/client

Query Parameters

Parameter Description
access_tokenaccess token
userEmailuser's email address
userPhoneuser's phone

Update client

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/client?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Put.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "userFirstName=Test&userLastName=Test&userEmail=test@test.ro&userPhone=0700000000"
    
    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/client?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "PUT",
      CURLOPT_POSTFIELDS => "userFirstName=Test&userLastName=Test&userEmail=test@test.ro&userPhone=0700000000",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request PUT \
    --url 'http://{{base_url}}/api/client?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'userFirstName=Test&userLastName=Test&userEmail=test@test.ro&userPhone=0700000000'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "PUT",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "client"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ userFirstName: 'Test',
      userLastName: 'Test',
      userEmail: 'test@test.ro',
      userPhone: '0700000000' }));
    req.end();

The above command returns JSON structured like this:

 {
    "status": "success"
 }

Update client's data

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

PUT {{base_url}} /api/client

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
userFirstNameuser's first name
userLastNameuser's last name
userCNPuser's address
userEmailuser's email address
userPhoneuser's phone
userSexpossible values: male, female
userCityuser's city
userCountyuser's county
userCountryuser's country
userAddressuser's address
userFamilyDetalispossible values: "single","married"
userChildrenuser's number of children
userIndustryuser's industry
userCompanyNameuser's company
userCompanyAddressuser's company address
userJobuser's job
userJobDescriptionuser's job description
userBirthdayuser's birthday, accepted format Y-m-d
userExternalIduser's id from the primary database
facebookUrlFacebook user profile
imageUrluser profile picture
marketingChannelsarray containing objects like
channel ('sms', 'email', 'notification', 'dm', 'socialMedia'),
type ('owner', 'group', 'partners'),
agreed ("true", "false")
interestsarray de strings ['books', 'cars']
preferencesarray de strings ['books', 'cars']
customDetails
hasKidspossible values: "true", "false"
noOfKidsnumber of kids
kidsAgearray of numbers - Ex: [6, 14]
agreeTandcTerms & Conditions Agreement, possible values: "true", "false"
agreePrivacyPrivacy Policy Agreement, possible values: "true", "false"
agreedTargetedMessagesPersonalized Messages Agreement possible values: "true", "false"
isAdultpossible values: "true", "false"

Delete client

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/api/client?access_token={{access_token}}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Delete.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "userExternalId=2446456"

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/client?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "DELETE",
      CURLOPT_POSTFIELDS => "userExternalId=2446456",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request DELETE \
    --url 'http://{{base_url}}/api/client?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data userExternalId=2446456
    var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "DELETE",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "client"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ userExternalId: '2446456' }));
    req.end();

The above command returns JSON structured like this:

  {
    "status": "success"
  }

Delete client's data

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

DELETE {{base_url}}/api/client

Query Parameters

Parameter Description
access_token access token

Data Tracking

Initialize tracking session


    require 'uri'
  require 'net/http'

  url = URI("http://{{base_url}}/jsapi/init")

  http = Net::HTTP.new(url.host, url.port)

  request = Net::HTTP::Post.new(url)
  request["Content-Type"] = 'application/x-www-form-urlencoded'
  request.body = "appkey=571e64183647a855d0sgf3a3&email=test.email%40test.com"

  response = http.request(request)
  puts response.read_body
   $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/jsapi/init",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "appkey=571e64183647a855d0sgf3a3&email=test.email%40test.com",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/x-www-form-urlencoded"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
    curl --request POST \
    --url 'http://{{base_url}}/jsapi/init' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'appkey=571e64183647a855d0sgf3a3&email=test.email%40test.com'
  var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "jsapi",
        "init"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ appkey: '571e64183647a855d0sgf3a3',
      email: 'test.email%40test.com' }));
    req.end();

The above command returns JSON structured like this:

  
{
    "status": "ok",
    "pid": "b38efdc7087731bbef9d6cb050a6aa9bbcb8beb2178ec42afac83eb5e836f050"
}

This method initialize the tracking session for a specific user. In a succesfull response you'll get an uid value (when the user was identified in our database) or a pid value for a NOT identified user. You can use this value in the next method for sending tracking data.

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/jsapi/init

Body

Parameter Description
appkey application key
email user's email address
technicalInfo[screenSize] screen size (widthxheight), string format
technicalInfo[browserUserAgent] browserUserAgent data; ex: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
technicalInfo[browserType] browser type; ex: Chrome
technicalInfo[appId] iTunes ID / Google Play ID
technicalInfo[deviceOs] device operating system (Windows, Android, iOS ...)

Send tracking data

Use the value obtained from "Initialize tracking session" method in the uid/pid field:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/jsapi/send")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "appkey=571e64183647a855d0sgf3a3&uid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&uType=c&actionType=visit&requestType=action&aditionalData%5Bbrands%5D%5B0%5D=Zara&aditionalData%5Bbrands%5D%5B1%5D=Adidas&aditionalData%5Btenants%5D%5B0%5D=H%26M&aditionalData%5Btenants%5D%5B1%5D=C%26A"

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/jsapi/send",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "appkey=571e64183647a855d0sgf3a3&uid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&uType=c&actionType=visit&requestType=action&aditionalData%5Bbrands%5D%5B0%5D=Zara&aditionalData%5Bbrands%5D%5B1%5D=Adidas&aditionalData%5Btenants%5D%5B0%5D=H%26M&aditionalData%5Btenants%5D%5B1%5D=C%26A",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/x-www-form-urlencoded"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
    curl --request POST \
    --url 'http://{{base_url}}/jsapi/send' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'appkey=571e64183647a855d0sgf3a3&uid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&uType=c&actionType=visit&requestType=action&aditionalData%5Bbrands%5D%5B0%5D=Zara&aditionalData%5Bbrands%5D%5B1%5D=Adidas&aditionalData%5Btenants%5D%5B0%5D=H%26M&aditionalData%5Btenants%5D%5B1%5D=C%26A'
  
  var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "jsapi",
        "send"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ appkey: '571e64183647a855d0sgf3a3',
      uid: 'a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667',
      uType: 'c',
      actionType: 'visit',
      requestType: 'action',
      'aditionalData[brands][0]': 'Zara',
      'aditionalData[brands][1]': 'Adidas',
      'aditionalData[tenants][0]': 'H&M',
      'aditionalData[tenants][1]': 'C&A' }));
    req.end();

The above command returns JSON structured like this:

  {}

This method send the tracking data for an specific user

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/jsapi/send

Body

Parameter Description
appkey application key
uid use the value obtained in Initialize tracking session method (uid/pid value)
uType accepted values: p,c (uType is p if Initialize tracking session returned pid value, uType is c if Initialize tracking session returned uid value)
actionType accepted values: visit,sale,contact,feedback,engagement,profiling
requestType accepted values: action
aditionalData[brands] array with brand names ex: [Zara, Adidas, C&A]; this aditional data should be used only when request type is 'visit'
aditionalData[tenants] array with tenants ex: [H&M]; this aditional data should be used only when request type is 'visit'
aditionalData[interests] array with interests ex: [Beverages,Food]; this aditional data should be used only when request type is 'visit'
aditionalData[receipts] array with receipts; receipt format [name => "tenant name", value=> amount] ex: aditionalData[receipts] = [[name => "C&A",value => 52], [name => "Adidas",value => 322]]; this aditional data should be used only when request type is 'sale'
aditionalData[rating] rating value; a number between 1-10; this aditional data should be used only when request type is 'feedback'
aditionalData[appointmentDate] appointment date; date format YYYY-MM-DD HH:ii:ss; this aditional data should be used only when request type is 'contact'
aditionalData[senderType] accepted values: person,organization; this aditional data should be used only when request type is 'contact'
aditionalData[percentCompleted] profile completion percentage (without "%" symbol); values between 0-100; this aditional data should be used only when request type is 'profiling'
aditionalData[description] string; this aditional data should be used only when request type is 'engagement'

Loyalty Campaign Codes

Get Active Loyalty Campaigns

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/loyaltyCode/active-campaigns?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    
    response = http.request(request)
    puts response.read_body
   $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/api/loyaltyCode/active-campaigns?access_token={{access_token}}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/x-www-form-urlencoded"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
    curl --request GET \
    --url 'http://{{base_url}}/api/loyaltyCode/active-campaigns?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded'
  var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "loyaltyCode",
        "active-campaigns"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

The above command returns JSON structured like this:

  {
    "status": "success",
    "campaigns": [
        {
            "_id": "5bd2f3b6a651e40b280741ac",
            "internalId": "3irf2dmn8ks",
            "name": "Demo Campaign 2",
            "startDate": "2018-10-26T10:59:08.000Z",
            "endDate": "2018-12-26T10:59:08.000Z",
            "expireCodesDate": "2019-10-27T10:59:08.000Z",
            "loyaltySettings": {
                "loyaltyPrizeTypes": [
                    {
                        "name": "Prize 1"
                    },
                    {
                        "name": "Prize 2"
                    }
                ]
            },
            "location": {
                "name": "Mega Mall"
            },
            "total": 0
        },
        {
            "_id": "5ls6a8de1f4da126689eec44",
            "internalId": "i8inejs4t8c",
            "name": "Demo Campaign 4",
            "startDate": "2018-10-07T08:59:40.000Z",
            "endDate": "2018-11-30T08:59:40.000Z",
            "expireCodesDate": "2018-11-22T08:59:40.000Z",
            "loyaltySettings": {
                "loyaltyPrizeTypes": [
                    {
                        "name": "Prize 3"
                    }
                ]
            },
            "location": {
                "name": "Mega Mall"
            },
            "total": 1
        }
    ]
}

This method allows you to get the list with all active campaigns associated to the authenticated user

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/loyaltyCode/active-campaigns

Query Parameters

Parameter Description
access_token access token

Get Loyalty Campaigns

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/loyaltyCode/campaigns?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/loyaltyCode/campaigns?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
    curl --request GET \
    --url 'http://{{base_url}}/api/loyaltyCode/campaigns?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "loyaltyCode",
        "campaigns"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end(); 

The above command returns JSON structured like this:

  {
    "status": "success",
    "campaigns": [
        {
            "_id": "5ss2f3b6a651736e40b280741ac",
            "internalId": "4ihf47mngkb",
            "name": "Campaign name",
            "type": "drive_loyalty",
            "budget": 0,
            "salesCost": null,
            "monthlySellingCost": null,
            "monthlyServicingCost": null,
            "productionCost": null,
            "profitabilityTime": null,
            "retentionRate": null,
            "landingPageURL": "",
            "startDate": "2018-10-26T10:59:08.000Z",
            "endDate": "2018-12-26T10:59:08.000Z",
            "expireCodesDate": "2019-10-27T10:59:08.000Z",
            "timestamp": "2018-10-26T11:00:06.633Z",
            "createdAt": "2018-10-26T11:00:06.633Z",
            "__v": 15,
            "locationId": "58d5385a68a157484ba1dw11",
            "loyaltySettings": {
                "type": "instant",
                "allowedChars": "",
                "codeLength": "9",
                "loyaltyPrizeTypes": [
                    {
                        "_id": "5cs8868d0880e32034d474d9",
                        "totalCodes": 22,
                        "pointsValue": 10,
                        "name": "Prize 1"
                    },
                    {
                        "_id": "5cs8968d0880e32034d474d8",
                        "totalCodes": 25,
                        "pointsValue": 20,
                        "name": "Prize 2"
                    }
                ]
            },
            "extraAllocations": [
                {
                    "type": "purchases",
                    "currency": "",
                    "criteria": "above",
                    "period": "",
                    "value": 120,
                    "betweenValue": null,
                    "loyaltyPoints": 10,
                    "customPeriod": 0,
                    "_id": "5ds2f3b6b651e42baaa941wq"
                }
            ],
            "leads": [],
            "total": 0
        }
    ]
}

This method allows you to get the list with all campaigns associated to the authenticated user

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/loyaltyCode/campaigns

Query Parameters

Parameter Description
access_token access token

Check Client Code

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/loyaltyCode/check?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "userEmail=mihai%40popescu.com&userPhone=%2B075364628484&campaignInternalId=msyfms5a9sd2"
    
    response = http.request(request)
    puts response.read_body
   $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/api/loyaltyCode/check?access_token={{access_token}}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "userEmail=mihai%40popescu.com&userPhone=%2B075364628484&campaignInternalId=msyfms5a9sd2",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/x-www-form-urlencoded"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
    curl --request POST \
  --url 'http://{{base_url}}/api/loyaltyCode/check?access_token={{access_token}}' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data 'userEmail=mihai%40popescu.com&userPhone=%2B075364628484&campaignInternalId=msyfms5a9sd2'
   var qs = require("querystring");
  var http = require("http");
  
  var options = {
    "method": "POST",
    "hostname": [
      "{{base_url}}"
    ],
    "path": [
      "api",
      "loyaltyCode",
      "check"
    ],
    "headers": {
      "Content-Type": "application/x-www-form-urlencoded"
    }
  };
  
  var req = http.request(options, function (res) {
    var chunks = [];
  
    res.on("data", function (chunk) {
      chunks.push(chunk);
    });
  
    res.on("end", function () {
      var body = Buffer.concat(chunks);
      console.log(body.toString());
    });
  });
  
  req.write(qs.stringify({ userEmail: 'mihai@popescu.com',
    userPhone: '+075364628484',
    campaignInternalId: 'msyfms5a9sd2' }));
  req.end();

The above command returns JSON structured like this:

  {
    "status": "success",
    "message": "redeem code found",
    "code": "9E58EDI",
    "expire_code_date": "2018-12-15 17:28:47",
    "prize_status": "associated", 
    "prize": {
          name: "Prize Name Example"
    }, 
    "last_update": "2018-11-21 15:48:14"
  }

This method allows you to check if a client has a code already allocated to a specific campaign

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/loyaltyCode/check

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
userEmail user's email address
userPhone user's phone
campaignInternalId campaign internal id

Change Code Status

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/loyaltyCode/change?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "userEmail=mihai%40popescu.com&userPhone=%2B075364628484&campaignInternalId=msyfms5a9sd2&code=XFSTWK98HG"
    
    response = http.request(request)
    puts response.read_body
   $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/api/loyaltyCode/change?access_token={{access_token}}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "userEmail=mihai%40popescu.com&userPhone=%2B075364628484&campaignInternalId=msyfms5a9sd2&code=XFSTWK98HG",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/x-www-form-urlencoded"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
    curl --request POST \
  --url 'http://{{base_url}}/api/loyaltyCode/change?access_token={{access_token}}' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data 'userEmail=mihai%40popescu.com&userPhone=%2B075364628484&campaignInternalId=msyfms5a9sd2&code=XFSTWK98HG'
   var qs = require("querystring");
  var http = require("http");
  
  var options = {
    "method": "POST",
    "hostname": [
      "{{base_url}}"
    ],
    "path": [
      "api",
      "loyaltyCode",
      "change"
    ],
    "headers": {
      "Content-Type": "application/x-www-form-urlencoded"
    }
  };
  
  var req = http.request(options, function (res) {
    var chunks = [];
  
    res.on("data", function (chunk) {
      chunks.push(chunk);
    });
  
    res.on("end", function () {
      var body = Buffer.concat(chunks);
      console.log(body.toString());
    });
  });
  
  req.write(qs.stringify({ userEmail: 'mihai@popescu.com',
    userPhone: '+075364628484',
    campaignInternalId: 'msyfms5a9sd2',
    code: 'XFSTWK98HG' }));
  req.end();

The above command returns JSON structured like this:

  {
    "status": "success"
  }

This method allows you to change a status code from allocated to redeemed/blocked

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/loyaltyCode/change

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
userEmail user's email address
userPhone user's phone
campaignInternalId campaign internal id
code the code to be redeemed/blocked

Code List

Use the access token obtained from authentication method:



    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/loyaltyCode/list?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "campaignInternalId=e2h11c3its&searchTerm=&page=1"

  $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/loyaltyCode/list?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "campaignInternalId=e2h11c3its&searchTerm=&page=1",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }

   curl --request POST \
    --url 'http://{{base_url}}/api/loyaltyCode/list?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'campaignInternalId=e2h11c3its&searchTerm=&page=1'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "loyaltyCode",
        "list"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ campaignInternalId: 'e2h11c3its', searchTerm: '', page: '1' }));
    req.end();

The above command returns JSON structured like this:

  {
  "status": "success",
  "clients": [
      {
          "code": "9X4C8DN6",
          "campaign": {
              "_id": "5cc5ef457c4c2154445fe9d2",
              "internalId": "e2h11c3its",
              "name": "Test 1",
              "type": "drive_loyalty",
              "startDate": "2018-10-01T13:38:39.000Z",
              "endDate": "2018-10-16T13:38:39.000Z",
              "loyaltySettings": {
                  "type": "standard"
              },
              "expireCodesDate": "2018-10-31T21:00:00.000Z"
          },
          "client": {
              "_id": "5ba4c44422206e61b1b8b515",
              "userFirstName": "Andrei",
              "userLastName": "Ionescu",
              "userEmail": "exemplu@test.com",
              "userPhone": "0700000000",
              "userAddress": ""
          },
          "status": "associated",
          "prize": {
              "pointsValue": 1,
              "name": "Prize number 1"
          },
          "hostess": {
              "_id": "5a0f3b91137e430dfc6795d7",
              "name": "Test Hostess"
          }
      }
  ],
  "totalResults": 1
} 

Get the paginated list with allocated,redeemed and blocked codes for one/all campaigns

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/loyaltyCode/list

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
campaignInternalId (optional) campaign internal id
searchTerm (optional) search in code field
page (optional) page number (if not specified the server will return the first page results)

Check Loyalty User Prize History

Use the access token obtained from authentication method:



    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/api/loyaltyCode/history?access_token={{access_token}}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "userEmail=mihai%40popescu.com&userPhone=%2B075364625500"

    response = http.request(request)
    puts response.read_body

  $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/loyaltyCode/history?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "userEmail=mihai%40popescu.com&userPhone=%2B075364625500",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }

   curl --request POST \
    --url 'http://{{base_url}}/api/loyaltyCode/history?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'userEmail=mihai%40popescu.com&userPhone=%2B075364625500'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "loyaltyCode",
        "history"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ userEmail: 'mihai@popescu.com', userPhone: '+075364625500' }));
    req.end();

The above command returns JSON structured like this:

  
    {
      "status": "success",
      "codes": [
          {
              "code": "JGFRZ328",
              "campaign": {
                  "internalId": "17ytx3n52qm",
                  "name": "Loyalty Test"
              },
              "status": "redeemed",
              "prize": {
                  "name": "Prize Name"
              },
              "location": {
                  "name": "Location name"
              },
              "expire_code_date": "2018-12-15T15:28:47.000Z",
              "last_update": "2018-11-28T09:26:00.726Z"
          }
      ]
  }

Get the prizes redeemed or associated to a specific user

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/loyaltyCode/history

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
userEmail user email
userPhone user phone

List Catalogues

Use the access token obtained from authentication method:

    require 'uri'
require 'net/http'

url = URI("http://{{base_url}}/api/offerCategory?access_token={{access_token}}")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/offerCategory?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request GET \
    --url 'http://{{base_url}}/api/offerCategory?access_token={{access_token}}'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "offerCategory"
      ],
      "headers": {}
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

Delete client's data

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/offerCategory

Query Parameters

Parameter Description
access_token access token

List Locations

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/api/location?access_token={{access_token}}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Get.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/location?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request GET \
    --url 'http://{{base_url}}/api/location?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "location"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

The above command returns JSON structured like this:


    [{
        "_id": "5b887473a504503c31559108",
        "timestamp": "2018-08-07T10:29:07.932Z",
        "createdAt": "2018-08-07T10:29:07.932Z",
        "areaId": "5b697473a504503c31299107",
        "name": "Sucursala Test", 
        "description": "17:00-19:00",
        "address": "Alba Iulia, Str. Test nr.1",
        "__v": 1,
        "coords": [
            0,
            0
        ],
        "image": ""
    }]

Lists bussiness locations

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/location

Query Parameters

Parameter Description
access_token access token

List Offline Campaigns

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/api/offlineCampaign?access_token={{access_token}}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Get.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/offlineCampaign?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
   curl --request GET \
    --url 'http://{{base_url}}/api/offlineCampaign?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "offlineCampaign"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

The above command returns JSON structured like this:


    [{
        "_id": "5b30cb8ae1267446c1554b6c",
        "locationId": "5b02c891f7fb282c3a8f34b9",
        "name": "Offline Campanign Test",
        "description": "",
        "image": null,
        "type": "offline",
        "budget": 0,
        "startDate": "2018-06-25T11:00:18.000Z",
        "endDate": "2018-11-30T11:00:18.000Z",
        "timestamp": "2018-06-25T11:00:58.546Z",
        "createdAt": "2018-06-25T11:00:58.546Z",
        "drawFrequency": {
            "repeats": "none",
            "frequency": null,
            "day": null,
            "end": {
                "type": "",
                "value": ""
            }
        },
        "winningType": [],
        "__v": 0
    }]

List Offline Campaigns

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/offlineCampaign

Query Parameters

Parameter Description
access_token access token