Class: FulfilApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fulfil_api/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Client

Returns a new instance of Client.

Parameters:



9
10
11
# File 'lib/fulfil_api/client.rb', line 9

def initialize(configuration)
  @configuration = configuration
end

Instance Method Details

#delete(relative_path) ⇒ Array, ...

Performs an HTTP DELETE request to a Fulfil API endpoint.

Parameters:

  • relative_path (String)

    The relative path to the API resource.

Returns:

  • (Array, Hash, String)

    The parsed response body.



17
18
19
# File 'lib/fulfil_api/client.rb', line 17

def delete(relative_path)
  request(:delete, relative_path)
end

#get(relative_path, url_parameters: nil) ⇒ Array, ...

Performs an HTTP GET request to a Fulfil API endpoint.

Parameters:

  • relative_path (String)

    The relative path to the API resource.

  • url_parameters (Hash, nil) (defaults to: nil)

    The optional URL parameters for the API endpoint.

Returns:

  • (Array, Hash, String)

    The parsed response body.



26
27
28
# File 'lib/fulfil_api/client.rb', line 26

def get(relative_path, url_parameters: nil)
  request(:get, relative_path, url_parameters)
end

#post(relative_path, body: {}) ⇒ Array, ...

Performs an HTTP POST request to a Fulfil API endpoint.

Parameters:

  • relative_path (String)

    The relative path to the API resource.

  • body (Array, Hash, nil) (defaults to: {})

    The request body for the POST HTTP request.

Returns:

  • (Array, Hash, String)

    The parsed response body.



35
36
37
# File 'lib/fulfil_api/client.rb', line 35

def post(relative_path, body: {})
  request(:post, relative_path, body)
end

#put(relative_path, body: nil) ⇒ Array, ...

Performs an HTTP PUT request to a Fulfil API endpoint.

Parameters:

  • relative_path (String)

    The relative path to the API resource.

  • body (Array, Hash, nil) (defaults to: nil)

    The optional request body for the PUT HTTP request.

Returns:

  • (Array, Hash, String)

    The parsed response body.



44
45
46
47
48
# File 'lib/fulfil_api/client.rb', line 44

def put(relative_path, body: nil)
  return request(:put, relative_path) if body.nil?

  request(:put, relative_path, body)
end