Class: CGIParty::Client
- Inherits:
-
Object
- Object
- CGIParty::Client
- Defined in:
- lib/cgi_party/client.rb
Instance Attribute Summary collapse
-
#collect_responses ⇒ Object
readonly
Returns the value of attribute collect_responses.
-
#polling_started_at ⇒ Object
readonly
Returns the value of attribute polling_started_at.
-
#savon_client ⇒ Object
readonly
Returns the value of attribute savon_client.
Instance Method Summary collapse
- #authenticate(ssn, options: {}) ⇒ Object
- #collect(order_reference, transaction_id, options: {}) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #poll_collect(order_ref, transaction_id = nil) ⇒ Object
- #polling_duration ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
8 9 10 |
# File 'lib/cgi_party/client.rb', line 8 def initialize @savon_client = Savon.client(savon_opts) end |
Instance Attribute Details
#collect_responses ⇒ Object (readonly)
Returns the value of attribute collect_responses.
6 7 8 |
# File 'lib/cgi_party/client.rb', line 6 def collect_responses @collect_responses end |
#polling_started_at ⇒ Object (readonly)
Returns the value of attribute polling_started_at.
6 7 8 |
# File 'lib/cgi_party/client.rb', line 6 def polling_started_at @polling_started_at end |
#savon_client ⇒ Object (readonly)
Returns the value of attribute savon_client.
6 7 8 |
# File 'lib/cgi_party/client.rb', line 6 def savon_client @savon_client end |
Instance Method Details
#authenticate(ssn, options: {}) ⇒ Object
27 28 29 |
# 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: {}) ⇒ Object
31 32 33 |
# 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) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# 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 ⇒ Object
23 24 25 |
# File 'lib/cgi_party/client.rb', line 23 def polling_duration Time.now - @polling_started_at end |