Skip to content

Commit 2b40234

Browse files
committed
Release 3.2.0
1 parent da150ec commit 2b40234

9 files changed

+75
-5
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ $ gem install wallee-ruby-sdk
2020

2121
## Usage
2222
The library needs to be configured with your account's space id, user id, and secret key which are available in your [wallee
23-
account dashboard](https://app-wallee.com/account/select). Set `space_id`, `user_id`, and `api_secret` to their values:
23+
account dashboard](https://app-wallee.com/account/select). Set `space_id`, `user_id`, and `api_secret` to their values. You can also optionally set `default_headers` to set some headers that will be sent to all requests:
2424

2525
### Configuring a Service
2626

@@ -31,9 +31,11 @@ space_id = 405
3131
app_user_id = 512
3232
app_user_key = "FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ="
3333

34+
# default_headers is an optional param, that represents headers sent to all requests
3435
Wallee.configure do |config|
3536
config.user_id = app_user_id
3637
config.authentication_key = app_user_key
38+
config.default_headers = {"x-meta-custom-header": 'value-1', "x-meta-custom-header-2": 'value-2'}
3739
end
3840

3941
# TransactionService

lib/wallee-ruby-sdk/api_client.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def initialize(config = Configuration.default)
4444
'Content-Type' => "application/json",
4545
'User-Agent' => @user_agent
4646
}
47+
config.default_headers.each do |key, value|
48+
@default_headers[key] = value
49+
end
4750
end
4851

4952
def self.default
@@ -98,7 +101,16 @@ def build_request(http_method, path, opts = {})
98101
url = build_request_url(path)
99102
http_method = http_method.to_sym.downcase
100103

104+
default_headers = {
105+
'x-meta-sdk-version': "3.2.0",
106+
'x-meta-sdk-language': "ruby",
107+
'x-meta-sdk-provider': "wallee",
108+
'x-meta-sdk-language-version': RUBY_VERSION
109+
}
110+
101111
header_params = @default_headers.merge(opts[:header_params] || {})
112+
header_params = header_params.merge(default_headers)
113+
102114
query_params = opts[:query_params] || {}
103115
form_params = opts[:form_params] || {}
104116

lib/wallee-ruby-sdk/configuration.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ class Configuration
9090

9191
attr_accessor :force_ending_format
9292

93-
def initialize
93+
attr_accessor :default_headers
94+
95+
def initialize(default_headers = {})
9496
@scheme = 'https'
9597
@host = 'app-wallee.com:443'
9698
@base_path = '/api'
@@ -102,6 +104,7 @@ def initialize
102104
@inject_format = false
103105
@force_ending_format = false
104106
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
107+
@default_headers = default_headers
105108

106109
yield(self) if block_given?
107110
end

lib/wallee-ruby-sdk/models/transaction_completion.rb

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ class TransactionCompletion
9595
#
9696
attr_accessor :state
9797

98+
# The statement descriptor explain charges or payments on bank statements.
99+
attr_accessor :statement_descriptor
100+
98101
#
99102
attr_accessor :succeeded_on
100103

@@ -138,6 +141,7 @@ def self.attribute_map
138141
:'remaining_line_items' => :'remainingLineItems',
139142
:'space_view_id' => :'spaceViewId',
140143
:'state' => :'state',
144+
:'statement_descriptor' => :'statementDescriptor',
141145
:'succeeded_on' => :'succeededOn',
142146
:'tax_amount' => :'taxAmount',
143147
:'time_zone' => :'timeZone',
@@ -174,6 +178,7 @@ def self.swagger_types
174178
:'remaining_line_items' => :'Array<LineItem>',
175179
:'space_view_id' => :'Integer',
176180
:'state' => :'TransactionCompletionState',
181+
:'statement_descriptor' => :'String',
177182
:'succeeded_on' => :'DateTime',
178183
:'tax_amount' => :'Float',
179184
:'time_zone' => :'String',
@@ -298,6 +303,10 @@ def initialize(attributes = {})
298303
self.state = attributes[:'state']
299304
end
300305

306+
if attributes.has_key?(:'statementDescriptor')
307+
self.statement_descriptor = attributes[:'statementDescriptor']
308+
end
309+
301310
if attributes.has_key?(:'succeededOn')
302311
self.succeeded_on = attributes[:'succeededOn']
303312
end
@@ -335,6 +344,10 @@ def list_invalid_properties
335344
invalid_properties.push('invalid value for "invoice_merchant_reference", the character length must be smaller than or equal to 100.')
336345
end
337346

347+
if !@statement_descriptor.nil? && @statement_descriptor.to_s.length > 22
348+
invalid_properties.push('invalid value for "statement_descriptor", the character length must be smaller than or equal to 22.')
349+
end
350+
338351
invalid_properties
339352
end
340353

@@ -344,6 +357,7 @@ def valid?
344357
return false if !@external_id.nil? && @external_id.to_s.length > 100
345358
return false if !@external_id.nil? && @external_id.to_s.length < 1
346359
return false if !@invoice_merchant_reference.nil? && @invoice_merchant_reference.to_s.length > 100
360+
return false if !@statement_descriptor.nil? && @statement_descriptor.to_s.length > 22
347361
true
348362
end
349363

@@ -371,6 +385,16 @@ def invoice_merchant_reference=(invoice_merchant_reference)
371385
@invoice_merchant_reference = invoice_merchant_reference
372386
end
373387

388+
# Custom attribute writer method with validation
389+
# @param [Object] statement_descriptor Value to be assigned
390+
def statement_descriptor=(statement_descriptor)
391+
if !statement_descriptor.nil? && statement_descriptor.to_s.length > 22
392+
fail ArgumentError, 'invalid value for "statement_descriptor", the character length must be smaller than or equal to 22.'
393+
end
394+
395+
@statement_descriptor = statement_descriptor
396+
end
397+
374398
# Checks equality by comparing each attribute.
375399
# @param [Object] Object to be compared
376400
def ==(o)
@@ -401,6 +425,7 @@ def ==(o)
401425
remaining_line_items == o.remaining_line_items &&
402426
space_view_id == o.space_view_id &&
403427
state == o.state &&
428+
statement_descriptor == o.statement_descriptor &&
404429
succeeded_on == o.succeeded_on &&
405430
tax_amount == o.tax_amount &&
406431
time_zone == o.time_zone &&
@@ -417,7 +442,7 @@ def eql?(o)
417442
# Calculates hash code according to all attributes.
418443
# @return [Fixnum] Hash code
419444
def hash
420-
[id, linked_space_id, linked_transaction, amount, base_line_items, created_by, created_on, external_id, failed_on, failure_reason, invoice_merchant_reference, labels, language, last_completion, line_item_version, line_items, mode, next_update_on, payment_information, planned_purge_date, processing_on, processor_reference, remaining_line_items, space_view_id, state, succeeded_on, tax_amount, time_zone, timeout_on, version].hash
445+
[id, linked_space_id, linked_transaction, amount, base_line_items, created_by, created_on, external_id, failed_on, failure_reason, invoice_merchant_reference, labels, language, last_completion, line_item_version, line_items, mode, next_update_on, payment_information, planned_purge_date, processing_on, processor_reference, remaining_line_items, space_view_id, state, statement_descriptor, succeeded_on, tax_amount, time_zone, timeout_on, version].hash
421446
end
422447

423448
# Builds the object from hash

lib/wallee-ruby-sdk/models/transaction_completion_request.rb

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class TransactionCompletionRequest
3232
# The line items which will be used to complete the transaction.
3333
attr_accessor :line_items
3434

35+
# The statement descriptor explain charges or payments on bank statements.
36+
attr_accessor :statement_descriptor
37+
3538
# The ID of the transaction which should be completed.
3639
attr_accessor :transaction_id
3740

@@ -42,6 +45,7 @@ def self.attribute_map
4245
:'invoice_merchant_reference' => :'invoiceMerchantReference',
4346
:'last_completion' => :'lastCompletion',
4447
:'line_items' => :'lineItems',
48+
:'statement_descriptor' => :'statementDescriptor',
4549
:'transaction_id' => :'transactionId'
4650
}
4751
end
@@ -53,6 +57,7 @@ def self.swagger_types
5357
:'invoice_merchant_reference' => :'String',
5458
:'last_completion' => :'BOOLEAN',
5559
:'line_items' => :'Array<CompletionLineItemCreate>',
60+
:'statement_descriptor' => :'String',
5661
:'transaction_id' => :'Integer'
5762
}
5863
end
@@ -83,6 +88,10 @@ def initialize(attributes = {})
8388
end
8489
end
8590

91+
if attributes.has_key?(:'statementDescriptor')
92+
self.statement_descriptor = attributes[:'statementDescriptor']
93+
end
94+
8695
if attributes.has_key?(:'transactionId')
8796
self.transaction_id = attributes[:'transactionId']
8897
end
@@ -112,6 +121,10 @@ def list_invalid_properties
112121
invalid_properties.push('invalid value for "last_completion", last_completion cannot be nil.')
113122
end
114123

124+
if !@statement_descriptor.nil? && @statement_descriptor.to_s.length > 22
125+
invalid_properties.push('invalid value for "statement_descriptor", the character length must be smaller than or equal to 22.')
126+
end
127+
115128
if @transaction_id.nil?
116129
invalid_properties.push('invalid value for "transaction_id", transaction_id cannot be nil.')
117130
end
@@ -127,6 +140,7 @@ def valid?
127140
return false if @external_id.to_s.length < 1
128141
return false if !@invoice_merchant_reference.nil? && @invoice_merchant_reference.to_s.length > 100
129142
return false if @last_completion.nil?
143+
return false if !@statement_descriptor.nil? && @statement_descriptor.to_s.length > 22
130144
return false if @transaction_id.nil?
131145
true
132146
end
@@ -159,6 +173,16 @@ def invoice_merchant_reference=(invoice_merchant_reference)
159173
@invoice_merchant_reference = invoice_merchant_reference
160174
end
161175

176+
# Custom attribute writer method with validation
177+
# @param [Object] statement_descriptor Value to be assigned
178+
def statement_descriptor=(statement_descriptor)
179+
if !statement_descriptor.nil? && statement_descriptor.to_s.length > 22
180+
fail ArgumentError, 'invalid value for "statement_descriptor", the character length must be smaller than or equal to 22.'
181+
end
182+
183+
@statement_descriptor = statement_descriptor
184+
end
185+
162186
# Checks equality by comparing each attribute.
163187
# @param [Object] Object to be compared
164188
def ==(o)
@@ -168,6 +192,7 @@ def ==(o)
168192
invoice_merchant_reference == o.invoice_merchant_reference &&
169193
last_completion == o.last_completion &&
170194
line_items == o.line_items &&
195+
statement_descriptor == o.statement_descriptor &&
171196
transaction_id == o.transaction_id
172197
end
173198

@@ -180,7 +205,7 @@ def eql?(o)
180205
# Calculates hash code according to all attributes.
181206
# @return [Fixnum] Hash code
182207
def hash
183-
[external_id, invoice_merchant_reference, last_completion, line_items, transaction_id].hash
208+
[external_id, invoice_merchant_reference, last_completion, line_items, statement_descriptor, transaction_id].hash
184209
end
185210

186211
# Builds the object from hash

lib/wallee-ruby-sdk/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
=end
1717

1818
module Wallee
19-
VERSION = '3.1.5'
19+
VERSION = '3.2.0'
2020
end

test/condition_type_service_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def test_condition_type_all
1111
Wallee.configure do |config|
1212
config.user_id = app_user_id
1313
config.authentication_key = app_user_key
14+
config.default_headers = {"x-meta-header-ruby": 'value', "x-meta-header-ruby-2": 'value2'}
1415
end
1516

1617
condition_type_service = Wallee::ConditionTypeService.new

test/transaction_create_service_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def test_create
1212
Wallee.configure do |config|
1313
config.user_id = app_user_id
1414
config.authentication_key = app_user_key
15+
config.default_headers = {"x-meta-header-ruby": 'value', "x-meta-header-ruby-2": 'value2'}
1516
end
1617

1718
transaction_service = Wallee::TransactionService.new

test/transaction_payment_page_service_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def test_payment_page_url
1212
Wallee.configure do |config|
1313
config.user_id = app_user_id
1414
config.authentication_key = app_user_key
15+
config.default_headers = {"x-meta-header-ruby": 'value', "x-meta-header-ruby-2": 'value2'}
1516
end
1617

1718
transaction_service = Wallee::TransactionService.new

0 commit comments

Comments
 (0)