From a8869d0dd30b1574efc66b25e9e27c8ad8513562 Mon Sep 17 00:00:00 2001 From: alphayax Date: Thu, 9 Jun 2016 21:52:44 +0200 Subject: [PATCH] Refresh Call API Add Call documentation --- README.md | 8 +- docs/AirMedia.md | 13 ++- docs/Call.md | 86 +++++++++++++++++++ exemple/Call/Call.php | 2 +- freebox/api/v3/services/Call/CallEntry.php | 17 ++-- .../api/v3/services/Call/ContactAddress.php | 12 +-- freebox/api/v3/services/Call/ContactEmail.php | 12 +-- freebox/api/v3/services/Call/ContactEntry.php | 47 +++------- .../api/v3/services/Call/ContactNumber.php | 12 +-- freebox/api/v3/services/Call/ContactUrl.php | 12 +-- 10 files changed, 135 insertions(+), 86 deletions(-) create mode 100644 docs/Call.md diff --git a/README.md b/README.md index acb3a10..6e8db74 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,7 @@ Pensez à installer les dependences :) L'intégralité des fonctionnalités de l'API Freebox (v3) sont implémentées : - [AirMedia](docs/AirMedia) -- Call - - CallEntry - - ContactEntry - - ContactAddress - - ContactEmail - - ContactNumber - - ContactUrl +- [Call](docs/Call) - FileSystem - FileSystem (Core) - FsTask diff --git a/docs/AirMedia.md b/docs/AirMedia.md index de9d743..f387445 100644 --- a/docs/AirMedia.md +++ b/docs/AirMedia.md @@ -1,19 +1,18 @@ # AirMedia -## Services +## AirMedia -### AirMedia +|---| +| Namespace |`alphayax\freebox\api\v3\services\AirMedia\` | +| Classe | `AirMedia`| -Namespace `alphayax\freebox\api\v3\services\AirMedia\` -Classe `AirMedia` - -#### Configuration +### Configuration - getConfiguration : Récupère la configuration courrante - setConfiguration : Définit la configuration -#### AirMedia Receivers +### AirMedia Receivers - getAirMediaReceivers : Retourne la liste des AirMedia Receivers connectés a la freebox - sendRequestToAirMediaReceiver : Envoie une Requete a un AirMedia Receiver donné \ No newline at end of file diff --git a/docs/Call.md b/docs/Call.md new file mode 100644 index 0000000..ef484a4 --- /dev/null +++ b/docs/Call.md @@ -0,0 +1,86 @@ + +# Call + +- CallEntry +- ContactEntry + - ContactEmail + - ContactAddress + - ContactNumber + - ContactUrl + +## CallEntry + +|---| +| Namespace |`alphayax\freebox\api\v3\services\Call` | +| Classe | `CallEntry`| + +- getAll : Retourne tous les appels +- getFromId : Retourne un appel donné +- delete : Supprime un appel de la liste des appels +- deleteFromId : Supprime un appel de la liste des appels +- update : Met à jour les informations d'un appel + +## ContactEntry + +|---| +| Namespace |`alphayax\freebox\api\v3\services\Call` | +| Classe | `ContactEntry`| + +- getAll : Retourne la liste de tous les contacts +- getFromId : Retourne un contact donné +- create : Ajoute une nouveau contact +- delete : Supprime un contact +- deleteFromId : Supprime un contact +- update : Met à jour les informations d'un contact +- getContactNumbersFromContactId : Retourne les numéros associés a un contact +- getContactAddressesFromContactId : Retourne les adresses associés a un contact +- getContactEmailsFromContactId : Retourne les emails associés a un contact +- getContactUrlsFromContactId : Retourne les URLs associés a un contact + +### Contact Email + +|---| +| Namespace |`alphayax\freebox\api\v3\services\Call` | +| Classe | `ContactEmail`| + +- getFromId +- create +- delete +- deleteFromId +- update + +### Contact Address + +|---| +| Namespace |`alphayax\freebox\api\v3\services\Call` | +| Classe | `ContactAddress`| + +- getFromId +- create +- delete +- deleteFromId +- update + +### Contact Number + +|---| +| Namespace |`alphayax\freebox\api\v3\services\Call` | +| Classe | `ContactNumber`| + +- getFromId +- create +- delete +- deleteFromId +- update + +### Contact URL + +|---| +| Namespace |`alphayax\freebox\api\v3\services\Call` | +| Classe | `ContactUrl`| + +- getFromId +- create +- delete +- deleteFromId +- update diff --git a/exemple/Call/Call.php b/exemple/Call/Call.php index 4dafc50..8e0174d 100644 --- a/exemple/Call/Call.php +++ b/exemple/Call/Call.php @@ -12,7 +12,7 @@ $CallService = new \alphayax\freebox\api\v3\services\Call\CallEntry( $App); /// Get last 100 call entries $CallEntries = $CallService->getAll(); -//print_r( $CallEntries); +print_r( $CallEntries); /// Get a specific call entry $CallEntry = $CallService->getFromId( $CallEntries[0]->getId()); diff --git a/freebox/api/v3/services/Call/CallEntry.php b/freebox/api/v3/services/Call/CallEntry.php index ed74552..91145dc 100644 --- a/freebox/api/v3/services/Call/CallEntry.php +++ b/freebox/api/v3/services/Call/CallEntry.php @@ -10,7 +10,7 @@ use alphayax\freebox\api\v3\models; */ class CallEntry extends Service { - const API_CALL_LOG = '/api/v3/call/log/'; + const API_CALL_LOG = '/api/v3/call/log/'; /** * List every calls @@ -21,12 +21,7 @@ class CallEntry extends Service { $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; + return $rest->getResultAsArray( models\Call\CallEntry::class); } /** @@ -38,7 +33,7 @@ class CallEntry extends Service { $rest = $this->getAuthService( self::API_CALL_LOG . $CallId); $rest->GET(); - return new models\Call\CallEntry( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\CallEntry::class); } /** @@ -59,7 +54,7 @@ class CallEntry extends Service { $rest = $this->getAuthService( self::API_CALL_LOG . $CallId); $rest->DELETE(); - return (bool) $rest->getCurlResponse()['success']; + return $rest->getSuccess(); } /** @@ -69,9 +64,9 @@ class CallEntry extends Service { */ public function update( models\Call\CallEntry $CallEntry){ $rest = $this->getAuthService( self::API_CALL_LOG . $CallEntry->getId()); - $rest->PUT( $CallEntry->toArray()); + $rest->PUT( $CallEntry); - return new models\Call\CallEntry( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\CallEntry::class); } } diff --git a/freebox/api/v3/services/Call/ContactAddress.php b/freebox/api/v3/services/Call/ContactAddress.php index e0e5fc0..b627d3b 100644 --- a/freebox/api/v3/services/Call/ContactAddress.php +++ b/freebox/api/v3/services/Call/ContactAddress.php @@ -20,7 +20,7 @@ class ContactAddress extends Service { $rest = $this->getAuthService( self::API_ADDRESS . $contactAddressId); $rest->GET(); - return new models\Call\ContactAddress ( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactAddress::class); } /** @@ -29,9 +29,9 @@ class ContactAddress extends Service { */ public function create( models\Call\ContactAddress $contactAddress){ $rest = $this->getAuthService( self::API_ADDRESS); - $rest->POST( $contactAddress->toArray()); + $rest->POST( $contactAddress); - return new models\Call\ContactAddress ( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactAddress::class); } /** @@ -50,7 +50,7 @@ class ContactAddress extends Service { $rest = $this->getAuthService( self::API_ADDRESS . $contactAddressId); $rest->DELETE(); - return (bool) $rest->getCurlResponse()['success']; + return $rest->getSuccess(); } /** @@ -59,9 +59,9 @@ class ContactAddress extends Service { */ public function update( models\Call\ContactAddress $contactAddress){ $rest = $this->getAuthService( self::API_ADDRESS . $contactAddress->getId()); - $rest->PUT( $contactAddress->toArray()); + $rest->PUT( $contactAddress); - return new models\Call\ContactAddress( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactAddress::class); } } diff --git a/freebox/api/v3/services/Call/ContactEmail.php b/freebox/api/v3/services/Call/ContactEmail.php index ec3e312..3fb0f00 100644 --- a/freebox/api/v3/services/Call/ContactEmail.php +++ b/freebox/api/v3/services/Call/ContactEmail.php @@ -20,7 +20,7 @@ class ContactEmail extends Service { $rest = $this->getAuthService( self::API_EMAIL . $ContactEmailId); $rest->GET(); - return new models\Call\ContactEmail( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactEmail::class); } /** @@ -29,9 +29,9 @@ class ContactEmail extends Service { */ public function create( models\Call\ContactEmail $ContactEmail){ $rest = $this->getAuthService( self::API_EMAIL); - $rest->POST( $ContactEmail->toArray()); + $rest->POST( $ContactEmail); - return new models\Call\ContactEmail( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactEmail::class); } /** @@ -50,7 +50,7 @@ class ContactEmail extends Service { $rest = $this->getAuthService( self::API_EMAIL . $ContactEmailId); $rest->DELETE(); - return (bool) $rest->getCurlResponse()['success']; + return $rest->getSuccess(); } /** @@ -59,9 +59,9 @@ class ContactEmail extends Service { */ public function update( models\Call\ContactEmail $ContactEmail){ $rest = $this->getAuthService( self::API_EMAIL . $ContactEmail->getId()); - $rest->PUT( $ContactEmail->toArray()); + $rest->PUT( $ContactEmail); - return new models\Call\ContactEmail( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactEmail::class); } } diff --git a/freebox/api/v3/services/Call/ContactEntry.php b/freebox/api/v3/services/Call/ContactEntry.php index 82f61fc..2ebec91 100644 --- a/freebox/api/v3/services/Call/ContactEntry.php +++ b/freebox/api/v3/services/Call/ContactEntry.php @@ -24,12 +24,7 @@ class ContactEntry extends Service { $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; + return $rest->getResultAsArray( models\Call\ContactEntry::class); } /** @@ -40,7 +35,7 @@ class ContactEntry extends Service { $rest = $this->getAuthService( self::API_CONTACT . $ContactEntryId); $rest->GET(); - return new models\Call\ContactEntry( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactEntry::class); } /** @@ -49,9 +44,9 @@ class ContactEntry extends Service { */ public function create( models\Call\ContactEntry $ContactEntry){ $rest = $this->getAuthService( self::API_CONTACT); - $rest->POST( $ContactEntry->toArray()); + $rest->POST( $ContactEntry); - return new models\Call\ContactEntry( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactEntry::class); } /** @@ -60,9 +55,9 @@ class ContactEntry extends Service { */ public function update( models\Call\ContactEntry $ContactEntry){ $rest = $this->getAuthService( self::API_CONTACT . $ContactEntry->getId()); - $rest->PUT( $ContactEntry->toArray()); + $rest->PUT( $ContactEntry); - return new models\Call\ContactEntry( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactEntry::class); } /** @@ -81,7 +76,7 @@ class ContactEntry extends Service { $rest = $this->getAuthService( self::API_CONTACT); $rest->DELETE( $ContactEntryId); - return $rest->getCurlResponse()['success']; + return $rest->getSuccess(); } /** @@ -93,12 +88,7 @@ class ContactEntry extends Service { $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; + return $rest->getResultAsArray( models\Call\ContactNumber::class); } /** @@ -110,12 +100,7 @@ class ContactEntry extends Service { $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; + return $rest->getResultAsArray( models\Call\ContactAddress::class); } /** @@ -127,12 +112,7 @@ class ContactEntry extends Service { $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; + return $rest->getResultAsArray( models\Call\ContactEmail::class); } /** @@ -144,12 +124,7 @@ class ContactEntry extends Service { $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; + return $rest->getResultAsArray( models\Call\ContactUrl::class); } } diff --git a/freebox/api/v3/services/Call/ContactNumber.php b/freebox/api/v3/services/Call/ContactNumber.php index 0f66349..29f1b5e 100644 --- a/freebox/api/v3/services/Call/ContactNumber.php +++ b/freebox/api/v3/services/Call/ContactNumber.php @@ -20,7 +20,7 @@ class ContactNumber extends Service { $rest = $this->getAuthService( self::API_NUMBER . $ContactNumberId); $rest->GET(); - return new models\Call\ContactNumber( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactNumber::class); } /** @@ -29,9 +29,9 @@ class ContactNumber extends Service { */ public function create( models\Call\ContactNumber $ContactNumber){ $rest = $this->getAuthService( self::API_NUMBER); - $rest->POST( $ContactNumber->toArray()); + $rest->POST( $ContactNumber); - return new models\Call\ContactNumber( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactNumber::class); } /** @@ -50,7 +50,7 @@ class ContactNumber extends Service { $rest = $this->getAuthService( self::API_NUMBER . $ContactNumberId); $rest->DELETE(); - return (bool) $rest->getCurlResponse()['success']; + return $rest->getSuccess(); } /** @@ -59,9 +59,9 @@ class ContactNumber extends Service { */ public function update( models\Call\ContactNumber $ContactNumber){ $rest = $this->getAuthService( self::API_NUMBER . $ContactNumber->getId()); - $rest->PUT( $ContactNumber->toArray()); + $rest->PUT( $ContactNumber); - return new models\Call\ContactNumber( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactNumber::class); } } diff --git a/freebox/api/v3/services/Call/ContactUrl.php b/freebox/api/v3/services/Call/ContactUrl.php index 995b4ac..8b47cd5 100644 --- a/freebox/api/v3/services/Call/ContactUrl.php +++ b/freebox/api/v3/services/Call/ContactUrl.php @@ -20,7 +20,7 @@ class ContactUrl extends Service { $rest = $this->getAuthService( self::API_URL . $ContactUrlId); $rest->GET(); - return new models\Call\ContactUrl( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactUrl::class); } /** @@ -29,9 +29,9 @@ class ContactUrl extends Service { */ public function create( models\Call\ContactUrl $ContactUrl){ $rest = $this->getAuthService( self::API_URL); - $rest->POST( $ContactUrl->toArray()); + $rest->POST( $ContactUrl); - return new models\Call\ContactUrl( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactUrl::class); } /** @@ -50,7 +50,7 @@ class ContactUrl extends Service { $rest = $this->getAuthService( self::API_URL . $ContactUrlId); $rest->DELETE(); - return (bool) $rest->getCurlResponse()['success']; + return $rest->getSuccess(); } /** @@ -59,9 +59,9 @@ class ContactUrl extends Service { */ public function update( models\Call\ContactUrl $ContactUrl){ $rest = $this->getAuthService( self::API_URL . $ContactUrl->getId()); - $rest->PUT( $ContactUrl->toArray()); + $rest->PUT( $ContactUrl); - return new models\Call\ContactUrl( $rest->getCurlResponse()['result']); + return $rest->getResult( models\Call\ContactUrl::class); } }