Skip to content

Commit e2fec91

Browse files
author
Sander de Vos
committed
Get all available shipping methods
1 parent e3a3e02 commit e2fec91

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Contracts/SendcloudContract.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ interface SendcloudContract
99
public const SHIPPING_API = 'https://panel.sendcloud.sc/api/v2/';
1010

1111
public const PARCELS_ENDPOINT = 'parcels';
12+
public const SHIPPING_METHODS_ENDPOINT = 'shipping_methods';
1213

1314
public function createParcel(RecipientData $recipient, array $optionalParameters = []): array;
15+
16+
public function shippingMethods(array $optionalParameters = []): array;
1417
}

src/Sendcloud.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ public function createParcel(RecipientData $recipient, array $optionalParameters
1515
return $this->request('post', self::PARCELS_ENDPOINT, $data);
1616
}
1717

18+
public function shippingMethods(array $optionalParameters = []): array
19+
{
20+
$query = http_build_query($optionalParameters);
21+
22+
$endpoint = self::SHIPPING_METHODS_ENDPOINT.'?'.$query;
23+
24+
return $this->request('get', $endpoint);
25+
}
26+
1827
private function request(string $method, string $endpoint, array $data = null): array
1928
{
2029
$response = Http::withBasicAuth(config('sendcloud.key'), config('sendcloud.secret'))

0 commit comments

Comments
 (0)