Class: Remind101::Client

Inherits:
Object
  • Object
show all
Includes:
AccessTokens, Connection, Groups, Messages, Subscribers
Defined in:
lib/remind101/client.rb

Defined Under Namespace

Modules: AccessTokens, Connection, Groups, Messages, Subscribers

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Subscribers

#delete_group_subscriber, #delete_group_subscribers, #get_group_subscribers, #get_subscriber, #get_subscribers, #rename_subscriber

Methods included from Messages

#delete_message, #get_message, #get_messages, #post_message

Methods included from Groups

#delete_group, #get_groups, #post_group

Methods included from AccessTokens

#post_access_tokens

Methods included from Connection

#middleware

Constructor Details

#initialize(options = {}) {|middleware| ... } ⇒ Client

Returns a new instance of Client.

Yields:



28
29
30
31
# File 'lib/remind101/client.rb', line 28

def initialize(options = {})
  @options = options
  yield middleware if block_given?
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/remind101/client.rb', line 15

def options
  @options
end

Instance Method Details

#auth_tokenObject

Public: Returns the auth token that’s being used for authenticated requests.

Returns String.



36
37
38
# File 'lib/remind101/client.rb', line 36

def auth_token
  options[:auth_token]
end

#auth_token=(token) ⇒ Object

Public: Sets the auth token to be used for authenticated requests.

Returns nothing.



43
44
45
# File 'lib/remind101/client.rb', line 43

def auth_token=(token)
  options[:auth_token] = token
end

#authenticate!(username, password) ⇒ Object

Public: Creates a new access token and sets it on the client for future requests.

Returns the faraday response from creating the access token.



20
21
22
23
24
25
26
# File 'lib/remind101/client.rb', line 20

def authenticate!(username, password)
  post_access_tokens(user: { email: username, password: password }).tap do |response|
    self.auth_token = response.body.auth_token
    # Force the connection to be recreated to use the new auth token.
    @connection = nil
  end
end