Class: Worldline::Acquiring::SDK::JSON::Marshaller

Inherits:
Object
  • Object
show all
Defined in:
lib/worldline/acquiring/sdk/json/marshaller.rb

Overview

Class responsible for marshalling and unmarshalling objects to and from JSON

Direct Known Subclasses

DefaultMarshaller

Instance Method Summary collapse

Instance Method Details

#marshal(request_object) ⇒ String

Marshals request_object to JSON format by calling #to_h on it.

Parameters:

Returns:

  • (String)

    request_object converted to JSON

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/worldline/acquiring/sdk/json/marshaller.rb', line 12

def marshal(request_object)
  raise NotImplementedError
end

#unmarshal(response_json, type) ⇒ Object

Unmarshals a JSON string into an object of type type. The new object is initialized by calling .new_from_hash with contents of the JSON as a Hash object.

Parameters:

  • response_json (String)

    The JSON to unmarshal

  • type (Type)

    The class of the object that will be instantiated using type.new_from_hash

Returns:

  • The JSON unmarshalled to the given type

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/worldline/acquiring/sdk/json/marshaller.rb', line 22

def unmarshal(response_json, type)
  raise NotImplementedError
end