Skip to content

Commit a755f77

Browse files
author
Okubanjo Oluwafunsho
committed
Updated the setGetResponse function
Updated the setGetResponse function to accept an array of data to sent, as a second parameter
1 parent 3e9bfac commit a755f77

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

src/Paystack.php

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ public function setResponse($relativeUrl)
127127
return $this;
128128
}
129129

130-
private function setGetResponse($relativeUrl)
130+
private function setGetResponse($relativeUrl, $body = array())
131131
{
132-
$this->response = $this->client->get($this->baseUrl . $relativeUrl, []);
132+
$this->response = $this->client->get($this->baseUrl . $relativeUrl, $body);
133133

134134
return $this;
135135
}
@@ -235,7 +235,7 @@ public function getAllCustomers()
235235
{
236236
$this->setRequestOptions();
237237

238-
return $this->setGetResponse("/customer")->getData();
238+
return $this->setGetResponse("/customer", [])->getData();
239239
}
240240

241241
/**
@@ -246,7 +246,7 @@ public function getAllPlans()
246246
{
247247
$this->setRequestOptions();
248248

249-
return $this->setGetResponse("/plan")->getData();
249+
return $this->setGetResponse("/plan", [])->getData();
250250
}
251251

252252
/**
@@ -257,7 +257,7 @@ public function getAllTransactions()
257257
{
258258
$this->setRequestOptions();
259259

260-
return $this->setGetResponse("/transaction")->getData();
260+
return $this->setGetResponse("/transaction", [])->getData();
261261
}
262262

263263
/**
@@ -299,11 +299,7 @@ public function createPlan(){
299299

300300
$this->setRequestOptions();
301301

302-
$this->response = $this->client->post($this->baseUrl .'/plan', [
303-
'body' => json_encode($data)
304-
]);
305-
306-
return $this->response->getResponse();
302+
return $this->setGetResponse("/plan", $data)->getResponse();
307303

308304
}
309305

@@ -316,9 +312,7 @@ public function fetchPlan($plan_code){
316312

317313
$this->setRequestOptions();
318314

319-
$this->response = $this->client->post($this->baseUrl .'/plan/' . $plan_code, []);
320-
321-
return $this->response->getResponse();
315+
return $this->setGetResponse('/plan/' . $plan_code, [])->getResponse();
322316

323317
}
324318

@@ -342,14 +336,12 @@ public function updatePlan($plan_code){
342336

343337
$this->setRequestOptions();
344338

345-
$this->response = $this->client->post($this->baseUrl .'/plan/' . $plan_code, [
346-
'body' => json_encode($data)
347-
]);
348-
349-
return $this->response->getResponse();
339+
return $this->setGetResponse('/plan/' . $plan_code, $data)->getResponse();
350340

351341
}
352342

343+
344+
353345
}
354346

355347

0 commit comments

Comments
 (0)