From 6e62b233ba64ed8b49c40778a2a2bf7ccd5edbeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pu=C5=9Blecki?= Date: Tue, 20 Sep 2016 13:41:51 +0200 Subject: [PATCH] Changes for update client object --- MangoPay/ApiClients.php | 28 +++--------- MangoPay/Client.php | 95 +++++++++++++++++++++++++++++++++++++-- MangoPay/PlatformType.php | 16 +++++++ demos/api/htmlHelper.php | 10 ++++- tests/cases/clients.php | 15 +++++++ 5 files changed, 137 insertions(+), 27 deletions(-) create mode 100644 MangoPay/PlatformType.php diff --git a/MangoPay/ApiClients.php b/MangoPay/ApiClients.php index 9e0dd9a7..496244d9 100644 --- a/MangoPay/ApiClients.php +++ b/MangoPay/ApiClients.php @@ -6,28 +6,6 @@ */ class ApiClients extends Libraries\ApiBase { - /** - * Get client data for Basic Access Authentication - * @param string $clientId Client identifier - * @param string $clientName Beautiful name for presentation - * @param string $clientEmail Client's email - * @return \MangoPay\Client Client object - */ - public function Create($clientId, $clientName, $clientEmail) - { - $urlMethod = $this->GetRequestUrl('authentication_base'); - $requestType = $this->GetRequestType('authentication_base'); - $requestData = array( - 'ClientId' => $clientId, - 'Name' => $clientName, - 'Email' => $clientEmail, - ); - - $rest = new Libraries\RestTool(false, $this->_root); - $response = $rest->Request($urlMethod, $requestType, $requestData); - return $this->CastResponseToEntity($response, '\MangoPay\Client'); - } - /** * Get client information * @@ -45,6 +23,12 @@ public function Get() */ public function Update($client) { + if (!is_null($client->HeadquartersAddress) + && is_a($client->HeadquartersAddress, "MangoPay\Address") + && $client->HeadquartersAddress->CanBeNull()) { + $client->HeadquartersAddress = null; + } + return $this->SaveObject('client_save', $client, '\MangoPay\Client'); } diff --git a/MangoPay/Client.php b/MangoPay/Client.php index 3d4cff6d..0779c2e2 100644 --- a/MangoPay/Client.php +++ b/MangoPay/Client.php @@ -19,14 +19,101 @@ class Client extends Libraries\EntityBase public $Name; /** - * Email of client + * The primary branding colour to use for your merchant * @var string */ - public $Email; + public $PrimaryThemeColour; + + + /** + * The primary branding colour to use for buttons for your merchant + * @var string + */ + public $PrimaryButtonColour; + + /** + * The URL of the logo of your client + * @var string + */ + public $Logo; + + /** + * A list of email addresses to use when contacting you for technical issues/communications + * @var array + */ + public $TechEmails; + + /** + * A list of email addresses to use when contacting you for admin/commercial issues/communications + * @var array + */ + public $AdminEmails; + + /** + * A list of email addresses to use when contacting you for fraud/compliance issues/communications + * @var array + */ + public $FraudEmails; + + /** + * A list of email addresses to use when contacting you for billing issues/communications + * @var string + */ + public $BillingEmails; /** - * Password for client + * A description of what your platform does * @var string */ - public $Passphrase; + public $PlatformDescription; + + /** + * The type of platform + * @var \MangoPay\PlatformType + */ + public $PlatformType; + + /** + * The URL for your website + * @var string + */ + public $PlatformURL; + + /** + * The address of the company’s headquarters + * @var \MangoPay\Address + */ + public $HeadquartersAddress; + + /** + * The tax (or VAT) number for your company + * @var string + */ + public $TaxNumber; + + /** + * Get array with mapping which property is object and what type of object + * @return array + */ + public function GetSubObjects() + { + $subObjects = parent::GetSubObjects(); + $subObjects['HeadquartersAddress'] = '\MangoPay\Address'; + + return $subObjects; + } + + /** + * Get array with read-only properties + * @return array + */ + public function GetReadOnlyProperties() + { + $properties = parent::GetReadOnlyProperties(); + array_push($properties, 'ClientId'); + array_push($properties, 'Name'); + array_push($properties, 'Logo'); + + return $properties; + } } diff --git a/MangoPay/PlatformType.php b/MangoPay/PlatformType.php new file mode 100644 index 00000000..7438181c --- /dev/null +++ b/MangoPay/PlatformType.php @@ -0,0 +1,16 @@ +'; @@ -283,8 +285,14 @@ public static function getEntity($entityName, $entityId = 0, $returnNullIfNoProp if (isset($_POST[$frmName]) && strlen($_POST[$frmName]) > 0) { // special fields for Owners property - if ($entityName == 'Wallet' && $name == 'Owners') + if ($entityName == 'Wallet' && $name == 'Owners' + || $entityName == 'Client' && $name == 'TechEmails' + || $entityName == 'Client' && $name == 'AdminEmails' + || $entityName == 'Client' && $name == 'FraudEmails' + || $entityName == 'Client' && $name == 'BillingEmails'){ + $entity->$name = explode(';', $_POST[$frmName]); + } // special cast to int for Birthday property in UserNatural // and UserLegal class elseif (($entityName == 'UserNatural' && $name == 'Birthday') diff --git a/tests/cases/clients.php b/tests/cases/clients.php index 4106cce1..14fe6001 100644 --- a/tests/cases/clients.php +++ b/tests/cases/clients.php @@ -17,6 +17,21 @@ function test_Clients_Save() { $clients = new \MangoPay\Client(); $clients->PrimaryButtonColour = "#afafae"; $clients->PrimaryThemeColour = "#afafae"; + $clients->PlatformDescription = "platform description"; + $clients->PlatformType = \MangoPay\PlatformType::Other; + $clients->PlatformURL = "http://sdk-unit-tests.com"; + $clients->HeadquartersAddress = new \MangoPay\Address(); + $clients->HeadquartersAddress->AddressLine1 = "AddressLine1"; + $clients->HeadquartersAddress->AddressLine2 = "AddressLine2"; + $clients->HeadquartersAddress->City = "City"; + $clients->HeadquartersAddress->Region = "Region"; + $clients->HeadquartersAddress->PostalCode = "11222"; + $clients->HeadquartersAddress->Country = "FR"; + $clients->TaxNumber = "12345"; + $clients->TechEmails = array("hugo@mangopay.com", "test@mangopay.com"); + $clients->AdminEmails = array("hugo@mangopay.com", "test@mangopay.com"); + $clients->FraudEmails = array("hugo@mangopay.com", "test@mangopay.com"); + $clients->BillingEmails = array("hugo@mangopay.com", "test@mangopay.com"); $saveClients = $this->_api->Clients->Update($clients);