NAV Navbar
cUrl NodeJS PHP Ruby

Introduction

The Footprints for Retail 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 support@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
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")
customDetailsoptional object; ex: customDetails[offerDetails] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit' or customDetails[vouchers] = ['shopId'=>1,'shopName'=>'sn', 'amount'=>22, 'currency'=>'RON']
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"

Update Lead

Use the access token obtained from authentication method:


      require "uri"
      require "net/http"
      
      url = URI("{{base_url}}/api/lead/5ce3b4089d5de975003244d2?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 = "status=sale_lead"
      
      response = http.request(request)
      puts response.read_body

  $curl = curl_init();

  curl_setopt_array($curl, array(
    CURLOPT_URL => "{{base_url}}/api/lead/5ce3b4089d5de975003244d2?access_token={{access_token}}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_POSTFIELDS => "status=sale_lead",
    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 --location --request PUT "{{base_url}}/api/lead/5ce3b4089d5de975003244d2?access_token={{access_token}}" \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --data "status=sale_lead"
   var https = require('https');

  var qs = require('querystring');
  
  var options = {
    'method': 'PUT',
    'hostname': '{{base_url}}',
    'path': '/api/lead/5ce3b4089d5de975003244d2?access_token={{access_token}}',
    'headers': {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  };
  
  var req = https.request(options, function (res) {
    var chunks = [];
  
    res.on("data", function (chunk) {
      chunks.push(chunk);
    });
  
    res.on("end", function (chunk) {
      var body = Buffer.concat(chunks);
      console.log(body.toString());
    });
  
    res.on("error", function (error) {
      console.error(error);
    });
  });
  
  var postData = qs.stringify({
    'status': 'sale_lead'
  });
  
  req.write(postData);
  
  req.end();

The above command returns JSON structured like this:

 {
    "interactions": [],
    "comments": [],
    "kidsAge": [
        6
    ],
    "_id": "5ce3b4089d5de975003244d2",
    "userFirstName": "Kibo",
    "userLastName": "English",
    "userEmail": "Duis.dignissim@vulputate.org",
    "userPhone": "0700000000",
    "offerId": "5aa2082c75d87fbce2e76ada",
    "industryId": "5b8561bd0bb67c30c35df800",
    "offerCategoryId": "5a003cc5b425fe79a0a41254",
    "offlineCampaignId": "5af77643f09b7f2c2fa3007e",
    "locationId": "86f838e268a157484ba1d658",
    "clientId": "5cs37a5083e3aa47a4a6a03e",
    "status": "sale_lead",
    "applicationKey": "154e64176f47a855dabff5f5",
    "application": {
        "id": "422acspo4645fcae8a4222555",
        "name": "App Test"
    },
    "offlineCampaign": {
        "id": "5af77643f09b7f2c2fa3007e",
        "name": "Campaign Test",
        "type": "offline",
        "budget": 0,
        "startDate": "2018-05-11T08:41:16.000Z",
        "endDate": "2018-05-13T08:41:16.000Z"
    },
    "offerCategory": {
        "id": "5a003cc5b425fe79a0a41254",
        "consultants": []
    },
    "nps": 10,
    "userSex": "male",
    "userCountry": "Romania",
    "userFamilyDetails": "relationship",
    "userBirthday": "Fri Oct 21 1960 00:00:00 GMT+0000 (UTC)",
    "facebookId": "100000708742934",
    "facebookUrl": "https://www.facebook.com/1245337",
    "twitterId": "7266181298",
    "twitterUrl": "https://twitter.com/78884",
    "linkedInId": "ARES817RT2",
    "linkedInUrl": "https://www.linkedin.com/in/122231",
    "googlePlusId": "6555524437781",
    "googlePlusUrl": "https://www.googleplus.com/in/122231",
    "userIncome": "8004",
    "agreeToCollect": true,
    "agreeTandc": true,
    "isAdult": true,
    "isMultipart": false,
    "isComplete": true,
    "timestamp": "2018-09-24T19:00:00.000Z",
    "timestampStatusChange": "2018-09-24T19:00:00.000Z",
    "createdAt": "2018-09-24T19:00:00.000Z",
    "actionRequired": true,
    "deviceType": "desktop",
    "type": "B2C",
    "technicalInfo": {
        "macAddress": "00:1B:44:00:3A:B8",
        "browserCookieId": "ieBF72Oshw",
        "browserUserAgent": "Mozilla/5.0 (Windows NT 5.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36",
        "browserType": "Firefox",
        "browserNotificationToken": "88Tre-33wnslZxlam",
        "appSessionId": "sdjahsdwqeuu",
        "deviceUuid": "92784376547",
        "deviceOs": "Android",
        "advertiserId": "263tsab2376ds9swq812l",
        "pushNotificationToken": "msahtq67785w5547",
        "androidAdvertisingId": "38400000-8cf0-11bd-b23e-10b96e40000d",
        "iosAdvertisingId": "AEBE52E7-03EE-455A-B3C4-E57283966239"
    },
    "offer": {
        "_id": "5aa2082c75d87fbce2e76ada",
        "price": 100,
        "name": "First Product"
    },
    "updatedAt": "2019-07-18T12:47:35.847Z",
    "channelId": "2f3e2b658720346d675b941c"
}

Update lead method

Headers

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

HTTP Request

PUT {{base_url}}/api/lead/{{leadId}}

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
statuslead status; accepted values: prospect, lead, sale_lead, opportunity, customer, lost

Get Leads

Use the access token obtained from authentication method:


        require "uri"
        require "net/http"
        
        url = URI("{{base_url}}/api/lead?access_token={{access_token}}&startDate=2018-11-25&endDate=2018-12-31&pageSize=10&page=1")
        
        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 => "{{base_url}}/api/lead?access_token={{access_token}}&startDate=2018-11-25&endDate=2018-12-31&pageSize=10&page=1",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => false,
      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 --location --request GET "{{base_url}}/api/lead?access_token={{access_token}}&startDate=2018-11-25&endDate=2018-12-31&pageSize=10&page=1" \
    --header "Content-Type: application/x-www-form-urlencoded" \
    --data ""
   var https = require('https');

    var qs = require('querystring');
    
    var options = {
      'method': 'GET',
      'hostname': '{{base_url}}',
      'path': '/api/lead?access_token={{access_token}}&startDate=2018-11-25&endDate=2018-12-31&pageSize=10&page=1',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    };
    
    var req = https.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function (chunk) {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    
      res.on("error", function (error) {
        console.error(error);
      });
    });
    
    var postData = qs.stringify({
    
    });
    
    req.write(postData);
    
    req.end();

The above command returns JSON structured like this:

 [{
    "interactions": [],
    "comments": [],
    "kidsAge": [
        6
    ],
    "_id": "5ce3b4089d5de975003244d2",
    "userFirstName": "Kibo",
    "userLastName": "English",
    "userEmail": "Duis.dignissim@vulputate.org",
    "userPhone": "0700000000",
    "offerId": "5aa2082c75d87fbce2e76ada",
    "industryId": "5b8561bd0bb67c30c35df800",
    "offerCategoryId": "5a003cc5b425fe79a0a41254",
    "offlineCampaignId": "5af77643f09b7f2c2fa3007e",
    "locationId": "86f838e268a157484ba1d658",
    "clientId": "5cs37a5083e3aa47a4a6a03e",
    "status": "sale_lead",
    "applicationKey": "154e64176f47a855dabff5f5",
    "application": {
        "id": "422acspo4645fcae8a4222555",
        "name": "App Test"
    },
    "offlineCampaign": {
        "id": "5af77643f09b7f2c2fa3007e",
        "name": "Campaign Test",
        "type": "offline",
        "budget": 0,
        "startDate": "2018-05-11T08:41:16.000Z",
        "endDate": "2018-05-13T08:41:16.000Z"
    },
    "offerCategory": {
        "id": "5a003cc5b425fe79a0a41254",
        "consultants": []
    },
    "nps": 10,
    "userSex": "male",
    "userCountry": "Romania",
    "userFamilyDetails": "relationship",
    "userBirthday": "Fri Oct 21 1960 00:00:00 GMT+0000 (UTC)",
    "facebookId": "100000708742934",
    "facebookUrl": "https://www.facebook.com/1245337",
    "twitterId": "7266181298",
    "twitterUrl": "https://twitter.com/78884",
    "linkedInId": "ARES817RT2",
    "linkedInUrl": "https://www.linkedin.com/in/122231",
    "googlePlusId": "6555524437781",
    "googlePlusUrl": "https://www.googleplus.com/in/122231",
    "userIncome": "8004",
    "agreeToCollect": true,
    "agreeTandc": true,
    "isAdult": true,
    "isMultipart": false,
    "isComplete": true,
    "timestamp": "2018-09-24T19:00:00.000Z",
    "timestampStatusChange": "2018-09-24T19:00:00.000Z",
    "createdAt": "2018-09-24T19:00:00.000Z",
    "actionRequired": true,
    "deviceType": "desktop",
    "type": "B2C",
    "technicalInfo": {
        "macAddress": "00:1B:44:00:3A:B8",
        "browserCookieId": "ieBF72Oshw",
        "browserUserAgent": "Mozilla/5.0 (Windows NT 5.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36",
        "browserType": "Firefox",
        "browserNotificationToken": "88Tre-33wnslZxlam",
        "appSessionId": "sdjahsdwqeuu",
        "deviceUuid": "92784376547",
        "deviceOs": "Android",
        "advertiserId": "263tsab2376ds9swq812l",
        "pushNotificationToken": "msahtq67785w5547",
        "androidAdvertisingId": "38400000-8cf0-11bd-b23e-10b96e40000d",
        "iosAdvertisingId": "AEBE52E7-03EE-455A-B3C4-E57283966239"
    },
    "offer": {
        "_id": "5aa2082c75d87fbce2e76ada",
        "price": 100,
        "name": "First Product"
    },
    "updatedAt": "2019-07-18T12:47:35.847Z",
    "channelId": "2f3e2b658720346d675b941c"
}]

Get leads method

Headers

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

HTTP Request

GET {{base_url}}/api/lead

Query Parameters

Parameter Description
access_token access token
startDate start date, accepted format Y-m-d
endDate start date, accepted format Y-m-d
pageSize items per page
page current page
appKey application key

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

Shoppers

Get shopper

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 shopper's email and phone (mandatory fields) or shopper's NationalId number

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 shopper

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 shopper'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 shopper

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 shopper'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

Web Data Tracking

Initialize web 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 initializes the web tracking session for a specific user. In a successful 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 web 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 sends the tracking data for a 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'

Mobile Data Tracking

Mobile Initialize tracking session


    require 'uri'
  require 'net/http'

  url = URI("http://{{base_url}}/mobileapi/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&userEmail=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}}/mobileapi/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&userEmail=test.email%40test.com&pushNotificationToken=123456",
    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}}/mobileapi/init' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'appkey=571e64183647a855d0sgf3a3&userEmail=test.email%40test.com&pushNotificationToken=123456'
  var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "mobileapi",
        "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',
        userEmail: 'test.email%40test.com', pushNotificationToken: 123456 }));
    req.end();

The above command returns JSON structured like this:

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

This method initializes the mobile tracking session for a specific user. In a successful 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}}/mobileapi/init

Body

Parameter Description
appkey application key
userEmail user's email address
userPhone user's phone
pushNotificationToken push notification token
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 mobile tracking screenview

Use the value obtained from "Initialize mobile tracking session" method in the mobileId field:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/mobileapi/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&mid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&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}}/mobileapi/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&mid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&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}}/mobileapi/send' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'appkey=571e64183647a855d0sgf3a3&mid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&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": [
        "mobileapi",
        "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',
      mid: 'a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667',
      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 sends the tracking data for a specific user

Headers

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

HTTP Request

POST {{base_url}}/mobileapi/send

Body

Parameter Description
appkey application key
mid use the value obtained in Initialize tracking session method (mobileId 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'

Send mobile tracking sensors

Use the value obtained from "Initialize mobile tracking session" method in the mobileId field:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/mobileapi/sensors")

    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&mid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&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 => "{{base_url}}/mobileapi/sensors",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_POSTFIELDS => "appkey={{username}}&mid=p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73&sensors%5B0%5D%5Buuid%5D=2376-34342-1233-23424&sensors%5B0%5D%5Brssi%5D=5&sensors%5B0%5D%5Bdistance%5D=4&sensors%5B0%5D%5BmacAddress%5D=345987345345-23482746-345934587&sensors%5B0%5D%5BtxPower%5D=2&sensors%5B0%5D%5Bname%5D=mimi&sensors%5B0%5D%5Bminor%5D=3.2&sensors%5B0%5D%5Bmajor%5D=4.1&sensors%5B1%5D%5Buuid%5D=2376-34342-1233-23422&sensors%5B1%5D%5Brssi%5D=5&sensors%5B1%5D%5Bdistance%5D=44&sensors%5B1%5D%5BmacAddress%5D=345987345345-23482746-345934587&sensors%5B1%5D%5BtxPower%5D=6&sensors%5B1%5D%5Bname%5D=cici&sensors%5B1%5D%5Bminor%5D=1.1&sensors%5B1%5D%5Bmajor%5D=2.2",
    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}}/mobileapi/sensors' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'appkey=571e64183647a855d0sgf3a3&mid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&sensors%5B0%5D%5Buuid%5D=2376-34342-1233-23424&sensors%5B0%5D%5Brssi%5D=5&sensors%5B0%5D%5Bdistance%5D=4&sensors%5B0%5D%5BmacAddress%5D=345987345345-23482746-345934587&sensors%5B0%5D%5BtxPower%5D=2&sensors%5B0%5D%5Bname%5D=mimi&sensors%5B0%5D%5Bminor%5D=3.2&sensors%5B0%5D%5Bmajor%5D=4.1&sensors%5B1%5D%5Buuid%5D=2376-34342-1233-23422&sensors%5B1%5D%5Brssi%5D=5&sensors%5B1%5D%5Bdistance%5D=44&sensors%5B1%5D%5BmacAddress%5D=345987345345-23482746-345934587&sensors%5B1%5D%5BtxPower%5D=6&sensors%5B1%5D%5Bname%5D=cici&sensors%5B1%5D%5Bminor%5D=1.1&sensors%5B1%5D%5Bmajor%5D=2.2'
  
  var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "PUT",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "mobileapi",
        "sensors"
      ],
      "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',
      mid: 'a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667',
      'sensors[uuid][0]': '4457-7784-5577-6655',
      'sensors[rssi][0]': '5461567',
      'sensors[distance][0]': 22,
      'sensors[txPower][0]': 568,
      'sensors[name][0]': 'Sensor1',
      'sensors[minor][0]': 10.2,
      'sensors[major][0]': 22.3,
      'sensors[macAddress][0]': '00-14-22-01-23-45' }));
    req.end();

The above command returns JSON structured like this:

  {
    "success": true
}

This method sends the tracking data for a group of sensors (beacons)

Headers

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

HTTP Request

POST {{base_url}}/mobileapi/sensors

Body

Parameter Description
appkey application key
mid use the value obtained in Initialize tracking session method (mobileId value)
sensors[x][uuid] sensor specific attribute
sensors[x][rssi] sensor specific attribute
sensors[x][distance] sensor specific attribute
sensors[x][macAddress] user macAddress
sensors[x][txPower] sensor specific attribute
sensors[x][name] sensor specific attribute
sensors[x][minor] sensor specific attribute
sensors[x][major] sensor specific attribute

Send mobile tracking geolocation

Use the value obtained from "Initialize mobile tracking session" method in the mobileId field:


    require "uri"
    require "net/http"

    url = URI("{{base_url}}/mobileapi/geo")

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

    request = Net::HTTP::Put.new(url)
    request["Content-Type"] = "application/x-www-form-urlencoded"
    request.body = "appkey={{username}}&mid=p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73&lat=44.432149&lon=26.088868&accuracy=3"

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

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{base_url}}/mobileapi/geo",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => false,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => "appkey={{username}}&mid=p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73&lat=44.432149&lon=26.088868&accuracy=3",
  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 --location --request PUT "{{base_url}}/mobileapi/geo" \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --data "appkey={{username}}&mid=p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73&lat=44.432149&lon=26.088868&accuracy=3"
  
  
  
  var qs = require("querystring");
  var https = require('https');

  var qs = require('querystring');
  
  var options = {
    'method': 'PUT',
    'hostname': '{{base_url}}',
    'path': '/mobileapi/geo',
    'headers': {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  };
  
  var req = https.request(options, function (res) {
    var chunks = [];
  
    res.on("data", function (chunk) {
      chunks.push(chunk);
    });
  
    res.on("end", function (chunk) {
      var body = Buffer.concat(chunks);
      console.log(body.toString());
    });
  
    res.on("error", function (error) {
      console.error(error);
    });
  });
  
  var postData = qs.stringify({
    'appkey': '{{username}}',
    'mid': 'p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73',
    'lat': '44.432149',
    'lon': '26.088868',
    'accuracy': '3'
  });
  
  req.write(postData);
  
  req.end();

The above command returns JSON structured like this:

  {
    "success": true
}

This method sends geolocation data

Headers

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

HTTP Request

POST {{base_url}}/mobileapi/sensors

Body

Parameter Description
appkey application key
mid use the value obtained in Initialize tracking session method (mobileId value)
lat latitude
lon longitude
accuracy accuracy

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