-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.stub
178 lines (122 loc) · 4.59 KB
/
README.stub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# bitinflow Accounts
[![Latest Stable Version](https://img.shields.io/packagist/v/ghostzero/bitinflow-accounts.svg?style=flat-square)](https://packagist.org/packages/ghostzero/bitinflow-accounts)
[![Total Downloads](https://img.shields.io/packagist/dt/ghostzero/bitinflow-accounts.svg?style=flat-square)](https://packagist.org/packages/ghostzero/bitinflow-accounts)
[![License](https://img.shields.io/packagist/l/ghostzero/bitinflow-accounts.svg?style=flat-square)](https://packagist.org/packages/ghostzero/bitinflow-accounts)
PHP bitinflow Accounts API Client for Laravel 5+
## Table of contents
1. [Installation](#installation)
2. [Event Listener](#event-listener)
3. [Configuration](#configuration)
4. [Examples](#examples)
5. [Documentation](#documentation)
6. [Development](#Development)
## Installation
```
composer require ghostzero/bitinflow-accounts
```
**If you use Laravel 5.5+ you are already done, otherwise continue.**
Add Service Provider to your `app.php` configuration file:
```php
Bitinflow\Accounts\Providers\BitinflowAccountsServiceProvider::class,
```
## Event Listener
- Add `SocialiteProviders\Manager\SocialiteWasCalled` event to your `listen[]` array in `app/Providers/EventServiceProvider`.
- Add your listeners (i.e. the ones from the providers) to the `SocialiteProviders\Manager\SocialiteWasCalled[]` that you just created.
- The listener that you add for this provider is `'GhostZero\\BitinflowAccounts\\Socialite\\BitinflowExtendSocialite@handle',`.
- Note: You do not need to add anything for the built-in socialite providers unless you override them with your own providers.
```
/**
* The event handler mappings for the application.
*
* @var array
*/
protected $listen = [
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
// add your listeners (aka providers) here
'Bitinflow\\Accounts\\Socialite\\BitinflowExtendSocialite@handle',
],
];
```
## Configuration
Copy configuration to config folder:
```
$ php artisan vendor:publish --provider="Bitinflow\Accounts\Providers\BitinflowAccountsServiceProvider"
```
Add environmental variables to your `.env`
```
BITINFLOW_ACCOUNTS_KEY=
BITINFLOW_ACCOUNTS_SECRET=
BITINFLOW_ACCOUNTS_REDIRECT_URI=http://localhost
```
You will need to add an entry to the services configuration file so that after config files are cached for usage in production environment (Laravel command `artisan config:cache`) all config is still available.
**Add to `config/services.php`:**
```php
'bitinflow-accounts' => [
'client_id' => env('BITINFLOW_ACCOUNTS_KEY'),
'client_secret' => env('BITINFLOW_ACCOUNTS_SECRET'),
'redirect' => env('BITINFLOW_ACCOUNTS_REDIRECT_URI')
],
```
## Examples
#### Basic
```php
$bitinflowAccounts = new Bitinflow\Accounts\BitinflowAccounts();
$bitinflowAccounts->setClientId('abc123');
// Get SSH Key by User ID
$result = $bitinflowAccounts->getSshKeysByUserId(38);
// Check, if the query was successfull
if ( ! $result->success()) {
die('Ooops: ' . $result->error());
}
// Shift result to get single key data
$sshKey = $result->shift();
echo $sshKey->name;
```
#### Setters
```php
$bitinflowAccounts = new Bitinflow\Accounts\BitinflowAccounts();
$bitinflowAccounts->setClientId('abc123');
$bitinflowAccounts->setClientSecret('abc456');
$bitinflowAccounts->setToken('abcdef123456');
$bitinflowAccounts = $bitinflowAccounts->withClientId('abc123');
$bitinflowAccounts = $bitinflowAccounts->withClientSecret('abc123');
$bitinflowAccounts = $bitinflowAccounts->withToken('abcdef123456');
```
#### OAuth Tokens
```php
$bitinflowAccounts = new Bitinflow\Accounts\BitinflowAccounts();
$bitinflowAccounts->setClientId('abc123');
$bitinflowAccounts->setToken('abcdef123456');
$result = $bitinflowAccounts->getAuthedUser();
$user = $userResult->shift();
```
```php
$bitinflowAccounts->setToken('uvwxyz456789');
$result = $bitinflowAccounts->getAuthedUser();
```
```php
$result = $bitinflowAccounts->withToken('uvwxyz456789')->getAuthedUser();
```
#### Facade
```php
use Bitinflow\Accounts\Facades\BitinflowAccounts;
BitinflowAccounts::withClientId('abc123')->withToken('abcdef123456')->getAuthedUser();
```
## Documentation
<!-- GENERATED-DOCS -->
[**OAuth Scopes Enums**](https://github.com/ghostzero/bitinflow-accounts/blob/master/src/Enums/Scope.php)
## Development
#### Run Tests
```shell
composer test
```
```shell
BASE_URL=xxxx CLIENT_ID=xxxx CLIENT_KEY=yyyy CLIENT_ACCESS_TOKEN=zzzz composer test
```
#### Generate Documentation
```shell
composer docs
```
---
Join the bitinflow Discord!
[![Discord](https://discordapp.com/api/guilds/373468864098336768/embed.png?style=banner2)](https://discord.gg/2ZrCe2h)