generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joshua Paul
authored and
Joshua Paul
committed
May 13, 2023
1 parent
529ed0e
commit c42e183
Showing
5 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Webhook API | ||
|
||
## Sample Webhook Payload | ||
|
||
```php | ||
$payload = [ | ||
'active' => true, | ||
'events' => ['address.created', 'shipment.created'], | ||
'live' => true, | ||
'name' => 'My Webhook', | ||
'url' => 'https://example.com/webhook' | ||
]; | ||
``` | ||
|
||
## Create Webhook | ||
|
||
This method allows you to create a new webhook. | ||
|
||
```php | ||
$webhook = TerminalAfrica::createWebhook($payload); | ||
``` | ||
|
||
## Get webhooks | ||
|
||
This method allows you to retrieve a list of webhooks. | ||
|
||
```php | ||
$payload = [ | ||
"perPage": 50, | ||
"page": 3 | ||
]; | ||
|
||
// The $payload parameter is optional. | ||
$webhooks = TerminalAfrica::getWebhooks($payload); | ||
``` | ||
|
||
## Get webhook | ||
|
||
This method allows you to retrieve details of a specific webhook. | ||
|
||
```php | ||
$webhookId = 'xxxxxxxxx'; | ||
$webhook = TerminalAfrica::getWebhook($webhookId); | ||
``` | ||
|
||
## Enable webhook | ||
|
||
This method allows you to enable a webhook. | ||
|
||
```php | ||
$webhookId = 'xxxxxxxxx'; | ||
$webhook = TerminalAfrica::enableWebhook($webhookId); | ||
``` | ||
|
||
## Disable webhook | ||
|
||
This method allows you to disable a webhook. | ||
|
||
```php | ||
$webhookId = 'xxxxxxxxx'; | ||
$webhook = TerminalAfrica::disableWebhook($webhookId); | ||
``` | ||
|
||
## Delete webhook | ||
|
||
This method allows you to delete a webhook. | ||
|
||
```php | ||
$webhookId = 'xxxxxxxxx'; | ||
$webhook = TerminalAfrica::deleteWebhook($webhookId); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
namespace Cybernerdie\LaravelTerminalAfrica\Traits; | ||
|
||
use Cybernerdie\LaravelTerminalAfrica\Constants\TerminalAfricaConstant; | ||
|
||
trait WebhookApi | ||
{ | ||
/** | ||
* This method allows you to create a new webhook. | ||
*/ | ||
public function createWebhook(array $formParams): array | ||
{ | ||
$endpoint = sprintf('%s', TerminalAfricaConstant::WEBHOOK_ENDPOINT); | ||
|
||
return $this->makeRequest( | ||
method: 'POST', | ||
endpoint: $endpoint, | ||
formParams: $formParams | ||
); | ||
} | ||
|
||
/** | ||
* This method allows you to retrieve a list of webhooks. | ||
*/ | ||
public function getWebhooks(array $queryParams = []): array | ||
{ | ||
$endpoint = sprintf('%s', TerminalAfricaConstant::WEBHOOK_ENDPOINT); | ||
|
||
return $this->makeRequest( | ||
method: 'GET', | ||
endpoint: $endpoint, | ||
queryParams: $queryParams | ||
); | ||
} | ||
|
||
/** | ||
* This method allows you to retrieve details of a specific webhook. | ||
*/ | ||
public function getWebhook(string $webhookId): array | ||
{ | ||
$endpoint = sprintf('%s/%s', TerminalAfricaConstant::WEBHOOK_ENDPOINT, $webhookId); | ||
|
||
return $this->makeRequest( | ||
method: 'GET', | ||
endpoint: $endpoint | ||
); | ||
} | ||
|
||
/** | ||
* This method allows you to disable a specific webhook. | ||
*/ | ||
public function disableWebhook(string $webhookId): array | ||
{ | ||
$endpoint = sprintf('%s/disable/%s', TerminalAfricaConstant::WEBHOOK_ENDPOINT, $webhookId); | ||
|
||
return $this->makeRequest( | ||
method: 'POST', | ||
endpoint: $endpoint | ||
); | ||
} | ||
|
||
/** | ||
* This method allows you to enable a specific webhook. | ||
*/ | ||
public function enableWebhook(string $webhookId): array | ||
{ | ||
$endpoint = sprintf('%s/enable/%s', TerminalAfricaConstant::WEBHOOK_ENDPOINT, $webhookId); | ||
|
||
return $this->makeRequest( | ||
method: 'POST', | ||
endpoint: $endpoint | ||
); | ||
} | ||
|
||
/** | ||
* This method allows you to delete a specific webhook. | ||
*/ | ||
public function deleteWebhook(string $webhookId): array | ||
{ | ||
$endpoint = sprintf('%s/%s', TerminalAfricaConstant::WEBHOOK_ENDPOINT, $webhookId); | ||
|
||
return $this->makeRequest( | ||
method: 'DELETE', | ||
endpoint: $endpoint | ||
); | ||
} | ||
} |
c42e183
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
laravel-terminal-africa – ./
laravel-terminal-africa.vercel.app
laravel-terminal-africa-cybernerdie.vercel.app
laravel-terminal-africa-git-main-cybernerdie.vercel.app