rallio 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +109 -1
- data/lib/rallio/account.rb +5 -0
- data/lib/rallio/account_ownership.rb +17 -0
- data/lib/rallio/base.rb +0 -6
- data/lib/rallio/franchisor.rb +1 -2
- data/lib/rallio/franchisor_ownership.rb +15 -0
- data/lib/rallio/ownerships_base.rb +18 -0
- data/lib/rallio/user.rb +2 -10
- data/lib/rallio/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c4ea3d06f8622e3412ca3a95e0f1a68cb02ae40
|
4
|
+
data.tar.gz: 972a7189aa36fa4840d3cf84b00d085509bba86c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62b63506746d5e6f923cd628afe9c1697cf25fbf3cfb9734d1a9392297010c38edd28ec5d9265f9d4f13f84c3fedf70e9913cd209309d528969d58a43fbc664c
|
7
|
+
data.tar.gz: d8226ce802c1209a0e0c78edf08ef2f7e96f3ce3e7d797e5c949e6971979630c49c5b6c905edddd4046f90d91d1d3e3e84dc80a6e746e4cd68944517157678d5
|
data/README.md
CHANGED
@@ -93,6 +93,24 @@ user.access_token
|
|
93
93
|
# => <Rallio::AccessToken @access_token="4a25dd89e50bd0a0db1eeae65864fe6b", @user_id=100, @expires_at=nil, @scopes="user_info basic_access">
|
94
94
|
```
|
95
95
|
|
96
|
+
#### #account_ownerships
|
97
|
+
|
98
|
+
Returns all the accounts this user is associated with.
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
user.account_ownerships
|
102
|
+
# => [#<Rallio::AccountOwnership:0x007fc3aaaa70b0 @user_id=100, @account_id=200, @account_name="Awesome Haircuts New York City", @account_franchisor_id=300, @account_franchisor_name="Awesome Haircuts Franchisor 1">]
|
103
|
+
```
|
104
|
+
|
105
|
+
#### #franchisor_ownerships
|
106
|
+
|
107
|
+
Returns all the franchisors this user is associated with.
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
user.franchisor_ownerships
|
111
|
+
# => [#<Rallio::FranchisorOwnership:0x007f93d8986340 @user_id=100, @franchisor_id=300, @franchisor_name="Awesome Haircuts Franchisor 1">]
|
112
|
+
```
|
113
|
+
|
96
114
|
#### #me
|
97
115
|
|
98
116
|
**NOTE:** This endpoint is in the docs but it appears it may not be implemented.
|
@@ -147,6 +165,87 @@ access_token = Rallio::AccessToken.new(access_token: '4a25dd89e50bd0a0db1eeae658
|
|
147
165
|
access_token.destroy # => true
|
148
166
|
```
|
149
167
|
|
168
|
+
### FranchisorOwnership
|
169
|
+
|
170
|
+
#### .for
|
171
|
+
|
172
|
+
Returns all franchisors for a given access token.
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
Rallio::FranchisorOwnership.for(access_token: '4a25dd89e50bd0a0db1eeae65864fe6b')
|
176
|
+
# => [<Rallio::FranchisorOwnership:0x007f93d8986340 @user_id=100, @franchisor_id=300, @franchisor_name="Awesome Haircuts Franchisor 1">]
|
177
|
+
```
|
178
|
+
|
179
|
+
#### .create
|
180
|
+
|
181
|
+
This creates an association between a user and a Franchisor.
|
182
|
+
|
183
|
+
```ruby
|
184
|
+
Rallio::FranchisorOwnership.create(user_id: 100, franchisor_id: 300)
|
185
|
+
# => <Rallio::FranchisorOwnership:0x007f93d8986340 @user_id=100, @franchisor_id=300, @franchisor_name="Awesome Haircuts Franchisor 1">
|
186
|
+
```
|
187
|
+
|
188
|
+
#### .destroy
|
189
|
+
|
190
|
+
Destroys a relationship between user and franchisor.
|
191
|
+
|
192
|
+
```ruby
|
193
|
+
Rallio::FranchisorOwnership.destroy(user_id: 100, franchisor_id: 300)
|
194
|
+
# => {}
|
195
|
+
```
|
196
|
+
|
197
|
+
### AccountOwnership
|
198
|
+
|
199
|
+
#### .for
|
200
|
+
|
201
|
+
Returns all accounts for a given access token.
|
202
|
+
|
203
|
+
```ruby
|
204
|
+
Rallio::AccountOwnership.for(access_token: '4a25dd89e50bd0a0db1eeae65864fe6b')
|
205
|
+
# => [<Rallio::AccountOwnership:0x007fc3aaaa70b0 @user_id=100, @account_id=200, @account_name="Awesome Haircuts New York City", @account_franchisor_id=300, @account_franchisor_name="Awesome Haircuts Franchisor 1">]
|
206
|
+
```
|
207
|
+
|
208
|
+
#### .create
|
209
|
+
|
210
|
+
This creates an association between a user and an Account.
|
211
|
+
|
212
|
+
```ruby
|
213
|
+
Rallio::AccountOwnership.create(user_id: 100, account_id: 200)
|
214
|
+
# => <Rallio::AccountOwnership:0x007fc3aaaa70b0 @user_id=100, @account_id=200, @account_name="Awesome Haircuts New York City", @account_franchisor_id=300, @account_franchisor_name="Awesome Haircuts Franchisor 1">
|
215
|
+
```
|
216
|
+
|
217
|
+
#### .destroy
|
218
|
+
|
219
|
+
Destroys a relationship between user and account.
|
220
|
+
|
221
|
+
```ruby
|
222
|
+
Rallio::AccountOwnership.destroy(user_id: 100, account_id: 200)
|
223
|
+
# => {}
|
224
|
+
```
|
225
|
+
|
226
|
+
### Franchisor
|
227
|
+
|
228
|
+
#### .all
|
229
|
+
|
230
|
+
Returns all franchisors for a given set of app credentials.
|
231
|
+
|
232
|
+
```ruby
|
233
|
+
Rallio::Franchisor.all
|
234
|
+
# => [<Rallio::Franchisor:0x007fa944c30e48 @id=100, @name="Awesome Haircuts", @short_name=nil, @url=nil, @city=nil, @country_code=nil, @time_zone=nil>]
|
235
|
+
```
|
236
|
+
|
237
|
+
#### #accounts
|
238
|
+
|
239
|
+
Returns all accounts associated with a franchisor.
|
240
|
+
|
241
|
+
```ruby
|
242
|
+
franchisor = Rallio::Franchisor.new(id: 100)
|
243
|
+
# => <Rallio::Franchisor:0x007fa944c30e48 @id=100, @name=nil, @short_name=nil, @url=nil, @city=nil, @country_code=nil, @time_zone=nil>
|
244
|
+
|
245
|
+
franchisor.accounts
|
246
|
+
# => [<Rallio::Account:0x007f801bb0a610 @id=100, @name="Awesome Haircuts New York City", @short_name="AH-NYC", @url="https://awesomehaircuts.fake", @city="New York", @country_code="US", @time_zone="Eastern Time (US & Canada)">]
|
247
|
+
```
|
248
|
+
|
150
249
|
### Account
|
151
250
|
|
152
251
|
These gives access to account info that a user has access to. In order to query
|
@@ -157,7 +256,16 @@ user.access_token
|
|
157
256
|
# => <Rallio::AccessToken @access_token="4a25dd89e50bd0a0db1eeae65864fe6b", @user_id=100, @expires_at=nil, @scopes="user_info basic_access">
|
158
257
|
```
|
159
258
|
|
160
|
-
#### .
|
259
|
+
#### .for
|
260
|
+
|
261
|
+
Get all accounts for a given franchisor_id.
|
262
|
+
|
263
|
+
```ruby
|
264
|
+
accounts = Rallio::Account.for(franchisor_id: 200)
|
265
|
+
# => [<Rallio::Account:0x007f801bb0a610 @id=100, @name="Awesome Haircuts New York City", @short_name="AH-NYC", @url="https://awesomehaircuts.fake", @city="New York", @country_code="US", @time_zone="Eastern Time (US & Canada)">]
|
266
|
+
```
|
267
|
+
|
268
|
+
#### #reviews
|
161
269
|
|
162
270
|
This is a convenience method to get reviews for a given account. All that is
|
163
271
|
needed is a `Rallio::Account` object instantiated with a valid account id. This
|
data/lib/rallio/account.rb
CHANGED
@@ -12,6 +12,11 @@ module Rallio
|
|
12
12
|
Review.all(type: type, id: id, access_token: access_token)
|
13
13
|
end
|
14
14
|
|
15
|
+
def self.for(franchisor_id:)
|
16
|
+
response = self.get("/franchisors/#{franchisor_id}/accounts", headers: app_credentials)
|
17
|
+
response.parsed_response['accounts'].map { |a| new a }
|
18
|
+
end
|
19
|
+
|
15
20
|
private
|
16
21
|
|
17
22
|
def type
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Rallio
|
2
|
+
class AccountOwnership < OwnershipsBase
|
3
|
+
attribute :user_id, Integer
|
4
|
+
attribute :account_id, Integer
|
5
|
+
attribute :account_name, String
|
6
|
+
attribute :account_franchisor_id, Integer
|
7
|
+
attribute :account_franchisor_name, String
|
8
|
+
|
9
|
+
def self.url_segment
|
10
|
+
'account_ownerships'
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.response_key
|
14
|
+
'account_ownership'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/rallio/base.rb
CHANGED
data/lib/rallio/franchisor.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Rallio
|
2
|
+
class FranchisorOwnership < OwnershipsBase
|
3
|
+
attribute :user_id, Integer
|
4
|
+
attribute :franchisor_id, Integer
|
5
|
+
attribute :franchisor_name, String
|
6
|
+
|
7
|
+
def self.url_segment
|
8
|
+
'franchisor_ownerships'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.response_key
|
12
|
+
'franchisor_ownership'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Rallio
|
2
|
+
class OwnershipsBase < Base
|
3
|
+
def self.for(access_token:)
|
4
|
+
headers = { 'Authorization' => "Bearer #{access_token}" }
|
5
|
+
response = self.get("/#{url_segment}", headers: headers)
|
6
|
+
response.parsed_response["#{url_segment}"].map { |a| new(a) }
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.create(user_id:, payload:)
|
10
|
+
response = self.post("/users/#{user_id}/#{url_segment}", headers: app_credentials, body: payload)
|
11
|
+
new response.parsed_response["#{response_key}"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.destroy(user_id:, object_id:)
|
15
|
+
self.delete("/users/#{user_id}/#{url_segment}/#{object_id}", headers: app_credentials)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/rallio/user.rb
CHANGED
@@ -28,13 +28,11 @@ module Rallio
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def account_ownerships
|
31
|
-
|
32
|
-
response.parsed_response
|
31
|
+
AccountOwnership.for(access_token: access_token.access_token)
|
33
32
|
end
|
34
33
|
|
35
34
|
def franchisor_ownerships
|
36
|
-
|
37
|
-
response.parsed_response
|
35
|
+
FranchisorOwnership.for(access_token: access_token.access_token)
|
38
36
|
end
|
39
37
|
|
40
38
|
# Initially this endpoint was in the API docs but it appears it may not be
|
@@ -45,11 +43,5 @@ module Rallio
|
|
45
43
|
# self.attributes = response.parsed_response
|
46
44
|
# self
|
47
45
|
# end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def user_credentials
|
52
|
-
{ 'Authorization' => "Bearer #{access_token.access_token}" }
|
53
|
-
end
|
54
46
|
end
|
55
47
|
end
|
data/lib/rallio/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rallio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JD Guzman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -142,8 +142,11 @@ files:
|
|
142
142
|
- lib/rallio.rb
|
143
143
|
- lib/rallio/access_token.rb
|
144
144
|
- lib/rallio/account.rb
|
145
|
+
- lib/rallio/account_ownership.rb
|
145
146
|
- lib/rallio/base.rb
|
146
147
|
- lib/rallio/franchisor.rb
|
148
|
+
- lib/rallio/franchisor_ownership.rb
|
149
|
+
- lib/rallio/ownerships_base.rb
|
147
150
|
- lib/rallio/review.rb
|
148
151
|
- lib/rallio/sign_on_token.rb
|
149
152
|
- lib/rallio/user.rb
|