From d0f2365080abdfc9db6d7caacd5a28c050f47f40 Mon Sep 17 00:00:00 2001 From: Maciej Tarnowski Date: Mon, 2 Mar 2020 13:59:58 +0100 Subject: [PATCH] SDK release 2.0.0 --- CHANGELOG.md | 12 ++ README.md | 85 +++++++---- UPGRADING.md | 22 +++ docs/lib/client.md | 57 +++---- docs/lib/client_debugging.md | 42 ++++-- docs/lib/create_resource.md | 10 +- docs/lib/delete_resource.md | 9 +- docs/lib/get_list_of_resources.md | 142 ++++++++++++++++++ docs/lib/get_resource_details.md | 22 ++- docs/lib/update_resource.md | 6 +- src/Environment/GetResponseEnterprise.php | 2 +- .../Accounts/Badge/GetBadge/GetBadge.php | 1 - .../Billing/GetBilling/GetBilling.php | 1 - .../GetBlacklists/GetBlacklists.php | 1 - .../GetBlacklistsSearchQuery.php | 1 - .../DeleteCallback/DeleteCallback.php | 1 - .../Callbacks/GetCallbacks/GetCallbacks.php | 1 - .../Accounts/GetAccounts/GetAccounts.php | 1 - .../Timezones/GetTimezones/GetTimezones.php | 1 - .../Accounts/UpdateAccount/UpdateAccount.php | 73 +++++++++ .../Addresses/DeleteAddress/DeleteAddress.php | 1 - .../Addresses/UpdateAddress/UpdateAddress.php | 4 +- .../DeleteAutoresponder.php | 1 - .../UpdateAutoresponder.php | 4 +- .../GetBlacklists/GetBlacklists.php | 1 - .../GetBlacklistsSearchQuery.php | 1 - .../GetContacts/GetContactsFields.php | 5 +- .../GetCampaigns/GetCampaignsSearchQuery.php | 1 - .../GetCampaignStatisticsBalance.php | 1 - .../GetCampaignStatisticsListSize.php | 1 - .../GetCampaignStatisticsLocations.php | 1 - .../GetCampaignStatisticsOrigins.php | 1 - .../GetCampaignStatisticsRemovals.php | 1 - .../GetCampaignStatisticsSubscriptions.php | 1 - .../GetCampaignStatisticsSummary.php | 1 - ...etCampaignStatisticsSummarySearchQuery.php | 1 - .../UpdateCampaign/UpdateCampaign.php | 4 +- .../GetClickTrack/GetClickTrack.php | 61 ++++++++ .../GetClickTrack/GetClickTrackFields.php | 22 +++ .../GetClickTracks/GetClickTracks.php | 92 ++++++++++++ .../GetClickTracks/GetClickTracksFields.php | 22 +++ .../GetClickTracksSearchQuery.php | 29 ++++ .../GetClickTracksSortParams.php | 17 +++ .../Contacts/DeleteContact/DeleteContact.php | 1 - .../Contacts/GetContact/GetContactFields.php | 5 +- .../GetContacts/GetContactsFields.php | 5 +- .../Contacts/UpdateContact/UpdateContact.php | 4 +- .../CreateCustomEvent/CreateCustomEvent.php | 73 +++++++++ .../DeleteCustomEvent/DeleteCustomEvent.php | 74 +++++++++ .../GetCustomEvent/GetCustomEvent.php | 61 ++++++++ .../GetCustomEvent/GetCustomEventFields.php | 21 +++ .../GetCustomEvents/GetCustomEvents.php | 92 ++++++++++++ .../GetCustomEvents/GetCustomEventsFields.php | 21 +++ .../GetCustomEventsSearchQuery.php | 49 ++++++ .../GetCustomEventsSortParams.php | 17 +++ .../TriggerCustomEvent/TriggerCustomEvent.php | 73 +++++++++ .../UpdateCustomEvent/UpdateCustomEvent.php | 82 ++++++++++ .../DeleteCustomField/DeleteCustomField.php | 1 - .../GetCustomFieldsSearchQuery.php | 1 - .../UpdateCustomField/UpdateCustomField.php | 4 +- .../Files/CreateFile/CreateFile.php | 73 +++++++++ .../Files/DeleteFile/DeleteFile.php | 74 +++++++++ .../FileLibrary/Files/GetFile/GetFile.php | 61 ++++++++ .../Files/GetFile/GetFileFields.php | 27 ++++ .../FileLibrary/Files/GetFiles/GetFiles.php | 92 ++++++++++++ .../Files/GetFiles/GetFilesFields.php | 27 ++++ .../Files/GetFiles/GetFilesSearchQuery.php | 102 +++++++++++++ .../Files/GetFiles/GetFilesSortParams.php | 19 +++ .../Folders/CreateFolder/CreateFolder.php | 73 +++++++++ .../Folders/GetFolders/GetFolders.php | 92 ++++++++++++ .../Folders/GetFolders/GetFoldersFields.php | 20 +++ .../GetFolders/GetFoldersSearchQuery.php | 28 ++++ .../GetFolders/GetFoldersSortParams.php | 19 +++ .../FileLibrary/Quota/GetQuota/GetQuota.php | 29 ++++ .../Variants/GetVariants/GetVariants.php | 1 - .../SetDefaultFromField.php | 1 - .../DeleteFromField/DeleteFromField.php | 1 - .../GetFromFieldsSearchQuery.php | 25 ++- .../Imports/GetImports/GetImports.php | 1 - .../Model/AutoresponderDayCondition.php | 6 +- .../Model/AutoresponderSendCustomSettings.php | 4 +- .../Model/AutoresponderSendDelaySettings.php | 4 +- .../AutoresponderSendImmediatelySettings.php | 2 - .../Model/AutoresponderSendSettings.php | 8 +- .../Model/AutoresponderSendSignupSettings.php | 2 - .../Model/AutoresponderTriggerSettings.php | 4 +- src/Operation/Model/CallbackActions.php | 24 +-- src/Operation/Model/CrmCondition.php | 2 - .../Model/CustomEventAttributeDetails.php | 45 ++++++ src/Operation/Model/CustomFieldCondition.php | 2 - src/Operation/Model/CustomFieldFormatEnum.php | 2 +- src/Operation/Model/CustomFieldTypeEnum.php | 2 +- .../ECommerceBrandPurchasedCondition.php | 2 - .../ECommerceNumberOfPurchasesCondition.php | 6 +- .../ECommerceProductPurchasedCondition.php | 2 - .../Model/ECommerceTotalSpentCondition.php | 2 - src/Operation/Model/EmailCondition.php | 2 - .../Model/EngagementScoreCondition.php | 50 ++++++ src/Operation/Model/FolderShort.php | 32 ++++ src/Operation/Model/GeolocationCondition.php | 2 - src/Operation/Model/GoalCondition.php | 6 +- .../Model/LastAutoresponderDateCondition.php | 2 - .../Model/LastClickDateCondition.php | 2 - .../Model/LastNewsletterDateCondition.php | 2 - src/Operation/Model/LastOpenDateCondition.php | 2 - src/Operation/Model/LinkClickedCondition.php | 2 - .../Model/LinkNotClickedCondition.php | 2 - src/Operation/Model/MessageEditorEnum.php | 8 +- src/Operation/Model/MessageFlagsArray.php | 41 +++++ .../Model/MessageNotSentCondition.php | 2 - src/Operation/Model/MessageSentCondition.php | 2 - src/Operation/Model/MessageTypeOperator.php | 43 ++++++ src/Operation/Model/NameCondition.php | 2 - src/Operation/Model/NewAutoresponder.php | 6 +- .../Model/NewCartSelectedProductVariant.php | 4 +- src/Operation/Model/NewCategory.php | 4 +- src/Operation/Model/NewContact.php | 17 +-- src/Operation/Model/NewCustomEvent.php | 45 ++++++ src/Operation/Model/NewFile.php | 50 ++++++ src/Operation/Model/NewFolder.php | 32 ++++ src/Operation/Model/NewNewsletter.php | 26 ++-- src/Operation/Model/NewProductCategory.php | 4 +- src/Operation/Model/NewProductVariant.php | 8 +- .../Model/NewProductVariantImage.php | 4 +- src/Operation/Model/NewRssNewsletter.php | 26 ++-- .../Model/NewSelectedProductVariant.php | 4 +- src/Operation/Model/NotOpenedCondition.php | 2 - src/Operation/Model/OpenedCondition.php | 2 - .../Model/RelationalNumericOperatorEnum.php | 47 ++++++ .../Model/RssNewsletterSendAsapSettings.php | 2 - .../Model/RssNewsletterSendDailySettings.php | 6 +- .../RssNewsletterSendMonthlySettings.php | 10 +- .../Model/RssNewsletterSendSettings.php | 4 +- .../Model/RssNewsletterSendWeeklySettings.php | 6 +- src/Operation/Model/ScoringCondition.php | 6 +- .../Model/SectionAllTimeSubscriptionDate.php | 2 - .../Model/SectionCustomSubscriptionDate.php | 2 - .../SectionLast2MonthsSubscriptionDate.php | 2 - .../SectionLast30DaysSubscriptionDate.php | 2 - .../SectionLast7DaysSubscriptionDate.php | 2 - .../SectionLastMonthSubscriptionDate.php | 2 - .../Model/SectionLastWeekSubscriptionDate.php | 2 - .../SectionThisMonthSubscriptionDate.php | 2 - .../Model/SectionThisWeekSubscriptionDate.php | 2 - .../Model/SectionTodaySubscriptionDate.php | 2 - .../SectionYesterdaySubscriptionDate.php | 2 - src/Operation/Model/SpecificDateEnum.php | 51 +++++++ src/Operation/Model/StatusEnum.php | 2 +- src/Operation/Model/StringBooleanEnum.php | 2 +- .../Model/SubscriptionDateCondition.php | 2 - .../Model/SubscriptionMethodCondition.php | 2 - src/Operation/Model/TagCondition.php | 2 - src/Operation/Model/TriggerCustomEvent.php | 51 +++++++ .../Model/TriggerCustomEventAttribute.php | 38 +++++ src/Operation/Model/UpdateAccount.php | 38 ++--- src/Operation/Model/UpdateAutoresponder.php | 6 +- src/Operation/Model/UpdateCategory.php | 4 +- src/Operation/Model/UpdateContact.php | 27 +--- src/Operation/Model/UpdateCustomEvent.php | 45 ++++++ src/Operation/Model/UpdateProductVariant.php | 8 +- src/Operation/Model/UpdateRssNewsletter.php | 26 ++-- .../Model/UpsertSingleProductCategory.php | 4 +- src/Operation/Model/WebinarCondition.php | 2 - .../GetActivities/GetActivities.php | 93 ++++++++++++ .../GetActivitiesSearchQuery.php | 60 ++++++++ .../GetActivities/GetActivitiesSortParams.php | 17 +++ .../CancelNewsletter/CancelNewsletter.php | 1 - .../DeleteNewsletter/DeleteNewsletter.php | 1 - .../GetNewsletter/GetNewsletterFields.php | 2 +- .../GetNewsletters/GetNewslettersFields.php | 2 +- .../SendNewsletterDraft.php | 4 +- .../DeletePredefinedField.php | 1 - .../GetPredefinedFieldsSearchQuery.php | 1 - .../UpdatePredefinedField.php | 4 +- .../DeleteRssNewsletter.php | 1 - .../GetRssNewsletterFields.php | 2 +- .../GetRssNewslettersFields.php | 2 +- .../UpdateRssNewsletter.php | 4 +- .../DeleteSearchContact.php | 1 - .../Shops/Carts/DeleteCart/DeleteCart.php | 1 - .../Shops/Carts/UpdateCart/UpdateCart.php | 4 +- .../DeleteCategory/DeleteCategory.php | 1 - .../GetCategoriesSearchQuery.php | 1 - .../UpdateCategory/UpdateCategory.php | 4 +- src/Operation/Shops/DeleteShop/DeleteShop.php | 1 - .../Shops/GetShops/GetShopsSearchQuery.php | 1 - .../DeleteMetaField/DeleteMetaField.php | 1 - .../UpdateMetaField/UpdateMetaField.php | 4 +- .../Shops/Orders/DeleteOrder/DeleteOrder.php | 1 - .../Orders/GetOrders/GetOrdersSearchQuery.php | 1 - .../Shops/Orders/UpdateOrder/UpdateOrder.php | 4 +- .../Products/DeleteProduct/DeleteProduct.php | 1 - .../Products/UpdateProduct/UpdateProduct.php | 4 +- .../Variants/DeleteVariant/DeleteVariant.php | 1 - .../Shops/Taxes/DeleteTax/DeleteTax.php | 1 - .../Shops/Taxes/UpdateTax/UpdateTax.php | 4 +- src/Operation/Shops/UpdateShop/UpdateShop.php | 4 +- .../GetSplittest/GetSplittestFields.php | 2 +- .../GetSplittests/GetSplittestsFields.php | 2 +- .../Body/GetBody/GetBody.php | 1 - .../Subject/GetSubject/GetSubject.php | 1 - .../DeleteSuppression/DeleteSuppression.php | 1 - .../UpdateSuppression/UpdateSuppression.php | 4 +- src/Operation/Tags/DeleteTag/DeleteTag.php | 1 - src/Operation/Tags/UpdateTag/UpdateTag.php | 4 +- .../GetTemplateCategoriesSearchQuery.php | 1 - .../Templates/GetTemplates/GetTemplates.php | 1 - .../Tracking/GetTracking/GetTracking.php | 29 ++++ .../CreateTransactionalEmail.php | 4 +- .../GetTransactionalEmail.php | 61 ++++++++ .../GetTransactionalEmailFields.php | 23 +++ .../GetTransactionalEmails.php | 78 ++++++++++ .../GetTransactionalEmailsFields.php | 22 +++ .../GetTransactionalEmailsSearchQuery.php | 62 ++++++++ .../GetStatistics/GetStatistics.php | 60 ++++++++ .../GetStatistics/GetStatisticsFields.php | 21 +++ .../GetStatisticsSearchQuery.php | 83 ++++++++++ .../Webinars/GetWebinar/GetWebinarFields.php | 1 + .../GetWebinars/GetWebinarsFields.php | 1 + .../GetWebinars/GetWebinarsSearchQuery.php | 46 +++++- .../UpdateWorkflow/UpdateWorkflow.php | 4 +- src/Version.php | 2 +- 222 files changed, 3381 insertions(+), 449 deletions(-) create mode 100644 UPGRADING.md create mode 100644 docs/lib/get_list_of_resources.md create mode 100644 src/Operation/Accounts/UpdateAccount/UpdateAccount.php create mode 100644 src/Operation/ClickTracks/GetClickTrack/GetClickTrack.php create mode 100644 src/Operation/ClickTracks/GetClickTrack/GetClickTrackFields.php create mode 100644 src/Operation/ClickTracks/GetClickTracks/GetClickTracks.php create mode 100644 src/Operation/ClickTracks/GetClickTracks/GetClickTracksFields.php create mode 100644 src/Operation/ClickTracks/GetClickTracks/GetClickTracksSearchQuery.php create mode 100644 src/Operation/ClickTracks/GetClickTracks/GetClickTracksSortParams.php create mode 100644 src/Operation/CustomEvents/CreateCustomEvent/CreateCustomEvent.php create mode 100644 src/Operation/CustomEvents/DeleteCustomEvent/DeleteCustomEvent.php create mode 100644 src/Operation/CustomEvents/GetCustomEvent/GetCustomEvent.php create mode 100644 src/Operation/CustomEvents/GetCustomEvent/GetCustomEventFields.php create mode 100644 src/Operation/CustomEvents/GetCustomEvents/GetCustomEvents.php create mode 100644 src/Operation/CustomEvents/GetCustomEvents/GetCustomEventsFields.php create mode 100644 src/Operation/CustomEvents/GetCustomEvents/GetCustomEventsSearchQuery.php create mode 100644 src/Operation/CustomEvents/GetCustomEvents/GetCustomEventsSortParams.php create mode 100644 src/Operation/CustomEvents/Trigger/TriggerCustomEvent/TriggerCustomEvent.php create mode 100644 src/Operation/CustomEvents/UpdateCustomEvent/UpdateCustomEvent.php create mode 100644 src/Operation/FileLibrary/Files/CreateFile/CreateFile.php create mode 100644 src/Operation/FileLibrary/Files/DeleteFile/DeleteFile.php create mode 100644 src/Operation/FileLibrary/Files/GetFile/GetFile.php create mode 100644 src/Operation/FileLibrary/Files/GetFile/GetFileFields.php create mode 100644 src/Operation/FileLibrary/Files/GetFiles/GetFiles.php create mode 100644 src/Operation/FileLibrary/Files/GetFiles/GetFilesFields.php create mode 100644 src/Operation/FileLibrary/Files/GetFiles/GetFilesSearchQuery.php create mode 100644 src/Operation/FileLibrary/Files/GetFiles/GetFilesSortParams.php create mode 100644 src/Operation/FileLibrary/Folders/CreateFolder/CreateFolder.php create mode 100644 src/Operation/FileLibrary/Folders/GetFolders/GetFolders.php create mode 100644 src/Operation/FileLibrary/Folders/GetFolders/GetFoldersFields.php create mode 100644 src/Operation/FileLibrary/Folders/GetFolders/GetFoldersSearchQuery.php create mode 100644 src/Operation/FileLibrary/Folders/GetFolders/GetFoldersSortParams.php create mode 100644 src/Operation/FileLibrary/Quota/GetQuota/GetQuota.php create mode 100644 src/Operation/Model/CustomEventAttributeDetails.php create mode 100644 src/Operation/Model/EngagementScoreCondition.php create mode 100644 src/Operation/Model/FolderShort.php create mode 100644 src/Operation/Model/MessageFlagsArray.php create mode 100644 src/Operation/Model/MessageTypeOperator.php create mode 100644 src/Operation/Model/NewCustomEvent.php create mode 100644 src/Operation/Model/NewFile.php create mode 100644 src/Operation/Model/NewFolder.php create mode 100644 src/Operation/Model/RelationalNumericOperatorEnum.php create mode 100644 src/Operation/Model/SpecificDateEnum.php create mode 100644 src/Operation/Model/TriggerCustomEvent.php create mode 100644 src/Operation/Model/TriggerCustomEventAttribute.php create mode 100644 src/Operation/Model/UpdateCustomEvent.php create mode 100644 src/Operation/Newsletters/Activities/GetActivities/GetActivities.php create mode 100644 src/Operation/Newsletters/Activities/GetActivities/GetActivitiesSearchQuery.php create mode 100644 src/Operation/Newsletters/Activities/GetActivities/GetActivitiesSortParams.php create mode 100644 src/Operation/Tracking/GetTracking/GetTracking.php create mode 100644 src/Operation/TransactionalEmails/GetTransactionalEmail/GetTransactionalEmail.php create mode 100644 src/Operation/TransactionalEmails/GetTransactionalEmail/GetTransactionalEmailFields.php create mode 100644 src/Operation/TransactionalEmails/GetTransactionalEmails/GetTransactionalEmails.php create mode 100644 src/Operation/TransactionalEmails/GetTransactionalEmails/GetTransactionalEmailsFields.php create mode 100644 src/Operation/TransactionalEmails/GetTransactionalEmails/GetTransactionalEmailsSearchQuery.php create mode 100644 src/Operation/TransactionalEmails/Statistics/GetStatistics/GetStatistics.php create mode 100644 src/Operation/TransactionalEmails/Statistics/GetStatistics/GetStatisticsFields.php create mode 100644 src/Operation/TransactionalEmails/Statistics/GetStatistics/GetStatisticsSearchQuery.php diff --git a/CHANGELOG.md b/CHANGELOG.md index d182a69..adb9d2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## 2.0.0 - 2020-03-02 + +* Add operations for: + * Click Tracks + * File Library + * Newsletter Activities + * Transactional Emails +* Remove unused classes and methods +* Code clean-up + +Read more in [Upgrade Guide](UPGRADING.md) + ## 1.2.1 - 2019-06-07 * Improve documentation diff --git a/README.md b/README.md index 7e65a81..4f71590 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ # GetResponse APIv3 PHP SDK +This document covers the basics of using SDK for PHP. For detailed documentation, please refer to the resources in [docs](docs) directory: -This document covers the basics of using SDK for PHP. For detailed documentation, please refer to the resources in ./lib directory: - -* [Client](./docs/lib/client.md) - methods and factories to create API Client -* [Client Debugging](./docs/lib/client_debugging.md) - how to get detailed information from API Client for development purposes -* [Collect list](./docs/lib/collect_list_of_resources.md) - getting lists of resources, with defining queries and sort fields -* [Resource details](./docs/lib/get_resource_details.md) - getting single resource with details -* [Create resources](./docs/lib/create_resource.md) - defining data models and creating resources -* [Delete resources](./docs/lib/delete_resource.md) - deleting resources -* [Updating resources](./docs/lib/update_resource.md) - updating resources - +* [Client](docs/lib/client.md) - basic API client usage +* [Client Debugging](docs/lib/client_debugging.md) - how to log API communication, and debug the integration +* [Getting lists of resources](docs/lib/get_list_of_resources.md) +* [Getting resource details](docs/lib/get_resource_details.md) +* [Create resources](docs/lib/create_resource.md) - building data models and creating resources +* [Deleting resources](docs/lib/delete_resource.md) +* [Updating resources](docs/lib/update_resource.md) +* [Upgrade guide](UPGRADING.md) - upgrading from 1.x version to 2.x +Read more about the API in [GetResponse API Docs](https://apidocs.getresponse.com/v3) and [GetResponse API Reference](https://apireference.getresponse.com/). ## Requirements @@ -23,36 +23,36 @@ This document covers the basics of using SDK for PHP. For detailed documentation ## SDK installation -### By git - -We recommend the `composer` installation. However, you can get SDK PHP by cloning the git project: +### Using Composer ``` - -git clone https://github.com/GetResponse/sdk-php.git - +composer require getresponse/sdk-php ``` -### Installing Composer +See [https://getcomposer.org](https://getcomposer.org) for details. -Copy composer.json from the `examples` directory into your project directory and run the `composer install` command in this directory. +### Using git + +We recommend the `composer` installation. However, you can get SDK PHP by cloning the git project: -You can also integrate with an existing one by running ``` -composer require getresponse/sdk-php + +git clone https://github.com/GetResponse/sdk-php.git + ``` -See [https://getcomposer.org](https://getcomposer.org) for in-depth tutorials. +The releases are available on GitHub: [https://github.com/GetResponse/sdk-php/releases](https://github.com/GetResponse/sdk-php/releases) ## Creating client To create a GetResponse client object, use: ```php +call($campaignsOperation); @@ -97,11 +103,11 @@ $response = $client->call($campaignsOperation); As a result, you will get a response object. -You can send multiple operations with one request. This will speed up operations with parallel processing. Please note that throttling limits will apply ([refer to API limit and throttling documentation](https://apidocs.getresponse.com/v3/limits)). +You can send multiple operations with one request. This will speed up operations with parallel processing. Please note that throttling limits will apply ([read more in API limits and throttling documentation](https://apidocs.getresponse.com/v3/limits)). ```php +callMany($operationsArray); @@ -114,8 +120,9 @@ As a result, you will get a collection of responses. The responses are in the sa To get a response, call: ```php +call($operation); +$response = $client->call($campaignsOperation); ``` @@ -124,6 +131,7 @@ $response = $client->call($operation); To determine if a response was successful, use: ```php +isSuccess(); @@ -132,7 +140,10 @@ $response->isSuccess(); To get HTTP status of response, use: ```php +getResponse()->getStatusCode(); + ``` ### Response data @@ -142,32 +153,40 @@ The response is compatible with [PSR-7](https://www.php-fig.org/psr/psr-7/). Examples: -To get the data from response (in array format): +To get the data from response (as array): ```php +getData(); + ``` To get unprocessed data, from a response (in a serialized JSON format): ```php +getResponse()->getBody()->getContents(); + ``` To get the response size: ```php +getResponse()->getBody()->getSize(); + ``` To get the pagination data: ```php +isPaginated(); $response->getPaginationValues(); -``` - ---- -Refer to [GetResponse API documentation](https://apidocs.getresponse.com/v3). +``` diff --git a/UPGRADING.md b/UPGRADING.md new file mode 100644 index 0000000..537e2fa --- /dev/null +++ b/UPGRADING.md @@ -0,0 +1,22 @@ +# Upgrade Guide + +## Upgrading from 1.x to 2.x + +Most changes made in 2.x release are effects of fixes and clarifications made to the API specification, the rest is related to some minor refactorings and optimisations. + +What to look for: + * removed classes, for example: + * classes that were never used in data models or operations, + * classes that made no sense, like empty `SearchQueries`, + * classes related to CRM functionality, + * removed methods, for example: + * it's not possible to change the `ipAddress` of an existing contact, but there was a method for it in `\Getresponse\Sdk\Operation\Model\UpdateContact` class, + * it's not possible to set contact's `note` when creating it, but there was a method for it in `\Getresponse\Sdk\Operation\Model\NewContact` class, + * some Operations had methods to set Pagination, Search or Sort params, but don't support them, + * added classes - SDK now supports more resources, for example: + * FileLibrary + * ClickTracks + * TransactionalEmails management and statistics + * Newsletter Activities + +There are no changes to the client, request or response handling. diff --git a/docs/lib/client.md b/docs/lib/client.md index 14d4c1d..1576893 100644 --- a/docs/lib/client.md +++ b/docs/lib/client.md @@ -1,53 +1,56 @@ # Creating API Client and handling requests. -## Before you begin -This is a general method. Please consider using the dedicated factory functions as described in [Initialization by factory](client.md#initialization-by-factory). - - ## Initialization +_This is a direct method. Please consider using the dedicated factory functions as described in [Initialization by factory](client.md#initialization-by-factory)._ + Example basic initialization with required arguments: -``` +```php +setLogger` function, the calls will be logged. The `Logger` class is our wrapper - you should configure it with the PSR-3 logger class: ```php +setLogger(new Logger(new DebugLogger($dataCollector))); ``` @@ -36,14 +44,18 @@ To retrieve the debug information, you have to call `dump` or `dumpToFile` funct ## Example of debug initialization and dumping ```php +call(...); -$debugger->dump(); //to output +$debugger->dump(); // to output $debugger->dumpToFile('/tmp/my_debug_file.txt'); ``` @@ -56,17 +68,27 @@ Once you start the debugger, you overwrite the Logger configuration by `DebugLog ## Example debugging ```php +setFields( + new GetContactsFields( + 'name', + 'email', + 'origin' + ) +); + $client = GetresponseClientFactory::createWithApiKey('my_api_key'); $debugger = GetresponseClientFactory::createDebugger($client); $response = $client->call($getContactsOperation); -// display dump +// echo the dump $debugger->dump(); // save to file @@ -77,9 +99,9 @@ Log content: ``` --------- CALLS --------- - 1. GET: /v3/contacts?sort[email]=desc&fields=email,name,origin + 1. GET: /v3/contacts?fields=email,name,origin URL: https://api.getresponse.com - Authorization: api-key my_example_api_key + Authorization: api-key my_api_key Time: 11:56:29 Protocol Version: 1.1 Request size: 313 @@ -87,8 +109,8 @@ Log content: Connect time: 134 ms Request Headers: host: api.getresponse.com - user-agent: GetResponse-SDK/0.1.0 GetResponse-API/3.0 GetResponse-Client/0.1.0 CurlRequestHandler (cURL 7.54.0; PHP 7.1.14; Darwin; cli) - x-auth-token: api-key my_example_api_key + user-agent: GetResponse-SDK/2.0.0 GetResponse-API/3.0 GetResponse-Client/1.1.0 CurlRequestHandler (cURL 7.54.0; PHP 7.1.14; Darwin; cli) + x-auth-token: api-key my_api_key Request Body: [EMPTY] Total time: 580 ms @@ -137,7 +159,7 @@ Log content: You can define your `Formatter` and `DebugDumper` classes to send debugs to systems like Elasticsearch or Sentry. -* the custom `Formatter` should implement `Formatter interface` with the function: `format(Array $data)` - you can convert the collected data to any format you need. We supply `LineFormatter`, which gives you the plain text with intends in the results. +* the custom `Formatter` should implement `Formatter interface` with the function: `format(array $data)` - you can convert the collected data to any format you need. We supply `LineFormatter`, which gives you the plain text with intends in the results. * the custom `Dumper` should implement the `DebugDumper interface` with the function `dump($debug)` - you can implement your own class which sends `$debug` to any output you wish. We supply `DisplayDebugDumper` and `FileDebugDumper`. **Please note that the dumped content may contain sensitive data.** diff --git a/docs/lib/create_resource.md b/docs/lib/create_resource.md index 0c13ba5..4342d2a 100644 --- a/docs/lib/create_resource.md +++ b/docs/lib/create_resource.md @@ -1,8 +1,10 @@ # Creating resources -Example code +Example code for adding a contact: ```php +isSuccess()) { } ``` -Output: +Output: - ```plain -OK +```plain +OK ``` ___ diff --git a/docs/lib/delete_resource.md b/docs/lib/delete_resource.md index e50126f..9de746d 100644 --- a/docs/lib/delete_resource.md +++ b/docs/lib/delete_resource.md @@ -1,14 +1,17 @@ # Deleting resources -Example code +Example code for deleting a contact: ```php +setIpAddress('127.0.0.1'); $deleteContactOperation->setUrlParameterQuery($deleteContactParams); $client = GetresponseClientFactory::createWithApiKey('my_api_key'); -$response = $client->call($deleteContactParams); +$response = $client->call($deleteContactOperation); if ($response->isSuccess()) { print 'OK'; diff --git a/docs/lib/get_list_of_resources.md b/docs/lib/get_list_of_resources.md new file mode 100644 index 0000000..9c53f5b --- /dev/null +++ b/docs/lib/get_list_of_resources.md @@ -0,0 +1,142 @@ +# Getting lists of resources + +## Get data + +Example code for getting the list of contacts: + +```php +call($getContactsOperation); + +// getData returns decoded data as an array +$data = $response->getData(); + +echo json_encode($data, JSON_PRETTY_PRINT); +``` + +Output: + +```json + [ + { + "contactId": "aad", + "href": "https://getresponse.com/v3/contacts/aad", + "name": "John Smith", + "email": "john.smith@example.com", + "note": null, + "origin": "api", + "dayOfCycle": null, + "changedOn": "2018-02-22T13:33:42+0000", + "timeZone": "Europe/Warsaw", + "ipAddress": null, + "activities": "https://getresponse.com/v3/contacts/aad/activities", + "campaign": { + "campaignId": "cdd", + "href": "https://getresponse.com/v3/campaigns/cdd", + "name": "campaigns_name" + }, + "createdOn": "2018-02-22T13:33:00+0000", + "scoring": 100 + } + ] +``` + +## Pagination + +You can set the pagination parameters: + +```php +setPagination(new Pagination($initialPage, $perPage)); + +``` + +To get the pagination info from a response: + +```php +isPaginated()) { + $paginationValues = $response->getPaginationValues(); + + var_dump($paginationValues->getTotalPages()); + var_dump($paginationValues->getTotalCount()); + var_dump($paginationValues->getPage()); +} + +``` + + +## Filter results + +You can choose a list of fields you will get in the API response. Use the `setFields` method of operation: + +```php +setFields( + new GetContactsFields( + 'email', + 'campaign', + 'name', + 'ipAddress' + ) +); + +``` + +## Search + +To search a resource by any available field, classes with all the allowed search fields are prepared. + + +```php +whereEmail('john.smith@example.com') + ->whereOriginIsApi(); + +$getContactsOperation->setQuery($searchQuery); +``` + +This code evaluates to the URL: + + /v3/contacts?query[email]=john.smith@example.com&query[origin]=api + +## List sorting + +```php +sortDescBy('createdOn'); + +$getContactsOperation->setSort($sortParams); +``` + +This code evaluates to the URL: + + /v3/contacts?sort[createdOn]=desc + +___ + +[Back](../../README.md) diff --git a/docs/lib/get_resource_details.md b/docs/lib/get_resource_details.md index 792eb36..8bebf34 100644 --- a/docs/lib/get_resource_details.md +++ b/docs/lib/get_resource_details.md @@ -1,13 +1,16 @@ # Getting single resource -Example code +Example code for getting a single contact details by ID ```php +call($getContactDetailsOperation); $data = $response->getData(); @@ -71,15 +74,20 @@ Output: You can choose a list of fields to get in the API response. Use the `setFields` method of operation: ```php +setFields( - 'description', - 'campaignId', - 'name' +$getContactDetailsOperation->setFields( + new GetContactFields( + 'email', + 'campaign', + 'name' + ) ); ``` ___ -[Back](../../README.md) \ No newline at end of file +[Back](../../README.md) diff --git a/docs/lib/update_resource.md b/docs/lib/update_resource.md index b711d1f..f9e48bc 100644 --- a/docs/lib/update_resource.md +++ b/docs/lib/update_resource.md @@ -1,14 +1,15 @@ # Updating resources -Example code +Example code for updating a name of a contact: ```php +setName('New name'); $updateContactOperation = new UpdateContact($updateContact, 'aad'); @@ -17,6 +18,7 @@ $response = $client->call($updateContactOperation); print $response->getData(); ``` + Output: ```json diff --git a/src/Environment/GetResponseEnterprise.php b/src/Environment/GetResponseEnterprise.php index 078e98b..fd7bd8e 100644 --- a/src/Environment/GetResponseEnterprise.php +++ b/src/Environment/GetResponseEnterprise.php @@ -43,7 +43,7 @@ public function processRequest(RequestInterface $request) */ private function validateDomain($domain) { - if (!preg_match('/^(?!www\\.)(?:(?:[a-zA-Z0-9]|(?<=[a-zA-Z0-9])\\-+(?=[a-zA-Z0-9])){1,63}\\.)+[a-zA-Z]{2,8}$/i', $domain)) { + if (!preg_match('/^(?!www\\.)(?:(?:[a-zA-Z0-9]|(?<=[a-zA-Z0-9])-+(?=[a-zA-Z0-9])){1,63}\\.)+[a-zA-Z]{2,8}$/i', $domain)) { throw new InvalidDomainException('The provided GetResponse Enterprise domain is invalid'); } } diff --git a/src/Operation/Accounts/Badge/GetBadge/GetBadge.php b/src/Operation/Accounts/Badge/GetBadge/GetBadge.php index 14b64cb..187f4ba 100644 --- a/src/Operation/Accounts/Badge/GetBadge/GetBadge.php +++ b/src/Operation/Accounts/Badge/GetBadge/GetBadge.php @@ -1,7 +1,6 @@ data = $data; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return self::METHOD_URL; + } + + + /** + * @return string + */ + public function getUrl() + { + return $this->buildUrlFromTemplate(); + } + + + /** + * @return string + */ + public function getMethod() + { + return Operation::POST; + } + + + /** + * @return string + * @throws InvalidCommandDataException + */ + public function getBody() + { + return $this->encode($this->data->jsonSerialize()); + } + + + /** + * @return int + */ + public function getSuccessCode() + { + return 200; + } +} diff --git a/src/Operation/Addresses/DeleteAddress/DeleteAddress.php b/src/Operation/Addresses/DeleteAddress/DeleteAddress.php index 27881c7..44c9fb7 100644 --- a/src/Operation/Addresses/DeleteAddress/DeleteAddress.php +++ b/src/Operation/Addresses/DeleteAddress/DeleteAddress.php @@ -1,7 +1,6 @@ clickTrackId = $clickTrackId; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return str_ireplace( + ['{clickTrackId}'], + [$this->clickTrackId], + self::METHOD_URL + ); + } + + + /** + * @param GetClickTrackFields $fields + * @return $this + */ + public function setFields(GetClickTrackFields $fields) + { + $this->fields = $fields; + return $this; + } + + + /** + * @return string + */ + public function getUrl() + { + $extra = $this->getFieldsParameterArray($this->fields); + return $this->buildUrlFromTemplate() . $this->buildQueryString(null, null, $extra); + } +} diff --git a/src/Operation/ClickTracks/GetClickTrack/GetClickTrackFields.php b/src/Operation/ClickTracks/GetClickTrack/GetClickTrackFields.php new file mode 100644 index 0000000..718fe63 --- /dev/null +++ b/src/Operation/ClickTracks/GetClickTrack/GetClickTrackFields.php @@ -0,0 +1,22 @@ +query = $query; + return $this; + } + + + /** + * @param GetClickTracksSortParams $sort + * @return $this + */ + public function setSort(GetClickTracksSortParams $sort) + { + $this->sort = $sort; + return $this; + } + + + /** + * @param Pagination $pagination + * @return $this + */ + public function setPagination(Pagination $pagination) + { + $this->pagination = $pagination; + return $this; + } + + + /** + * @param GetClickTracksFields $fields + * @return $this + */ + public function setFields(GetClickTracksFields $fields) + { + $this->fields = $fields; + return $this; + } + + + /** + * @return string + */ + public function getUrl() + { + $extra = array_merge( + $this->getPaginationParametersArray($this->pagination), + $this->getFieldsParameterArray($this->fields) + ); + + return $this->buildUrlFromTemplate() . $this->buildQueryString($this->query, $this->sort, $extra); + } +} diff --git a/src/Operation/ClickTracks/GetClickTracks/GetClickTracksFields.php b/src/Operation/ClickTracks/GetClickTracks/GetClickTracksFields.php new file mode 100644 index 0000000..52e2f0c --- /dev/null +++ b/src/Operation/ClickTracks/GetClickTracks/GetClickTracksFields.php @@ -0,0 +1,22 @@ +set('createdOn', $createdOn->toArray()); + } +} diff --git a/src/Operation/ClickTracks/GetClickTracks/GetClickTracksSortParams.php b/src/Operation/ClickTracks/GetClickTracks/GetClickTracksSortParams.php new file mode 100644 index 0000000..c1bb9b0 --- /dev/null +++ b/src/Operation/ClickTracks/GetClickTracks/GetClickTracksSortParams.php @@ -0,0 +1,17 @@ +data = $data; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return self::METHOD_URL; + } + + + /** + * @return string + */ + public function getUrl() + { + return $this->buildUrlFromTemplate(); + } + + + /** + * @return string + */ + public function getMethod() + { + return Operation::POST; + } + + + /** + * @return string + * @throws InvalidCommandDataException + */ + public function getBody() + { + return $this->encode($this->data->jsonSerialize()); + } + + + /** + * @return int + */ + public function getSuccessCode() + { + return 201; + } +} diff --git a/src/Operation/CustomEvents/DeleteCustomEvent/DeleteCustomEvent.php b/src/Operation/CustomEvents/DeleteCustomEvent/DeleteCustomEvent.php new file mode 100644 index 0000000..babe46d --- /dev/null +++ b/src/Operation/CustomEvents/DeleteCustomEvent/DeleteCustomEvent.php @@ -0,0 +1,74 @@ +customEventId = $customEventId; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return str_ireplace( + ['{customEventId}'], + [$this->customEventId], + self::METHOD_URL + ); + } + + + /** + * @return string + */ + public function getUrl() + { + return $this->buildUrlFromTemplate(); + } + + + /** + * @return string + */ + public function getMethod() + { + return Operation::DELETE; + } + + + /** + * @return string + */ + public function getBody() + { + return ''; + } + + + /** + * @return int + */ + public function getSuccessCode() + { + return 204; + } +} diff --git a/src/Operation/CustomEvents/GetCustomEvent/GetCustomEvent.php b/src/Operation/CustomEvents/GetCustomEvent/GetCustomEvent.php new file mode 100644 index 0000000..865f606 --- /dev/null +++ b/src/Operation/CustomEvents/GetCustomEvent/GetCustomEvent.php @@ -0,0 +1,61 @@ +customEventId = $customEventId; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return str_ireplace( + ['{customEventId}'], + [$this->customEventId], + self::METHOD_URL + ); + } + + + /** + * @param GetCustomEventFields $fields + * @return $this + */ + public function setFields(GetCustomEventFields $fields) + { + $this->fields = $fields; + return $this; + } + + + /** + * @return string + */ + public function getUrl() + { + $extra = $this->getFieldsParameterArray($this->fields); + return $this->buildUrlFromTemplate() . $this->buildQueryString(null, null, $extra); + } +} diff --git a/src/Operation/CustomEvents/GetCustomEvent/GetCustomEventFields.php b/src/Operation/CustomEvents/GetCustomEvent/GetCustomEventFields.php new file mode 100644 index 0000000..dcf47f9 --- /dev/null +++ b/src/Operation/CustomEvents/GetCustomEvent/GetCustomEventFields.php @@ -0,0 +1,21 @@ +query = $query; + return $this; + } + + + /** + * @param GetCustomEventsSortParams $sort + * @return $this + */ + public function setSort(GetCustomEventsSortParams $sort) + { + $this->sort = $sort; + return $this; + } + + + /** + * @param Pagination $pagination + * @return $this + */ + public function setPagination(Pagination $pagination) + { + $this->pagination = $pagination; + return $this; + } + + + /** + * @param GetCustomEventsFields $fields + * @return $this + */ + public function setFields(GetCustomEventsFields $fields) + { + $this->fields = $fields; + return $this; + } + + + /** + * @return string + */ + public function getUrl() + { + $extra = array_merge( + $this->getPaginationParametersArray($this->pagination), + $this->getFieldsParameterArray($this->fields) + ); + + return $this->buildUrlFromTemplate() . $this->buildQueryString($this->query, $this->sort, $extra); + } +} diff --git a/src/Operation/CustomEvents/GetCustomEvents/GetCustomEventsFields.php b/src/Operation/CustomEvents/GetCustomEvents/GetCustomEventsFields.php new file mode 100644 index 0000000..97ecaa7 --- /dev/null +++ b/src/Operation/CustomEvents/GetCustomEvents/GetCustomEventsFields.php @@ -0,0 +1,21 @@ +set('name', $name); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereHasAttributesIsTrue() + { + return $this->set('hasAttributes', 'true'); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereHasAttributesIsFalse() + { + return $this->set('hasAttributes', 'false'); + } +} diff --git a/src/Operation/CustomEvents/GetCustomEvents/GetCustomEventsSortParams.php b/src/Operation/CustomEvents/GetCustomEvents/GetCustomEventsSortParams.php new file mode 100644 index 0000000..a6bf774 --- /dev/null +++ b/src/Operation/CustomEvents/GetCustomEvents/GetCustomEventsSortParams.php @@ -0,0 +1,17 @@ +data = $data; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return self::METHOD_URL; + } + + + /** + * @return string + */ + public function getUrl() + { + return $this->buildUrlFromTemplate(); + } + + + /** + * @return string + */ + public function getMethod() + { + return Operation::POST; + } + + + /** + * @return string + * @throws InvalidCommandDataException + */ + public function getBody() + { + return $this->encode($this->data->jsonSerialize()); + } + + + /** + * @return int + */ + public function getSuccessCode() + { + return 201; + } +} diff --git a/src/Operation/CustomEvents/UpdateCustomEvent/UpdateCustomEvent.php b/src/Operation/CustomEvents/UpdateCustomEvent/UpdateCustomEvent.php new file mode 100644 index 0000000..e50efd7 --- /dev/null +++ b/src/Operation/CustomEvents/UpdateCustomEvent/UpdateCustomEvent.php @@ -0,0 +1,82 @@ +data = $data; + $this->customEventId = $customEventId; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return str_ireplace( + ['{customEventId}'], + [$this->customEventId], + self::METHOD_URL + ); + } + + + /** + * @return string + */ + public function getUrl() + { + return $this->buildUrlFromTemplate(); + } + + + /** + * @return string + */ + public function getMethod() + { + return Operation::POST; + } + + + /** + * @return string + * @throws InvalidCommandDataException + */ + public function getBody() + { + return $this->encode($this->data->jsonSerialize()); + } + + + /** + * @return int + */ + public function getSuccessCode() + { + return 200; + } +} diff --git a/src/Operation/CustomFields/DeleteCustomField/DeleteCustomField.php b/src/Operation/CustomFields/DeleteCustomField/DeleteCustomField.php index 0010695..0a68190 100644 --- a/src/Operation/CustomFields/DeleteCustomField/DeleteCustomField.php +++ b/src/Operation/CustomFields/DeleteCustomField/DeleteCustomField.php @@ -1,7 +1,6 @@ data = $data; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return self::METHOD_URL; + } + + + /** + * @return string + */ + public function getUrl() + { + return $this->buildUrlFromTemplate(); + } + + + /** + * @return string + */ + public function getMethod() + { + return Operation::POST; + } + + + /** + * @return string + * @throws InvalidCommandDataException + */ + public function getBody() + { + return $this->encode($this->data->jsonSerialize()); + } + + + /** + * @return int + */ + public function getSuccessCode() + { + return 201; + } +} diff --git a/src/Operation/FileLibrary/Files/DeleteFile/DeleteFile.php b/src/Operation/FileLibrary/Files/DeleteFile/DeleteFile.php new file mode 100644 index 0000000..68e3772 --- /dev/null +++ b/src/Operation/FileLibrary/Files/DeleteFile/DeleteFile.php @@ -0,0 +1,74 @@ +fileId = $fileId; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return str_ireplace( + ['{fileId}'], + [$this->fileId], + self::METHOD_URL + ); + } + + + /** + * @return string + */ + public function getUrl() + { + return $this->buildUrlFromTemplate(); + } + + + /** + * @return string + */ + public function getMethod() + { + return Operation::DELETE; + } + + + /** + * @return string + */ + public function getBody() + { + return ''; + } + + + /** + * @return int + */ + public function getSuccessCode() + { + return 204; + } +} diff --git a/src/Operation/FileLibrary/Files/GetFile/GetFile.php b/src/Operation/FileLibrary/Files/GetFile/GetFile.php new file mode 100644 index 0000000..bbec0dd --- /dev/null +++ b/src/Operation/FileLibrary/Files/GetFile/GetFile.php @@ -0,0 +1,61 @@ +fileId = $fileId; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return str_ireplace( + ['{fileId}'], + [$this->fileId], + self::METHOD_URL + ); + } + + + /** + * @param GetFileFields $fields + * @return $this + */ + public function setFields(GetFileFields $fields) + { + $this->fields = $fields; + return $this; + } + + + /** + * @return string + */ + public function getUrl() + { + $extra = $this->getFieldsParameterArray($this->fields); + return $this->buildUrlFromTemplate() . $this->buildQueryString(null, null, $extra); + } +} diff --git a/src/Operation/FileLibrary/Files/GetFile/GetFileFields.php b/src/Operation/FileLibrary/Files/GetFile/GetFileFields.php new file mode 100644 index 0000000..1602e7f --- /dev/null +++ b/src/Operation/FileLibrary/Files/GetFile/GetFileFields.php @@ -0,0 +1,27 @@ +query = $query; + return $this; + } + + + /** + * @param GetFilesSortParams $sort + * @return $this + */ + public function setSort(GetFilesSortParams $sort) + { + $this->sort = $sort; + return $this; + } + + + /** + * @param Pagination $pagination + * @return $this + */ + public function setPagination(Pagination $pagination) + { + $this->pagination = $pagination; + return $this; + } + + + /** + * @param GetFilesFields $fields + * @return $this + */ + public function setFields(GetFilesFields $fields) + { + $this->fields = $fields; + return $this; + } + + + /** + * @return string + */ + public function getUrl() + { + $extra = array_merge( + $this->getPaginationParametersArray($this->pagination), + $this->getFieldsParameterArray($this->fields) + ); + + return $this->buildUrlFromTemplate() . $this->buildQueryString($this->query, $this->sort, $extra); + } +} diff --git a/src/Operation/FileLibrary/Files/GetFiles/GetFilesFields.php b/src/Operation/FileLibrary/Files/GetFiles/GetFilesFields.php new file mode 100644 index 0000000..cc09d14 --- /dev/null +++ b/src/Operation/FileLibrary/Files/GetFiles/GetFilesFields.php @@ -0,0 +1,27 @@ +set('allFolders', 'true'); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereAllFoldersIsFalse() + { + return $this->set('allFolders', 'false'); + } + + + /** + * @param string $folderId + * @return $this + * @throws \InvalidArgumentException + */ + public function whereFolderId($folderId) + { + return $this->set('folderId', $folderId); + } + + + /** + * @param string $name + * @return $this + * @throws \InvalidArgumentException + */ + public function whereName($name) + { + return $this->set('name', $name); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereGroupIsAudio() + { + return $this->set('group', 'audio'); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereGroupIsVideo() + { + return $this->set('group', 'video'); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereGroupIsPhoto() + { + return $this->set('group', 'photo'); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereGroupIsDocument() + { + return $this->set('group', 'document'); + } +} diff --git a/src/Operation/FileLibrary/Files/GetFiles/GetFilesSortParams.php b/src/Operation/FileLibrary/Files/GetFiles/GetFilesSortParams.php new file mode 100644 index 0000000..ae08890 --- /dev/null +++ b/src/Operation/FileLibrary/Files/GetFiles/GetFilesSortParams.php @@ -0,0 +1,19 @@ +data = $data; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return self::METHOD_URL; + } + + + /** + * @return string + */ + public function getUrl() + { + return $this->buildUrlFromTemplate(); + } + + + /** + * @return string + */ + public function getMethod() + { + return Operation::POST; + } + + + /** + * @return string + * @throws InvalidCommandDataException + */ + public function getBody() + { + return $this->encode($this->data->jsonSerialize()); + } + + + /** + * @return int + */ + public function getSuccessCode() + { + return 201; + } +} diff --git a/src/Operation/FileLibrary/Folders/GetFolders/GetFolders.php b/src/Operation/FileLibrary/Folders/GetFolders/GetFolders.php new file mode 100644 index 0000000..4849ddf --- /dev/null +++ b/src/Operation/FileLibrary/Folders/GetFolders/GetFolders.php @@ -0,0 +1,92 @@ +query = $query; + return $this; + } + + + /** + * @param GetFoldersSortParams $sort + * @return $this + */ + public function setSort(GetFoldersSortParams $sort) + { + $this->sort = $sort; + return $this; + } + + + /** + * @param Pagination $pagination + * @return $this + */ + public function setPagination(Pagination $pagination) + { + $this->pagination = $pagination; + return $this; + } + + + /** + * @param GetFoldersFields $fields + * @return $this + */ + public function setFields(GetFoldersFields $fields) + { + $this->fields = $fields; + return $this; + } + + + /** + * @return string + */ + public function getUrl() + { + $extra = array_merge( + $this->getPaginationParametersArray($this->pagination), + $this->getFieldsParameterArray($this->fields) + ); + + return $this->buildUrlFromTemplate() . $this->buildQueryString($this->query, $this->sort, $extra); + } +} diff --git a/src/Operation/FileLibrary/Folders/GetFolders/GetFoldersFields.php b/src/Operation/FileLibrary/Folders/GetFolders/GetFoldersFields.php new file mode 100644 index 0000000..85ba4cb --- /dev/null +++ b/src/Operation/FileLibrary/Folders/GetFolders/GetFoldersFields.php @@ -0,0 +1,20 @@ +set('name', $name); + } +} diff --git a/src/Operation/FileLibrary/Folders/GetFolders/GetFoldersSortParams.php b/src/Operation/FileLibrary/Folders/GetFolders/GetFoldersSortParams.php new file mode 100644 index 0000000..6de71d6 --- /dev/null +++ b/src/Operation/FileLibrary/Folders/GetFolders/GetFoldersSortParams.php @@ -0,0 +1,19 @@ +buildUrlFromTemplate(); + } +} diff --git a/src/Operation/Forms/Variants/GetVariants/GetVariants.php b/src/Operation/Forms/Variants/GetVariants/GetVariants.php index fe3b3bc..83a04ea 100644 --- a/src/Operation/Forms/Variants/GetVariants/GetVariants.php +++ b/src/Operation/Forms/Variants/GetVariants/GetVariants.php @@ -1,7 +1,6 @@ set('name', $name); } + + + /** + * @param string $isDefault + * @return $this + * @throws \InvalidArgumentException + */ + public function whereIsDefault($isDefault) + { + return $this->set('isDefault', $isDefault); + } + + + /** + * @param string $isActive + * @return $this + * @throws \InvalidArgumentException + */ + public function whereIsActive($isActive) + { + return $this->set('isActive', $isActive); + } } diff --git a/src/Operation/Imports/GetImports/GetImports.php b/src/Operation/Imports/GetImports/GetImports.php index 8bbfef1..9f07c47 100644 --- a/src/Operation/Imports/GetImports/GetImports.php +++ b/src/Operation/Imports/GetImports/GetImports.php @@ -1,7 +1,6 @@ name = $name; + } + + + /** + * @param string $type + */ + public function setType($type) + { + $this->type = $type; + } + + + /** + * @return array + */ + public function jsonSerialize() + { + $data = [ + 'name' => $this->name, + 'type' => $this->type, + ]; + + return $this->filterUnsetFields($data); + } +} diff --git a/src/Operation/Model/CustomFieldCondition.php b/src/Operation/Model/CustomFieldCondition.php index d7248e1..876ca89 100644 --- a/src/Operation/Model/CustomFieldCondition.php +++ b/src/Operation/Model/CustomFieldCondition.php @@ -1,8 +1,6 @@ operator = $operator; + $this->value = $value; + } + + + /** + * @param string $operatorType + */ + public function setOperatorType($operatorType) + { + $this->operatorType = $operatorType; + } + + + /** + * @return array + */ + public function jsonSerialize() + { + $data = [ + 'operatorType' => $this->operatorType, + 'operator' => $this->operator, + 'value' => $this->value, + ]; + + return array_merge(parent::jsonSerialize(), $this->filterUnsetFields($data)); + } +} diff --git a/src/Operation/Model/FolderShort.php b/src/Operation/Model/FolderShort.php new file mode 100644 index 0000000..6959530 --- /dev/null +++ b/src/Operation/Model/FolderShort.php @@ -0,0 +1,32 @@ +folderId = $folderId; + } + + + /** + * @return array + */ + public function jsonSerialize() + { + $data = [ + 'folderId' => $this->folderId, + ]; + + return $this->filterUnsetFields($data); + } +} diff --git a/src/Operation/Model/GeolocationCondition.php b/src/Operation/Model/GeolocationCondition.php index 8883874..00ce003 100644 --- a/src/Operation/Model/GeolocationCondition.php +++ b/src/Operation/Model/GeolocationCondition.php @@ -1,8 +1,6 @@ value; + } +} diff --git a/src/Operation/Model/MessageNotSentCondition.php b/src/Operation/Model/MessageNotSentCondition.php index 4b444b6..191621a 100644 --- a/src/Operation/Model/MessageNotSentCondition.php +++ b/src/Operation/Model/MessageNotSentCondition.php @@ -1,8 +1,6 @@ value; + } +} diff --git a/src/Operation/Model/NameCondition.php b/src/Operation/Model/NameCondition.php index ee56659..31db395 100644 --- a/src/Operation/Model/NameCondition.php +++ b/src/Operation/Model/NameCondition.php @@ -1,8 +1,6 @@ flags = $flags; } diff --git a/src/Operation/Model/NewCartSelectedProductVariant.php b/src/Operation/Model/NewCartSelectedProductVariant.php index ed014de..a4c7172 100644 --- a/src/Operation/Model/NewCartSelectedProductVariant.php +++ b/src/Operation/Model/NewCartSelectedProductVariant.php @@ -8,7 +8,7 @@ class NewCartSelectedProductVariant extends BaseModel /** @var string */ private $variantId; - /** @var integer */ + /** @var int */ private $quantity; /** @var float */ @@ -20,7 +20,7 @@ class NewCartSelectedProductVariant extends BaseModel /** * @param string $variantId - * @param integer $quantity + * @param int $quantity * @param float $price * @param float $priceTax */ diff --git a/src/Operation/Model/NewCategory.php b/src/Operation/Model/NewCategory.php index 5f7ba27..0fdeb0a 100644 --- a/src/Operation/Model/NewCategory.php +++ b/src/Operation/Model/NewCategory.php @@ -11,7 +11,7 @@ class NewCategory extends BaseModel /** @var string */ private $parentId = self::FIELD_NOT_SET; - /** @var boolean */ + /** @var bool */ private $isDefault = self::FIELD_NOT_SET; /** @var string */ @@ -40,7 +40,7 @@ public function setParentId($parentId) /** - * @param boolean $isDefault + * @param bool $isDefault */ public function setIsDefault($isDefault) { diff --git a/src/Operation/Model/NewContact.php b/src/Operation/Model/NewContact.php index bdfe868..29bd494 100644 --- a/src/Operation/Model/NewContact.php +++ b/src/Operation/Model/NewContact.php @@ -14,11 +14,8 @@ class NewContact extends BaseModel /** @var string */ private $email; - /** @var float */ - private $dayOfCycle = self::FIELD_NOT_SET; - /** @var string */ - private $note = self::FIELD_NOT_SET; + private $dayOfCycle = self::FIELD_NOT_SET; /** @var float */ private $scoring = self::FIELD_NOT_SET; @@ -54,7 +51,7 @@ public function setName($name) /** - * @param float $dayOfCycle + * @param string $dayOfCycle */ public function setDayOfCycle($dayOfCycle) { @@ -62,15 +59,6 @@ public function setDayOfCycle($dayOfCycle) } - /** - * @param string $note - */ - public function setNote($note) - { - $this->note = $note; - } - - /** * @param float $scoring */ @@ -117,7 +105,6 @@ public function jsonSerialize() 'campaign' => $this->campaign, 'email' => $this->email, 'dayOfCycle' => $this->dayOfCycle, - 'note' => $this->note, 'scoring' => $this->scoring, 'ipAddress' => $this->ipAddress, 'tags' => $this->tags, diff --git a/src/Operation/Model/NewCustomEvent.php b/src/Operation/Model/NewCustomEvent.php new file mode 100644 index 0000000..eedcddf --- /dev/null +++ b/src/Operation/Model/NewCustomEvent.php @@ -0,0 +1,45 @@ +name = $name; + } + + + /** + * @param CustomEventAttributeDetails[] $attributes + */ + public function setAttributes(array $attributes) + { + $this->attributes = $attributes; + } + + + /** + * @return array + */ + public function jsonSerialize() + { + $data = [ + 'name' => $this->name, + 'attributes' => $this->attributes, + ]; + + return $this->filterUnsetFields($data); + } +} diff --git a/src/Operation/Model/NewFile.php b/src/Operation/Model/NewFile.php new file mode 100644 index 0000000..822af1e --- /dev/null +++ b/src/Operation/Model/NewFile.php @@ -0,0 +1,50 @@ +content = $content; + $this->name = $name; + $this->extension = $extension; + $this->folder = $folder; + } + + + /** + * @return array + */ + public function jsonSerialize() + { + $data = [ + 'content' => $this->content, + 'name' => $this->name, + 'extension' => $this->extension, + 'folder' => $this->folder, + ]; + + return $this->filterUnsetFields($data); + } +} diff --git a/src/Operation/Model/NewFolder.php b/src/Operation/Model/NewFolder.php new file mode 100644 index 0000000..324d8fb --- /dev/null +++ b/src/Operation/Model/NewFolder.php @@ -0,0 +1,32 @@ +name = $name; + } + + + /** + * @return array + */ + public function jsonSerialize() + { + $data = [ + 'name' => $this->name, + ]; + + return $this->filterUnsetFields($data); + } +} diff --git a/src/Operation/Model/NewNewsletter.php b/src/Operation/Model/NewNewsletter.php index 373946a..ecdd009 100644 --- a/src/Operation/Model/NewNewsletter.php +++ b/src/Operation/Model/NewNewsletter.php @@ -5,6 +5,9 @@ class NewNewsletter extends BaseModel { + /** @var MessageFlagsArray */ + private $flags = self::FIELD_NOT_SET; + /** @var string */ private $name = self::FIELD_NOT_SET; @@ -32,9 +35,6 @@ class NewNewsletter extends BaseModel /** @var MessageContent */ private $content; - /** @var MessageFlags */ - private $flags = self::FIELD_NOT_SET; - /** @var NewsletterAttachment[] */ private $attachments = self::FIELD_NOT_SET; @@ -64,6 +64,15 @@ public function __construct( } + /** + * @param MessageFlagsArray $flags + */ + public function setFlags(MessageFlagsArray $flags) + { + $this->flags = $flags; + } + + /** * @param string $name */ @@ -109,15 +118,6 @@ public function setSendOn($sendOn) } - /** - * @param MessageFlags $flags - */ - public function setFlags(MessageFlags $flags) - { - $this->flags = $flags; - } - - /** * @param NewsletterAttachment[] $attachments */ @@ -133,6 +133,7 @@ public function setAttachments(array $attachments) public function jsonSerialize() { $data = [ + 'flags' => $this->flags, 'name' => $this->name, 'type' => $this->type, 'editor' => $this->editor, @@ -142,7 +143,6 @@ public function jsonSerialize() 'campaign' => $this->campaign, 'sendOn' => $this->sendOn, 'content' => $this->content, - 'flags' => $this->flags, 'attachments' => $this->attachments, 'sendSettings' => $this->sendSettings, ]; diff --git a/src/Operation/Model/NewProductCategory.php b/src/Operation/Model/NewProductCategory.php index 57c178e..c2411c9 100644 --- a/src/Operation/Model/NewProductCategory.php +++ b/src/Operation/Model/NewProductCategory.php @@ -11,7 +11,7 @@ class NewProductCategory extends BaseModel /** @var string */ private $parentId = self::FIELD_NOT_SET; - /** @var boolean */ + /** @var bool */ private $isDefault = self::FIELD_NOT_SET; /** @var string */ @@ -40,7 +40,7 @@ public function setParentId($parentId) /** - * @param boolean $isDefault + * @param bool $isDefault */ public function setIsDefault($isDefault) { diff --git a/src/Operation/Model/NewProductVariant.php b/src/Operation/Model/NewProductVariant.php index 611ff14..ba89dc4 100644 --- a/src/Operation/Model/NewProductVariant.php +++ b/src/Operation/Model/NewProductVariant.php @@ -26,10 +26,10 @@ class NewProductVariant extends BaseModel /** @var float */ private $previousPriceTax = self::FIELD_NOT_SET; - /** @var integer */ + /** @var int */ private $quantity = self::FIELD_NOT_SET; - /** @var integer */ + /** @var int */ private $position = self::FIELD_NOT_SET; /** @var string */ @@ -94,7 +94,7 @@ public function setPreviousPriceTax($previousPriceTax) /** - * @param integer $quantity + * @param int $quantity */ public function setQuantity($quantity) { @@ -103,7 +103,7 @@ public function setQuantity($quantity) /** - * @param integer $position + * @param int $position */ public function setPosition($position) { diff --git a/src/Operation/Model/NewProductVariantImage.php b/src/Operation/Model/NewProductVariantImage.php index eee8b04..416cabe 100644 --- a/src/Operation/Model/NewProductVariantImage.php +++ b/src/Operation/Model/NewProductVariantImage.php @@ -8,13 +8,13 @@ class NewProductVariantImage extends BaseModel /** @var string */ private $src; - /** @var integer */ + /** @var int */ private $position; /** * @param string $src - * @param integer $position + * @param int $position */ public function __construct($src, $position) { diff --git a/src/Operation/Model/NewRssNewsletter.php b/src/Operation/Model/NewRssNewsletter.php index 6331819..e20dcc3 100644 --- a/src/Operation/Model/NewRssNewsletter.php +++ b/src/Operation/Model/NewRssNewsletter.php @@ -5,6 +5,9 @@ class NewRssNewsletter extends BaseModel { + /** @var MessageFlagsArray */ + private $flags = self::FIELD_NOT_SET; + /** @var string */ private $rssFeedUrl; @@ -29,9 +32,6 @@ class NewRssNewsletter extends BaseModel /** @var MessageContent */ private $content; - /** @var MessageFlags */ - private $flags = self::FIELD_NOT_SET; - /** @var RssNewsletterSendSettings */ private $sendSettings; @@ -61,6 +61,15 @@ public function __construct( } + /** + * @param MessageFlagsArray $flags + */ + public function setFlags(MessageFlagsArray $flags) + { + $this->flags = $flags; + } + + /** * @param string $name */ @@ -88,21 +97,13 @@ public function setReplyTo(FromFieldReference $replyTo) } - /** - * @param MessageFlags $flags - */ - public function setFlags(MessageFlags $flags) - { - $this->flags = $flags; - } - - /** * @return array */ public function jsonSerialize() { $data = [ + 'flags' => $this->flags, 'rssFeedUrl' => $this->rssFeedUrl, 'subject' => $this->subject, 'name' => $this->name, @@ -111,7 +112,6 @@ public function jsonSerialize() 'fromField' => $this->fromField, 'replyTo' => $this->replyTo, 'content' => $this->content, - 'flags' => $this->flags, 'sendSettings' => $this->sendSettings, ]; diff --git a/src/Operation/Model/NewSelectedProductVariant.php b/src/Operation/Model/NewSelectedProductVariant.php index 2628f5a..2778675 100644 --- a/src/Operation/Model/NewSelectedProductVariant.php +++ b/src/Operation/Model/NewSelectedProductVariant.php @@ -14,7 +14,7 @@ class NewSelectedProductVariant extends BaseModel /** @var float */ private $priceTax = self::FIELD_NOT_SET; - /** @var integer */ + /** @var int */ private $quantity; /** @var NewTax[] */ @@ -24,7 +24,7 @@ class NewSelectedProductVariant extends BaseModel /** * @param string $variantId * @param float $price - * @param integer $quantity + * @param int $quantity */ public function __construct($variantId, $price, $quantity) { diff --git a/src/Operation/Model/NotOpenedCondition.php b/src/Operation/Model/NotOpenedCondition.php index 443c133..e229401 100644 --- a/src/Operation/Model/NotOpenedCondition.php +++ b/src/Operation/Model/NotOpenedCondition.php @@ -1,8 +1,6 @@ value; + } +} diff --git a/src/Operation/Model/RssNewsletterSendAsapSettings.php b/src/Operation/Model/RssNewsletterSendAsapSettings.php index e0a7596..5dfe21c 100644 --- a/src/Operation/Model/RssNewsletterSendAsapSettings.php +++ b/src/Operation/Model/RssNewsletterSendAsapSettings.php @@ -1,8 +1,6 @@ value; + } +} diff --git a/src/Operation/Model/StatusEnum.php b/src/Operation/Model/StatusEnum.php index fae6456..5fad77a 100644 --- a/src/Operation/Model/StatusEnum.php +++ b/src/Operation/Model/StatusEnum.php @@ -9,7 +9,7 @@ class StatusEnum extends BaseEnum const DISABLED = 'disabled'; /** - * @return boolean + * @return bool */ public function isMultiple() { diff --git a/src/Operation/Model/StringBooleanEnum.php b/src/Operation/Model/StringBooleanEnum.php index 8fcbd58..d801d4e 100644 --- a/src/Operation/Model/StringBooleanEnum.php +++ b/src/Operation/Model/StringBooleanEnum.php @@ -9,7 +9,7 @@ class StringBooleanEnum extends BaseEnum const FALSE = 'false'; /** - * @return boolean + * @return bool */ public function isMultiple() { diff --git a/src/Operation/Model/SubscriptionDateCondition.php b/src/Operation/Model/SubscriptionDateCondition.php index 4038167..c16e1e4 100644 --- a/src/Operation/Model/SubscriptionDateCondition.php +++ b/src/Operation/Model/SubscriptionDateCondition.php @@ -1,8 +1,6 @@ name = $name; + $this->contactId = $contactId; + } + + + /** + * @param TriggerCustomEventAttribute[] $attributes + */ + public function setAttributes(array $attributes) + { + $this->attributes = $attributes; + } + + + /** + * @return array + */ + public function jsonSerialize() + { + $data = [ + 'name' => $this->name, + 'contactId' => $this->contactId, + 'attributes' => $this->attributes, + ]; + + return $this->filterUnsetFields($data); + } +} diff --git a/src/Operation/Model/TriggerCustomEventAttribute.php b/src/Operation/Model/TriggerCustomEventAttribute.php new file mode 100644 index 0000000..329aad3 --- /dev/null +++ b/src/Operation/Model/TriggerCustomEventAttribute.php @@ -0,0 +1,38 @@ +name = $name; + $this->value = $value; + } + + + /** + * @return array + */ + public function jsonSerialize() + { + $data = [ + 'name' => $this->name, + 'value' => $this->value, + ]; + + return $this->filterUnsetFields($data); + } +} diff --git a/src/Operation/Model/UpdateAccount.php b/src/Operation/Model/UpdateAccount.php index ff28316..84c6e91 100644 --- a/src/Operation/Model/UpdateAccount.php +++ b/src/Operation/Model/UpdateAccount.php @@ -18,22 +18,22 @@ class UpdateAccount extends BaseModel private $phone = self::FIELD_NOT_SET; /** @var string */ - private $street = self::FIELD_NOT_SET; + private $state = self::FIELD_NOT_SET; /** @var string */ private $city = self::FIELD_NOT_SET; /** @var string */ - private $state = self::FIELD_NOT_SET; + private $street = self::FIELD_NOT_SET; /** @var string */ private $zipCode = self::FIELD_NOT_SET; /** @var string */ - private $timeFormat = self::FIELD_NOT_SET; + private $numberOfEmployees = self::FIELD_NOT_SET; /** @var string */ - private $numberOfEmployees = self::FIELD_NOT_SET; + private $timeFormat = self::FIELD_NOT_SET; /** @@ -73,11 +73,11 @@ public function setPhone($phone) /** - * @param string $street + * @param string $state */ - public function setStreet($street) + public function setState($state) { - $this->street = $street; + $this->state = $state; } @@ -91,11 +91,11 @@ public function setCity($city) /** - * @param string $state + * @param string $street */ - public function setState($state) + public function setStreet($street) { - $this->state = $state; + $this->street = $street; } @@ -109,20 +109,20 @@ public function setZipCode($zipCode) /** - * @param string $timeFormat + * @param string $numberOfEmployees */ - public function setTimeFormat($timeFormat) + public function setNumberOfEmployees($numberOfEmployees) { - $this->timeFormat = $timeFormat; + $this->numberOfEmployees = $numberOfEmployees; } /** - * @param string $numberOfEmployees + * @param string $timeFormat */ - public function setNumberOfEmployees($numberOfEmployees) + public function setTimeFormat($timeFormat) { - $this->numberOfEmployees = $numberOfEmployees; + $this->timeFormat = $timeFormat; } @@ -136,12 +136,12 @@ public function jsonSerialize() 'lastName' => $this->lastName, 'companyName' => $this->companyName, 'phone' => $this->phone, - 'street' => $this->street, - 'city' => $this->city, 'state' => $this->state, + 'city' => $this->city, + 'street' => $this->street, 'zipCode' => $this->zipCode, - 'timeFormat' => $this->timeFormat, 'numberOfEmployees' => $this->numberOfEmployees, + 'timeFormat' => $this->timeFormat, ]; return $this->filterUnsetFields($data); diff --git a/src/Operation/Model/UpdateAutoresponder.php b/src/Operation/Model/UpdateAutoresponder.php index a420b15..baae84e 100644 --- a/src/Operation/Model/UpdateAutoresponder.php +++ b/src/Operation/Model/UpdateAutoresponder.php @@ -29,7 +29,7 @@ class UpdateAutoresponder extends BaseModel /** @var MessageContent */ private $content = self::FIELD_NOT_SET; - /** @var MessageFlags */ + /** @var MessageFlagsArray */ private $flags = self::FIELD_NOT_SET; /** @var AutoresponderSendSettings */ @@ -112,9 +112,9 @@ public function setContent(MessageContent $content) /** - * @param MessageFlags $flags + * @param MessageFlagsArray $flags */ - public function setFlags(MessageFlags $flags) + public function setFlags(MessageFlagsArray $flags) { $this->flags = $flags; } diff --git a/src/Operation/Model/UpdateCategory.php b/src/Operation/Model/UpdateCategory.php index a9b824f..14171de 100644 --- a/src/Operation/Model/UpdateCategory.php +++ b/src/Operation/Model/UpdateCategory.php @@ -11,7 +11,7 @@ class UpdateCategory extends BaseModel /** @var string */ private $parentId = self::FIELD_NOT_SET; - /** @var boolean */ + /** @var bool */ private $isDefault = self::FIELD_NOT_SET; /** @var string */ @@ -40,7 +40,7 @@ public function setParentId($parentId) /** - * @param boolean $isDefault + * @param bool $isDefault */ public function setIsDefault($isDefault) { diff --git a/src/Operation/Model/UpdateContact.php b/src/Operation/Model/UpdateContact.php index e26f62a..be7017e 100644 --- a/src/Operation/Model/UpdateContact.php +++ b/src/Operation/Model/UpdateContact.php @@ -14,17 +14,14 @@ class UpdateContact extends BaseModel /** @var string */ private $email = self::FIELD_NOT_SET; - /** @var float */ - private $dayOfCycle = self::FIELD_NOT_SET; - /** @var string */ - private $note = self::FIELD_NOT_SET; + private $dayOfCycle = self::FIELD_NOT_SET; /** @var float */ private $scoring = self::FIELD_NOT_SET; /** @var string */ - private $ipAddress = self::FIELD_NOT_SET; + private $note = self::FIELD_NOT_SET; /** @var NewContactTag[] */ private $tags = self::FIELD_NOT_SET; @@ -61,7 +58,7 @@ public function setEmail($email) /** - * @param float $dayOfCycle + * @param string $dayOfCycle */ public function setDayOfCycle($dayOfCycle) { @@ -69,15 +66,6 @@ public function setDayOfCycle($dayOfCycle) } - /** - * @param string $note - */ - public function setNote($note) - { - $this->note = $note; - } - - /** * @param float $scoring */ @@ -88,11 +76,11 @@ public function setScoring($scoring) /** - * @param string $ipAddress + * @param string $note */ - public function setIpAddress($ipAddress) + public function setNote($note) { - $this->ipAddress = $ipAddress; + $this->note = $note; } @@ -124,9 +112,8 @@ public function jsonSerialize() 'campaign' => $this->campaign, 'email' => $this->email, 'dayOfCycle' => $this->dayOfCycle, - 'note' => $this->note, 'scoring' => $this->scoring, - 'ipAddress' => $this->ipAddress, + 'note' => $this->note, 'tags' => $this->tags, 'customFieldValues' => $this->customFieldValues, ]; diff --git a/src/Operation/Model/UpdateCustomEvent.php b/src/Operation/Model/UpdateCustomEvent.php new file mode 100644 index 0000000..77ceb6b --- /dev/null +++ b/src/Operation/Model/UpdateCustomEvent.php @@ -0,0 +1,45 @@ +name = $name; + } + + + /** + * @param CustomEventAttributeDetails[] $attributes + */ + public function setAttributes(array $attributes) + { + $this->attributes = $attributes; + } + + + /** + * @return array + */ + public function jsonSerialize() + { + $data = [ + 'name' => $this->name, + 'attributes' => $this->attributes, + ]; + + return $this->filterUnsetFields($data); + } +} diff --git a/src/Operation/Model/UpdateProductVariant.php b/src/Operation/Model/UpdateProductVariant.php index 077e1b3..b27b3c1 100644 --- a/src/Operation/Model/UpdateProductVariant.php +++ b/src/Operation/Model/UpdateProductVariant.php @@ -26,10 +26,10 @@ class UpdateProductVariant extends BaseModel /** @var float */ private $previousPriceTax = self::FIELD_NOT_SET; - /** @var integer */ + /** @var int */ private $quantity = self::FIELD_NOT_SET; - /** @var integer */ + /** @var int */ private $position = self::FIELD_NOT_SET; /** @var string */ @@ -115,7 +115,7 @@ public function setPreviousPriceTax($previousPriceTax) /** - * @param integer $quantity + * @param int $quantity */ public function setQuantity($quantity) { @@ -124,7 +124,7 @@ public function setQuantity($quantity) /** - * @param integer $position + * @param int $position */ public function setPosition($position) { diff --git a/src/Operation/Model/UpdateRssNewsletter.php b/src/Operation/Model/UpdateRssNewsletter.php index a6cde2c..a7db7a2 100644 --- a/src/Operation/Model/UpdateRssNewsletter.php +++ b/src/Operation/Model/UpdateRssNewsletter.php @@ -5,6 +5,9 @@ class UpdateRssNewsletter extends BaseModel { + /** @var MessageFlagsArray */ + private $flags = self::FIELD_NOT_SET; + /** @var string */ private $rssFeedUrl = self::FIELD_NOT_SET; @@ -29,13 +32,19 @@ class UpdateRssNewsletter extends BaseModel /** @var MessageContent */ private $content = self::FIELD_NOT_SET; - /** @var MessageFlags */ - private $flags = self::FIELD_NOT_SET; - /** @var RssNewsletterSendSettings */ private $sendSettings = self::FIELD_NOT_SET; + /** + * @param MessageFlagsArray $flags + */ + public function setFlags(MessageFlagsArray $flags) + { + $this->flags = $flags; + } + + /** * @param string $rssFeedUrl */ @@ -108,15 +117,6 @@ public function setContent(MessageContent $content) } - /** - * @param MessageFlags $flags - */ - public function setFlags(MessageFlags $flags) - { - $this->flags = $flags; - } - - /** * @param RssNewsletterSendSettings $sendSettings */ @@ -132,6 +132,7 @@ public function setSendSettings(RssNewsletterSendSettings $sendSettings) public function jsonSerialize() { $data = [ + 'flags' => $this->flags, 'rssFeedUrl' => $this->rssFeedUrl, 'subject' => $this->subject, 'name' => $this->name, @@ -140,7 +141,6 @@ public function jsonSerialize() 'fromField' => $this->fromField, 'replyTo' => $this->replyTo, 'content' => $this->content, - 'flags' => $this->flags, 'sendSettings' => $this->sendSettings, ]; diff --git a/src/Operation/Model/UpsertSingleProductCategory.php b/src/Operation/Model/UpsertSingleProductCategory.php index c4a1058..a83933d 100644 --- a/src/Operation/Model/UpsertSingleProductCategory.php +++ b/src/Operation/Model/UpsertSingleProductCategory.php @@ -8,7 +8,7 @@ class UpsertSingleProductCategory extends BaseModel /** @var string */ private $categoryId; - /** @var boolean */ + /** @var bool */ private $isDefault = self::FIELD_NOT_SET; @@ -22,7 +22,7 @@ public function __construct($categoryId) /** - * @param boolean $isDefault + * @param bool $isDefault */ public function setIsDefault($isDefault) { diff --git a/src/Operation/Model/WebinarCondition.php b/src/Operation/Model/WebinarCondition.php index 9764d82..1b8a652 100644 --- a/src/Operation/Model/WebinarCondition.php +++ b/src/Operation/Model/WebinarCondition.php @@ -1,8 +1,6 @@ newsletterId = $newsletterId; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return str_ireplace( + ['{newsletterId}'], + [$this->newsletterId], + self::METHOD_URL + ); + } + + + /** + * @param GetActivitiesSearchQuery $query + * @return $this + */ + public function setQuery(GetActivitiesSearchQuery $query) + { + $this->query = $query; + return $this; + } + + + /** + * @param GetActivitiesSortParams $sort + * @return $this + */ + public function setSort(GetActivitiesSortParams $sort) + { + $this->sort = $sort; + return $this; + } + + + /** + * @param Pagination $pagination + * @return $this + */ + public function setPagination(Pagination $pagination) + { + $this->pagination = $pagination; + return $this; + } + + + /** + * @return string + */ + public function getUrl() + { + $extra = array_merge( + $this->getPaginationParametersArray($this->pagination) + ); + + return $this->buildUrlFromTemplate() . $this->buildQueryString($this->query, $this->sort, $extra); + } +} diff --git a/src/Operation/Newsletters/Activities/GetActivities/GetActivitiesSearchQuery.php b/src/Operation/Newsletters/Activities/GetActivities/GetActivitiesSearchQuery.php new file mode 100644 index 0000000..32f7b1b --- /dev/null +++ b/src/Operation/Newsletters/Activities/GetActivities/GetActivitiesSearchQuery.php @@ -0,0 +1,60 @@ +set('activity', 'send'); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereActivityIsOpen() + { + return $this->set('activity', 'open'); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereActivityIsClick() + { + return $this->set('activity', 'click'); + } + + + /** + * @param DateRangeSearch $createdOn + * @return $this + * @throws \InvalidArgumentException + */ + public function whereCreatedOn(DateRangeSearch $createdOn) + { + return $this->set('createdOn', $createdOn->toArray()); + } +} diff --git a/src/Operation/Newsletters/Activities/GetActivities/GetActivitiesSortParams.php b/src/Operation/Newsletters/Activities/GetActivities/GetActivitiesSortParams.php new file mode 100644 index 0000000..37cca6a --- /dev/null +++ b/src/Operation/Newsletters/Activities/GetActivities/GetActivitiesSortParams.php @@ -0,0 +1,17 @@ +buildUrlFromTemplate(); + } +} diff --git a/src/Operation/TransactionalEmails/CreateTransactionalEmail/CreateTransactionalEmail.php b/src/Operation/TransactionalEmails/CreateTransactionalEmail/CreateTransactionalEmail.php index 4bf0300..33ca340 100644 --- a/src/Operation/TransactionalEmails/CreateTransactionalEmail/CreateTransactionalEmail.php +++ b/src/Operation/TransactionalEmails/CreateTransactionalEmail/CreateTransactionalEmail.php @@ -13,12 +13,12 @@ class CreateTransactionalEmail extends CommandOperation const METHOD_URL = '/v3/transactional-emails'; - /** @var CreateTransactionalEmail */ + /** @var ModelCreateTransactionalEmail */ protected $data; /** - * @param CreateTransactionalEmail $data + * @param ModelCreateTransactionalEmail $data */ public function __construct(ModelCreateTransactionalEmail $data) { diff --git a/src/Operation/TransactionalEmails/GetTransactionalEmail/GetTransactionalEmail.php b/src/Operation/TransactionalEmails/GetTransactionalEmail/GetTransactionalEmail.php new file mode 100644 index 0000000..740afaa --- /dev/null +++ b/src/Operation/TransactionalEmails/GetTransactionalEmail/GetTransactionalEmail.php @@ -0,0 +1,61 @@ +transactionalEmailId = $transactionalEmailId; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return str_ireplace( + ['{transactionalEmailId}'], + [$this->transactionalEmailId], + self::METHOD_URL + ); + } + + + /** + * @param GetTransactionalEmailFields $fields + * @return $this + */ + public function setFields(GetTransactionalEmailFields $fields) + { + $this->fields = $fields; + return $this; + } + + + /** + * @return string + */ + public function getUrl() + { + $extra = $this->getFieldsParameterArray($this->fields); + return $this->buildUrlFromTemplate() . $this->buildQueryString(null, null, $extra); + } +} diff --git a/src/Operation/TransactionalEmails/GetTransactionalEmail/GetTransactionalEmailFields.php b/src/Operation/TransactionalEmails/GetTransactionalEmail/GetTransactionalEmailFields.php new file mode 100644 index 0000000..3d04b33 --- /dev/null +++ b/src/Operation/TransactionalEmails/GetTransactionalEmail/GetTransactionalEmailFields.php @@ -0,0 +1,23 @@ +query = $query; + return $this; + } + + + /** + * @param Pagination $pagination + * @return $this + */ + public function setPagination(Pagination $pagination) + { + $this->pagination = $pagination; + return $this; + } + + + /** + * @param GetTransactionalEmailsFields $fields + * @return $this + */ + public function setFields(GetTransactionalEmailsFields $fields) + { + $this->fields = $fields; + return $this; + } + + + /** + * @return string + */ + public function getUrl() + { + $extra = array_merge( + $this->getPaginationParametersArray($this->pagination), + $this->getFieldsParameterArray($this->fields) + ); + + return $this->buildUrlFromTemplate() . $this->buildQueryString($this->query, null, $extra); + } +} diff --git a/src/Operation/TransactionalEmails/GetTransactionalEmails/GetTransactionalEmailsFields.php b/src/Operation/TransactionalEmails/GetTransactionalEmails/GetTransactionalEmailsFields.php new file mode 100644 index 0000000..617ca4f --- /dev/null +++ b/src/Operation/TransactionalEmails/GetTransactionalEmails/GetTransactionalEmailsFields.php @@ -0,0 +1,22 @@ +set('tagged', 'true'); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereTaggedIsFalse() + { + return $this->set('tagged', 'false'); + } + + + /** + * @param string $tagId + * @return $this + * @throws \InvalidArgumentException + */ + public function whereTagId($tagId) + { + return $this->set('tagId', $tagId); + } + + + /** + * @param DateRangeSearch $sentOn + * @return $this + * @throws \InvalidArgumentException + */ + public function whereSentOn(DateRangeSearch $sentOn) + { + return $this->set('sentOn', $sentOn->toArray()); + } +} diff --git a/src/Operation/TransactionalEmails/Statistics/GetStatistics/GetStatistics.php b/src/Operation/TransactionalEmails/Statistics/GetStatistics/GetStatistics.php new file mode 100644 index 0000000..d1c6b65 --- /dev/null +++ b/src/Operation/TransactionalEmails/Statistics/GetStatistics/GetStatistics.php @@ -0,0 +1,60 @@ +query = $query; + } + + + /** + * @return string + */ + public function buildUrlFromTemplate() + { + return self::METHOD_URL; + } + + + /** + * @param GetStatisticsFields $fields + * @return $this + */ + public function setFields(GetStatisticsFields $fields) + { + $this->fields = $fields; + return $this; + } + + + /** + * @return string + */ + public function getUrl() + { + $extra = array_merge( + $this->getFieldsParameterArray($this->fields) + ); + + return $this->buildUrlFromTemplate() . $this->buildQueryString($this->query, null, $extra); + } +} diff --git a/src/Operation/TransactionalEmails/Statistics/GetStatistics/GetStatisticsFields.php b/src/Operation/TransactionalEmails/Statistics/GetStatistics/GetStatisticsFields.php new file mode 100644 index 0000000..6fd9569 --- /dev/null +++ b/src/Operation/TransactionalEmails/Statistics/GetStatistics/GetStatisticsFields.php @@ -0,0 +1,21 @@ +setGroupBy($groupBy); + } + + + /** + * @param string $value + */ + private function setGroupBy($value) + { + $enum = new QueryEnum('string', ['total','day'], $value); + $this->set('groupBy', $enum->getValue()); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereTaggedIsTrue() + { + return $this->set('tagged', 'true'); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereTaggedIsFalse() + { + return $this->set('tagged', 'false'); + } + + + /** + * @param string $tagId + * @return $this + * @throws \InvalidArgumentException + */ + public function whereTagId($tagId) + { + return $this->set('tagId', $tagId); + } + + + /** + * @param DateRangeSearch $timeFrame + * @return $this + * @throws \InvalidArgumentException + */ + public function whereTimeFrame(DateRangeSearch $timeFrame) + { + return $this->set('timeFrame', $timeFrame->toArray()); + } +} diff --git a/src/Operation/Webinars/GetWebinar/GetWebinarFields.php b/src/Operation/Webinars/GetWebinar/GetWebinarFields.php index 4ed71dd..68dad2d 100644 --- a/src/Operation/Webinars/GetWebinar/GetWebinarFields.php +++ b/src/Operation/Webinars/GetWebinar/GetWebinarFields.php @@ -17,6 +17,7 @@ public function getAllowedValues() 'startsOn', 'webinarUrl', 'status', + 'type', 'campaigns', 'newsletters', 'statistics', diff --git a/src/Operation/Webinars/GetWebinars/GetWebinarsFields.php b/src/Operation/Webinars/GetWebinars/GetWebinarsFields.php index 52c0e44..a593928 100644 --- a/src/Operation/Webinars/GetWebinars/GetWebinarsFields.php +++ b/src/Operation/Webinars/GetWebinars/GetWebinarsFields.php @@ -17,6 +17,7 @@ public function getAllowedValues() 'startsOn', 'webinarUrl', 'status', + 'type', 'campaigns', 'newsletters', 'statistics', diff --git a/src/Operation/Webinars/GetWebinars/GetWebinarsSearchQuery.php b/src/Operation/Webinars/GetWebinars/GetWebinarsSearchQuery.php index bdd3440..684ccb3 100644 --- a/src/Operation/Webinars/GetWebinars/GetWebinarsSearchQuery.php +++ b/src/Operation/Webinars/GetWebinars/GetWebinarsSearchQuery.php @@ -1,7 +1,6 @@ set('status', 'deleted'); + return $this->set('status', 'published'); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereStatusIsUnpublished() + { + return $this->set('status', 'unpublished'); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereTypeIsAll() + { + return $this->set('type', 'all'); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereTypeIsLive() + { + return $this->set('type', 'live'); + } + + + /** + * @return $this + * @throws \InvalidArgumentException + */ + public function whereTypeIsOnDemand() + { + return $this->set('type', 'on_demand'); } } diff --git a/src/Operation/Workflow/UpdateWorkflow/UpdateWorkflow.php b/src/Operation/Workflow/UpdateWorkflow/UpdateWorkflow.php index 56c73d8..e4e6d98 100644 --- a/src/Operation/Workflow/UpdateWorkflow/UpdateWorkflow.php +++ b/src/Operation/Workflow/UpdateWorkflow/UpdateWorkflow.php @@ -13,7 +13,7 @@ class UpdateWorkflow extends CommandOperation const METHOD_URL = '/v3/workflow/{workflowId}'; - /** @var UpdateWorkflow */ + /** @var ModelUpdateWorkflow */ protected $data; /** @var string */ @@ -21,7 +21,7 @@ class UpdateWorkflow extends CommandOperation /** - * @param UpdateWorkflow $data + * @param ModelUpdateWorkflow $data * @param string $workflowId */ public function __construct(ModelUpdateWorkflow $data, $workflowId) diff --git a/src/Version.php b/src/Version.php index d30c650..3fed4dd 100644 --- a/src/Version.php +++ b/src/Version.php @@ -8,7 +8,7 @@ */ class Version { - const VERSION = '1.2.1'; + const VERSION = '2.0.0'; const API_COMPATIBLE = '3.0'; }