Class: Remind101::Client

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

Defined Under Namespace

Modules: AccessTokens, ChatMessages, Connection, Groups, Messages, Subscribers, Users

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Users

#get_user

Methods included from Subscribers

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

Methods included from ChatMessages

#get_chat_message

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:



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

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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



19
20
21
# File 'lib/remind101/client.rb', line 19

def options
  @options
end

Class Method Details

.authenticate!(username, password, *args) ⇒ Object

Public: Helper remind Client#authenticate!



22
23
24
# File 'lib/remind101/client.rb', line 22

def self.authenticate!(username, password, *args)
  new(*args).authenticate!(username, password)
end

Instance Method Details

#auth_tokenObject

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

Returns String.



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

def auth_token
  options[:auth_token]
end

#auth_token=(token) ⇒ Object

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

Returns nothing.



49
50
51
# File 'lib/remind101/client.rb', line 49

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

#authenticate!(username, password) ⇒ Object

Public: Authenticates using this client, then returns a new client with the access token.

Returns a Remind101::Client.



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

def authenticate!(username, password)
  resp = post_access_tokens(user: { email: username, password: password })
  self.class.new(options.merge(auth_token: resp.body.token))
end