Skip to content

Commit 485b4ad

Browse files
author
Okubanjo Oluwafunsho
committed
Created setPostResponse and setPutResponse
Created setPostResponse and setPutResponse to handle POST and PUT request respectively
1 parent 76faead commit 485b4ad

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/Paystack.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,20 @@ private function setGetResponse($relativeUrl, $body = [])
134134
return $this;
135135
}
136136

137+
private function setPostResponse($relativeUrl, $body = [])
138+
{
139+
$this->response = $this->client->post($this->baseUrl . $relativeUrl, $body);
140+
141+
return $this;
142+
}
143+
144+
private function setPutResponse($relativeUrl, $body = [])
145+
{
146+
$this->response = $this->client->put($this->baseUrl . $relativeUrl, $body);
147+
148+
return $this;
149+
}
150+
137151
/**
138152
* Get the authorization url from the callback response
139153
* @return Unicodeveloper\Paystack\Paystack
@@ -295,7 +309,7 @@ public function createPlan(){
295309

296310
$this->setRequestOptions();
297311

298-
$this->response = $this->setGetResponse("/plan", $data);
312+
$this->response = $this->setPostResponse("/plan", $data);
299313

300314
}
301315

@@ -331,7 +345,7 @@ public function updatePlan($plan_code){
331345

332346
$this->setRequestOptions();
333347

334-
return $this->setGetResponse('/plan/' . $plan_code, $data)->getResponse();
348+
return $this->setPutResponse('/plan/' . $plan_code, $data)->getResponse();
335349

336350
}
337351

@@ -352,7 +366,7 @@ public function createCustomer(){
352366

353367
$this->setRequestOptions();
354368

355-
$this->response = $this->setGetResponse('/customer', $data);
369+
$this->response = $this->setPostResponse('/customer', $data);
356370

357371
}
358372

@@ -387,7 +401,7 @@ public function updateCustomer($customer_id){
387401

388402
$this->setRequestOptions();
389403

390-
return $this->setGetResponse('/customer/'. $customer_id, $data)->getResponse();
404+
return $this->setPutResponse('/customer/'. $customer_id, $data)->getResponse();
391405

392406
}
393407

@@ -423,7 +437,7 @@ public function createSubscription(){
423437

424438
$this->setRequestOptions();
425439

426-
$this->response = $this->setGetResponse('/subscription', $data);
440+
$this->response = $this->setPostResponse('/subscription', $data);
427441
}
428442

429443
/**
@@ -439,7 +453,7 @@ public function enableSubscription(){
439453

440454
$this->setRequestOptions();
441455

442-
return $this->setGetResponse('/subscription/enable', $data)->getResponse();
456+
return $this->setPostResponse('/subscription/enable', $data)->getResponse();
443457

444458
}
445459

@@ -456,7 +470,7 @@ public function disableSubscription(){
456470

457471
$this->setRequestOptions();
458472

459-
return $this->setGetResponse('/subscription/disable', $data)->getResponse();
473+
return $this->setPostResponse('/subscription/disable', $data)->getResponse();
460474

461475
}
462476

@@ -487,7 +501,7 @@ public function createPage(){
487501

488502
$this->setRequestOptions();
489503

490-
$this->response = $this->setGetResponse('/page', $data);
504+
$this->response = $this->setPostResponse('/page', $data);
491505

492506
}
493507

0 commit comments

Comments
 (0)