Class: FioAPI::Payment
- Inherits:
-
Object
- Object
- FioAPI::Payment
- Defined in:
- lib/base/payment.rb
Overview
Base class for submit payments and waiting for authorization
Instance Attribute Summary collapse
-
#payments ⇒ Object
Returns the value of attribute payments.
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #import ⇒ Object
-
#initialize(payments) ⇒ Payment
constructor
A new instance of Payment.
- #path ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(payments) ⇒ Payment
Returns a new instance of Payment.
6 7 8 |
# File 'lib/base/payment.rb', line 6 def initialize(payments) @payments = [payments].flatten end |
Instance Attribute Details
#payments ⇒ Object
Returns the value of attribute payments.
4 5 6 |
# File 'lib/base/payment.rb', line 4 def payments @payments end |
#request ⇒ Object
Returns the value of attribute request.
4 5 6 |
# File 'lib/base/payment.rb', line 4 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/base/payment.rb', line 4 def response @response end |
Instance Method Details
#import ⇒ Object
14 15 16 17 18 |
# File 'lib/base/payment.rb', line 14 def import self.request ||= FioAPI::Request.post(path, headers: headers, body: { 'file' => file }, parser: FioAPI::ImportResponseDeserializer) self.response ||= self.request.parsed_response self.request end |
#path ⇒ Object
10 11 12 |
# File 'lib/base/payment.rb', line 10 def path "/import/?token=#{FioAPI.token}&type=xml" end |
#success? ⇒ Boolean
20 21 22 |
# File 'lib/base/payment.rb', line 20 def success? response.status.error_code.zero? end |