Class: Yp::Base
- Inherits:
-
Object
- Object
- Yp::Base
- Defined in:
- lib/base.rb
Direct Known Subclasses
Constant Summary collapse
- TYPE =
{ ecom: 1, moto: 2, ca: 9 }.freeze
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, type: :ecom, **params) ⇒ Base
constructor
A new instance of Base.
- #send ⇒ Object
Constructor Details
#initialize(signature_key, type: :ecom, **params) ⇒ Base
Returns a new instance of Base.
11 12 13 14 |
# File 'lib/base.rb', line 11 def initialize(signature_key, type: :ecom, **params) @params = params.merge(default_params).merge(transaction_type(type)) @signature_key = signature_key end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
9 10 11 |
# File 'lib/base.rb', line 9 def params @params end |
Class Method Details
.digest(str_params) ⇒ Object
46 47 48 |
# File 'lib/base.rb', line 46 def digest(str_params) Digest::SHA512.hexdigest str_params end |
.parse(response) ⇒ Object
54 55 56 |
# File 'lib/base.rb', line 54 def parse(response) ruby_hash_from_response(CGI::parse(response)) end |
.serialize_params(params) ⇒ Object
50 51 52 |
# File 'lib/base.rb', line 50 def serialize_params(params) uri_string_from_hash(params) end |
Instance Method Details
#body ⇒ Object
16 17 18 |
# File 'lib/base.rb', line 16 def body @params.clone.tap { |params| params[:signature] = create_signing_hash } end |
#create_signing_hash ⇒ Object
20 21 22 |
# File 'lib/base.rb', line 20 def create_signing_hash self.class.digest(self.class.serialize_params(@params) + @signature_key) end |