Class: CuentaDigital::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/cuenta_digital/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Response

Returns a new instance of 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]
  @barcode_image = @request[:invoice][:barcodeimage]
  @barcode_base_64 = @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

#actionObject

Returns the value of attribute action.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def action
  @action
end

#amountObject

Returns the value of attribute amount.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def amount
  @amount
end

#barcode_base_64Object

Returns the value of attribute barcode_base_64.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def barcode_base_64
  @barcode_base_64
end

#barcode_imageObject

Returns the value of attribute barcode_image.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def barcode_image
  @barcode_image
end

#conceptObject

Returns the value of attribute concept.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def concept
  @concept
end

#countryObject

Returns the value of attribute country.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def country
  @country
end

#currObject

Returns the value of attribute curr.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def curr
  @curr
end

#dateObject

Returns the value of attribute date.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def date
  @date
end

#due_dateObject

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_toObject

Returns the value of attribute email_to.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def email_to
  @email_to
end

#errorObject

Returns the value of attribute error.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def error
  @error
end

#exceptionObject

Returns the value of attribute exception.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def exception
  @exception
end

#invoice_urlObject

Returns the value of attribute invoice_url.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def invoice_url
  @invoice_url
end

#ipaddressObject

Returns the value of attribute ipaddress.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def ipaddress
  @ipaddress
end

#langObject

Returns the value of attribute lang.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def lang
  @lang
end

#merchant_idObject

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_referenceObject

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_1Object

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_10Object

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_2Object

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_3Object

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_4Object

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_5Object

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_6Object

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_7Object

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_8Object

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_9Object

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

#requestObject

Returns the value of attribute request.



5
6
7
# File 'lib/cuenta_digital/response.rb', line 5

def request
  @request
end

#second_amountObject

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_dateObject

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

#siteObject

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

Returns:

  • (Boolean)


78
79
80
# File 'lib/cuenta_digital/response.rb', line 78

def error?
  @action == :error
end

#invoice_generated?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/cuenta_digital/response.rb', line 74

def invoice_generated?
  @action == :invoice_generated
end