class Yp::Base
Constants
- TYPE
Attributes
params[R]
Public Class Methods
new(signature_key, type: :ecom, **params)
click to toggle source
# File lib/base.rb, line 15 def initialize(signature_key, type: :ecom, **params) @params = transaction_params(params, type) @signature_key = signature_key end
Public Instance Methods
send!() { |parse_and_validate response| ... }
click to toggle source
# File lib/base.rb, line 20 def send! if block_given? RestClient.post(URL, body) do |response| yield(parse_and_validate response) end else parse_and_validate(RestClient.post(URL, body)) end end
Protected Instance Methods
action_params()
click to toggle source
# File lib/base.rb, line 36 def action_params {} end
default_params()
click to toggle source
# File lib/base.rb, line 32 def default_params {} end
Private Instance Methods
body()
click to toggle source
# File lib/base.rb, line 53 def body @params.clone.tap do |params| params[:signature] = create_signing_hash TransactionLogger.log_request(params) end end
create_signing_hash()
click to toggle source
# File lib/base.rb, line 60 def create_signing_hash SigningHashCreator.new(@params, @signature_key).create end
parse_and_validate(response)
click to toggle source
# File lib/base.rb, line 64 def parse_and_validate(response) Response .new(@signature_key, response, TransactionLogger) .parse_and_validate end
transaction_params(params, type)
click to toggle source
# File lib/base.rb, line 42 def transaction_params(params, type) params .merge(default_params) .merge(transaction_type(type)) .merge(action_params) end
transaction_type(type)
click to toggle source
# File lib/base.rb, line 49 def transaction_type(type) { type: TYPE[type] } end