authorizenet 1.9.4 → 1.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/lib/app/helpers/authorize_net_helper.rb +2 -3
  2. data/lib/authorize_net.rb +5 -5
  3. data/lib/authorize_net/addresses/address.rb +15 -19
  4. data/lib/authorize_net/addresses/shipping_address.rb +12 -16
  5. data/lib/authorize_net/aim/response.rb +27 -38
  6. data/lib/authorize_net/aim/transaction.rb +46 -65
  7. data/lib/authorize_net/api/api_transaction.rb +85 -90
  8. data/lib/authorize_net/api/constants.yml +1 -1
  9. data/lib/authorize_net/api/schema.rb +968 -936
  10. data/lib/authorize_net/api/transaction.rb +100 -102
  11. data/lib/authorize_net/arb/fields.rb +21 -21
  12. data/lib/authorize_net/arb/paging.rb +7 -11
  13. data/lib/authorize_net/arb/response.rb +7 -15
  14. data/lib/authorize_net/arb/sorting.rb +6 -10
  15. data/lib/authorize_net/arb/subscription.rb +27 -31
  16. data/lib/authorize_net/arb/subscription_detail.rb +1 -5
  17. data/lib/authorize_net/arb/subscription_list_response.rb +13 -20
  18. data/lib/authorize_net/arb/transaction.rb +50 -56
  19. data/lib/authorize_net/authorize_net.rb +20 -27
  20. data/lib/authorize_net/cim/customer_profile.rb +4 -8
  21. data/lib/authorize_net/cim/payment_profile.rb +10 -12
  22. data/lib/authorize_net/cim/response.rb +19 -24
  23. data/lib/authorize_net/cim/transaction.rb +168 -174
  24. data/lib/authorize_net/customer.rb +11 -14
  25. data/lib/authorize_net/email_receipt.rb +8 -12
  26. data/lib/authorize_net/fields.rb +483 -502
  27. data/lib/authorize_net/key_value_response.rb +54 -62
  28. data/lib/authorize_net/key_value_transaction.rb +87 -97
  29. data/lib/authorize_net/line_item.rb +10 -14
  30. data/lib/authorize_net/order.rb +21 -25
  31. data/lib/authorize_net/payment_methods/credit_card.rb +6 -7
  32. data/lib/authorize_net/payment_methods/echeck.rb +29 -31
  33. data/lib/authorize_net/reporting/batch.rb +4 -7
  34. data/lib/authorize_net/reporting/batch_statistics.rb +2 -6
  35. data/lib/authorize_net/reporting/fds_filter.rb +2 -5
  36. data/lib/authorize_net/reporting/response.rb +54 -60
  37. data/lib/authorize_net/reporting/returned_item.rb +11 -12
  38. data/lib/authorize_net/reporting/transaction.rb +27 -29
  39. data/lib/authorize_net/reporting/transaction_details.rb +3 -6
  40. data/lib/authorize_net/response.rb +6 -10
  41. data/lib/authorize_net/sim/hosted_payment_form.rb +16 -20
  42. data/lib/authorize_net/sim/hosted_receipt_page.rb +18 -23
  43. data/lib/authorize_net/sim/response.rb +24 -33
  44. data/lib/authorize_net/sim/transaction.rb +33 -43
  45. data/lib/authorize_net/transaction.rb +15 -21
  46. data/lib/authorize_net/xml_response.rb +36 -54
  47. data/lib/authorize_net/xml_transaction.rb +115 -134
  48. data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +5 -6
  49. data/lib/generators/authorize_net/sim/sim_generator.rb +6 -7
  50. data/lib/generators/generator_extensions.rb +23 -25
  51. metadata +127 -81
  52. checksums.yaml +0 -7
@@ -1,12 +1,11 @@
1
1
  module AuthorizeNet::Reporting
2
-
3
2
  class ReturnedItem
4
3
  include AuthorizeNet::Model
5
4
 
6
5
  attr_accessor :id, :date_utc, :date_local, :code, :description, :returned_items
7
6
 
8
7
  def date_utc=(time)
9
- if time.kind_of?(DateTime)
8
+ if time.is_a?(DateTime)
10
9
  @date_utc = time
11
10
  else
12
11
  @date_utc = DateTime.parse(time.to_s)
@@ -14,7 +13,7 @@ module AuthorizeNet::Reporting
14
13
  end
15
14
 
16
15
  def date_local=(time)
17
- if time.kind_of?(DateTime)
16
+ if time.is_a?(DateTime)
18
17
  @date_local = time
19
18
  else
20
19
  @date_local = DateTime.parse(time.to_s)
@@ -22,24 +21,24 @@ module AuthorizeNet::Reporting
22
21
  end
23
22
 
24
23
  def add_returned_item(id = nil, date_utc = nil, date_local = nil, code = nil, description = nil)
25
- if id.kind_of?(AuthorizeNet::Reporting::ReturnedItem)
24
+ if id.is_a?(AuthorizeNet::Reporting::ReturnedItem)
26
25
  returned_item = id
27
26
  else
28
- returned_item = AuthorizeNet::Reporting::ReturnedItem.new({:return_item_id => id, :return_item_date_utc => date_utc, :return_item_date_local => date_local, :return_item_code => code, :line_item_description => description})
27
+ returned_item = AuthorizeNet::Reporting::ReturnedItem.new(return_item_id: id, return_item_date_utc: date_utc, return_item_date_local: date_local, return_item_code: code, line_item_description: description)
29
28
  end
30
29
  @returned_items = @returned_items.to_a << returned_item
31
30
  end
32
31
 
33
32
  def to_hash
34
33
  hash = {
35
- :id => @id,
36
- :date_utc => @date_utc,
37
- :date_local => @date_local,
38
- :code => @code,
39
- :description => @description,
40
- :returned_items => handle_multivalue_hashing(@returned_items)
34
+ id: @id,
35
+ date_utc: @date_utc,
36
+ date_local: @date_local,
37
+ code: @code,
38
+ description: @description,
39
+ returned_items: handle_multivalue_hashing(@returned_items)
41
40
  }
42
- hash.delete_if { |k, v| v.nil? }
41
+ hash.delete_if { |_k, v| v.nil? }
43
42
  hash
44
43
  end
45
44
  end
@@ -1,65 +1,64 @@
1
1
  module AuthorizeNet::Reporting
2
-
3
2
  # The Reporting API transaction class.
4
3
  class Transaction < AuthorizeNet::XmlTransaction
5
-
6
4
  include AuthorizeNet::Reporting::Fields
7
-
5
+
8
6
  # The class to wrap our response in.
9
7
  @response_class = AuthorizeNet::Reporting::Response
10
-
8
+
11
9
  # Fields to convert to/from Date.
12
- @@datetime_fields = [:first_settlement_date, :last_settlement_date]
13
-
10
+ @@datetime_fields = %i[first_settlement_date last_settlement_date]
11
+
14
12
  # Constructs a Reporting transaction. You can use the new Reporting transaction object
15
13
  # to issue a request to the payment gateway and parse the response into a new
16
14
  # AuthorizeNet::Reporting::Response object.
17
- #
15
+ #
18
16
  # +api_login_id+:: Your API login ID, as a string.
19
17
  # +api_transaction_key+:: Your API transaction key, as a string.
20
18
  # +options+:: A hash of options. See below for values.
21
- #
19
+ #
22
20
  # Options
23
- # +gateway+:: The gateway to submit the transaction to. Can be a URL string, an AuthorizeNet::Reporting::Transaction::Gateway constant, or one of the convenience symbols :sandbox, :test, :production, or :live (:test is an alias for :sandbox, and :live is an alias for :production).
21
+ # +gateway+:: The gateway to submit the transaction to. Can be a URL string, an AuthorizeNet::Reporting::Transaction::Gateway constant, or one of the convenience symbols :sandbox, :test, :production, or :live (:test is an alias for :sandbox, and :live is an alias for :production).
24
22
  # +verify_ssl+:: A boolean indicating if the SSL certificate of the +gateway+ should be verified. Defaults to true.
25
23
  # +reference_id+:: A string that can be used to identify a particular transaction with its response. Will be echo'd in the response, only if it was provided in the transaction. Defaults to nil.
26
24
  #
27
25
  def initialize(api_login_id, api_transaction_key, options = {})
26
+ ActiveSupport::Deprecation.warn "use AuthorizeNet::API::Transaction"
28
27
  super
29
28
  end
30
-
29
+
31
30
  # Sets up and submits a getSettledBatchListRequest transaction. If this transaction has already been
32
31
  # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
33
32
  # response object will have an array of Batch objects available via its batch_list method if
34
33
  # the request was successful.
35
- #
34
+ #
36
35
  #
37
36
  # +from_date+:: Takes either a DateTime or a String representing a date and time. Only settled batches >= this value will be returned. Defaults to nil (which returns >= 24hrs ago). A to_date must be specified if a from_date is.
38
37
  # +to_date+:: Takes either a DateTime or a String representing a date and time. Only settled batches <= this value will be returned. Defaults to nil. The maximum date range is 31 days, and a from_date must be supplied if a to_date is.
39
38
  # +include_stats+:: Takes a Boolean. Determines if BatchStatistics should be returned with the Batch objects. Defaults to false.
40
39
  #
41
40
  # Typical usage:
42
- #
41
+ #
43
42
  # response = transaction.get_settled_batch_list(DateTime.now() - (1 * 3600 * 48), DateTime.now(), true)
44
43
  # batches = response.batch_list if response.success?
45
44
  #
46
45
  def get_settled_batch_list(from_date = nil, to_date = nil, include_stats = false)
47
46
  @type = Type::REPORT_GET_BATCH_LIST
48
- set_fields({:first_settlement_date => from_date, :last_settlement_date => to_date, :include_statistics => include_stats})
47
+ set_fields(first_settlement_date: from_date, last_settlement_date: to_date, include_statistics: include_stats)
49
48
  make_request
50
49
  end
51
-
50
+
52
51
  # Sets up and submits a getTransactionListRequest transaction. If this transaction has already been
53
52
  # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
54
53
  # response object will have an array of TransactionDetail objects available via its transactions method if
55
54
  # the request was successful. These TransactionDetail objects will not be fully populated. Use get_transaction_details
56
55
  # to get all the details.
57
- #
56
+ #
58
57
  #
59
58
  # +batch_id+:: Takes either a Batch object with its id attribute populated, or a String representing the ID of the batch to retrieve the transaction list from.
60
59
  #
61
60
  # Typical usage:
62
- #
61
+ #
63
62
  # response = transaction.get_transaction_list('123456')
64
63
  # transactions = response.transactions if response.success?
65
64
  #
@@ -68,16 +67,16 @@ module AuthorizeNet::Reporting
68
67
  handle_batch_id(batch_id)
69
68
  make_request
70
69
  end
71
-
70
+
72
71
  # Sets up and submits a getUnsettledTransactionListRequest transaction. If this transaction has already been
73
72
  # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
74
73
  # response object will have an array of TransactionDetail objects available via its transactions method if
75
74
  # the request was successful. These TransactionDetail objects will not be fully populated. Use get_transaction_details
76
75
  # to get all the details.
77
- #
76
+ #
78
77
  #
79
78
  # Typical usage:
80
- #
79
+ #
81
80
  # response = transaction.get_unsettled_transaction_list
82
81
  # transactions = response.transactions if response.success?
83
82
  #
@@ -91,12 +90,12 @@ module AuthorizeNet::Reporting
91
90
  # response object will have a TransactionDetail object available via its transactions method if
92
91
  # the request was successful. This TransactionDetail object will have more data than the limited version
93
92
  # returned by get_transaction_list.
94
- #
93
+ #
95
94
  #
96
95
  # +transaction_id+:: Takes either a TransactionDetail object with its id attribute populated, or a String representing the ID of the transaction to retrieve the details from.
97
96
  #
98
97
  # Typical usage:
99
- #
98
+ #
100
99
  # response = transaction.get_transaction_details('123456789')
101
100
  # transactions = response.transactions if response.success?
102
101
  #
@@ -105,29 +104,28 @@ module AuthorizeNet::Reporting
105
104
  handle_transaction_id(transaction_id)
106
105
  make_request
107
106
  end
108
-
107
+
109
108
  #:enddoc:
110
109
  protected
111
-
110
+
112
111
  # Handles batch id type massaging.
113
112
  def handle_batch_id(id)
114
113
  case id
115
114
  when Batch
116
- set_fields(:batch_id => id.id.to_s)
115
+ set_fields(batch_id: id.id.to_s)
117
116
  else
118
- set_fields(:batch_id => id.to_s)
117
+ set_fields(batch_id: id.to_s)
119
118
  end
120
119
  end
121
-
120
+
122
121
  # Handles transaction id type massaging.
123
122
  def handle_transaction_id(id)
124
123
  case id
125
124
  when TransactionDetails
126
- set_fields(:transaction_id => id.id.to_s)
125
+ set_fields(transaction_id: id.id.to_s)
127
126
  else
128
- set_fields(:transaction_id => id.to_s)
127
+ set_fields(transaction_id: id.to_s)
129
128
  end
130
129
  end
131
130
  end
132
-
133
131
  end
@@ -1,8 +1,6 @@
1
1
  module AuthorizeNet::Reporting
2
-
3
2
  # Models the details of a transaction.
4
3
  class TransactionDetails
5
-
6
4
  include AuthorizeNet::Model
7
5
 
8
6
  attr_accessor :id, :submitted_at, :status, :order, :customer, :account_type,
@@ -12,14 +10,13 @@ module AuthorizeNet::Reporting
12
10
  :fds_filter_action, :fds_filters, :batch, :prepaid_balance_remaining,
13
11
  :payment_method, :recurring_billing, :bill_to, :ship_to, :auth_amount,
14
12
  :subscription_id, :subscription_paynum, :solution_id, :solution_name, :returns
15
-
13
+
16
14
  def submitted_at=(time)
17
- if time.kind_of?(DateTime)
15
+ if time.is_a?(DateTime)
18
16
  @submitted_at = time
19
17
  else
20
18
  @submitted_at = DateTime.parse(time.to_s)
21
19
  end
22
20
  end
23
-
24
21
  end
25
- end
22
+ end
@@ -1,29 +1,25 @@
1
1
  module AuthorizeNet
2
-
3
2
  # The core, API agnostic response class. You shouldn't instantiate
4
3
  # this one. Instead you should use AuthorizeNet::AIM::Response,
5
4
  # AuthorizeNet::ARB::Response or AuthorizeNet::SIM::Response.
6
5
  class Response
7
-
8
6
  include AuthorizeNet::TypeConversions
9
-
7
+
10
8
  # Fields to convert to/from booleans.
11
9
  @@boolean_fields = []
12
10
 
13
11
  # Fields to convert to/from BigDecimal.
14
12
  @@decimal_fields = []
15
-
13
+
16
14
  # DO NOT USE. Instantiate AuthorizeNet::AIM::Response or
17
15
  # AuthorizeNet::SIM::Response instead.
18
- def initialize()
19
- raise "#{self.class.to_s} should not be instantiated directly."
16
+ def initialize
17
+ raise "#{self.class} should not be instantiated directly."
20
18
  end
21
-
19
+
22
20
  # Check to see if the response indicated success.
23
21
  def success?
24
22
  false
25
23
  end
26
-
27
24
  end
28
-
29
- end
25
+ end
@@ -1,38 +1,34 @@
1
1
  module AuthorizeNet::SIM
2
-
3
2
  # Models a hosted payment form.
4
3
  class HostedPaymentForm
5
-
6
4
  include AuthorizeNet::Model
7
-
5
+
8
6
  attr_accessor :header_html, :footer_html, :color_background, :color_link, :color_text, :logo_url, :background_url, :rename
9
-
7
+
10
8
  # Convenience method for adding field rename requests to the transaction. This renames a field shown on
11
9
  # the hosted payment form.
12
10
  def add_rename(field, name)
13
11
  rename = "#{field},#{name}"
14
- unless @rename.nil?
15
- @rename = @rename.to_a << rename
16
- else
12
+ if @rename.nil?
17
13
  @rename = [rename]
14
+ else
15
+ @rename = @rename.to_a << rename
18
16
  end
19
17
  end
20
-
18
+
21
19
  def to_hash
22
20
  hash = {
23
- :header_html_payment_form => @header_html,
24
- :footer_html_payment_form => @footer_html,
25
- :color_background => @color_background,
26
- :color_link => @color_link,
27
- :color_text => @color_text,
28
- :logo_url => @logo_url,
29
- :background_url => @background_url,
30
- :rename => @rename
21
+ header_html_payment_form: @header_html,
22
+ footer_html_payment_form: @footer_html,
23
+ color_background: @color_background,
24
+ color_link: @color_link,
25
+ color_text: @color_text,
26
+ logo_url: @logo_url,
27
+ background_url: @background_url,
28
+ rename: @rename
31
29
  }
32
- hash.delete_if {|k, v| v.nil?}
30
+ hash.delete_if { |_k, v| v.nil? }
33
31
  hash
34
32
  end
35
-
36
33
  end
37
-
38
- end
34
+ end
@@ -1,37 +1,32 @@
1
1
  module AuthorizeNet::SIM
2
-
3
2
  # Models a hosted receipt page.
4
3
  class HostedReceiptPage
5
-
6
4
  # Defines constants for each of the link methods used by the hosted receipt page.
7
5
  module LinkMethod
8
- LINK = 'LINK'
9
- POST = 'POST'
10
- GET = 'GET'
6
+ LINK = 'LINK'.freeze
7
+ POST = 'POST'.freeze
8
+ GET = 'GET'.freeze
11
9
  end
12
-
10
+
13
11
  include AuthorizeNet::Model
14
-
12
+
15
13
  attr_accessor :header_html, :footer_html, :color_background, :color_link, :color_text, :logo_url, :background_url, :link_method, :link_text, :link_url
16
-
17
-
14
+
18
15
  def to_hash
19
16
  hash = {
20
- :header_html_receipt => @header_html,
21
- :footer_html_receipt => @footer_html,
22
- :color_background => @color_background,
23
- :color_link => @color_link,
24
- :color_text => @color_text,
25
- :logo_url => @logo_url,
26
- :background_url => @background_url,
27
- :receipt_link_method => @link_method,
28
- :receipt_link_text => @link_text,
29
- :receipt_link_url => @link_url
17
+ header_html_receipt: @header_html,
18
+ footer_html_receipt: @footer_html,
19
+ color_background: @color_background,
20
+ color_link: @color_link,
21
+ color_text: @color_text,
22
+ logo_url: @logo_url,
23
+ background_url: @background_url,
24
+ receipt_link_method: @link_method,
25
+ receipt_link_text: @link_text,
26
+ receipt_link_url: @link_url
30
27
  }
31
- hash.delete_if {|k, v| v.nil?}
28
+ hash.delete_if { |_k, v| v.nil? }
32
29
  hash
33
30
  end
34
-
35
31
  end
36
-
37
- end
32
+ end
@@ -1,20 +1,18 @@
1
1
  module AuthorizeNet::SIM
2
-
3
2
  # The SIM response class. Handles parsing the response from the gateway. Also
4
3
  # provides a few relay response helpers used to implement Direct Post Method.
5
4
  class Response < AuthorizeNet::KeyValueResponse
6
-
7
5
  # Our MD5 digest generator.
8
6
  @@digest = OpenSSL::Digest.new('md5')
9
7
 
10
8
  include AuthorizeNet::SIM::Fields
11
-
9
+
12
10
  # Constructs a new response object from a +raw_response+. Provides utility methods
13
11
  # for validating the response as authentic, and for handling the Direct Post Method
14
12
  # relay response.
15
- #
13
+ #
16
14
  # +raw_response+:: The raw response, either a string in POST body or GET query string format, or a hash of key/value pairs.
17
- #
15
+ #
18
16
  # Typical usage:
19
17
  # response = AuthorizeNet::SIM::Response("x_first_name=John&x_last_name=Doe")
20
18
  def initialize(raw_response)
@@ -23,30 +21,27 @@ module AuthorizeNet::SIM
23
21
  @fields = {}
24
22
  parse_response(@raw_response)
25
23
  end
26
-
27
-
24
+
28
25
  # Returns True if the MD5 hash found in the response payload validates using
29
26
  # the supplied api_login and secret merchant_value (THIS IS NOT YOUR API KEY).
30
27
  def valid_md5?(api_login, merchant_value)
31
- if @fields[:MD5_Hash].nil?
32
- return false
33
- end
34
- @@digest.hexdigest("#{merchant_value}#{api_login}#{@fields[:trans_id]}#{@fields[:amount]}").downcase == @fields[:MD5_Hash].downcase
28
+ return false if @fields[:MD5_Hash].nil?
29
+ @@digest.hexdigest("#{merchant_value}#{api_login}#{@fields[:trans_id]}#{@fields[:amount]}").casecmp(@fields[:MD5_Hash]).zero?
35
30
  end
36
-
31
+
37
32
  # Returns an HTML string that can be returned to the gateway during the Relay Response,
38
33
  # and will send the user on to URL you specify. Takes a hash of options, currently the
39
34
  # only option is :include, which can be True to include all fields returned in the response
40
35
  # as query string parameters, or it can be an array of fields to include.
41
36
  def direct_post_reply(url, options = {})
42
- url = direct_post_url(url, options[:include]) if options.has_key?(:include)
43
- js_url = url.gsub("'", '\'')
44
- html_url = url.gsub('&', '&amp;').gsub('"', "\"")
37
+ url = direct_post_url(url, options[:include]) if options.key?(:include)
38
+ js_url = url.tr("'", '\'')
39
+ html_url = url.gsub('&', '&amp;').tr('"', "\"")
45
40
  html = <<-HTML
46
41
  <html><head><script type="text/javascript" charset="utf-8">window.location='#{js_url}';</script><noscript><meta http-equiv="refresh" content="1;url=#{html_url}"></noscript></head><body></body></html>
47
42
  HTML
48
43
  end
49
-
44
+
50
45
  # Returns an URL with the fields found in the response and specified in include_fields attached as
51
46
  # part of the URL's query string. If you pass true instead of an array of fields, all fields will be
52
47
  # attached.
@@ -68,48 +63,48 @@ HTML
68
63
  parsed_url = URI.parse(url)
69
64
  if parsed_url.query.nil?
70
65
  parsed_url.query = ''
71
- elsif parsed_url.query.length != 0
66
+ elsif !parsed_url.query.empty?
72
67
  parsed_url.query = parsed_url.query.chomp('&') + '&'
73
68
  end
74
- parsed_url.query += ((fields.select { |k| @fields.has_key?(k) }).collect { |k| self.to_param(k, @fields[k]) }).join('&')
69
+ parsed_url.query += ((fields.select { |k| @fields.key?(k) }).collect { |k| to_param(k, @fields[k]) }).join('&')
75
70
  parsed_url.query.chomp('&')
76
71
  url = parsed_url.to_s
77
72
  end
78
73
  url
79
74
  end
80
-
75
+
81
76
  # Check to see if the response indicated success. Success is defined as a valid MD5 hash
82
77
  # and an response code of AuthorizeNet::Response::ResponseCode::APPROVED.
83
78
  def success?(api_login, merchant_value)
84
79
  valid_md5?(api_login, merchant_value) && approved?
85
80
  end
86
-
81
+
87
82
  # Returns the transaction's authorization code. This should be shown to the
88
83
  # end user.
89
84
  def authorization_code
90
85
  @fields[:auth_code]
91
86
  end
92
-
87
+
93
88
  # Returns the transaction's authorization id. You will need this for future void, refund
94
89
  # and prior authorization capture requests.
95
90
  def transaction_id
96
91
  @fields[:trans_id]
97
92
  end
98
-
93
+
99
94
  # Returns the customer id from the response.
100
95
  def customer_id
101
96
  @fields[:cust_id]
102
97
  end
103
-
98
+
104
99
  # Returns a response code (from AVSResponseCode) indicating the result of any Address Verification
105
- # Service checks.
100
+ # Service checks.
106
101
  def avs_response
107
102
  @fields[:avs_code]
108
103
  end
109
-
104
+
110
105
  #:enddoc:
111
106
  protected
112
-
107
+
113
108
  # Internal helper to parse the raw response object. It handles both raw POST bodies and
114
109
  # hashes.
115
110
  def parse_response(raw_response)
@@ -125,18 +120,14 @@ HTML
125
120
  end
126
121
  when String
127
122
  # convert to hash and re-parse
128
- hash = CGI::parse(raw_response)
123
+ hash = CGI.parse(raw_response)
129
124
  hash.each do |k, v|
130
- if v.kind_of?(Array) && v.length == 1
131
- hash[k] = v[0]
132
- end
125
+ hash[k] = v[0] if v.is_a?(Array) && v.length == 1
133
126
  end
134
127
  parse_response(hash)
135
128
  else
136
129
  parse_response(@raw_response.to_s)
137
130
  end
138
131
  end
139
-
140
132
  end
141
-
142
- end
133
+ end