diff --git a/README.md b/README.md index 59d8c18..5ad5d3d 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,10 @@ $thepeer->chargeLink("lost-in-the-world", 5000, "Benz"); - reference (string) - event (string) - `returns`: object +* getBusinesses + - `accepts`: + - channel (string) + - `returns`: object ## Extra diff --git a/composer.json b/composer.json index d1399ea..d369a31 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,10 @@ { "name": "Michael Okoh", "email": "trojan@thepeer.co" + }, + { + "name": "Idorenyin Udoh", + "email": "idorenyin@thepeer.co" } ], "minimum-stability": "dev", diff --git a/src/Thepeer.php b/src/Thepeer.php index b381be3..e97107a 100644 --- a/src/Thepeer.php +++ b/src/Thepeer.php @@ -149,6 +149,19 @@ public function authorizeCharge(string $reference, string $event) } } + public function getBusinesses(string $channel) + { + try { + $request = $this->client->get("/businesses?channel={$channel}"); + + $payload = json_decode($request->getBody()->getContents()); + + return $this->processResponse($payload, $request); + } catch (GuzzleException $e) { + throw new ServerErrorException($e->getMessage()); + } + } + private function processResponse($payload, $request) { switch ($request->getStatusCode()) {