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(arg, path_context = nil, client_meta_info = false) ⇒ ApiResource

Creates a new ApiResource.

Parameters:

  • arg (OnlinePayments::SDK::ApiResource, OnlinePayments::SDK::Communicator)

    parent class or Communicator instance. If a parent class is given its communicator will be used for communication.

  • path_context (Hash, nil) (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. For example in the URL payment.preprod.online-payments.com/{version}/{merchantId}/payments {version} and {merchantId} can be instantiated using the hash {‘version’ => ‘v2’, ‘merchantId’ => ‘1’}. The final URL in this case will be payment.preprod.online-payments.com/v2/1/payments.

  • client_meta_info (String, nil) (defaults to: false)

    JSON string containing the meta data for the client.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/onlinepayments/sdk/api_resource.rb', line 23

def initialize(arg, path_context = nil, client_meta_info = false)
  if client_meta_info == false
    raise ArgumentError, 'parent is required' unless arg

    @parent = arg
    @communicator = arg.communicator
    @client_meta_info = arg.client_meta_info
  else
    raise ArgumentError, 'communicator is required' unless arg

    @parent = nil
    @communicator = arg
    @client_meta_info = client_meta_info
  end
  @path_context = path_context
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