Class: Bluepay::Transaction

Inherits:
Base
  • Object
show all
Includes:
STQ
Defined in:
lib/bluepay/transaction.rb

Constant Summary

Constants included from STQ

STQ::PATH

Constants included from Parameters

Parameters::BOOLEAN_CONVERTER, Parameters::DEFAULT_CONVERTER

Instance Attribute Summary

Attributes inherited from Base

#request, #response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Interface

#data, #path

Methods included from Parameters

#bluepay_params, #converted_params, included, #params

Methods included from TamperProofSeal

#hash, #tps

Constructor Details

#initialize(params = {}) ⇒ Transaction

Returns a new instance of Transaction.



13
14
15
# File 'lib/bluepay/transaction.rb', line 13

def initialize(params={})
  super(params)
end

Class Method Details

.query!(params = {}) ⇒ Object



9
10
11
# File 'lib/bluepay/transaction.rb', line 9

def self.query!(params = {})
  new(params).retrieve!
end

.retrieve!(id, params = {}) ⇒ Object



5
6
7
# File 'lib/bluepay/transaction.rb', line 5

def self.retrieve!(id, params = {})
  new(params.merge(id: id)).retrieve!
end

Instance Method Details

#request_paramsObject



21
22
23
24
25
26
27
# File 'lib/bluepay/transaction.rb', line 21

def request_params
  bluepay_params.
    merge(tps(
      :report_start_date,
      :report_end_date
    ))
end

#retrieve!Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bluepay/transaction.rb', line 29

def retrieve!
  @request = Request.new(self)
  @response = request.execute!

  _data = response.data
  (class << self; self; end).class_eval do
    _data.each { |k, v| define_method(k) { v } }
  end

  self
end

#to_hObject



41
42
43
# File 'lib/bluepay/transaction.rb', line 41

def to_h
  response.data
end