a4anthony / whereby-laravel
WhereBy 包
1.0.4
2023-01-04 13:56 UTC
Requires
- ext-curl: *
- ext-json: *
Requires (Dev)
- orchestra/testbench: ^6.0
README
Whereby API 的 Laravel 包
安装
要安装此包,请在您的终端中运行以下命令
composer require a4anthony/whereby-laravel
包安装完成后,您需要注册服务提供者。打开 config/app.php
并将以下内容添加到 providers
键中。
'providers' => [ ... A4Anthony\WherebyLaravel\Providers\WherebyLaravelServiceProvider::class, ... ]
如果您使用 Laravel >= 5.5,则可以跳过此步骤并转到
配置
同时,按照如下方式注册 Facade
'aliases' => [ ... 'WherebyLaravel': A4Anthony/WherebyLaravel/Facades/WherebyLaravel::class ... ]
配置
您可以使用以下命令发布配置文件
php artisan vendor:publish --provider="A4Anthony\WherebyLaravel\Providers\WherebyLaravelServiceProvider"
一个名为 whereby-laravel.php
的配置文件(包含一些合理的默认值)将被放置在您的 config
目录中
<?php return [ /** * Whereby API Key */ "api_key" => env("WHEREBY_API_KEY"), /** * Whereby API Version */ "api_version" => env("WHEREBY_API_VERSION", "v1"), /** * Whereby API Base URL */ "base_uri" => env("WHEREBY_BASE_URI", "https://api.whereby.dev"), ];
用法
打开您的 .env 文件,并添加您的公钥、密钥、商户电子邮件和支付 URL,如下所示
WHEREBY_API_KEY=xxxxxxxxxxxxx WHEREBY_API_VERSION=xxxxxxxxxxxxx WHEREBY_WEBHOOK_SECRET=xxxxxxxxxxxxx
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use WherebyLaravel; class HomeController extends Controller { public function index() { $data = [ "isLocked" => false, "startDate" => "2020-10-10T10:10:10Z", "endDate" => "2023-10-10T10:10:10Z", ]; $meeting = WherebyLaravel::createMeeting($data); // Create a meeting dd($meeting); } }
让我为您解释一下该包提供的流畅方法。
/** * Creates a new meeting * * @param array $data [see https://whereby.dev/http-api/#/paths/~1meetings/post] */ WherebyLaravel::createMeeting($data); /** * Retrieves a meeting * * @param string $meetingId [see https://whereby.dev/http-api/#/paths/~1meetings/post] */ WherebyLaravel::getMeeting($meetingId); /** * Retrieves an event from webhook * * [see https://docs.whereby.com/monitoring-usage/webhooks] */ WherebyLaravel::webhook();
贡献
请随意fork此包,通过提交拉取请求来增强功能进行贡献。
如何感谢您?
为什么不给 github 仓库加个星标?我很乐意得到关注!为什么不把此仓库的链接分享到 Twitter 或 HackerNews 上?传播一下信息吧!
别忘了关注我的推特!
谢谢!Anthony Akro。
许可协议
MIT 许可协议(MIT)。请参阅许可文件以获取更多信息。