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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1faa05e29b28622fcfda12de219e9a633596a989
4
- data.tar.gz: c69839a0a708c5d79e291126442c70ddefe32aca
3
+ metadata.gz: 1180dc343c9abc1871c8bbffd694025194f88111
4
+ data.tar.gz: 51a08c766d818d5c2bdce644fd47e564ad33af38
5
5
  SHA512:
6
- metadata.gz: 070b8ae9bf4b8228b874e2a7b428e991755a129d06f7bd05d92eb080c85b5af2012997d0c8b42889e8c843bd7bc59546c0ab1d99f306e650a7143979b83b0963
7
- data.tar.gz: a949cbf125c0b7a8318c5d5405a070b1a0093f68a154f3e77c48a8b2fb7f2fe9c806254044cd88eb11ff14594b3c1235580cf5d8cd309af7ab5ca1ba22a5e29e
6
+ metadata.gz: 8292a36351c1a5fab925e46635eb669b19138f2e691a82641a8afa383f638ee709001a2790b76a22789df1da89b4030a68516416f8fd9e83a4a915674a556caf
7
+ data.tar.gz: 380be6108c21e9bfe936202bb39a0a9a10110dcaee01cb0b9058f644f555203e9e6a4a54e10d7bd92e5145b64e3132b12574256cefaab96c19a42be44e2ac2f4
@@ -0,0 +1,13 @@
1
+ module Remind101::Client::Users
2
+
3
+ # Public: Returns the current user.
4
+ #
5
+ # Examples
6
+ #
7
+ # remind101.get_user
8
+ #
9
+ # Returns the faraday response.
10
+ def get_user
11
+ api_get('/user')
12
+ end
13
+ end
@@ -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: Creates a new access token and sets it on the client for future requests.
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 the faraday response from creating the access token.
26
+ # Returns a Remind101::Client.
20
27
  def authenticate!(username, password)
21
- post_access_tokens(user: { email: username, password: password }).tap do |response|
22
- self.auth_token = response.body.auth_token
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 = {})
@@ -1,8 +1,12 @@
1
1
  module Remind101
2
2
  module Error
3
- ClientError = Class.new(Faraday::Error::ClientError)
4
- ResourceNotFound = Class.new(ClientError)
5
- ConnectionFailed = Class.new(ClientError)
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
@@ -1,3 +1,3 @@
1
1
  module Remind101
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
@@ -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: { auth_token: auth_token })
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(client.auth_token).to eq auth_token
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.1
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-27 00:00:00.000000000 Z
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