2017 © Pedro Peláez
 

library intervention-sdk

BixevIntervention API SDK

image

bixev/intervention-sdk

BixevIntervention API SDK

  • Wednesday, July 20, 2016
  • by thomas.leviandier@gmail.com
  • Repository
  • 1 Watchers
  • 2 Stars
  • 79 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

This SDK aims to help you dealing with BixevIntervention APIs, (*1)

Installation

It's recommended that you use Composer to install InterventionSDK., (*2)

composer require bixev/intervention-sdk "~1.0"

This will install SDK and all required dependencies., (*3)

so each of your php scripts need to require composer autoload file, (*4)

<?php

require 'vendor/autoload.php';

Usage

Available services are, (*5)

  • Intervention (search, create, update, read)
  • InterventionType (getAvailable)
  • ScheduleWizard (getSlots)

API init

Initialize api with your access url, (*6)

$autoconfigUrl = 'https://api.intervention.bixev.com/connectors/XXX/YYYYYYYYY';
$bixevInterventionAPI = \Bixev\InterventionSdk\InterventionApi::init($autoconfigUrl);

Intervention service

You can access services directly from the api $bixevInterventionAPI->services, (*7)

$interventionService = $bixevInterventionAPI->services->newServiceIntervention();

Search interventions

Retrieve the SearchInput object to set all-what-you-need input parameters, (*8)

$searchInput = $interventionService->newSearchInput();
$searchInput->status = \Bixev\InterventionSdk\Model\Intervention::STATUS_PENDING;

Use the search method on the interventionService to get your interventions, (*9)

$result = $interventionService->search($searchInput);

Returned result is instance of \Bixev\InterventionSdk\Model\Response\Interventions, (*10)

echo $results->pagination->returned . " results returned\n";
foreach ($results->interventions as $intervention) {
    echo "Intervention cref : " . $intervention->cref . "\n";
}

All in one to search interventions :, (*11)

// initialize api
$autoconfigUrl = 'https://api.intervention.bixev.com/connectors/XXX/YYYYYYYYY';
$bixevInterventionAPI = \Bixev\InterventionSdk\InterventionApi::init($autoconfigUrl);
// get service
$interventionService = $bixevInterventionAPI->services->newServiceIntervention();
// get input
$searchInput = $interventionService->newSearchInput();
$searchInput->status = \Bixev\InterventionSdk\Model\Intervention::STATUS_PENDING;
// call method
$result = $interventionService->search($searchInput);
// process results
echo $results->pagination->returned . " results returned\n";
foreach ($results->interventions as $intervention) {
    echo "Intervention cref : " . $intervention->cref . "\n";
}

Read/Create/Update intervention

Instanciate new intervention model, (*12)

$intervention = $bixevInterventionAPI->models->newModelIntervention();

cref field is required (to set or retrieve unique intervention informations), this is YOUR intervention unique identifier, (*13)

$intervention->cref = 'myCustomInterventionReference';

Read intervention data

$result = $interventionService->read($intervention);

Intervention is find by cref, (*14)

Create or update intervention

If needed you can instanciate new customer model. customer type/reference fields are required as unique identifier, (*15)

$intervention->customer = $bixevInterventionAPI->models->newModelCustomer();
$intervention->customer->type = \Bixev\InterventionSdk\Model\Customer::CUSTOMER_TYPE_COMPANY;
$intervention->customer->reference = 'customerReference';

Create :, (*16)

$result = $interventionService->create($intervention);

If intervention with cref already exists, it is updated, (*17)

Update :, (*18)

$result = $interventionService->update($intervention);

Intervention is find by cref, (*19)

Intervention and customer fields are available from corresponding classes. They are :, (*20)

$intervention->cref // unique identifier
$intervention->reference
$intervention->address
$intervention->address_additional
$intervention->comment
$intervention->duration // seconds
$intervention->scheduled_start_at // ISO 8601 format, can be set by $intervention->setScheduledStart($date)
$intervention->custom_fields // associative array of $key => $value additional fields

$customer->reference
$customer->type
$customer->name
$customer->address
$customer->address_additional
$customer->phone
$customer->mobile
$customer->email
$customer->comment

InterventionType service

you can retrieve your available intervention types. If you have multiple ones, creating intervention will required which one you want., (*21)

$interventionTypeService = $bixevInterventionAPI->services->newServiceInterventionType();
$result = $interventionTypeService->getAvailable();

Schedule wizard service

To get available assignment slots, use ScheduleWizard !!!, (*22)

Retrieve the ScheduleWizardInput object to set all-what-you-need input parameters, (*23)

$scheduleWizardService = $bixevInterventionAPI->services->newServiceScheduleWizard();
$scheduleWizardInput = $scheduleWizardService->newWizardInput();
$scheduleWizardInput->address = '7 rue de la Dordogne Toulouse';

Use the getSlots method on the scheduleWizardService to get available slots, (*24)

$result = $scheduleWizardService->getSlots($scheduleWizardInput);

Returned result is instance of \Bixev\InterventionSdk\Model\Response\ScheduleWizard\ScheduleWizard, (*25)

echo count($result) . ' dates returned' . "\n";
echo 'best slot : ';
$bestSlot = $result->getBestSlot();
if ($bestSlot === null) {
    echo "No slot available";
} else {
    echo "Best slot : " . $bestSlot->date;
}

Schedule Wizard get options are :, (*26)

$scheduleWizardInput->address
$scheduleWizardInput->date_min // ISO 8601 format, can be set by $intervention->setDateMin($date)
$scheduleWizardInput->date_max // ISO 8601 format, can be set by $intervention->setDateMax($date)

Log

You can use a logger object within this sdk. It has just to implement \Bixev\LightLogger\LoggerInterface, (*27)

class MyLogger implements \Bixev\LightLogger\LoggerInterface
{
    public function log($log)
    {
        print_r($log);
    }
}

Then pass it to your api initialization :, (*28)

$logger = new MyLogger;
$bixevInterventionAPI = \Bixev\InterventionSdk\InterventionApi::init($autoconfigUrl, $logger);

Override routes

You're able to force routes the sdk use to connect to the api (no use of autoconfig, or override), (*29)

Routes are on client level :, (*30)

$client = $bixevInterventionAPI->getClient();
$routes = $client->getRoutes();

So you can simply set your own set of routes. A route must extend \Bixev\InterventionSdk\Model\Routes\Route, (*31)

$route = new \Bixev\InterventionSdk\Model\Routes\Route;
$route->identifier = \Bixev\InterventionSdk\Model\Routes\Route::IDENTIFIER_INTERVENTION_LIST;
$route->method = \Bixev\InterventionSdk\Client\Curl::METHOD_GET;
$route->url = 'http://mycutomdomain/mycutomroute';
$routes[] = $route;

The Versions

20/07 2016

dev-master

9999999-dev

BixevIntervention API SDK

  Sources   Download

MIT

The Requires

 

20/07 2016

1.0.9

1.0.9.0

BixevIntervention API SDK

  Sources   Download

MIT

The Requires

 

19/07 2016

1.0.8

1.0.8.0

BixevIntervention API SDK

  Sources   Download

MIT

The Requires

 

10/05 2016

1.0.7

1.0.7.0

BixevIntervention API SDK

  Sources   Download

MIT

The Requires

 

25/04 2016

1.0.6

1.0.6.0

BixevIntervention API SDK

  Sources   Download

MIT

The Requires

 

22/03 2016

1.0.5

1.0.5.0

BixevIntervention API SDK

  Sources   Download

MIT

The Requires

 

22/03 2016

1.0.4

1.0.4.0

BixevIntervention API SDK

  Sources   Download

MIT

The Requires

 

19/03 2016

1.0.3

1.0.3.0

BixevIntervention API SDK

  Sources   Download

MIT

The Requires

 

07/03 2016

1.0.2

1.0.2.0

BixevIntervention API SDK

  Sources   Download

MIT

The Requires

 

05/03 2016

1.0.1

1.0.1.0

BixevIntervention API SDK

  Sources   Download

MIT

The Requires

  • php >=5.3

 

05/03 2016

1.0.0

1.0.0.0

BixevIntervention API SDK

  Sources   Download

The Requires

  • php >=5.3