Skip to content

Commit b82662c

Browse files
authored
Merge pull request #4 from rikmorskate/support-for-new-shipping-price-endpoint
Added method to retrieve shipping price
2 parents 0f6ba96 + 3fe91fa commit b82662c

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Contracts/SendcloudContract.php

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public function parcelStatuses(): array;
2424

2525
public function shippingMethods(array $optionalParameters = []): array;
2626

27+
public function shippingPrice(int $shippingMethodId, string $fromCountry, int $weight, string $weightUnit, array $optionalParameters = []): array;
28+
2729
public function download(string $url): string;
2830

2931
public function verbose(bool $verbose = true): self;

src/Sendcloud.php

+19
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,25 @@ public function shippingMethods(array $optionalParameters = []): array
6565
return $this->request('get', self::SHIPPING_METHODS_ENDPOINT, $optionalParameters);
6666
}
6767

68+
public function shippingPrice(
69+
int $shippingMethodId,
70+
string $fromCountry,
71+
int $weight,
72+
string $weightUnit,
73+
array $optionalParameters = []
74+
): array {
75+
$parameters = [
76+
'shipping_method_id' => $shippingMethodId,
77+
'from_country' => $fromCountry,
78+
'weight' => $weight,
79+
'weight_unit' => $weightUnit,
80+
];
81+
82+
$parameters = array_merge($parameters, $optionalParameters);
83+
84+
return $this->request('get', 'shipping-price', $parameters);
85+
}
86+
6887
public function download(string $url): string
6988
{
7089
$response = Http::withBasicAuth($this->apiKey, $this->apiSecret)

0 commit comments

Comments
 (0)