cherrypulp / laravel-actito
一个 Laravel 的 Actito
1.1.1
2021-03-23 08:08 UTC
Requires
- php: >=7.1.6
This package is auto-updated.
Last update: 2024-09-13 16:10:18 UTC
README
Laravel 的 Actito API 客户端
安装
通过 composer 安装
composer require cherrypulp/laravel-actito
注册服务提供者
注意!如果你使用 laravel>=5.5 并且启用了包自动发现功能,以下步骤是可选的。
将服务提供者添加到 config/app.php
文件的 providers
部分
Cherrypulp\LaravelActito\ServiceProvider::class,
注册外观
在 config/app.php
文件的 aliases
部分注册包外观
'Actito' => Cherrypulp\LaravelActito\Facades\LaravelActito::class,
发布配置文件
php artisan vendor:publish --provider="Cherrypulp\LaravelActito\ServiceProvider" --tag="config"
用法
简单调用
Actito::get('entities', $options)
Actito::post('xxx', $options)
Actito::delete('xxx', $options)
Actito::put('xxx', $options)
或者
Actito::request('xxx')
更新或创建一个配置文件
有一个助手函数可以用来更新或创建配置文件
$actito->updateOrCreate('xxx', 'Users', [
"attributes" => [
'birthDate' => date('Y-m-d', strtotime($user->birthday)),
'cardBrand' => $user->card_brand,
'cardLastFour' => $user->card_last_four,
'city' => $user->city,
'country' => $user->country,
'emailAddress' => $user->email,
'firstName' => $user->firstname,
'lastName' => $user->lastname,
'gsmNumber' => $user->phone,
'motherLanguage' => $language,
'sex' => $user->gender === 'female' ? 'F' : 'M',
'stripeid' => $user->stripe_id,
'userId' => $user->id,
'zip' => $user->zip,
'marketingConsent' => 1
],
"subscriptions" => [
"Newsletter" => true,
"Promotions" => true,
"Alertes" => true,
"Archives" => true,
"Retargeting" => true,
],
]);
``
### Update or create a custom table :
$actito->updateOrCreateCustomTable('xxx', 'Charges', [
"properties" => [
'charge_id' => $charge->id,
'updated_at' => $charge->updated_at->format('Y-m-d H:i:s'),
'created_at' => $charge->created_at->format('Y-m-d H:i:s'),
'user_id' => $charge->user_id,
'stripe_id' => $charge->stripe_id,
],
]);
### Access to the GuzzleClient
The request method is based on Guzzle for more information you can have a look here :
app('laravel-actito')->client
[http://docs.guzzlephp.org/en/stable/request-options.html](http://docs.guzzlephp.org/en/stable/request-options.html)
The Client is based on Guzzle. For more information
## Security
If you discover any security related issues, please email
instead of using the issue tracker.
## Credits
- [Cherrypulp](https://github.com/cherrypulp/laravel-actito)
- [All contributors](https://github.com/cherrypulp/laravel-actito/graphs/contributors)
This package is bootstrapped with the help of
[blok/laravel-package-generator](https://github.com/cherrypulp/laravel-package-generator).