2017 © Pedro Peláez
 

library lender-api-sdk

PHP-SDK for Suretly Lender API

image

suretly/lender-api-sdk

PHP-SDK for Suretly Lender API

  • Wednesday, July 25, 2018
  • by ndolgopolov
  • Repository
  • 0 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 15 Versions
  • -75 % Grown

The README.md

Suretly LenderAPI SDK

PHP7 SDK for Suretly Lender API, (*1)

Installing LenderAPI SDK

The recommended way to install LenderAPI SDK is through Composer., (*2)

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version of LenderAPI SDK:, (*3)

php composer.phar require suretly/lender-api-sdk

After installing, you need to require Composer's autoloader:, (*4)

require 'vendor/autoload.php';

Use

After installing, you need to create a new Suretly\LenderApi\LenderManager., (*5)

Include LenderManager class, (*6)

use Suretly\LenderApi\LenderManager;

You can create SDK from static method:, (*7)

$sdk = LenderManager::create('id', 'token', 'server'):

Or you can create a configuration for your connection and create a LenderManager:, (*8)

$config = [
    'id' => '<your_id>',
    'token' => '<your_token>',
    'server' => '<server_name>'
];
$sdk = new LenderManager($config);

Calling API methods with SDK

1 General methods

$options = $sdk->getOptions();

#1.2 Orders list

Get orders with parameter $limit and optional parameter $skip. The limit parameter must be set in the range from 0 to 25., (*9)

$orders = $sdk->getOrders($limit, $skip);

#2 Creating and handling orders

#2.2 Create surety order

For a create a new order, you must create a new Suretly\LenderApi\Model\NewOrder object., (*10)

/** @var Suretly\LenderApi\Model\NewOrder $newOrder */
$newOrder = new NewOrder()

// ...
// set data
// ..

After, you can add new order on Suretly server with method postNewOrder:, (*11)

/** @var string $orderID */
$orderID = $sdk->postNewOrder($newOrder)->id;

Method postNewOrder return object with id, (*12)

/** @var object $response */
$response = $sdk->postNewOrder($newOrder);
$orderID = $response->id;

For example, json data, (*13)

{
    "id": "string"
}

#2.3 Get order status

To get the status of the order, run method getOrderStatus, which return Suretly\LenderApi\Model\OrderStatus object:, (*14)

$orderStatus = $sdk->getOrderStatus($orderID);

For example, json data, (*15)

{
    "id": "string",
    "public": true,
    "sum": 0,
    "cost": 0,
    "bids_count": 0,
    "stop_time": 0,
    "fee_total": 0,
    "fee_paid": 0,
    "payment_link": "string"
}

#2.4 Get public Order and public Order Url

To get a order, you must call method getOrder with parameter $orderID:, (*16)

/** @var \Suretly\LenderApi\Model\Order $order */
$order = $sdk->getOrder($orderID);

For example, json data for Borrower with russian passport:, (*17)

{
  "id": "string",
  "uid": "string",
  "status": "string",
  "borrower": {
    "name": {
      "first": "string",
      "middle": "string",
      "last": "string",
      "maiden": "string"
    },
    "gender": "string",
    "birth": {
      "date": "string",
      "place": "string"
    },
    "email": "string",
    "phone": "string",
    "profile_url": "string",
    "photo_url": "string",
    "city": "string",
    "identity_document_type": "passport_rf",
    "identity_document": {
      "series": "string",
      "number": "string",
      "issue_date": "string",
      "issue_place": "string",
      "issue_code": "string",
      "registration": {
        "country": "string",
        "zip": "string",
        "area": "string",
        "city": "string",
        "street": "string",
        "house": "string",
        "building": "string",
        "flat": "string",
        "address_line_1": "string",
        "address_line_2": "string"
      },
      "iin": "string",
      "expire_date": "string",
      "ssn": "string",
      "authority": "string"
    },
    "residential": {
      "country": "string",
      "zip": "string",
      "area": "string",
      "city": "string",
      "street": "string",
      "house": "string",
      "building": "string",
      "flat": "string",
      "address_line_1": "string",
      "address_line_2": "string"
    }
  },
  "user_credit_score": 0,
  "cost": "string",
  "loan_sum": "string",
  "loan_term": "string",
  "loan_rate": 0,
  "currency_code": "string",
  "max_wait_time": "string",
  "created_at": "string",
  "modify_at": "string",
  "closed_at": "string",
  "bids_count": "string",
  "bids_sum": "string",
  "callback": "string"
}

#2.5 Cancel order

For a cancel the order, you must call method postOrderStop with parameter $orderID:, (*18)

$sdk->postOrderStop($orderID);

#2.6 Get borrower contract

To get a contract for a Borrower, you must call method getContract with parameter $orderID:, (*19)

/** @var string $contractHTML */
$contractHTML = $sdk->getContract($orderID);

Method getContract return HTML code:, (*20)

'<html><head>Contract</head>...</html>'

#2.7 Confirm that contract is signed by borrower

To confirm that contract is signed by borrower:, (*21)

$sdk->postContractAccept($orderID);

#2.8 Confirm that order is paid and issued

To confirm that order is paid and issued:, (*22)

$sdk->postOrderIssued($orderID);

#2.9 8 Confirm that order is paid

To confirm that order is paid:, (*23)

$sdk->postOrderPaid($orderID);

#2.10 Confirm that order is partial paid

To confirm that order is partial paid:, (*24)

$sdk->postOrderPartialPaid($orderID, $sum);

#2.11 Prolong order

To get fee_amount prolong order, you must run method getOrderProlong with parameter $orderID and parameter $days, which return float value:, (*25)

/** @var float $feeAmount */
$feeAmount = $sdk->getOrderProlong($orderID, $days);

For example, json data, (*26)

{
  "fee_amount": 0
}

To prolong order, you must call method postOrderUnpaid, (*27)

$sdk->postOrderProlong($orderID, $days);

#2.13 Upload borrower image

To upload a borrower image, you must call method postUploadImageOrder with parameter $orderID, parameter $realPathToFile, which is realpath to file, and optional parameter $filename:, (*28)

$sdk->postUploadImageOrder($orderID, $realPathToFile, $filename);

#2.14 Mark loan as overdue

Mark loan as overdue:, (*29)

$sdk->postOrderUnpaid($orderID, $sum);

Dictionaries

Currencies

/** @var \Suretly\LenderApi\Model\Currency[] $currencies */
$currencies = $sdk->getCurrencies();

For example, json data, (*30)

[
    {
      "code": "DE",
      "name": "Germany"
    },
    {
      "code": "FR",
      "name": "France"
    },
    {
      "code": "US",
      "name": "United States of America"
    },
    {
      "code": "RU",
      "name": "Russia"
    },
    {
      "code": "KZ",
      "name": "Казахстан"
    }
]

Countries

/** @var \Suretly\LenderApi\Model\Country[] $countries */
$countries = $sdk->getCountries();

For example, json data, (*31)

[
    {
      "code": "DE",
      "name": "Germany",
      "currency_code": "EUR"
    },
    {
      "code": "FR",
      "name": "France",
      "currency_code": "EUR"
    },
    {
      "code": "US",
      "name": "United States of America",
      "currency_code": "USD"
    },
    {
      "code": "SWE",
      "name": "Sweden",
      "currency_code": "BTC"
    },
    {
      "code": "RU",
      "name": "Russia",
      "currency_code": "RUB"
    },
    {
      "code": "KZ",
      "name": "Казахстан",
      "currency_code": "KZT"
    }
]

# Work with errors

All SDK methods should use try/catch. For example:, (*32)

try {
    $sdk->postOrderUnpaid($orderID, $sum);
} catch (\Exception $exception) {
    echo $exception->getMessage();
}

All SDK methods call ResponseErrorException when an error occurs on the server. You can see all errors in class - SuretlySDK\Type\ResponseErrorStatusType., (*33)

try {
    $sdk->postOrderUnpaid($orderID, $sum);
} catch (\SuretlySDK\Type\ResponseErrorStatusType $exception) {
    echo $exception->getCode() . ': ' . $exception->getMessage();
}

Migration

version v0.2 to v0.3

First change:, (*34)

use Suretly\LenderApi\Suretly;

And second, Method getOrders() consists of only limit and skip arguments., (*35)

// before
$sdk->getOrders($from, $to, $limit, $skip);

// after
$sdk->getOrders($limit, $skip);

version v0.3 to v0.4

Now, you should use LenderManager instead Suretly., (*36)

use Suretly\LenderApi\LenderManager;

// create sdk
$sdk = LenderManager::create('id', 'token');

Also, all field on Model is private and you should use getters and setters., (*37)

// create sdk
/** @var Order $order */
$orderId = $order->getId();

That's all., (*38)

Development

For run examples test in root project directory run commands, (*39)

cd examples
php example_v0.4.php

For run unit tests in root project directory run command in console, (*40)

/vendor/bin/phpunit

For Windows, (*41)

/vendor/bin/phpunit.bat

The Versions

25/07 2018

v0.4.x-dev

0.4.9999999.9999999-dev https://github.com/SURETLY/PHP-SDK

PHP-SDK for Suretly Lender API

  Sources   Download

The Requires

 

The Development Requires

by Aleksandr Serenko

suretly lenderapi

25/07 2018

dev-master

9999999-dev https://github.com/SURETLY/PHP-SDK

PHP-SDK for Suretly Lender API

  Sources   Download

The Requires

 

The Development Requires

by Aleksandr Serenko

suretly lenderapi

25/07 2018

v0.4.5

0.4.5.0 https://github.com/SURETLY/PHP-SDK

PHP-SDK for Suretly Lender API

  Sources   Download

The Requires

 

The Development Requires

by Aleksandr Serenko

suretly lenderapi

25/07 2018

dev-v0.3-dev

dev-v0.3-dev https://github.com/SURETLY/PHP-SDK

PHP-SDK for Suretly Lender API

  Sources   Download

The Requires

 

The Development Requires

by Aleksandr Serenko

suretly lenderapi

24/07 2018

v0.3.4

0.3.4.0 https://github.com/SURETLY/PHP-SDK

PHP-SDK for Suretly Lender API

  Sources   Download

The Requires

 

The Development Requires

by Aleksandr Serenko

suretly lenderapi

24/07 2018

v0.4.4

0.4.4.0 https://github.com/SURETLY/PHP-SDK

PHP-SDK for Suretly Lender API

  Sources   Download

The Requires

 

The Development Requires

by Aleksandr Serenko

suretly lenderapi

24/07 2018

v0.4.3

0.4.3.0 https://github.com/SURETLY/PHP-SDK

PHP-SDK for Suretly Lender API

  Sources   Download

The Requires

 

The Development Requires

by Aleksandr Serenko

suretly lenderapi

24/07 2018

v0.4.2

0.4.2.0 https://github.com/SURETLY/PHP-SDK

PHP-SDK for Suretly Lender API

  Sources   Download

The Requires

 

The Development Requires

by Aleksandr Serenko

suretly lenderapi

24/07 2018

v0.3.2

0.3.2.0 https://github.com/SURETLY/PHP-SDK

PHP-SDK for Suretly Lender API

  Sources   Download

The Requires

 

The Development Requires

by Aleksandr Serenko

suretly lenderapi

04/07 2018

v0.3.1

0.3.1.0 https://github.com/SURETLY/PHP-SDK

PHP-SDK for Suretly Lender API

  Sources   Download

The Requires

 

The Development Requires

by Aleksandr Serenko

suretly lenderapi

04/07 2018

v0.3

0.3.0.0 https://github.com/SURETLY/PHP-SDK

PHP-SDK for Suretly Lender API

  Sources   Download

The Requires

 

The Development Requires

by Aleksandr Serenko

suretly lenderapi

04/07 2018

v0.4.1

0.4.1.0 https://github.com/SURETLY/PHP-SDK

PHP-SDK for Suretly Lender API

  Sources   Download

The Requires

 

The Development Requires

by Aleksandr Serenko

suretly lenderapi

04/06 2018

dev-develop

dev-develop https://github.com/SURETLY/PHP-SDK

PHP-SDK for Suretly Lender API

  Sources   Download

The Requires

 

suretly lenderapi

06/05 2018
13/10 2017