Class: CheckoutSdk::AbstractCheckoutSdkBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/checkout_sdk/abstract_checkout_sdk_builder.rb

Direct Known Subclasses

CheckoutOAuthSdkBuilder, StaticKeysBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#environmentEnvironment

Returns:



13
14
15
# File 'lib/checkout_sdk/abstract_checkout_sdk_builder.rb', line 13

def environment
  @environment
end

#environment_subdomainEnvironmentSubdomain?

Returns:



13
# File 'lib/checkout_sdk/abstract_checkout_sdk_builder.rb', line 13

attr_accessor :environment, :http_client, :multipart_http_client, :logger, :environment_subdomain

#http_clientFaraday::Connection

Returns:

  • (Faraday::Connection)


13
# File 'lib/checkout_sdk/abstract_checkout_sdk_builder.rb', line 13

attr_accessor :environment, :http_client, :multipart_http_client, :logger, :environment_subdomain

#loggerObject

Returns the value of attribute logger.



13
14
15
# File 'lib/checkout_sdk/abstract_checkout_sdk_builder.rb', line 13

def logger
  @logger
end

#multipart_http_clientFaraday::Connection

Returns:

  • (Faraday::Connection)


13
# File 'lib/checkout_sdk/abstract_checkout_sdk_builder.rb', line 13

attr_accessor :environment, :http_client, :multipart_http_client, :logger, :environment_subdomain

Instance Method Details

#buildObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/checkout_sdk/abstract_checkout_sdk_builder.rb', line 44

def build
  with_environment(Environment.sandbox) if environment.nil?
  if http_client.nil?
    @http_client = CheckoutUtils.build_default_client
  else
    unless @http_client.instance_of?(Faraday::Connection)
      raise CheckoutArgumentException, 'http_client must be an instance of Faraday::Connection'
    end
  end
  if multipart_http_client.nil?
    @multipart_http_client = CheckoutUtils.build_multipart_client
  else
    unless @multipart_http_client.instance_of?(Faraday::Connection)
      raise CheckoutArgumentException, 'multipart_http_client must be an instance of Faraday::Connection'
    end
  end
  @logger = SimpleLogger.new.logger if @logger.nil?
end

#with_environment(environment) ⇒ Object

Parameters:



16
17
18
19
# File 'lib/checkout_sdk/abstract_checkout_sdk_builder.rb', line 16

def with_environment(environment)
  @environment = environment
  self
end

#with_environment_subdomain(subdomain) ⇒ Object

Parameters:

  • subdomain (String, nil)


39
40
41
42
# File 'lib/checkout_sdk/abstract_checkout_sdk_builder.rb', line 39

def with_environment_subdomain(subdomain)
  @environment_subdomain = EnvironmentSubdomain.new(@environment, subdomain)
  self
end

#with_http_client(http_client) ⇒ Object

Parameters:

  • http_client (Faraday::Connection)


22
23
24
25
# File 'lib/checkout_sdk/abstract_checkout_sdk_builder.rb', line 22

def with_http_client(http_client)
  @http_client = http_client
  self
end

#with_logger(logger) ⇒ Object



33
34
35
36
# File 'lib/checkout_sdk/abstract_checkout_sdk_builder.rb', line 33

def with_logger(logger)
  @logger = logger
  self
end

#with_multipart_http_client(multipart_http_client) ⇒ Object

Parameters:

  • multipart_http_client (Faraday::Connection)


28
29
30
31
# File 'lib/checkout_sdk/abstract_checkout_sdk_builder.rb', line 28

def with_multipart_http_client(multipart_http_client)
  @multipart_http_client = multipart_http_client
  self
end