Class: TwelvedataRuby::Request
- Inherits:
-
Object
- Object
- TwelvedataRuby::Request
- Extended by:
- Forwardable
- Defined in:
- lib/twelvedata_ruby/request.rb
Constant Summary collapse
- DEFAULT_HTTP_VERB =
:get
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Instance Method Summary collapse
- #fetch ⇒ Object
- #full_url ⇒ Object
- #http_verb ⇒ Object
-
#initialize(name, **query_params) ⇒ Request
constructor
A new instance of Request.
- #params ⇒ Object
- #relative_url ⇒ Object
- #to_a ⇒ Object (also: #build)
- #to_h ⇒ Object
Constructor Details
Instance Attribute Details
#endpoint ⇒ Object
Returns the value of attribute endpoint.
10 11 12 |
# File 'lib/twelvedata_ruby/request.rb', line 10 def endpoint @endpoint end |
Instance Method Details
#fetch ⇒ Object
17 18 19 |
# File 'lib/twelvedata_ruby/request.rb', line 17 def fetch Client.instance.fetch(self) end |
#full_url ⇒ Object
33 34 35 |
# File 'lib/twelvedata_ruby/request.rb', line 33 def full_url return_nil_unless_valid { "#{Client.origin[:origin]}/#{relative_url}" } end |
#http_verb ⇒ Object
21 22 23 |
# File 'lib/twelvedata_ruby/request.rb', line 21 def http_verb return_nil_unless_valid { endpoint.definition[:http_verb] || DEFAULT_HTTP_VERB } end |
#params ⇒ Object
25 26 27 |
# File 'lib/twelvedata_ruby/request.rb', line 25 def params {params: endpoint.query_params} end |
#relative_url ⇒ Object
29 30 31 |
# File 'lib/twelvedata_ruby/request.rb', line 29 def relative_url return_nil_unless_valid { name.to_s } end |
#to_a ⇒ Object Also known as: build
41 42 43 |
# File 'lib/twelvedata_ruby/request.rb', line 41 def to_a return_nil_unless_valid { [http_verb, relative_url, params] } end |
#to_h ⇒ Object
37 38 39 |
# File 'lib/twelvedata_ruby/request.rb', line 37 def to_h return_nil_unless_valid { {http_verb: http_verb, relative_url: relative_url}.merge(params: params) } end |