Class: Myra::Request
- Inherits:
-
Object
- Object
- Myra::Request
- Defined in:
- lib/myra/request.rb,
lib/myra/request/http.rb,
lib/myra/request/signature.rb
Defined Under Namespace
Constant Summary collapse
- ALLOWED_TYPES =
[ :get, :post, :put, :options, :head, :delete ].freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
readonly
Returns the value of attribute api_secret.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #content_type ⇒ Object
- #do ⇒ Object
-
#initialize(path:, type: :get) ⇒ Request
constructor
A new instance of Request.
- #signing_string ⇒ Object
- #uri ⇒ Object
- #with_payload? ⇒ Boolean
Constructor Details
#initialize(path:, type: :get) ⇒ Request
Returns a new instance of Request.
21 22 23 24 25 26 27 |
# File 'lib/myra/request.rb', line 21 def initialize(path:, type: :get) @date = DateTime.now.to_s @api_key = Myra.configuration.api_key @api_secret = Myra.configuration.api_secret @type = type @path = path end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
9 10 11 |
# File 'lib/myra/request.rb', line 9 def api_key @api_key end |
#api_secret ⇒ Object (readonly)
Returns the value of attribute api_secret.
9 10 11 |
# File 'lib/myra/request.rb', line 9 def api_secret @api_secret end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
9 10 11 |
# File 'lib/myra/request.rb', line 9 def date @date end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/myra/request.rb', line 9 def path @path end |
#payload ⇒ Object
Returns the value of attribute payload.
10 11 12 |
# File 'lib/myra/request.rb', line 10 def payload @payload end |
#type ⇒ Object
Returns the value of attribute type.
10 11 12 |
# File 'lib/myra/request.rb', line 10 def type @type end |
Instance Method Details
#content_type ⇒ Object
48 49 50 |
# File 'lib/myra/request.rb', line 48 def content_type 'application/json' end |
#signing_string ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/myra/request.rb', line 29 def signing_string [ md5.(payload), verb, "#{Myra::PATH}#{path}", content_type, date ].join '#' end |
#uri ⇒ Object
52 53 54 |
# File 'lib/myra/request.rb', line 52 def uri "#{Myra::BASE_URL}#{Myra::PATH}#{path}" end |
#with_payload? ⇒ Boolean
61 62 63 |
# File 'lib/myra/request.rb', line 61 def with_payload? [:post, :put, :delete].include?(type) end |