omniauth-applicaster 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/applicaster/accounts.rb +8 -4
- data/lib/omniauth-applicaster/version.rb +1 -1
- data/spec/lib/applicaster/accounts_spec.rb +32 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cdfcee895b255c8a6aab814044d79692d2a1b0f
|
4
|
+
data.tar.gz: 5d43ff220df15f20799c267c6e7b004e33928b9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94660689cb5cbe63ae03646dd6fedcb3de2aac8a9aaf9560cb775e2f79a5b3c24a116d81dafefe6e19ae0e7edc38fd5b9d58cdd5cc84741084df3773097713b5
|
7
|
+
data.tar.gz: 5ce0f144b60f822b1b4809acd5dc777c80d3e78db654f87431c59a0ba7ef2faa106d40f2801abbe928c72f4cf5cb32775cd56309f3fd8b85275b6b3e231ca3d9
|
data/README.md
CHANGED
@@ -99,6 +99,13 @@ user = Applicaster::Accounts.user_from_token(access_token)
|
|
99
99
|
# user is an Applicaster::Accounts::User instance
|
100
100
|
```
|
101
101
|
|
102
|
+
#### Get a list of accounts for a specific user
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
accounts = Applicaster::Accounts.accounts_from_token(access_token)
|
106
|
+
# accounts is an array of `Applicaster::Accounts::User` objects
|
107
|
+
```
|
108
|
+
|
102
109
|
## Contributing
|
103
110
|
|
104
111
|
1. Fork it ( https://github.com/[my-github-username]/omniauth-applicaster/fork )
|
data/lib/applicaster/accounts.rb
CHANGED
@@ -59,6 +59,13 @@ module Applicaster
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
def accounts_from_token(token)
|
63
|
+
connection(token: token)
|
64
|
+
.get("/api/v1/accounts.json")
|
65
|
+
.body
|
66
|
+
.map {|a| Account.new(a) }
|
67
|
+
end
|
68
|
+
|
62
69
|
def config
|
63
70
|
@config ||= Configuration.new
|
64
71
|
end
|
@@ -82,10 +89,7 @@ module Applicaster
|
|
82
89
|
end
|
83
90
|
|
84
91
|
def accounts
|
85
|
-
|
86
|
-
.get("/api/v1/accounts.json")
|
87
|
-
.body
|
88
|
-
.map {|a| Account.new(a) }
|
92
|
+
self.class.accounts_from_token(client_credentials_token.token)
|
89
93
|
end
|
90
94
|
|
91
95
|
def connection(*args)
|
@@ -92,6 +92,20 @@ RSpec.describe Applicaster::Accounts do
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
+
describe ".accounts_from_token" do
|
96
|
+
let(:token) { "valid-access-token" }
|
97
|
+
let(:return_value) { Applicaster::Accounts.accounts_from_token(token) }
|
98
|
+
|
99
|
+
before do
|
100
|
+
stub_accounts_index_request(token)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "returns an array of Applicaster::Accounts::Account" do
|
104
|
+
expect(return_value).to be_kind_of(Array)
|
105
|
+
expect(return_value.first).to be_kind_of(Applicaster::Accounts::Account)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
95
109
|
describe ".config" do
|
96
110
|
it "returns an Applicaster::Accounts::Configuration" do
|
97
111
|
expect(config).to be_kind_of(Applicaster::Accounts::Configuration)
|
@@ -119,7 +133,7 @@ RSpec.describe Applicaster::Accounts do
|
|
119
133
|
describe "#accounts" do
|
120
134
|
before do
|
121
135
|
stub_client_credentials_request
|
122
|
-
stub_accounts_index_request
|
136
|
+
stub_accounts_index_request("client-credentials-token")
|
123
137
|
end
|
124
138
|
|
125
139
|
it "returns an array of Account objects" do
|
@@ -131,24 +145,24 @@ RSpec.describe Applicaster::Accounts do
|
|
131
145
|
def return_value
|
132
146
|
@return_value ||= accounts_service.accounts
|
133
147
|
end
|
148
|
+
end
|
134
149
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
150
|
+
def stub_accounts_index_request(token)
|
151
|
+
stub_request(:get, "https://accounts2.applicaster.com/api/v1/accounts.json").
|
152
|
+
with(query: { access_token: token }).
|
153
|
+
to_return(successful_json_response(mock_accounts_response))
|
154
|
+
end
|
140
155
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
end
|
156
|
+
def mock_accounts_response
|
157
|
+
[
|
158
|
+
{
|
159
|
+
id: "1-account-1",
|
160
|
+
name: "Account 1",
|
161
|
+
},
|
162
|
+
{
|
163
|
+
id: "2-account-2",
|
164
|
+
name: "Account 2",
|
165
|
+
},
|
166
|
+
]
|
153
167
|
end
|
154
168
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-applicaster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neer Friedman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|