1. Go to this page and download the library: Download covergenius/xcover-php 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/ */
covergenius / xcover-php example snippets
use XCoverClient\Config;
use XCoverClient\XCover;
// Instantiate client
$client = new XCover(new Config([
'baseUrl' => env('BASE_URL'),
'apiPrefix' => env('API_PREFIX'),
'apiKey' => env('API_KEY'),
'apiSecret' => env('API_SECRET'),
'partner' => env('PARTNER_CODE'),
]));
// Quote request
$quoteResponse = $client->createQuote(
[
'request' => [
[
'policy_type' => 'event_ticket_protection',
'policy_type_version' => 1,
'policy_start_date' => '2019-12-01T17:59:00.831+00:00',
'event_datetime' => '2019-12-25T21:00:00+00:00',
'event_name' => 'Ariana Grande',
'event_location' => 'The O2',
'number_of_tickets' => 2,
'total_ticket_price' => 100,
'resale_ticket' => false,
'event_country' => 'GB'
]
],
'currency' => 'GBP',
'customer_country' => 'GB',
'customer_region' => 'London',
'customer_language' => 'en'
]
);
$quotePackage = $quoteResponse->json();
// Quote package array will contain all information 30,
'country' => 'GB'
]
]
);
// Booking has the same id as quote package and a similar structure
$booking = $bookingResponse->json();
echo $booking['id']; // 'JWFFM-M3W3Y-INS'
echo $booking['status']; // 'CONFIRMED'
echo $booking['total_price']; // 5.00
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use XCoverClient\Config;
use XCoverClient\Middleware\AuthMiddleware;
use XCoverClient\Middleware\JsonResponseMiddleware;
use XCoverClient\XCover;
// Add XCover mandatory middlewares
$handlerStack = HandlerStack::create();
$handlerStack->push(
new AuthMiddleware([
'apiKey' => $this->config->apiKey(),
'apiSecret' => $this->config->apiSecret(),
]),
'auth'
);
$handlerStack->push(new JsonResponseMiddleware, 'json_response');
// You can add your custom middlewares here
// You can add your custom options to the Guzzle's Client constructor below
$client = new Client([
'handler' => $handlerStack,
'headers' => [
'Content-Type' => 'application/json',
'X-Api-Key' => $this->config->apiKey(),
],
]);
// Now pass it to XCover constructor as second argument
$client = new XCover(new Config([
'baseUrl' => env('BASE_URL'),
'apiPrefix' => env('API_PREFIX'),
'apiKey' => env('API_KEY'),
'apiSecret' => env('API_SECRET'),
'partner' => env('PARTNER_CODE'),
]), $client);
bash
composer
bash
composer analyse
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.