class CGIParty::Client
Attributes
collect_responses[R]
polling_started_at[R]
savon_client[R]
Public Class Methods
new()
click to toggle source
# File lib/cgi_party/client.rb, line 8 def initialize @savon_client = Savon.client(savon_opts) end
Public Instance Methods
authenticate(ssn, options: {})
click to toggle source
# File lib/cgi_party/client.rb, line 27 def authenticate(ssn, options: {}) CGIParty::AuthenticateRequest.new(@savon_client, ssn).execute end
collect(order_reference, transaction_id, options: {})
click to toggle source
# File lib/cgi_party/client.rb, line 31 def collect(order_reference, transaction_id, options: {}) CGIParty::CollectRequest.new(@savon_client, order_reference, transaction_id).execute end
poll_collect(order_ref, transaction_id = nil) { |collect_response| ... }
click to toggle source
# File lib/cgi_party/client.rb, line 12 def poll_collect(order_ref, transaction_id = nil) @polling_started_at = Time.now loop do collect_response = collect(order_ref, transaction_id) return collect_response if timeout_polling? yield(collect_response) return collect_response if collect_response.authentication_finished? sleep(CGIParty.config.collect_polling_delay) end end
polling_duration()
click to toggle source
# File lib/cgi_party/client.rb, line 23 def polling_duration Time.now - @polling_started_at end
Private Instance Methods
savon_opts()
click to toggle source
# File lib/cgi_party/client.rb, line 41 def savon_opts { namespace: CGIParty::WSDL_NAMESPACE, namespace_identifier: :v1, wsdl: CGIParty.config.wsdl_path, env_namespace: :soapenv, ssl_verify_mode: :none } end
timeout_polling?()
click to toggle source
# File lib/cgi_party/client.rb, line 37 def timeout_polling? polling_duration >= CGIParty.config.collect_polling_timeout end