Class: Ingenico::Connect::SDK::Client

Inherits:
ApiResource show all
Includes:
Logging::LoggingCapable, Logging::Obfuscation::ObfuscationCapable
Defined in:
lib/ingenico/connect/sdk/client.rb

Overview

Ingenico ePayments platform client.

This client and all its child clients are bound to one specific value for the X-GCS-ClientMetaInfo header.

To get a new client with a different header value, use with_client_meta_info.

Thread safe.

Instance Attribute Summary

Attributes inherited from ApiResource

#client_meta_info, #communicator

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(communicator, client_meta_info = nil) ⇒ Client

Returns a new instance of Client.

Parameters:



34
35
36
# File 'lib/ingenico/connect/sdk/client.rb', line 34

def initialize(communicator, client_meta_info=nil)
  super(communicator, nil, client_meta_info)
end

Class Method Details

.API_VERSIONString

Returns:

  • (String)


28
29
30
# File 'lib/ingenico/connect/sdk/client.rb', line 28

def self.API_VERSION
  'v1'
end

Instance Method Details

#closeObject

Releases any system resources associated with this object.



92
93
94
# File 'lib/ingenico/connect/sdk/client.rb', line 92

def close
  @communicator.close
end

#close_expired_connectionsObject

Utility method that delegates the call to this client’s communicator.



64
65
66
# File 'lib/ingenico/connect/sdk/client.rb', line 64

def close_expired_connections
  @communicator.close_expired_connections
end

#close_idle_connections(idle_time) ⇒ Object

Utility method that delegates the call to this client’s communicator.



59
60
61
# File 'lib/ingenico/connect/sdk/client.rb', line 59

def close_idle_connections(idle_time)
  @communicator.close_idle_connections(idle_time)
end

#disable_loggingObject

Turns off logging.



87
88
89
# File 'lib/ingenico/connect/sdk/client.rb', line 87

def disable_logging
  @communicator.disable_logging
end

#enable_logging(communicator_logger) ⇒ Object

Turns on logging using the given communicator logger.

Parameters:



82
83
84
# File 'lib/ingenico/connect/sdk/client.rb', line 82

def enable_logging(communicator_logger)
  @communicator.enable_logging(communicator_logger)
end

#merchant(merchant_id) ⇒ Ingenico::Connect::SDK::Merchant::MerchantClient

Resource /{merchantId}

Parameters:

  • merchant_id (String)

Returns:



99
100
101
102
103
# File 'lib/ingenico/connect/sdk/client.rb', line 99

def merchant(merchant_id)
  Ingenico::Connect::SDK::Merchant::MerchantClient.new(self, {
    'merchantId'.freeze => merchant_id,
  })
end

#set_body_obfuscator(body_obfuscator) ⇒ Object

Sets the current body obfuscator to use.



70
71
72
# File 'lib/ingenico/connect/sdk/client.rb', line 70

def set_body_obfuscator(body_obfuscator)
  @communicator.set_body_obfuscator(body_obfuscator)
end

#set_header_obfuscator(header_obfuscator) ⇒ Object

Sets the current header obfuscator to use.



76
77
78
# File 'lib/ingenico/connect/sdk/client.rb', line 76

def set_header_obfuscator(header_obfuscator)
  @communicator.set_header_obfuscator(header_obfuscator)
end

#with_client_meta_info(client_meta_info) ⇒ Ingenico::Connect::SDK::Client

Returns a Client which uses the passed meta data for the X-GCS-ClientMetaInfo header.

Parameters:

  • client_meta_info (String)

    JSON string containing the meta data for the client

Returns:

Raises:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ingenico/connect/sdk/client.rb', line 41

def with_client_meta_info(client_meta_info)
  if @client_meta_info.nil? && client_meta_info.nil?
    self
  elsif client_meta_info.nil?
    return Client.new(@communicator, nil)
  else
    # Checking to see if this is valid JSON (no JSON parse exceptions)
    @communicator.marshaller.unmarshal(client_meta_info, DataObject)
    client_meta_info = Base64.strict_encode64(client_meta_info)
    if @client_meta_info == client_meta_info
      self
    else
      return Client.new(@communicator, client_meta_info)
    end
  end
end