Class: TelegraphApi::Request
- Inherits:
-
Object
- Object
- TelegraphApi::Request
- Defined in:
- lib/telegraph_api_ruby/request.rb
Defined Under Namespace
Classes: ResponseError
Constant Summary collapse
- API_URL =
'https://api.telegra.ph/'.freeze
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#response_schema ⇒ Object
readonly
Returns the value of attribute response_schema.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(path, opts = {}, response_schema = nil) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(path, opts = {}, response_schema = nil) ⇒ Request
Returns a new instance of Request.
16 17 18 19 20 |
# File 'lib/telegraph_api_ruby/request.rb', line 16 def initialize(path, opts = {}, response_schema = nil) @path = path @opts = opts @response_schema = response_schema end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
8 9 10 |
# File 'lib/telegraph_api_ruby/request.rb', line 8 def opts @opts end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/telegraph_api_ruby/request.rb', line 8 def path @path end |
#response_schema ⇒ Object (readonly)
Returns the value of attribute response_schema.
8 9 10 |
# File 'lib/telegraph_api_ruby/request.rb', line 8 def response_schema @response_schema end |
Class Method Details
.call(*args) ⇒ Object
12 13 14 |
# File 'lib/telegraph_api_ruby/request.rb', line 12 def self.call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
22 23 24 25 |
# File 'lib/telegraph_api_ruby/request.rb', line 22 def call result = request(path, opts) response(result.body, response_schema) end |