pagseguro-oficial 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -5
  3. data/CHANGELOG.md +0 -1
  4. data/README.md +6 -1
  5. data/docs/transparent_checkout.md +201 -0
  6. data/examples/boleto_transaction_request.rb +94 -0
  7. data/examples/create_session.rb +13 -0
  8. data/examples/credit_card_transaction_request.rb +122 -0
  9. data/examples/installment.rb +20 -9
  10. data/examples/online_debit_transaction.rb +98 -0
  11. data/examples/transaction_by_code.rb +62 -0
  12. data/examples/transaction_by_notification_code.rb +55 -51
  13. data/lib/pagseguro.rb +17 -1
  14. data/lib/pagseguro/bank.rb +8 -0
  15. data/lib/pagseguro/boleto_transaction_request.rb +8 -0
  16. data/lib/pagseguro/credit_card_transaction_request.rb +39 -0
  17. data/lib/pagseguro/document.rb +2 -2
  18. data/lib/pagseguro/errors.rb +11 -5
  19. data/lib/pagseguro/holder.rb +28 -0
  20. data/lib/pagseguro/installment.rb +11 -16
  21. data/lib/pagseguro/installment/collection.rb +25 -0
  22. data/lib/pagseguro/installment/request_serializer.rb +24 -0
  23. data/lib/pagseguro/installment/response.rb +29 -4
  24. data/lib/pagseguro/installment/{serializer.rb → response_serializer.rb} +1 -1
  25. data/lib/pagseguro/items.rb +3 -0
  26. data/lib/pagseguro/online_debit_transaction_request.rb +17 -0
  27. data/lib/pagseguro/payment_method.rb +1 -0
  28. data/lib/pagseguro/payment_releases.rb +3 -0
  29. data/lib/pagseguro/sender.rb +4 -0
  30. data/lib/pagseguro/session.rb +34 -0
  31. data/lib/pagseguro/session/response.rb +32 -0
  32. data/lib/pagseguro/session/response_serializer.rb +18 -0
  33. data/lib/pagseguro/transaction.rb +6 -3
  34. data/lib/pagseguro/transaction/response.rb +1 -1
  35. data/lib/pagseguro/transaction_installment.rb +11 -0
  36. data/lib/pagseguro/transaction_request.rb +143 -0
  37. data/lib/pagseguro/transaction_request/request_serializer.rb +148 -0
  38. data/lib/pagseguro/transaction_request/response.rb +32 -0
  39. data/lib/pagseguro/transaction_request/response_serializer.rb +117 -0
  40. data/lib/pagseguro/version.rb +1 -1
  41. data/spec/fixtures/session/success.xml +4 -0
  42. data/spec/fixtures/transaction_request/success.xml +58 -0
  43. data/spec/fixtures/transactions/search.xml +40 -0
  44. data/spec/pagseguro/bank_spec.rb +5 -0
  45. data/spec/pagseguro/boleto_transaction_request_spec.rb +9 -0
  46. data/spec/pagseguro/credit_card_transaction_request_spec.rb +36 -0
  47. data/spec/pagseguro/document_spec.rb +1 -1
  48. data/spec/pagseguro/errors_spec.rb +5 -2
  49. data/spec/pagseguro/features/create_session_spec.rb +52 -0
  50. data/spec/pagseguro/features/create_transaction_request_spec.rb +58 -0
  51. data/spec/pagseguro/holder_spec.rb +9 -0
  52. data/spec/pagseguro/installment/collection_spec.rb +43 -0
  53. data/spec/pagseguro/installment/request_serializer_spec.rb +16 -0
  54. data/spec/pagseguro/installment/{serializer_spec.rb → response_serializer_spec.rb} +1 -1
  55. data/spec/pagseguro/installment/response_spec.rb +52 -0
  56. data/spec/pagseguro/installment_spec.rb +22 -73
  57. data/spec/pagseguro/online_debit_transaction_request_spec.rb +18 -0
  58. data/spec/pagseguro/payment_method_spec.rb +1 -0
  59. data/spec/pagseguro/payment_request/response_spec.rb +0 -11
  60. data/spec/pagseguro/sender_spec.rb +1 -0
  61. data/spec/pagseguro/session/response_serializer_spec.rb +12 -0
  62. data/spec/pagseguro/session/response_spec.rb +52 -0
  63. data/spec/pagseguro/session_spec.rb +41 -0
  64. data/spec/pagseguro/transaction/search/search_abandoned_spec.rb +27 -0
  65. data/spec/pagseguro/transaction/search/search_by_date_spec.rb +26 -0
  66. data/spec/pagseguro/transaction/search/search_by_reference_spec.rb +26 -0
  67. data/spec/pagseguro/transaction/search_spec.rb +131 -0
  68. data/spec/pagseguro/transaction_installment_spec.rb +6 -0
  69. data/spec/pagseguro/transaction_request/request_serializer_spec.rb +213 -0
  70. data/spec/pagseguro/transaction_request/response_serializer_spec.rb +52 -0
  71. data/spec/pagseguro/transaction_request/response_spec.rb +60 -0
  72. data/spec/pagseguro/transaction_request_spec.rb +125 -0
  73. data/spec/support/helpers.rb +14 -0
  74. metadata +79 -6
@@ -2,18 +2,29 @@ require_relative "boot"
2
2
 
3
3
  installments = PagSeguro::Installment.find("100.00")
4
4
 
5
- puts "=> INSTALLMENTS"
6
- puts
7
- installments.each do |installment|
8
- puts installment.inspect
5
+ if installments.errors.any?
6
+ puts "=> ERRORS"
7
+ puts installments.errors.join("\n")
8
+ puts installments.inspect
9
+ else
10
+ puts "=> INSTALLMENTS"
11
+ puts
12
+ installments.each do |installment|
13
+ puts installment.inspect
14
+ end
9
15
  end
10
16
 
11
-
12
17
  visa_installments = PagSeguro::Installment.find("100.00", "visa")
13
18
 
14
19
  puts
15
- puts "=> VISA INSTALLMENTS"
16
- puts
17
- visa_installments.each do |installment|
18
- puts installment.inspect
20
+ if installments.errors.any?
21
+ puts "=> ERRORS"
22
+ puts installments.errors.join("\n")
23
+ puts installments.inspect
24
+ else
25
+ puts "=> VISA INSTALLMENTS"
26
+ puts
27
+ visa_installments.each do |installment|
28
+ puts installment.inspect
29
+ end
19
30
  end
@@ -0,0 +1,98 @@
1
+ require_relative "boot"
2
+
3
+ payment = PagSeguro::OnlineDebitTransactionRequest.new
4
+ payment.notification_url = "http://www.meusite.com.br/notification"
5
+ payment.payment_mode = "gateway"
6
+
7
+ payment.items << {
8
+ id: 1234,
9
+ description: %[Televisão 19" Sony],
10
+ amount: 459.50,
11
+ weight: 0
12
+ }
13
+
14
+ payment.reference = "REF1234-online-debit"
15
+ payment.sender = {
16
+ hash: "7e215170790948f45e26175c2192c77e88c0e4c361a5860b99d2e9a97af982e6",
17
+ name: "Joao Comprador",
18
+ email: "joao@sandbox.pagseguro.com.br",
19
+ cpf: "75073461100",
20
+ phone: {
21
+ area_code: 11,
22
+ number: "12345678"
23
+ }
24
+ }
25
+
26
+ payment.shipping = {
27
+ type_name: "sedex",
28
+ address: {
29
+ street: "Av. Brig. Faria Lima",
30
+ number: "1384",
31
+ complement: "5º andar",
32
+ city: "São Paulo",
33
+ state: "SP",
34
+ district: "Jardim Paulistano",
35
+ postal_code: "01452002"
36
+ }
37
+ }
38
+
39
+ payment.bank = {
40
+ name: "itau"
41
+ }
42
+
43
+
44
+ # Add extras params to request
45
+ # payment.extra_params << { paramName: 'paramValue' }
46
+ # payment.extra_params << { senderBirthDate: '07/05/1981' }
47
+
48
+ puts "=> REQUEST"
49
+ puts PagSeguro::TransactionRequest::RequestSerializer.new(payment).to_params
50
+ puts
51
+
52
+ payment.create
53
+
54
+ if payment.errors.any?
55
+ puts "=> ERRORS"
56
+ puts payment.errors.join("\n")
57
+ else
58
+ puts "=> Transaction"
59
+ puts " code: #{payment.code}"
60
+ puts " reference: #{payment.reference}"
61
+ puts " type: #{payment.type_id}"
62
+ puts " payment link: #{payment.payment_link}"
63
+ puts " status: #{payment.status}"
64
+ puts " payment method type: #{payment.payment_method}"
65
+ puts " created at: #{payment.created_at}"
66
+ puts " updated at: #{payment.updated_at}"
67
+ puts " gross amount: #{payment.gross_amount.to_f}"
68
+ puts " discount amount: #{payment.discount_amount.to_f}"
69
+ puts " net amount: #{payment.net_amount.to_f}"
70
+ puts " extra amount: #{payment.extra_amount.to_f}"
71
+ puts " installment count: #{payment.installment_count}"
72
+
73
+ puts " => Items"
74
+ puts " items count: #{payment.items.size}"
75
+ payment.items.each do |item|
76
+ puts " item id: #{item.id}"
77
+ puts " description: #{item.description}"
78
+ puts " quantity: #{item.quantity}"
79
+ puts " amount: #{item.amount.to_f}"
80
+ end
81
+
82
+ puts " => Sender"
83
+ puts " name: #{payment.sender.name}"
84
+ puts " email: #{payment.sender.email}"
85
+ puts " phone: (#{payment.sender.phone.area_code}) #{payment.sender.phone.number}"
86
+ puts " document: #{payment.sender.document}"
87
+
88
+ puts " => Shipping"
89
+ puts " street: #{payment.shipping.address.street}, #{payment.shipping.address.number}"
90
+ puts " complement: #{payment.shipping.address.complement}"
91
+ puts " postal code: #{payment.shipping.address.postal_code}"
92
+ puts " district: #{payment.shipping.address.district}"
93
+ puts " city: #{payment.shipping.address.city}"
94
+ puts " state: #{payment.shipping.address.state}"
95
+ puts " country: #{payment.shipping.address.country}"
96
+ puts " type: #{payment.shipping.type_name}"
97
+ puts " cost: #{payment.shipping.cost}"
98
+ end
@@ -0,0 +1,62 @@
1
+ require_relative "boot"
2
+
3
+ transaction = PagSeguro::Transaction.find_by_code("E69FCE5813A142C29EB9B9652BCDC1A8")
4
+
5
+ if transaction.errors.any?
6
+ transaction.errors.join("\n")
7
+ else
8
+ puts "=> Transaction"
9
+ puts " code: #{transaction.code}"
10
+ puts " type: #{transaction.type_id}"
11
+ puts " status: #{transaction.status.status}"
12
+ puts " cancellation source: #{transaction.cancellation_source}"
13
+ puts " escrow end date: #{transaction.escrow_end_date}"
14
+ puts " payment method type: #{transaction.payment_method.type}"
15
+ puts " gross amount: #{transaction.gross_amount.to_f}"
16
+ puts " discount amount: #{transaction.discount_amount.to_f}"
17
+ puts " operational fee amount: #{transaction.creditor_fees.operational_fee_amount.to_f}"
18
+ puts " installment fee amount: #{transaction.creditor_fees.installment_fee_amount.to_f}"
19
+ puts " intermediation rate amount: #{transaction.creditor_fees.intermediation_rate_amount.to_f}"
20
+ puts " intermediation fee amount: #{transaction.creditor_fees.intermediation_fee_amount.to_f}"
21
+ puts " commission fee amount: #{transaction.creditor_fees.commission_fee_amount.to_f}"
22
+ puts " efrete: #{transaction.creditor_fees.efrete.to_f}"
23
+ puts " net amount: #{transaction.net_amount.to_f}"
24
+ puts " extra amount: #{transaction.extra_amount.to_f}"
25
+ puts " installment count: #{transaction.installments}"
26
+
27
+ puts " => Payment Release"
28
+ transaction.payment_releases.each do |release|
29
+ puts " current installment: #{release.installment}"
30
+ puts " total amount: #{release.total_amount.to_f}"
31
+ puts " release amount: #{release.release_amount.to_f}"
32
+ puts " status: #{release.status}"
33
+ puts " release date: #{release.release_date}"
34
+ end
35
+
36
+ puts " => Items"
37
+ puts " items count: #{transaction.items.size}"
38
+ transaction.items.each do |item|
39
+ puts " item id: #{item.id}"
40
+ puts " description: #{item.description}"
41
+ puts " quantity: #{item.quantity}"
42
+ puts " amount: #{item.amount.to_f}"
43
+ puts " weight: #{item.weight}g"
44
+ end
45
+
46
+ puts " => Sender"
47
+ puts " name: #{transaction.sender.name}"
48
+ puts " email: #{transaction.sender.email}"
49
+ puts " phone: (#{transaction.sender.phone.area_code}) #{transaction.sender.phone.number}"
50
+ puts " document: #{transaction.sender.document.type}: #{transaction.sender.document.value}"
51
+
52
+ puts " => Shipping"
53
+ puts " street: #{transaction.shipping.address.street}, #{transaction.shipping.address.number}"
54
+ puts " complement: #{transaction.shipping.address.complement}"
55
+ puts " postal code: #{transaction.shipping.address.postal_code}"
56
+ puts " district: #{transaction.shipping.address.district}"
57
+ puts " city: #{transaction.shipping.address.city}"
58
+ puts " state: #{transaction.shipping.address.state}"
59
+ puts " country: #{transaction.shipping.address.country}"
60
+ puts " type: #{transaction.shipping.type_name}"
61
+ puts " cost: #{transaction.shipping.cost}"
62
+ end
@@ -2,58 +2,62 @@ require_relative "boot"
2
2
 
3
3
  transaction = PagSeguro::Transaction.find_by_notification_code("739D69-79C052C05280-55542D9FBB33-4AB2D0")
4
4
 
5
- puts "=> Transaction"
6
- puts " code: #{transaction.code}"
7
- puts " type: #{transaction.type_id}"
8
- puts " status: #{transaction.status.status}"
9
- puts " cancellation source: #{transaction.cancellation_source}"
10
- puts " escrow end date: #{transaction.escrow_end_date}"
11
- puts " payment method type: #{transaction.payment_method.type}"
12
- puts " gross amount: #{transaction.gross_amount.to_f}"
13
- puts " discount amount: #{transaction.discount_amount.to_f}"
14
- puts " operational fee amount: #{transaction.creditor_fees.operational_fee_amount.to_f}"
15
- puts " installment fee amount: #{transaction.creditor_fees.installment_fee_amount.to_f}"
16
- puts " intermediation rate amount: #{transaction.creditor_fees.intermediation_rate_amount.to_f}"
17
- puts " intermediation fee amount: #{transaction.creditor_fees.intermediation_fee_amount.to_f}"
18
- puts " commission fee amount: #{transaction.creditor_fees.commission_fee_amount.to_f}"
19
- puts " commission fee amount: #{transaction.creditor_fees.commission_fee_amount.to_f}"
20
- puts " efrete: #{transaction.creditor_fees.efrete.to_f}"
21
- puts " net amount: #{transaction.net_amount.to_f}"
22
- puts " extra amount: #{transaction.extra_amount.to_f}"
5
+ if transaction.errors.any?
6
+ transaction.errors.join("\n")
7
+ else
8
+ puts "=> Transaction"
9
+ puts " code: #{transaction.code}"
10
+ puts " type: #{transaction.type_id}"
11
+ puts " status: #{transaction.status.status}"
12
+ puts " cancellation source: #{transaction.cancellation_source}"
13
+ puts " escrow end date: #{transaction.escrow_end_date}"
14
+ puts " payment method type: #{transaction.payment_method.type}"
15
+ puts " gross amount: #{transaction.gross_amount.to_f}"
16
+ puts " discount amount: #{transaction.discount_amount.to_f}"
17
+ puts " operational fee amount: #{transaction.creditor_fees.operational_fee_amount.to_f}"
18
+ puts " installment fee amount: #{transaction.creditor_fees.installment_fee_amount.to_f}"
19
+ puts " intermediation rate amount: #{transaction.creditor_fees.intermediation_rate_amount.to_f}"
20
+ puts " intermediation fee amount: #{transaction.creditor_fees.intermediation_fee_amount.to_f}"
21
+ puts " commission fee amount: #{transaction.creditor_fees.commission_fee_amount.to_f}"
22
+ puts " commission fee amount: #{transaction.creditor_fees.commission_fee_amount.to_f}"
23
+ puts " efrete: #{transaction.creditor_fees.efrete.to_f}"
24
+ puts " net amount: #{transaction.net_amount.to_f}"
25
+ puts " extra amount: #{transaction.extra_amount.to_f}"
26
+ puts " installment count: #{transaction.installments}"
23
27
 
24
- puts " => Payments"
25
- puts " installment count: #{transaction.installments}"
26
- transaction.payment_releases.each do |release|
27
- puts " current installment: #{release.installment}"
28
- puts " total amount: #{release.total_amount.to_f}"
29
- puts " release amount: #{release.release_amount.to_f}"
30
- puts " status: #{release.status}"
31
- puts " release date: #{release.release_date}"
32
- end
28
+ puts " => Payment Release"
29
+ transaction.payment_releases.each do |release|
30
+ puts " current installment: #{release.installment}"
31
+ puts " total amount: #{release.total_amount.to_f}"
32
+ puts " release amount: #{release.release_amount.to_f}"
33
+ puts " status: #{release.status}"
34
+ puts " release date: #{release.release_date}"
35
+ end
33
36
 
34
- puts " => Items"
35
- puts " items count: #{transaction.items.size}"
36
- transaction.items.each do |item|
37
- puts " item id: #{item.id}"
38
- puts " description: #{item.description}"
39
- puts " quantity: #{item.quantity}"
40
- puts " amount: #{item.amount.to_f}"
41
- puts " weight: #{item.weight}g"
42
- end
37
+ puts " => Items"
38
+ puts " items count: #{transaction.items.size}"
39
+ transaction.items.each do |item|
40
+ puts " item id: #{item.id}"
41
+ puts " description: #{item.description}"
42
+ puts " quantity: #{item.quantity}"
43
+ puts " amount: #{item.amount.to_f}"
44
+ puts " weight: #{item.weight}g"
45
+ end
43
46
 
44
- puts " => Sender"
45
- puts " name: #{transaction.sender.name}"
46
- puts " email: #{transaction.sender.email}"
47
- puts " phone: (#{transaction.sender.phone.area_code}) #{transaction.sender.phone.number}"
48
- puts " document: #{transaction.sender.document.type}: #{transaction.sender.document.value}"
47
+ puts " => Sender"
48
+ puts " name: #{transaction.sender.name}"
49
+ puts " email: #{transaction.sender.email}"
50
+ puts " phone: (#{transaction.sender.phone.area_code}) #{transaction.sender.phone.number}"
51
+ puts " document: #{transaction.sender.document.type}: #{transaction.sender.document.value}"
49
52
 
50
- puts " => Shipping"
51
- puts " street: #{transaction.shipping.address.street}, #{transaction.shipping.address.number}"
52
- puts " complement: #{transaction.shipping.address.complement}"
53
- puts " postal code: #{transaction.shipping.address.postal_code}"
54
- puts " district: #{transaction.shipping.address.district}"
55
- puts " city: #{transaction.shipping.address.city}"
56
- puts " state: #{transaction.shipping.address.state}"
57
- puts " country: #{transaction.shipping.address.country}"
58
- puts " type: #{transaction.shipping.type_name}"
59
- puts " cost: #{transaction.shipping.cost}"
53
+ puts " => Shipping"
54
+ puts " street: #{transaction.shipping.address.street}, #{transaction.shipping.address.number}"
55
+ puts " complement: #{transaction.shipping.address.complement}"
56
+ puts " postal code: #{transaction.shipping.address.postal_code}"
57
+ puts " district: #{transaction.shipping.address.district}"
58
+ puts " city: #{transaction.shipping.address.city}"
59
+ puts " state: #{transaction.shipping.address.state}"
60
+ puts " country: #{transaction.shipping.address.country}"
61
+ puts " type: #{transaction.shipping.type_name}"
62
+ puts " cost: #{transaction.shipping.cost}"
63
+ end
data/lib/pagseguro.rb CHANGED
@@ -20,10 +20,15 @@ require "pagseguro/document"
20
20
  require "pagseguro/shipping"
21
21
  require "pagseguro/phone"
22
22
  require "pagseguro/installment"
23
+ require "pagseguro/installment/collection"
23
24
  require "pagseguro/installment/response"
24
- require "pagseguro/installment/serializer"
25
+ require "pagseguro/installment/response_serializer"
26
+ require "pagseguro/installment/request_serializer"
25
27
  require "pagseguro/item"
26
28
  require "pagseguro/items"
29
+ require "pagseguro/bank"
30
+ require "pagseguro/holder"
31
+ require "pagseguro/document"
27
32
  require "pagseguro/payment_method"
28
33
  require "pagseguro/payment_release"
29
34
  require "pagseguro/payment_releases"
@@ -33,6 +38,9 @@ require "pagseguro/payment_request/response"
33
38
  require "pagseguro/payment_status"
34
39
  require "pagseguro/request"
35
40
  require "pagseguro/sender"
41
+ require "pagseguro/session"
42
+ require "pagseguro/session/response"
43
+ require "pagseguro/session/response_serializer"
36
44
  require "pagseguro/notification"
37
45
  require "pagseguro/transaction"
38
46
  require "pagseguro/transaction/response"
@@ -41,6 +49,14 @@ require "pagseguro/transaction/search"
41
49
  require "pagseguro/transaction/search/search_by_date"
42
50
  require "pagseguro/transaction/search/search_by_reference"
43
51
  require "pagseguro/transaction/search/search_abandoned"
52
+ require "pagseguro/transaction_installment"
53
+ require "pagseguro/transaction_request"
54
+ require "pagseguro/transaction_request/response"
55
+ require "pagseguro/transaction_request/response_serializer"
56
+ require "pagseguro/transaction_request/request_serializer"
57
+ require "pagseguro/boleto_transaction_request"
58
+ require "pagseguro/online_debit_transaction_request"
59
+ require "pagseguro/credit_card_transaction_request"
44
60
 
45
61
  I18n.load_path += Dir[File.expand_path("../../locales/*.yml", __FILE__)]
46
62
 
@@ -0,0 +1,8 @@
1
+ module PagSeguro
2
+ class Bank
3
+ include Extensions::MassAssignment
4
+
5
+ # Set the bank name.
6
+ attr_accessor :name
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module PagSeguro
2
+ class BoletoTransactionRequest < TransactionRequest
3
+ # Get the payment_method.
4
+ def payment_method
5
+ "boleto"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,39 @@
1
+ module PagSeguro
2
+ class CreditCardTransactionRequest < TransactionRequest
3
+ # Set credit card token.
4
+ # Required for credit card payment method.
5
+ attr_accessor :credit_card_token
6
+
7
+ # Get installment info.
8
+ attr_reader :installment
9
+
10
+ # Get credit card holder info.
11
+ attr_reader :holder
12
+
13
+ # Get billing address info.
14
+ attr_reader :billing_address
15
+
16
+ # Get the payment_method.
17
+ def payment_method
18
+ "credit_card"
19
+ end
20
+
21
+ # Set the installment.
22
+ # Required for credit card payment method.
23
+ def installment=(installment)
24
+ @installment = ensure_type(TransactionInstallment, installment)
25
+ end
26
+
27
+ # Set the credit card holder.
28
+ # Required for credit card payment method.
29
+ def holder=(holder)
30
+ @holder = ensure_type(Holder, holder)
31
+ end
32
+
33
+ # Set the billing address.
34
+ # Required for credit card payment method.
35
+ def billing_address=(address)
36
+ @billing_address = ensure_type(Address, address)
37
+ end
38
+ end
39
+ end
@@ -2,10 +2,10 @@ module PagSeguro
2
2
  class Document
3
3
  include Extensions::MassAssignment
4
4
 
5
- # the type of the document
5
+ # Set the type.
6
6
  attr_accessor :type
7
7
 
8
- # the value of the document
8
+ # Set the value.
9
9
  attr_accessor :value
10
10
  end
11
11
  end
@@ -9,16 +9,22 @@ module PagSeguro
9
9
  @response = response
10
10
  @messages = []
11
11
 
12
- process_response if response
12
+ process(@response) if response
13
+ end
14
+
15
+ # Adds errors.
16
+ # Accepts a response.
17
+ def add(response)
18
+ process(response)
13
19
  end
14
20
 
15
21
  private
16
- def process_response
17
- @messages << error_message(:unauthorized, "Unauthorized") if @response.unauthorized?
22
+ def process(response)
23
+ @messages << error_message(:unauthorized, "Unauthorized") if response.unauthorized?
18
24
 
19
- @response.data.css("errors > error").each do |error|
25
+ response.data.css("errors > error").each do |error|
20
26
  @messages << error_message(error.css("code").text, error.css("message").text)
21
- end if @response.bad_request?
27
+ end if response.bad_request?
22
28
  end
23
29
 
24
30
  def error_message(code, message)