Class: BotFramework::ApiBase

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/bot_framework/api_base.rb

Direct Known Subclasses

BotState, Conversation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service_url) ⇒ ApiBase

Returns a new instance of ApiBase.



8
9
10
# File 'lib/bot_framework/api_base.rb', line 8

def initialize(service_url)
  @service_url = service_url
end

Instance Attribute Details

#service_urlObject

Returns the value of attribute service_url.



6
7
8
# File 'lib/bot_framework/api_base.rb', line 6

def service_url
  @service_url
end

Instance Method Details

#api_delete(local_uri) ⇒ Object



23
24
25
26
# File 'lib/bot_framework/api_base.rb', line 23

def api_delete(local_uri)
  uri = URI.join(service_url, URI.escape(local_uri))
  BotFramework.connector.token.delete(uri)
end

#api_get(local_uri, _opts = {}) ⇒ Object



12
13
14
15
# File 'lib/bot_framework/api_base.rb', line 12

def api_get(local_uri, _opts = {})
  uri = URI.join(service_url, URI.escape(local_uri))
  JSON.parse(BotFramework.connector.token.get(uri).body)
end

#api_post(local_uri, opts = {}) ⇒ Object



17
18
19
20
21
# File 'lib/bot_framework/api_base.rb', line 17

def api_post(local_uri, opts = {})
  uri = URI.join(service_url, URI.escape(local_uri))
  JSON.parse(BotFramework.connector.token.post(uri, body: opts.to_json,
                                                    headers: { 'Content-Type' => 'application/json' }).body)
end

#api_request(method, local_uri, opts) ⇒ Object



28
29
30
31
# File 'lib/bot_framework/api_base.rb', line 28

def api_request(method, local_uri, opts)
  uri = URI.join(service_url, URI.escape(local_uri))
  BotFramework.connector.token.request(method, uri, opts)
end