Class: Yp::Base
- Inherits:
-
Object
- Object
- Yp::Base
- Defined in:
- lib/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #body ⇒ Object
- #create_signing_hash ⇒ Object
-
#initialize(signature_key, **params) ⇒ Base
constructor
A new instance of Base.
- #send ⇒ Object
Constructor Details
#initialize(signature_key, **params) ⇒ Base
6 7 8 9 |
# File 'lib/base.rb', line 6 def initialize(signature_key, **params) @params = params.merge default_params @signature_key = signature_key end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/base.rb', line 4 def params @params end |
Class Method Details
.digest(str_params) ⇒ Object
37 38 39 |
# File 'lib/base.rb', line 37 def digest(str_params) Digest::SHA512.hexdigest str_params end |
.parse(response) ⇒ Object
45 46 47 |
# File 'lib/base.rb', line 45 def parse(response) ruby_hash_from_response(CGI::parse(response)) end |
.serialize_params(params) ⇒ Object
41 42 43 |
# File 'lib/base.rb', line 41 def serialize_params(params) uri_string_from_hash(params) end |
Instance Method Details
#body ⇒ Object
11 12 13 |
# File 'lib/base.rb', line 11 def body @params.clone.tap { |params| params[:signature] = create_signing_hash } end |
#create_signing_hash ⇒ Object
15 16 17 |
# File 'lib/base.rb', line 15 def create_signing_hash self.class.digest(self.class.serialize_params(@params) + @signature_key) end |