PHP code example of robinhq / api
1. Go to this page and download the library: Download robinhq/api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
robinhq / api example snippets
use Robin\Api\Models\Customer;
use Robin\Api\Views\Panel;
$panel = Panel::make($totalOrders, $totalSpend);
$robinCustomer = Customer::make($email, $customerSince, $ordersCount, $totalSpent, $panel);
$robinCustomer = //...
$customers = new Robin\Api\Collections\Customers([$robinCustomer]);
//...
$robin = new Robin\Api\Robin($key, $secret, $url);
$response = $robin->customers($customers); //returns Psr\Http\Message\ResponseInterface
use Robin\Api\Robin;
use Robin\Api\Models\Customer;
use Robin\Api\Views\Panel;
use Robin\Api\Collections\Customers;
$robin = new Robin($key, $secret, $url);
$panel = Panel::make($totalOrders, $totalSpend);
$robinCustomer = Customer::make($email, $customerSince, $ordersCount, $totalSpend, $panel);
$customers = new Customers([$robinCustomer]);
$response = $robin->customers($customers);
use Robin\Api\Robin;
use Robin\Api\Models\Customer;
use Robin\Api\Views\Panel;
use Robin\Api\Collections\Customers;
$robin = new Robin($key, $secret, $url);
$shopCustomers = $shop->allCustomers();
$robinCustomers = new Customers();
foreach($shopCustomers as $shopCustomer){
$panel = Panel::make($shopCustomer->totalOrders, $shopCustomer->totalSpend);
$robinCustomer = Customer::make(
$shopCustomer->email,
$shopCustomer->createdAt,
$shopCustomer->totalOrders,
$shopCustomer->totalSpend,
$panel
);
$robinCustomers->push($robinCustomer);
$response = $robin->customers($robinCustomers);
}
Order::make(
$number,
$email,
$createdAt,
$price,
$editUrl,
$listView,
$detailsView
);
use Robin\Api\Models\Views\ListView;
$listView = ListView::make($orderNumber, $date, $status);
use Robin\Api\Collections\DetailsView;
$detailsView = new DetailsView();
use Robin\Api\Models\Views\Details\OrderDetails;
$orderDetails = OrderDetails::make($date, $status, $paymentStatus, $shipmentStatus);
$detailsView->addDetails($orderDetails);
$products = new Products();
$product = Product::make($product->title, $product->quantity, $product->price);
$products->push($product);
$detailsView->addColumns($products, "Products");
use Robin\Api\Models\Views\Details\Detail;
class CustomDetailsView extends Detail
{
public $fooBar;
public $barFoo;
public static function make($foo, $bar)
{
$view = new static;
$view->fooBar = $foo;
$view->barFoo = $bar;
return $view;
}
}
$details = new DetailsView();
$custom = CustomDetailsView::make("foo", "bar");
$details->addColumns($custom, "Dummy");
$json = $details->toJson(); // {"display_as":"columns","caption":"Dummy","data":{"foo_bar":"foo","bar_foo":"bar"}}