jonathanpmartins / staysvel
Laravel Package for integration with Stays External API.
1.5.1
2024-09-17 04:50 UTC
Requires
- php: ^8.0.0
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- illuminate/http: ^9.0|^10.0|^11
- illuminate/validation: ^9.0|^10.0|^11
Requires (Dev)
- orchestra/testbench: ~9.0
- pestphp/pest: ^2.34
README
Laravel Package for integration with Stays External API. Docs: https://stays.net/external-api/
How to install
composer require jonathanpmartins/staysvel;
Add the following code to your config\services.php
configuration file:
'stays' => [ 'endpoint' => env('STAYS_ENDPOINT'), 'client_id' => env('STAYS_CLIENT_ID'), 'client_secret' => env('STAYS_CLIENT_SECRET'), ],
Add the following keys to you .env
file and fill them up with your credentials.
STAYS_ENDPOINT=
STAYS_CLIENT_ID=
STAYS_CLIENT_SECRET=
Usage
Import the Stays
class:
use Staysvel\Stays;
Request and Response
- All input parameters are of type
array
orstring
. - All parameters marked with an asterisk (*) are required.
- The
$response
object is an instance ofIlluminate\Http\Client\Response
. It basically returns what the laravel http-client returns.
How deal with it
From Laravel 9 docs:
$response->body() : string; $response->json($key = null) : array|mixed; $response->object() : object; $response->collect($key = null) : Illuminate\Support\Collection; $response->status() : int; $response->ok() : bool; $response->successful() : bool; $response->redirect(): bool; $response->failed() : bool; $response->serverError() : bool; $response->clientError() : bool; $response->header($header) : string; $response->headers() : array;
Example
$response = Stays::content()->properties()->create(array $parameters); if ($response->successful()) { $data = $response->json(); // return data from stays } if ($response->failed()) { $status = $response->status(); $json = $response->json(); if (isset($json['message'])) { throw new \Exception($json['message'], $status); } else { throw new \Exception($response->body(), $status); } }
Timeout
The default timeout is 60
seconds. To change it, use the timeout(int $timeoutInSeconds)
function before the last function of the chain. Examples:
$response = Stays::timeout(30)->content()->properties()->create(array $parameters); $response = Stays::content()->timeout(30)->properties()->create(array $parameters); $response = Stays::content()->properties()->timeout(30)->create(array $parameters);
Table of Contents
Booking Checkout API
Promo code API
Booking API
Finance API
Listing Calendar API
Prices API
Content API
Listing Settings API
Translations API
Booking Checkout API
Initiate checkout process
$response = Stays::bookRequest(array $parameters);
Parameters
Promo code API
Create promo code
$response = Stays::booking()->promoCodes()->create(array $parameters);
Parameters
Get promo code
$response = Stays::booking()->promoCodes()->get(string $id);
Modify promo code
$response = Stays::booking()->promoCodes()->update(string $id, array $parameters);
Parameters
Delete promo code
$response = Stays::booking()->promoCodes()->delete(string $id);
Search promo codes
$response = Stays::booking()->promoCodes()->search(array $parameters);
Parameters
Booking API
Retrieve Search filter
$response = Stays::booking()->search()->filter();
Search listings
$response = Stays::booking()->search()->listings(array $parameters);
Parameters
Calculate listing price
$response = Stays::booking()->listingPrice()->calculate(array $parameters);
Parameters
Create blocking
$response = Stays::booking()->blocking()->create(array $parameters);
Parameters
Modify blocking
$response = Stays::booking()->blocking()->update(string $reservationId, array $parameters);
Parameters
Delete blocking
$response = Stays::booking()->blocking()->delete(string $reservationId);
Create reservation
$response = Stays::booking()->reservations()->create(array $parameters);
Parameters
Retrieve reservation
$response = Stays::booking()->reservations()->get(string $reservationId);
Modify reservation
$response = Stays::booking()->reservations()->update(string $reservationId, array $parameters);
Parameters
Cancel reservation
$response = Stays::booking()->reservations()->cancel(string $reservationId, array $parameters);
Parameters
Delete reservation
$response = Stays::booking()->reservations()->delete(string $reservationId);
Search active reservations
$response = Stays::booking()->reservations()->search(array $parameters);
Parameters
Reservations report XLSX
$response = Stays::booking()->reservations()->export()->xlsx(array $parameters); $raw = $response->body();
Parameters
Reservations report JSON
$response = Stays::booking()->reservations()->export()->json(array $parameters);
Parameters
Clients
$response = Stays::booking()->clients()->search(array $parameters);
Parameters
Client
$response = Stays::booking()->clients()->get(string $clientId);
Finance API
Create Payment Provider
$response = Stays::finance()->paymentProviders()->create(array $parameters);
Parameters
Retrieve Payment Provider
$response = Stays::finance()->paymentProviders()->get(string $providerId);
Modify Payment Provider
$response = Stays::finance()->paymentProviders()->update(string $providerId, array $parameters);
Parameters
Retrieve Payment Providers
$response = Stays::finance()->paymentProviders()->search(array $parameters);
Parameters
Listing Calendar API
Retrieve Listing Calendar
$response = Stays::calendar()->listings()->get(string $listingId, array $parameters);
Parameters
Update Listing Calendar
$response = Stays::calendar()->listings()->update(string $listingId, array $parameters);
Parameters
Prices API
Retrieve Price Regions
$response = Stays::price()->regions()->search();
Create Price Region
$response = Stays::price()->regions()->create(array $parameters);
Parameters
Modify Price Region
$response = Stays::price()->regions()->update(string $id, array $parameters);
Parameters
Delete Price Region
$response = Stays::price()->regions()->delete(string $id);
Retrieve Sell Price Rules
$response = Stays::price()->rules()->search(array $parameters);
Parameters
Create Sell Price Rule
$response = Stays::price()->rules()->create(array $parameters);
Parameters
Retrieve Sell Price Rule
$response = Stays::price()->rules()->get(string $id);
Modify Sell Price Rule
$response = Stays::price()->rules()->update(string $id, array $parameters);
Parameters
Delete Sell Price Rule
$response = Stays::price()->rules()->delete(string $id);
Retrieve Listing Sell Prices
$response = Stays::price()->sells()->search(array $parameters);
Parameters
Retrieve Listing Sell Price
$response = Stays::price()->sells()->get(string $listingId);
Modify Listing Sell Price
$response = Stays::price()->sells()->update(string $seasonId, array $parameters);
Parameters
Content API
Create Property
$response = Stays::content()->properties()->create(array $parameters);
Parameters
Retrieve Property
$response = Stays::content()->properties()->get(string $propertyId);
Modify Property
$response = Stays::content()->properties()->update(string $propertyId, array $parameters);
Parameters
Retrieve Properties
$response = Stays::content()->properties()->search(array $parameters);
Parameters
Create Listing
$response = Stays::content()->listings()->create(array $parameters);
Parameters
Retrieve Listing
$response = Stays::content()->listings()->get(string $listingId);
Modify Listing
$response = Stays::content()->listings()->update(string $listingId, array $parameters);
Parameters
Retrieve Listings
$response = Stays::content()->listings()->search(array $parameters);
Parameters
Create group
$response = Stays::content()->groups()->create(array $parameters);
Parameters
Retrieve group
$response = Stays::content()->groups()->get(string $groupId);
Modify group
$response = Stays::content()->groups()->update(string $groupId, array $parameters);
Parameters
Delete group
$response = Stays::content()->groups()->delete(string $groupId);
Retrieve Groups
$response = Stays::content()->groups()->search(array $parameters);
Parameters
Listing Settings API
Listing sell price settings
$response = Stays::setting()->listing()->price(string $listingId);
Listing booking settings
$response = Stays::setting()->listing()->booking(string $listingId);
Translations API
Multi-unit property types
$response = Stays::translation()->types()->multiUnitProperty();
Single-unit property types
$response = Stays::translation()->types()->singleUnitProperty();
Listing types
$response = Stays::translation()->types()->listing();
Room types
$response = Stays::translation()->types()->room();
Bedroom types
$response = Stays::translation()->types()->bedroom();
Bathroom types
$response = Stays::translation()->types()->bathroom();
Other living room types
$response = Stays::translation()->types()->other();
Bed types
$response = Stays::translation()->types()->bed();
Property amenities
$response = Stays::translation()->amenities()->property();
Listing amenities
$response = Stays::translation()->amenities()->listing();