Class: FulfilApi::TplClient
- Inherits:
-
Object
- Object
- FulfilApi::TplClient
- Defined in:
- lib/fulfil_api/tpl_client.rb
Overview
The TplClient allows making proxy requests to Fulfil’s 3PL carrier API endpoint. It provides a simple interface for interacting with the 3PL supplier API using standard HTTP methods.
Defined Under Namespace
Classes: ConfigurationError
Constant Summary collapse
- DEFAULT_API_VERSION =
"v1"
Instance Method Summary collapse
-
#get(relative_path, **url_parameters) ⇒ Array, ...
Performs an HTTP GET request to a 3PL API endpoint.
-
#initialize(configuration) ⇒ TplClient
constructor
A new instance of TplClient.
-
#patch(relative_path, body = {}) ⇒ Array, ...
Performs an HTTP PATCH request to a 3PL API endpoint.
-
#post(relative_path, body = {}) ⇒ Array, ...
Performs an HTTP POST request to a 3PL API endpoint.
-
#put(relative_path, body = nil) ⇒ Array, ...
Performs an HTTP PUT request to a 3PL API endpoint.
Constructor Details
#initialize(configuration) ⇒ TplClient
Returns a new instance of TplClient.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fulfil_api/tpl_client.rb', line 20 def initialize(configuration) @configuration = configuration tpl_config = configuration.tpl || {} @auth_token = tpl_config[:auth_token].presence || raise(ConfigurationError, "Please provide a 3PL authentication token via config.tpl = { auth_token: ... }") @merchant_id = tpl_config[:merchant_id].presence || configuration.merchant_id.presence || raise(ConfigurationError, "Please provide a merchant ID") @api_version = tpl_config[:api_version].presence || DEFAULT_API_VERSION end |
Instance Method Details
#get(relative_path, **url_parameters) ⇒ Array, ...
Performs an HTTP GET request to a 3PL API endpoint.
38 39 40 |
# File 'lib/fulfil_api/tpl_client.rb', line 38 def get(relative_path, **url_parameters) request(:get, relative_path, url_parameters.presence) end |
#patch(relative_path, body = {}) ⇒ Array, ...
Performs an HTTP PATCH request to a 3PL API endpoint.
47 48 49 |
# File 'lib/fulfil_api/tpl_client.rb', line 47 def patch(relative_path, body = {}) request(:patch, relative_path, body) end |
#post(relative_path, body = {}) ⇒ Array, ...
Performs an HTTP POST request to a 3PL API endpoint.
56 57 58 |
# File 'lib/fulfil_api/tpl_client.rb', line 56 def post(relative_path, body = {}) request(:post, relative_path, body) end |
#put(relative_path, body = nil) ⇒ Array, ...
Performs an HTTP PUT request to a 3PL API endpoint.
65 66 67 68 69 |
# File 'lib/fulfil_api/tpl_client.rb', line 65 def put(relative_path, body = nil) return request(:put, relative_path) if body.nil? request(:put, relative_path, body) end |