Class: Worldline::Connect::SDK::CallContext

Inherits:
Object
  • Object
show all
Defined in:
lib/worldline/connect/sdk/call_context.rb

Overview

A CallContext is used to identify requests and manage idempotent requests. A CallContext contains the following:

idempotence_key

A randomly generated key used to identify requests

idempotence_request_timestamp

If a previous request arrived with the same idempotence key, this value will be set to a timestamp of that request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(idempotence_key = nil) ⇒ CallContext

Returns a new instance of CallContext.



20
21
22
# File 'lib/worldline/connect/sdk/call_context.rb', line 20

def initialize(idempotence_key = nil)
  @idempotence_key = idempotence_key
end

Instance Attribute Details

#idempotence_keyString (readonly)

The idempotence key used to identify this request. If two requests share the same idempotence_key, they are considered to be the same request and only the first request will be processed.

Returns:

  • (String)

    the current value of idempotence_key



16
17
18
# File 'lib/worldline/connect/sdk/call_context.rb', line 16

def idempotence_key
  @idempotence_key
end

#idempotence_request_timestampInteger

If two or more requests arrive at the Worldline Global Collect platform with the same idempotence_key, the idempotence_request_timestamp will be set to the arrival time of the first of these requests.

Returns:

  • (Integer)

    the current value of idempotence_request_timestamp



16
17
18
# File 'lib/worldline/connect/sdk/call_context.rb', line 16

def idempotence_request_timestamp
  @idempotence_request_timestamp
end