Class: MstdnIvory::Client

Inherits:
Object
  • Object
show all
Includes:
Api
Defined in:
lib/mstdn_ivory/client.rb

Constant Summary collapse

DEFAULT_TIMEOUT =
{ connect: 2, read: 5, write: 20 }

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Rest

#get, #post

Methods included from Request

#request

Methods included from Register

#create_app, #create_authorization_url, #get_access_token

Constructor Details

#initialize(base_url, token = '', options = {}) ⇒ Client



13
14
15
16
17
# File 'lib/mstdn_ivory/client.rb', line 13

def initialize(base_url, token = '', options = {})
  @base_url = base_url
  @token = token
  @timeout = DEFAULT_TIMEOUT.merge(options[:timeout] || {})
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



8
9
10
# File 'lib/mstdn_ivory/client.rb', line 8

def base_url
  @base_url
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



9
10
11
# File 'lib/mstdn_ivory/client.rb', line 9

def timeout
  @timeout
end

#tokenObject

Returns the value of attribute token.



7
8
9
# File 'lib/mstdn_ivory/client.rb', line 7

def token
  @token
end

Instance Method Details

#headersObject



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

def headers
  {
    accept: '*/*',
    user_agent:'mstdn ivory',
    authorization: "Bearer #{@token}"
  }
end