├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── config └── chatwork.php └── src ├── Facade.php └── ServiceProvider.php /.gitignore: -------------------------------------------------------------------------------- 1 | composer.phar 2 | /vendor/ 3 | /coverage 4 | composer.lock 5 | 6 | .idea 7 | .vscode 8 | .DS_Strore 9 | 10 | .phpunit.result.cache 11 | # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control 12 | # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file 13 | # composer.lock 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Sun* Research 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel Chatwork SDK 2 | 3 | [![Latest Stable Version](https://poser.pugx.org/sun-asterisk/laravel-chatwork/v/stable)](https://packagist.org/packages/sun-asterisk/laravel-chatwork) 4 | 5 | Chatwork SDK for Laravel 5, 6, 7. 6 | 7 | ## Installation 8 | 9 | Using composer: 10 | 11 | ```sh 12 | composer require sun-asterisk/laravel-chatwork 13 | ``` 14 | 15 | For Laravel 5.4 and earlier, add the service provider to your `config/app.php`. 16 | 17 | ```php 18 | 'providers' => [ 19 | // ... 20 | SunAsterisk\Chatwork\Laravel\ServiceProvider::class 21 | // ... 22 | ]; 23 | ``` 24 | 25 | ## Configure 26 | 27 | First register an API Key [here](https://www.chatwork.com/service/packages/chatwork/subpackages/api/token.php). 28 | Then add the API key to your `.env`: 29 | 30 | ```env 31 | CHATWORK_API_KEY=your_api_key_here 32 | ``` 33 | 34 | ## Usage 35 | 36 | You can use the provided facade via an alias: 37 | 38 | ```php 39 | use Chatwork; 40 | 41 | $me = Chatwork::me(); 42 | $members = Chatwork::room($roomId)->members()->list(); 43 | ``` 44 | 45 | Or use dependency injection: 46 | 47 | ```php 48 | use SunAsterisk\Chatwork\Chatwork; 49 | 50 | class ChatworkCommand extends Command 51 | { 52 | public function handle(Chatwork $chatwork) 53 | { 54 | $message = $chatwork->toAll()->text('Hi there'); 55 | $chatwork->room($roomId)->messages()->create($message); 56 | } 57 | } 58 | ``` 59 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sun-asterisk/laravel-chatwork", 3 | "description": "Chatwork SDK for Laravel", 4 | "type": "library", 5 | "require": { 6 | "sun-asterisk/chatwork-php": "^0.1.1", 7 | "illuminate/support": "^5.0|^6.0|^7.0" 8 | }, 9 | "require-dev": { 10 | "phpunit/phpunit": "^8.3" 11 | }, 12 | "license": "MIT", 13 | "autoload": { 14 | "psr-4": { 15 | "SunAsterisk\\Chatwork\\Laravel\\": "src/" 16 | } 17 | }, 18 | "autoload-dev": { 19 | "classmap": [ 20 | "tests/" 21 | ] 22 | }, 23 | "config": { 24 | "sort-packages": true 25 | }, 26 | "extra": { 27 | "laravel": { 28 | "providers": [ 29 | "SunAsterisk\\Chatwork\\Laravel\\ServiceProvider" 30 | ], 31 | "aliases": { 32 | "Chatwork": "SunAsterisk\\Chatwork\\Laravel\\Facade" 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /config/chatwork.php: -------------------------------------------------------------------------------- 1 | env('CHATWORK_API_KEY'), 5 | ]; 6 | -------------------------------------------------------------------------------- /src/Facade.php: -------------------------------------------------------------------------------- 1 | mergeConfigFrom( 15 | __DIR__.'/../config/chatwork.php', 16 | 'chatwork' 17 | ); 18 | 19 | $this->app->singleton(Chatwork::class, function (Application $app) { 20 | $token = $app->make('config')->get('chatwork.api_key'); 21 | $auth = new APIToken($token); 22 | return new Chatwork($auth); 23 | }); 24 | } 25 | } 26 | --------------------------------------------------------------------------------