Class: OnlinePayments::SDK::CallContext

Inherits:
Object
  • Object
show all
Defined in:
lib/onlinepayments/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.

idempotence_response_date_time

If a previous request arrived with the same idempotence key, this value will be set to the date/time of the first response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(idempotence_key = nil) ⇒ CallContext

Returns a new instance of CallContext.



26
27
28
# File 'lib/onlinepayments/sdk/call_context.rb', line 26

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



21
22
23
# File 'lib/onlinepayments/sdk/call_context.rb', line 21

def idempotence_key
  @idempotence_key
end

#idempotence_request_timestampInteger

If two or more requests arrive at the Online Payments 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



21
22
23
# File 'lib/onlinepayments/sdk/call_context.rb', line 21

def idempotence_request_timestamp
  @idempotence_request_timestamp
end

#idempotence_response_date_timeDateTime

If two or more requests arrive at the Online Payments platform with the same idempotence_key, the idempotence_response_date_time will be set to the response date/time of the first response.

Returns:

  • (DateTime)

    the current value of idempotence_response_date_time



21
22
23
# File 'lib/onlinepayments/sdk/call_context.rb', line 21

def idempotence_response_date_time
  @idempotence_response_date_time
end