diff --git a/src/Models/Country.php b/src/Models/Country.php new file mode 100644 index 0000000..ea42476 --- /dev/null +++ b/src/Models/Country.php @@ -0,0 +1,79 @@ +id; + } + + + /** + * @return string + */ + public function getCode() + { + return $this->code; + } + + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + + /** + * @return array + */ + public function getProvinces() + { + return $this->provinces; + } + + + /** + * @return float + */ + public function getTax() + { + return $this->tax; + } + +} \ No newline at end of file diff --git a/src/Models/Province.php b/src/Models/Province.php new file mode 100644 index 0000000..adcfd28 --- /dev/null +++ b/src/Models/Province.php @@ -0,0 +1,134 @@ +code; + } + + + /** + * @return int + */ + public function getCountryId() + { + return $this->countryId; + } + + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + + /** + * @return int + */ + public function getShippingZoneId() + { + return $this->shippingZoneId; + } + + + /** + * @return float + */ + public function getTax() + { + return $this->tax; + } + + + /** + * @return string + */ + public function getTaxName() + { + return $this->taxName; + } + + + /** + * @return string + */ + public function getTaxType() + { + return $this->taxType; + } + + + /** + * @return float + */ + public function getTaxPercentage() + { + return $this->taxPercentage; + } + +} \ No newline at end of file diff --git a/src/Models/ShippingZone.php b/src/Models/ShippingZone.php new file mode 100644 index 0000000..f2db260 --- /dev/null +++ b/src/Models/ShippingZone.php @@ -0,0 +1,90 @@ +id; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + + /** + * @return array + */ + public function getCountries() + { + return $this->countries; + } + + /** + * @return array + */ + public function getCarrierShippingRateProviders() + { + return $this->carrierShippingRateProviders; + } + + + /** + * @return array + */ + public function getPriceBasedShippingRates() + { + return $this->priceBasedShippingRates; + } + + + /** + * @return array + */ + public function getWeightBasedShippingRates() + { + return $this->weightBasedShippingRates; + } +} \ No newline at end of file diff --git a/src/Services/ShippingZone.php b/src/Services/ShippingZone.php new file mode 100644 index 0000000..c1a2835 --- /dev/null +++ b/src/Services/ShippingZone.php @@ -0,0 +1,72 @@ +client->get('admin/shipping_zones.json', array_merge([ + 'page' => $page, + 'limit' => $limit + ], $filter)); + + $shippingZones = array_map(function ($zone) { + $zone['countries'] = $this->unserializeCountries($zone['countries']); + + return $this->unserializeModel($zone, ShippingZoneModel::class); + }, $raw['shipping_zones']); + + return collect($shippingZones); + } + + + /** + * @param $data + * + * @return Collection + */ + public function unserializeCountries($data) + { + if (null === $data) { + return; + } + $countries = array_map(function ($country) { + $country['provinces'] = $this->unserializeProvinces($country['provinces']); + + return $this->unserializeModel($country, Country::class); + }, $data); + + return collect($countries); + } + + + /** + * @param $data + * + * @return Collection + */ + public function unserializeProvinces($data) + { + if (null === $data) { + return; + } + $provinces = array_map(function ($province) { + return $this->unserializeModel($province, Province::class); + }, $data); + + return collect($provinces); + } +} \ No newline at end of file