Repository: mailchimp/mailchimp-marketing-php Branch: master Commit: c1a38f7248d8 Files: 41 Total size: 1.6 MB Directory structure: gitextract_dj57h0oe/ ├── .github/ │ └── PULL_REQUEST_TEMPLATE.md ├── .php_cs ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── composer.json ├── git_push.sh ├── lib/ │ ├── Api/ │ │ ├── AccountExportApi.php │ │ ├── AccountExportsApi.php │ │ ├── ActivityFeedApi.php │ │ ├── AuthorizedAppsApi.php │ │ ├── AutomationsApi.php │ │ ├── BatchWebhooksApi.php │ │ ├── BatchesApi.php │ │ ├── CampaignFoldersApi.php │ │ ├── CampaignsApi.php │ │ ├── ConnectedSitesApi.php │ │ ├── ConversationsApi.php │ │ ├── CustomerJourneysApi.php │ │ ├── EcommerceApi.php │ │ ├── FacebookAdsApi.php │ │ ├── FileManagerApi.php │ │ ├── LandingPagesApi.php │ │ ├── ListsApi.php │ │ ├── PingApi.php │ │ ├── ReportingApi.php │ │ ├── ReportsApi.php │ │ ├── RootApi.php │ │ ├── SearchCampaignsApi.php │ │ ├── SearchMembersApi.php │ │ ├── SurveysApi.php │ │ ├── TemplateFoldersApi.php │ │ ├── TemplatesApi.php │ │ └── VerifiedDomainsApi.php │ ├── ApiClient.php │ ├── ApiException.php │ ├── Configuration.php │ ├── HeaderSelector.php │ └── ObjectSerializer.php └── phpunit.xml.dist ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ Note: This repository is auto-generated, and does not accept pull requests. To make changes or open issues for this SDK, use the [code generation repository](https://github.com/mailchimp/mailchimp-client-lib-codegen). ================================================ FILE: .php_cs ================================================ setUsingCache(true) ->setRules([ '@PSR2' => true, 'ordered_imports' => true, 'phpdoc_order' => true, 'array_syntax' => [ 'syntax' => 'short' ], 'strict_comparison' => true, 'strict_param' => true, 'no_trailing_whitespace' => false, 'no_trailing_whitespace_in_comment' => false, 'braces' => false, 'single_blank_line_at_eof' => false, 'blank_line_after_namespace' => false, ]) ->setFinder( PhpCsFixer\Finder::create() ->exclude('test') ->exclude('tests') ->in(__DIR__) ); ================================================ FILE: .travis.yml ================================================ language: php sudo: false php: - 5.4 - 5.5 - 5.6 - 7.0 - hhvm before_install: "composer install" script: "vendor/bin/phpunit" ================================================ FILE: CHANGELOG.md ================================================ # Changelog ## Transactional ### 1.0.48 * Allowing users to schedule messages (using messages/send, messages/send-template, messages/send-raw and messages/reschedule APIs) within a year from the date of scheduling. ### 1.0.46 * Added a little more granularity to the `set_timeout` method to the Client class in the Ruby SDK; now supports `read`, `write` and `connect` parameters, which will default to the `timeout` param if unspecified, or 300 seconds if `timeout` is unspecified. ### 1.0.45 * Added a `set_timeout` method to the Client class in the Ruby SDK ### 1.0.44 * Added a `set_timeout` method to the Client class in the Python SDK ### 1.0.43 * Added a `setTimeout` method to the Configuration class in the PHP SDK. ### 1.0.42 * Added a `setDefaultTimeoutMs` method to the node client. This allows users to override the default timeout for API requests, which is set to 5 minutes by default. ### 1.0.41 * Updated the "reject_reasons" response for /messages/send and /messages/send-template to correctly use "hard-bounce" and "soft-bounce" instead of the previously stated "hard_bounce" and "soft_bounce". ### 1.0.40 * Added the new /allowlists/ series of endpoints and the /exports/allowlist endpoint to the API reference ### 1.0.39 * Fixes the output directory for the Changelog for the php client library ### 1.0.38 * A change was made to `mailchimp-transactional-php` - the API client will now always return an `Exception`, instead of an `Exception` or a string, when the API returns an error. Having to parse the response as a string was found to be a bit clunky. ### 1.0.37 * Added a changelog, which will be used to describe changes to both transactional and marketing client libraries. ## Marketing ### 3.0.72 * Updated the `PATCH /automations/.../emails/.../` documentation to state the required `workflow_type` ### 3.0.70 * Added more granularity for the `timeout` field in the Ruby Marketing SDK; now supports `read_timeout`, `write_timeout` and `connect_timeout` fields which will default to the `timeout` value. ### 3.0.69 * Added handling for a `timeout` field in the config block passed to the client constructor in the Ruby Marketing SDK. ### 3.0.68 * Added handling for a `'timeout'` field in `set_config()` in the Python Marketing SDK. ### 3.0.67 * Added a `setTimeout()` method to the configuration class in the PHP Marketing SDK, to allow manually setting the timeout for Guzzle requests. ### 3.0.65 * Added a new API endpoint, `/3.0/account-exports`, allowing users to programatically export their account information ### 3.0.64 * Fixes the output directory for the Changelog for the php client library ### 3.0.63 * Added a changelog, which will be used to describe changes to both transactional and marketing client libraries. ================================================ FILE: LICENSE ================================================ Mailchimp Client Library License Agreement IMPORTANT- PLEASE READ CAREFULLY BEFORE OPENING, INSTALLING, COPYING OR USING THE CLIENT LIBRARY. This Client Library License Agreement (“Agreement”) is a legal document by and between you (hereinafter referred to as “You” “Your” or “Licensee”) and The Rocket Science Group LLC (“Mailchimp”) (each a “Party” and collectively, “Parties”) for the client library, including any upgrades, modified versions, updates, additions, and copies of the foregoing, including the software and related documentation (the “Mailchimp Client Library”). BY OPENING, INSTALLING, COPYING OR USING THE MAILCHIMP CLIENT LIBRARY OR ANY PORTION THEREOF, YOU AGREE TO ALL THE TERMS OF THIS AGREEMENT. IF YOU ARE AGREEING TO THIS AGREEMENT AS AN INDIVIDUAL, “YOU” “YOUR” AND “LICENSEE” REFERS TO YOU INDIVIDUALLY. IF YOU ARE AGREEING TO THIS AGREEMENT AS A REPRESENTATIVE OF A LEGAL ENTITY, YOU REPRESENT THAT YOU HAVE THE AUTHORITY TO BIND THAT ENTITY AND “YOU” “YOUR” AND “LICENSEE” REFERS TO THAT LEGAL ENTITY AND ALL THE USERS ACCESSING THE SOFTWARE BY, THROUGH OR ON BEHALF OF THAT LEGAL ENTITY. IF YOU DO NOT AGREE WITH ALL OF THE TERMS OF THIS AGREEMENT, DO NOT (AND ENSURE THAT YOUR END USERS DO NOT) OPEN, INSTALL, COPY OR USE THE MAILCHIMP CLIENT LIBRARY. TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. “License” shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 10 of these Terms and Conditions for Use, Reproduction and Distribution. “Legal Entity” shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, “control” means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. “You” (or “Your”) shall mean an individual or Legal Entity exercising permissions granted by this License. “Source” form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. “Object” form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. “Work” shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work. “Derivative Works” shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. “Contribution” shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Mailchimp for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to Mailchimp or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Mailchimp for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as “Not a Contribution.” “Contributor” shall mean Mailchimp and any individual or Legal Entity on behalf of whom a Contribution has been received by Mailchimp and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this Agreement, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: a) You must give any other recipients of the Work or Derivative Works a copy of this License; and b) You must cause any modified files to carry prominent notices stating that You changed the files; and c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and d) If the Work includes a “NOTICE” text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Any Contribution submitted for inclusion in the Work by You to Mailchimp shall be made under the terms and conditions of the Individual Contributor License Agreement or the Software Grant and Corporate Contributor License Agreement, as applicable. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of Mailchimp, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Export controls. The Mailchimp Client Library is subject to united states export laws and regulations. You must comply with all domestic and international export laws and regulations that apply to the Mailchimp Client Library. These laws include restrictions on destinations, end-users and end use. 8. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 9. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 10. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. Copyright 2020, The Rocket Science Group LLC Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. You should include a copy of the License, typically in a file called LICENSE, in your work, and consider also including a NOTICE file. To apply the License to specific files in your work, attach the following boilerplate declaration, with the fields enclosed by brackets “[]” replaced with your own identifying information. (Don’t include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same “printed page” as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Mailchimp Client Library License Agreement (the “License”); you may not use this file except in compliance with the License. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either or express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================
# Mailchimp Marketing — PHP The official PHP client library for the Mailchimp Marketing API ## Installation **Option 1:** Install via Packagist ``` composer require mailchimp/marketing ``` Or add the following to `composer.json` ``` { "require": { "mailchimp/marketing": "*" } } ``` Install all composer dependencies using: ``` composer install ``` **Option 2:** Install Manually Clone the repo ``` git clone git@github.com:mailchimp/mailchimp-marketing-php.git ``` In the client library project root, install all dependencies ``` composer install ``` Manually include `vendor/autoload.php` in your implementation ```php require_once('/path/to/MailchimpMarketing/vendor/autoload.php'); ``` ## Quick Start ### Note that this SDK requires PHP 7.2 or above. ```php require_once('/path/to/MailchimpMarketing/vendor/autoload.php'); $mailchimp = new MailchimpMarketing\ApiClient(); $mailchimp->setConfig([ 'apiKey' => 'YOUR_API_KEY', 'server' => 'YOUR_SERVER_PREFIX' ]); $response = $mailchimp->ping->get(); print_r($response); ``` ## Authentication Methods The client library can be configured to use either **Basic Auth** or **OAuth2**. For either method, a server prefix should be passed in i.e. `us19`, in order for the client to determine to appropriate host url. ### Basic Auth ```php $mailchimp->setConfig([ 'apiKey' => 'YOUR_API_KEY', 'server' => 'YOUR_SERVER_PREFIX' ]); ``` ### OAuth2 ```php $mailchimp->setConfig([ 'accessToken' => 'YOUR_ACCESS_TOKEN', 'server' => 'YOUR_SERVER_PREFIX' ]); ``` ## PRs and Issues This repo is autogenerated from https://github.com/mailchimp/mailchimp-client-lib-codegen -- please submit PRs or issues there! ## Other configuration options The APIClient class lets you set various configuration options like timeouts, host, user agent, and debug output. See https://github.com/mailchimp/mailchimp-marketing-php/blob/master/lib/Configuration.php for more details. ## API Endpoints All URIs are relative to *https://server.api.mailchimp.com/3.0* | Method | Endpoint | | ---------- | -------- | | **accountExport.getAccountExports** | /account-exports/{export_id} | | **accountExports.listAccountExports** | /account-exports | | **accountExports.createAccountExport** | /account-exports | | **activityFeed.getChimpChatter** | /activity-feed/chimp-chatter | | **authorizedApps.list** | /authorized-apps | | **authorizedApps.get** | /authorized-apps/{app_id} | | **automations.archive** | /automations/{workflow_id}/actions/archive | | **automations.deleteWorkflowEmail** | /automations/{workflow_id}/emails/{workflow_email_id} | | **automations.list** | /automations | | **automations.get** | /automations/{workflow_id} | | **automations.listAllWorkflowEmails** | /automations/{workflow_id}/emails | | **automations.getWorkflowEmail** | /automations/{workflow_id}/emails/{workflow_email_id} | | **automations.getWorkflowEmailSubscriberQueue** | /automations/{workflow_id}/emails/{workflow_email_id}/queue | | **automations.getWorkflowEmailSubscriber** | /automations/{workflow_id}/emails/{workflow_email_id}/queue/{subscriber_hash} | | **automations.listWorkflowEmailSubscribersRemoved** | /automations/{workflow_id}/removed-subscribers | | **automations.getRemovedWorkflowEmailSubscriber** | /automations/{workflow_id}/removed-subscribers/{subscriber_hash} | | **automations.updateWorkflowEmail** | /automations/{workflow_id}/emails/{workflow_email_id} | | **automations.create** | /automations | | **automations.pauseAllEmails** | /automations/{workflow_id}/actions/pause-all-emails | | **automations.startAllEmails** | /automations/{workflow_id}/actions/start-all-emails | | **automations.pauseWorkflowEmail** | /automations/{workflow_id}/emails/{workflow_email_id}/actions/pause | | **automations.startWorkflowEmail** | /automations/{workflow_id}/emails/{workflow_email_id}/actions/start | | **automations.addWorkflowEmailSubscriber** | /automations/{workflow_id}/emails/{workflow_email_id}/queue | | **automations.removeWorkflowEmailSubscriber** | /automations/{workflow_id}/removed-subscribers | | **batchWebhooks.remove** | /batch-webhooks/{batch_webhook_id} | | **batchWebhooks.get** | /batch-webhooks/{batch_webhook_id} | | **batchWebhooks.list** | /batch-webhooks | | **batchWebhooks.update** | /batch-webhooks/{batch_webhook_id} | | **batchWebhooks.create** | /batch-webhooks | | **batches.deleteRequest** | /batches/{batch_id} | | **batches.list** | /batches | | **batches.status** | /batches/{batch_id} | | **batches.start** | /batches | | **campaignFolders.remove** | /campaign-folders/{folder_id} | | **campaignFolders.list** | /campaign-folders | | **campaignFolders.get** | /campaign-folders/{folder_id} | | **campaignFolders.update** | /campaign-folders/{folder_id} | | **campaignFolders.create** | /campaign-folders | | **campaigns.remove** | /campaigns/{campaign_id} | | **campaigns.deleteFeedbackMessage** | /campaigns/{campaign_id}/feedback/{feedback_id} | | **campaigns.list** | /campaigns | | **campaigns.get** | /campaigns/{campaign_id} | | **campaigns.getContent** | /campaigns/{campaign_id}/content | | **campaigns.getFeedback** | /campaigns/{campaign_id}/feedback | | **campaigns.getFeedbackMessage** | /campaigns/{campaign_id}/feedback/{feedback_id} | | **campaigns.getSendChecklist** | /campaigns/{campaign_id}/send-checklist | | **campaigns.update** | /campaigns/{campaign_id} | | **campaigns.updateFeedbackMessage** | /campaigns/{campaign_id}/feedback/{feedback_id} | | **campaigns.create** | /campaigns | | **campaigns.cancelSend** | /campaigns/{campaign_id}/actions/cancel-send | | **campaigns.createResend** | /campaigns/{campaign_id}/actions/create-resend | | **campaigns.pause** | /campaigns/{campaign_id}/actions/pause | | **campaigns.replicate** | /campaigns/{campaign_id}/actions/replicate | | **campaigns.resume** | /campaigns/{campaign_id}/actions/resume | | **campaigns.schedule** | /campaigns/{campaign_id}/actions/schedule | | **campaigns.send** | /campaigns/{campaign_id}/actions/send | | **campaigns.sendTestEmail** | /campaigns/{campaign_id}/actions/test | | **campaigns.unschedule** | /campaigns/{campaign_id}/actions/unschedule | | **campaigns.addFeedback** | /campaigns/{campaign_id}/feedback | | **campaigns.setContent** | /campaigns/{campaign_id}/content | | **connectedSites.remove** | /connected-sites/{connected_site_id} | | **connectedSites.list** | /connected-sites | | **connectedSites.get** | /connected-sites/{connected_site_id} | | **connectedSites.create** | /connected-sites | | **connectedSites.verifyScriptInstallation** | /connected-sites/{connected_site_id}/actions/verify-script-installation | | **conversations.list** | /conversations | | **conversations.get** | /conversations/{conversation_id} | | **conversations.getConversationMessages** | /conversations/{conversation_id}/messages | | **conversations.getConversationMessage** | /conversations/{conversation_id}/messages/{message_id} | | **customerJourneys.trigger** | /customer-journeys/journeys/{journey_id}/steps/{step_id}/actions/trigger | | **ecommerce.deleteStore** | /ecommerce/stores/{store_id} | | **ecommerce.deleteStoreCart** | /ecommerce/stores/{store_id}/carts/{cart_id} | | **ecommerce.deleteCartLineItem** | /ecommerce/stores/{store_id}/carts/{cart_id}/lines/{line_id} | | **ecommerce.deleteStoreCustomer** | /ecommerce/stores/{store_id}/customers/{customer_id} | | **ecommerce.deleteOrder** | /ecommerce/stores/{store_id}/orders/{order_id} | | **ecommerce.deleteOrderLineItem** | /ecommerce/stores/{store_id}/orders/{order_id}/lines/{line_id} | | **ecommerce.deleteStoreProduct** | /ecommerce/stores/{store_id}/products/{product_id} | | **ecommerce.deleteProductImage** | /ecommerce/stores/{store_id}/products/{product_id}/images/{image_id} | | **ecommerce.deleteProductVariant** | /ecommerce/stores/{store_id}/products/{product_id}/variants/{variant_id} | | **ecommerce.deletePromoCode** | /ecommerce/stores/{store_id}/promo-rules/{promo_rule_id}/promo-codes/{promo_code_id} | | **ecommerce.deletePromoRule** | /ecommerce/stores/{store_id}/promo-rules/{promo_rule_id} | | **ecommerce.orders** | /ecommerce/orders | | **ecommerce.stores** | /ecommerce/stores | | **ecommerce.getStore** | /ecommerce/stores/{store_id} | | **ecommerce.getStoreCarts** | /ecommerce/stores/{store_id}/carts | | **ecommerce.getStoreCart** | /ecommerce/stores/{store_id}/carts/{cart_id} | | **ecommerce.getAllCartLineItems** | /ecommerce/stores/{store_id}/carts/{cart_id}/lines | | **ecommerce.getCartLineItem** | /ecommerce/stores/{store_id}/carts/{cart_id}/lines/{line_id} | | **ecommerce.getAllStoreCustomers** | /ecommerce/stores/{store_id}/customers | | **ecommerce.getStoreCustomer** | /ecommerce/stores/{store_id}/customers/{customer_id} | | **ecommerce.getStoreOrders** | /ecommerce/stores/{store_id}/orders | | **ecommerce.getOrder** | /ecommerce/stores/{store_id}/orders/{order_id} | | **ecommerce.getAllOrderLineItems** | /ecommerce/stores/{store_id}/orders/{order_id}/lines | | **ecommerce.getOrderLineItem** | /ecommerce/stores/{store_id}/orders/{order_id}/lines/{line_id} | | **ecommerce.getAllStoreProducts** | /ecommerce/stores/{store_id}/products | | **ecommerce.getStoreProduct** | /ecommerce/stores/{store_id}/products/{product_id} | | **ecommerce.getProductImages** | /ecommerce/stores/{store_id}/products/{product_id}/images | | **ecommerce.getProductImage** | /ecommerce/stores/{store_id}/products/{product_id}/images/{image_id} | | **ecommerce.getProductVariants** | /ecommerce/stores/{store_id}/products/{product_id}/variants | | **ecommerce.getProductVariant** | /ecommerce/stores/{store_id}/products/{product_id}/variants/{variant_id} | | **ecommerce.getPromoCodes** | /ecommerce/stores/{store_id}/promo-rules/{promo_rule_id}/promo-codes | | **ecommerce.getPromoCode** | /ecommerce/stores/{store_id}/promo-rules/{promo_rule_id}/promo-codes/{promo_code_id} | | **ecommerce.listPromoRules** | /ecommerce/stores/{store_id}/promo-rules | | **ecommerce.getPromoRule** | /ecommerce/stores/{store_id}/promo-rules/{promo_rule_id} | | **ecommerce.updateStore** | /ecommerce/stores/{store_id} | | **ecommerce.updateStoreCart** | /ecommerce/stores/{store_id}/carts/{cart_id} | | **ecommerce.updateCartLineItem** | /ecommerce/stores/{store_id}/carts/{cart_id}/lines/{line_id} | | **ecommerce.updateStoreCustomer** | /ecommerce/stores/{store_id}/customers/{customer_id} | | **ecommerce.updateOrder** | /ecommerce/stores/{store_id}/orders/{order_id} | | **ecommerce.updateOrderLineItem** | /ecommerce/stores/{store_id}/orders/{order_id}/lines/{line_id} | | **ecommerce.updateStoreProduct** | /ecommerce/stores/{store_id}/products/{product_id} | | **ecommerce.updateProductImage** | /ecommerce/stores/{store_id}/products/{product_id}/images/{image_id} | | **ecommerce.updateProductVariant** | /ecommerce/stores/{store_id}/products/{product_id}/variants/{variant_id} | | **ecommerce.updatePromoCode** | /ecommerce/stores/{store_id}/promo-rules/{promo_rule_id}/promo-codes/{promo_code_id} | | **ecommerce.updatePromoRule** | /ecommerce/stores/{store_id}/promo-rules/{promo_rule_id} | | **ecommerce.addStore** | /ecommerce/stores | | **ecommerce.addStoreCart** | /ecommerce/stores/{store_id}/carts | | **ecommerce.addCartLineItem** | /ecommerce/stores/{store_id}/carts/{cart_id}/lines | | **ecommerce.addStoreCustomer** | /ecommerce/stores/{store_id}/customers | | **ecommerce.addStoreOrder** | /ecommerce/stores/{store_id}/orders | | **ecommerce.addOrderLineItem** | /ecommerce/stores/{store_id}/orders/{order_id}/lines | | **ecommerce.addStoreProduct** | /ecommerce/stores/{store_id}/products | | **ecommerce.addProductImage** | /ecommerce/stores/{store_id}/products/{product_id}/images | | **ecommerce.addProductVariants** | /ecommerce/stores/{store_id}/products/{product_id}/variants | | **ecommerce.addPromoCode** | /ecommerce/stores/{store_id}/promo-rules/{promo_rule_id}/promo-codes | | **ecommerce.addPromoRules** | /ecommerce/stores/{store_id}/promo-rules | | **ecommerce.setStoreCustomer** | /ecommerce/stores/{store_id}/customers/{customer_id} | | **ecommerce.addProductVariant** | /ecommerce/stores/{store_id}/products/{product_id}/variants/{variant_id} | | **facebookAds.list** | /facebook-ads | | **facebookAds.getAd** | /facebook-ads/{outreach_id} | | **fileManager.deleteFile** | /file-manager/files/{file_id} | | **fileManager.deleteFolder** | /file-manager/folders/{folder_id} | | **fileManager.files** | /file-manager/files | | **fileManager.getFile** | /file-manager/files/{file_id} | | **fileManager.listFolders** | /file-manager/folders | | **fileManager.getFolder** | /file-manager/folders/{folder_id} | | **fileManager.updateFile** | /file-manager/files/{file_id} | | **fileManager.updateFolder** | /file-manager/folders/{folder_id} | | **fileManager.upload** | /file-manager/files | | **fileManager.createFolder** | /file-manager/folders | | **landingPages.deletePage** | /landing-pages/{page_id} | | **landingPages.getAll** | /landing-pages | | **landingPages.getPage** | /landing-pages/{page_id} | | **landingPages.getPageContent** | /landing-pages/{page_id}/content | | **landingPages.updatePage** | /landing-pages/{page_id} | | **landingPages.create** | /landing-pages | | **landingPages.publishPage** | /landing-pages/{page_id}/actions/publish | | **landingPages.unpublishPage** | /landing-pages/{page_id}/actions/unpublish | | **lists.deleteList** | /lists/{list_id} | | **lists.deleteInterestCategory** | /lists/{list_id}/interest-categories/{interest_category_id} | | **lists.deleteInterestCategoryInterest** | /lists/{list_id}/interest-categories/{interest_category_id}/interests/{interest_id} | | **lists.deleteListMember** | /lists/{list_id}/members/{subscriber_hash} | | **lists.deleteListMemberNote** | /lists/{list_id}/members/{subscriber_hash}/notes/{note_id} | | **lists.deleteListMergeField** | /lists/{list_id}/merge-fields/{merge_id} | | **lists.deleteSegment** | /lists/{list_id}/segments/{segment_id} | | **lists.removeSegmentMember** | /lists/{list_id}/segments/{segment_id}/members/{subscriber_hash} | | **lists.deleteListWebhook** | /lists/{list_id}/webhooks/{webhook_id} | | **lists.getListMemberTags** | /lists/{list_id}/members/{subscriber_hash}/tags | | **lists.getAllLists** | /lists | | **lists.getList** | /lists/{list_id} | | **lists.getListAbuseReports** | /lists/{list_id}/abuse-reports | | **lists.getListAbuseReportDetails** | /lists/{list_id}/abuse-reports/{report_id} | | **lists.getListRecentActivity** | /lists/{list_id}/activity | | **lists.getListClients** | /lists/{list_id}/clients | | **lists.getListGrowthHistory** | /lists/{list_id}/growth-history | | **lists.getListGrowthHistoryByMonth** | /lists/{list_id}/growth-history/{month} | | **lists.getListInterestCategories** | /lists/{list_id}/interest-categories | | **lists.getInterestCategory** | /lists/{list_id}/interest-categories/{interest_category_id} | | **lists.listInterestCategoryInterests** | /lists/{list_id}/interest-categories/{interest_category_id}/interests | | **lists.getInterestCategoryInterest** | /lists/{list_id}/interest-categories/{interest_category_id}/interests/{interest_id} | | **lists.getListLocations** | /lists/{list_id}/locations | | **lists.getListMembersInfo** | /lists/{list_id}/members | | **lists.getListMember** | /lists/{list_id}/members/{subscriber_hash} | | **lists.getListMemberActivity** | /lists/{list_id}/members/{subscriber_hash}/activity | | **lists.getListMemberActivityFeed** | /lists/{list_id}/members/{subscriber_hash}/activity-feed | | **lists.getListMemberEvents** | /lists/{list_id}/members/{subscriber_hash}/events | | **lists.getListMemberGoals** | /lists/{list_id}/members/{subscriber_hash}/goals | | **lists.getListMemberNotes** | /lists/{list_id}/members/{subscriber_hash}/notes | | **lists.getListMemberNote** | /lists/{list_id}/members/{subscriber_hash}/notes/{note_id} | | **lists.getListMergeFields** | /lists/{list_id}/merge-fields | | **lists.getListMergeField** | /lists/{list_id}/merge-fields/{merge_id} | | **lists.getSegment** | /lists/{list_id}/segments/{segment_id} | | **lists.getSegmentMembersList** | /lists/{list_id}/segments/{segment_id}/members | | **lists.getListSignupForms** | /lists/{list_id}/signup-forms | | **lists.getAllSurveysForList** | /lists/{list_id}/surveys | | **lists.getSurvey** | /lists/{list_id}/surveys/{survey_id} | | **lists.getListWebhooks** | /lists/{list_id}/webhooks | | **lists.getListWebhook** | /lists/{list_id}/webhooks/{webhook_id} | | **lists.updateList** | /lists/{list_id} | | **lists.updateInterestCategory** | /lists/{list_id}/interest-categories/{interest_category_id} | | **lists.updateInterestCategoryInterest** | /lists/{list_id}/interest-categories/{interest_category_id}/interests/{interest_id} | | **lists.updateListMember** | /lists/{list_id}/members/{subscriber_hash} | | **lists.updateListMemberNote** | /lists/{list_id}/members/{subscriber_hash}/notes/{note_id} | | **lists.updateListMergeField** | /lists/{list_id}/merge-fields/{merge_id} | | **lists.updateSegment** | /lists/{list_id}/segments/{segment_id} | | **lists.updateListWebhook** | /lists/{list_id}/webhooks/{webhook_id} | | **lists.createListMemberEvent** | /lists/{list_id}/members/{subscriber_hash}/events | | **lists.updateListMemberTags** | /lists/{list_id}/members/{subscriber_hash}/tags | | **lists.createList** | /lists | | **lists.batchListMembers** | /lists/{list_id} | | **lists.createListInterestCategory** | /lists/{list_id}/interest-categories | | **lists.createInterestCategoryInterest** | /lists/{list_id}/interest-categories/{interest_category_id}/interests | | **lists.addListMember** | /lists/{list_id}/members | | **lists.deleteListMemberPermanent** | /lists/{list_id}/members/{subscriber_hash}/actions/delete-permanent | | **lists.createListMemberNote** | /lists/{list_id}/members/{subscriber_hash}/notes | | **lists.addListMergeField** | /lists/{list_id}/merge-fields | | **lists.createSegment** | /lists/{list_id}/segments | | **lists.batchSegmentMembers** | /lists/{list_id}/segments/{segment_id} | | **lists.createSegmentMember** | /lists/{list_id}/segments/{segment_id}/members | | **lists.updateListSignupForm** | /lists/{list_id}/signup-forms | | **lists.createListWebhook** | /lists/{list_id}/webhooks | | **lists.listSegments** | /lists/{list_id}/segments | | **lists.setListMember** | /lists/{list_id}/members/{subscriber_hash} | | **lists.tagSearch** | /lists/{list_id}/tag-search | | **ping.get** | /ping | | **reporting.getFacebookAdsReportAll** | /reporting/facebook-ads | | **reporting.getFacebookAdReport** | /reporting/facebook-ads/{outreach_id} | | **reporting.getFacebookAdProductActivityReport** | /reporting/facebook-ads/{outreach_id}/ecommerce-product-activity | | **reporting.getLandingPageReportsAll** | /reporting/landing-pages | | **reporting.getLandingPageReport** | /reporting/landing-pages/{outreach_id} | | **reporting.getSurveyReportsAll** | /reporting/surveys | | **reporting.getSurveyReport** | /reporting/surveys/{outreach_id} | | **reporting.getSurveyQuestionReportsAll** | /reporting/surveys/{outreach_id}/questions | | **reporting.getSurveyQuestionReport** | /reporting/surveys/{outreach_id}/questions/{question_id} | | **reporting.getSurveyQuestionAnswers** | /reporting/surveys/{outreach_id}/questions/{question_id}/answers | | **reporting.getSurveyResponsesAll** | /reporting/surveys/{outreach_id}/responses | | **reporting.getSurveyResponse** | /reporting/surveys/{outreach_id}/responses/{response_id} | | **reports.getAllCampaignReports** | /reports | | **reports.getCampaignReport** | /reports/{campaign_id} | | **reports.getCampaignAbuseReports** | /reports/{campaign_id}/abuse-reports | | **reports.getCampaignAbuseReport** | /reports/{campaign_id}/abuse-reports/{report_id} | | **reports.getCampaignAdvice** | /reports/{campaign_id}/advice | | **reports.getCampaignClickDetails** | /reports/{campaign_id}/click-details | | **reports.getCampaignClickDetailsForLink** | /reports/{campaign_id}/click-details/{link_id} | | **reports.getSubscribersInfo** | /reports/{campaign_id}/click-details/{link_id}/members | | **reports.getSubscriberInfo** | /reports/{campaign_id}/click-details/{link_id}/members/{subscriber_hash} | | **reports.getDomainPerformanceForCampaign** | /reports/{campaign_id}/domain-performance | | **reports.getEcommerceProductActivityForCampaign** | /reports/{campaign_id}/ecommerce-product-activity | | **reports.getEepurlActivityForCampaign** | /reports/{campaign_id}/eepurl | | **reports.getEmailActivityForCampaign** | /reports/{campaign_id}/email-activity | | **reports.getEmailActivityForSubscriber** | /reports/{campaign_id}/email-activity/{subscriber_hash} | | **reports.getLocationsForCampaign** | /reports/{campaign_id}/locations | | **reports.getCampaignOpenDetails** | /reports/{campaign_id}/open-details | | **reports.getSubscriberInfoForOpenedCampaign** | /reports/{campaign_id}/open-details/{subscriber_hash} | | **reports.getCampaignRecipients** | /reports/{campaign_id}/sent-to | | **reports.getCampaignRecipient** | /reports/{campaign_id}/sent-to/{subscriber_hash} | | **reports.getSubReportsForCampaign** | /reports/{campaign_id}/sub-reports | | **reports.getUnsubscribedListForCampaign** | /reports/{campaign_id}/unsubscribed | | **reports.getUnsubscribedListMember** | /reports/{campaign_id}/unsubscribed/{subscriber_hash} | | **root.getRoot** | / | | **searchCampaigns.search** | /search-campaigns | | **searchMembers.search** | /search-members | | **Surveys.publishSurvey** | /lists/{list_id}/surveys/{survey_id}/actions/publish | | **Surveys.unpublishSurvey** | /lists/{list_id}/surveys/{survey_id}/actions/unpublish | | **templateFolders.remove** | /template-folders/{folder_id} | | **templateFolders.list** | /template-folders | | **templateFolders.get** | /template-folders/{folder_id} | | **templateFolders.update** | /template-folders/{folder_id} | | **templateFolders.create** | /template-folders | | **templates.deleteTemplate** | /templates/{template_id} | | **templates.list** | /templates | | **templates.getTemplate** | /templates/{template_id} | | **templates.getDefaultContentForTemplate** | /templates/{template_id}/default-content | | **templates.updateTemplate** | /templates/{template_id} | | **templates.create** | /templates | | **verifiedDomains.createVerifiedDomain** | /verified-domains | | **verifiedDomains.deleteDomain** | /verified-domains/{domain_name} | | **verifiedDomains.getDomain** | /verified-domains/{domain_name} | | **verifiedDomains.getVerifiedDomainsAll** | /verified-domains | | **verifiedDomains.submitDomainVerification** | /verified-domains/{domain_name}/actions/verify | ## Additional Libraries Mailchimp Marketing libraries are available in the following languages: ================================================ FILE: composer.json ================================================ { "name": "mailchimp/marketing", "version": "3.0.80", "description": "", "keywords": [ "swagger", "php", "sdk", "api" ], "homepage": "http://swagger.io", "license": "proprietary", "authors": [ { "name": "Mailchimp", "homepage": "https://github.com/mailchimp/mailchimp-marketing-php" } ], "require": { "php": ">=7.2", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", "guzzlehttp/psr7": "^1.7 || ^2.0", "guzzlehttp/guzzle": "^6.4 || ^7.2" }, "require-dev": { "phpunit/phpunit": "^7", "squizlabs/php_codesniffer": "~2.6", "friendsofphp/php-cs-fixer": "~2.12" }, "autoload": { "psr-4": { "MailchimpMarketing\\" : "lib/" } }, "autoload-dev": { "psr-4": { "MailchimpMarketing\\" : "test/" } } } ================================================ FILE: git_push.sh ================================================ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # # Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" git_user_id=$1 git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then git_user_id="mailchimp" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then git_repo_id="mailchimp-marketing-php" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi if [ "$release_note" = "" ]; then release_note="Minor update" echo "[INFO] No command line input provided. Set \$release_note to $release_note" fi # Initialize the local directory as a Git repository git init # Adds the files in the local repository and stages them for commit. git add . # Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote git_remote=`git remote` if [ "$git_remote" = "" ]; then # git remote not defined if [ "$GIT_TOKEN" = "" ]; then echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git else git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git fi fi git pull origin master # Pushes (Forces) the changes in the local repository up to the remote repository echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' ================================================ FILE: lib/Api/AccountExportApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function getAccountExports($export_id, $fields = null, $exclude_fields = null) { $response = $this->getAccountExportsWithHttpInfo($export_id, $fields, $exclude_fields); return $response; } public function getAccountExportsWithHttpInfo($export_id, $fields = null, $exclude_fields = null) { $request = $this->getAccountExportsRequest($export_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getAccountExportsRequest($export_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'export_id' is set if ($export_id === null || (is_array($export_id) && count($export_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $export_id when calling ' ); } $resourcePath = '/account-exports/{export_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($export_id !== null) { $resourcePath = str_replace( '{' . 'export_id' . '}', ObjectSerializer::toPathValue($export_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/AccountExportsApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function listAccountExports($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->listAccountExportsWithHttpInfo($fields, $exclude_fields, $count, $offset); return $response; } public function listAccountExportsWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->listAccountExportsRequest($fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listAccountExportsRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling AccountExportsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/account-exports'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function createAccountExport($body) { $response = $this->createAccountExportWithHttpInfo($body); return $response; } public function createAccountExportWithHttpInfo($body) { $request = $this->createAccountExportRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createAccountExportRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/account-exports'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/ActivityFeedApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function getChimpChatter($count = '10', $offset = '0') { $response = $this->getChimpChatterWithHttpInfo($count, $offset); return $response; } public function getChimpChatterWithHttpInfo($count = '10', $offset = '0') { $request = $this->getChimpChatterRequest($count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getChimpChatterRequest($count = '10', $offset = '0') { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ActivityFeedApi., must be smaller than or equal to 1000.'); } $resourcePath = '/activity-feed/chimp-chatter'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/AuthorizedAppsApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function list($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->listWithHttpInfo($fields, $exclude_fields, $count, $offset); return $response; } public function listWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->listRequest($fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling AuthorizedAppsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/authorized-apps'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function get($app_id, $fields = null, $exclude_fields = null) { $response = $this->getWithHttpInfo($app_id, $fields, $exclude_fields); return $response; } public function getWithHttpInfo($app_id, $fields = null, $exclude_fields = null) { $request = $this->getRequest($app_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getRequest($app_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'app_id' is set if ($app_id === null || (is_array($app_id) && count($app_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $app_id when calling ' ); } $resourcePath = '/authorized-apps/{app_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($app_id !== null) { $resourcePath = str_replace( '{' . 'app_id' . '}', ObjectSerializer::toPathValue($app_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/AutomationsApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function archive($workflow_id) { $this->archiveWithHttpInfo($workflow_id); } public function archiveWithHttpInfo($workflow_id) { $request = $this->archiveRequest($workflow_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function archiveRequest($workflow_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/actions/archive'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteWorkflowEmail($workflow_id, $workflow_email_id) { $this->deleteWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id); } public function deleteWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id) { $request = $this->deleteWorkflowEmailRequest($workflow_id, $workflow_email_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteWorkflowEmailRequest($workflow_id, $workflow_email_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function list($count = '10', $offset = '0', $fields = null, $exclude_fields = null, $before_create_time = null, $since_create_time = null, $before_start_time = null, $since_start_time = null, $status = null) { $response = $this->listWithHttpInfo($count, $offset, $fields, $exclude_fields, $before_create_time, $since_create_time, $before_start_time, $since_start_time, $status); return $response; } public function listWithHttpInfo($count = '10', $offset = '0', $fields = null, $exclude_fields = null, $before_create_time = null, $since_create_time = null, $before_start_time = null, $since_start_time = null, $status = null) { $request = $this->listRequest($count, $offset, $fields, $exclude_fields, $before_create_time, $since_create_time, $before_start_time, $since_start_time, $status); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listRequest($count = '10', $offset = '0', $fields = null, $exclude_fields = null, $before_create_time = null, $since_create_time = null, $before_start_time = null, $since_start_time = null, $status = null) { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling AutomationsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/automations'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($before_create_time !== null) { $queryParams['before_create_time'] = ObjectSerializer::toQueryValue($before_create_time); } // query params if ($since_create_time !== null) { $queryParams['since_create_time'] = ObjectSerializer::toQueryValue($since_create_time); } // query params if ($before_start_time !== null) { $queryParams['before_start_time'] = ObjectSerializer::toQueryValue($before_start_time); } // query params if ($since_start_time !== null) { $queryParams['since_start_time'] = ObjectSerializer::toQueryValue($since_start_time); } // query params if ($status !== null) { $queryParams['status'] = ObjectSerializer::toQueryValue($status); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function get($workflow_id, $fields = null, $exclude_fields = null) { $response = $this->getWithHttpInfo($workflow_id, $fields, $exclude_fields); return $response; } public function getWithHttpInfo($workflow_id, $fields = null, $exclude_fields = null) { $request = $this->getRequest($workflow_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getRequest($workflow_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } $resourcePath = '/automations/{workflow_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function listAllWorkflowEmails($workflow_id) { $response = $this->listAllWorkflowEmailsWithHttpInfo($workflow_id); return $response; } public function listAllWorkflowEmailsWithHttpInfo($workflow_id) { $request = $this->listAllWorkflowEmailsRequest($workflow_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listAllWorkflowEmailsRequest($workflow_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getWorkflowEmail($workflow_id, $workflow_email_id) { $response = $this->getWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id); return $response; } public function getWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id) { $request = $this->getWorkflowEmailRequest($workflow_id, $workflow_email_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getWorkflowEmailRequest($workflow_id, $workflow_email_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getWorkflowEmailSubscriberQueue($workflow_id, $workflow_email_id) { $response = $this->getWorkflowEmailSubscriberQueueWithHttpInfo($workflow_id, $workflow_email_id); return $response; } public function getWorkflowEmailSubscriberQueueWithHttpInfo($workflow_id, $workflow_email_id) { $request = $this->getWorkflowEmailSubscriberQueueRequest($workflow_id, $workflow_email_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getWorkflowEmailSubscriberQueueRequest($workflow_id, $workflow_email_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}/queue'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getWorkflowEmailSubscriber($workflow_id, $workflow_email_id, $subscriber_hash) { $response = $this->getWorkflowEmailSubscriberWithHttpInfo($workflow_id, $workflow_email_id, $subscriber_hash); return $response; } public function getWorkflowEmailSubscriberWithHttpInfo($workflow_id, $workflow_email_id, $subscriber_hash) { $request = $this->getWorkflowEmailSubscriberRequest($workflow_id, $workflow_email_id, $subscriber_hash); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getWorkflowEmailSubscriberRequest($workflow_id, $workflow_email_id, $subscriber_hash) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}/queue/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function listWorkflowEmailSubscribersRemoved($workflow_id) { $response = $this->listWorkflowEmailSubscribersRemovedWithHttpInfo($workflow_id); return $response; } public function listWorkflowEmailSubscribersRemovedWithHttpInfo($workflow_id) { $request = $this->listWorkflowEmailSubscribersRemovedRequest($workflow_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listWorkflowEmailSubscribersRemovedRequest($workflow_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/removed-subscribers'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getRemovedWorkflowEmailSubscriber($workflow_id, $subscriber_hash) { $response = $this->getRemovedWorkflowEmailSubscriberWithHttpInfo($workflow_id, $subscriber_hash); return $response; } public function getRemovedWorkflowEmailSubscriberWithHttpInfo($workflow_id, $subscriber_hash) { $request = $this->getRemovedWorkflowEmailSubscriberRequest($workflow_id, $subscriber_hash); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getRemovedWorkflowEmailSubscriberRequest($workflow_id, $subscriber_hash) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/automations/{workflow_id}/removed-subscribers/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateWorkflowEmail($workflow_id, $workflow_email_id, $body) { $response = $this->updateWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id, $body); return $response; } public function updateWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id, $body) { $request = $this->updateWorkflowEmailRequest($workflow_id, $workflow_email_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateWorkflowEmailRequest($workflow_id, $workflow_email_id, $body) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function create($body) { $response = $this->createWithHttpInfo($body); return $response; } public function createWithHttpInfo($body) { $request = $this->createRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/automations'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function pauseAllEmails($workflow_id) { $this->pauseAllEmailsWithHttpInfo($workflow_id); } public function pauseAllEmailsWithHttpInfo($workflow_id) { $request = $this->pauseAllEmailsRequest($workflow_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function pauseAllEmailsRequest($workflow_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/actions/pause-all-emails'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function startAllEmails($workflow_id) { $this->startAllEmailsWithHttpInfo($workflow_id); } public function startAllEmailsWithHttpInfo($workflow_id) { $request = $this->startAllEmailsRequest($workflow_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function startAllEmailsRequest($workflow_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/actions/start-all-emails'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function pauseWorkflowEmail($workflow_id, $workflow_email_id) { $this->pauseWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id); } public function pauseWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id) { $request = $this->pauseWorkflowEmailRequest($workflow_id, $workflow_email_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function pauseWorkflowEmailRequest($workflow_id, $workflow_email_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}/actions/pause'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function startWorkflowEmail($workflow_id, $workflow_email_id) { $this->startWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id); } public function startWorkflowEmailWithHttpInfo($workflow_id, $workflow_email_id) { $request = $this->startWorkflowEmailRequest($workflow_id, $workflow_email_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function startWorkflowEmailRequest($workflow_id, $workflow_email_id) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}/actions/start'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addWorkflowEmailSubscriber($workflow_id, $workflow_email_id, $body) { $response = $this->addWorkflowEmailSubscriberWithHttpInfo($workflow_id, $workflow_email_id, $body); return $response; } public function addWorkflowEmailSubscriberWithHttpInfo($workflow_id, $workflow_email_id, $body) { $request = $this->addWorkflowEmailSubscriberRequest($workflow_id, $workflow_email_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addWorkflowEmailSubscriberRequest($workflow_id, $workflow_email_id, $body) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'workflow_email_id' is set if ($workflow_email_id === null || (is_array($workflow_email_id) && count($workflow_email_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_email_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/automations/{workflow_id}/emails/{workflow_email_id}/queue'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // path params if ($workflow_email_id !== null) { $resourcePath = str_replace( '{' . 'workflow_email_id' . '}', ObjectSerializer::toPathValue($workflow_email_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function removeWorkflowEmailSubscriber($workflow_id, $body) { $response = $this->removeWorkflowEmailSubscriberWithHttpInfo($workflow_id, $body); return $response; } public function removeWorkflowEmailSubscriberWithHttpInfo($workflow_id, $body) { $request = $this->removeWorkflowEmailSubscriberRequest($workflow_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function removeWorkflowEmailSubscriberRequest($workflow_id, $body) { // verify the required parameter 'workflow_id' is set if ($workflow_id === null || (is_array($workflow_id) && count($workflow_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $workflow_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/automations/{workflow_id}/removed-subscribers'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($workflow_id !== null) { $resourcePath = str_replace( '{' . 'workflow_id' . '}', ObjectSerializer::toPathValue($workflow_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/BatchWebhooksApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function remove($batch_webhook_id) { $this->removeWithHttpInfo($batch_webhook_id); } public function removeWithHttpInfo($batch_webhook_id) { $request = $this->removeRequest($batch_webhook_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function removeRequest($batch_webhook_id) { // verify the required parameter 'batch_webhook_id' is set if ($batch_webhook_id === null || (is_array($batch_webhook_id) && count($batch_webhook_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $batch_webhook_id when calling ' ); } $resourcePath = '/batch-webhooks/{batch_webhook_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($batch_webhook_id !== null) { $resourcePath = str_replace( '{' . 'batch_webhook_id' . '}', ObjectSerializer::toPathValue($batch_webhook_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function get($batch_webhook_id, $fields = null, $exclude_fields = null) { $response = $this->getWithHttpInfo($batch_webhook_id, $fields, $exclude_fields); return $response; } public function getWithHttpInfo($batch_webhook_id, $fields = null, $exclude_fields = null) { $request = $this->getRequest($batch_webhook_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getRequest($batch_webhook_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'batch_webhook_id' is set if ($batch_webhook_id === null || (is_array($batch_webhook_id) && count($batch_webhook_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $batch_webhook_id when calling ' ); } $resourcePath = '/batch-webhooks/{batch_webhook_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($batch_webhook_id !== null) { $resourcePath = str_replace( '{' . 'batch_webhook_id' . '}', ObjectSerializer::toPathValue($batch_webhook_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function list($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->listWithHttpInfo($fields, $exclude_fields, $count, $offset); return $response; } public function listWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->listRequest($fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling BatchWebhooksApi., must be smaller than or equal to 1000.'); } $resourcePath = '/batch-webhooks'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function update($batch_webhook_id, $body) { $response = $this->updateWithHttpInfo($batch_webhook_id, $body); return $response; } public function updateWithHttpInfo($batch_webhook_id, $body) { $request = $this->updateRequest($batch_webhook_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateRequest($batch_webhook_id, $body) { // verify the required parameter 'batch_webhook_id' is set if ($batch_webhook_id === null || (is_array($batch_webhook_id) && count($batch_webhook_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $batch_webhook_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/batch-webhooks/{batch_webhook_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($batch_webhook_id !== null) { $resourcePath = str_replace( '{' . 'batch_webhook_id' . '}', ObjectSerializer::toPathValue($batch_webhook_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function create($body) { $response = $this->createWithHttpInfo($body); return $response; } public function createWithHttpInfo($body) { $request = $this->createRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/batch-webhooks'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/BatchesApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function deleteRequest($batch_id) { $this->deleteRequestWithHttpInfo($batch_id); } public function deleteRequestWithHttpInfo($batch_id) { $request = $this->deleteRequestRequest($batch_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteRequestRequest($batch_id) { // verify the required parameter 'batch_id' is set if ($batch_id === null || (is_array($batch_id) && count($batch_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $batch_id when calling ' ); } $resourcePath = '/batches/{batch_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($batch_id !== null) { $resourcePath = str_replace( '{' . 'batch_id' . '}', ObjectSerializer::toPathValue($batch_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function list($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->listWithHttpInfo($fields, $exclude_fields, $count, $offset); return $response; } public function listWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->listRequest($fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling BatchesApi., must be smaller than or equal to 1000.'); } $resourcePath = '/batches'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function status($batch_id, $fields = null, $exclude_fields = null) { $response = $this->statusWithHttpInfo($batch_id, $fields, $exclude_fields); return $response; } public function statusWithHttpInfo($batch_id, $fields = null, $exclude_fields = null) { $request = $this->statusRequest($batch_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function statusRequest($batch_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'batch_id' is set if ($batch_id === null || (is_array($batch_id) && count($batch_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $batch_id when calling ' ); } $resourcePath = '/batches/{batch_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($batch_id !== null) { $resourcePath = str_replace( '{' . 'batch_id' . '}', ObjectSerializer::toPathValue($batch_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function start($body) { $response = $this->startWithHttpInfo($body); return $response; } public function startWithHttpInfo($body) { $request = $this->startRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function startRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/batches'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/CampaignFoldersApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function remove($folder_id) { $this->removeWithHttpInfo($folder_id); } public function removeWithHttpInfo($folder_id) { $request = $this->removeRequest($folder_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function removeRequest($folder_id) { // verify the required parameter 'folder_id' is set if ($folder_id === null || (is_array($folder_id) && count($folder_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $folder_id when calling ' ); } $resourcePath = '/campaign-folders/{folder_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($folder_id !== null) { $resourcePath = str_replace( '{' . 'folder_id' . '}', ObjectSerializer::toPathValue($folder_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function list($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->listWithHttpInfo($fields, $exclude_fields, $count, $offset); return $response; } public function listWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->listRequest($fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling CampaignFoldersApi., must be smaller than or equal to 1000.'); } $resourcePath = '/campaign-folders'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function get($folder_id, $fields = null, $exclude_fields = null) { $response = $this->getWithHttpInfo($folder_id, $fields, $exclude_fields); return $response; } public function getWithHttpInfo($folder_id, $fields = null, $exclude_fields = null) { $request = $this->getRequest($folder_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getRequest($folder_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'folder_id' is set if ($folder_id === null || (is_array($folder_id) && count($folder_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $folder_id when calling ' ); } $resourcePath = '/campaign-folders/{folder_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($folder_id !== null) { $resourcePath = str_replace( '{' . 'folder_id' . '}', ObjectSerializer::toPathValue($folder_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function update($folder_id, $body) { $response = $this->updateWithHttpInfo($folder_id, $body); return $response; } public function updateWithHttpInfo($folder_id, $body) { $request = $this->updateRequest($folder_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateRequest($folder_id, $body) { // verify the required parameter 'folder_id' is set if ($folder_id === null || (is_array($folder_id) && count($folder_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $folder_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/campaign-folders/{folder_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($folder_id !== null) { $resourcePath = str_replace( '{' . 'folder_id' . '}', ObjectSerializer::toPathValue($folder_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function create($body) { $response = $this->createWithHttpInfo($body); return $response; } public function createWithHttpInfo($body) { $request = $this->createRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/campaign-folders'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/CampaignsApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function remove($campaign_id) { $this->removeWithHttpInfo($campaign_id); } public function removeWithHttpInfo($campaign_id) { $request = $this->removeRequest($campaign_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function removeRequest($campaign_id) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteFeedbackMessage($campaign_id, $feedback_id) { $this->deleteFeedbackMessageWithHttpInfo($campaign_id, $feedback_id); } public function deleteFeedbackMessageWithHttpInfo($campaign_id, $feedback_id) { $request = $this->deleteFeedbackMessageRequest($campaign_id, $feedback_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteFeedbackMessageRequest($campaign_id, $feedback_id) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'feedback_id' is set if ($feedback_id === null || (is_array($feedback_id) && count($feedback_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $feedback_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/feedback/{feedback_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // path params if ($feedback_id !== null) { $resourcePath = str_replace( '{' . 'feedback_id' . '}', ObjectSerializer::toPathValue($feedback_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function list($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $status = null, $before_send_time = null, $since_send_time = null, $before_create_time = null, $since_create_time = null, $list_id = null, $folder_id = null, $member_id = null, $sort_field = null, $sort_dir = null) { $response = $this->listWithHttpInfo($fields, $exclude_fields, $count, $offset, $type, $status, $before_send_time, $since_send_time, $before_create_time, $since_create_time, $list_id, $folder_id, $member_id, $sort_field, $sort_dir); return $response; } public function listWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $status = null, $before_send_time = null, $since_send_time = null, $before_create_time = null, $since_create_time = null, $list_id = null, $folder_id = null, $member_id = null, $sort_field = null, $sort_dir = null) { $request = $this->listRequest($fields, $exclude_fields, $count, $offset, $type, $status, $before_send_time, $since_send_time, $before_create_time, $since_create_time, $list_id, $folder_id, $member_id, $sort_field, $sort_dir); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $status = null, $before_send_time = null, $since_send_time = null, $before_create_time = null, $since_create_time = null, $list_id = null, $folder_id = null, $member_id = null, $sort_field = null, $sort_dir = null) { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling CampaignsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/campaigns'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($type !== null) { $queryParams['type'] = ObjectSerializer::toQueryValue($type); } // query params if ($status !== null) { $queryParams['status'] = ObjectSerializer::toQueryValue($status); } // query params if ($before_send_time !== null) { $queryParams['before_send_time'] = ObjectSerializer::toQueryValue($before_send_time); } // query params if ($since_send_time !== null) { $queryParams['since_send_time'] = ObjectSerializer::toQueryValue($since_send_time); } // query params if ($before_create_time !== null) { $queryParams['before_create_time'] = ObjectSerializer::toQueryValue($before_create_time); } // query params if ($since_create_time !== null) { $queryParams['since_create_time'] = ObjectSerializer::toQueryValue($since_create_time); } // query params if ($list_id !== null) { $queryParams['list_id'] = ObjectSerializer::toQueryValue($list_id); } // query params if ($folder_id !== null) { $queryParams['folder_id'] = ObjectSerializer::toQueryValue($folder_id); } // query params if ($member_id !== null) { $queryParams['member_id'] = ObjectSerializer::toQueryValue($member_id); } // query params if ($sort_field !== null) { $queryParams['sort_field'] = ObjectSerializer::toQueryValue($sort_field); } // query params if ($sort_dir !== null) { $queryParams['sort_dir'] = ObjectSerializer::toQueryValue($sort_dir); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function get($campaign_id, $fields = null, $exclude_fields = null) { $response = $this->getWithHttpInfo($campaign_id, $fields, $exclude_fields); return $response; } public function getWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null) { $request = $this->getRequest($campaign_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getRequest($campaign_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getContent($campaign_id, $fields = null, $exclude_fields = null) { $response = $this->getContentWithHttpInfo($campaign_id, $fields, $exclude_fields); return $response; } public function getContentWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null) { $request = $this->getContentRequest($campaign_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getContentRequest($campaign_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/content'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getFeedback($campaign_id, $fields = null, $exclude_fields = null) { $response = $this->getFeedbackWithHttpInfo($campaign_id, $fields, $exclude_fields); return $response; } public function getFeedbackWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null) { $request = $this->getFeedbackRequest($campaign_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getFeedbackRequest($campaign_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/feedback'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getFeedbackMessage($campaign_id, $feedback_id, $fields = null, $exclude_fields = null) { $response = $this->getFeedbackMessageWithHttpInfo($campaign_id, $feedback_id, $fields, $exclude_fields); return $response; } public function getFeedbackMessageWithHttpInfo($campaign_id, $feedback_id, $fields = null, $exclude_fields = null) { $request = $this->getFeedbackMessageRequest($campaign_id, $feedback_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getFeedbackMessageRequest($campaign_id, $feedback_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'feedback_id' is set if ($feedback_id === null || (is_array($feedback_id) && count($feedback_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $feedback_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/feedback/{feedback_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // path params if ($feedback_id !== null) { $resourcePath = str_replace( '{' . 'feedback_id' . '}', ObjectSerializer::toPathValue($feedback_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSendChecklist($campaign_id, $fields = null, $exclude_fields = null) { $response = $this->getSendChecklistWithHttpInfo($campaign_id, $fields, $exclude_fields); return $response; } public function getSendChecklistWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null) { $request = $this->getSendChecklistRequest($campaign_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSendChecklistRequest($campaign_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/send-checklist'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function update($campaign_id, $body) { $response = $this->updateWithHttpInfo($campaign_id, $body); return $response; } public function updateWithHttpInfo($campaign_id, $body) { $request = $this->updateRequest($campaign_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateRequest($campaign_id, $body) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/campaigns/{campaign_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateFeedbackMessage($campaign_id, $feedback_id, $body) { $response = $this->updateFeedbackMessageWithHttpInfo($campaign_id, $feedback_id, $body); return $response; } public function updateFeedbackMessageWithHttpInfo($campaign_id, $feedback_id, $body) { $request = $this->updateFeedbackMessageRequest($campaign_id, $feedback_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateFeedbackMessageRequest($campaign_id, $feedback_id, $body) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'feedback_id' is set if ($feedback_id === null || (is_array($feedback_id) && count($feedback_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $feedback_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/feedback/{feedback_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // path params if ($feedback_id !== null) { $resourcePath = str_replace( '{' . 'feedback_id' . '}', ObjectSerializer::toPathValue($feedback_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function create($body) { $response = $this->createWithHttpInfo($body); return $response; } public function createWithHttpInfo($body) { $request = $this->createRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/campaigns'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function cancelSend($campaign_id) { $this->cancelSendWithHttpInfo($campaign_id); } public function cancelSendWithHttpInfo($campaign_id) { $request = $this->cancelSendRequest($campaign_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function cancelSendRequest($campaign_id) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/actions/cancel-send'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function createResend($campaign_id) { $response = $this->createResendWithHttpInfo($campaign_id); return $response; } public function createResendWithHttpInfo($campaign_id) { $request = $this->createResendRequest($campaign_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createResendRequest($campaign_id) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/actions/create-resend'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function pause($campaign_id) { $this->pauseWithHttpInfo($campaign_id); } public function pauseWithHttpInfo($campaign_id) { $request = $this->pauseRequest($campaign_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function pauseRequest($campaign_id) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/actions/pause'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function replicate($campaign_id) { $response = $this->replicateWithHttpInfo($campaign_id); return $response; } public function replicateWithHttpInfo($campaign_id) { $request = $this->replicateRequest($campaign_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function replicateRequest($campaign_id) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/actions/replicate'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function resume($campaign_id) { $this->resumeWithHttpInfo($campaign_id); } public function resumeWithHttpInfo($campaign_id) { $request = $this->resumeRequest($campaign_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function resumeRequest($campaign_id) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/actions/resume'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function schedule($campaign_id, $body) { $this->scheduleWithHttpInfo($campaign_id, $body); } public function scheduleWithHttpInfo($campaign_id, $body) { $request = $this->scheduleRequest($campaign_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function scheduleRequest($campaign_id, $body) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/actions/schedule'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function send($campaign_id) { $this->sendWithHttpInfo($campaign_id); } public function sendWithHttpInfo($campaign_id) { $request = $this->sendRequest($campaign_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function sendRequest($campaign_id) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/actions/send'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function sendTestEmail($campaign_id, $body) { $this->sendTestEmailWithHttpInfo($campaign_id, $body); } public function sendTestEmailWithHttpInfo($campaign_id, $body) { $request = $this->sendTestEmailRequest($campaign_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function sendTestEmailRequest($campaign_id, $body) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/actions/test'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function unschedule($campaign_id) { $this->unscheduleWithHttpInfo($campaign_id); } public function unscheduleWithHttpInfo($campaign_id) { $request = $this->unscheduleRequest($campaign_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function unscheduleRequest($campaign_id) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/actions/unschedule'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addFeedback($campaign_id, $body) { $response = $this->addFeedbackWithHttpInfo($campaign_id, $body); return $response; } public function addFeedbackWithHttpInfo($campaign_id, $body) { $request = $this->addFeedbackRequest($campaign_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addFeedbackRequest($campaign_id, $body) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/feedback'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function setContent($campaign_id, $body) { $response = $this->setContentWithHttpInfo($campaign_id, $body); return $response; } public function setContentWithHttpInfo($campaign_id, $body) { $request = $this->setContentRequest($campaign_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function setContentRequest($campaign_id, $body) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/campaigns/{campaign_id}/content'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PUT', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/ConnectedSitesApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function remove($connected_site_id) { $this->removeWithHttpInfo($connected_site_id); } public function removeWithHttpInfo($connected_site_id) { $request = $this->removeRequest($connected_site_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function removeRequest($connected_site_id) { // verify the required parameter 'connected_site_id' is set if ($connected_site_id === null || (is_array($connected_site_id) && count($connected_site_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $connected_site_id when calling ' ); } $resourcePath = '/connected-sites/{connected_site_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($connected_site_id !== null) { $resourcePath = str_replace( '{' . 'connected_site_id' . '}', ObjectSerializer::toPathValue($connected_site_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function list($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->listWithHttpInfo($fields, $exclude_fields, $count, $offset); return $response; } public function listWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->listRequest($fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ConnectedSitesApi., must be smaller than or equal to 1000.'); } $resourcePath = '/connected-sites'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function get($connected_site_id, $fields = null, $exclude_fields = null) { $response = $this->getWithHttpInfo($connected_site_id, $fields, $exclude_fields); return $response; } public function getWithHttpInfo($connected_site_id, $fields = null, $exclude_fields = null) { $request = $this->getRequest($connected_site_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getRequest($connected_site_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'connected_site_id' is set if ($connected_site_id === null || (is_array($connected_site_id) && count($connected_site_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $connected_site_id when calling ' ); } $resourcePath = '/connected-sites/{connected_site_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($connected_site_id !== null) { $resourcePath = str_replace( '{' . 'connected_site_id' . '}', ObjectSerializer::toPathValue($connected_site_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function create($body) { $response = $this->createWithHttpInfo($body); return $response; } public function createWithHttpInfo($body) { $request = $this->createRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/connected-sites'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function verifyScriptInstallation($connected_site_id) { $this->verifyScriptInstallationWithHttpInfo($connected_site_id); } public function verifyScriptInstallationWithHttpInfo($connected_site_id) { $request = $this->verifyScriptInstallationRequest($connected_site_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function verifyScriptInstallationRequest($connected_site_id) { // verify the required parameter 'connected_site_id' is set if ($connected_site_id === null || (is_array($connected_site_id) && count($connected_site_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $connected_site_id when calling ' ); } $resourcePath = '/connected-sites/{connected_site_id}/actions/verify-script-installation'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($connected_site_id !== null) { $resourcePath = str_replace( '{' . 'connected_site_id' . '}', ObjectSerializer::toPathValue($connected_site_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/ConversationsApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function list($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $has_unread_messages = null, $list_id = null, $campaign_id = null) { $response = $this->listWithHttpInfo($fields, $exclude_fields, $count, $offset, $has_unread_messages, $list_id, $campaign_id); return $response; } public function listWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $has_unread_messages = null, $list_id = null, $campaign_id = null) { $request = $this->listRequest($fields, $exclude_fields, $count, $offset, $has_unread_messages, $list_id, $campaign_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $has_unread_messages = null, $list_id = null, $campaign_id = null) { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ConversationsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/conversations'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($has_unread_messages !== null) { $queryParams['has_unread_messages'] = ObjectSerializer::toQueryValue($has_unread_messages); } // query params if ($list_id !== null) { $queryParams['list_id'] = ObjectSerializer::toQueryValue($list_id); } // query params if ($campaign_id !== null) { $queryParams['campaign_id'] = ObjectSerializer::toQueryValue($campaign_id); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function get($conversation_id, $fields = null, $exclude_fields = null) { $response = $this->getWithHttpInfo($conversation_id, $fields, $exclude_fields); return $response; } public function getWithHttpInfo($conversation_id, $fields = null, $exclude_fields = null) { $request = $this->getRequest($conversation_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getRequest($conversation_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'conversation_id' is set if ($conversation_id === null || (is_array($conversation_id) && count($conversation_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $conversation_id when calling ' ); } $resourcePath = '/conversations/{conversation_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($conversation_id !== null) { $resourcePath = str_replace( '{' . 'conversation_id' . '}', ObjectSerializer::toPathValue($conversation_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getConversationMessages($conversation_id, $fields = null, $exclude_fields = null, $is_read = null, $before_timestamp = null, $since_timestamp = null) { $response = $this->getConversationMessagesWithHttpInfo($conversation_id, $fields, $exclude_fields, $is_read, $before_timestamp, $since_timestamp); return $response; } public function getConversationMessagesWithHttpInfo($conversation_id, $fields = null, $exclude_fields = null, $is_read = null, $before_timestamp = null, $since_timestamp = null) { $request = $this->getConversationMessagesRequest($conversation_id, $fields, $exclude_fields, $is_read, $before_timestamp, $since_timestamp); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getConversationMessagesRequest($conversation_id, $fields = null, $exclude_fields = null, $is_read = null, $before_timestamp = null, $since_timestamp = null) { // verify the required parameter 'conversation_id' is set if ($conversation_id === null || (is_array($conversation_id) && count($conversation_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $conversation_id when calling ' ); } $resourcePath = '/conversations/{conversation_id}/messages'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($is_read !== null) { $queryParams['is_read'] = ObjectSerializer::toQueryValue($is_read); } // query params if ($before_timestamp !== null) { $queryParams['before_timestamp'] = ObjectSerializer::toQueryValue($before_timestamp); } // query params if ($since_timestamp !== null) { $queryParams['since_timestamp'] = ObjectSerializer::toQueryValue($since_timestamp); } // path params if ($conversation_id !== null) { $resourcePath = str_replace( '{' . 'conversation_id' . '}', ObjectSerializer::toPathValue($conversation_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getConversationMessage($conversation_id, $message_id, $fields = null, $exclude_fields = null) { $response = $this->getConversationMessageWithHttpInfo($conversation_id, $message_id, $fields, $exclude_fields); return $response; } public function getConversationMessageWithHttpInfo($conversation_id, $message_id, $fields = null, $exclude_fields = null) { $request = $this->getConversationMessageRequest($conversation_id, $message_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getConversationMessageRequest($conversation_id, $message_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'conversation_id' is set if ($conversation_id === null || (is_array($conversation_id) && count($conversation_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $conversation_id when calling ' ); } // verify the required parameter 'message_id' is set if ($message_id === null || (is_array($message_id) && count($message_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $message_id when calling ' ); } $resourcePath = '/conversations/{conversation_id}/messages/{message_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($conversation_id !== null) { $resourcePath = str_replace( '{' . 'conversation_id' . '}', ObjectSerializer::toPathValue($conversation_id), $resourcePath ); } // path params if ($message_id !== null) { $resourcePath = str_replace( '{' . 'message_id' . '}', ObjectSerializer::toPathValue($message_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/CustomerJourneysApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function trigger($journey_id, $step_id, $body) { $response = $this->triggerWithHttpInfo($journey_id, $step_id, $body); return $response; } public function triggerWithHttpInfo($journey_id, $step_id, $body) { $request = $this->triggerRequest($journey_id, $step_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function triggerRequest($journey_id, $step_id, $body) { // verify the required parameter 'journey_id' is set if ($journey_id === null || (is_array($journey_id) && count($journey_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $journey_id when calling ' ); } // verify the required parameter 'step_id' is set if ($step_id === null || (is_array($step_id) && count($step_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $step_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/customer-journeys/journeys/{journey_id}/steps/{step_id}/actions/trigger'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($journey_id !== null) { $resourcePath = str_replace( '{' . 'journey_id' . '}', ObjectSerializer::toPathValue($journey_id), $resourcePath ); } // path params if ($step_id !== null) { $resourcePath = str_replace( '{' . 'step_id' . '}', ObjectSerializer::toPathValue($step_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/EcommerceApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function deleteStore($store_id) { $response = $this->deleteStoreWithHttpInfo($store_id); return $response; } public function deleteStoreWithHttpInfo($store_id) { $request = $this->deleteStoreRequest($store_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteStoreRequest($store_id) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteStoreCart($store_id, $cart_id) { $this->deleteStoreCartWithHttpInfo($store_id, $cart_id); } public function deleteStoreCartWithHttpInfo($store_id, $cart_id) { $request = $this->deleteStoreCartRequest($store_id, $cart_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteStoreCartRequest($store_id, $cart_id) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'cart_id' is set if ($cart_id === null || (is_array($cart_id) && count($cart_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $cart_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/carts/{cart_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($cart_id !== null) { $resourcePath = str_replace( '{' . 'cart_id' . '}', ObjectSerializer::toPathValue($cart_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteCartLineItem($store_id, $cart_id, $line_id) { $this->deleteCartLineItemWithHttpInfo($store_id, $cart_id, $line_id); } public function deleteCartLineItemWithHttpInfo($store_id, $cart_id, $line_id) { $request = $this->deleteCartLineItemRequest($store_id, $cart_id, $line_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteCartLineItemRequest($store_id, $cart_id, $line_id) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'cart_id' is set if ($cart_id === null || (is_array($cart_id) && count($cart_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $cart_id when calling ' ); } // verify the required parameter 'line_id' is set if ($line_id === null || (is_array($line_id) && count($line_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $line_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/carts/{cart_id}/lines/{line_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($cart_id !== null) { $resourcePath = str_replace( '{' . 'cart_id' . '}', ObjectSerializer::toPathValue($cart_id), $resourcePath ); } // path params if ($line_id !== null) { $resourcePath = str_replace( '{' . 'line_id' . '}', ObjectSerializer::toPathValue($line_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteStoreCustomer($store_id, $customer_id) { $this->deleteStoreCustomerWithHttpInfo($store_id, $customer_id); } public function deleteStoreCustomerWithHttpInfo($store_id, $customer_id) { $request = $this->deleteStoreCustomerRequest($store_id, $customer_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteStoreCustomerRequest($store_id, $customer_id) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'customer_id' is set if ($customer_id === null || (is_array($customer_id) && count($customer_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $customer_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/customers/{customer_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($customer_id !== null) { $resourcePath = str_replace( '{' . 'customer_id' . '}', ObjectSerializer::toPathValue($customer_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteOrder($store_id, $order_id) { $this->deleteOrderWithHttpInfo($store_id, $order_id); } public function deleteOrderWithHttpInfo($store_id, $order_id) { $request = $this->deleteOrderRequest($store_id, $order_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteOrderRequest($store_id, $order_id) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'order_id' is set if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $order_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/orders/{order_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($order_id !== null) { $resourcePath = str_replace( '{' . 'order_id' . '}', ObjectSerializer::toPathValue($order_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteOrderLineItem($store_id, $order_id, $line_id) { $this->deleteOrderLineItemWithHttpInfo($store_id, $order_id, $line_id); } public function deleteOrderLineItemWithHttpInfo($store_id, $order_id, $line_id) { $request = $this->deleteOrderLineItemRequest($store_id, $order_id, $line_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteOrderLineItemRequest($store_id, $order_id, $line_id) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'order_id' is set if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $order_id when calling ' ); } // verify the required parameter 'line_id' is set if ($line_id === null || (is_array($line_id) && count($line_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $line_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/orders/{order_id}/lines/{line_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($order_id !== null) { $resourcePath = str_replace( '{' . 'order_id' . '}', ObjectSerializer::toPathValue($order_id), $resourcePath ); } // path params if ($line_id !== null) { $resourcePath = str_replace( '{' . 'line_id' . '}', ObjectSerializer::toPathValue($line_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteStoreProduct($store_id, $product_id) { $this->deleteStoreProductWithHttpInfo($store_id, $product_id); } public function deleteStoreProductWithHttpInfo($store_id, $product_id) { $request = $this->deleteStoreProductRequest($store_id, $product_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteStoreProductRequest($store_id, $product_id) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteProductImage($store_id, $product_id, $image_id) { $this->deleteProductImageWithHttpInfo($store_id, $product_id, $image_id); } public function deleteProductImageWithHttpInfo($store_id, $product_id, $image_id) { $request = $this->deleteProductImageRequest($store_id, $product_id, $image_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteProductImageRequest($store_id, $product_id, $image_id) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } // verify the required parameter 'image_id' is set if ($image_id === null || (is_array($image_id) && count($image_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $image_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}/images/{image_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // path params if ($image_id !== null) { $resourcePath = str_replace( '{' . 'image_id' . '}', ObjectSerializer::toPathValue($image_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteProductVariant($store_id, $product_id, $variant_id) { $this->deleteProductVariantWithHttpInfo($store_id, $product_id, $variant_id); } public function deleteProductVariantWithHttpInfo($store_id, $product_id, $variant_id) { $request = $this->deleteProductVariantRequest($store_id, $product_id, $variant_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteProductVariantRequest($store_id, $product_id, $variant_id) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } // verify the required parameter 'variant_id' is set if ($variant_id === null || (is_array($variant_id) && count($variant_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $variant_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}/variants/{variant_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // path params if ($variant_id !== null) { $resourcePath = str_replace( '{' . 'variant_id' . '}', ObjectSerializer::toPathValue($variant_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deletePromoCode($store_id, $promo_rule_id, $promo_code_id) { $this->deletePromoCodeWithHttpInfo($store_id, $promo_rule_id, $promo_code_id); } public function deletePromoCodeWithHttpInfo($store_id, $promo_rule_id, $promo_code_id) { $request = $this->deletePromoCodeRequest($store_id, $promo_rule_id, $promo_code_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deletePromoCodeRequest($store_id, $promo_rule_id, $promo_code_id) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'promo_rule_id' is set if ($promo_rule_id === null || (is_array($promo_rule_id) && count($promo_rule_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $promo_rule_id when calling ' ); } // verify the required parameter 'promo_code_id' is set if ($promo_code_id === null || (is_array($promo_code_id) && count($promo_code_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $promo_code_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/promo-rules/{promo_rule_id}/promo-codes/{promo_code_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($promo_rule_id !== null) { $resourcePath = str_replace( '{' . 'promo_rule_id' . '}', ObjectSerializer::toPathValue($promo_rule_id), $resourcePath ); } // path params if ($promo_code_id !== null) { $resourcePath = str_replace( '{' . 'promo_code_id' . '}', ObjectSerializer::toPathValue($promo_code_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deletePromoRule($store_id, $promo_rule_id) { $this->deletePromoRuleWithHttpInfo($store_id, $promo_rule_id); } public function deletePromoRuleWithHttpInfo($store_id, $promo_rule_id) { $request = $this->deletePromoRuleRequest($store_id, $promo_rule_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deletePromoRuleRequest($store_id, $promo_rule_id) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'promo_rule_id' is set if ($promo_rule_id === null || (is_array($promo_rule_id) && count($promo_rule_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $promo_rule_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/promo-rules/{promo_rule_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($promo_rule_id !== null) { $resourcePath = str_replace( '{' . 'promo_rule_id' . '}', ObjectSerializer::toPathValue($promo_rule_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function orders($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $campaign_id = null, $outreach_id = null, $customer_id = null, $has_outreach = null) { $response = $this->ordersWithHttpInfo($fields, $exclude_fields, $count, $offset, $campaign_id, $outreach_id, $customer_id, $has_outreach); return $response; } public function ordersWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $campaign_id = null, $outreach_id = null, $customer_id = null, $has_outreach = null) { $request = $this->ordersRequest($fields, $exclude_fields, $count, $offset, $campaign_id, $outreach_id, $customer_id, $has_outreach); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function ordersRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $campaign_id = null, $outreach_id = null, $customer_id = null, $has_outreach = null) { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling EcommerceApi., must be smaller than or equal to 1000.'); } $resourcePath = '/ecommerce/orders'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($campaign_id !== null) { $queryParams['campaign_id'] = ObjectSerializer::toQueryValue($campaign_id); } // query params if ($outreach_id !== null) { $queryParams['outreach_id'] = ObjectSerializer::toQueryValue($outreach_id); } // query params if ($customer_id !== null) { $queryParams['customer_id'] = ObjectSerializer::toQueryValue($customer_id); } // query params if ($has_outreach !== null) { $queryParams['has_outreach'] = ObjectSerializer::toQueryValue($has_outreach); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function stores($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->storesWithHttpInfo($fields, $exclude_fields, $count, $offset); return $response; } public function storesWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->storesRequest($fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function storesRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling EcommerceApi., must be smaller than or equal to 1000.'); } $resourcePath = '/ecommerce/stores'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getStore($store_id, $fields = null, $exclude_fields = null) { $response = $this->getStoreWithHttpInfo($store_id, $fields, $exclude_fields); return $response; } public function getStoreWithHttpInfo($store_id, $fields = null, $exclude_fields = null) { $request = $this->getStoreRequest($store_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getStoreRequest($store_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getStoreCarts($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getStoreCartsWithHttpInfo($store_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getStoreCartsWithHttpInfo($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getStoreCartsRequest($store_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getStoreCartsRequest($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling EcommerceApi., must be smaller than or equal to 1000.'); } $resourcePath = '/ecommerce/stores/{store_id}/carts'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getStoreCart($store_id, $cart_id, $fields = null, $exclude_fields = null) { $response = $this->getStoreCartWithHttpInfo($store_id, $cart_id, $fields, $exclude_fields); return $response; } public function getStoreCartWithHttpInfo($store_id, $cart_id, $fields = null, $exclude_fields = null) { $request = $this->getStoreCartRequest($store_id, $cart_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getStoreCartRequest($store_id, $cart_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'cart_id' is set if ($cart_id === null || (is_array($cart_id) && count($cart_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $cart_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/carts/{cart_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($cart_id !== null) { $resourcePath = str_replace( '{' . 'cart_id' . '}', ObjectSerializer::toPathValue($cart_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getAllCartLineItems($store_id, $cart_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getAllCartLineItemsWithHttpInfo($store_id, $cart_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getAllCartLineItemsWithHttpInfo($store_id, $cart_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getAllCartLineItemsRequest($store_id, $cart_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getAllCartLineItemsRequest($store_id, $cart_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'cart_id' is set if ($cart_id === null || (is_array($cart_id) && count($cart_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $cart_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling EcommerceApi., must be smaller than or equal to 1000.'); } $resourcePath = '/ecommerce/stores/{store_id}/carts/{cart_id}/lines'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($cart_id !== null) { $resourcePath = str_replace( '{' . 'cart_id' . '}', ObjectSerializer::toPathValue($cart_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getCartLineItem($store_id, $cart_id, $line_id, $fields = null, $exclude_fields = null) { $response = $this->getCartLineItemWithHttpInfo($store_id, $cart_id, $line_id, $fields, $exclude_fields); return $response; } public function getCartLineItemWithHttpInfo($store_id, $cart_id, $line_id, $fields = null, $exclude_fields = null) { $request = $this->getCartLineItemRequest($store_id, $cart_id, $line_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getCartLineItemRequest($store_id, $cart_id, $line_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'cart_id' is set if ($cart_id === null || (is_array($cart_id) && count($cart_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $cart_id when calling ' ); } // verify the required parameter 'line_id' is set if ($line_id === null || (is_array($line_id) && count($line_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $line_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/carts/{cart_id}/lines/{line_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($cart_id !== null) { $resourcePath = str_replace( '{' . 'cart_id' . '}', ObjectSerializer::toPathValue($cart_id), $resourcePath ); } // path params if ($line_id !== null) { $resourcePath = str_replace( '{' . 'line_id' . '}', ObjectSerializer::toPathValue($line_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getAllStoreCustomers($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $email_address = null) { $response = $this->getAllStoreCustomersWithHttpInfo($store_id, $fields, $exclude_fields, $count, $offset, $email_address); return $response; } public function getAllStoreCustomersWithHttpInfo($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $email_address = null) { $request = $this->getAllStoreCustomersRequest($store_id, $fields, $exclude_fields, $count, $offset, $email_address); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getAllStoreCustomersRequest($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $email_address = null) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling EcommerceApi., must be smaller than or equal to 1000.'); } $resourcePath = '/ecommerce/stores/{store_id}/customers'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($email_address !== null) { $queryParams['email_address'] = ObjectSerializer::toQueryValue($email_address); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getStoreCustomer($store_id, $customer_id, $fields = null, $exclude_fields = null) { $response = $this->getStoreCustomerWithHttpInfo($store_id, $customer_id, $fields, $exclude_fields); return $response; } public function getStoreCustomerWithHttpInfo($store_id, $customer_id, $fields = null, $exclude_fields = null) { $request = $this->getStoreCustomerRequest($store_id, $customer_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getStoreCustomerRequest($store_id, $customer_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'customer_id' is set if ($customer_id === null || (is_array($customer_id) && count($customer_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $customer_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/customers/{customer_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($customer_id !== null) { $resourcePath = str_replace( '{' . 'customer_id' . '}', ObjectSerializer::toPathValue($customer_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getStoreOrders($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $customer_id = null, $has_outreach = null, $campaign_id = null, $outreach_id = null) { $response = $this->getStoreOrdersWithHttpInfo($store_id, $fields, $exclude_fields, $count, $offset, $customer_id, $has_outreach, $campaign_id, $outreach_id); return $response; } public function getStoreOrdersWithHttpInfo($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $customer_id = null, $has_outreach = null, $campaign_id = null, $outreach_id = null) { $request = $this->getStoreOrdersRequest($store_id, $fields, $exclude_fields, $count, $offset, $customer_id, $has_outreach, $campaign_id, $outreach_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getStoreOrdersRequest($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $customer_id = null, $has_outreach = null, $campaign_id = null, $outreach_id = null) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling EcommerceApi., must be smaller than or equal to 1000.'); } $resourcePath = '/ecommerce/stores/{store_id}/orders'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($customer_id !== null) { $queryParams['customer_id'] = ObjectSerializer::toQueryValue($customer_id); } // query params if ($has_outreach !== null) { $queryParams['has_outreach'] = ObjectSerializer::toQueryValue($has_outreach); } // query params if ($campaign_id !== null) { $queryParams['campaign_id'] = ObjectSerializer::toQueryValue($campaign_id); } // query params if ($outreach_id !== null) { $queryParams['outreach_id'] = ObjectSerializer::toQueryValue($outreach_id); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getOrder($store_id, $order_id, $fields = null, $exclude_fields = null) { $response = $this->getOrderWithHttpInfo($store_id, $order_id, $fields, $exclude_fields); return $response; } public function getOrderWithHttpInfo($store_id, $order_id, $fields = null, $exclude_fields = null) { $request = $this->getOrderRequest($store_id, $order_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getOrderRequest($store_id, $order_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'order_id' is set if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $order_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/orders/{order_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($order_id !== null) { $resourcePath = str_replace( '{' . 'order_id' . '}', ObjectSerializer::toPathValue($order_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getAllOrderLineItems($store_id, $order_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getAllOrderLineItemsWithHttpInfo($store_id, $order_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getAllOrderLineItemsWithHttpInfo($store_id, $order_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getAllOrderLineItemsRequest($store_id, $order_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getAllOrderLineItemsRequest($store_id, $order_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'order_id' is set if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $order_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling EcommerceApi., must be smaller than or equal to 1000.'); } $resourcePath = '/ecommerce/stores/{store_id}/orders/{order_id}/lines'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($order_id !== null) { $resourcePath = str_replace( '{' . 'order_id' . '}', ObjectSerializer::toPathValue($order_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getOrderLineItem($store_id, $order_id, $line_id, $fields = null, $exclude_fields = null) { $response = $this->getOrderLineItemWithHttpInfo($store_id, $order_id, $line_id, $fields, $exclude_fields); return $response; } public function getOrderLineItemWithHttpInfo($store_id, $order_id, $line_id, $fields = null, $exclude_fields = null) { $request = $this->getOrderLineItemRequest($store_id, $order_id, $line_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getOrderLineItemRequest($store_id, $order_id, $line_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'order_id' is set if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $order_id when calling ' ); } // verify the required parameter 'line_id' is set if ($line_id === null || (is_array($line_id) && count($line_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $line_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/orders/{order_id}/lines/{line_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($order_id !== null) { $resourcePath = str_replace( '{' . 'order_id' . '}', ObjectSerializer::toPathValue($order_id), $resourcePath ); } // path params if ($line_id !== null) { $resourcePath = str_replace( '{' . 'line_id' . '}', ObjectSerializer::toPathValue($line_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getAllStoreProducts($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getAllStoreProductsWithHttpInfo($store_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getAllStoreProductsWithHttpInfo($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getAllStoreProductsRequest($store_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getAllStoreProductsRequest($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling EcommerceApi., must be smaller than or equal to 1000.'); } $resourcePath = '/ecommerce/stores/{store_id}/products'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getStoreProduct($store_id, $product_id, $fields = null, $exclude_fields = null) { $response = $this->getStoreProductWithHttpInfo($store_id, $product_id, $fields, $exclude_fields); return $response; } public function getStoreProductWithHttpInfo($store_id, $product_id, $fields = null, $exclude_fields = null) { $request = $this->getStoreProductRequest($store_id, $product_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getStoreProductRequest($store_id, $product_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getProductImages($store_id, $product_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getProductImagesWithHttpInfo($store_id, $product_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getProductImagesWithHttpInfo($store_id, $product_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getProductImagesRequest($store_id, $product_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getProductImagesRequest($store_id, $product_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling EcommerceApi., must be smaller than or equal to 1000.'); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}/images'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getProductImage($store_id, $product_id, $image_id, $fields = null, $exclude_fields = null) { $response = $this->getProductImageWithHttpInfo($store_id, $product_id, $image_id, $fields, $exclude_fields); return $response; } public function getProductImageWithHttpInfo($store_id, $product_id, $image_id, $fields = null, $exclude_fields = null) { $request = $this->getProductImageRequest($store_id, $product_id, $image_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getProductImageRequest($store_id, $product_id, $image_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } // verify the required parameter 'image_id' is set if ($image_id === null || (is_array($image_id) && count($image_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $image_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}/images/{image_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // path params if ($image_id !== null) { $resourcePath = str_replace( '{' . 'image_id' . '}', ObjectSerializer::toPathValue($image_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getProductVariants($store_id, $product_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getProductVariantsWithHttpInfo($store_id, $product_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getProductVariantsWithHttpInfo($store_id, $product_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getProductVariantsRequest($store_id, $product_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getProductVariantsRequest($store_id, $product_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling EcommerceApi., must be smaller than or equal to 1000.'); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}/variants'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getProductVariant($store_id, $product_id, $variant_id, $fields = null, $exclude_fields = null) { $response = $this->getProductVariantWithHttpInfo($store_id, $product_id, $variant_id, $fields, $exclude_fields); return $response; } public function getProductVariantWithHttpInfo($store_id, $product_id, $variant_id, $fields = null, $exclude_fields = null) { $request = $this->getProductVariantRequest($store_id, $product_id, $variant_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getProductVariantRequest($store_id, $product_id, $variant_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } // verify the required parameter 'variant_id' is set if ($variant_id === null || (is_array($variant_id) && count($variant_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $variant_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}/variants/{variant_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // path params if ($variant_id !== null) { $resourcePath = str_replace( '{' . 'variant_id' . '}', ObjectSerializer::toPathValue($variant_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getPromoCodes($promo_rule_id, $store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getPromoCodesWithHttpInfo($promo_rule_id, $store_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getPromoCodesWithHttpInfo($promo_rule_id, $store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getPromoCodesRequest($promo_rule_id, $store_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getPromoCodesRequest($promo_rule_id, $store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'promo_rule_id' is set if ($promo_rule_id === null || (is_array($promo_rule_id) && count($promo_rule_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $promo_rule_id when calling ' ); } // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling EcommerceApi., must be smaller than or equal to 1000.'); } $resourcePath = '/ecommerce/stores/{store_id}/promo-rules/{promo_rule_id}/promo-codes'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($promo_rule_id !== null) { $resourcePath = str_replace( '{' . 'promo_rule_id' . '}', ObjectSerializer::toPathValue($promo_rule_id), $resourcePath ); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getPromoCode($store_id, $promo_rule_id, $promo_code_id, $fields = null, $exclude_fields = null) { $response = $this->getPromoCodeWithHttpInfo($store_id, $promo_rule_id, $promo_code_id, $fields, $exclude_fields); return $response; } public function getPromoCodeWithHttpInfo($store_id, $promo_rule_id, $promo_code_id, $fields = null, $exclude_fields = null) { $request = $this->getPromoCodeRequest($store_id, $promo_rule_id, $promo_code_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getPromoCodeRequest($store_id, $promo_rule_id, $promo_code_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'promo_rule_id' is set if ($promo_rule_id === null || (is_array($promo_rule_id) && count($promo_rule_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $promo_rule_id when calling ' ); } // verify the required parameter 'promo_code_id' is set if ($promo_code_id === null || (is_array($promo_code_id) && count($promo_code_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $promo_code_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/promo-rules/{promo_rule_id}/promo-codes/{promo_code_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($promo_rule_id !== null) { $resourcePath = str_replace( '{' . 'promo_rule_id' . '}', ObjectSerializer::toPathValue($promo_rule_id), $resourcePath ); } // path params if ($promo_code_id !== null) { $resourcePath = str_replace( '{' . 'promo_code_id' . '}', ObjectSerializer::toPathValue($promo_code_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function listPromoRules($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->listPromoRulesWithHttpInfo($store_id, $fields, $exclude_fields, $count, $offset); return $response; } public function listPromoRulesWithHttpInfo($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->listPromoRulesRequest($store_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listPromoRulesRequest($store_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling EcommerceApi., must be smaller than or equal to 1000.'); } $resourcePath = '/ecommerce/stores/{store_id}/promo-rules'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getPromoRule($store_id, $promo_rule_id, $fields = null, $exclude_fields = null) { $response = $this->getPromoRuleWithHttpInfo($store_id, $promo_rule_id, $fields, $exclude_fields); return $response; } public function getPromoRuleWithHttpInfo($store_id, $promo_rule_id, $fields = null, $exclude_fields = null) { $request = $this->getPromoRuleRequest($store_id, $promo_rule_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getPromoRuleRequest($store_id, $promo_rule_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'promo_rule_id' is set if ($promo_rule_id === null || (is_array($promo_rule_id) && count($promo_rule_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $promo_rule_id when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/promo-rules/{promo_rule_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($promo_rule_id !== null) { $resourcePath = str_replace( '{' . 'promo_rule_id' . '}', ObjectSerializer::toPathValue($promo_rule_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateStore($store_id, $body) { $response = $this->updateStoreWithHttpInfo($store_id, $body); return $response; } public function updateStoreWithHttpInfo($store_id, $body) { $request = $this->updateStoreRequest($store_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateStoreRequest($store_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateStoreCart($store_id, $cart_id, $body) { $response = $this->updateStoreCartWithHttpInfo($store_id, $cart_id, $body); return $response; } public function updateStoreCartWithHttpInfo($store_id, $cart_id, $body) { $request = $this->updateStoreCartRequest($store_id, $cart_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateStoreCartRequest($store_id, $cart_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'cart_id' is set if ($cart_id === null || (is_array($cart_id) && count($cart_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $cart_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/carts/{cart_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($cart_id !== null) { $resourcePath = str_replace( '{' . 'cart_id' . '}', ObjectSerializer::toPathValue($cart_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateCartLineItem($store_id, $cart_id, $line_id, $body) { $response = $this->updateCartLineItemWithHttpInfo($store_id, $cart_id, $line_id, $body); return $response; } public function updateCartLineItemWithHttpInfo($store_id, $cart_id, $line_id, $body) { $request = $this->updateCartLineItemRequest($store_id, $cart_id, $line_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateCartLineItemRequest($store_id, $cart_id, $line_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'cart_id' is set if ($cart_id === null || (is_array($cart_id) && count($cart_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $cart_id when calling ' ); } // verify the required parameter 'line_id' is set if ($line_id === null || (is_array($line_id) && count($line_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $line_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/carts/{cart_id}/lines/{line_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($cart_id !== null) { $resourcePath = str_replace( '{' . 'cart_id' . '}', ObjectSerializer::toPathValue($cart_id), $resourcePath ); } // path params if ($line_id !== null) { $resourcePath = str_replace( '{' . 'line_id' . '}', ObjectSerializer::toPathValue($line_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateStoreCustomer($store_id, $customer_id, $body) { $response = $this->updateStoreCustomerWithHttpInfo($store_id, $customer_id, $body); return $response; } public function updateStoreCustomerWithHttpInfo($store_id, $customer_id, $body) { $request = $this->updateStoreCustomerRequest($store_id, $customer_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateStoreCustomerRequest($store_id, $customer_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'customer_id' is set if ($customer_id === null || (is_array($customer_id) && count($customer_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $customer_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/customers/{customer_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($customer_id !== null) { $resourcePath = str_replace( '{' . 'customer_id' . '}', ObjectSerializer::toPathValue($customer_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateOrder($store_id, $order_id, $body) { $response = $this->updateOrderWithHttpInfo($store_id, $order_id, $body); return $response; } public function updateOrderWithHttpInfo($store_id, $order_id, $body) { $request = $this->updateOrderRequest($store_id, $order_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateOrderRequest($store_id, $order_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'order_id' is set if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $order_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/orders/{order_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($order_id !== null) { $resourcePath = str_replace( '{' . 'order_id' . '}', ObjectSerializer::toPathValue($order_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateOrderLineItem($store_id, $order_id, $line_id, $body) { $response = $this->updateOrderLineItemWithHttpInfo($store_id, $order_id, $line_id, $body); return $response; } public function updateOrderLineItemWithHttpInfo($store_id, $order_id, $line_id, $body) { $request = $this->updateOrderLineItemRequest($store_id, $order_id, $line_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateOrderLineItemRequest($store_id, $order_id, $line_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'order_id' is set if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $order_id when calling ' ); } // verify the required parameter 'line_id' is set if ($line_id === null || (is_array($line_id) && count($line_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $line_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/orders/{order_id}/lines/{line_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($order_id !== null) { $resourcePath = str_replace( '{' . 'order_id' . '}', ObjectSerializer::toPathValue($order_id), $resourcePath ); } // path params if ($line_id !== null) { $resourcePath = str_replace( '{' . 'line_id' . '}', ObjectSerializer::toPathValue($line_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateStoreProduct($store_id, $product_id, $body) { $response = $this->updateStoreProductWithHttpInfo($store_id, $product_id, $body); return $response; } public function updateStoreProductWithHttpInfo($store_id, $product_id, $body) { $request = $this->updateStoreProductRequest($store_id, $product_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateStoreProductRequest($store_id, $product_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateProductImage($store_id, $product_id, $image_id, $body) { $response = $this->updateProductImageWithHttpInfo($store_id, $product_id, $image_id, $body); return $response; } public function updateProductImageWithHttpInfo($store_id, $product_id, $image_id, $body) { $request = $this->updateProductImageRequest($store_id, $product_id, $image_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateProductImageRequest($store_id, $product_id, $image_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } // verify the required parameter 'image_id' is set if ($image_id === null || (is_array($image_id) && count($image_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $image_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}/images/{image_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // path params if ($image_id !== null) { $resourcePath = str_replace( '{' . 'image_id' . '}', ObjectSerializer::toPathValue($image_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateProductVariant($store_id, $product_id, $variant_id, $body) { $response = $this->updateProductVariantWithHttpInfo($store_id, $product_id, $variant_id, $body); return $response; } public function updateProductVariantWithHttpInfo($store_id, $product_id, $variant_id, $body) { $request = $this->updateProductVariantRequest($store_id, $product_id, $variant_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateProductVariantRequest($store_id, $product_id, $variant_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } // verify the required parameter 'variant_id' is set if ($variant_id === null || (is_array($variant_id) && count($variant_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $variant_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}/variants/{variant_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // path params if ($variant_id !== null) { $resourcePath = str_replace( '{' . 'variant_id' . '}', ObjectSerializer::toPathValue($variant_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updatePromoCode($store_id, $promo_rule_id, $promo_code_id, $body) { $response = $this->updatePromoCodeWithHttpInfo($store_id, $promo_rule_id, $promo_code_id, $body); return $response; } public function updatePromoCodeWithHttpInfo($store_id, $promo_rule_id, $promo_code_id, $body) { $request = $this->updatePromoCodeRequest($store_id, $promo_rule_id, $promo_code_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updatePromoCodeRequest($store_id, $promo_rule_id, $promo_code_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'promo_rule_id' is set if ($promo_rule_id === null || (is_array($promo_rule_id) && count($promo_rule_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $promo_rule_id when calling ' ); } // verify the required parameter 'promo_code_id' is set if ($promo_code_id === null || (is_array($promo_code_id) && count($promo_code_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $promo_code_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/promo-rules/{promo_rule_id}/promo-codes/{promo_code_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($promo_rule_id !== null) { $resourcePath = str_replace( '{' . 'promo_rule_id' . '}', ObjectSerializer::toPathValue($promo_rule_id), $resourcePath ); } // path params if ($promo_code_id !== null) { $resourcePath = str_replace( '{' . 'promo_code_id' . '}', ObjectSerializer::toPathValue($promo_code_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updatePromoRule($store_id, $promo_rule_id, $body) { $response = $this->updatePromoRuleWithHttpInfo($store_id, $promo_rule_id, $body); return $response; } public function updatePromoRuleWithHttpInfo($store_id, $promo_rule_id, $body) { $request = $this->updatePromoRuleRequest($store_id, $promo_rule_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updatePromoRuleRequest($store_id, $promo_rule_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'promo_rule_id' is set if ($promo_rule_id === null || (is_array($promo_rule_id) && count($promo_rule_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $promo_rule_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/promo-rules/{promo_rule_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($promo_rule_id !== null) { $resourcePath = str_replace( '{' . 'promo_rule_id' . '}', ObjectSerializer::toPathValue($promo_rule_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addStore($body) { $response = $this->addStoreWithHttpInfo($body); return $response; } public function addStoreWithHttpInfo($body) { $request = $this->addStoreRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addStoreRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addStoreCart($store_id, $body) { $response = $this->addStoreCartWithHttpInfo($store_id, $body); return $response; } public function addStoreCartWithHttpInfo($store_id, $body) { $request = $this->addStoreCartRequest($store_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addStoreCartRequest($store_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/carts'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addCartLineItem($store_id, $cart_id, $body) { $response = $this->addCartLineItemWithHttpInfo($store_id, $cart_id, $body); return $response; } public function addCartLineItemWithHttpInfo($store_id, $cart_id, $body) { $request = $this->addCartLineItemRequest($store_id, $cart_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addCartLineItemRequest($store_id, $cart_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'cart_id' is set if ($cart_id === null || (is_array($cart_id) && count($cart_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $cart_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/carts/{cart_id}/lines'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($cart_id !== null) { $resourcePath = str_replace( '{' . 'cart_id' . '}', ObjectSerializer::toPathValue($cart_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addStoreCustomer($store_id, $body) { $response = $this->addStoreCustomerWithHttpInfo($store_id, $body); return $response; } public function addStoreCustomerWithHttpInfo($store_id, $body) { $request = $this->addStoreCustomerRequest($store_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addStoreCustomerRequest($store_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/customers'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addStoreOrder($store_id, $body) { $response = $this->addStoreOrderWithHttpInfo($store_id, $body); return $response; } public function addStoreOrderWithHttpInfo($store_id, $body) { $request = $this->addStoreOrderRequest($store_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addStoreOrderRequest($store_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/orders'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addOrderLineItem($store_id, $order_id, $body) { $response = $this->addOrderLineItemWithHttpInfo($store_id, $order_id, $body); return $response; } public function addOrderLineItemWithHttpInfo($store_id, $order_id, $body) { $request = $this->addOrderLineItemRequest($store_id, $order_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addOrderLineItemRequest($store_id, $order_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'order_id' is set if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $order_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/orders/{order_id}/lines'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($order_id !== null) { $resourcePath = str_replace( '{' . 'order_id' . '}', ObjectSerializer::toPathValue($order_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addStoreProduct($store_id, $body) { $response = $this->addStoreProductWithHttpInfo($store_id, $body); return $response; } public function addStoreProductWithHttpInfo($store_id, $body) { $request = $this->addStoreProductRequest($store_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addStoreProductRequest($store_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/products'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addProductImage($store_id, $product_id, $body) { $response = $this->addProductImageWithHttpInfo($store_id, $product_id, $body); return $response; } public function addProductImageWithHttpInfo($store_id, $product_id, $body) { $request = $this->addProductImageRequest($store_id, $product_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addProductImageRequest($store_id, $product_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}/images'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addProductVariants($store_id, $product_id, $body) { $response = $this->addProductVariantsWithHttpInfo($store_id, $product_id, $body); return $response; } public function addProductVariantsWithHttpInfo($store_id, $product_id, $body) { $request = $this->addProductVariantsRequest($store_id, $product_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addProductVariantsRequest($store_id, $product_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}/variants'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addPromoCode($store_id, $promo_rule_id, $body) { $response = $this->addPromoCodeWithHttpInfo($store_id, $promo_rule_id, $body); return $response; } public function addPromoCodeWithHttpInfo($store_id, $promo_rule_id, $body) { $request = $this->addPromoCodeRequest($store_id, $promo_rule_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addPromoCodeRequest($store_id, $promo_rule_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'promo_rule_id' is set if ($promo_rule_id === null || (is_array($promo_rule_id) && count($promo_rule_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $promo_rule_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/promo-rules/{promo_rule_id}/promo-codes'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($promo_rule_id !== null) { $resourcePath = str_replace( '{' . 'promo_rule_id' . '}', ObjectSerializer::toPathValue($promo_rule_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addPromoRules($store_id, $body) { $response = $this->addPromoRulesWithHttpInfo($store_id, $body); return $response; } public function addPromoRulesWithHttpInfo($store_id, $body) { $request = $this->addPromoRulesRequest($store_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addPromoRulesRequest($store_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/promo-rules'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function setStoreCustomer($store_id, $customer_id, $body) { $response = $this->setStoreCustomerWithHttpInfo($store_id, $customer_id, $body); return $response; } public function setStoreCustomerWithHttpInfo($store_id, $customer_id, $body) { $request = $this->setStoreCustomerRequest($store_id, $customer_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function setStoreCustomerRequest($store_id, $customer_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'customer_id' is set if ($customer_id === null || (is_array($customer_id) && count($customer_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $customer_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/customers/{customer_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($customer_id !== null) { $resourcePath = str_replace( '{' . 'customer_id' . '}', ObjectSerializer::toPathValue($customer_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PUT', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addProductVariant($store_id, $product_id, $variant_id, $body) { $response = $this->addProductVariantWithHttpInfo($store_id, $product_id, $variant_id, $body); return $response; } public function addProductVariantWithHttpInfo($store_id, $product_id, $variant_id, $body) { $request = $this->addProductVariantRequest($store_id, $product_id, $variant_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addProductVariantRequest($store_id, $product_id, $variant_id, $body) { // verify the required parameter 'store_id' is set if ($store_id === null || (is_array($store_id) && count($store_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $store_id when calling ' ); } // verify the required parameter 'product_id' is set if ($product_id === null || (is_array($product_id) && count($product_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $product_id when calling ' ); } // verify the required parameter 'variant_id' is set if ($variant_id === null || (is_array($variant_id) && count($variant_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $variant_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/ecommerce/stores/{store_id}/products/{product_id}/variants/{variant_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($store_id !== null) { $resourcePath = str_replace( '{' . 'store_id' . '}', ObjectSerializer::toPathValue($store_id), $resourcePath ); } // path params if ($product_id !== null) { $resourcePath = str_replace( '{' . 'product_id' . '}', ObjectSerializer::toPathValue($product_id), $resourcePath ); } // path params if ($variant_id !== null) { $resourcePath = str_replace( '{' . 'variant_id' . '}', ObjectSerializer::toPathValue($variant_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PUT', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/FacebookAdsApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function list($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null, $sort_dir = null) { $response = $this->listWithHttpInfo($fields, $exclude_fields, $count, $offset, $sort_field, $sort_dir); return $response; } public function listWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null, $sort_dir = null) { $request = $this->listRequest($fields, $exclude_fields, $count, $offset, $sort_field, $sort_dir); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null, $sort_dir = null) { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling FacebookAdsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/facebook-ads'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($sort_field !== null) { $queryParams['sort_field'] = ObjectSerializer::toQueryValue($sort_field); } // query params if ($sort_dir !== null) { $queryParams['sort_dir'] = ObjectSerializer::toQueryValue($sort_dir); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getAd($outreach_id, $fields = null, $exclude_fields = null) { $response = $this->getAdWithHttpInfo($outreach_id, $fields, $exclude_fields); return $response; } public function getAdWithHttpInfo($outreach_id, $fields = null, $exclude_fields = null) { $request = $this->getAdRequest($outreach_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getAdRequest($outreach_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'outreach_id' is set if ($outreach_id === null || (is_array($outreach_id) && count($outreach_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $outreach_id when calling ' ); } $resourcePath = '/facebook-ads/{outreach_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($outreach_id !== null) { $resourcePath = str_replace( '{' . 'outreach_id' . '}', ObjectSerializer::toPathValue($outreach_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/FileManagerApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function deleteFile($file_id) { $this->deleteFileWithHttpInfo($file_id); } public function deleteFileWithHttpInfo($file_id) { $request = $this->deleteFileRequest($file_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteFileRequest($file_id) { // verify the required parameter 'file_id' is set if ($file_id === null || (is_array($file_id) && count($file_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $file_id when calling ' ); } $resourcePath = '/file-manager/files/{file_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($file_id !== null) { $resourcePath = str_replace( '{' . 'file_id' . '}', ObjectSerializer::toPathValue($file_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteFolder($folder_id) { $this->deleteFolderWithHttpInfo($folder_id); } public function deleteFolderWithHttpInfo($folder_id) { $request = $this->deleteFolderRequest($folder_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteFolderRequest($folder_id) { // verify the required parameter 'folder_id' is set if ($folder_id === null || (is_array($folder_id) && count($folder_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $folder_id when calling ' ); } $resourcePath = '/file-manager/folders/{folder_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($folder_id !== null) { $resourcePath = str_replace( '{' . 'folder_id' . '}', ObjectSerializer::toPathValue($folder_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function files($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $created_by = null, $before_created_at = null, $since_created_at = null, $sort_field = null, $sort_dir = null) { $response = $this->filesWithHttpInfo($fields, $exclude_fields, $count, $offset, $type, $created_by, $before_created_at, $since_created_at, $sort_field, $sort_dir); return $response; } public function filesWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $created_by = null, $before_created_at = null, $since_created_at = null, $sort_field = null, $sort_dir = null) { $request = $this->filesRequest($fields, $exclude_fields, $count, $offset, $type, $created_by, $before_created_at, $since_created_at, $sort_field, $sort_dir); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function filesRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $created_by = null, $before_created_at = null, $since_created_at = null, $sort_field = null, $sort_dir = null) { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling FileManagerApi., must be smaller than or equal to 1000.'); } $resourcePath = '/file-manager/files'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($type !== null) { $queryParams['type'] = ObjectSerializer::toQueryValue($type); } // query params if ($created_by !== null) { $queryParams['created_by'] = ObjectSerializer::toQueryValue($created_by); } // query params if ($before_created_at !== null) { $queryParams['before_created_at'] = ObjectSerializer::toQueryValue($before_created_at); } // query params if ($since_created_at !== null) { $queryParams['since_created_at'] = ObjectSerializer::toQueryValue($since_created_at); } // query params if ($sort_field !== null) { $queryParams['sort_field'] = ObjectSerializer::toQueryValue($sort_field); } // query params if ($sort_dir !== null) { $queryParams['sort_dir'] = ObjectSerializer::toQueryValue($sort_dir); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getFile($file_id, $fields = null, $exclude_fields = null) { $response = $this->getFileWithHttpInfo($file_id, $fields, $exclude_fields); return $response; } public function getFileWithHttpInfo($file_id, $fields = null, $exclude_fields = null) { $request = $this->getFileRequest($file_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getFileRequest($file_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'file_id' is set if ($file_id === null || (is_array($file_id) && count($file_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $file_id when calling ' ); } $resourcePath = '/file-manager/files/{file_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($file_id !== null) { $resourcePath = str_replace( '{' . 'file_id' . '}', ObjectSerializer::toPathValue($file_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function listFolders($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $created_by = null, $before_created_at = null, $since_created_at = null) { $response = $this->listFoldersWithHttpInfo($fields, $exclude_fields, $count, $offset, $created_by, $before_created_at, $since_created_at); return $response; } public function listFoldersWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $created_by = null, $before_created_at = null, $since_created_at = null) { $request = $this->listFoldersRequest($fields, $exclude_fields, $count, $offset, $created_by, $before_created_at, $since_created_at); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listFoldersRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $created_by = null, $before_created_at = null, $since_created_at = null) { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling FileManagerApi., must be smaller than or equal to 1000.'); } $resourcePath = '/file-manager/folders'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($created_by !== null) { $queryParams['created_by'] = ObjectSerializer::toQueryValue($created_by); } // query params if ($before_created_at !== null) { $queryParams['before_created_at'] = ObjectSerializer::toQueryValue($before_created_at); } // query params if ($since_created_at !== null) { $queryParams['since_created_at'] = ObjectSerializer::toQueryValue($since_created_at); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getFolder($folder_id, $fields = null, $exclude_fields = null) { $response = $this->getFolderWithHttpInfo($folder_id, $fields, $exclude_fields); return $response; } public function getFolderWithHttpInfo($folder_id, $fields = null, $exclude_fields = null) { $request = $this->getFolderRequest($folder_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getFolderRequest($folder_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'folder_id' is set if ($folder_id === null || (is_array($folder_id) && count($folder_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $folder_id when calling ' ); } $resourcePath = '/file-manager/folders/{folder_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($folder_id !== null) { $resourcePath = str_replace( '{' . 'folder_id' . '}', ObjectSerializer::toPathValue($folder_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateFile($file_id, $body) { $response = $this->updateFileWithHttpInfo($file_id, $body); return $response; } public function updateFileWithHttpInfo($file_id, $body) { $request = $this->updateFileRequest($file_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateFileRequest($file_id, $body) { // verify the required parameter 'file_id' is set if ($file_id === null || (is_array($file_id) && count($file_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $file_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/file-manager/files/{file_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($file_id !== null) { $resourcePath = str_replace( '{' . 'file_id' . '}', ObjectSerializer::toPathValue($file_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateFolder($folder_id, $body) { $response = $this->updateFolderWithHttpInfo($folder_id, $body); return $response; } public function updateFolderWithHttpInfo($folder_id, $body) { $request = $this->updateFolderRequest($folder_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateFolderRequest($folder_id, $body) { // verify the required parameter 'folder_id' is set if ($folder_id === null || (is_array($folder_id) && count($folder_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $folder_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/file-manager/folders/{folder_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($folder_id !== null) { $resourcePath = str_replace( '{' . 'folder_id' . '}', ObjectSerializer::toPathValue($folder_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function upload($body) { $response = $this->uploadWithHttpInfo($body); return $response; } public function uploadWithHttpInfo($body) { $request = $this->uploadRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function uploadRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/file-manager/files'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function createFolder($body) { $response = $this->createFolderWithHttpInfo($body); return $response; } public function createFolderWithHttpInfo($body) { $request = $this->createFolderRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createFolderRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/file-manager/folders'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/LandingPagesApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function deletePage($page_id) { $this->deletePageWithHttpInfo($page_id); } public function deletePageWithHttpInfo($page_id) { $request = $this->deletePageRequest($page_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deletePageRequest($page_id) { // verify the required parameter 'page_id' is set if ($page_id === null || (is_array($page_id) && count($page_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $page_id when calling ' ); } $resourcePath = '/landing-pages/{page_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($page_id !== null) { $resourcePath = str_replace( '{' . 'page_id' . '}', ObjectSerializer::toPathValue($page_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getAll($sort_dir = null, $sort_field = null, $fields = null, $exclude_fields = null, $count = '10') { $response = $this->getAllWithHttpInfo($sort_dir, $sort_field, $fields, $exclude_fields, $count); return $response; } public function getAllWithHttpInfo($sort_dir = null, $sort_field = null, $fields = null, $exclude_fields = null, $count = '10') { $request = $this->getAllRequest($sort_dir, $sort_field, $fields, $exclude_fields, $count); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getAllRequest($sort_dir = null, $sort_field = null, $fields = null, $exclude_fields = null, $count = '10') { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling LandingPagesApi., must be smaller than or equal to 1000.'); } $resourcePath = '/landing-pages'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($sort_dir !== null) { $queryParams['sort_dir'] = ObjectSerializer::toQueryValue($sort_dir); } // query params if ($sort_field !== null) { $queryParams['sort_field'] = ObjectSerializer::toQueryValue($sort_field); } // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getPage($page_id, $fields = null, $exclude_fields = null) { $response = $this->getPageWithHttpInfo($page_id, $fields, $exclude_fields); return $response; } public function getPageWithHttpInfo($page_id, $fields = null, $exclude_fields = null) { $request = $this->getPageRequest($page_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getPageRequest($page_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'page_id' is set if ($page_id === null || (is_array($page_id) && count($page_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $page_id when calling ' ); } $resourcePath = '/landing-pages/{page_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($page_id !== null) { $resourcePath = str_replace( '{' . 'page_id' . '}', ObjectSerializer::toPathValue($page_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getPageContent($page_id, $fields = null, $exclude_fields = null) { $response = $this->getPageContentWithHttpInfo($page_id, $fields, $exclude_fields); return $response; } public function getPageContentWithHttpInfo($page_id, $fields = null, $exclude_fields = null) { $request = $this->getPageContentRequest($page_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getPageContentRequest($page_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'page_id' is set if ($page_id === null || (is_array($page_id) && count($page_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $page_id when calling ' ); } $resourcePath = '/landing-pages/{page_id}/content'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($page_id !== null) { $resourcePath = str_replace( '{' . 'page_id' . '}', ObjectSerializer::toPathValue($page_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updatePage($page_id, $body) { $response = $this->updatePageWithHttpInfo($page_id, $body); return $response; } public function updatePageWithHttpInfo($page_id, $body) { $request = $this->updatePageRequest($page_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updatePageRequest($page_id, $body) { // verify the required parameter 'page_id' is set if ($page_id === null || (is_array($page_id) && count($page_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $page_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/landing-pages/{page_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($page_id !== null) { $resourcePath = str_replace( '{' . 'page_id' . '}', ObjectSerializer::toPathValue($page_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function create($body, $use_default_list = null) { $response = $this->createWithHttpInfo($body, $use_default_list); return $response; } public function createWithHttpInfo($body, $use_default_list = null) { $request = $this->createRequest($body, $use_default_list); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createRequest($body, $use_default_list = null) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/landing-pages'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($use_default_list !== null) { $queryParams['use_default_list'] = ObjectSerializer::toQueryValue($use_default_list); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function publishPage($page_id) { $this->publishPageWithHttpInfo($page_id); } public function publishPageWithHttpInfo($page_id) { $request = $this->publishPageRequest($page_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function publishPageRequest($page_id) { // verify the required parameter 'page_id' is set if ($page_id === null || (is_array($page_id) && count($page_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $page_id when calling ' ); } $resourcePath = '/landing-pages/{page_id}/actions/publish'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($page_id !== null) { $resourcePath = str_replace( '{' . 'page_id' . '}', ObjectSerializer::toPathValue($page_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function unpublishPage($page_id) { $this->unpublishPageWithHttpInfo($page_id); } public function unpublishPageWithHttpInfo($page_id) { $request = $this->unpublishPageRequest($page_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function unpublishPageRequest($page_id) { // verify the required parameter 'page_id' is set if ($page_id === null || (is_array($page_id) && count($page_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $page_id when calling ' ); } $resourcePath = '/landing-pages/{page_id}/actions/unpublish'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($page_id !== null) { $resourcePath = str_replace( '{' . 'page_id' . '}', ObjectSerializer::toPathValue($page_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/ListsApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function deleteList($list_id) { $this->deleteListWithHttpInfo($list_id); } public function deleteListWithHttpInfo($list_id) { $request = $this->deleteListRequest($list_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteListRequest($list_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } $resourcePath = '/lists/{list_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteInterestCategory($list_id, $interest_category_id) { $this->deleteInterestCategoryWithHttpInfo($list_id, $interest_category_id); } public function deleteInterestCategoryWithHttpInfo($list_id, $interest_category_id) { $request = $this->deleteInterestCategoryRequest($list_id, $interest_category_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteInterestCategoryRequest($list_id, $interest_category_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'interest_category_id' is set if ($interest_category_id === null || (is_array($interest_category_id) && count($interest_category_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $interest_category_id when calling ' ); } $resourcePath = '/lists/{list_id}/interest-categories/{interest_category_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($interest_category_id !== null) { $resourcePath = str_replace( '{' . 'interest_category_id' . '}', ObjectSerializer::toPathValue($interest_category_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteInterestCategoryInterest($list_id, $interest_category_id, $interest_id) { $this->deleteInterestCategoryInterestWithHttpInfo($list_id, $interest_category_id, $interest_id); } public function deleteInterestCategoryInterestWithHttpInfo($list_id, $interest_category_id, $interest_id) { $request = $this->deleteInterestCategoryInterestRequest($list_id, $interest_category_id, $interest_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteInterestCategoryInterestRequest($list_id, $interest_category_id, $interest_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'interest_category_id' is set if ($interest_category_id === null || (is_array($interest_category_id) && count($interest_category_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $interest_category_id when calling ' ); } // verify the required parameter 'interest_id' is set if ($interest_id === null || (is_array($interest_id) && count($interest_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $interest_id when calling ' ); } $resourcePath = '/lists/{list_id}/interest-categories/{interest_category_id}/interests/{interest_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($interest_category_id !== null) { $resourcePath = str_replace( '{' . 'interest_category_id' . '}', ObjectSerializer::toPathValue($interest_category_id), $resourcePath ); } // path params if ($interest_id !== null) { $resourcePath = str_replace( '{' . 'interest_id' . '}', ObjectSerializer::toPathValue($interest_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteListMember($list_id, $subscriber_hash) { $this->deleteListMemberWithHttpInfo($list_id, $subscriber_hash); } public function deleteListMemberWithHttpInfo($list_id, $subscriber_hash) { $request = $this->deleteListMemberRequest($list_id, $subscriber_hash); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteListMemberRequest($list_id, $subscriber_hash) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteListMemberNote($list_id, $subscriber_hash, $note_id) { $this->deleteListMemberNoteWithHttpInfo($list_id, $subscriber_hash, $note_id); } public function deleteListMemberNoteWithHttpInfo($list_id, $subscriber_hash, $note_id) { $request = $this->deleteListMemberNoteRequest($list_id, $subscriber_hash, $note_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteListMemberNoteRequest($list_id, $subscriber_hash, $note_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } // verify the required parameter 'note_id' is set if ($note_id === null || (is_array($note_id) && count($note_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $note_id when calling ' ); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}/notes/{note_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // path params if ($note_id !== null) { $resourcePath = str_replace( '{' . 'note_id' . '}', ObjectSerializer::toPathValue($note_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteListMergeField($list_id, $merge_id) { $this->deleteListMergeFieldWithHttpInfo($list_id, $merge_id); } public function deleteListMergeFieldWithHttpInfo($list_id, $merge_id) { $request = $this->deleteListMergeFieldRequest($list_id, $merge_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteListMergeFieldRequest($list_id, $merge_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'merge_id' is set if ($merge_id === null || (is_array($merge_id) && count($merge_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $merge_id when calling ' ); } $resourcePath = '/lists/{list_id}/merge-fields/{merge_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($merge_id !== null) { $resourcePath = str_replace( '{' . 'merge_id' . '}', ObjectSerializer::toPathValue($merge_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteSegment($list_id, $segment_id) { $this->deleteSegmentWithHttpInfo($list_id, $segment_id); } public function deleteSegmentWithHttpInfo($list_id, $segment_id) { $request = $this->deleteSegmentRequest($list_id, $segment_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteSegmentRequest($list_id, $segment_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'segment_id' is set if ($segment_id === null || (is_array($segment_id) && count($segment_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $segment_id when calling ' ); } $resourcePath = '/lists/{list_id}/segments/{segment_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($segment_id !== null) { $resourcePath = str_replace( '{' . 'segment_id' . '}', ObjectSerializer::toPathValue($segment_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function removeSegmentMember($list_id, $segment_id, $subscriber_hash) { $this->removeSegmentMemberWithHttpInfo($list_id, $segment_id, $subscriber_hash); } public function removeSegmentMemberWithHttpInfo($list_id, $segment_id, $subscriber_hash) { $request = $this->removeSegmentMemberRequest($list_id, $segment_id, $subscriber_hash); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function removeSegmentMemberRequest($list_id, $segment_id, $subscriber_hash) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'segment_id' is set if ($segment_id === null || (is_array($segment_id) && count($segment_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $segment_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/lists/{list_id}/segments/{segment_id}/members/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($segment_id !== null) { $resourcePath = str_replace( '{' . 'segment_id' . '}', ObjectSerializer::toPathValue($segment_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteListWebhook($list_id, $webhook_id) { $this->deleteListWebhookWithHttpInfo($list_id, $webhook_id); } public function deleteListWebhookWithHttpInfo($list_id, $webhook_id) { $request = $this->deleteListWebhookRequest($list_id, $webhook_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteListWebhookRequest($list_id, $webhook_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'webhook_id' is set if ($webhook_id === null || (is_array($webhook_id) && count($webhook_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $webhook_id when calling ' ); } $resourcePath = '/lists/{list_id}/webhooks/{webhook_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($webhook_id !== null) { $resourcePath = str_replace( '{' . 'webhook_id' . '}', ObjectSerializer::toPathValue($webhook_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListMemberTags($list_id, $subscriber_hash, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getListMemberTagsWithHttpInfo($list_id, $subscriber_hash, $fields, $exclude_fields, $count, $offset); return $response; } public function getListMemberTagsWithHttpInfo($list_id, $subscriber_hash, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getListMemberTagsRequest($list_id, $subscriber_hash, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListMemberTagsRequest($list_id, $subscriber_hash, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}/tags'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getAllLists($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $before_date_created = null, $since_date_created = null, $before_campaign_last_sent = null, $since_campaign_last_sent = null, $email = null, $sort_field = null, $sort_dir = null, $has_ecommerce_store = null, $include_total_contacts = null) { $response = $this->getAllListsWithHttpInfo($fields, $exclude_fields, $count, $offset, $before_date_created, $since_date_created, $before_campaign_last_sent, $since_campaign_last_sent, $email, $sort_field, $sort_dir, $has_ecommerce_store, $include_total_contacts); return $response; } public function getAllListsWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $before_date_created = null, $since_date_created = null, $before_campaign_last_sent = null, $since_campaign_last_sent = null, $email = null, $sort_field = null, $sort_dir = null, $has_ecommerce_store = null, $include_total_contacts = null) { $request = $this->getAllListsRequest($fields, $exclude_fields, $count, $offset, $before_date_created, $since_date_created, $before_campaign_last_sent, $since_campaign_last_sent, $email, $sort_field, $sort_dir, $has_ecommerce_store, $include_total_contacts); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getAllListsRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $before_date_created = null, $since_date_created = null, $before_campaign_last_sent = null, $since_campaign_last_sent = null, $email = null, $sort_field = null, $sort_dir = null, $has_ecommerce_store = null, $include_total_contacts = null) { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($before_date_created !== null) { $queryParams['before_date_created'] = ObjectSerializer::toQueryValue($before_date_created); } // query params if ($since_date_created !== null) { $queryParams['since_date_created'] = ObjectSerializer::toQueryValue($since_date_created); } // query params if ($before_campaign_last_sent !== null) { $queryParams['before_campaign_last_sent'] = ObjectSerializer::toQueryValue($before_campaign_last_sent); } // query params if ($since_campaign_last_sent !== null) { $queryParams['since_campaign_last_sent'] = ObjectSerializer::toQueryValue($since_campaign_last_sent); } // query params if ($email !== null) { $queryParams['email'] = ObjectSerializer::toQueryValue($email); } // query params if ($sort_field !== null) { $queryParams['sort_field'] = ObjectSerializer::toQueryValue($sort_field); } // query params if ($sort_dir !== null) { $queryParams['sort_dir'] = ObjectSerializer::toQueryValue($sort_dir); } // query params if ($has_ecommerce_store !== null) { $queryParams['has_ecommerce_store'] = ObjectSerializer::toQueryValue($has_ecommerce_store); } // query params if ($include_total_contacts !== null) { $queryParams['include_total_contacts'] = ObjectSerializer::toQueryValue($include_total_contacts); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getList($list_id, $fields = null, $exclude_fields = null, $include_total_contacts = null) { $response = $this->getListWithHttpInfo($list_id, $fields, $exclude_fields, $include_total_contacts); return $response; } public function getListWithHttpInfo($list_id, $fields = null, $exclude_fields = null, $include_total_contacts = null) { $request = $this->getListRequest($list_id, $fields, $exclude_fields, $include_total_contacts); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListRequest($list_id, $fields = null, $exclude_fields = null, $include_total_contacts = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } $resourcePath = '/lists/{list_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($include_total_contacts !== null) { $queryParams['include_total_contacts'] = ObjectSerializer::toQueryValue($include_total_contacts); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListAbuseReports($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getListAbuseReportsWithHttpInfo($list_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getListAbuseReportsWithHttpInfo($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getListAbuseReportsRequest($list_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListAbuseReportsRequest($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/abuse-reports'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListAbuseReportDetails($list_id, $report_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getListAbuseReportDetailsWithHttpInfo($list_id, $report_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getListAbuseReportDetailsWithHttpInfo($list_id, $report_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getListAbuseReportDetailsRequest($list_id, $report_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListAbuseReportDetailsRequest($list_id, $report_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'report_id' is set if ($report_id === null || (is_array($report_id) && count($report_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $report_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/abuse-reports/{report_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($report_id !== null) { $resourcePath = str_replace( '{' . 'report_id' . '}', ObjectSerializer::toPathValue($report_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListRecentActivity($list_id, $count = '10', $offset = '0', $fields = null, $exclude_fields = null) { $response = $this->getListRecentActivityWithHttpInfo($list_id, $count, $offset, $fields, $exclude_fields); return $response; } public function getListRecentActivityWithHttpInfo($list_id, $count = '10', $offset = '0', $fields = null, $exclude_fields = null) { $request = $this->getListRecentActivityRequest($list_id, $count, $offset, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListRecentActivityRequest($list_id, $count = '10', $offset = '0', $fields = null, $exclude_fields = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/activity'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListClients($list_id, $fields = null, $exclude_fields = null) { $response = $this->getListClientsWithHttpInfo($list_id, $fields, $exclude_fields); return $response; } public function getListClientsWithHttpInfo($list_id, $fields = null, $exclude_fields = null) { $request = $this->getListClientsRequest($list_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListClientsRequest($list_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } $resourcePath = '/lists/{list_id}/clients'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListGrowthHistory($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null, $sort_dir = null) { $response = $this->getListGrowthHistoryWithHttpInfo($list_id, $fields, $exclude_fields, $count, $offset, $sort_field, $sort_dir); return $response; } public function getListGrowthHistoryWithHttpInfo($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null, $sort_dir = null) { $request = $this->getListGrowthHistoryRequest($list_id, $fields, $exclude_fields, $count, $offset, $sort_field, $sort_dir); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListGrowthHistoryRequest($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null, $sort_dir = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/growth-history'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($sort_field !== null) { $queryParams['sort_field'] = ObjectSerializer::toQueryValue($sort_field); } // query params if ($sort_dir !== null) { $queryParams['sort_dir'] = ObjectSerializer::toQueryValue($sort_dir); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListGrowthHistoryByMonth($list_id, $month, $fields = null, $exclude_fields = null) { $response = $this->getListGrowthHistoryByMonthWithHttpInfo($list_id, $month, $fields, $exclude_fields); return $response; } public function getListGrowthHistoryByMonthWithHttpInfo($list_id, $month, $fields = null, $exclude_fields = null) { $request = $this->getListGrowthHistoryByMonthRequest($list_id, $month, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListGrowthHistoryByMonthRequest($list_id, $month, $fields = null, $exclude_fields = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'month' is set if ($month === null || (is_array($month) && count($month) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $month when calling ' ); } $resourcePath = '/lists/{list_id}/growth-history/{month}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($month !== null) { $resourcePath = str_replace( '{' . 'month' . '}', ObjectSerializer::toPathValue($month), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListInterestCategories($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null) { $response = $this->getListInterestCategoriesWithHttpInfo($list_id, $fields, $exclude_fields, $count, $offset, $type); return $response; } public function getListInterestCategoriesWithHttpInfo($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null) { $request = $this->getListInterestCategoriesRequest($list_id, $fields, $exclude_fields, $count, $offset, $type); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListInterestCategoriesRequest($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/interest-categories'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($type !== null) { $queryParams['type'] = ObjectSerializer::toQueryValue($type); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getInterestCategory($list_id, $interest_category_id, $fields = null, $exclude_fields = null) { $response = $this->getInterestCategoryWithHttpInfo($list_id, $interest_category_id, $fields, $exclude_fields); return $response; } public function getInterestCategoryWithHttpInfo($list_id, $interest_category_id, $fields = null, $exclude_fields = null) { $request = $this->getInterestCategoryRequest($list_id, $interest_category_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getInterestCategoryRequest($list_id, $interest_category_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'interest_category_id' is set if ($interest_category_id === null || (is_array($interest_category_id) && count($interest_category_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $interest_category_id when calling ' ); } $resourcePath = '/lists/{list_id}/interest-categories/{interest_category_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($interest_category_id !== null) { $resourcePath = str_replace( '{' . 'interest_category_id' . '}', ObjectSerializer::toPathValue($interest_category_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function listInterestCategoryInterests($list_id, $interest_category_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->listInterestCategoryInterestsWithHttpInfo($list_id, $interest_category_id, $fields, $exclude_fields, $count, $offset); return $response; } public function listInterestCategoryInterestsWithHttpInfo($list_id, $interest_category_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->listInterestCategoryInterestsRequest($list_id, $interest_category_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listInterestCategoryInterestsRequest($list_id, $interest_category_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'interest_category_id' is set if ($interest_category_id === null || (is_array($interest_category_id) && count($interest_category_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $interest_category_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/interest-categories/{interest_category_id}/interests'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($interest_category_id !== null) { $resourcePath = str_replace( '{' . 'interest_category_id' . '}', ObjectSerializer::toPathValue($interest_category_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getInterestCategoryInterest($list_id, $interest_category_id, $interest_id, $fields = null, $exclude_fields = null) { $response = $this->getInterestCategoryInterestWithHttpInfo($list_id, $interest_category_id, $interest_id, $fields, $exclude_fields); return $response; } public function getInterestCategoryInterestWithHttpInfo($list_id, $interest_category_id, $interest_id, $fields = null, $exclude_fields = null) { $request = $this->getInterestCategoryInterestRequest($list_id, $interest_category_id, $interest_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getInterestCategoryInterestRequest($list_id, $interest_category_id, $interest_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'interest_category_id' is set if ($interest_category_id === null || (is_array($interest_category_id) && count($interest_category_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $interest_category_id when calling ' ); } // verify the required parameter 'interest_id' is set if ($interest_id === null || (is_array($interest_id) && count($interest_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $interest_id when calling ' ); } $resourcePath = '/lists/{list_id}/interest-categories/{interest_category_id}/interests/{interest_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($interest_category_id !== null) { $resourcePath = str_replace( '{' . 'interest_category_id' . '}', ObjectSerializer::toPathValue($interest_category_id), $resourcePath ); } // path params if ($interest_id !== null) { $resourcePath = str_replace( '{' . 'interest_id' . '}', ObjectSerializer::toPathValue($interest_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListLocations($list_id, $fields = null, $exclude_fields = null) { $response = $this->getListLocationsWithHttpInfo($list_id, $fields, $exclude_fields); return $response; } public function getListLocationsWithHttpInfo($list_id, $fields = null, $exclude_fields = null) { $request = $this->getListLocationsRequest($list_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListLocationsRequest($list_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } $resourcePath = '/lists/{list_id}/locations'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListMembersInfo($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $email_type = null, $status = null, $since_timestamp_opt = null, $before_timestamp_opt = null, $since_last_changed = null, $before_last_changed = null, $unique_email_id = null, $vip_only = null, $interest_category_id = null, $interest_ids = null, $interest_match = null, $sort_field = null, $sort_dir = null, $since_last_campaign = null, $unsubscribed_since = null) { $response = $this->getListMembersInfoWithHttpInfo($list_id, $fields, $exclude_fields, $count, $offset, $email_type, $status, $since_timestamp_opt, $before_timestamp_opt, $since_last_changed, $before_last_changed, $unique_email_id, $vip_only, $interest_category_id, $interest_ids, $interest_match, $sort_field, $sort_dir, $since_last_campaign, $unsubscribed_since); return $response; } public function getListMembersInfoWithHttpInfo($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $email_type = null, $status = null, $since_timestamp_opt = null, $before_timestamp_opt = null, $since_last_changed = null, $before_last_changed = null, $unique_email_id = null, $vip_only = null, $interest_category_id = null, $interest_ids = null, $interest_match = null, $sort_field = null, $sort_dir = null, $since_last_campaign = null, $unsubscribed_since = null) { $request = $this->getListMembersInfoRequest($list_id, $fields, $exclude_fields, $count, $offset, $email_type, $status, $since_timestamp_opt, $before_timestamp_opt, $since_last_changed, $before_last_changed, $unique_email_id, $vip_only, $interest_category_id, $interest_ids, $interest_match, $sort_field, $sort_dir, $since_last_campaign, $unsubscribed_since); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListMembersInfoRequest($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $email_type = null, $status = null, $since_timestamp_opt = null, $before_timestamp_opt = null, $since_last_changed = null, $before_last_changed = null, $unique_email_id = null, $vip_only = null, $interest_category_id = null, $interest_ids = null, $interest_match = null, $sort_field = null, $sort_dir = null, $since_last_campaign = null, $unsubscribed_since = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/members'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($email_type !== null) { $queryParams['email_type'] = ObjectSerializer::toQueryValue($email_type); } // query params if ($status !== null) { $queryParams['status'] = ObjectSerializer::toQueryValue($status); } // query params if ($since_timestamp_opt !== null) { $queryParams['since_timestamp_opt'] = ObjectSerializer::toQueryValue($since_timestamp_opt); } // query params if ($before_timestamp_opt !== null) { $queryParams['before_timestamp_opt'] = ObjectSerializer::toQueryValue($before_timestamp_opt); } // query params if ($since_last_changed !== null) { $queryParams['since_last_changed'] = ObjectSerializer::toQueryValue($since_last_changed); } // query params if ($before_last_changed !== null) { $queryParams['before_last_changed'] = ObjectSerializer::toQueryValue($before_last_changed); } // query params if ($unique_email_id !== null) { $queryParams['unique_email_id'] = ObjectSerializer::toQueryValue($unique_email_id); } // query params if ($vip_only !== null) { $queryParams['vip_only'] = ObjectSerializer::toQueryValue($vip_only); } // query params if ($interest_category_id !== null) { $queryParams['interest_category_id'] = ObjectSerializer::toQueryValue($interest_category_id); } // query params if ($interest_ids !== null) { $queryParams['interest_ids'] = ObjectSerializer::toQueryValue($interest_ids); } // query params if ($interest_match !== null) { $queryParams['interest_match'] = ObjectSerializer::toQueryValue($interest_match); } // query params if ($sort_field !== null) { $queryParams['sort_field'] = ObjectSerializer::toQueryValue($sort_field); } // query params if ($sort_dir !== null) { $queryParams['sort_dir'] = ObjectSerializer::toQueryValue($sort_dir); } // query params if ($since_last_campaign !== null) { $queryParams['since_last_campaign'] = ObjectSerializer::toQueryValue($since_last_campaign); } // query params if ($unsubscribed_since !== null) { $queryParams['unsubscribed_since'] = ObjectSerializer::toQueryValue($unsubscribed_since); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListMember($list_id, $subscriber_hash, $fields = null, $exclude_fields = null) { $response = $this->getListMemberWithHttpInfo($list_id, $subscriber_hash, $fields, $exclude_fields); return $response; } public function getListMemberWithHttpInfo($list_id, $subscriber_hash, $fields = null, $exclude_fields = null) { $request = $this->getListMemberRequest($list_id, $subscriber_hash, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListMemberRequest($list_id, $subscriber_hash, $fields = null, $exclude_fields = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListMemberActivity($list_id, $subscriber_hash, $fields = null, $exclude_fields = null, $action = null) { $response = $this->getListMemberActivityWithHttpInfo($list_id, $subscriber_hash, $fields, $exclude_fields, $action); return $response; } public function getListMemberActivityWithHttpInfo($list_id, $subscriber_hash, $fields = null, $exclude_fields = null, $action = null) { $request = $this->getListMemberActivityRequest($list_id, $subscriber_hash, $fields, $exclude_fields, $action); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListMemberActivityRequest($list_id, $subscriber_hash, $fields = null, $exclude_fields = null, $action = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}/activity'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if (is_array($action)) { $queryParams['action'] = ObjectSerializer::serializeCollection($action, 'csv'); } else if ($action !== null) { $queryParams['action'] = ObjectSerializer::toQueryValue($action); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListMemberActivityFeed($list_id, $subscriber_hash, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $activity_filters = null) { $response = $this->getListMemberActivityFeedWithHttpInfo($list_id, $subscriber_hash, $fields, $exclude_fields, $count, $offset, $activity_filters); return $response; } public function getListMemberActivityFeedWithHttpInfo($list_id, $subscriber_hash, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $activity_filters = null) { $request = $this->getListMemberActivityFeedRequest($list_id, $subscriber_hash, $fields, $exclude_fields, $count, $offset, $activity_filters); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListMemberActivityFeedRequest($list_id, $subscriber_hash, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $activity_filters = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}/activity-feed'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if (is_array($activity_filters)) { $queryParams['activity_filters'] = ObjectSerializer::serializeCollection($activity_filters, 'csv'); } else if ($activity_filters !== null) { $queryParams['activity_filters'] = ObjectSerializer::toQueryValue($activity_filters); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListMemberEvents($list_id, $subscriber_hash, $count = '10', $offset = '0', $fields = null, $exclude_fields = null) { $response = $this->getListMemberEventsWithHttpInfo($list_id, $subscriber_hash, $count, $offset, $fields, $exclude_fields); return $response; } public function getListMemberEventsWithHttpInfo($list_id, $subscriber_hash, $count = '10', $offset = '0', $fields = null, $exclude_fields = null) { $request = $this->getListMemberEventsRequest($list_id, $subscriber_hash, $count, $offset, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListMemberEventsRequest($list_id, $subscriber_hash, $count = '10', $offset = '0', $fields = null, $exclude_fields = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}/events'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListMemberGoals($list_id, $subscriber_hash, $fields = null, $exclude_fields = null) { $response = $this->getListMemberGoalsWithHttpInfo($list_id, $subscriber_hash, $fields, $exclude_fields); return $response; } public function getListMemberGoalsWithHttpInfo($list_id, $subscriber_hash, $fields = null, $exclude_fields = null) { $request = $this->getListMemberGoalsRequest($list_id, $subscriber_hash, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListMemberGoalsRequest($list_id, $subscriber_hash, $fields = null, $exclude_fields = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}/goals'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListMemberNotes($list_id, $subscriber_hash, $sort_field = null, $sort_dir = null, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getListMemberNotesWithHttpInfo($list_id, $subscriber_hash, $sort_field, $sort_dir, $fields, $exclude_fields, $count, $offset); return $response; } public function getListMemberNotesWithHttpInfo($list_id, $subscriber_hash, $sort_field = null, $sort_dir = null, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getListMemberNotesRequest($list_id, $subscriber_hash, $sort_field, $sort_dir, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListMemberNotesRequest($list_id, $subscriber_hash, $sort_field = null, $sort_dir = null, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}/notes'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($sort_field !== null) { $queryParams['sort_field'] = ObjectSerializer::toQueryValue($sort_field); } // query params if ($sort_dir !== null) { $queryParams['sort_dir'] = ObjectSerializer::toQueryValue($sort_dir); } // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListMemberNote($list_id, $subscriber_hash, $note_id, $fields = null, $exclude_fields = null) { $response = $this->getListMemberNoteWithHttpInfo($list_id, $subscriber_hash, $note_id, $fields, $exclude_fields); return $response; } public function getListMemberNoteWithHttpInfo($list_id, $subscriber_hash, $note_id, $fields = null, $exclude_fields = null) { $request = $this->getListMemberNoteRequest($list_id, $subscriber_hash, $note_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListMemberNoteRequest($list_id, $subscriber_hash, $note_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } // verify the required parameter 'note_id' is set if ($note_id === null || (is_array($note_id) && count($note_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $note_id when calling ' ); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}/notes/{note_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // path params if ($note_id !== null) { $resourcePath = str_replace( '{' . 'note_id' . '}', ObjectSerializer::toPathValue($note_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListMergeFields($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $required = null) { $response = $this->getListMergeFieldsWithHttpInfo($list_id, $fields, $exclude_fields, $count, $offset, $type, $required); return $response; } public function getListMergeFieldsWithHttpInfo($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $required = null) { $request = $this->getListMergeFieldsRequest($list_id, $fields, $exclude_fields, $count, $offset, $type, $required); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListMergeFieldsRequest($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $required = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/merge-fields'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($type !== null) { $queryParams['type'] = ObjectSerializer::toQueryValue($type); } // query params if ($required !== null) { $queryParams['required'] = ObjectSerializer::toQueryValue($required); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListMergeField($list_id, $merge_id, $exclude_fields = null, $fields = null) { $response = $this->getListMergeFieldWithHttpInfo($list_id, $merge_id, $exclude_fields, $fields); return $response; } public function getListMergeFieldWithHttpInfo($list_id, $merge_id, $exclude_fields = null, $fields = null) { $request = $this->getListMergeFieldRequest($list_id, $merge_id, $exclude_fields, $fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListMergeFieldRequest($list_id, $merge_id, $exclude_fields = null, $fields = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'merge_id' is set if ($merge_id === null || (is_array($merge_id) && count($merge_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $merge_id when calling ' ); } $resourcePath = '/lists/{list_id}/merge-fields/{merge_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($merge_id !== null) { $resourcePath = str_replace( '{' . 'merge_id' . '}', ObjectSerializer::toPathValue($merge_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSegment($list_id, $segment_id, $fields = null, $exclude_fields = null, $include_cleaned = null, $include_transactional = null, $include_unsubscribed = null) { $response = $this->getSegmentWithHttpInfo($list_id, $segment_id, $fields, $exclude_fields, $include_cleaned, $include_transactional, $include_unsubscribed); return $response; } public function getSegmentWithHttpInfo($list_id, $segment_id, $fields = null, $exclude_fields = null, $include_cleaned = null, $include_transactional = null, $include_unsubscribed = null) { $request = $this->getSegmentRequest($list_id, $segment_id, $fields, $exclude_fields, $include_cleaned, $include_transactional, $include_unsubscribed); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSegmentRequest($list_id, $segment_id, $fields = null, $exclude_fields = null, $include_cleaned = null, $include_transactional = null, $include_unsubscribed = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'segment_id' is set if ($segment_id === null || (is_array($segment_id) && count($segment_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $segment_id when calling ' ); } $resourcePath = '/lists/{list_id}/segments/{segment_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($include_cleaned !== null) { $queryParams['include_cleaned'] = ObjectSerializer::toQueryValue($include_cleaned); } // query params if ($include_transactional !== null) { $queryParams['include_transactional'] = ObjectSerializer::toQueryValue($include_transactional); } // query params if ($include_unsubscribed !== null) { $queryParams['include_unsubscribed'] = ObjectSerializer::toQueryValue($include_unsubscribed); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($segment_id !== null) { $resourcePath = str_replace( '{' . 'segment_id' . '}', ObjectSerializer::toPathValue($segment_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSegmentMembersList($list_id, $segment_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $include_cleaned = null, $include_transactional = null, $include_unsubscribed = null) { $response = $this->getSegmentMembersListWithHttpInfo($list_id, $segment_id, $fields, $exclude_fields, $count, $offset, $include_cleaned, $include_transactional, $include_unsubscribed); return $response; } public function getSegmentMembersListWithHttpInfo($list_id, $segment_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $include_cleaned = null, $include_transactional = null, $include_unsubscribed = null) { $request = $this->getSegmentMembersListRequest($list_id, $segment_id, $fields, $exclude_fields, $count, $offset, $include_cleaned, $include_transactional, $include_unsubscribed); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSegmentMembersListRequest($list_id, $segment_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $include_cleaned = null, $include_transactional = null, $include_unsubscribed = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'segment_id' is set if ($segment_id === null || (is_array($segment_id) && count($segment_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $segment_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/segments/{segment_id}/members'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($include_cleaned !== null) { $queryParams['include_cleaned'] = ObjectSerializer::toQueryValue($include_cleaned); } // query params if ($include_transactional !== null) { $queryParams['include_transactional'] = ObjectSerializer::toQueryValue($include_transactional); } // query params if ($include_unsubscribed !== null) { $queryParams['include_unsubscribed'] = ObjectSerializer::toQueryValue($include_unsubscribed); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($segment_id !== null) { $resourcePath = str_replace( '{' . 'segment_id' . '}', ObjectSerializer::toPathValue($segment_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListSignupForms($list_id) { $response = $this->getListSignupFormsWithHttpInfo($list_id); return $response; } public function getListSignupFormsWithHttpInfo($list_id) { $request = $this->getListSignupFormsRequest($list_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListSignupFormsRequest($list_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } $resourcePath = '/lists/{list_id}/signup-forms'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getAllSurveysForList($list_id) { $this->getAllSurveysForListWithHttpInfo($list_id); } public function getAllSurveysForListWithHttpInfo($list_id) { $request = $this->getAllSurveysForListRequest($list_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getAllSurveysForListRequest($list_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } $resourcePath = '/lists/{list_id}/surveys'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSurvey($list_id, $survey_id) { $this->getSurveyWithHttpInfo($list_id, $survey_id); } public function getSurveyWithHttpInfo($list_id, $survey_id) { $request = $this->getSurveyRequest($list_id, $survey_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSurveyRequest($list_id, $survey_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'survey_id' is set if ($survey_id === null || (is_array($survey_id) && count($survey_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $survey_id when calling ' ); } $resourcePath = '/lists/{list_id}/surveys/{survey_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($survey_id !== null) { $resourcePath = str_replace( '{' . 'survey_id' . '}', ObjectSerializer::toPathValue($survey_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListWebhooks($list_id) { $response = $this->getListWebhooksWithHttpInfo($list_id); return $response; } public function getListWebhooksWithHttpInfo($list_id) { $request = $this->getListWebhooksRequest($list_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListWebhooksRequest($list_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } $resourcePath = '/lists/{list_id}/webhooks'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getListWebhook($list_id, $webhook_id) { $response = $this->getListWebhookWithHttpInfo($list_id, $webhook_id); return $response; } public function getListWebhookWithHttpInfo($list_id, $webhook_id) { $request = $this->getListWebhookRequest($list_id, $webhook_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getListWebhookRequest($list_id, $webhook_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'webhook_id' is set if ($webhook_id === null || (is_array($webhook_id) && count($webhook_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $webhook_id when calling ' ); } $resourcePath = '/lists/{list_id}/webhooks/{webhook_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($webhook_id !== null) { $resourcePath = str_replace( '{' . 'webhook_id' . '}', ObjectSerializer::toPathValue($webhook_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateList($list_id, $body) { $response = $this->updateListWithHttpInfo($list_id, $body); return $response; } public function updateListWithHttpInfo($list_id, $body) { $request = $this->updateListRequest($list_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateListRequest($list_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateInterestCategory($list_id, $interest_category_id, $body) { $response = $this->updateInterestCategoryWithHttpInfo($list_id, $interest_category_id, $body); return $response; } public function updateInterestCategoryWithHttpInfo($list_id, $interest_category_id, $body) { $request = $this->updateInterestCategoryRequest($list_id, $interest_category_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateInterestCategoryRequest($list_id, $interest_category_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'interest_category_id' is set if ($interest_category_id === null || (is_array($interest_category_id) && count($interest_category_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $interest_category_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/interest-categories/{interest_category_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($interest_category_id !== null) { $resourcePath = str_replace( '{' . 'interest_category_id' . '}', ObjectSerializer::toPathValue($interest_category_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateInterestCategoryInterest($list_id, $interest_category_id, $interest_id, $body) { $response = $this->updateInterestCategoryInterestWithHttpInfo($list_id, $interest_category_id, $interest_id, $body); return $response; } public function updateInterestCategoryInterestWithHttpInfo($list_id, $interest_category_id, $interest_id, $body) { $request = $this->updateInterestCategoryInterestRequest($list_id, $interest_category_id, $interest_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateInterestCategoryInterestRequest($list_id, $interest_category_id, $interest_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'interest_category_id' is set if ($interest_category_id === null || (is_array($interest_category_id) && count($interest_category_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $interest_category_id when calling ' ); } // verify the required parameter 'interest_id' is set if ($interest_id === null || (is_array($interest_id) && count($interest_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $interest_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/interest-categories/{interest_category_id}/interests/{interest_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($interest_category_id !== null) { $resourcePath = str_replace( '{' . 'interest_category_id' . '}', ObjectSerializer::toPathValue($interest_category_id), $resourcePath ); } // path params if ($interest_id !== null) { $resourcePath = str_replace( '{' . 'interest_id' . '}', ObjectSerializer::toPathValue($interest_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateListMember($list_id, $subscriber_hash, $body, $skip_merge_validation = null) { $response = $this->updateListMemberWithHttpInfo($list_id, $subscriber_hash, $body, $skip_merge_validation); return $response; } public function updateListMemberWithHttpInfo($list_id, $subscriber_hash, $body, $skip_merge_validation = null) { $request = $this->updateListMemberRequest($list_id, $subscriber_hash, $body, $skip_merge_validation); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateListMemberRequest($list_id, $subscriber_hash, $body, $skip_merge_validation = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($skip_merge_validation !== null) { $queryParams['skip_merge_validation'] = ObjectSerializer::toQueryValue($skip_merge_validation); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateListMemberNote($list_id, $subscriber_hash, $note_id, $body) { $response = $this->updateListMemberNoteWithHttpInfo($list_id, $subscriber_hash, $note_id, $body); return $response; } public function updateListMemberNoteWithHttpInfo($list_id, $subscriber_hash, $note_id, $body) { $request = $this->updateListMemberNoteRequest($list_id, $subscriber_hash, $note_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateListMemberNoteRequest($list_id, $subscriber_hash, $note_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } // verify the required parameter 'note_id' is set if ($note_id === null || (is_array($note_id) && count($note_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $note_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}/notes/{note_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // path params if ($note_id !== null) { $resourcePath = str_replace( '{' . 'note_id' . '}', ObjectSerializer::toPathValue($note_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateListMergeField($list_id, $merge_id, $body) { $response = $this->updateListMergeFieldWithHttpInfo($list_id, $merge_id, $body); return $response; } public function updateListMergeFieldWithHttpInfo($list_id, $merge_id, $body) { $request = $this->updateListMergeFieldRequest($list_id, $merge_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateListMergeFieldRequest($list_id, $merge_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'merge_id' is set if ($merge_id === null || (is_array($merge_id) && count($merge_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $merge_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/merge-fields/{merge_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($merge_id !== null) { $resourcePath = str_replace( '{' . 'merge_id' . '}', ObjectSerializer::toPathValue($merge_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateSegment($list_id, $segment_id, $body) { $response = $this->updateSegmentWithHttpInfo($list_id, $segment_id, $body); return $response; } public function updateSegmentWithHttpInfo($list_id, $segment_id, $body) { $request = $this->updateSegmentRequest($list_id, $segment_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateSegmentRequest($list_id, $segment_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'segment_id' is set if ($segment_id === null || (is_array($segment_id) && count($segment_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $segment_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/segments/{segment_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($segment_id !== null) { $resourcePath = str_replace( '{' . 'segment_id' . '}', ObjectSerializer::toPathValue($segment_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateListWebhook($list_id, $webhook_id, $body) { $response = $this->updateListWebhookWithHttpInfo($list_id, $webhook_id, $body); return $response; } public function updateListWebhookWithHttpInfo($list_id, $webhook_id, $body) { $request = $this->updateListWebhookRequest($list_id, $webhook_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateListWebhookRequest($list_id, $webhook_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'webhook_id' is set if ($webhook_id === null || (is_array($webhook_id) && count($webhook_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $webhook_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/webhooks/{webhook_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($webhook_id !== null) { $resourcePath = str_replace( '{' . 'webhook_id' . '}', ObjectSerializer::toPathValue($webhook_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function createListMemberEvent($list_id, $subscriber_hash, $body) { $this->createListMemberEventWithHttpInfo($list_id, $subscriber_hash, $body); } public function createListMemberEventWithHttpInfo($list_id, $subscriber_hash, $body) { $request = $this->createListMemberEventRequest($list_id, $subscriber_hash, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createListMemberEventRequest($list_id, $subscriber_hash, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}/events'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateListMemberTags($list_id, $subscriber_hash, $body) { $this->updateListMemberTagsWithHttpInfo($list_id, $subscriber_hash, $body); } public function updateListMemberTagsWithHttpInfo($list_id, $subscriber_hash, $body) { $request = $this->updateListMemberTagsRequest($list_id, $subscriber_hash, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateListMemberTagsRequest($list_id, $subscriber_hash, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}/tags'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function createList($body) { $response = $this->createListWithHttpInfo($body); return $response; } public function createListWithHttpInfo($body) { $request = $this->createListRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createListRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function batchListMembers($list_id, $body, $skip_merge_validation = null, $skip_duplicate_check = null) { $response = $this->batchListMembersWithHttpInfo($list_id, $body, $skip_merge_validation, $skip_duplicate_check); return $response; } public function batchListMembersWithHttpInfo($list_id, $body, $skip_merge_validation = null, $skip_duplicate_check = null) { $request = $this->batchListMembersRequest($list_id, $body, $skip_merge_validation, $skip_duplicate_check); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function batchListMembersRequest($list_id, $body, $skip_merge_validation = null, $skip_duplicate_check = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($skip_merge_validation !== null) { $queryParams['skip_merge_validation'] = ObjectSerializer::toQueryValue($skip_merge_validation); } // query params if ($skip_duplicate_check !== null) { $queryParams['skip_duplicate_check'] = ObjectSerializer::toQueryValue($skip_duplicate_check); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function createListInterestCategory($list_id, $body) { $response = $this->createListInterestCategoryWithHttpInfo($list_id, $body); return $response; } public function createListInterestCategoryWithHttpInfo($list_id, $body) { $request = $this->createListInterestCategoryRequest($list_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createListInterestCategoryRequest($list_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/interest-categories'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function createInterestCategoryInterest($list_id, $interest_category_id, $body) { $response = $this->createInterestCategoryInterestWithHttpInfo($list_id, $interest_category_id, $body); return $response; } public function createInterestCategoryInterestWithHttpInfo($list_id, $interest_category_id, $body) { $request = $this->createInterestCategoryInterestRequest($list_id, $interest_category_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createInterestCategoryInterestRequest($list_id, $interest_category_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'interest_category_id' is set if ($interest_category_id === null || (is_array($interest_category_id) && count($interest_category_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $interest_category_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/interest-categories/{interest_category_id}/interests'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($interest_category_id !== null) { $resourcePath = str_replace( '{' . 'interest_category_id' . '}', ObjectSerializer::toPathValue($interest_category_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addListMember($list_id, $body, $skip_merge_validation = null) { $response = $this->addListMemberWithHttpInfo($list_id, $body, $skip_merge_validation); return $response; } public function addListMemberWithHttpInfo($list_id, $body, $skip_merge_validation = null) { $request = $this->addListMemberRequest($list_id, $body, $skip_merge_validation); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addListMemberRequest($list_id, $body, $skip_merge_validation = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/members'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($skip_merge_validation !== null) { $queryParams['skip_merge_validation'] = ObjectSerializer::toQueryValue($skip_merge_validation); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteListMemberPermanent($list_id, $subscriber_hash) { $this->deleteListMemberPermanentWithHttpInfo($list_id, $subscriber_hash); } public function deleteListMemberPermanentWithHttpInfo($list_id, $subscriber_hash) { $request = $this->deleteListMemberPermanentRequest($list_id, $subscriber_hash); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteListMemberPermanentRequest($list_id, $subscriber_hash) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}/actions/delete-permanent'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function createListMemberNote($list_id, $subscriber_hash, $body) { $response = $this->createListMemberNoteWithHttpInfo($list_id, $subscriber_hash, $body); return $response; } public function createListMemberNoteWithHttpInfo($list_id, $subscriber_hash, $body) { $request = $this->createListMemberNoteRequest($list_id, $subscriber_hash, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createListMemberNoteRequest($list_id, $subscriber_hash, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}/notes'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function addListMergeField($list_id, $body) { $response = $this->addListMergeFieldWithHttpInfo($list_id, $body); return $response; } public function addListMergeFieldWithHttpInfo($list_id, $body) { $request = $this->addListMergeFieldRequest($list_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function addListMergeFieldRequest($list_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/merge-fields'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function createSegment($list_id, $body) { $response = $this->createSegmentWithHttpInfo($list_id, $body); return $response; } public function createSegmentWithHttpInfo($list_id, $body) { $request = $this->createSegmentRequest($list_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createSegmentRequest($list_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/segments'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function batchSegmentMembers($body, $list_id, $segment_id) { $response = $this->batchSegmentMembersWithHttpInfo($body, $list_id, $segment_id); return $response; } public function batchSegmentMembersWithHttpInfo($body, $list_id, $segment_id) { $request = $this->batchSegmentMembersRequest($body, $list_id, $segment_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function batchSegmentMembersRequest($body, $list_id, $segment_id) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'segment_id' is set if ($segment_id === null || (is_array($segment_id) && count($segment_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $segment_id when calling ' ); } $resourcePath = '/lists/{list_id}/segments/{segment_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($segment_id !== null) { $resourcePath = str_replace( '{' . 'segment_id' . '}', ObjectSerializer::toPathValue($segment_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function createSegmentMember($list_id, $segment_id, $body) { $response = $this->createSegmentMemberWithHttpInfo($list_id, $segment_id, $body); return $response; } public function createSegmentMemberWithHttpInfo($list_id, $segment_id, $body) { $request = $this->createSegmentMemberRequest($list_id, $segment_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createSegmentMemberRequest($list_id, $segment_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'segment_id' is set if ($segment_id === null || (is_array($segment_id) && count($segment_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $segment_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/segments/{segment_id}/members'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($segment_id !== null) { $resourcePath = str_replace( '{' . 'segment_id' . '}', ObjectSerializer::toPathValue($segment_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateListSignupForm($list_id, $body) { $response = $this->updateListSignupFormWithHttpInfo($list_id, $body); return $response; } public function updateListSignupFormWithHttpInfo($list_id, $body) { $request = $this->updateListSignupFormRequest($list_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateListSignupFormRequest($list_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/signup-forms'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function createListWebhook($list_id, $body) { $response = $this->createListWebhookWithHttpInfo($list_id, $body); return $response; } public function createListWebhookWithHttpInfo($list_id, $body) { $request = $this->createListWebhookRequest($list_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createListWebhookRequest($list_id, $body) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/webhooks'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function listSegments($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $since_created_at = null, $before_created_at = null, $include_cleaned = null, $include_transactional = null, $include_unsubscribed = null, $since_updated_at = null, $before_updated_at = null) { $response = $this->listSegmentsWithHttpInfo($list_id, $fields, $exclude_fields, $count, $offset, $type, $since_created_at, $before_created_at, $include_cleaned, $include_transactional, $include_unsubscribed, $since_updated_at, $before_updated_at); return $response; } public function listSegmentsWithHttpInfo($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $since_created_at = null, $before_created_at = null, $include_cleaned = null, $include_transactional = null, $include_unsubscribed = null, $since_updated_at = null, $before_updated_at = null) { $request = $this->listSegmentsRequest($list_id, $fields, $exclude_fields, $count, $offset, $type, $since_created_at, $before_created_at, $include_cleaned, $include_transactional, $include_unsubscribed, $since_updated_at, $before_updated_at); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listSegmentsRequest($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $since_created_at = null, $before_created_at = null, $include_cleaned = null, $include_transactional = null, $include_unsubscribed = null, $since_updated_at = null, $before_updated_at = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ListsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/lists/{list_id}/segments'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($type !== null) { $queryParams['type'] = ObjectSerializer::toQueryValue($type); } // query params if ($since_created_at !== null) { $queryParams['since_created_at'] = ObjectSerializer::toQueryValue($since_created_at); } // query params if ($before_created_at !== null) { $queryParams['before_created_at'] = ObjectSerializer::toQueryValue($before_created_at); } // query params if ($include_cleaned !== null) { $queryParams['include_cleaned'] = ObjectSerializer::toQueryValue($include_cleaned); } // query params if ($include_transactional !== null) { $queryParams['include_transactional'] = ObjectSerializer::toQueryValue($include_transactional); } // query params if ($include_unsubscribed !== null) { $queryParams['include_unsubscribed'] = ObjectSerializer::toQueryValue($include_unsubscribed); } // query params if ($since_updated_at !== null) { $queryParams['since_updated_at'] = ObjectSerializer::toQueryValue($since_updated_at); } // query params if ($before_updated_at !== null) { $queryParams['before_updated_at'] = ObjectSerializer::toQueryValue($before_updated_at); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function setListMember($list_id, $subscriber_hash, $body, $skip_merge_validation = null) { $response = $this->setListMemberWithHttpInfo($list_id, $subscriber_hash, $body, $skip_merge_validation); return $response; } public function setListMemberWithHttpInfo($list_id, $subscriber_hash, $body, $skip_merge_validation = null) { $request = $this->setListMemberRequest($list_id, $subscriber_hash, $body, $skip_merge_validation); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function setListMemberRequest($list_id, $subscriber_hash, $body, $skip_merge_validation = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/lists/{list_id}/members/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($skip_merge_validation !== null) { $queryParams['skip_merge_validation'] = ObjectSerializer::toQueryValue($skip_merge_validation); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PUT', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function tagSearch($list_id, $name = null) { $response = $this->tagSearchWithHttpInfo($list_id, $name); return $response; } public function tagSearchWithHttpInfo($list_id, $name = null) { $request = $this->tagSearchRequest($list_id, $name); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function tagSearchRequest($list_id, $name = null) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } $resourcePath = '/lists/{list_id}/tag-search'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($name !== null) { $queryParams['name'] = ObjectSerializer::toQueryValue($name); } // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/PingApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function get() { $response = $this->getWithHttpInfo(); return $response; } public function getWithHttpInfo() { $request = $this->getRequest(); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getRequest() { $resourcePath = '/ping'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/ReportingApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function getFacebookAdsReportAll($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null, $sort_dir = null) { $response = $this->getFacebookAdsReportAllWithHttpInfo($fields, $exclude_fields, $count, $offset, $sort_field, $sort_dir); return $response; } public function getFacebookAdsReportAllWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null, $sort_dir = null) { $request = $this->getFacebookAdsReportAllRequest($fields, $exclude_fields, $count, $offset, $sort_field, $sort_dir); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getFacebookAdsReportAllRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null, $sort_dir = null) { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ReportingApi., must be smaller than or equal to 1000.'); } $resourcePath = '/reporting/facebook-ads'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($sort_field !== null) { $queryParams['sort_field'] = ObjectSerializer::toQueryValue($sort_field); } // query params if ($sort_dir !== null) { $queryParams['sort_dir'] = ObjectSerializer::toQueryValue($sort_dir); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getFacebookAdReport($outreach_id, $fields = null, $exclude_fields = null) { $response = $this->getFacebookAdReportWithHttpInfo($outreach_id, $fields, $exclude_fields); return $response; } public function getFacebookAdReportWithHttpInfo($outreach_id, $fields = null, $exclude_fields = null) { $request = $this->getFacebookAdReportRequest($outreach_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getFacebookAdReportRequest($outreach_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'outreach_id' is set if ($outreach_id === null || (is_array($outreach_id) && count($outreach_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $outreach_id when calling ' ); } $resourcePath = '/reporting/facebook-ads/{outreach_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($outreach_id !== null) { $resourcePath = str_replace( '{' . 'outreach_id' . '}', ObjectSerializer::toPathValue($outreach_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getFacebookAdProductActivityReport($outreach_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null) { $response = $this->getFacebookAdProductActivityReportWithHttpInfo($outreach_id, $fields, $exclude_fields, $count, $offset, $sort_field); return $response; } public function getFacebookAdProductActivityReportWithHttpInfo($outreach_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null) { $request = $this->getFacebookAdProductActivityReportRequest($outreach_id, $fields, $exclude_fields, $count, $offset, $sort_field); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getFacebookAdProductActivityReportRequest($outreach_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null) { // verify the required parameter 'outreach_id' is set if ($outreach_id === null || (is_array($outreach_id) && count($outreach_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $outreach_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ReportingApi., must be smaller than or equal to 1000.'); } $resourcePath = '/reporting/facebook-ads/{outreach_id}/ecommerce-product-activity'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($sort_field !== null) { $queryParams['sort_field'] = ObjectSerializer::toQueryValue($sort_field); } // path params if ($outreach_id !== null) { $resourcePath = str_replace( '{' . 'outreach_id' . '}', ObjectSerializer::toPathValue($outreach_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getLandingPageReportsAll($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getLandingPageReportsAllWithHttpInfo($fields, $exclude_fields, $count, $offset); return $response; } public function getLandingPageReportsAllWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getLandingPageReportsAllRequest($fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getLandingPageReportsAllRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ReportingApi., must be smaller than or equal to 1000.'); } $resourcePath = '/reporting/landing-pages'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getLandingPageReport($outreach_id, $fields = null, $exclude_fields = null) { $response = $this->getLandingPageReportWithHttpInfo($outreach_id, $fields, $exclude_fields); return $response; } public function getLandingPageReportWithHttpInfo($outreach_id, $fields = null, $exclude_fields = null) { $request = $this->getLandingPageReportRequest($outreach_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getLandingPageReportRequest($outreach_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'outreach_id' is set if ($outreach_id === null || (is_array($outreach_id) && count($outreach_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $outreach_id when calling ' ); } $resourcePath = '/reporting/landing-pages/{outreach_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($outreach_id !== null) { $resourcePath = str_replace( '{' . 'outreach_id' . '}', ObjectSerializer::toPathValue($outreach_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSurveyReportsAll($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getSurveyReportsAllWithHttpInfo($fields, $exclude_fields, $count, $offset); return $response; } public function getSurveyReportsAllWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getSurveyReportsAllRequest($fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSurveyReportsAllRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ReportingApi., must be smaller than or equal to 1000.'); } $resourcePath = '/reporting/surveys'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSurveyReport($outreach_id, $fields = null, $exclude_fields = null) { $response = $this->getSurveyReportWithHttpInfo($outreach_id, $fields, $exclude_fields); return $response; } public function getSurveyReportWithHttpInfo($outreach_id, $fields = null, $exclude_fields = null) { $request = $this->getSurveyReportRequest($outreach_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSurveyReportRequest($outreach_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'outreach_id' is set if ($outreach_id === null || (is_array($outreach_id) && count($outreach_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $outreach_id when calling ' ); } $resourcePath = '/reporting/surveys/{outreach_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($outreach_id !== null) { $resourcePath = str_replace( '{' . 'outreach_id' . '}', ObjectSerializer::toPathValue($outreach_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSurveyQuestionReportsAll($outreach_id, $fields = null, $exclude_fields = null) { $response = $this->getSurveyQuestionReportsAllWithHttpInfo($outreach_id, $fields, $exclude_fields); return $response; } public function getSurveyQuestionReportsAllWithHttpInfo($outreach_id, $fields = null, $exclude_fields = null) { $request = $this->getSurveyQuestionReportsAllRequest($outreach_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSurveyQuestionReportsAllRequest($outreach_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'outreach_id' is set if ($outreach_id === null || (is_array($outreach_id) && count($outreach_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $outreach_id when calling ' ); } $resourcePath = '/reporting/surveys/{outreach_id}/questions'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($outreach_id !== null) { $resourcePath = str_replace( '{' . 'outreach_id' . '}', ObjectSerializer::toPathValue($outreach_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSurveyQuestionReport($outreach_id, $question_id, $fields = null, $exclude_fields = null) { $response = $this->getSurveyQuestionReportWithHttpInfo($outreach_id, $question_id, $fields, $exclude_fields); return $response; } public function getSurveyQuestionReportWithHttpInfo($outreach_id, $question_id, $fields = null, $exclude_fields = null) { $request = $this->getSurveyQuestionReportRequest($outreach_id, $question_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSurveyQuestionReportRequest($outreach_id, $question_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'outreach_id' is set if ($outreach_id === null || (is_array($outreach_id) && count($outreach_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $outreach_id when calling ' ); } // verify the required parameter 'question_id' is set if ($question_id === null || (is_array($question_id) && count($question_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $question_id when calling ' ); } $resourcePath = '/reporting/surveys/{outreach_id}/questions/{question_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($outreach_id !== null) { $resourcePath = str_replace( '{' . 'outreach_id' . '}', ObjectSerializer::toPathValue($outreach_id), $resourcePath ); } // path params if ($question_id !== null) { $resourcePath = str_replace( '{' . 'question_id' . '}', ObjectSerializer::toPathValue($question_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSurveyQuestionAnswers($outreach_id, $question_id, $fields = null, $exclude_fields = null, $respondent_familiarity_is = null) { $response = $this->getSurveyQuestionAnswersWithHttpInfo($outreach_id, $question_id, $fields, $exclude_fields, $respondent_familiarity_is); return $response; } public function getSurveyQuestionAnswersWithHttpInfo($outreach_id, $question_id, $fields = null, $exclude_fields = null, $respondent_familiarity_is = null) { $request = $this->getSurveyQuestionAnswersRequest($outreach_id, $question_id, $fields, $exclude_fields, $respondent_familiarity_is); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSurveyQuestionAnswersRequest($outreach_id, $question_id, $fields = null, $exclude_fields = null, $respondent_familiarity_is = null) { // verify the required parameter 'outreach_id' is set if ($outreach_id === null || (is_array($outreach_id) && count($outreach_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $outreach_id when calling ' ); } // verify the required parameter 'question_id' is set if ($question_id === null || (is_array($question_id) && count($question_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $question_id when calling ' ); } $resourcePath = '/reporting/surveys/{outreach_id}/questions/{question_id}/answers'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($respondent_familiarity_is !== null) { $queryParams['respondent_familiarity_is'] = ObjectSerializer::toQueryValue($respondent_familiarity_is); } // path params if ($outreach_id !== null) { $resourcePath = str_replace( '{' . 'outreach_id' . '}', ObjectSerializer::toPathValue($outreach_id), $resourcePath ); } // path params if ($question_id !== null) { $resourcePath = str_replace( '{' . 'question_id' . '}', ObjectSerializer::toPathValue($question_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSurveyResponsesAll($outreach_id, $fields = null, $exclude_fields = null, $answered_question = null, $chose_answer = null, $respondent_familiarity_is = null) { $response = $this->getSurveyResponsesAllWithHttpInfo($outreach_id, $fields, $exclude_fields, $answered_question, $chose_answer, $respondent_familiarity_is); return $response; } public function getSurveyResponsesAllWithHttpInfo($outreach_id, $fields = null, $exclude_fields = null, $answered_question = null, $chose_answer = null, $respondent_familiarity_is = null) { $request = $this->getSurveyResponsesAllRequest($outreach_id, $fields, $exclude_fields, $answered_question, $chose_answer, $respondent_familiarity_is); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSurveyResponsesAllRequest($outreach_id, $fields = null, $exclude_fields = null, $answered_question = null, $chose_answer = null, $respondent_familiarity_is = null) { // verify the required parameter 'outreach_id' is set if ($outreach_id === null || (is_array($outreach_id) && count($outreach_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $outreach_id when calling ' ); } $resourcePath = '/reporting/surveys/{outreach_id}/responses'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($answered_question !== null) { $queryParams['answered_question'] = ObjectSerializer::toQueryValue($answered_question); } // query params if ($chose_answer !== null) { $queryParams['chose_answer'] = ObjectSerializer::toQueryValue($chose_answer); } // query params if ($respondent_familiarity_is !== null) { $queryParams['respondent_familiarity_is'] = ObjectSerializer::toQueryValue($respondent_familiarity_is); } // path params if ($outreach_id !== null) { $resourcePath = str_replace( '{' . 'outreach_id' . '}', ObjectSerializer::toPathValue($outreach_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSurveyResponse($outreach_id, $response_id) { $response = $this->getSurveyResponseWithHttpInfo($outreach_id, $response_id); return $response; } public function getSurveyResponseWithHttpInfo($outreach_id, $response_id) { $request = $this->getSurveyResponseRequest($outreach_id, $response_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSurveyResponseRequest($outreach_id, $response_id) { // verify the required parameter 'outreach_id' is set if ($outreach_id === null || (is_array($outreach_id) && count($outreach_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $outreach_id when calling ' ); } // verify the required parameter 'response_id' is set if ($response_id === null || (is_array($response_id) && count($response_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $response_id when calling ' ); } $resourcePath = '/reporting/surveys/{outreach_id}/responses/{response_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($outreach_id !== null) { $resourcePath = str_replace( '{' . 'outreach_id' . '}', ObjectSerializer::toPathValue($outreach_id), $resourcePath ); } // path params if ($response_id !== null) { $resourcePath = str_replace( '{' . 'response_id' . '}', ObjectSerializer::toPathValue($response_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/ReportsApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function getAllCampaignReports($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $before_send_time = null, $since_send_time = null) { $response = $this->getAllCampaignReportsWithHttpInfo($fields, $exclude_fields, $count, $offset, $type, $before_send_time, $since_send_time); return $response; } public function getAllCampaignReportsWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $before_send_time = null, $since_send_time = null) { $request = $this->getAllCampaignReportsRequest($fields, $exclude_fields, $count, $offset, $type, $before_send_time, $since_send_time); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getAllCampaignReportsRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $type = null, $before_send_time = null, $since_send_time = null) { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/reports'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($type !== null) { $queryParams['type'] = ObjectSerializer::toQueryValue($type); } // query params if ($before_send_time !== null) { $queryParams['before_send_time'] = ObjectSerializer::toQueryValue($before_send_time); } // query params if ($since_send_time !== null) { $queryParams['since_send_time'] = ObjectSerializer::toQueryValue($since_send_time); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getCampaignReport($campaign_id, $fields = null, $exclude_fields = null) { $response = $this->getCampaignReportWithHttpInfo($campaign_id, $fields, $exclude_fields); return $response; } public function getCampaignReportWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null) { $request = $this->getCampaignReportRequest($campaign_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getCampaignReportRequest($campaign_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/reports/{campaign_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getCampaignAbuseReports($campaign_id, $fields = null, $exclude_fields = null) { $response = $this->getCampaignAbuseReportsWithHttpInfo($campaign_id, $fields, $exclude_fields); return $response; } public function getCampaignAbuseReportsWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null) { $request = $this->getCampaignAbuseReportsRequest($campaign_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getCampaignAbuseReportsRequest($campaign_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/reports/{campaign_id}/abuse-reports'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getCampaignAbuseReport($campaign_id, $report_id, $fields = null, $exclude_fields = null) { $response = $this->getCampaignAbuseReportWithHttpInfo($campaign_id, $report_id, $fields, $exclude_fields); return $response; } public function getCampaignAbuseReportWithHttpInfo($campaign_id, $report_id, $fields = null, $exclude_fields = null) { $request = $this->getCampaignAbuseReportRequest($campaign_id, $report_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getCampaignAbuseReportRequest($campaign_id, $report_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'report_id' is set if ($report_id === null || (is_array($report_id) && count($report_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $report_id when calling ' ); } $resourcePath = '/reports/{campaign_id}/abuse-reports/{report_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // path params if ($report_id !== null) { $resourcePath = str_replace( '{' . 'report_id' . '}', ObjectSerializer::toPathValue($report_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getCampaignAdvice($campaign_id, $fields = null, $exclude_fields = null) { $response = $this->getCampaignAdviceWithHttpInfo($campaign_id, $fields, $exclude_fields); return $response; } public function getCampaignAdviceWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null) { $request = $this->getCampaignAdviceRequest($campaign_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getCampaignAdviceRequest($campaign_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/reports/{campaign_id}/advice'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getCampaignClickDetails($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getCampaignClickDetailsWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getCampaignClickDetailsWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getCampaignClickDetailsRequest($campaign_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getCampaignClickDetailsRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/reports/{campaign_id}/click-details'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getCampaignClickDetailsForLink($campaign_id, $link_id, $fields = null, $exclude_fields = null) { $response = $this->getCampaignClickDetailsForLinkWithHttpInfo($campaign_id, $link_id, $fields, $exclude_fields); return $response; } public function getCampaignClickDetailsForLinkWithHttpInfo($campaign_id, $link_id, $fields = null, $exclude_fields = null) { $request = $this->getCampaignClickDetailsForLinkRequest($campaign_id, $link_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getCampaignClickDetailsForLinkRequest($campaign_id, $link_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'link_id' is set if ($link_id === null || (is_array($link_id) && count($link_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $link_id when calling ' ); } $resourcePath = '/reports/{campaign_id}/click-details/{link_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // path params if ($link_id !== null) { $resourcePath = str_replace( '{' . 'link_id' . '}', ObjectSerializer::toPathValue($link_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSubscribersInfo($campaign_id, $link_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getSubscribersInfoWithHttpInfo($campaign_id, $link_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getSubscribersInfoWithHttpInfo($campaign_id, $link_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getSubscribersInfoRequest($campaign_id, $link_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSubscribersInfoRequest($campaign_id, $link_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'link_id' is set if ($link_id === null || (is_array($link_id) && count($link_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $link_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/reports/{campaign_id}/click-details/{link_id}/members'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // path params if ($link_id !== null) { $resourcePath = str_replace( '{' . 'link_id' . '}', ObjectSerializer::toPathValue($link_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSubscriberInfo($campaign_id, $link_id, $subscriber_hash, $fields = null, $exclude_fields = null) { $response = $this->getSubscriberInfoWithHttpInfo($campaign_id, $link_id, $subscriber_hash, $fields, $exclude_fields); return $response; } public function getSubscriberInfoWithHttpInfo($campaign_id, $link_id, $subscriber_hash, $fields = null, $exclude_fields = null) { $request = $this->getSubscriberInfoRequest($campaign_id, $link_id, $subscriber_hash, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSubscriberInfoRequest($campaign_id, $link_id, $subscriber_hash, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'link_id' is set if ($link_id === null || (is_array($link_id) && count($link_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $link_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/reports/{campaign_id}/click-details/{link_id}/members/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // path params if ($link_id !== null) { $resourcePath = str_replace( '{' . 'link_id' . '}', ObjectSerializer::toPathValue($link_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getDomainPerformanceForCampaign($campaign_id, $fields = null, $exclude_fields = null) { $response = $this->getDomainPerformanceForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields); return $response; } public function getDomainPerformanceForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null) { $request = $this->getDomainPerformanceForCampaignRequest($campaign_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getDomainPerformanceForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/reports/{campaign_id}/domain-performance'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getEcommerceProductActivityForCampaign($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null) { $response = $this->getEcommerceProductActivityForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset, $sort_field); return $response; } public function getEcommerceProductActivityForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null) { $request = $this->getEcommerceProductActivityForCampaignRequest($campaign_id, $fields, $exclude_fields, $count, $offset, $sort_field); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getEcommerceProductActivityForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $sort_field = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/reports/{campaign_id}/ecommerce-product-activity'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($sort_field !== null) { $queryParams['sort_field'] = ObjectSerializer::toQueryValue($sort_field); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getEepurlActivityForCampaign($campaign_id, $fields = null, $exclude_fields = null) { $response = $this->getEepurlActivityForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields); return $response; } public function getEepurlActivityForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null) { $request = $this->getEepurlActivityForCampaignRequest($campaign_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getEepurlActivityForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/reports/{campaign_id}/eepurl'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getEmailActivityForCampaign($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $since = null) { $response = $this->getEmailActivityForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset, $since); return $response; } public function getEmailActivityForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $since = null) { $request = $this->getEmailActivityForCampaignRequest($campaign_id, $fields, $exclude_fields, $count, $offset, $since); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getEmailActivityForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $since = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/reports/{campaign_id}/email-activity'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($since !== null) { $queryParams['since'] = ObjectSerializer::toQueryValue($since); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getEmailActivityForSubscriber($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null, $since = null) { $response = $this->getEmailActivityForSubscriberWithHttpInfo($campaign_id, $subscriber_hash, $fields, $exclude_fields, $since); return $response; } public function getEmailActivityForSubscriberWithHttpInfo($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null, $since = null) { $request = $this->getEmailActivityForSubscriberRequest($campaign_id, $subscriber_hash, $fields, $exclude_fields, $since); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getEmailActivityForSubscriberRequest($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null, $since = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/reports/{campaign_id}/email-activity/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($since !== null) { $queryParams['since'] = ObjectSerializer::toQueryValue($since); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getLocationsForCampaign($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getLocationsForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getLocationsForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getLocationsForCampaignRequest($campaign_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getLocationsForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/reports/{campaign_id}/locations'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getCampaignOpenDetails($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $since = null) { $response = $this->getCampaignOpenDetailsWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset, $since); return $response; } public function getCampaignOpenDetailsWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $since = null) { $request = $this->getCampaignOpenDetailsRequest($campaign_id, $fields, $exclude_fields, $count, $offset, $since); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getCampaignOpenDetailsRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $since = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/reports/{campaign_id}/open-details'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($since !== null) { $queryParams['since'] = ObjectSerializer::toQueryValue($since); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSubscriberInfoForOpenedCampaign($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null) { $response = $this->getSubscriberInfoForOpenedCampaignWithHttpInfo($campaign_id, $subscriber_hash, $fields, $exclude_fields); return $response; } public function getSubscriberInfoForOpenedCampaignWithHttpInfo($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null) { $request = $this->getSubscriberInfoForOpenedCampaignRequest($campaign_id, $subscriber_hash, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSubscriberInfoForOpenedCampaignRequest($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/reports/{campaign_id}/open-details/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getCampaignRecipients($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getCampaignRecipientsWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getCampaignRecipientsWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getCampaignRecipientsRequest($campaign_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getCampaignRecipientsRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/reports/{campaign_id}/sent-to'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getCampaignRecipient($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null) { $response = $this->getCampaignRecipientWithHttpInfo($campaign_id, $subscriber_hash, $fields, $exclude_fields); return $response; } public function getCampaignRecipientWithHttpInfo($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null) { $request = $this->getCampaignRecipientRequest($campaign_id, $subscriber_hash, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getCampaignRecipientRequest($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/reports/{campaign_id}/sent-to/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getSubReportsForCampaign($campaign_id, $fields = null, $exclude_fields = null) { $response = $this->getSubReportsForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields); return $response; } public function getSubReportsForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null) { $request = $this->getSubReportsForCampaignRequest($campaign_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getSubReportsForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } $resourcePath = '/reports/{campaign_id}/sub-reports'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getUnsubscribedListForCampaign($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->getUnsubscribedListForCampaignWithHttpInfo($campaign_id, $fields, $exclude_fields, $count, $offset); return $response; } public function getUnsubscribedListForCampaignWithHttpInfo($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->getUnsubscribedListForCampaignRequest($campaign_id, $fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getUnsubscribedListForCampaignRequest($campaign_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0') { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling ReportsApi., must be smaller than or equal to 1000.'); } $resourcePath = '/reports/{campaign_id}/unsubscribed'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getUnsubscribedListMember($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null) { $response = $this->getUnsubscribedListMemberWithHttpInfo($campaign_id, $subscriber_hash, $fields, $exclude_fields); return $response; } public function getUnsubscribedListMemberWithHttpInfo($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null) { $request = $this->getUnsubscribedListMemberRequest($campaign_id, $subscriber_hash, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getUnsubscribedListMemberRequest($campaign_id, $subscriber_hash, $fields = null, $exclude_fields = null) { // verify the required parameter 'campaign_id' is set if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $campaign_id when calling ' ); } // verify the required parameter 'subscriber_hash' is set if ($subscriber_hash === null || (is_array($subscriber_hash) && count($subscriber_hash) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $subscriber_hash when calling ' ); } $resourcePath = '/reports/{campaign_id}/unsubscribed/{subscriber_hash}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($campaign_id !== null) { $resourcePath = str_replace( '{' . 'campaign_id' . '}', ObjectSerializer::toPathValue($campaign_id), $resourcePath ); } // path params if ($subscriber_hash !== null) { $resourcePath = str_replace( '{' . 'subscriber_hash' . '}', ObjectSerializer::toPathValue($subscriber_hash), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/RootApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function getRoot($fields = null, $exclude_fields = null) { $response = $this->getRootWithHttpInfo($fields, $exclude_fields); return $response; } public function getRootWithHttpInfo($fields = null, $exclude_fields = null) { $request = $this->getRootRequest($fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getRootRequest($fields = null, $exclude_fields = null) { $resourcePath = '/'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/SearchCampaignsApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function search($query, $fields = null, $exclude_fields = null) { $response = $this->searchWithHttpInfo($query, $fields, $exclude_fields); return $response; } public function searchWithHttpInfo($query, $fields = null, $exclude_fields = null) { $request = $this->searchRequest($query, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function searchRequest($query, $fields = null, $exclude_fields = null) { // verify the required parameter 'query' is set if ($query === null || (is_array($query) && count($query) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $query when calling ' ); } $resourcePath = '/search-campaigns'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($query !== null) { $queryParams['query'] = ObjectSerializer::toQueryValue($query); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/SearchMembersApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function search($query, $fields = null, $exclude_fields = null, $list_id = null) { $response = $this->searchWithHttpInfo($query, $fields, $exclude_fields, $list_id); return $response; } public function searchWithHttpInfo($query, $fields = null, $exclude_fields = null, $list_id = null) { $request = $this->searchRequest($query, $fields, $exclude_fields, $list_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function searchRequest($query, $fields = null, $exclude_fields = null, $list_id = null) { // verify the required parameter 'query' is set if ($query === null || (is_array($query) && count($query) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $query when calling ' ); } $resourcePath = '/search-members'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($query !== null) { $queryParams['query'] = ObjectSerializer::toQueryValue($query); } // query params if ($list_id !== null) { $queryParams['list_id'] = ObjectSerializer::toQueryValue($list_id); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/SurveysApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function publishSurvey($list_id, $survey_id) { $this->publishSurveyWithHttpInfo($list_id, $survey_id); } public function publishSurveyWithHttpInfo($list_id, $survey_id) { $request = $this->publishSurveyRequest($list_id, $survey_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function publishSurveyRequest($list_id, $survey_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'survey_id' is set if ($survey_id === null || (is_array($survey_id) && count($survey_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $survey_id when calling ' ); } $resourcePath = '/lists/{list_id}/surveys/{survey_id}/actions/publish'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($survey_id !== null) { $resourcePath = str_replace( '{' . 'survey_id' . '}', ObjectSerializer::toPathValue($survey_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function unpublishSurvey($list_id, $survey_id) { $this->unpublishSurveyWithHttpInfo($list_id, $survey_id); } public function unpublishSurveyWithHttpInfo($list_id, $survey_id) { $request = $this->unpublishSurveyRequest($list_id, $survey_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function unpublishSurveyRequest($list_id, $survey_id) { // verify the required parameter 'list_id' is set if ($list_id === null || (is_array($list_id) && count($list_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $list_id when calling ' ); } // verify the required parameter 'survey_id' is set if ($survey_id === null || (is_array($survey_id) && count($survey_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $survey_id when calling ' ); } $resourcePath = '/lists/{list_id}/surveys/{survey_id}/actions/unpublish'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($list_id !== null) { $resourcePath = str_replace( '{' . 'list_id' . '}', ObjectSerializer::toPathValue($list_id), $resourcePath ); } // path params if ($survey_id !== null) { $resourcePath = str_replace( '{' . 'survey_id' . '}', ObjectSerializer::toPathValue($survey_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/TemplateFoldersApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function remove($folder_id) { $this->removeWithHttpInfo($folder_id); } public function removeWithHttpInfo($folder_id) { $request = $this->removeRequest($folder_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function removeRequest($folder_id) { // verify the required parameter 'folder_id' is set if ($folder_id === null || (is_array($folder_id) && count($folder_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $folder_id when calling ' ); } $resourcePath = '/template-folders/{folder_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($folder_id !== null) { $resourcePath = str_replace( '{' . 'folder_id' . '}', ObjectSerializer::toPathValue($folder_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function list($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $response = $this->listWithHttpInfo($fields, $exclude_fields, $count, $offset); return $response; } public function listWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { $request = $this->listRequest($fields, $exclude_fields, $count, $offset); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0') { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling TemplateFoldersApi., must be smaller than or equal to 1000.'); } $resourcePath = '/template-folders'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function get($folder_id, $fields = null, $exclude_fields = null) { $response = $this->getWithHttpInfo($folder_id, $fields, $exclude_fields); return $response; } public function getWithHttpInfo($folder_id, $fields = null, $exclude_fields = null) { $request = $this->getRequest($folder_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getRequest($folder_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'folder_id' is set if ($folder_id === null || (is_array($folder_id) && count($folder_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $folder_id when calling ' ); } $resourcePath = '/template-folders/{folder_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($folder_id !== null) { $resourcePath = str_replace( '{' . 'folder_id' . '}', ObjectSerializer::toPathValue($folder_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function update($folder_id, $body) { $response = $this->updateWithHttpInfo($folder_id, $body); return $response; } public function updateWithHttpInfo($folder_id, $body) { $request = $this->updateRequest($folder_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateRequest($folder_id, $body) { // verify the required parameter 'folder_id' is set if ($folder_id === null || (is_array($folder_id) && count($folder_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $folder_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/template-folders/{folder_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($folder_id !== null) { $resourcePath = str_replace( '{' . 'folder_id' . '}', ObjectSerializer::toPathValue($folder_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function create($body) { $response = $this->createWithHttpInfo($body); return $response; } public function createWithHttpInfo($body) { $request = $this->createRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/template-folders'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/TemplatesApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function deleteTemplate($template_id) { $this->deleteTemplateWithHttpInfo($template_id); } public function deleteTemplateWithHttpInfo($template_id) { $request = $this->deleteTemplateRequest($template_id); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteTemplateRequest($template_id) { // verify the required parameter 'template_id' is set if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $template_id when calling ' ); } $resourcePath = '/templates/{template_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($template_id !== null) { $resourcePath = str_replace( '{' . 'template_id' . '}', ObjectSerializer::toPathValue($template_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function list($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $created_by = null, $since_date_created = null, $before_date_created = null, $type = null, $category = null, $folder_id = null, $sort_field = null, $sort_dir = null) { $response = $this->listWithHttpInfo($fields, $exclude_fields, $count, $offset, $created_by, $since_date_created, $before_date_created, $type, $category, $folder_id, $sort_field, $sort_dir); return $response; } public function listWithHttpInfo($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $created_by = null, $since_date_created = null, $before_date_created = null, $type = null, $category = null, $folder_id = null, $sort_field = null, $sort_dir = null) { $request = $this->listRequest($fields, $exclude_fields, $count, $offset, $created_by, $since_date_created, $before_date_created, $type, $category, $folder_id, $sort_field, $sort_dir); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function listRequest($fields = null, $exclude_fields = null, $count = '10', $offset = '0', $created_by = null, $since_date_created = null, $before_date_created = null, $type = null, $category = null, $folder_id = null, $sort_field = null, $sort_dir = null) { if ($count !== null && $count > 1000) { throw new \InvalidArgumentException('invalid value for "$count" when calling TemplatesApi., must be smaller than or equal to 1000.'); } $resourcePath = '/templates'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // query params if ($count !== null) { $queryParams['count'] = ObjectSerializer::toQueryValue($count); } // query params if ($offset !== null) { $queryParams['offset'] = ObjectSerializer::toQueryValue($offset); } // query params if ($created_by !== null) { $queryParams['created_by'] = ObjectSerializer::toQueryValue($created_by); } // query params if ($since_date_created !== null) { $queryParams['since_date_created'] = ObjectSerializer::toQueryValue($since_date_created); } // query params if ($before_date_created !== null) { $queryParams['before_date_created'] = ObjectSerializer::toQueryValue($before_date_created); } // query params if ($type !== null) { $queryParams['type'] = ObjectSerializer::toQueryValue($type); } // query params if ($category !== null) { $queryParams['category'] = ObjectSerializer::toQueryValue($category); } // query params if ($folder_id !== null) { $queryParams['folder_id'] = ObjectSerializer::toQueryValue($folder_id); } // query params if ($sort_field !== null) { $queryParams['sort_field'] = ObjectSerializer::toQueryValue($sort_field); } // query params if ($sort_dir !== null) { $queryParams['sort_dir'] = ObjectSerializer::toQueryValue($sort_dir); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getTemplate($template_id, $fields = null, $exclude_fields = null) { $response = $this->getTemplateWithHttpInfo($template_id, $fields, $exclude_fields); return $response; } public function getTemplateWithHttpInfo($template_id, $fields = null, $exclude_fields = null) { $request = $this->getTemplateRequest($template_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getTemplateRequest($template_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'template_id' is set if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $template_id when calling ' ); } $resourcePath = '/templates/{template_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($template_id !== null) { $resourcePath = str_replace( '{' . 'template_id' . '}', ObjectSerializer::toPathValue($template_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getDefaultContentForTemplate($template_id, $fields = null, $exclude_fields = null) { $response = $this->getDefaultContentForTemplateWithHttpInfo($template_id, $fields, $exclude_fields); return $response; } public function getDefaultContentForTemplateWithHttpInfo($template_id, $fields = null, $exclude_fields = null) { $request = $this->getDefaultContentForTemplateRequest($template_id, $fields, $exclude_fields); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getDefaultContentForTemplateRequest($template_id, $fields = null, $exclude_fields = null) { // verify the required parameter 'template_id' is set if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $template_id when calling ' ); } $resourcePath = '/templates/{template_id}/default-content'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if (is_array($fields)) { $queryParams['fields'] = ObjectSerializer::serializeCollection($fields, 'csv'); } else if ($fields !== null) { $queryParams['fields'] = ObjectSerializer::toQueryValue($fields); } // query params if (is_array($exclude_fields)) { $queryParams['exclude_fields'] = ObjectSerializer::serializeCollection($exclude_fields, 'csv'); } else if ($exclude_fields !== null) { $queryParams['exclude_fields'] = ObjectSerializer::toQueryValue($exclude_fields); } // path params if ($template_id !== null) { $resourcePath = str_replace( '{' . 'template_id' . '}', ObjectSerializer::toPathValue($template_id), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function updateTemplate($template_id, $body) { $response = $this->updateTemplateWithHttpInfo($template_id, $body); return $response; } public function updateTemplateWithHttpInfo($template_id, $body) { $request = $this->updateTemplateRequest($template_id, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function updateTemplateRequest($template_id, $body) { // verify the required parameter 'template_id' is set if ($template_id === null || (is_array($template_id) && count($template_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $template_id when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/templates/{template_id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($template_id !== null) { $resourcePath = str_replace( '{' . 'template_id' . '}', ObjectSerializer::toPathValue($template_id), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function create($body) { $response = $this->createWithHttpInfo($body); return $response; } public function createWithHttpInfo($body) { $request = $this->createRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/templates'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/Api/VerifiedDomainsApi.php ================================================ client = new Client([ 'defaults' => [ 'timeout' => 120.0 ] ]); $this->headerSelector = new HeaderSelector(); $this->config = $config ?: new Configuration(); } public function getConfig() { return $this->config; } public function createVerifiedDomain($body) { $response = $this->createVerifiedDomainWithHttpInfo($body); return $response; } public function createVerifiedDomainWithHttpInfo($body) { $request = $this->createVerifiedDomainRequest($body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function createVerifiedDomainRequest($body) { // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/verified-domains'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function deleteDomain($domain_name) { $this->deleteDomainWithHttpInfo($domain_name); } public function deleteDomainWithHttpInfo($domain_name) { $request = $this->deleteDomainRequest($domain_name); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function deleteDomainRequest($domain_name) { // verify the required parameter 'domain_name' is set if ($domain_name === null || (is_array($domain_name) && count($domain_name) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $domain_name when calling ' ); } $resourcePath = '/verified-domains/{domain_name}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($domain_name !== null) { $resourcePath = str_replace( '{' . 'domain_name' . '}', ObjectSerializer::toPathValue($domain_name), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getDomain($domain_name) { $response = $this->getDomainWithHttpInfo($domain_name); return $response; } public function getDomainWithHttpInfo($domain_name) { $request = $this->getDomainRequest($domain_name); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getDomainRequest($domain_name) { // verify the required parameter 'domain_name' is set if ($domain_name === null || (is_array($domain_name) && count($domain_name) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $domain_name when calling ' ); } $resourcePath = '/verified-domains/{domain_name}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($domain_name !== null) { $resourcePath = str_replace( '{' . 'domain_name' . '}', ObjectSerializer::toPathValue($domain_name), $resourcePath ); } // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function getVerifiedDomainsAll() { $response = $this->getVerifiedDomainsAllWithHttpInfo(); return $response; } public function getVerifiedDomainsAllWithHttpInfo() { $request = $this->getVerifiedDomainsAllRequest(); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function getVerifiedDomainsAllRequest() { $resourcePath = '/verified-domains'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // body params $_tempBody = null; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } public function submitDomainVerification($domain_name, $body) { $response = $this->submitDomainVerificationWithHttpInfo($domain_name, $body); return $response; } public function submitDomainVerificationWithHttpInfo($domain_name, $body) { $request = $this->submitDomainVerificationRequest($domain_name, $body); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw $e; } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); $content = $responseBody->getContents(); $content = json_decode($content); return $content; } catch (ApiException $e) { throw $e->getResponseBody(); } } protected function submitDomainVerificationRequest($domain_name, $body) { // verify the required parameter 'domain_name' is set if ($domain_name === null || (is_array($domain_name) && count($domain_name) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $domain_name when calling ' ); } // verify the required parameter 'body' is set if ($body === null || (is_array($body) && count($body) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $body when calling ' ); } $resourcePath = '/verified-domains/{domain_name}/actions/verify'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($domain_name !== null) { $resourcePath = str_replace( '{' . 'domain_name' . '}', ObjectSerializer::toPathValue($domain_name), $resourcePath ); } // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json', 'application/problem+json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json', 'application/problem+json'], ['application/json'] ); } // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; if($headers['Content-Type'] === 'application/json') { if ($httpBody instanceof \stdClass) { $httpBody = \GuzzleHttp\json_encode($httpBody); } if (is_array($httpBody)) { $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); } } } elseif (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValue ]; } $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { $httpBody = Query::build($formParams); } } // Basic Authentication if (!empty($this->config->getUsername()) && !empty($this->config->getPassword())) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } // OAuth Authentication if (!empty($this->config->getAccessToken())) { $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $query = Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getTimeout()) { $options[RequestOptions::TIMEOUT] = $this->config->getTimeout(); } return $options; } } ================================================ FILE: lib/ApiClient.php ================================================ responseHeaders = $responseHeaders; $this->responseBody = $responseBody; } /** * Gets the HTTP response header * * @return string[]|null HTTP response header */ public function getResponseHeaders() { return $this->responseHeaders; } /** * Gets the HTTP body of the server response either as Json or string * * @return mixed HTTP body of the server response either as \stdClass or string */ public function getResponseBody() { return $this->responseBody; } /** * Sets the deseralized response object (during deserialization) * * @param mixed $obj Deserialized response object * * @return void */ public function setResponseObject($obj) { $this->responseObject = $obj; } /** * Gets the deseralized response object (during deserialization) * * @return mixed the deserialized response object */ public function getResponseObject() { return $this->responseObject; } } ================================================ FILE: lib/Configuration.php ================================================ tempFolderPath = sys_get_temp_dir(); $this->accountExport = new AccountExportApi($this); $this->accountExports = new AccountExportsApi($this); $this->activityFeed = new ActivityFeedApi($this); $this->authorizedApps = new AuthorizedAppsApi($this); $this->automations = new AutomationsApi($this); $this->batchWebhooks = new BatchWebhooksApi($this); $this->batches = new BatchesApi($this); $this->campaignFolders = new CampaignFoldersApi($this); $this->campaigns = new CampaignsApi($this); $this->connectedSites = new ConnectedSitesApi($this); $this->conversations = new ConversationsApi($this); $this->customerJourneys = new CustomerJourneysApi($this); $this->ecommerce = new EcommerceApi($this); $this->facebookAds = new FacebookAdsApi($this); $this->fileManager = new FileManagerApi($this); $this->landingPages = new LandingPagesApi($this); $this->lists = new ListsApi($this); $this->ping = new PingApi($this); $this->reporting = new ReportingApi($this); $this->reports = new ReportsApi($this); $this->root = new RootApi($this); $this->searchCampaigns = new SearchCampaignsApi($this); $this->searchMembers = new SearchMembersApi($this); $this->Surveys = new SurveysApi($this); $this->templateFolders = new TemplateFoldersApi($this); $this->templates = new TemplatesApi($this); $this->verifiedDomains = new VerifiedDomainsApi($this); } public function setConfig($config = array()) { $apiKey = isset($config['apiKey']) ? $config['apiKey'] : ''; $accessToken = isset($config['accessToken']) ? $config['accessToken'] : ''; $server = isset($config['server']) ? $config['server'] : 'invalid-server'; $host = str_replace('server', $server, $this->getHost()); // Basic Authentication if (!empty($apiKey)) { $this->setUsername('user'); $this->setPassword($apiKey); } // OAuth Authentication elseif (!empty($accessToken)) { $this->accessToken = $accessToken; } $this->setHost($host); if (isset($config['timeout'])) { $this->timeout = $config['timeout']; } return $this; } public function setApiKey($apiKeyIdentifier, $key) { $this->apiKeys[$apiKeyIdentifier] = $key; return $this; } public function getApiKey($apiKeyIdentifier) { return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null; } public function setApiKeyPrefix($apiKeyIdentifier, $prefix) { $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix; return $this; } public function getApiKeyPrefix($apiKeyIdentifier) { return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null; } public function setAccessToken($accessToken) { $this->accessToken = $accessToken; return $this; } public function getAccessToken() { return $this->accessToken; } public function setUsername($username) { $this->username = $username; return $this; } public function getUsername() { return $this->username; } public function setPassword($password) { $this->password = $password; return $this; } public function getPassword() { return $this->password; } public function setHost($host) { $this->host = $host; return $this; } public function getHost() { return $this->host; } public function setUserAgent($userAgent) { if (!is_string($userAgent)) { throw new \InvalidArgumentException('User-agent must be a string.'); } $this->userAgent = $userAgent; return $this; } public function getUserAgent() { return $this->userAgent; } public function setDebug($debug) { $this->debug = $debug; return $this; } public function getDebug() { return $this->debug; } public function setDebugFile($debugFile) { $this->debugFile = $debugFile; return $this; } public function getDebugFile() { return $this->debugFile; } public function setTempFolderPath($tempFolderPath) { $this->tempFolderPath = $tempFolderPath; return $this; } public function getTempFolderPath() { return $this->tempFolderPath; } public function setTimeout($timeout) { $this->timeout = $timeout; } public function getTimeout() { return $this->timeout; } public static function getDefaultConfiguration() { if (self::$defaultConfiguration === null) { self::$defaultConfiguration = new Configuration(); } return self::$defaultConfiguration; } public static function setDefaultConfiguration(Configuration $config) { self::$defaultConfiguration = $config; } public static function toDebugReport() { $report = 'PHP SDK (MailchimpMarketing) Debug Report:' . PHP_EOL; $report .= ' OS: ' . php_uname() . PHP_EOL; $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' OpenAPI Spec Version: 3.0.80' . PHP_EOL; $report .= ' SDK Package Version: 3.0.80' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; } public function getApiKeyWithPrefix($apiKeyIdentifier) { $prefix = $this->getApiKeyPrefix($apiKeyIdentifier); $apiKey = $this->getApiKey($apiKeyIdentifier); if ($apiKey === null) { return null; } if ($prefix === null) { $keyWithPrefix = $apiKey; } else { $keyWithPrefix = $prefix . ' ' . $apiKey; } return $keyWithPrefix; } } ================================================ FILE: lib/HeaderSelector.php ================================================ selectAcceptHeader($accept); if ($accept !== null) { $headers['Accept'] = $accept; } $headers['Content-Type'] = $this->selectContentTypeHeader($contentTypes); return $headers; } /** * @param string[] $accept * @return array */ public function selectHeadersForMultipart($accept) { $headers = $this->selectHeaders($accept, []); unset($headers['Content-Type']); return $headers; } /** * Return the header 'Accept' based on an array of Accept provided * * @param string[] $accept Array of header * * @return string Accept (e.g. application/json) */ private function selectAcceptHeader($accept) { if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) { return null; } elseif (preg_grep("/application\/json/i", $accept)) { return 'application/json'; } else { return implode(',', $accept); } } /** * Return the content type based on an array of content-type provided * * @param string[] $contentType Array fo content-type * * @return string Content-Type (e.g. application/json) */ private function selectContentTypeHeader($contentType) { if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) { return 'application/json'; } elseif (preg_grep("/application\/json/i", $contentType)) { return 'application/json'; } else { return implode(',', $contentType); } } } ================================================ FILE: lib/ObjectSerializer.php ================================================ format('Y-m-d') : $data->format(\DateTime::ATOM); } elseif (is_array($data)) { foreach ($data as $property => $value) { $data[$property] = self::sanitizeForSerialization($value); } return $data; } elseif ($data instanceof \stdClass) { foreach ($data as $property => $value) { $data->$property = self::sanitizeForSerialization($value); } return $data; } elseif (is_object($data)) { $values = []; $formats = $data::swaggerFormats(); foreach ($data::swaggerTypes() as $property => $swaggerType) { $getter = $data::getters()[$property]; $value = $data->$getter(); if ($value !== null && !in_array($swaggerType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true) && method_exists($swaggerType, 'getAllowableEnumValues') && !in_array($value, $swaggerType::getAllowableEnumValues(), true)) { $imploded = implode("', '", $swaggerType::getAllowableEnumValues()); throw new \InvalidArgumentException("Invalid value for enum '$swaggerType', must be one of: '$imploded'"); } if ($value !== null) { $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $swaggerType, $formats[$property]); } } return (object)$values; } else { return (string)$data; } } /** * Sanitize filename by removing path. * e.g. ../../sun.gif becomes sun.gif * * @param string $filename filename to be sanitized * * @return string the sanitized filename */ public static function sanitizeFilename($filename) { if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) { return $match[1]; } else { return $filename; } } /** * Take value and turn it into a string suitable for inclusion in * the path, by url-encoding. * * @param string $value a string which will be part of the path * * @return string the serialized object */ public static function toPathValue($value) { return rawurlencode(self::toString($value)); } /** * Take value and turn it into a string suitable for inclusion in * the query, by imploding comma-separated if it's an object. * If it's a string, pass through unchanged. It will be url-encoded * later. * * @param string[]|string|\DateTime $object an object to be serialized to a string * * @return string the serialized object */ public static function toQueryValue($object) { if (is_array($object)) { return implode(',', $object); } else { return self::toString($object); } } /** * Take value and turn it into a string suitable for inclusion in * the header. If it's a string, pass through unchanged * If it's a datetime object, format it in ISO8601 * * @param string $value a string which will be part of the header * * @return string the header string */ public static function toHeaderValue($value) { return self::toString($value); } /** * Take value and turn it into a string suitable for inclusion in * the http body (form parameter). If it's a string, pass through unchanged * If it's a datetime object, format it in ISO8601 * * @param string|\SplFileObject $value the value of the form parameter * * @return string the form string */ public static function toFormValue($value) { if ($value instanceof \SplFileObject) { return $value->getRealPath(); } else { return self::toString($value); } } /** * Take value and turn it into a string suitable for inclusion in * the parameter. If it's a string, pass through unchanged * If it's a datetime object, format it in ISO8601 * * @param string|\DateTime $value the value of the parameter * * @return string the header string */ public static function toString($value) { if ($value instanceof \DateTime) { // datetime in ISO8601 format return $value->format(\DateTime::ATOM); } else { return $value; } } /** * Serialize an array to a string. * * @param array $collection collection to serialize to a string * @param string $collectionFormat the format use for serialization (csv, * ssv, tsv, pipes, multi) * @param bool $allowCollectionFormatMulti allow collection format to be a multidimensional array * * @return string */ public static function serializeCollection(array $collection, $collectionFormat, $allowCollectionFormatMulti = false) { if ($allowCollectionFormatMulti && ('multi' === $collectionFormat)) { // http_build_query() almost does the job for us. We just // need to fix the result of multidimensional arrays. return preg_replace('/%5B[0-9]+%5D=/', '=', http_build_query($collection, '', '&')); } switch ($collectionFormat) { case 'pipes': return implode('|', $collection); case 'tsv': return implode("\t", $collection); case 'ssv': return implode(' ', $collection); case 'csv': // Deliberate fall through. CSV is default format. default: return implode(',', $collection); } } /** * Deserialize a JSON string into an object * * @param mixed $data object or primitive to be deserialized * @param string $class class name is passed as a string * @param string[] $httpHeaders HTTP headers * @param string $discriminator discriminator if polymorphism is used * * @return object|array|null an single or an array of $class instances */ public static function deserialize($data, $class, $httpHeaders = null) { if (null === $data) { return null; } elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] $inner = substr($class, 4, -1); $deserialized = []; if (strrpos($inner, ",") !== false) { $subClass_array = explode(',', $inner, 2); $subClass = $subClass_array[1]; foreach ($data as $key => $value) { $deserialized[$key] = self::deserialize($value, $subClass, null); } } return $deserialized; } elseif (strcasecmp(substr($class, -2), '[]') === 0) { $subClass = substr($class, 0, -2); $values = []; foreach ($data as $key => $value) { $values[] = self::deserialize($value, $subClass, null); } return $values; } elseif ($class === 'object') { settype($data, 'array'); return $data; } elseif ($class === '\DateTime') { // Some API's return an invalid, empty string as a // date-time property. DateTime::__construct() will return // the current time for empty input which is probably not // what is meant. The invalid empty string is probably to // be interpreted as a missing field/value. Let's handle // this graceful. if (!empty($data)) { return new \DateTime($data); } else { return null; } } elseif (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { settype($data, $class); return $data; } elseif ($class === '\SplFileObject') { /** @var \Psr\Http\Message\StreamInterface $data */ // determine file name if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) { $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]); } else { $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); } $file = fopen($filename, 'w'); while ($chunk = $data->read(200)) { fwrite($file, $chunk); } fclose($file); return new \SplFileObject($filename, 'r'); } elseif (method_exists($class, 'getAllowableEnumValues')) { if (!in_array($data, $class::getAllowableEnumValues(), true)) { $imploded = implode("', '", $class::getAllowableEnumValues()); throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); } return $data; } else { // If a discriminator is defined and points to a valid subclass, use it. $discriminator = $class::DISCRIMINATOR; if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { $subclass = '\MailchimpMarketing\Model\\' . $data->{$discriminator}; if (is_subclass_of($subclass, $class)) { $class = $subclass; } } $instance = new $class(); foreach ($instance::swaggerTypes() as $property => $type) { $propertySetter = $instance::setters()[$property]; if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) { continue; } $propertyValue = $data->{$instance::attributeMap()[$property]}; if (isset($propertyValue)) { $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); } } return $instance; } } } ================================================ FILE: phpunit.xml.dist ================================================