remind101 0.2.1 → 0.2.2
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/lib/remind101/client/users.rb +13 -0
- data/lib/remind101/client.rb +11 -7
- data/lib/remind101/error.rb +7 -3
- data/lib/remind101/version.rb +1 -1
- data/spec/remind101/client_spec.rb +3 -3
- data/spec/remind101/error_spec.rb +9 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1180dc343c9abc1871c8bbffd694025194f88111
|
4
|
+
data.tar.gz: 51a08c766d818d5c2bdce644fd47e564ad33af38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8292a36351c1a5fab925e46635eb669b19138f2e691a82641a8afa383f638ee709001a2790b76a22789df1da89b4030a68516416f8fd9e83a4a915674a556caf
|
7
|
+
data.tar.gz: 380be6108c21e9bfe936202bb39a0a9a10110dcaee01cb0b9058f644f555203e9e6a4a54e10d7bd92e5145b64e3132b12574256cefaab96c19a42be44e2ac2f4
|
data/lib/remind101/client.rb
CHANGED
@@ -5,24 +5,28 @@ module Remind101
|
|
5
5
|
require 'remind101/client/groups'
|
6
6
|
require 'remind101/client/messages'
|
7
7
|
require 'remind101/client/subscribers'
|
8
|
+
require 'remind101/client/users'
|
8
9
|
|
9
10
|
include Connection
|
10
11
|
include AccessTokens
|
11
12
|
include Groups
|
12
13
|
include Messages
|
13
14
|
include Subscribers
|
15
|
+
include Users
|
14
16
|
|
15
17
|
attr_reader :options
|
16
18
|
|
17
|
-
# Public:
|
19
|
+
# Public: Helper remind Client#authenticate!
|
20
|
+
def self.authenticate!(username, password, *args)
|
21
|
+
new(*args).authenticate!(username, password)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Public: Authenticates using this client, then returns a new client with the access token.
|
18
25
|
#
|
19
|
-
# Returns
|
26
|
+
# Returns a Remind101::Client.
|
20
27
|
def authenticate!(username, password)
|
21
|
-
post_access_tokens(user: { email: username, password: password })
|
22
|
-
|
23
|
-
# Force the connection to be recreated to use the new auth token.
|
24
|
-
@connection = nil
|
25
|
-
end
|
28
|
+
resp = post_access_tokens(user: { email: username, password: password })
|
29
|
+
self.class.new(options.merge(auth_token: resp.body.token))
|
26
30
|
end
|
27
31
|
|
28
32
|
def initialize(options = {})
|
data/lib/remind101/error.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
module Remind101
|
2
2
|
module Error
|
3
|
-
ClientError
|
4
|
-
ResourceNotFound
|
5
|
-
ConnectionFailed
|
3
|
+
ClientError = Class.new(Faraday::Error::ClientError)
|
4
|
+
ResourceNotFound = Class.new(ClientError)
|
5
|
+
ConnectionFailed = Class.new(ClientError)
|
6
|
+
|
7
|
+
ServerError = Class.new(ClientError)
|
8
|
+
InternalServerError = Class.new(ServerError)
|
9
|
+
ServiceUnavailable = Class.new(ServerError)
|
6
10
|
|
7
11
|
module ErrorsBody
|
8
12
|
def error
|
data/lib/remind101/version.rb
CHANGED
@@ -14,12 +14,12 @@ describe Remind101::Client do
|
|
14
14
|
before do
|
15
15
|
stub_request(:post, 'https://api.remind.com/v2/access_tokens')
|
16
16
|
.with(body: { user: { email: username, password: password } })
|
17
|
-
.to_return(body: {
|
17
|
+
.to_return(body: { token: auth_token })
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'returns an auth token for the user' do
|
21
|
-
client.authenticate!(username, password)
|
22
|
-
expect(
|
21
|
+
new_client = client.authenticate!(username, password)
|
22
|
+
expect(new_client.auth_token).to eq auth_token
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -8,8 +8,16 @@ describe Remind101::Error do
|
|
8
8
|
Remind101::Error::Unauthorized,
|
9
9
|
Remind101::Error::ResourceNotFound,
|
10
10
|
Remind101::Error::ValidationError,
|
11
|
-
Remind101::Error::ConnectionFailed
|
11
|
+
Remind101::Error::ConnectionFailed,
|
12
|
+
Remind101::Error::ServerError
|
12
13
|
].each do |klass|
|
13
14
|
specify { klass.should inherit_from Remind101::Error::ClientError }
|
14
15
|
end
|
16
|
+
|
17
|
+
[
|
18
|
+
Remind101::Error::InternalServerError,
|
19
|
+
Remind101::Error::ServiceUnavailable,
|
20
|
+
].each do |klass|
|
21
|
+
specify { klass.should inherit_from Remind101::Error::ServerError }
|
22
|
+
end
|
15
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remind101
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric J. Holmes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- lib/remind101/client/groups.rb
|
167
167
|
- lib/remind101/client/messages.rb
|
168
168
|
- lib/remind101/client/subscribers.rb
|
169
|
+
- lib/remind101/client/users.rb
|
169
170
|
- lib/remind101/command/auth.rb
|
170
171
|
- lib/remind101/command/base.rb
|
171
172
|
- lib/remind101/command/groups.rb
|