Class: Docdata::Refund
- Inherits:
-
Object
- Object
- Docdata::Refund
- Defined in:
- lib/docdata/refund.rb
Constant Summary collapse
- @@amount =
"?"
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#description ⇒ Object
Returns the value of attribute description.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#payment ⇒ Object
Returns the value of attribute payment.
Instance Method Summary collapse
-
#initialize(args = nil) ⇒ Refund
constructor
Initializer to transform a +Hash+ into an Refund object.
-
#perform_refund ⇒ Object
This calls the 'refund' method of the SOAP API It refunds (part of) the payment and returns a Docdata::Response object.
-
#refund_xml ⇒ String
The xml to send in the SOAP API.
-
#valid? ⇒ Boolean
True/false, depending if this instanciated object is valid.
Constructor Details
#initialize(args = nil) ⇒ Refund
Initializer to transform a +Hash+ into an Refund object
38 39 40 41 42 43 44 |
# File 'lib/docdata/refund.rb', line 38 def initialize(args=nil) @line_items = [] return if args.nil? args.each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
28 29 30 |
# File 'lib/docdata/refund.rb', line 28 def amount @amount end |
#currency ⇒ Object
Returns the value of attribute currency.
29 30 31 |
# File 'lib/docdata/refund.rb', line 29 def currency @currency end |
#description ⇒ Object
Returns the value of attribute description.
31 32 33 |
# File 'lib/docdata/refund.rb', line 31 def description @description end |
#errors ⇒ Object
Returns the value of attribute errors.
27 28 29 |
# File 'lib/docdata/refund.rb', line 27 def errors @errors end |
#payment ⇒ Object
Returns the value of attribute payment.
30 31 32 |
# File 'lib/docdata/refund.rb', line 30 def payment @payment end |
Instance Method Details
#perform_refund ⇒ Object
This calls the 'refund' method of the SOAP API It refunds (part of) the payment and returns a Docdata::Response object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/docdata/refund.rb', line 55 def perform_refund # make the SOAP API call response = Docdata.client.call(:refund, xml: refund_xml) response_object = Docdata::Response.parse(:refund, response) if response_object.success? return true else return false end end |
#refund_xml ⇒ String
Returns the xml to send in the SOAP API.
67 68 69 70 71 72 |
# File 'lib/docdata/refund.rb', line 67 def refund_xml xml_file = "#{File.dirname(__FILE__)}/xml/refund.xml.erb" template = File.read(xml_file) namespace = OpenStruct.new(refund: self, payment: self.payment) xml = ERB.new(template).result(namespace.instance_eval { binding }) end |
#valid? ⇒ Boolean
Returns true/false, depending if this instanciated object is valid.
47 48 49 50 |
# File 'lib/docdata/refund.rb', line 47 def valid? validator = RefundValidator.new validator.valid?(self) end |