class MailchimpEcommerce in Mailchimp 8
Same name in this branch
- 8 lib/mailchimp-api-php/src/MailchimpEcommerce.php \Mailchimp\MailchimpEcommerce
- 8 lib/mailchimp-api-php/tests/src/MailchimpEcommerce.php \Mailchimp\Tests\MailchimpEcommerce
Mailchimp Ecommerce library test cases.
@package Mailchimp\Tests
Hierarchy
- class \Mailchimp\Mailchimp
- class \Mailchimp\MailchimpEcommerce
- class \Mailchimp\Tests\MailchimpEcommerce
- class \Mailchimp\MailchimpEcommerce
Expanded class hierarchy of MailchimpEcommerce
File
- lib/
mailchimp-api-php/ tests/ src/ MailchimpEcommerce.php, line 12
Namespace
Mailchimp\TestsView source
class MailchimpEcommerce extends \Mailchimp\MailchimpEcommerce {
/**
* Storage for stores. Used in place of real Mailchimp API.
*
* @var array $stores
*/
private $stores = [];
/**
* Storage for customers. Used in place of real Mailchimp API.
*
* @var array $customers
*/
private $customers = [];
/**
* Storage for orders. Used in place of real Mailchimp API.
*
* @var array $orders
*/
private $orders = [];
/**
* @inheritdoc
*/
public function __construct($api_key = 'apikey', $api_user = 'apikey', $http_options = []) {
$this->client = new MailchimpTestHttpClient();
}
public function getClient() {
return $this->client;
}
public function getEndpoint() {
return $this->endpoint;
}
/**
* @inheritdoc
*/
public function getStore($store_id, $parameters = []) {
parent::getStore($store_id, $parameters);
return isset($this->stores[$store_id]) ? $this->stores[$store_id] : NULL;
}
/**
* @inheritdoc
*/
public function addStore($id, $store, $parameters = [], $batch = FALSE) {
parent::addStore($id, $store, $batch);
$parameters = [
'id' => $id,
];
$parameters += $store;
$this->stores[$id] = (object) $parameters;
}
/**
* @inheritdoc
*/
public function getCustomer($store_id, $customer_id, $parameters = []) {
parent::getCustomer($store_id, $customer_id, $parameters);
if (isset($this->customers[$store_id])) {
return isset($this->customers[$store_id][$customer_id]) ? $this->customers[$store_id][$customer_id] : NULL;
}
return NULL;
}
/**
* @inheritdoc
*/
public function addCustomer($store_id, $customer, $batch = FALSE) {
parent::addCustomer($store_id, $customer, $batch);
if (!isset($this->customers[$store_id])) {
$this->customers[$store_id] = [];
}
$this->customers[$store_id][$customer['id']] = (object) $customer;
}
/**
* @inheritdoc
*/
public function getOrder($store_id, $order_id, $parameters = []) {
parent::getOrder($store_id, $order_id, $parameters);
if (isset($this->orders[$store_id])) {
return isset($this->orders[$store_id][$order_id]) ? $this->orders[$store_id][$order_id] : NULL;
}
return NULL;
}
/**
* @inheritdoc
*/
public function addOrder($store_id, $id, array $customer, array $order, $batch = FALSE) {
parent::addOrder($store_id, $id, $customer, $order, $batch);
if (empty($store_id)) {
throw new MailchimpAPIException('Store ID cannot be empty.');
}
if (empty($id)) {
throw new MailchimpAPIException('Order ID cannot be empty.');
}
if (empty($customer)) {
throw new MailchimpAPIException('Customer cannot be empty.');
}
if (empty($order)) {
throw new MailchimpAPIException('Order cannot be empty.');
}
if (!isset($order['lines']) || empty($order['lines'])) {
throw new MailchimpAPIException('Order must contain at least one line item.');
}
if (!isset($this->orders[$store_id])) {
$this->orders[$store_id] = [];
}
$parameters = [
'id' => $id,
'customer' => (object) $customer,
];
$parameters += $order;
$this->orders[$store_id][$id] = (object) $parameters;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Mailchimp:: |
private | property | The Mailchimp API key to authenticate with. | |
Mailchimp:: |
private | property | The Mailchimp API username to authenticate with. | |
Mailchimp:: |
private | property | Array of pending batch operations. | |
Mailchimp:: |
protected | property | The HTTP client. | |
Mailchimp:: |
private | property | A Mailchimp API error code to return with every API response. | |
Mailchimp:: |
protected | property | The REST API endpoint. | |
Mailchimp:: |
public | property | API version. | |
Mailchimp:: |
protected | function | Adds a pending batch operation. | |
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
constant | |||
Mailchimp:: |
public | function | Gets Mailchimp account information for the authenticated account. | |
Mailchimp:: |
public | function | Gets the status of a batch request. | |
Mailchimp:: |
private | function | Gets the ID of the data center associated with an API key. | |
Mailchimp:: |
private | function | Instantiates a default HTTP client based on the local environment. | |
Mailchimp:: |
public | function | Processes all pending batch operations. | |
Mailchimp:: |
public | function | Makes a request to the Mailchimp API. | |
Mailchimp:: |
public | function | Sets a custom HTTP client to be used for all API requests. | |
Mailchimp:: |
public | function | Sets a Mailchimp error code to be returned by all requests. | |
Mailchimp:: |
constant | |||
MailchimpEcommerce:: |
private | property | Storage for customers. Used in place of real Mailchimp API. | |
MailchimpEcommerce:: |
private | property | Storage for orders. Used in place of real Mailchimp API. | |
MailchimpEcommerce:: |
private | property | Storage for stores. Used in place of real Mailchimp API. | |
MailchimpEcommerce:: |
public | function | Adds a new cart to a store. | |
MailchimpEcommerce:: |
public | function | Add a new line item to an existing cart. | |
MailchimpEcommerce:: |
public | function |
@inheritdoc Overrides MailchimpEcommerce:: |
|
MailchimpEcommerce:: |
public | function |
@inheritdoc Overrides MailchimpEcommerce:: |
|
MailchimpEcommerce:: |
public | function | Add a new line item to an existing order. | |
MailchimpEcommerce:: |
public | function | Add a product to a store. | |
MailchimpEcommerce:: |
public | function | Add a variant to a product. | |
MailchimpEcommerce:: |
public | function |
@inheritdoc Overrides MailchimpEcommerce:: |
|
MailchimpEcommerce:: |
public | function | Deletes a cart. | |
MailchimpEcommerce:: |
public | function | Deletes a line item in a cart. | |
MailchimpEcommerce:: |
public | function | Deletes a customer from a store. | |
MailchimpEcommerce:: |
public | function | Deletes an order. | |
MailchimpEcommerce:: |
public | function | Delete a product. | |
MailchimpEcommerce:: |
public | function | Delete a specific variant of a specific product. | |
MailchimpEcommerce:: |
public | function | Deletes a Mailchimp store. | |
MailchimpEcommerce:: |
public | function | Get information about a specific cart. | |
MailchimpEcommerce:: |
public | function | Get information about a specific cart line item. | |
MailchimpEcommerce:: |
public | function | Get information about a cart's line items. | |
MailchimpEcommerce:: |
public | function | Get information about a store’s carts. | |
MailchimpEcommerce:: |
public | function | ||
MailchimpEcommerce:: |
public | function |
@inheritdoc Overrides MailchimpEcommerce:: |
|
MailchimpEcommerce:: |
public | function | Get information about a store's customers. | |
MailchimpEcommerce:: |
public | function | ||
MailchimpEcommerce:: |
public | function |
@inheritdoc Overrides MailchimpEcommerce:: |
|
MailchimpEcommerce:: |
public | function | Get information about a specific order line item. | |
MailchimpEcommerce:: |
public | function | Get information about an order's line items. | |
MailchimpEcommerce:: |
public | function | Get information about a store's orders. | |
MailchimpEcommerce:: |
public | function | Get information about a specific product. | |
MailchimpEcommerce:: |
public | function | Get information about all products for a store. | |
MailchimpEcommerce:: |
public | function | Get information about a specific variant of a specific product. | |
MailchimpEcommerce:: |
public | function | Get information on all variants of a specific product. | |
MailchimpEcommerce:: |
public | function |
@inheritdoc Overrides MailchimpEcommerce:: |
|
MailchimpEcommerce:: |
public | function | Gets information about all stores in the account. | |
MailchimpEcommerce:: |
public | function | Updates a specific cart. | |
MailchimpEcommerce:: |
public | function | Updates an existing line item in a cart. | |
MailchimpEcommerce:: |
public | function | Update a customer. | |
MailchimpEcommerce:: |
public | function | Update a specific order. | |
MailchimpEcommerce:: |
public | function | Update a product in a store. | |
MailchimpEcommerce:: |
public | function | Update a specific variant of a specific product. | |
MailchimpEcommerce:: |
public | function | Updates a store. | |
MailchimpEcommerce:: |
public | function |
@inheritdoc Overrides Mailchimp:: |