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(ip_address, options: {}) ⇒ Object
- #collect(order_reference, transaction_id, options: {}) ⇒ Object
- #generate_qr(start_token:, start_secret:, seconds:) ⇒ 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(ip_address, options: {}) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/cgi_party/client.rb', line 30 def authenticate(ip_address, options: {}) CGIParty::AuthenticateRequest.new(@savon_client, ip_address, options: ) .execute end |
#collect(order_reference, transaction_id, options: {}) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/cgi_party/client.rb', line 41 def collect(order_reference, transaction_id, options: {}) CGIParty::CollectRequest.new(@savon_client, order_reference, transaction_id, options: ) .execute end |
#generate_qr(start_token:, start_secret:, seconds:) ⇒ Object
37 38 39 |
# File 'lib/cgi_party/client.rb', line 37 def generate_qr(start_token:, start_secret:, seconds:) RQRCode::QRCode.new(qr_auth_code(start_token, start_secret, seconds)) end |
#poll_collect(order_ref, transaction_id = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# 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
26 27 28 |
# File 'lib/cgi_party/client.rb', line 26 def polling_duration Time.now - @polling_started_at end |