Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Introduction

...

This call allows you to get an Authorization token that will allow you to access other APIs in the ARI tool.

<?php

$curl = curl_init();

$apiEndPoint = 'https://ari.ekomiapps.dev/api/1.0/security/login';
$ekomiConnectUsername = 'username';
$ekomiConnectPassword = 'password';

curl_setopt_array($curl, array(
    CURLOPT_URL => $apiEndPoint,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => '{"username": "'.$ekomiConnectUsername.'", "password": "'.$ekomiConnectPassword.'"}',
    CURLOPT_HTTPHEADER => array(
        'cache-control: no-cache',
        'content-type: application/json',
    ),
));

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

curl_close($curl);

if ($err) {
    echo 'cURL Error #:' . $err;
} else {
    $json = json_decode($response, true);
    echo $json['accessToken'];
}

Reviews

For this API to work, the eKomi Connect must have this role assigned to his account: ARI_POST_REVIEW

Please note that a new endpoint is added for POST review which accepts productReviewTitle: https://ari.ekomiapps.dev/api/1.1/reviews

Example call:

<?php

$curl = curl_init();

$apiEndPoint = 'https://ari.ekomiapps.dev/api/1.0/reviews';

// You get this token when you call the login API
$ekomiConnectAccessToken = 'MnRlMjJlNDE5ZTdlMjFmZTdlNmIzOGQ1OGZkYjA2NjYwMzBmZmQ0OTIyNmM1ODM2ODg1Mjk0ODU2NTY2MGVlNQ';

// Those parameters are mandatory
$curlOptPostFields = [];
$curlOptPostFields['inputSourceId'] = 2; // The ID of the input source (created in the ari tool admin)
$curlOptPostFields['orderId'] = 'test-12'; // The order ID
$curlOptPostFields['rating'] = 4; // Review rating
$curlOptPostFields['reviewText'] = 'This is lorem'; // Review text
$curlOptPostFields['transactionDate'] = '2004-02-12T15:19:21+00:00'; // ISO 8601 date
$curlOptPostFields['shopId'] = '12345'; // Account Id
// Those parameters are optional $curlOptPostFields['clientId'] = 1234; // The client’s id by which the client shall be registered. Must be alpha-numeric.
$curlOptPostFields['email'] = 'abdel@example.com'; // Clients contact email address


curl_setopt_array(
    $curl,
    array(
        CURLOPT_URL => $apiEndPoint,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => json_encode($curlOptPostFields),
        CURLOPT_HTTPHEADER => array(
            'authorization: ekomi '.$ekomiConnectAccessToken,
            'cache-control: no-cache',
            'content-type: application/json',
        ),
    )
);

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

curl_close($curl);

if ($err) {
    echo 'cURL Error #:'.$err;
} else {
    $json = json_decode($response, true);
    print_r($json);
}



8. Special Authentication API


There may be cases, where eKomi sytsem needs to be integrated into a third party system where users of the third party system need to login into eKomi without any need for special authentication. There are two ways to go about it:

a. The third party system implements eKomi's single sign on functionality, eKomi Connect

or 

b. Our special token based authentication is used. 


The token based authentication allows special accounts to retrieve a login token that can be used to login automatically. This needs to be enabled to accounts and is not enabled on all accounts. Furthermore, the authentication is restricted by IPs. 

To retrieve the token, the API will look like this: 

http://lite-api.coddle.de/getagent?connectuser=<connect_user>&access_token=<access_token>

Note that this is NOT the actual api link, the actual API link can be provided once this is enabled. 

The above API returns result such as following:


// 20200525163556
// http://lite-api.coddle.de/getagent?connectuser=<connect_user>&access_token=<access_token>

{
"status": 200,
"data": "http://lite.coddle.de/organizations/<orgnization_id>?token=<returned_access_token>"
}


Then user can login directly into the account using the data above.