Class: Telegraphist::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/telegraphist/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authentication_token) ⇒ Client



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

def initialize(authentication_token)
  @authentication_token = authentication_token
  @options = {}
end

Instance Attribute Details

#authentication_tokenObject (readonly)

Returns the value of attribute authentication_token.



6
7
8
# File 'lib/telegraphist/client.rb', line 6

def authentication_token
  @authentication_token
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/telegraphist/client.rb', line 6

def options
  @options
end

Instance Method Details

#get(path, payload = {}) ⇒ Object



13
14
15
# File 'lib/telegraphist/client.rb', line 13

def get(path, payload={})
  self.class.get(url(path), options.deep_merge(payload)).parsed_response
end

#post(path, payload = {}) ⇒ Object



17
18
19
# File 'lib/telegraphist/client.rb', line 17

def post(path, payload={})
  self.class.post(url(path), options.deep_merge(payload)).parsed_response
end

#url(path) ⇒ Object



21
22
23
# File 'lib/telegraphist/client.rb', line 21

def url(path)
  ['/', 'bot', authentication_token, '/', path].join
end