initial docker setup

This commit is contained in:
GotPPay
2018-06-14 16:49:28 +02:00
parent bc80b7342e
commit b5f87f27f8
3023 changed files with 985078 additions and 1 deletions

View File

@@ -0,0 +1,337 @@
<?php
/**
* Created by Vextras.
*
* Name: Ryan Hungate
* Email: ryan@vextras.com
* Date: 3/8/16
* Time: 2:22 PM
*/
class MailChimp_WooCommerce_Address
{
protected $type;
protected $name;
protected $address1;
protected $address2;
protected $city;
protected $province;
protected $province_code;
protected $postal_code;
protected $country;
protected $country_code;
protected $longitude;
protected $latitude;
protected $phone;
protected $company;
/**
* @return array
*/
public function getValidation()
{
return array(
'address1' => 'string',
'address2' => 'string',
'city' => 'string',
'province' => 'string',
'province_code' => 'string|digits:2',
'postal_code' => 'string',
'country' => 'string',
'country_code' => 'string|digits:2',
'latitude' => 'numeric',
'longitude' => 'numeric',
);
}
/**
* @return mixed
*/
public function getName()
{
return $this->name;
}
/**
* @param mixed $name
* @return MailChimp_WooCommerce_Address
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* @return mixed
*/
public function getAddress1()
{
return $this->address1;
}
/**
* @param mixed $address1
* @return MailChimp_WooCommerce_Address
*/
public function setAddress1($address1)
{
$this->address1 = $address1;
return $this;
}
/**
* @return mixed
*/
public function getAddress2()
{
return $this->address2;
}
/**
* @param mixed $address2
* @return MailChimp_WooCommerce_Address
*/
public function setAddress2($address2)
{
$this->address2 = $address2;
return $this;
}
/**
* @return mixed
*/
public function getCity()
{
return $this->city;
}
/**
* @param mixed $city
* @return MailChimp_WooCommerce_Address
*/
public function setCity($city)
{
$this->city = $city;
return $this;
}
/**
* @return mixed
*/
public function getProvince()
{
return $this->province;
}
/**
* @param mixed $province
* @return MailChimp_WooCommerce_Address
*/
public function setProvince($province)
{
$this->province = $province;
return $this;
}
/**
* @return mixed
*/
public function getProvinceCode()
{
return $this->province_code;
}
/**
* @param mixed $province_code
* @return MailChimp_WooCommerce_Address
*/
public function setProvinceCode($province_code)
{
$this->province_code = $province_code;
return $this;
}
/**
* @return mixed
*/
public function getPostalCode()
{
return $this->postal_code;
}
/**
* @param mixed $postal_code
* @return MailChimp_WooCommerce_Address
*/
public function setPostalCode($postal_code)
{
$this->postal_code = $postal_code;
return $this;
}
/**
* @return mixed
*/
public function getCountry()
{
return $this->country;
}
/**
* @param mixed $country
* @return MailChimp_WooCommerce_Address
*/
public function setCountry($country)
{
$this->country = $country;
return $this;
}
/**
* @return mixed
*/
public function getCountryCode()
{
return $this->country_code;
}
/**
* @param mixed $country_code
* @return MailChimp_WooCommerce_Address
*/
public function setCountryCode($country_code)
{
$this->country_code = $country_code;
return $this;
}
/**
* @return mixed
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* @param mixed $longitude
* @return MailChimp_WooCommerce_Address
*/
public function setLongitude($longitude)
{
$this->longitude = $longitude;
return $this;
}
/**
* @return mixed
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* @param mixed $latitude
* @return MailChimp_WooCommerce_Address
*/
public function setLatitude($latitude)
{
$this->latitude = $latitude;
return $this;
}
/**
* @return mixed
*/
public function getPhone()
{
return $this->phone;
}
/**
* @param mixed $phone
* @return MailChimp_WooCommerce_Address
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}
/**
* @return mixed
*/
public function getCompany()
{
return $this->company;
}
/**
* @param mixed $company
* @return MailChimp_WooCommerce_Address
*/
public function setCompany($company)
{
$this->company = $company;
return $this;
}
/**
* @return array
*/
public function toArray()
{
return mailchimp_array_remove_empty(array(
'name' => (string) $this->name,
'address1' => (string) $this->address1,
'address2' => (string) $this->address2,
'city' => (string) $this->city,
'province' => (string) $this->province,
'province_code' => (string) $this->province_code,
'postal_code' => (string) $this->postal_code,
'country' => (string) $this->country,
'country_code' => (string) $this->country_code,
'longitude' => ($this->longitude ? (int) $this->longitude : null),
'latitude' => ($this->latitude ? (int) $this->latitude : null),
'phone' => (string) $this->phone,
'company' => (string) $this->company,
));
}
/**
* @param array $data
* @return MailChimp_WooCommerce_Address
*/
public function fromArray(array $data)
{
$singles = array(
'name', 'address1', 'address2', 'city',
'province', 'province_code', 'postal_code',
'country', 'country_code', 'longitude',
'phone', 'company',
);
foreach ($singles as $key) {
if (array_key_exists($key, $data)) {
$this->$key = $data[$key];
}
}
return $this;
}
}

View File

@@ -0,0 +1,277 @@
<?php
/**
* Created by Vextras.
*
* Name: Ryan Hungate
* Email: ryan@vextras.com
* Date: 7/15/16
* Time: 1:26 PM
*/
class MailChimp_WooCommerce_Cart
{
protected $store_id;
protected $id;
protected $customer;
protected $campaign_id;
protected $checkout_url;
protected $currency_code;
protected $order_total;
protected $tax_total;
protected $lines = array();
/**
* @param $unique_id
* @return $this
*/
public function setId($unique_id)
{
$this->id = $unique_id;
return $this;
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param $store_id
* @return $this
*/
public function setStoreID($store_id)
{
$this->store_id = $store_id;
return $this;
}
/**
* @return mixed
*/
public function getStoreID()
{
if (empty($this->store_id)) {
$this->store_id = mailchimp_get_store_id();
}
return $this->store_id;
}
/**
* @param MailChimp_WooCommerce_Customer $customer
* @return $this
*/
public function setCustomer(MailChimp_WooCommerce_Customer $customer)
{
$this->customer = $customer;
return $this;
}
/**
* @return MailChimp_WooCommerce_Customer
*/
public function getCustomer()
{
if (empty($this->customer)) {
$this->customer = new MailChimp_WooCommerce_Customer();
}
return $this->customer;
}
/**
* @param $id
* @return $this
*/
public function setCampaignID($id)
{
$this->campaign_id = $id;
return $this;
}
/**
* @return mixed
*/
public function getCampaignID()
{
return $this->campaign_id;
}
/**
* @param $url
* @return $this
*/
public function setCheckoutUrl($url)
{
$this->checkout_url = $url;
return $this;
}
/**
* @return string
*/
public function getCheckoutURL()
{
if (empty($this->checkout_url)) {
$this->checkout_url = wc_get_checkout_url();
}
return $this->checkout_url;
}
/**
* @param $code
* @return $this
*/
public function setCurrencyCode($code)
{
$this->currency_code = $code;
return $this;
}
/**
* @return string
*/
public function getCurrencyCode()
{
if (empty($this->currency_code)) {
$options = get_option('mailchimp-woocommerce', array());
$this->currency_code = isset($options['store_currency_code']) ? $options['store_currency_code'] : 'USD';
}
return $this->currency_code;
}
/**
* @param $total
* @return $this
*/
public function setOrderTotal($total)
{
$this->order_total = $total;
return $this;
}
/**
* @return float
*/
public function getOrderTotal()
{
return $this->order_total;
}
/**
* @param $total
* @return $this
*/
public function setTaxTotal($total)
{
$this->tax_total = $total;
return $this;
}
/**
* @return float
*/
public function getTaxTotal()
{
return $this->tax_total;
}
/**
* @param MailChimp_WooCommerce_LineItem $item
* @return $this
*/
public function addItem(MailChimp_WooCommerce_LineItem $item)
{
$this->lines[] = $item;
return $this;
}
/**
* @return array
*/
public function items()
{
return $this->lines;
}
/**
* @return mixed
*/
public function toArray()
{
return mailchimp_array_remove_empty(array(
'id' => (string) $this->getId(),
'customer' => $this->getCustomer()->toArray(),
'campaign_id' => (string) $this->getCampaignID(),
'checkout_url' => (string) $this->getCheckoutURL(),
'currency_code' => (string) $this->getCurrencyCode(),
'order_total' => floatval($this->getOrderTotal()),
'tax_total' => $this->getTaxTotal() > 0 ? floatval($this->getTaxTotal()) : null,
'lines' => array_map(function($item) {
return $item->toArray();
}, $this->items()),
));
}
/**
* @return array
*/
public function toArrayForUpdate()
{
return mailchimp_array_remove_empty(array(
'campaign_id' => (string) $this->getCampaignID(),
'checkout_url' => (string) $this->getCheckoutURL(),
'currency_code' => (string) $this->getCurrencyCode(),
'order_total' => $this->getOrderTotal(),
'tax_total' => ($this->getTaxTotal() > 0 ? $this->getTaxTotal() : null),
'lines' => array_map(function($item) {
return $item->toArray();
}, $this->items()),
));
}
/**
* @param array $data
* @return MailChimp_WooCommerce_Cart
*/
public function fromArray(array $data)
{
$singles = array(
'store_id', 'id', 'campaign_id', 'checkout_url',
'currency_code', 'order_total', 'tax_total',
);
foreach ($singles as $key) {
if (array_key_exists($key, $data)) {
$this->$key = $data[$key];
}
}
if (array_key_exists('customer', $data) && is_array($data['customer'])) {
$customer = new MailChimp_WooCommerce_Customer();
$this->customer = $customer->fromArray($data['customer']);
}
if (array_key_exists('lines', $data) && is_array($data['lines'])) {
foreach ($data['lines'] as $line_item) {
$item = new MailChimp_WooCommerce_LineItem();
$this->lines[] = $item->fromArray($line_item);
}
}
return $this;
}
}

View File

@@ -0,0 +1,258 @@
<?php
/**
* Created by Vextras.
*
* Name: Ryan Hungate
* Email: ryan@vextras.com
* Date: 3/8/16
* Time: 2:16 PM
*/
class MailChimp_WooCommerce_Customer
{
protected $id = null;
protected $email_address = null;
protected $opt_in_status = null;
protected $company = null;
protected $first_name = null;
protected $last_name = null;
protected $orders_count = null;
protected $total_spent = null;
protected $address;
/**
* @return array
*/
public function getValidation()
{
return array(
'id' => 'required',
'email_address' => 'required|email',
'opt_in_status' => 'required|boolean',
'company' => 'string',
'first_name' => 'string',
'last_name' => 'string',
'orders_count' => 'integer',
'total_spent' => 'integer',
);
}
/**
* @return null
*/
public function getId()
{
return $this->id;
}
/**
* @param null $id
* @return MailChimp_WooCommerce_Customer
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* @return null
*/
public function getEmailAddress()
{
return $this->email_address;
}
/**
* @param null $email_address
* @return MailChimp_WooCommerce_Customer
*/
public function setEmailAddress($email_address)
{
$this->email_address = $email_address;
return $this;
}
/**
* @return null
*/
public function getOptInStatus()
{
return $this->opt_in_status;
}
/**
* @param null $opt_in_status
* @return MailChimp_WooCommerce_Customer
*/
public function setOptInStatus($opt_in_status)
{
$this->opt_in_status = $opt_in_status;
return $this;
}
/**
* @return null
*/
public function getCompany()
{
return $this->company;
}
/**
* @param null $company
* @return MailChimp_WooCommerce_Customer
*/
public function setCompany($company)
{
$this->company = $company;
return $this;
}
/**
* @return null
*/
public function getFirstName()
{
return $this->first_name;
}
/**
* @param null $first_name
* @return MailChimp_WooCommerce_Customer
*/
public function setFirstName($first_name)
{
$this->first_name = $first_name;
return $this;
}
/**
* @return null
*/
public function getLastName()
{
return $this->last_name;
}
/**
* @param null $last_name
* @return MailChimp_WooCommerce_Customer
*/
public function setLastName($last_name)
{
$this->last_name = $last_name;
return $this;
}
/**
* @return null
*/
public function getOrdersCount()
{
return $this->orders_count;
}
/**
* @param null $orders_count
* @return MailChimp_WooCommerce_Customer
*/
public function setOrdersCount($orders_count)
{
$this->orders_count = $orders_count;
return $this;
}
/**
* @return null
*/
public function getTotalSpent()
{
return $this->total_spent;
}
/**
* @param null $total_spent
* @return MailChimp_WooCommerce_Customer
*/
public function setTotalSpent($total_spent)
{
$this->total_spent = $total_spent;
return $this;
}
/**
* @return MailChimp_WooCommerce_Address
*/
public function getAddress()
{
if (empty($this->address)) {
$this->address = new MailChimp_WooCommerce_Address();
}
return $this->address;
}
/**
* @param MailChimp_WooCommerce_Address $address
* @return MailChimp_WooCommerce_Customer
*/
public function setAddress(MailChimp_WooCommerce_Address $address)
{
$this->address = $address;
return $this;
}
/**
* @return array
*/
public function toArray()
{
$address = $this->getAddress()->toArray();
return mailchimp_array_remove_empty(array(
'id' => (string) $this->getId(),
'email_address' => (string) $this->getEmailAddress(),
'opt_in_status' => $this->getOptInStatus(),
'company' => (string) $this->getCompany(),
'first_name' => (string) $this->getFirstName(),
'last_name' => (string) $this->getLastName(),
'orders_count' => (int) $this->getOrdersCount(),
'total_spent' => floatval(number_format($this->getTotalSpent(), 2)),
'address' => (empty($address) ? null : $address),
));
}
/**
* @param array $data
* @return MailChimp_WooCommerce_Customer
*/
public function fromArray(array $data)
{
$singles = array(
'id', 'email_address', 'opt_in_status', 'company',
'first_name', 'last_name', 'orders_count', 'total_spent',
);
foreach ($singles as $key) {
if (array_key_exists($key, $data)) {
$this->$key = $data[$key];
}
}
if (array_key_exists('address', $data) && is_array($data['address'])) {
$address = new MailChimp_WooCommerce_Address();
$this->address = $address->fromArray($data['address']);
}
return $this;
}
}

View File

@@ -0,0 +1,180 @@
<?php
/**
* Created by Vextras.
*
* Name: Ryan Hungate
* Email: ryan@vextras.com
* Date: 3/8/16
* Time: 2:16 PM
*/
class MailChimp_WooCommerce_LineItem
{
protected $id;
protected $product_id;
protected $product_variant_id;
protected $quantity;
protected $price;
/**
* @return array
*/
public function getValidation()
{
return array(
'id' => 'required|string',
'product_id' => 'required|string',
'product_variant_id' => 'required|string',
'quantity' => 'required|integer',
'price' => 'required|numeric',
);
}
/**
* @param $id
* @param $product_id
* @param $variant_id
* @param $quantity
* @param $price
* @return MailChimp_WooCommerce_LineItem
*/
public static function make($id, $product_id, $variant_id, $quantity, $price)
{
$item = new MailChimp_WooCommerce_LineItem();
$item->id = $id;
$item->product_id = $product_id;
$item->product_variant_id = $variant_id;
$item->quantity = $quantity;
$item->price = $price;
return $item;
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param mixed $id
* @return MailChimp_WooCommerce_LineItem
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* @return mixed
*/
public function getProductId()
{
return $this->product_id;
}
/**
* @param mixed $product_id
* @return MailChimp_WooCommerce_LineItem
*/
public function setProductId($product_id)
{
$this->product_id = $product_id;
return $this;
}
/**
* @return mixed
*/
public function getProductVariantId()
{
return $this->product_variant_id;
}
/**
* @param mixed $product_variant_id
* @return MailChimp_WooCommerce_LineItem
*/
public function setProductVariantId($product_variant_id)
{
$this->product_variant_id = $product_variant_id;
return $this;
}
/**
* @return mixed
*/
public function getQuantity()
{
return $this->quantity;
}
/**
* @param mixed $quantity
* @return MailChimp_WooCommerce_LineItem
*/
public function setQuantity($quantity)
{
$this->quantity = $quantity;
return $this;
}
/**
* @return mixed
*/
public function getPrice()
{
return $this->price;
}
/**
* @param mixed $price
* @return MailChimp_WooCommerce_LineItem
*/
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/**
* @return array
*/
public function toArray()
{
return mailchimp_array_remove_empty(array(
'id' => (string) $this->id,
'product_id' => (string) $this->product_id,
'product_variant_id' => (string) $this->product_variant_id,
'quantity' => (int) $this->quantity,
'price' => (string) $this->price,
));
}
/**
* @param array $data
* @return MailChimp_WooCommerce_LineItem
*/
public function fromArray(array $data)
{
$singles = array(
'id', 'product_id', 'product_variant_id', 'quantity', 'price',
);
foreach ($singles as $key) {
if (array_key_exists($key, $data)) {
$this->$key = $data[$key];
}
}
return $this;
}
}

View File

@@ -0,0 +1,547 @@
<?php
/**
* Created by Vextras.
*
* Name: Ryan Hungate
* Email: ryan@vextras.com
* Date: 3/8/16
* Time: 2:16 PM
*/
class MailChimp_WooCommerce_Order
{
protected $id = null;
protected $landing_site = null;
protected $customer = null;
protected $campaign_id = null;
protected $financial_status = null;
protected $fulfillment_status = null;
protected $currency_code = null;
protected $order_total = null;
protected $tax_total = null;
protected $discount_total = null;
protected $shipping_total = null;
protected $updated_at_foreign = null;
protected $processed_at_foreign = null;
protected $cancelled_at_foreign = null;
protected $order_url = null;
protected $shipping_address = null;
protected $billing_address = null;
protected $lines = array();
protected $confirm_and_paid = false;
protected $promos = array();
protected $is_amazon_order = false;
/**
* @param $bool
* @return $this
*/
public function flagAsAmazonOrder($bool)
{
$this->is_amazon_order = (bool) $bool;
return $this;
}
/**
* @return bool
*/
public function isFlaggedAsAmazonOrder()
{
return (bool) $this->is_amazon_order;
}
/**
* @return array
*/
public function getValidation()
{
return array(
'id' => 'required|string',
'landing_site' => 'required|string',
'customer' => 'required',
'campaign_id' => 'string',
'financial_status' => 'string',
'fulfillment_status' => 'string',
'currency_code' => 'required|currency_code',
'order_total' => 'required|numeric',
'tax_total' => 'numeric',
'discount_total' => 'numeric',
'processed_at_foreign' => 'date',
'updated_at_foreign' => 'date',
'cancelled_at_foreign' => 'date',
'order_url' => 'string',
'lines' => 'required|array',
);
}
/**
* @param $id
* @return MailChimp_WooCommerce_Order
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* @return null|string
*/
public function getId()
{
return $this->id;
}
/**
* @param $landing_site
* @return $this
*/
public function setLandingSite($landing_site)
{
$this->landing_site = $landing_site;
return $this;
}
/**
* @return null|string
*/
public function getLandingSite()
{
return $this->landing_site;
}
/**
* @param MailChimp_WooCommerce_Customer $customer
* @return MailChimp_WooCommerce_Order
*/
public function setCustomer(MailChimp_WooCommerce_Customer $customer)
{
$this->customer = $customer;
return $this;
}
/**
* @return null|MailChimp_WooCommerce_Customer
*/
public function getCustomer()
{
if (empty($this->customer)) {
$this->customer = new MailChimp_WooCommerce_Customer();
}
return $this->customer;
}
/**
* @param MailChimp_WooCommerce_LineItem $item
* @return $this
*/
public function addItem(MailChimp_WooCommerce_LineItem $item)
{
$this->lines[] = $item;
return $this;
}
/**
* @param $code
* @param $amount
* @param bool $is_percentage
* @return $this
*/
public function addDiscount($code, $amount, $is_percentage = false)
{
$this->promos[] = array(
'code' => $code,
'amount_discounted' => $amount,
'type' => $is_percentage ? 'percent' : 'fixed'
);
return $this;
}
/**
* @return array
*/
public function discounts()
{
return $this->promos;
}
/**
* @return array
*/
public function items()
{
return $this->lines;
}
/**
* @return null
*/
public function getCampaignId()
{
return $this->campaign_id;
}
/**
* @param null $campaign_id
* @return MailChimp_WooCommerce_Order
*/
public function setCampaignId($campaign_id)
{
$this->campaign_id = $campaign_id;
return $this;
}
/**
* @return null
*/
public function getFinancialStatus()
{
return $this->financial_status;
}
/**
* @param null $financial_status
* @return MailChimp_WooCommerce_Order
*/
public function setFinancialStatus($financial_status)
{
$this->financial_status = $financial_status;
return $this;
}
/**
* @return null
*/
public function getFulfillmentStatus()
{
return $this->fulfillment_status;
}
/**
* @param null $fulfillment_status
* @return MailChimp_WooCommerce_Order
*/
public function setFulfillmentStatus($fulfillment_status)
{
$this->fulfillment_status = $fulfillment_status;
return $this;
}
/**
* @return null
*/
public function getCurrencyCode()
{
return $this->currency_code;
}
/**
* @param null $currency_code
* @return MailChimp_WooCommerce_Order
*/
public function setCurrencyCode($currency_code)
{
$this->currency_code = $currency_code;
return $this;
}
/**
* @return mixed
*/
public function getOrderTotal()
{
return $this->order_total;
}
/**
* @param mixed $order_total
* @return MailChimp_WooCommerce_Order
*/
public function setOrderTotal($order_total)
{
$this->order_total = $order_total;
return $this;
}
/**
* @param $url
* @return $this
*/
public function setOrderURL($url)
{
if (($url = wp_http_validate_url($url))) {
$this->order_url = $url;
}
return $this;
}
/**
* @return string
*/
public function getOrderURL()
{
return $this->order_url;
}
/**
* @return mixed
*/
public function getTaxTotal()
{
return $this->tax_total;
}
/**
* @param mixed $tax_total
* @return MailChimp_WooCommerce_Order
*/
public function setTaxTotal($tax_total)
{
$this->tax_total = $tax_total;
return $this;
}
/**
* @return mixed
*/
public function getShippingTotal()
{
return $this->shipping_total;
}
/**
* @param mixed $shipping_total
* @return MailChimp_WooCommerce_Order
*/
public function setShippingTotal($shipping_total)
{
$this->shipping_total = $shipping_total;
return $this;
}
/**
* @return mixed
*/
public function getDiscountTotal()
{
return $this->discount_total;
}
/**
* @param mixed $discount_total
* @return MailChimp_WooCommerce_Order
*/
public function setDiscountTotal($discount_total)
{
$this->discount_total = $discount_total;
return $this;
}
/**
* @param \DateTime $time
* @return $this
*/
public function setProcessedAt(\DateTime $time)
{
$this->processed_at_foreign = $time->format('Y-m-d H:i:s');
return $this;
}
/**
* @return null
*/
public function getProcessedAt()
{
return $this->processed_at_foreign;
}
/**
* @param \DateTime $time
* @return $this
*/
public function setCancelledAt(\DateTime $time)
{
$this->cancelled_at_foreign = $time->format('Y-m-d H:i:s');
return $this;
}
/**
* @return null
*/
public function getCancelledAt()
{
return $this->cancelled_at_foreign;
}
/**
* @param \DateTime $time
* @return $this
*/
public function setUpdatedAt(\DateTime $time)
{
$this->updated_at_foreign = $time->format('Y-m-d H:i:s');
return $this;
}
/**
* @return null
*/
public function getUpdatedAt()
{
return $this->updated_at_foreign;
}
/**
* @param $bool
* @param $bool
* @return $this
*/
public function confirmAndPay($bool)
{
$this->confirm_and_paid = (bool) $bool;
return $this;
}
/**
* @return bool
*/
public function shouldConfirmAndPay()
{
return $this->confirm_and_paid;
}
/**
* @param MailChimp_WooCommerce_Address $address
* @return $this
*/
public function setShippingAddress(MailChimp_WooCommerce_Address $address)
{
$this->shipping_address = $address;
return $this;
}
/**
* @return MailChimp_WooCommerce_Address
*/
public function getShippingAddress()
{
if (empty($this->shipping_address)) {
$this->shipping_address = new MailChimp_WooCommerce_Address();
}
return $this->shipping_address;
}
/**
* @param MailChimp_WooCommerce_Address $address
* @return $this
*/
public function setBillingAddress(MailChimp_WooCommerce_Address $address)
{
$this->billing_address = $address;
return $this;
}
/**
* @return MailChimp_WooCommerce_Address
*/
public function getBillingAddress()
{
if (empty($this->billing_address)) {
$this->billing_address = new MailChimp_WooCommerce_Address();
}
return $this->billing_address;
}
/**
* @return array
*/
public function toArray()
{
return mailchimp_array_remove_empty(array(
'id' => (string) $this->getId(),
'landing_site' => (string) $this->getLandingSite(),
'customer' => $this->getCustomer()->toArray(),
'campaign_id' => (string) $this->getCampaignId(),
'financial_status' => (string) $this->getFinancialStatus(),
'fulfillment_status' => (string) $this->getFulfillmentStatus(),
'currency_code' => (string) $this->getCurrencyCode(),
'order_total' => floatval($this->getOrderTotal()),
'order_url' => (string) $this->getOrderURL(),
'tax_total' => floatval($this->getTaxTotal()),
'discount_total' => floatval($this->getDiscountTotal()),
'shipping_total' => floatval($this->getShippingTotal()),
'processed_at_foreign' => (string) $this->getProcessedAt(),
'cancelled_at_foreign' => (string) $this->getCancelledAt(),
'updated_at_foreign' => (string) $this->getUpdatedAt(),
'shipping_address' => $this->getShippingAddress()->toArray(),
'billing_address' => $this->getBillingAddress()->toArray(),
'promos' => !empty($this->promos) ? $this->promos : null,
'lines' => array_map(function ($item) {
/** @var MailChimp_WooCommerce_LineItem $item */
return $item->toArray();
}, $this->items()),
));
}
/**
* @param array $data
* @return MailChimp_WooCommerce_Order
*/
public function fromArray(array $data)
{
$singles = array(
'id', 'landing_site', 'campaign_id', 'financial_status', 'fulfillment_status',
'currency_code', 'order_total', 'order_url', 'tax_total', 'discount_total', 'processed_at_foreign',
'cancelled_at_foreign', 'updated_at_foreign'
);
foreach ($singles as $key) {
if (array_key_exists($key, $data)) {
$this->$key = $data[$key];
}
}
if (array_key_exists('shipping_address', $data) && is_array($data['shipping_address'])) {
$shipping = new MailChimp_WooCommerce_Address();
$this->shipping_address = $shipping->fromArray($data['shipping_address']);
}
if (array_key_exists('billing_address', $data) && is_array($data['billing_address'])) {
$billing = new MailChimp_WooCommerce_Address();
$this->billing_address = $billing->fromArray($data['billing_address']);
}
if (array_key_exists('promos', $data)) {
$this->promos = $data['promos'];
}
if (array_key_exists('lines', $data) && is_array($data['lines'])) {
$this->lines = array();
foreach ($data['lines'] as $line_item) {
$item = new MailChimp_WooCommerce_LineItem();
$this->lines[] = $item->fromArray($line_item);
}
}
return $this;
}
}

View File

@@ -0,0 +1,250 @@
<?php
/**
* Created by Vextras.
*
* Name: Ryan Hungate
* Email: ryan@vextras.com
* Date: 3/8/16
* Time: 2:17 PM
*/
class MailChimp_WooCommerce_ProductVariation
{
protected $id = null;
protected $title = null;
protected $url = null;
protected $sku = null;
protected $price = null;
protected $inventory_quantity = null;
protected $image_url = null;
protected $backorders = null;
protected $visibility = null;
/**
* @return array
*/
public function getValidation()
{
return array(
'id' => 'required|string',
'title' => 'required|string',
'url' => 'url',
'sku' => 'string',
'price' => 'numeric',
'inventory_quantity' => 'integer',
'image_url' => 'url',
'backorders' => 'string',
'visibility' => 'string',
);
}
/**
* @return null
*/
public function getId()
{
return $this->id;
}
/**
* @param null $id
* @return MailChimp_WooCommerce_ProductVariation
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* @return null
*/
public function getTitle()
{
return $this->title;
}
/**
* @param null $title
* @return MailChimp_WooCommerce_ProductVariation
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* @return null
*/
public function getUrl()
{
return $this->url;
}
/**
* @param null $url
* @return MailChimp_WooCommerce_ProductVariation
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* @return null
*/
public function getSku()
{
return $this->sku;
}
/**
* @param null $sku
* @return MailChimp_WooCommerce_ProductVariation
*/
public function setSku($sku)
{
$this->sku = $sku;
return $this;
}
/**
* @return null
*/
public function getPrice()
{
return $this->price;
}
/**
* @param null $price
* @return MailChimp_WooCommerce_ProductVariation
*/
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/**
* @return null
*/
public function getInventoryQuantity()
{
return $this->inventory_quantity;
}
/**
* @param null $inventory_quantity
* @return MailChimp_WooCommerce_ProductVariation
*/
public function setInventoryQuantity($inventory_quantity)
{
$this->inventory_quantity = $inventory_quantity;
return $this;
}
/**
* @return null
*/
public function getImageUrl()
{
return !empty($this->image_url) ? $this->image_url : null;
}
/**
* @param null $image_url
* @return MailChimp_WooCommerce_ProductVariation
*/
public function setImageUrl($image_url)
{
$this->image_url = $image_url;
return $this;
}
/**
* @return null
*/
public function getBackorders()
{
return $this->backorders;
}
/**
* @param null $backorders
* @return MailChimp_WooCommerce_ProductVariation
*/
public function setBackorders($backorders)
{
$this->backorders = $backorders;
return $this;
}
/**
* @return null
*/
public function getVisibility()
{
return $this->visibility;
}
/**
* @param null $visibility
* @return MailChimp_WooCommerce_ProductVariation
*/
public function setVisibility($visibility)
{
$this->visibility = $visibility;
return $this;
}
/**
* @return array
*/
public function toArray()
{
return mailchimp_array_remove_empty(array(
'id' => (string) $this->getId(),
'title' => $this->getTitle(),
'url' => (string) $this->getUrl(),
'sku' => (string) $this->getSku(),
'price' => $this->getPrice(),
'inventory_quantity' => (int) $this->getInventoryQuantity(),
'image_url' => (string) $this->getImageUrl(),
'backorders' => $this->getBackorders() ? 'true' : 'false',
'visibility' => (string) $this->getVisibility(),
));
}
/**
* @param array $data
* @return MailChimp_WooCommerce_ProductVariation
*/
public function fromArray(array $data)
{
$singles = array(
'id', 'title', 'url', 'sku',
'price', 'inventory_quantity', 'image_url', 'backorders',
'visibility',
);
foreach ($singles as $key) {
if (array_key_exists($key, $data)) {
$this->$key = $data[$key];
}
}
return $this;
}
}

View File

@@ -0,0 +1,282 @@
<?php
/**
* Created by Vextras.
*
* Name: Ryan Hungate
* Email: ryan@vextras.com
* Date: 3/8/16
* Time: 2:17 PM
*/
class MailChimp_WooCommerce_Product
{
protected $id;
protected $title;
protected $handle = null;
protected $url = null;
protected $description = null;
protected $type = null;
protected $vendor = null;
protected $image_url = null;
protected $variants = array();
protected $published_at_foreign = null;
/**
* @return array
*/
public function getValidation()
{
return array(
'id' => 'required|string',
'title' => 'required|string',
'handle' => 'string',
'url' => 'url',
'description' => 'string',
'type' => 'string',
'vendor' => 'string',
'image_url' => 'url',
'variants' => 'required|array',
'published_at_foreign' => 'date',
);
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param mixed $id
* @return MailChimp_WooCommerce_Product
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* @return mixed
*/
public function getTitle()
{
return $this->title;
}
/**
* @param mixed $title
* @return MailChimp_WooCommerce_Product
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* @return null
*/
public function getHandle()
{
return $this->handle;
}
/**
* @param null $handle
* @return MailChimp_WooCommerce_Product
*/
public function setHandle($handle)
{
$this->handle = $handle;
return $this;
}
/**
* @return null
*/
public function getUrl()
{
return $this->url;
}
/**
* @param null $url
* @return MailChimp_WooCommerce_Product
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* @return null
*/
public function getDescription()
{
return $this->description;
}
/**
* @param null $description
* @return MailChimp_WooCommerce_Product
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* @return null
*/
public function getType()
{
return $this->type;
}
/**
* @param null $type
* @return MailChimp_WooCommerce_Product
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* @return null
*/
public function getVendor()
{
return $this->vendor;
}
/**
* @param null $vendor
* @return MailChimp_WooCommerce_Product
*/
public function setVendor($vendor)
{
$this->vendor = $vendor;
return $this;
}
/**
* @return null
*/
public function getImageUrl()
{
return $this->image_url;
}
/**
* @param null $image_url
* @return MailChimp_WooCommerce_Product
*/
public function setImageUrl($image_url)
{
$this->image_url = $image_url;
return $this;
}
/**
* @return array
*/
public function getVariations()
{
return $this->variants;
}
/**
* @param MailChimp_WooCommerce_ProductVariation $variation
* @return MailChimp_WooCommerce_Product
*/
public function addVariant(MailChimp_WooCommerce_ProductVariation $variation)
{
$this->variants[] = $variation;
return $this;
}
/**
* @return string
*/
public function getPublishedAtForeign()
{
return $this->published_at_foreign;
}
/**
* @param \DateTime $time
* @return MailChimp_WooCommerce_Product
*/
public function setPublishedAtForeign(\DateTime $time)
{
$this->published_at_foreign = $time->format('Y-m-d H:i:s');
return $this;
}
/**
* @return array
*/
public function toArray()
{
return mailchimp_array_remove_empty(array(
'id' => (string) $this->getId(),
'title' => $this->getTitle(),
'handle' => (string) $this->getHandle(),
'url' => (string) $this->getUrl(),
'description' => (string) $this->getDescription(),
'type' => (string) $this->getType(),
'vendor' => (string) $this->getVendor(),
'image_url' => (string) $this->getImageUrl(),
'variants' => array_map(function ($item) {
return $item->toArray();
}, $this->getVariations()),
'published_at_foreign' => (string) $this->getPublishedAtForeign(),
));
}
/**
* @param array $data
* @return MailChimp_WooCommerce_Product
*/
public function fromArray(array $data)
{
$singles = array(
'id', 'title', 'handle', 'url',
'description', 'type', 'vendor', 'image_url',
'published_at_foreign',
);
foreach ($singles as $key) {
if (array_key_exists($key, $data)) {
$this->$key = $data[$key];
}
}
if (array_key_exists('variants', $data) && is_array($data['variants'])) {
$this->variants = array();
foreach ($data['variants'] as $variant) {
$variation = new MailChimp_WooCommerce_ProductVariation();
$this->variants[] = $variation->fromArray($variant);
}
}
return $this;
}
}

View File

@@ -0,0 +1,230 @@
<?php
/**
* Created by Vextras.
*
* Name: Ryan Hungate
* Email: ryan@vextras.com
* Date: 6/13/17
* Time: 1:19 PM
*/
class MailChimp_WooCommerce_PromoCode
{
/**
* @var string
* @title Promo Rule Foreign ID
* @description A unique identifier for the promo code
*/
protected $id;
/**
* @var string
* @title Code
* @required
* @description The discount code
*/
protected $code;
/**
* @var string
* @title Promo Redemption Url
* @required
* @description The url that should be used in the promotion campaign. Eg. A url that applies promo code directly at checkout or a url that points to sale page. Use store url if promotion url is not available.
*/
protected $redemption_url;
/**
* @var string
* @title Description
* @default null
* @description Number of times promo code has been used.
*/
protected $usage_count;
/**
* @var boolean
* @title Enabled
* @default true
* @description Whether the promo code is currently enabled. ***
*/
protected $enabled;
/**
* @var \DateTime
* @title Start Time
* @default null
* @description The date and time when the promotion starts in ISO 8601 format
*/
protected $created_at_foreign;
/**
* @var \DateTime
* @title Start Time
* @default null
* @description The date and time when the promotion starts in ISO 8601 format
*/
protected $updated_at_foreign;
/**
* @var MailChimp_WooCommerce_PromoRule|null
*/
protected $promo_rule;
/**
* @return array
*/
public function getValidation()
{
return [
'id' => 'required',
'code' => 'required',
'redemption_url' => 'required',
'usage_count' => 'integer',
'created_at_foreign' => 'date',
'updated_at_foreign' => 'date',
];
}
/**
* @param MailChimp_WooCommerce_PromoRule $promo
* @return MailChimp_WooCommerce_PromoCode
*/
public function attachPromoRule(MailChimp_WooCommerce_PromoRule $promo)
{
$this->promo_rule = $promo;
return $this;
}
/**
* @return MailChimp_WooCommerce_PromoRule|null
*/
public function getAttachedPromoRule()
{
return $this->promo_rule;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param null $id
* @return MailChimp_WooCommerce_PromoCode
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* @param string $code
* @return MailChimp_WooCommerce_PromoCode
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* @return string
*/
public function getRedemptionURL()
{
return $this->redemption_url;
}
/**
* @param string $url
* @return MailChimp_WooCommerce_PromoCode
*/
public function setRedemptionURL($url)
{
$this->redemption_url = $url;
return $this;
}
public function getUsageCount()
{
return $this->usage_count;
}
/**
* @param $count
* @return MailChimp_WooCommerce_PromoCode
*/
public function setUsageCount($count)
{
$this->usage_count = $count;
return $this;
}
/**
* @param $enabled
* @return MailChimp_WooCommerce_PromoCode
*/
public function setEnabled($enabled)
{
$this->enabled = (bool) $enabled;
return $this;
}
/**
* @return bool
*/
public function isEnabled()
{
return (bool) $this->enabled;
}
/**
* @return array
*/
public function toArray()
{
return mailchimp_array_remove_empty([
'id' => (string) $this->getId(),
'code' => (string) $this->getCode(),
'redemption_url' => (string) $this->getRedemptionURL(),
'usage_count' => $this->getUsageCount(),
'enabled' => $this->isEnabled(),
]);
}
/**
* @param array $data
* @return MailChimp_WooCommerce_PromoCode
*/
public function fromArray(array $data)
{
$singles = [
'id', 'code', 'usage_count', 'enabled',
'redemption_url', 'created_at_foreign', 'updated_at_foreign',
];
foreach ($singles as $key) {
if (array_key_exists($key, $data)) {
$this->$key = $data[$key];
}
}
return $this;
}
}

View File

@@ -0,0 +1,405 @@
<?php
/**
* Created by Vextras.
*
* Name: Ryan Hungate
* Email: ryan@vextras.com
* Date: 6/13/17
* Time: 1:19 PM
*/
class MailChimp_WooCommerce_PromoRule
{
/**
* @var string
* @title Promo Rule Foreign ID
* @default = null
* @description
* A unique identifier for the promo rule. If Ecomm platform does not support promo rule,
* use promo code id as promo rule id.
* Restricted to UTF-8 characters with max length 50
*/
protected $id;
/**
* @var string
* @title Title
* @default null
* @description The title that will show up in promotion campaign. Restricted to UTF-8 characters with max length 100
*/
protected $title;
/**
* @var string
* @title Description
* @default null
* @description The description of a promotion
*/
protected $description;
/**
* @var \DateTime
* @title Start Time
* @default null
* @description The date and time when the promotion starts in ISO 8601 format
*/
protected $starts_at;
/**
* @var \DateTime
* @title Start Time
* @default null
* @description The date and time when the promotion starts in ISO 8601 format
*/
protected $ends_at;
/**
* @var float
* @title Amount
* @required
* @description The amount of discount; Positive dollar or percentage amount.
*/
protected $amount;
/**
* @var string
* @title Type
* @required
* @description One of fixed , percentage
*/
protected $type;
/**
* @var string
* @title Target
* @required
* @description One of per_item, total, shipping
*/
protected $target;
/**
* @var boolean
* @title Enabled
* @default true
* @description Whether the promo rule is currently enabled
*/
protected $enabled = true;
/**
* @var \DateTime
* @title Start Time
* @default null
* @description The date and time when the promotion starts in ISO 8601 format
*/
protected $created_at_foreign;
/**
* @var \DateTime
* @title Start Time
* @default null
* @description The date and time when the promotion starts in ISO 8601 format
*/
protected $updated_at_foreign;
/**
* @return array
*/
public function getValidation()
{
return [
'id' => 'required',
'amount' => 'required|number',
'type' => 'required',
'target' => 'required',
'enabled' => 'boolean',
'starts_at' => 'date',
'ends_at' => 'date',
'created_at_foreign' => 'date',
'updated_at_foreign' => 'date',
];
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param null $id
* @return MailChimp_WooCommerce_PromoRule
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $name
* @return MailChimp_WooCommerce_PromoRule
*/
public function setTitle($name)
{
$this->title = $name;
return $this;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @param string $description
* @return MailChimp_WooCommerce_PromoRule
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* @param \DateTime $date
* @return $this
*/
public function setStartsAt(\DateTime $date)
{
$this->starts_at = (string) $date;
return $this;
}
/**
* @return \DateTime
*/
public function getStartsAt()
{
return $this->starts_at;
}
/**
* @param \DateTime $date
* @return $this
*/
public function setEndsAt(\DateTime $date)
{
$this->ends_at = (string) $date;
return $this;
}
/**
* @return \DateTime
*/
public function getEndsAt()
{
return $this->ends_at;
}
/**
* @param $enabled
* @return $this
*/
public function setEnabled($enabled)
{
$this->enabled = (bool) $enabled;
return $this;
}
/**
* @return bool
*/
public function isEnabled()
{
return (bool) $this->enabled;
}
/**
* @return string
*/
public function getAmount()
{
return $this->amount;
}
/**
* @param int $amount
* @return MailChimp_WooCommerce_PromoRule
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @return string
*/
public function getTarget()
{
return $this->target;
}
/**
* @return $this
*/
public function setTypeFixed()
{
$this->type = 'fixed';
return $this;
}
/**
* @return $this
*/
public function setTypePercentage()
{
$this->type = 'percentage';
return $this;
}
/**
* @return $this
*/
public function setTargetTypePerItem()
{
$this->target = 'per_item';
return $this;
}
/**
* @return $this
*/
public function setTargetTypeShipping()
{
$this->target = 'shipping';
return $this;
}
/**
* @return $this
*/
public function setTargetTypeTotal()
{
$this->target = 'total';
return $this;
}
/**
* @param \DateTime $time
* @return $this
*/
public function setUpdatedAt(\DateTime $time)
{
$this->updated_at_foreign = (string) $time;
return $this;
}
/**
* @return null
*/
public function getUpdatedAt()
{
return $this->updated_at_foreign;
}
/**
* @param \DateTime $time
* @return $this
*/
public function setCreatedAt(\DateTime $time)
{
$this->created_at_foreign = (string) $time;
return $this;
}
/**
* @return null
*/
public function getCreatedAt()
{
return $this->created_at_foreign;
}
/**
* @return array
*/
public function toArray()
{
return mailchimp_array_remove_empty([
'id' => (string) $this->getId(),
'title' => (string) $this->getTitle(),
'description' => (string) $this->getDescription(),
'starts_at' => (string) $this->getStartsAt(),
'ends_at' => (string) $this->getEndsAt(),
'amount' => floatval($this->getAmount()),
'type' => (string) $this->getType(),
'target' => (string) $this->getTarget(),
'enabled' => (bool) $this->isEnabled(),
'created_at_foreign' => (string) $this->getCreatedAt(),
'updated_at_foreign' => (string) $this->getUpdatedAt(),
]);
}
/**
* @param array $data
* @return MailChimp_WooCommerce_PromoRule
*/
public function fromArray(array $data)
{
$singles = [
'id',
'title',
'description',
'starts_at',
'ends_at',
'amount',
'type',
'target',
'enabled',
'created_at_foreign',
'updated_at_foreign'
];
foreach ($singles as $key) {
if (array_key_exists($key, $data)) {
$this->$key = $data[$key];
}
}
return $this;
}
}

View File

@@ -0,0 +1,390 @@
<?php
/**
* Created by Vextras.
*
* Name: Ryan Hungate
* Email: ryan@vextras.com
* Date: 3/8/16
* Time: 3:13 PM
*/
class MailChimp_WooCommerce_Store
{
protected $id = null;
protected $is_syncing = false;
protected $list_id = null;
protected $name = null;
protected $domain = null;
protected $email_address = null;
protected $currency_code = null;
protected $money_format = null;
protected $primary_locale = null;
protected $timezone = null;
protected $phone = null;
protected $address = null;
protected $platform = null;
protected $connected_site = null;
/**
* @return array
*/
public function getValidation()
{
return array(
'id' => 'required|string',
'list_id' => 'required|string',
'name' => 'required|string',
'domain' => 'string',
'email_address' => 'email',
'currency_code' => 'required|currency_code',
'primary_locale' => 'locale_basic',
'timezone' => 'timezone',
'phone' => 'string',
);
}
/**
* @return null
*/
public function getId()
{
return $this->id;
}
/**
* @param null $id
* @return MailChimp_WooCommerce_Store
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* @param $bool
* @return $this
*/
public function flagSyncing($bool)
{
$this->is_syncing = $bool;
return $this;
}
/**
* @return bool
*/
public function isSyncing()
{
return $this->is_syncing;
}
/**
* @return null
*/
public function getListId()
{
return $this->list_id;
}
/**
* @param null $list_id
* @return MailChimp_WooCommerce_Store
*/
public function setListId($list_id)
{
$this->list_id = $list_id;
return $this;
}
/**
* @return null
*/
public function getName()
{
return $this->name;
}
/**
* @param null $name
* @return MailChimp_WooCommerce_Store;
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* @return null
*/
public function getDomain()
{
return $this->domain;
}
/**
* @param null $domain
* @return MailChimp_WooCommerce_Store;
*/
public function setDomain($domain)
{
$this->domain = $domain;
return $this;
}
/**
* @return null
*/
public function getEmailAddress()
{
return $this->email_address;
}
/**
* @param null $email_address
* @return MailChimp_WooCommerce_Store;
*/
public function setEmailAddress($email_address)
{
$this->email_address = $email_address;
return $this;
}
/**
* @return null
*/
public function getCurrencyCode()
{
return $this->currency_code;
}
/**
* @param null $currency_code
* @return MailChimp_WooCommerce_Store;
*/
public function setCurrencyCode($currency_code)
{
$this->currency_code = $currency_code;
return $this;
}
/**
* @return null
*/
public function getMoneyFormat()
{
return $this->money_format;
}
/**
* @param null $money_format
* @return MailChimp_WooCommerce_Store;
*/
public function setMoneyFormat($money_format)
{
$this->money_format = $money_format;
return $this;
}
/**
* @return null
*/
public function getPrimaryLocale()
{
return $this->primary_locale;
}
/**
* @param null $primary_locale
* @return MailChimp_WooCommerce_Store;
*/
public function setPrimaryLocale($primary_locale)
{
$this->primary_locale = $primary_locale;
return $this;
}
/**
* @return null
*/
public function getTimezone()
{
return $this->timezone;
}
/**
* @param null $timezone
* @return MailChimp_WooCommerce_Store;
*/
public function setTimezone($timezone)
{
$this->timezone = $timezone;
return $this;
}
/**
* @return null
*/
public function getPhone()
{
return $this->phone;
}
/**
* @param null $phone
* @return MailChimp_WooCommerce_Store;
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}
/**
* @param $platform
* @return $this
*/
public function setPlatform($platform)
{
$this->platform = $platform;
return $this;
}
/**
* @return string
*/
public function getPlatform()
{
return $this->platform;
}
/**
* @return MailChimp_WooCommerce_Address
*/
public function getAddress()
{
if (empty($this->address)) {
$this->address = new MailChimp_WooCommerce_Address();
}
return $this->address;
}
/**
* @param MailChimp_WooCommerce_Address $address
* @return Store;
*/
public function setAddress(MailChimp_WooCommerce_Address $address)
{
$this->address = $address;
return $this;
}
/**
* @return null|string
*/
public function getConnectedSiteForeignID()
{
return $this->getConnectedSiteParam('site_foreign_id');
}
/**
* @return null|string
*/
public function getConnectedSiteScriptUrl()
{
if (($script = $this->getConnectedSiteParam('site_script'))) {
return $script['url'];
}
return false;
}
/**
* @return null|string
*/
public function getConnectedSiteScriptFragment()
{
if (($script = $this->getConnectedSiteParam('site_script'))) {
return $script['fragment'];
}
return false;
}
/**
* @param $key
* @param null $default
* @return null
*/
public function getConnectedSiteParam($key, $default = null)
{
if (empty($this->connected_site)) {
return $default;
}
return array_key_exists($key, $this->connected_site) ? $this->connected_site[$key] : null;
}
/**
* @return array
*/
public function toArray()
{
return mailchimp_array_remove_empty(array(
'id' => $this->getId(),
'is_syncing' => $this->isSyncing(),
'platform' => $this->getPlatform(),
'list_id' => $this->getListId(),
'name' => $this->getName(),
'domain' => $this->getDomain(),
'email_address' => $this->getEmailAddress(),
'currency_code' => $this->getCurrencyCode(),
'money_format' => $this->getMoneyFormat(),
'primary_locale' => $this->getPrimaryLocale(),
'timezone' => $this->getTimezone(),
'phone' => $this->getPhone(),
'address' => $this->getAddress()->toArray(),
));
}
/**
* @param array $data
* @return MailChimp_WooCommerce_Store
*/
public function fromArray(array $data)
{
$singles = array(
'id', 'list_id', 'name', 'domain', 'is_syncing',
'email_address', 'currency_code', 'money_format',
'primary_locale', 'timezone', 'phone', 'platform',
);
foreach ($singles as $key) {
if (array_key_exists($key, $data)) {
$this->$key = $data[$key];
}
}
if (array_key_exists('address', $data)) {
$address = new MailChimp_WooCommerce_Address();
$this->address = $address->fromArray($data['address']);
}
if (array_key_exists('connected_site', $data)) {
$this->connected_site = $data['connected_site'];
}
return $this;
}
}