Class: BotFramework::ApiBase
- Inherits:
-
Object
- Object
- BotFramework::ApiBase
- Includes:
- HTTParty
- Defined in:
- lib/bot_framework/api_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#service_url ⇒ Object
Returns the value of attribute service_url.
Instance Method Summary collapse
- #api_delete(local_uri) ⇒ Object
- #api_get(local_uri, _opts = {}) ⇒ Object
- #api_post(local_uri, opts = {}) ⇒ Object
- #api_request(method, local_uri, opts) ⇒ Object
-
#initialize(service_url) ⇒ ApiBase
constructor
A new instance of ApiBase.
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_url ⇒ Object
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 |