braintree 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/braintree.gemspec +1 -1
- data/lib/braintree.rb +2 -1
- data/lib/braintree/account_updater_daily_report.rb +1 -1
- data/lib/braintree/address.rb +1 -1
- data/lib/braintree/apple_pay.rb +1 -1
- data/lib/braintree/apple_pay_card.rb +1 -1
- data/lib/braintree/apple_pay_options.rb +1 -1
- data/lib/braintree/authorization_adjustment.rb +1 -1
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/configuration.rb +11 -11
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
- data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
- data/lib/braintree/credit_card.rb +2 -2
- data/lib/braintree/credit_card_gateway.rb +3 -3
- data/lib/braintree/credit_card_verification.rb +5 -5
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +2 -2
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/disbursement.rb +1 -1
- data/lib/braintree/dispute.rb +1 -1
- data/lib/braintree/dispute_gateway.rb +2 -2
- data/lib/braintree/dispute_search.rb +2 -2
- data/lib/braintree/document_upload.rb +1 -1
- data/lib/braintree/error_codes.rb +7 -0
- data/lib/braintree/google_pay_card.rb +1 -1
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +7 -7
- data/lib/braintree/http.rb +3 -3
- data/lib/braintree/local_payment_completed.rb +1 -1
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +1 -1
- data/lib/braintree/merchant_account.rb +1 -1
- data/lib/braintree/merchant_account_gateway.rb +1 -1
- data/lib/braintree/merchant_gateway.rb +1 -1
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +1 -1
- data/lib/braintree/oauth_gateway.rb +5 -5
- data/lib/braintree/payment_instrument_type.rb +10 -10
- data/lib/braintree/payment_method_gateway.rb +3 -3
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/samsung_pay_card.rb +1 -1
- data/lib/braintree/settlement_batch_summary.rb +2 -2
- data/lib/braintree/subscription.rb +6 -6
- data/lib/braintree/transaction.rb +32 -24
- data/lib/braintree/transaction_gateway.rb +23 -4
- data/lib/braintree/transaction_line_item.rb +1 -1
- data/lib/braintree/transaction_search.rb +3 -1
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +3 -3
- data/lib/braintree/us_bank_account_verification.rb +1 -1
- data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
- data/lib/braintree/util.rb +4 -4
- data/lib/braintree/venmo_account.rb +1 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +2 -2
- data/lib/braintree/webhook_notification.rb +28 -19
- data/lib/braintree/webhook_notification_gateway.rb +5 -5
- data/lib/braintree/webhook_testing_gateway.rb +10 -0
- data/lib/braintree/xml/generator.rb +5 -4
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +10 -10
- data/spec/integration/braintree/add_on_spec.rb +1 -1
- data/spec/integration/braintree/address_spec.rb +24 -24
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +3 -3
- data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
- data/spec/integration/braintree/client_api/spec_helper.rb +5 -5
- data/spec/integration/braintree/credit_card_spec.rb +119 -119
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
- data/spec/integration/braintree/customer_search_spec.rb +8 -8
- data/spec/integration/braintree/customer_spec.rb +165 -165
- data/spec/integration/braintree/dispute_search_spec.rb +3 -3
- data/spec/integration/braintree/dispute_spec.rb +6 -6
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/http_spec.rb +2 -2
- data/spec/integration/braintree/merchant_account_spec.rb +25 -26
- data/spec/integration/braintree/merchant_spec.rb +12 -12
- data/spec/integration/braintree/oauth_spec.rb +11 -11
- data/spec/integration/braintree/payment_method_nonce_spec.rb +12 -12
- data/spec/integration/braintree/payment_method_spec.rb +165 -165
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +9 -9
- data/spec/integration/braintree/paypal_account_spec.rb +28 -28
- data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +133 -133
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +10 -10
- data/spec/integration/braintree/transaction_search_spec.rb +93 -67
- data/spec/integration/braintree/transaction_spec.rb +498 -344
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +20 -20
- data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +2 -2
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +4 -3
- data/spec/unit/braintree/address_spec.rb +1 -1
- data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +42 -42
- data/spec/unit/braintree/credit_card_spec.rb +7 -7
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +2 -2
- data/spec/unit/braintree/customer_spec.rb +3 -3
- data/spec/unit/braintree/disbursement_spec.rb +7 -7
- data/spec/unit/braintree/dispute_spec.rb +8 -8
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- data/spec/unit/braintree/http_spec.rb +5 -5
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_spec.rb +1 -1
- data/spec/unit/braintree/paypal_account_spec.rb +2 -2
- data/spec/unit/braintree/resource_collection_spec.rb +9 -9
- data/spec/unit/braintree/subscription_search_spec.rb +1 -1
- data/spec/unit/braintree/successful_result_spec.rb +1 -1
- data/spec/unit/braintree/three_d_secure_info_spec.rb +1 -1
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +25 -17
- data/spec/unit/braintree/util_spec.rb +18 -18
- data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
- data/spec/unit/braintree/webhook_notification_spec.rb +72 -56
- data/spec/unit/braintree/xml_spec.rb +31 -31
- metadata +3 -3
- data/lib/braintree/settlement_batch.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 85d22ee560b343f4bbd3f71272f4e9d5cfaa83672ddc36fceb9fc383b25772e3
|
|
4
|
+
data.tar.gz: 8d29ee6fcd9b7f6ccbab6680029b66c70e53867448b369af806feb454cfdb18c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d35fdc8ebf0d555649b08e401b4b16f6ac58ee52ca3fdb6a0ce899b10a4c7b2db94873fdb940649941c105cf9ca44686a415a9760619be4e7f5d7d9b33883e81
|
|
7
|
+
data.tar.gz: 687c698cd56953bc23694112256bfe422b53e0a0f0697e5c6626567933ecaab332a1fc6732f4085747ef68178a1d76d6f76a372ec070feb365c8557db8301f51
|
data/braintree.gemspec
CHANGED
data/lib/braintree.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "base64"
|
|
2
2
|
require "bigdecimal"
|
|
3
3
|
require "cgi"
|
|
4
4
|
require "date"
|
|
@@ -71,6 +71,7 @@ require "braintree/gateway"
|
|
|
71
71
|
require "braintree/graphql_client"
|
|
72
72
|
require "braintree/google_pay_card"
|
|
73
73
|
require "braintree/local_payment_completed"
|
|
74
|
+
require "braintree/local_payment_reversed"
|
|
74
75
|
require "braintree/transaction/local_payment_details"
|
|
75
76
|
require "braintree/merchant"
|
|
76
77
|
require "braintree/merchant_gateway"
|
data/lib/braintree/address.rb
CHANGED
data/lib/braintree/apple_pay.rb
CHANGED
|
@@ -40,12 +40,12 @@ module Braintree
|
|
|
40
40
|
]
|
|
41
41
|
|
|
42
42
|
class << self
|
|
43
|
-
attr_writer
|
|
44
|
-
attr_reader
|
|
43
|
+
attr_writer(*WRITABLE_ATTRIBUTES)
|
|
44
|
+
attr_reader(*NON_REQUIRED_READABLE_ATTRIBUTES)
|
|
45
45
|
end
|
|
46
|
-
attr_reader
|
|
47
|
-
attr_reader
|
|
48
|
-
attr_writer
|
|
46
|
+
attr_reader(*READABLE_ATTRIBUTES)
|
|
47
|
+
attr_reader(*NON_REQUIRED_READABLE_ATTRIBUTES)
|
|
48
|
+
attr_writer(*WRITABLE_ATTRIBUTES)
|
|
49
49
|
|
|
50
50
|
def self.expectant_reader(*attributes) # :nodoc:
|
|
51
51
|
attributes.each do |attribute|
|
|
@@ -56,7 +56,7 @@ module Braintree
|
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
|
-
expectant_reader
|
|
59
|
+
expectant_reader(*READABLE_ATTRIBUTES)
|
|
60
60
|
|
|
61
61
|
# Sets the Braintree environment to use. Valid values are <tt>:sandbox</tt> and <tt>:production</tt>
|
|
62
62
|
def self.environment=(env)
|
|
@@ -86,7 +86,7 @@ module Braintree
|
|
|
86
86
|
:proxy_port => proxy_port,
|
|
87
87
|
:proxy_user => proxy_user,
|
|
88
88
|
:proxy_pass => proxy_pass,
|
|
89
|
-
:ssl_version => ssl_version
|
|
89
|
+
:ssl_version => ssl_version,
|
|
90
90
|
)
|
|
91
91
|
end
|
|
92
92
|
|
|
@@ -205,7 +205,7 @@ module Braintree
|
|
|
205
205
|
def port # :nodoc:
|
|
206
206
|
case @environment
|
|
207
207
|
when :development, :integration
|
|
208
|
-
ENV[
|
|
208
|
+
ENV["GATEWAY_PORT"] || 3000
|
|
209
209
|
when :production, :qa, :sandbox
|
|
210
210
|
443
|
|
211
211
|
end
|
|
@@ -214,7 +214,7 @@ module Braintree
|
|
|
214
214
|
def graphql_port # :nodoc:
|
|
215
215
|
case @environment
|
|
216
216
|
when :development, :integration
|
|
217
|
-
ENV[
|
|
217
|
+
ENV["GRAPHQL_PORT"] || 8080
|
|
218
218
|
when :production, :qa, :sandbox
|
|
219
219
|
443
|
|
220
220
|
end
|
|
@@ -235,7 +235,7 @@ module Braintree
|
|
|
235
235
|
def server # :nodoc:
|
|
236
236
|
case @environment
|
|
237
237
|
when :development, :integration
|
|
238
|
-
ENV[
|
|
238
|
+
ENV["GATEWAY_HOST"] || "localhost"
|
|
239
239
|
when :production
|
|
240
240
|
"#{endpoint}.braintreegateway.com"
|
|
241
241
|
when :qa
|
|
@@ -248,7 +248,7 @@ module Braintree
|
|
|
248
248
|
def graphql_server # :nodoc:
|
|
249
249
|
case @environment
|
|
250
250
|
when :development, :integration
|
|
251
|
-
ENV[
|
|
251
|
+
ENV["GRAPHQL_HOST"] || "graphql.bt.local"
|
|
252
252
|
when :production
|
|
253
253
|
"payments.braintree-api.com"
|
|
254
254
|
when :qa
|
|
@@ -123,7 +123,7 @@ module Braintree
|
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
def _most_recent_verification(attributes)
|
|
126
|
-
verification = (attributes[:verifications] || []).sort_by{ |verification| verification[:created_at] }.reverse.first
|
|
126
|
+
verification = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first
|
|
127
127
|
CreditCardVerification._new(verification) if verification
|
|
128
128
|
end
|
|
129
129
|
|
|
@@ -181,7 +181,7 @@ module Braintree
|
|
|
181
181
|
end
|
|
182
182
|
|
|
183
183
|
def self._new(*args) # :nodoc:
|
|
184
|
-
self.new
|
|
184
|
+
self.new(*args)
|
|
185
185
|
end
|
|
186
186
|
end
|
|
187
187
|
end
|
|
@@ -38,8 +38,8 @@ module Braintree
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def expiring_between(start_date, end_date, options = {})
|
|
41
|
-
formatted_start_date = start_date.strftime(
|
|
42
|
-
formatted_end_date = end_date.strftime(
|
|
41
|
+
formatted_start_date = start_date.strftime("%m%Y")
|
|
42
|
+
formatted_end_date = end_date.strftime("%m%Y")
|
|
43
43
|
response = @config.http.post("#{@config.base_merchant_path}/payment_methods/all/expiring_ids?start=#{formatted_start_date}&end=#{formatted_end_date}")
|
|
44
44
|
ResourceCollection.new(response) { |ids| _fetch_expiring_between(formatted_start_date, formatted_end_date, ids) }
|
|
45
45
|
end
|
|
@@ -145,7 +145,7 @@ module Braintree
|
|
|
145
145
|
def _fetch_expiring_between(formatted_start_date, formatted_end_date, ids) # :nodoc:
|
|
146
146
|
response = @config.http.post(
|
|
147
147
|
"#{@config.base_merchant_path}/payment_methods/all/expiring?start=#{formatted_start_date}&end=#{formatted_end_date}",
|
|
148
|
-
:search => {:ids => ids}
|
|
148
|
+
:search => {:ids => ids},
|
|
149
149
|
)
|
|
150
150
|
attributes = response[:payment_methods]
|
|
151
151
|
Util.extract_attribute_as_array(attributes, :credit_card).map { |attrs| CreditCard._new(@gateway, attrs) }
|
|
@@ -17,10 +17,10 @@ module Braintree
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
module Status
|
|
20
|
-
Failed =
|
|
21
|
-
GatewayRejected =
|
|
22
|
-
ProcessorDeclined =
|
|
23
|
-
Verified =
|
|
20
|
+
Failed = "failed"
|
|
21
|
+
GatewayRejected = "gateway_rejected"
|
|
22
|
+
ProcessorDeclined = "processor_declined"
|
|
23
|
+
Verified = "verified"
|
|
24
24
|
|
|
25
25
|
All = [Failed, GatewayRejected, ProcessorDeclined, Verified]
|
|
26
26
|
end
|
|
@@ -92,7 +92,7 @@ module Braintree
|
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
def self._new(*args) # :nodoc:
|
|
95
|
-
self.new
|
|
95
|
+
self.new(*args)
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
def self.find(*args)
|
data/lib/braintree/customer.rb
CHANGED
|
@@ -42,7 +42,7 @@ module Braintree
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def self.credit!(customer_id, transaction_attributes)
|
|
45
|
-
return_object_or_raise(:transaction){ credit(customer_id, transaction_attributes) }
|
|
45
|
+
return_object_or_raise(:transaction) { credit(customer_id, transaction_attributes) }
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def self.delete(*args)
|
|
@@ -142,7 +142,7 @@ module Braintree
|
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
def self._new(*args) # :nodoc:
|
|
145
|
-
self.new
|
|
145
|
+
self.new(*args)
|
|
146
146
|
end
|
|
147
147
|
|
|
148
148
|
def self._attributes # :nodoc:
|
data/lib/braintree/dispute.rb
CHANGED
|
@@ -25,7 +25,7 @@ module Braintree
|
|
|
25
25
|
raise ArgumentError, "dispute_id cannot be blank" if dispute_id.nil? || dispute_id.to_s.strip == ""
|
|
26
26
|
raise ArgumentError, "document_id_or_request cannot be blank" if document_id_or_request.nil?
|
|
27
27
|
|
|
28
|
-
request = document_id_or_request.is_a?(Hash) ? document_id_or_request : {
|
|
28
|
+
request = document_id_or_request.is_a?(Hash) ? document_id_or_request : {document_id: document_id_or_request}
|
|
29
29
|
|
|
30
30
|
raise ArgumentError, "document_id contains invalid characters" unless request[:document_id].to_s =~ /\A[\w-]+\z/
|
|
31
31
|
raise ArgumentError, "document_id cannot be blank" if request[:document_id].nil? || dispute_id.to_s.strip == ""
|
|
@@ -55,7 +55,7 @@ module Braintree
|
|
|
55
55
|
raise ArgumentError, "dispute_id cannot be blank" if dispute_id.nil? || dispute_id.to_s.strip == ""
|
|
56
56
|
raise ArgumentError, "content_or_request cannot be blank" if content_or_request.nil?
|
|
57
57
|
|
|
58
|
-
request = content_or_request.is_a?(String) ? {
|
|
58
|
+
request = content_or_request.is_a?(String) ? {content: content_or_request} : content_or_request
|
|
59
59
|
|
|
60
60
|
raise ArgumentError, "content cannot be blank" if request[:content].nil? || request[:content].to_s.strip == ""
|
|
61
61
|
raise ArgumentError, "request can only contain the keys [:content, :category, :sequence_number]" if (request.keys - [:category, :content, :sequence_number]).any?
|
|
@@ -5,7 +5,7 @@ module Braintree
|
|
|
5
5
|
:customer_id,
|
|
6
6
|
:id,
|
|
7
7
|
:reference_number,
|
|
8
|
-
:transaction_id
|
|
8
|
+
:transaction_id,
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
multiple_value_field :kind, :allows => Dispute::Kind::All
|
|
@@ -21,7 +21,7 @@ module Braintree
|
|
|
21
21
|
:disbursement_date,
|
|
22
22
|
:effective_date,
|
|
23
23
|
:received_date,
|
|
24
|
-
:reply_by_date
|
|
24
|
+
:reply_by_date,
|
|
25
25
|
)
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -271,6 +271,7 @@ module Braintree
|
|
|
271
271
|
end
|
|
272
272
|
|
|
273
273
|
module Transaction
|
|
274
|
+
AdjustmentAmountMustBeGreaterThanZero = "95605"
|
|
274
275
|
AmountCannotBeNegative = "81501"
|
|
275
276
|
AmountDoesNotMatch3DSecureAmount = "91585"
|
|
276
277
|
AmountFormatIsInvalid = "81503" # Keep for backwards compatibility
|
|
@@ -322,6 +323,7 @@ module Braintree
|
|
|
322
323
|
MerchantAccountIdDoesNotMatchSubscription = "915180"
|
|
323
324
|
MerchantAccountIdIsInvalid = "91513"
|
|
324
325
|
MerchantAccountIsSuspended = "91514"
|
|
326
|
+
NoNetAmountToPerformAuthAdjustment = "95606"
|
|
325
327
|
OrderIdIsTooLong = "91501"
|
|
326
328
|
PayPalAuthExpired = "91579"
|
|
327
329
|
PayPalNotEnabled = "91576"
|
|
@@ -343,8 +345,11 @@ module Braintree
|
|
|
343
345
|
ProcessorAuthorizationCodeCannotBeSet = "91519"
|
|
344
346
|
ProcessorAuthorizationCodeIsInvalid = "81520"
|
|
345
347
|
ProcessorDoesNotSupportAuths = "915104"
|
|
348
|
+
ProcessorDoesNotSupportAuthAdjustment = "915222"
|
|
346
349
|
ProcessorDoesNotSupportCredits = "91546"
|
|
350
|
+
ProcessorDoesNotSupportIncrementalAuth = "915220"
|
|
347
351
|
ProcessorDoesNotSupportMotoForCardType = "915195"
|
|
352
|
+
ProcessorDoesNotSupportPartialAuthReversal = "915221"
|
|
348
353
|
ProcessorDoesNotSupportPartialSettlement = "915102"
|
|
349
354
|
ProcessorDoesNotSupportUpdatingDescriptor = "915108"
|
|
350
355
|
ProcessorDoesNotSupportUpdatingOrderId = "915107"
|
|
@@ -398,6 +403,8 @@ module Braintree
|
|
|
398
403
|
ThreeDSecureTransactionPaymentMethodDoesntMatchThreeDSecureAuthenticationPaymentMethod = "915197"
|
|
399
404
|
ThreeDSecureXidIsRequired = "915115"
|
|
400
405
|
TooManyLineItems = "915157"
|
|
406
|
+
TransactionIsNotEligibleForAdjustment = "915219"
|
|
407
|
+
TransactionMustBeInStateAuthorized = "915218"
|
|
401
408
|
TransactionSourceIsInvalid = "915133"
|
|
402
409
|
TypeIsInvalid = "91523"
|
|
403
410
|
TypeIsRequired = "91524"
|
|
@@ -4,9 +4,9 @@ module Braintree
|
|
|
4
4
|
def initialize(config)
|
|
5
5
|
@config = config
|
|
6
6
|
@graphql_headers = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
"Accept" => "application/json",
|
|
8
|
+
"Braintree-Version" => @config.graphql_api_version,
|
|
9
|
+
"Content-Type" => "application/json"
|
|
10
10
|
}
|
|
11
11
|
end
|
|
12
12
|
|
|
@@ -14,9 +14,9 @@ module Braintree
|
|
|
14
14
|
graphql_connection = _setup_connection(@config.graphql_server, @config.graphql_port)
|
|
15
15
|
|
|
16
16
|
request = {}
|
|
17
|
-
request[
|
|
18
|
-
request[
|
|
19
|
-
request[
|
|
17
|
+
request["query"] = definition
|
|
18
|
+
request["operationName"] = operationName if operationName
|
|
19
|
+
request["variables"] = variables
|
|
20
20
|
|
|
21
21
|
response = _http_do Net::HTTP::Post, @config.graphql_base_url, request.to_json, nil, graphql_connection, @graphql_headers
|
|
22
22
|
data = _parse_response(response)
|
|
@@ -27,7 +27,7 @@ module Braintree
|
|
|
27
27
|
|
|
28
28
|
def _parse_response(response)
|
|
29
29
|
body = response.body
|
|
30
|
-
body = Zlib::GzipReader.new(StringIO.new(body)).read if response.header[
|
|
30
|
+
body = Zlib::GzipReader.new(StringIO.new(body)).read if response.header["Content-Encoding"] == "gzip"
|
|
31
31
|
JSON.parse(body, :symbolize_names => true)
|
|
32
32
|
end
|
|
33
33
|
end
|