Skip to content

Commit

Permalink
Merge pull request #246 from Mangopay/feature/configuration_for_UK
Browse files Browse the repository at this point in the history
Add a configuration for UK
  • Loading branch information
iulian03 authored Mar 8, 2024
2 parents 7439e6d + 89766c1 commit d708a3c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion lib/mangopay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Configuration
:client_id, :client_apiKey,
:temp_dir, :log_file, :http_timeout,
:http_max_retries, :http_open_timeout,
:logger, :use_ssl
:logger, :use_ssl, :uk_header_flag

def apply_configuration
MangoPay.configure do |config|
Expand All @@ -70,6 +70,7 @@ def apply_configuration
config.http_open_timeout = @http_open_timeout
config.use_ssl = @use_ssl
config.logger = @logger
config.uk_header_flag = @uk_header_flag
end
end

Expand Down Expand Up @@ -100,6 +101,10 @@ def use_ssl?

true
end

def uk_header_flag
@uk_header_flag || false
end
end

class << self
Expand Down Expand Up @@ -193,6 +198,10 @@ def request(method, url, params={}, filters={}, headers_or_idempotency_key = nil
headers['Idempotency-Key'] = headers_or_idempotency_key if headers_or_idempotency_key != nil
end

if configuration.uk_header_flag
headers['x-tenant-id'] = 'uk'
end

res = Net::HTTP.start(uri.host, uri.port, :use_ssl => configuration.use_ssl?, :read_timeout => configuration.http_timeout,
:max_retries => configuration.http_max_retries,
:open_timeout => configuration.http_open_timeout, ssl_version: :TLSv1_2) do |http|
Expand Down
2 changes: 1 addition & 1 deletion lib/mangopay/authorization_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def get
end

def store(token)
File.open(file_path, File::RDWR|File::CREAT, 0644) do |f|
File.open(file_path, File::RDWR | File::CREAT, 0644) do |f|
f.flock(File::LOCK_EX)
f.truncate(0)
f.rewind
Expand Down

0 comments on commit d708a3c

Please sign in to comment.