'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; } }