Class: OnlinePayments::SDK::ApiResource

Inherits:
Object
  • Object
show all
Defined in:
lib/onlinepayments/sdk/api_resource.rb

Overview

Base class of all Online Payments platform API resources. Provides shared functionality to facilitate communication with the Online Payments platform.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent: nil, communicator: nil, path_context: nil, client_meta_info: nil) ⇒ ApiResource

Creates a new ApiResource.

Parameters:

  • parent (OnlinePayments::SDK::ApiResource) (defaults to: nil)

    parent resource instance.

  • communicator (OnlinePayments::SDK::Communicator) (defaults to: nil)

    Communicator instance.

  • path_context (Hash) (defaults to: nil)

    hash that contains substitutions for generic locations in the URL path. This hash will be used to instantiate a concrete URL used to access specific resources.

  • client_meta_info (String) (defaults to: nil)

    JSON string containing the metadata for the client.

Raises:

  • (ArgumentError)


19
20
21
22
23
24
25
# File 'lib/onlinepayments/sdk/api_resource.rb', line 19

def initialize(parent: nil, communicator: nil, path_context: nil, client_meta_info: nil)
  raise ArgumentError.new('parent and/or communicator is required') if parent.nil? and communicator.nil?
  @parent = parent
  @communicator = communicator.nil? ? parent.communicator : communicator
  @path_context = path_context
  @client_meta_info = client_meta_info || parent.nil? ? client_meta_info : parent.client_meta_info
end

Instance Attribute Details

#client_meta_infoString (readonly)

JSON string containing client info specific to the current client.

Returns:

  • (String)

    the current value of client_meta_info



10
11
12
# File 'lib/onlinepayments/sdk/api_resource.rb', line 10

def client_meta_info
  @client_meta_info
end

#communicatorOnlinePayments::SDK::Communicator (readonly)

Communicator instance that provides communication with the Online Payments platform.

Returns:



10
11
12
# File 'lib/onlinepayments/sdk/api_resource.rb', line 10

def communicator
  @communicator
end