github.com/Ingenico-ePayments/connect-sdk-go@v0.0.0-20240318153750-1f8cd329b9c9/CallContext.go (about)

     1  package connectsdk
     2  
     3  // CallContext can be used to send extra information with a request, and to receive extra information from a response.
     4  // Please note that this type is not thread-safe. Each request should get its own call context instance.
     5  type CallContext struct {
     6  	IdempotenceKey              string
     7  	IdempotenceRequestTimestamp *int64
     8  }
     9  
    10  // GetIdempotenceKey returns the idempotence key
    11  func (c *CallContext) GetIdempotenceKey() string {
    12  	return c.IdempotenceKey
    13  }
    14  
    15  // GetIdempotenceRequestTimestamp returns the idempotence timestamp
    16  func (c *CallContext) GetIdempotenceRequestTimestamp() *int64 {
    17  	if c.IdempotenceRequestTimestamp == nil {
    18  		return nil
    19  	}
    20  
    21  	timestamp := *c.IdempotenceRequestTimestamp
    22  
    23  	return &timestamp
    24  }
    25  
    26  // SetIdempotenceRequestTimestamp sets the idempotence timestamp
    27  func (c *CallContext) SetIdempotenceRequestTimestamp(timestamp *int64) {
    28  	c.IdempotenceRequestTimestamp = timestamp
    29  }
    30  
    31  // NewCallContext creates a CallContext using the given idempotenceKey
    32  func NewCallContext(idempotenceKey string) (*CallContext, error) {
    33  	return &CallContext{idempotenceKey, nil}, nil
    34  }