Add Call and Contact API

This commit is contained in:
alphayax 2016-05-21 22:39:24 +02:00
parent c72c9fdb08
commit ae2f716501
21 changed files with 1578 additions and 0 deletions

View File

@ -12,6 +12,13 @@ Ce projet est basé sur **composer**. Pensez à installer les dependences :)
Jusqu'a présent, les fonctionalités suivantes ont été implémentées :
- AirMedia
- Call
- CallEntry
- ContactEntry
- ContactAddress
- ContactEmail
- ContactNumber
- ContactUrl
- FileSystem
- FileSystem (Core)
- FsTask
@ -90,6 +97,9 @@ alphayax\freebox\api\v3\models\SystemConfig Object
Les exemples sont disponibles dans le repertoire `exemple`. Ils sont classés par services :
- `AirMedia` : Exemple de lancement d'une video sur le Freebox Player
- `Call` :
- `Call` : Liste les appels recus et emis sur la freebox (avec exemple de supression et de marquage comme lu)
- `Contact` : Liste les contacts, ajoute et retire un numéro de téléphone au premier contact de la liste
- `FileSystem`
- `fileSharing` : Un exemple de partage de fichier sur le net
- `fsListing` : Un exemple de scan de repertoires de la freebox

31
exemple/Call/Call.php Normal file
View File

@ -0,0 +1,31 @@
<?php
/// Require Composer AutoLoader
require_once '../../vendor/autoload.php';
/// Define our application
$App = new \alphayax\freebox\utils\Application( 'com.alphayax.freebox.call', 'PHP API Example (Call)', '1.0.0');
$App->authorize();
$App->openSession();
$CallService = new \alphayax\freebox\api\v3\services\Call\CallEntry( $App);
/// Get last 100 call entries
$CallEntries = $CallService->getAll();
//print_r( $CallEntries);
/// Get a specific call entry
$CallEntry = $CallService->getFromId( $CallEntries[0]->getId());
print_r( $CallEntry);
/// Delete a specific call entry
$isDeleted = $CallService->deleteFromId( $CallEntries[0]->getId());
print_r( $isDeleted);
/// Update a specific call entry
$CallEntries[1]->setNew( false);
$CallEntry = $CallService->update( $CallEntries[1]);
print_r( $CallEntry);

65
exemple/Call/Contact.php Normal file
View File

@ -0,0 +1,65 @@
<?php
/// Require Composer AutoLoader
require_once '../../vendor/autoload.php';
/// Define our application
$App = new \alphayax\freebox\utils\Application( 'com.alphayax.freebox.call', 'PHP API Example (Call)', '1.0.0');
$App->authorize();
$App->openSession();
$ContactService = new \alphayax\freebox\api\v3\services\Call\ContactEntry( $App);
$ContactEntries = $ContactService->getAll();
print_r( $ContactEntries);
/*
$ContactNumber = new \alphayax\freebox\api\v3\models\Call\ContactNumber();
$ContactNumber->setContactId( 1);
$ContactNumber->setNumber( '0213456789');
$ContactNumber->setType( \alphayax\freebox\api\v3\symbols\Call\ContactNumberType::HOME);
$ContactNumber = $ContactService->addContactNumber( $ContactNumber);
print_r( $ContactNumber);
$ContactNumbers = $ContactService->getContactNumbersFromContactId( 1);
print_r( $ContactNumbers);
*/
/*
$ContactAddressService = new \alphayax\freebox\api\v3\services\Call\ContactAddress( $App);
$ContactAddress = new \alphayax\freebox\api\v3\models\Call\ContactAddress();
$ContactAddress->setContactId( $ContactEntries[0]->getId());
$ContactAddress->setType( \alphayax\freebox\api\v3\symbols\Call\ContactAdressType::WORK);
$ContactAddress->setCity( 'Montpellier');
$ContactAddress->setCountry( 'France');
$ContactAddressCreated = $ContactAddressService->create( $ContactAddress);
print_r( $ContactAddressCreated);
$ContactAddressDeleted = $ContactAddressService->delete( $ContactAddressCreated);
print_r( $ContactAddressDeleted);
*/
$ContactNumbersService = new \alphayax\freebox\api\v3\services\Call\ContactNumber( $App);
$Number = new \alphayax\freebox\api\v3\models\Call\ContactNumber();
$Number->setType(\alphayax\freebox\api\v3\symbols\Call\ContactNumberType::HOME);
$Number->setNumber('0456123789');
$Number->setContactId( $ContactEntries[0]->getId());
$Number = $ContactNumbersService->create( $Number);
$ContactNumbers = $ContactService->getContactNumbersFromContactId( $ContactEntries[0]->getId());
print_r( $ContactNumbers);
$ContactNumbersService->delete( $Number);
$ContactNumbers = $ContactService->getContactNumbersFromContactId( $ContactEntries[0]->getId());
print_r( $ContactNumbers);

View File

@ -0,0 +1,55 @@
<?php
namespace alphayax\freebox\Exception;
class InvalidRequestException extends \Exception {
protected $http_request_header;
protected $http_url;
protected $http_params;
/**
* @return mixed
*/
public function getHttpRequestHeader() {
return $this->http_request_header;
}
/**
* @param mixed $http_method
*/
public function setHttpRequestHeader( $http_method) {
$this->http_request_header = $http_method;
}
/**
* @return mixed
*/
public function getHttpUrl() {
return $this->http_url;
}
/**
* @param mixed $http_url
*/
public function setHttpUrl( $http_url) {
$this->http_url = $http_url;
}
/**
* @return mixed
*/
public function getHttpParams() {
return $this->http_params;
}
/**
* @param mixed $http_params
*/
public function setHttpParams( $http_params) {
$this->http_params = $http_params;
}
}

View File

@ -0,0 +1,103 @@
<?php
namespace alphayax\freebox\api\v3\models\Call;
use alphayax\freebox\api\v3\Model;
/**
* Class CallEntry
* @package alphayax\freebox\api\v3\models\Call
*/
class CallEntry extends Model {
/** @var int (Read-only) : id */
protected $id;
/**
* @var string (Read-only)
* @see alphayax\freebox\api\v3\symbols\Call\CallEntryType
*/
protected $type;
/** @var int timestamp (Read-only) : Call creation timestamp. */
protected $datetime;
/** @var string (Read-only) : Callee number for outgoing calls. Caller number for incoming calls. */
protected $number;
/** @var string (Read-only)
* Callee name for outgoing calls. Caller name for incoming calls.
* For incoming call if the network does not provide a contact name, we try to use the contact database to find a suitable name */
protected $name;
/** @var int (Read-only) : Call duration in seconds. */
protected $duration;
/** @var bool : Call entry as not been acknowledged yet. */
protected $new;
/** @var int (Read-only) : If the number matches an entry in the contact database, the id of the matching contact. */
protected $contact_id;
/**
* @return int
*/
public function getId() {
return $this->id;
}
/**
* @return string
*/
public function getType() {
return $this->type;
}
/**
* @return int
*/
public function getDatetime() {
return $this->datetime;
}
/**
* @return string
*/
public function getNumber() {
return $this->number;
}
/**
* @return string
*/
public function getName() {
return $this->name;
}
/**
* @return int
*/
public function getDuration() {
return $this->duration;
}
/**
* @return boolean
*/
public function isNew() {
return $this->new;
}
/**
* @param boolean $new
*/
public function setNew( $new) {
$this->new = $new;
}
/**
* @return int
*/
public function getContactId() {
return $this->contact_id;
}
}

View File

@ -0,0 +1,167 @@
<?php
namespace alphayax\freebox\api\v3\models\Call;
use alphayax\freebox\api\v3\Model;
/**
* Class ContactAddress
* @package alphayax\freebox\api\v3\models\Call
*/
class ContactAddress extends Model {
/** @var int : address id */
protected $id;
/** @var int : id of the related contact */
protected $contact_id;
/**
* @var string : Type of email
* @see ContactAddressType
*/
protected $type;
/** @var string */
protected $number;
/** @var string */
protected $street;
/** @var string */
protected $street2;
/** @var string */
protected $city;
/** @var string */
protected $zipcode;
/** @var string */
protected $country;
/**
* @return int
*/
public function getId() {
return $this->id;
}
/**
* @param int $id
*/
public function setId($id) {
$this->id = $id;
}
/**
* @return int
*/
public function getContactId() {
return $this->contact_id;
}
/**
* @param int $contact_id
*/
public function setContactId( $contact_id) {
$this->contact_id = $contact_id;
}
/**
* @return string
*/
public function getType() {
return $this->type;
}
/**
* @param string $type
*/
public function setType( $type) {
$this->type = $type;
}
/**
* @return string
*/
public function getNumber() {
return $this->number;
}
/**
* @param string $number
*/
public function setNumber( $number) {
$this->number = $number;
}
/**
* @return string
*/
public function getStreet() {
return $this->street;
}
/**
* @param string $street
*/
public function setStreet( $street) {
$this->street = $street;
}
/**
* @return string
*/
public function getStreet2() {
return $this->street2;
}
/**
* @param string $street2
*/
public function setStreet2( $street2) {
$this->street2 = $street2;
}
/**
* @return string
*/
public function getCity() {
return $this->city;
}
/**
* @param string $city
*/
public function setCity( $city) {
$this->city = $city;
}
/**
* @return string
*/
public function getZipcode() {
return $this->zipcode;
}
/**
* @param string $zipcode
*/
public function setZipcode( $zipcode) {
$this->zipcode = $zipcode;
}
/**
* @return string
*/
public function getCountry() {
return $this->country;
}
/**
* @param string $country
*/
public function setCountry( $country) {
$this->country = $country;
}
}

View File

@ -0,0 +1,82 @@
<?php
namespace alphayax\freebox\api\v3\models\Call;
use alphayax\freebox\api\v3\Model;
/**
* Class ContactEmail
* @package alphayax\freebox\api\v3\models\Call
*/
class ContactEmail extends Model {
/** @var int : address id */
protected $id;
/** @var int : id of the related contact */
protected $contact_id;
/**
* @var string : Type of address
* @see alphayax\freebox\api\v3\symbols\Call\ContactEmailType
*/
protected $type;
/** @var string : email address */
protected $email;
/**
* @return int
*/
public function getId() {
return $this->id;
}
/**
* @param int $id
*/
public function setId( $id) {
$this->id = $id;
}
/**
* @return int
*/
public function getContactId() {
return $this->contact_id;
}
/**
* @param int $contact_id
*/
public function setContactId( $contact_id) {
$this->contact_id = $contact_id;
}
/**
* @return string
*/
public function getType() {
return $this->type;
}
/**
* @param string $type
*/
public function setType( $type) {
$this->type = $type;
}
/**
* @return string
*/
public function getEmail() {
return $this->email;
}
/**
* @param string $email
*/
public function setEmail( $email) {
$this->email = $email;
}
}

View File

@ -0,0 +1,255 @@
<?php
namespace alphayax\freebox\api\v3\models\Call;
use alphayax\freebox\api\v3\Model;
/**
* Class ContactEntry
* @package alphayax\freebox\api\v3\models\Call
*/
class ContactEntry extends Model {
/** @var int : contact id */
protected $id;
/** @var string : contact display name */
protected $display_name;
/** @var string : contact first name */
protected $first_name;
/** @var string : contact last name */
protected $last_name;
/** @var string : contact company name */
protected $company;
/** @var string : contact photo URL. NOTE the photo URL can be embedded (for instance “data:image/jpeg;base64,/9j/4AA [ ... ]”) */
protected $photo_url;
/** @var int timestamp : contact last modification timestamp */
protected $last_update ;
/** @var string : contact last modification timestamp */
protected $notes;
/** @var ContactAddress[] : list of contact postal addresses */
protected $addresses = [];
/** @var ContactEmail[] : list of contact email addresses */
protected $emails = [];
/** @var ContactNumber[] : list of contact phone numbers */
protected $numbers = [];
/** @var ContactUrl[] : list of contact URL */
protected $urls = [];
/**
* FreeplugNetwork constructor.
* @param array $properties_x
*/
public function __construct( array $properties_x){
parent::__construct( $properties_x);
$this->initPropertyArray( 'addresses', ContactAddress::class);
$this->initPropertyArray( 'emails' , ContactEmail::class);
$this->initPropertyArray( 'numbers' , ContactNumber::class);
$this->initPropertyArray( 'urls' , ContactUrl::class);
}
/**
* @return int
*/
public function getId() {
return $this->id;
}
/**
* @param int $id
*/
public function setId( $id) {
$this->id = $id;
}
/**
* @return string
*/
public function getDisplayName() {
return $this->display_name;
}
/**
* @param string $display_name
*/
public function setDisplayName( $display_name) {
$this->display_name = $display_name;
}
/**
* @return string
*/
public function getFirstName() {
return $this->first_name;
}
/**
* @param string $first_name
*/
public function setFirstName( $first_name) {
$this->first_name = $first_name;
}
/**
* @return string
*/
public function getLastName() {
return $this->last_name;
}
/**
* @param string $last_name
*/
public function setLastName( $last_name) {
$this->last_name = $last_name;
}
/**
* @return string
*/
public function getCompany() {
return $this->company;
}
/**
* @param string $company
*/
public function setCompany( $company) {
$this->company = $company;
}
/**
* @return string
*/
public function getPhotoUrl() {
return $this->photo_url;
}
/**
* @param string $photo_url
*/
public function setPhotoUrl( $photo_url) {
$this->photo_url = $photo_url;
}
/**
* @return int
*/
public function getLastUpdate() {
return $this->last_update;
}
/**
* @param int $last_update
*/
public function setLastUpdate( $last_update) {
$this->last_update = $last_update;
}
/**
* @return string
*/
public function getNotes() {
return $this->notes;
}
/**
* @param string $notes
*/
public function setNotes( $notes) {
$this->notes = $notes;
}
/**
* @return ContactAddress[]
*/
public function getAddresses() {
return $this->addresses;
}
/**
* @param ContactAddress[] $addresses
*/
public function setAddresses( array $addresses) {
$this->addresses = $addresses;
}
/**
* @param ContactAddress $address
*/
public function addAddress( ContactAddress $address) {
$this->addresses[] = $address;
}
/**
* @return ContactEmail[]
*/
public function getEmails() {
return $this->emails;
}
/**
* @param ContactEmail[] $emails
*/
public function setEmails( array $emails) {
$this->emails = $emails;
}
/**
* @param ContactEmail $email
*/
public function addEmail( ContactEmail $email) {
$this->emails[] = $email;
}
/**
* @return ContactNumber[]
*/
public function getNumbers() {
return $this->numbers;
}
/**
* @param ContactNumber[] $numbers
*/
public function setNumbers( array $numbers) {
$this->numbers = $numbers;
}
/**
* @param ContactNumber $number
*/
public function addNumbers( ContactNumber $number) {
$this->numbers[] = $number;
}
/**
* @return ContactUrl[]
*/
public function getUrls() {
return $this->urls;
}
/**
* @param ContactUrl[] $urls
*/
public function setUrls( array $urls) {
$this->urls = $urls;
}
/**
* @param ContactUrl $url
*/
public function addUrl( ContactUrl $url) {
$this->urls[] = $url;
}
}

View File

@ -0,0 +1,116 @@
<?php
namespace alphayax\freebox\api\v3\models\Call;
use alphayax\freebox\api\v3\Model;
/**
* Class ContactNumber
* @package alphayax\freebox\api\v3\models\Call
*/
class ContactNumber extends Model {
/** @var int : address id */
protected $id;
/** @var int : id of the related contact */
protected $contact_id;
/**
* @var string
* @see alphayax\freebox\api\v3\symbols\Call\ContactNumberType
*/
protected $type;
/** @var string */
protected $number;
/** @var bool : is this number the preferred contact phone number */
protected $is_default;
/** @var bool : is this number the Freebox owner number */
protected $is_own;
/**
* @return int
*/
public function getId() {
return $this->id;
}
/**
* @param int $id
*/
public function setId($id) {
$this->id = $id;
}
/**
* @return int
*/
public function getContactId() {
return $this->contact_id;
}
/**
* @param int $contact_id
*/
public function setContactId($contact_id) {
$this->contact_id = $contact_id;
}
/**
* @return string
*/
public function getType() {
return $this->type;
}
/**
* @param string $type
*/
public function setType($type) {
$this->type = $type;
}
/**
* @return string
*/
public function getNumber() {
return $this->number;
}
/**
* @param string $number
*/
public function setNumber($number) {
$this->number = $number;
}
/**
* @return boolean
*/
public function isIsDefault() {
return $this->is_default;
}
/**
* @param boolean $is_default
*/
public function setIsDefault($is_default) {
$this->is_default = $is_default;
}
/**
* @return boolean
*/
public function isIsOwn() {
return $this->is_own;
}
/**
* @param boolean $is_own
*/
public function setIsOwn($is_own) {
$this->is_own = $is_own;
}
}

View File

@ -0,0 +1,82 @@
<?php
namespace alphayax\freebox\api\v3\models\Call;
use alphayax\freebox\api\v3\Model;
/**
* Class ContactUrl
* @package alphayax\freebox\api\v3\models\Call
*/
class ContactUrl extends Model {
/** @var int : address id */
protected $id;
/** @var int : id of the related contact */
protected $contact_id;
/**
* @var string : Type of URL
* @see ContactUrlType
*/
protected $type;
/** @var string : URL address */
protected $url;
/**
* @return int
*/
public function getId() {
return $this->id;
}
/**
* @param int $id
*/
public function setId( $id) {
$this->id = $id;
}
/**
* @return int
*/
public function getContactId() {
return $this->contact_id;
}
/**
* @param int $contact_id
*/
public function setContactId( $contact_id) {
$this->contact_id = $contact_id;
}
/**
* @return string
*/
public function getType() {
return $this->type;
}
/**
* @param string $type
*/
public function setType( $type) {
$this->type = $type;
}
/**
* @return string
*/
public function getUrl() {
return $this->url;
}
/**
* @param string $url
*/
public function setUrl( $url) {
$this->url = $url;
}
}

View File

@ -0,0 +1,77 @@
<?php
namespace alphayax\freebox\api\v3\services\Call;
use alphayax\freebox\api\v3\Service;
use alphayax\freebox\api\v3\models;
/**
* Class System
* @package alphayax\freebox\api\v3\services\config
*/
class CallEntry extends Service {
const API_CALL_LOG = '/api/v3/call/log/';
/**
* List every calls
* @throws \Exception
* @return models\Call\CallEntry[]
*/
public function getAll(){
$rest = $this->getAuthService( self::API_CALL_LOG);
$rest->GET();
$CallEntry_xs = $rest->getCurlResponse()['result'];
$CallEntries = [];
foreach( $CallEntry_xs as $CallEntry_x) {
$CallEntries[] = new models\Call\CallEntry( $CallEntry_x);
}
return $CallEntries;
}
/**
* Access a given call entry
* @param int $CallId
* @return models\Call\CallEntry[]
*/
public function getFromId( $CallId){
$rest = $this->getAuthService( self::API_CALL_LOG . $CallId);
$rest->GET();
return new models\Call\CallEntry( $rest->getCurlResponse()['result']);
}
/**
* Delete a call entry
* @param models\Call\CallEntry $CallEntry
* @return bool
*/
public function delete( models\Call\CallEntry $CallEntry){
return $this->deleteFromId( $CallEntry->getId());
}
/**
* Delete a call entry
* @param int $CallId
* @return bool
*/
public function deleteFromId( $CallId){
$rest = $this->getAuthService( self::API_CALL_LOG . $CallId);
$rest->DELETE();
return (bool) $rest->getCurlResponse()['success'];
}
/**
* Update a given call entry
* @param models\Call\CallEntry $CallEntry
* @return models\Call\CallEntry
*/
public function update( models\Call\CallEntry $CallEntry){
$rest = $this->getAuthService( self::API_CALL_LOG . $CallEntry->getId());
$rest->PUT( $CallEntry->toArray());
return new models\Call\CallEntry( $rest->getCurlResponse()['result']);
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace alphayax\freebox\api\v3\services\Call;
use alphayax\freebox\api\v3\Service;
use alphayax\freebox\api\v3\models;
/**
* Class ContactAddress
* @package alphayax\freebox\api\v3\services\Call
*/
class ContactAddress extends Service {
const API_ADDRESS = '/api/v3/address/';
/**
* @param int $contactAddressId
* @return models\Call\ContactAddress
*/
public function getFromId( $contactAddressId){
$rest = $this->getAuthService( self::API_ADDRESS . $contactAddressId);
$rest->GET();
return new models\Call\ContactAddress ( $rest->getCurlResponse()['result']);
}
/**
* @param models\Call\ContactAddress $contactAddress
* @return models\Call\ContactAddress
*/
public function create( models\Call\ContactAddress $contactAddress){
$rest = $this->getAuthService( self::API_ADDRESS);
$rest->POST( $contactAddress->toArray());
return new models\Call\ContactAddress ( $rest->getCurlResponse()['result']);
}
/**
* @param models\Call\ContactAddress $contactAddress
* @return bool
*/
public function delete( models\Call\ContactAddress $contactAddress){
return $this->deleteFromId( $contactAddress->getId());
}
/**
* @param int $contactAddressId
* @return bool
*/
public function deleteFromId( $contactAddressId){
$rest = $this->getAuthService( self::API_ADDRESS . $contactAddressId);
$rest->DELETE();
return (bool) $rest->getCurlResponse()['success'];
}
/**
* @param models\Call\ContactAddress $contactAddress
* @return models\Call\ContactAddress
*/
public function update( models\Call\ContactAddress $contactAddress){
$rest = $this->getAuthService( self::API_ADDRESS . $contactAddress->getId());
$rest->PUT( $contactAddress->toArray());
return new models\Call\ContactAddress( $rest->getCurlResponse()['result']);
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace alphayax\freebox\api\v3\services\Call;
use alphayax\freebox\api\v3\Service;
use alphayax\freebox\api\v3\models;
/**
* Class ContactEmail
* @package alphayax\freebox\api\v3\services\Call
*/
class ContactEmail extends Service {
const API_EMAIL = '/api/v3/email/';
/**
* @param int $ContactEmailId
* @return models\Call\ContactEmail
*/
public function getFromId( $ContactEmailId){
$rest = $this->getAuthService( self::API_EMAIL . $ContactEmailId);
$rest->GET();
return new models\Call\ContactEmail( $rest->getCurlResponse()['result']);
}
/**
* @param models\Call\ContactEmail $ContactEmail
* @return models\Call\ContactEmail
*/
public function create( models\Call\ContactEmail $ContactEmail){
$rest = $this->getAuthService( self::API_EMAIL);
$rest->POST( $ContactEmail->toArray());
return new models\Call\ContactEmail( $rest->getCurlResponse()['result']);
}
/**
* @param models\Call\ContactEmail $ContactEmail
* @return bool
*/
public function delete( models\Call\ContactEmail $ContactEmail){
return $this->deleteFromId( $ContactEmail->getId());
}
/**
* @param int $ContactEmailId
* @return bool
*/
public function deleteFromId( $ContactEmailId){
$rest = $this->getAuthService( self::API_EMAIL . $ContactEmailId);
$rest->DELETE();
return (bool) $rest->getCurlResponse()['success'];
}
/**
* @param models\Call\ContactEmail $ContactEmail
* @return models\Call\ContactEmail
*/
public function update( models\Call\ContactEmail $ContactEmail){
$rest = $this->getAuthService( self::API_EMAIL . $ContactEmail->getId());
$rest->PUT( $ContactEmail->toArray());
return new models\Call\ContactEmail( $rest->getCurlResponse()['result']);
}
}

View File

@ -0,0 +1,155 @@
<?php
namespace alphayax\freebox\api\v3\services\Call;
use alphayax\freebox\api\v3\Service;
use alphayax\freebox\api\v3\models;
/**
* Class Contact
* @package alphayax\freebox\api\v3\services\Call
*/
class ContactEntry extends Service {
const API_CONTACT = '/api/v3/contact/';
const API_CONTACT_NUMBERS = '/api/v3/contact/%u/numbers/';
const API_CONTACT_ADDRESSES = '/api/v3/contact/%u/addresses/';
const API_CONTACT_URLS = '/api/v3/contact/%u/urls/';
const API_CONTACT_EMAILS = '/api/v3/contact/%u/emails/';
/**
* List every calls
* @return models\Call\CallEntry[]
*/
public function getAll(){
$rest = $this->getAuthService( self::API_CONTACT);
$rest->GET();
$ContactEntry_xs = $rest->getCurlResponse()['result'];
$ContactEntries = [];
foreach( $ContactEntry_xs as $ContactEntry_x) {
$ContactEntries[] = new models\Call\ContactEntry( $ContactEntry_x);
}
return $ContactEntries;
}
/**
* @param int $ContactEntryId
* @return models\Call\ContactEntry
*/
public function getFromId( $ContactEntryId){
$rest = $this->getAuthService( self::API_CONTACT . $ContactEntryId);
$rest->GET();
return new models\Call\ContactEntry( $rest->getCurlResponse()['result']);
}
/**
* @param models\Call\ContactEntry $ContactEntry
* @return models\Call\ContactEntry
*/
public function create( models\Call\ContactEntry $ContactEntry){
$rest = $this->getAuthService( self::API_CONTACT);
$rest->POST( $ContactEntry->toArray());
return new models\Call\ContactEntry( $rest->getCurlResponse()['result']);
}
/**
* @param models\Call\ContactEntry $ContactEntry
* @return models\Call\ContactEntry
*/
public function update( models\Call\ContactEntry $ContactEntry){
$rest = $this->getAuthService( self::API_CONTACT . $ContactEntry->getId());
$rest->PUT( $ContactEntry->toArray());
return new models\Call\ContactEntry( $rest->getCurlResponse()['result']);
}
/**
* @param models\Call\ContactEntry $ContactEntry
* @return models\Call\ContactEntry
*/
public function delete( models\Call\ContactEntry $ContactEntry){
return $this->deleteFromId( $ContactEntry->getId());
}
/**
* @param int $ContactEntryId
* @return models\Call\ContactEntry
*/
public function deleteFromId( $ContactEntryId){
$rest = $this->getAuthService( self::API_CONTACT);
$rest->DELETE( $ContactEntryId);
return $rest->getCurlResponse()['success'];
}
/**
* @param int $ContactEntryId
* @return models\Call\ContactNumber[]
*/
public function getContactNumbersFromContactId( $ContactEntryId){
$service = sprintf( self::API_CONTACT_NUMBERS, $ContactEntryId);
$rest = $this->getAuthService( $service);
$rest->GET();
$ContactNumber_xs = @$rest->getCurlResponse()['result'] ?: [];
$ContactNumbers = [];
foreach( $ContactNumber_xs as $ContactNumber_x) {
$ContactNumbers[] = new models\Call\ContactNumber( $ContactNumber_x);
}
return $ContactNumbers;
}
/**
* @param int $ContactEntryId
* @return models\Call\ContactAddress[]
*/
public function getContactAddressesFromContactId( $ContactEntryId){
$service = sprintf( self::API_CONTACT_ADDRESSES, $ContactEntryId);
$rest = $this->getAuthService( $service);
$rest->GET();
$ContactAddress_xs = @$rest->getCurlResponse()['result'] ?: [];
$ContactAddresses = [];
foreach( $ContactAddress_xs as $ContactAddress_x) {
$ContactAddresses[] = new models\Call\ContactAddress( $ContactAddress_x);
}
return $ContactAddresses;
}
/**
* @param int $ContactEntryId
* @return models\Call\ContactEmail[]
*/
public function getContactEmailsFromContactId( $ContactEntryId){
$service = sprintf( self::API_CONTACT_EMAILS, $ContactEntryId);
$rest = $this->getAuthService( $service);
$rest->GET();
$ContactEmail_xs = @$rest->getCurlResponse()['result'] ?: [];
$ContactEmails = [];
foreach( $ContactEmail_xs as $ContactEmail_x) {
$ContactEmails[] = new models\Call\ContactEmail( $ContactEmail_x);
}
return $ContactEmails;
}
/**
* @param int $ContactEntryId
* @return models\Call\ContactUrl[]
*/
public function getContactUrlsFromContactId( $ContactEntryId){
$service = sprintf( self::API_CONTACT_URLS, $ContactEntryId);
$rest = $this->getAuthService( $service);
$rest->GET();
$ContactUrl_xs = @$rest->getCurlResponse()['result'] ?: [];
$ContactUrls = [];
foreach( $ContactUrl_xs as $ContactUrl_x) {
$ContactUrls[] = new models\Call\ContactUrl( $ContactUrl_x);
}
return $ContactUrls;
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace alphayax\freebox\api\v3\services\Call;
use alphayax\freebox\api\v3\Service;
use alphayax\freebox\api\v3\models;
/**
* Class ContactNumber
* @package alphayax\freebox\api\v3\services\Call
*/
class ContactNumber extends Service {
const API_NUMBER = '/api/v3/number/';
/**
* @param int $ContactNumberId
* @return models\Call\ContactNumber
*/
public function getFromId( $ContactNumberId){
$rest = $this->getAuthService( self::API_NUMBER . $ContactNumberId);
$rest->GET();
return new models\Call\ContactNumber( $rest->getCurlResponse()['result']);
}
/**
* @param models\Call\ContactNumber $ContactNumber
* @return models\Call\ContactNumber
*/
public function create( models\Call\ContactNumber $ContactNumber){
$rest = $this->getAuthService( self::API_NUMBER);
$rest->POST( $ContactNumber->toArray());
return new models\Call\ContactNumber( $rest->getCurlResponse()['result']);
}
/**
* @param models\Call\ContactNumber $ContactNumber
* @return bool
*/
public function delete( models\Call\ContactNumber $ContactNumber){
return $this->deleteFromId( $ContactNumber->getId());
}
/**
* @param int $ContactNumberId
* @return bool
*/
public function deleteFromId( $ContactNumberId){
$rest = $this->getAuthService( self::API_NUMBER . $ContactNumberId);
$rest->DELETE();
return (bool) $rest->getCurlResponse()['success'];
}
/**
* @param models\Call\ContactNumber $ContactNumber
* @return models\Call\ContactNumber
*/
public function update( models\Call\ContactNumber $ContactNumber){
$rest = $this->getAuthService( self::API_NUMBER . $ContactNumber->getId());
$rest->PUT( $ContactNumber->toArray());
return new models\Call\ContactNumber( $rest->getCurlResponse()['result']);
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace alphayax\freebox\api\v3\services\Call;
use alphayax\freebox\api\v3\Service;
use alphayax\freebox\api\v3\models;
/**
* Class ContactUrl
* @package alphayax\freebox\api\v3\services\Call
*/
class ContactUrl extends Service {
const API_URL = '/api/v3/url/';
/**
* @param int $ContactUrlId
* @return models\Call\ContactUrl
*/
public function getFromId( $ContactUrlId){
$rest = $this->getAuthService( self::API_URL . $ContactUrlId);
$rest->GET();
return new models\Call\ContactUrl( $rest->getCurlResponse()['result']);
}
/**
* @param models\Call\ContactUrl $ContactUrl
* @return models\Call\ContactUrl
*/
public function create( models\Call\ContactUrl $ContactUrl){
$rest = $this->getAuthService( self::API_URL);
$rest->POST( $ContactUrl->toArray());
return new models\Call\ContactUrl( $rest->getCurlResponse()['result']);
}
/**
* @param models\Call\ContactUrl $ContactUrl
* @return bool
*/
public function delete( models\Call\ContactUrl $ContactUrl){
return $this->deleteFromId( $ContactUrl->getId());
}
/**
* @param int $ContactUrlId
* @return bool
*/
public function deleteFromId( $ContactUrlId){
$rest = $this->getAuthService( self::API_URL . $ContactUrlId);
$rest->DELETE();
return (bool) $rest->getCurlResponse()['success'];
}
/**
* @param models\Call\ContactUrl $ContactUrl
* @return models\Call\ContactUrl
*/
public function update( models\Call\ContactUrl $ContactUrl){
$rest = $this->getAuthService( self::API_URL . $ContactUrl->getId());
$rest->PUT( $ContactUrl->toArray());
return new models\Call\ContactUrl( $rest->getCurlResponse()['result']);
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace alphayax\freebox\api\v3\symbols\Call;
/**
* Interface CallEntryType
* @package alphayax\freebox\api\v3\symbols\Call
* @see alphayax\freebox\api\v3\models\Call\CallEntry
*/
interface CallEntryType {
/** Missed incoming call */
const MISSED = 'missed';
/** Incoming call */
const ACCEPTED = 'accepted';
/** Outgoing call */
const OUTGOING = 'outgoing';
}

View File

@ -0,0 +1,20 @@
<?php
namespace alphayax\freebox\api\v3\symbols\Call;
/**
* Symbol ContactAdressType
* @package alphayax\freebox\api\v3\symbols\Call
* @see alphayax\freebox\api\v3\models\Call\ContactAddress
*/
interface ContactAdressType {
/** home address */
const HOME = 'home';
/** work address */
const WORK = 'work';
/** other */
const OTHER = 'other';
}

View File

@ -0,0 +1,20 @@
<?php
namespace alphayax\freebox\api\v3\symbols\Call;
/**
* Symbol ContactEmailType
* @package alphayax\freebox\api\v3\symbols\Call
* @see alphayax\freebox\api\v3\models\Call\ContactEmail
*/
interface ContactEmailType {
/** home address */
const HOME = 'home';
/** work address */
const WORK = 'work';
/** other */
const OTHER = 'other';
}

View File

@ -0,0 +1,29 @@
<?php
namespace alphayax\freebox\api\v3\symbols\Call;
/**
* Symbol ContactNumberType
* @package alphayax\freebox\api\v3\symbols\Call
* @see alphayax\freebox\api\v3\models\Call\ContactNumber
*/
interface ContactNumberType {
/** home address */
const HOME = 'fixed';
/** fixed phone */
const FIXED = 'fixed';
/** mobile phone */
const MOBILE = 'mobile';
/** fax */
const FAX = 'fax';
/** work address */
const WORK = 'work';
/** other */
const OTHER = 'other';
}

View File

@ -0,0 +1,23 @@
<?php
namespace alphayax\freebox\api\v3\symbols\Call;
/**
* Symbol ContactUrlType
* @package alphayax\freebox\api\v3\symbols\Call
* @see alphayax\freebox\api\v3\models\Call\ContactUrl
*/
interface ContactUrlType {
/** profile address */
const PROFILE = 'profile';
/** blog address */
const BLOG = 'blog';
/** site adress */
const SITE = 'site';
/** other */
const OTHER = 'other';
}