Class: CuentaDigital::Response
- Inherits:
-
Object
- Object
- CuentaDigital::Response
- Defined in:
- lib/cuenta_digital/response.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#barcode_base_64 ⇒ Object
Returns the value of attribute barcode_base_64.
-
#barcode_image ⇒ Object
Returns the value of attribute barcode_image.
-
#concept ⇒ Object
Returns the value of attribute concept.
-
#country ⇒ Object
Returns the value of attribute country.
-
#curr ⇒ Object
Returns the value of attribute curr.
-
#date ⇒ Object
Returns the value of attribute date.
-
#due_date ⇒ Object
Returns the value of attribute due_date.
-
#email_to ⇒ Object
Returns the value of attribute email_to.
-
#error ⇒ Object
Returns the value of attribute error.
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#invoice_url ⇒ Object
Returns the value of attribute invoice_url.
-
#ipaddress ⇒ Object
Returns the value of attribute ipaddress.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
-
#merchant_reference ⇒ Object
Returns the value of attribute merchant_reference.
-
#payment_code_1 ⇒ Object
Returns the value of attribute payment_code_1.
-
#payment_code_10 ⇒ Object
Returns the value of attribute payment_code_10.
-
#payment_code_2 ⇒ Object
Returns the value of attribute payment_code_2.
-
#payment_code_3 ⇒ Object
Returns the value of attribute payment_code_3.
-
#payment_code_4 ⇒ Object
Returns the value of attribute payment_code_4.
-
#payment_code_5 ⇒ Object
Returns the value of attribute payment_code_5.
-
#payment_code_6 ⇒ Object
Returns the value of attribute payment_code_6.
-
#payment_code_7 ⇒ Object
Returns the value of attribute payment_code_7.
-
#payment_code_8 ⇒ Object
Returns the value of attribute payment_code_8.
-
#payment_code_9 ⇒ Object
Returns the value of attribute payment_code_9.
-
#request ⇒ Object
Returns the value of attribute request.
-
#second_amount ⇒ Object
Returns the value of attribute second_amount.
-
#second_due_date ⇒ Object
Returns the value of attribute second_due_date.
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(params) ⇒ Response
constructor
A new instance of Response.
- #invoice_generated? ⇒ Boolean
Constructor Details
#initialize(params) ⇒ Response
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cuenta_digital/response.rb', line 37 def initialize(params) parser = Nori.new(convert_tags_to: proc { |tag| tag.snakecase.to_sym }) @request = parser.parse(params)[:request] @action = @request[:action].gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr('-', '_').downcase.to_sym @merchant_id = @request[:invoice][:merchantid] @ipaddress = @request[:invoice][:ipaddress] @payment_code_1 = @request[:invoice][:paymentcode1] @payment_code_2 = @request[:invoice][:paymentcode2] @payment_code_3 = @request[:invoice][:paymentcode3] @payment_code_4 = @request[:invoice][:paymentcode4] @payment_code_5 = @request[:invoice][:paymentcode5] @payment_code_6 = @request[:invoice][:paymentcode6] @payment_code_7 = @request[:invoice][:paymentcode7] @payment_code_8 = @request[:invoice][:paymentcode8] @payment_code_9 = @request[:invoice][:paymentcode9] @payment_code_10 = @request[:invoice][:paymentcode10] = @request[:invoice][:barcodeimage] = @request[:invoice][:barcodebase64] @invoice_url = @request[:invoice][:invoiceurl] @site = @request[:invoice][:site] @merchant_reference = @request[:invoice][:merchantreference] @concept = @request[:invoice][:concept] @curr = @request[:invoice][:curr] @amount = @request[:invoice][:amount] @secondamount = @request[:invoice][:secondamount] @date = @request[:invoice][:date] @due_date = Time.parse(@request[:invoice][:duedate]) rescue nil @second_due_date = Time.parse(@request[:invoice][:secondduedate]) rescue nil @email_to = @request[:invoice][:emailto] @country = @request[:invoice][:country] @lang = @request[:invoice][:lang] rescue => e @exception = e @error = params @action = :error unless @action == :invoice_generated end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def action @action end |
#amount ⇒ Object
Returns the value of attribute amount.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def amount @amount end |
#barcode_base_64 ⇒ Object
Returns the value of attribute barcode_base_64.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def end |
#barcode_image ⇒ Object
Returns the value of attribute barcode_image.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def end |
#concept ⇒ Object
Returns the value of attribute concept.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def concept @concept end |
#country ⇒ Object
Returns the value of attribute country.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def country @country end |
#curr ⇒ Object
Returns the value of attribute curr.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def curr @curr end |
#date ⇒ Object
Returns the value of attribute date.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def date @date end |
#due_date ⇒ Object
Returns the value of attribute due_date.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def due_date @due_date end |
#email_to ⇒ Object
Returns the value of attribute email_to.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def email_to @email_to end |
#error ⇒ Object
Returns the value of attribute error.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def error @error end |
#exception ⇒ Object
Returns the value of attribute exception.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def exception @exception end |
#invoice_url ⇒ Object
Returns the value of attribute invoice_url.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def invoice_url @invoice_url end |
#ipaddress ⇒ Object
Returns the value of attribute ipaddress.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def ipaddress @ipaddress end |
#lang ⇒ Object
Returns the value of attribute lang.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def lang @lang end |
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def merchant_id @merchant_id end |
#merchant_reference ⇒ Object
Returns the value of attribute merchant_reference.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def merchant_reference @merchant_reference end |
#payment_code_1 ⇒ Object
Returns the value of attribute payment_code_1.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def payment_code_1 @payment_code_1 end |
#payment_code_10 ⇒ Object
Returns the value of attribute payment_code_10.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def payment_code_10 @payment_code_10 end |
#payment_code_2 ⇒ Object
Returns the value of attribute payment_code_2.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def payment_code_2 @payment_code_2 end |
#payment_code_3 ⇒ Object
Returns the value of attribute payment_code_3.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def payment_code_3 @payment_code_3 end |
#payment_code_4 ⇒ Object
Returns the value of attribute payment_code_4.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def payment_code_4 @payment_code_4 end |
#payment_code_5 ⇒ Object
Returns the value of attribute payment_code_5.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def payment_code_5 @payment_code_5 end |
#payment_code_6 ⇒ Object
Returns the value of attribute payment_code_6.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def payment_code_6 @payment_code_6 end |
#payment_code_7 ⇒ Object
Returns the value of attribute payment_code_7.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def payment_code_7 @payment_code_7 end |
#payment_code_8 ⇒ Object
Returns the value of attribute payment_code_8.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def payment_code_8 @payment_code_8 end |
#payment_code_9 ⇒ Object
Returns the value of attribute payment_code_9.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def payment_code_9 @payment_code_9 end |
#request ⇒ Object
Returns the value of attribute request.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def request @request end |
#second_amount ⇒ Object
Returns the value of attribute second_amount.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def second_amount @second_amount end |
#second_due_date ⇒ Object
Returns the value of attribute second_due_date.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def second_due_date @second_due_date end |
#site ⇒ Object
Returns the value of attribute site.
5 6 7 |
# File 'lib/cuenta_digital/response.rb', line 5 def site @site end |
Instance Method Details
#error? ⇒ Boolean
78 79 80 |
# File 'lib/cuenta_digital/response.rb', line 78 def error? @action == :error end |
#invoice_generated? ⇒ Boolean
74 75 76 |
# File 'lib/cuenta_digital/response.rb', line 74 def invoice_generated? @action == :invoice_generated end |