Module: Simpal::API::Orders

Defined in:
lib/simpal/api/orders.rb

Overview

Class Method Summary collapse

Class Method Details

.authorize(id, params = {}, headers: {}, client: nil) ⇒ Hash

Authorize the payment for an order.

Parameters:

  • id (String)

    The ID of an existing order.

  • params (Hash) (defaults to: {})

    The parameters for the authorize request.

  • headers (Hash) (defaults to: {})

    The custom headers to add to the request.

  • client (Simpal::Client) (defaults to: nil)

    The API client to make the request with.

Returns:

  • (Hash)

    A Hash representing the order.



56
57
58
59
60
# File 'lib/simpal/api/orders.rb', line 56

def self.authorize(id, params = {}, headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.post("/v2/checkout/orders/#{id}/authorize", params, headers)
  response.body
end

.capture(id, params = {}, headers: {}, client: nil) ⇒ Hash

Capture the payment for an order.

Parameters:

  • id (String)

    The ID of an existing order.

  • params (Hash) (defaults to: {})

    The parameters for the capture request.

  • headers (Hash) (defaults to: {})

    The custom headers to add to the request.

  • client (Simpal::Client) (defaults to: nil)

    The API client to make the request with.

Returns:

  • (Hash)

    A Hash representing the order.



70
71
72
73
74
# File 'lib/simpal/api/orders.rb', line 70

def self.capture(id, params = {}, headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.post("/v2/checkout/orders/#{id}/capture", params, headers)
  response.body
end

.create(params = {}, headers: {}, client: nil) ⇒ Hash

Create an order.

Parameters:

  • params (Hash) (defaults to: {})

    The parameters for the create request.

  • headers (Hash) (defaults to: {})

    The custom headers to add to the request.

  • client (Simpal::Client) (defaults to: nil)

    The API client to make the request with.

Returns:

  • (Hash)

    A Hash representing the order.



15
16
17
18
19
# File 'lib/simpal/api/orders.rb', line 15

def self.create(params = {}, headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.post('/v2/checkout/orders', params, headers)
  response.body
end

.retrieve(id, headers: {}, client: nil) ⇒ Hash

Retrieve an order.

Parameters:

  • id (String)

    The ID of an existing order.

  • headers (Hash) (defaults to: {})

    The custom headers to add to the request.

  • client (Simpal::Client) (defaults to: nil)

    The API client to make the request with.

Returns:

  • (Hash)

    A Hash representing the order.



42
43
44
45
46
# File 'lib/simpal/api/orders.rb', line 42

def self.retrieve(id, headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.get("/v2/checkout/orders/#{id}", headers)
  response.body
end

.update(id, params = [], headers: {}, client: nil) ⇒ Hash

Update an order.

Parameters:

  • id (String)

    The ID of an existing order.

  • params (Array<Hash>) (defaults to: [])

    The collection of patches to apply to the order.

  • headers (Hash) (defaults to: {})

    The custom headers to add to the request.

  • client (Simpal::Client) (defaults to: nil)

    The API client to make the request with.

Returns:

  • (Hash)

    An empty hash.



29
30
31
32
33
# File 'lib/simpal/api/orders.rb', line 29

def self.update(id, params = [], headers: {}, client: nil)
  client = Simpal.client_for(client)
  response = client.connection.patch("/v2/checkout/orders/#{id}", params, headers)
  response.body
end