Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add savon adapter config option #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/gus_bir1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class << self

def_delegators :client, :production, :client_key, :service_status,
:session_status, :status_date_state, :find_by, :find_and_get_full_data,
:get_full_data
def_delegators :client, :production=, :client_key=, :log_level=, :logging=
:get_full_data, :savon_adapter
def_delegators :client, :production=, :client_key=, :log_level=, :logging=, :savon_adapter=

def service_available?
client.service_status.to_i == 1
Expand Down
13 changes: 9 additions & 4 deletions lib/gus_bir1/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module GusBir1
class Client
SESSION_TIMEOUT = 3600
attr_accessor :production, :client_key, :log_level, :logging
attr_accessor :production, :client_key, :log_level, :logging, :savon_adapter

def service_status
v = get_value(Constants::PARAM_PARAM_NAME => Constants::PARAM_SERVICE_STATUS)
Expand Down Expand Up @@ -58,7 +58,7 @@ def get_full_data_from_response(hash)
end

def find_and_get_full_data(hash)
r = find_by(hash)
r = find_by(**hash)
r.map { |h| get_full_data_from_response(h) }
end

Expand All @@ -85,7 +85,7 @@ def endpoint

def method_missing(method, *args)
if savon_client.operations.include? method
response_hash = call(method, args[0]).hash
response_hash = call(method, args[0]).full_hash
response_hash.dig(:envelope, :body, "#{method}_response".to_sym, "#{method}_result".to_sym)
else
super
Expand Down Expand Up @@ -149,14 +149,19 @@ def savon_options(publ: false)
multipart: true,
log_level: @log_level,
log: @logging,
proxy: ENV['GUS_BIR_PROXY_URL']
proxy: ENV['GUS_BIR_PROXY_URL'],
adapter: adapter
}
if defined?(@sid) && @sid.nil? == false
params.merge!({headers: { sid: @sid } })
end
params
end

def adapter
@savon_adapter || :net_http
end

def clear_savon_clients
@savon_client = nil
@savon_client_publ = nil
Expand Down
2 changes: 1 addition & 1 deletion lib/gus_bir1/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module GusBir1
VERSION = '1.1.0'
VERSION = '1.1.1'
end