two-tap/php-sdk

The Two Tap SDK for PHP provides a native interface to the Two Tap API

This package's canonical repository appears to be gone and the package has been frozen as a result.

1.0.9 2018-08-27 17:32 UTC

This package is not auto-updated.

Last update: 2019-05-27 19:11:03 UTC


README

The Two Tap SDK for PHP provides a native interface to the Two Tap API

Installation

This library can be found on Packagist. The recommended way to install this is through composer.

Run these commands to install composer, the library and its dependencies:

$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar require two-tap/php-sdk

You then need to install guzzle:

$ php composer.phar require guzzlehttp/guzzle:~6.0

Or edit composer.json and add:

{
    "require": {
        "two-tap/php-sdk": "~1.0"
    }
}

And then add guzzle:

{
    "require": {
        "guzzlehttp/guzzle": "~6.0"
    }
}

Documentation

For full API documentation can please consult our official documentation page.

Usage

<?php

require 'vendor/autoload.php';

use TwoTap\Api;

// create an api object
$api = new Api([
    'public_token' => 'YOUR_PUBLIC_TOKEN',
    'private_token' => 'YOUR_PRIVATE_TOKEN'
]);

// ...

Product::class

get()

$api->product()->get($siteId, $md5, $destinationCountry, $productAttributesFormat);
$api->product()->get($siteId, null, null, null, $catalogKey);

search()

$api->product()->search($filter, $sort, $page, $perPage, $productAttributesFormat, $destinationCountry);

scroll()

$api->product()->scroll($filter, $size, $scrollId, $productAttributesFormat, $destinationCountry);

filters()

$api->product()->filters($filter);

taxonomy()

$api->product()->taxonomy();

Cart::class

create()

$api->cart()->create($products, $finishedUrl, $finishedProductAttributesFormat, $notes, $testMode, $cacheTime, $destinationCountry);

status()

$api->cart()->status($cartId, $productAttributesFormat, $testMode, $destinationCountry);

estimates()

$api->cart()->estimates($cartId, $fieldsInput, $products, $destinationCountry);

Purchase::class

create()

$api->purchase()->create($cartId, $fieldsInput, $affiliateLinks, $confirm, $products, $notes, $testMode, $locale);

status()

$api->purchase()->status($purchaseId, $testMode);

history()

$api->purchase()->history($since);

confirm()

$api->purchase()->confirm($purchaseId, $testMode);

Utils::class

fieldsInputValidate()

$api->utils()->fieldsInputValidate($cartId, $flatFieldsInput);

quicky()

$api->utils()->quicky($products, $smsConfirmUrl, $phone, $message);

supportedSites()

$api->utils()->supportedSites($cartId, $flatFieldsInput);

coupons()

$api->utils()->coupons($cartId, $flatFieldsInput);

PickupOptions::class

create()

$api->pickupOptions()->create($cartId, $fieldsInput, $products, $finishedUrl);

status()

$api->pickupOptions()->status($cartId);

Wallet::class

userToken()

$api->wallet()->userToken($userKey);

retrieve()

$api->wallet()->retrieve($userToken, $filterFieldTypes, $filterGroupIds);

store()

$api->wallet()->store($userToken, $fieldType, $groupId, $fields);

delete()

$api->wallet()->delete($userToken, $fieldType, $fieldGroupId);

meta()

$api->wallet()->meta($$metaFields, $fieldType, $expiresIn);

Laravel usage

Two Tap API SDK has optional support for Laravel & Lumen and comes with a Service Provider and Facades for easy integration.

After you have installed TwoTap API SDK, open your Laravel config file config/app.php and add the following lines.

In the $providers array add the service providers for this package.

TwoTap\TwoTapServiceProvider::class

Add the facade of this package to the $aliases array.

'TwoTap' => TwoTap\Facades\TwoTap::class

Now the TwoTap Class will be auto-loaded by Laravel.

Example

// usage inside a laravel route
Route::get('/', function()
{
    $filter = [
        "keywords" => "Vans sneakers"
    ];

    $results = TwoTap::product()->search($filter);

    return $results->products;
});