Class: Ribose::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ribose/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



5
6
7
# File 'lib/ribose/client.rb', line 5

def initialize(options = {})
  initialize_client_details(options)
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



3
4
5
# File 'lib/ribose/client.rb', line 3

def access_token
  @access_token
end

#api_emailObject

Returns the value of attribute api_email.



3
4
5
# File 'lib/ribose/client.rb', line 3

def api_email
  @api_email
end

#api_tokenObject

Returns the value of attribute api_token.



3
4
5
# File 'lib/ribose/client.rb', line 3

def api_token
  @api_token
end

#client_idObject

Returns the value of attribute client_id.



3
4
5
# File 'lib/ribose/client.rb', line 3

def client_id
  @client_id
end

#uidObject

Returns the value of attribute uid.



3
4
5
# File 'lib/ribose/client.rb', line 3

def uid
  @uid
end

Class Method Details

.from_login(email:, password:) ⇒ Ribose::Client

Initiate a ribose client

This interface takes email, password, api_email and api_token Then it will do all the underlying work to find out client id and uid Finally it will return a ribose client.

Parameters:

  • :email (String)

    The email for your Ribose account

  • :password (String)

    The password for your account

  • :api_email (String)

    The email for your API account

  • :api_token (String)

    The authentication token for your API account

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ribose/client.rb', line 21

def self.(email:, password:)
  session = Ribose::Session.create(
    username: email, password: password,
  )

  new(
    api_email: email,
    uid: session.uid,
    client_id: session.client,
    api_token: session["access-token"],
    access_token: session["access-token"],
  )
end