class ShipEngine::TrackingApi
Attributes
Public Class Methods
# File lib/ship_engine/api/tracking_api.rb, line 19 def initialize(api_client = ApiClient.default) @api_client = api_client end
Public Instance Methods
Get Tracking Information Retrieve package tracking information @param [Hash] opts the optional parameters @option opts [String] :carrier_code Carrier
code used to retrieve tracking information @option opts [String] :tracking_number The tracking number associated with a shipment @return [GetTrackingLogResponseBody]
# File lib/ship_engine/api/tracking_api.rb, line 28 def get_tracking_log(opts = {}) data, _status_code, _headers = get_tracking_log_with_http_info(opts) data end
Get Tracking Information Retrieve package tracking information @param [Hash] opts the optional parameters @option opts [String] :carrier_code Carrier
code used to retrieve tracking information @option opts [String] :tracking_number The tracking number associated with a shipment @return [Array<(GetTrackingLogResponseBody
, Integer, Hash)>] GetTrackingLogResponseBody
data, response status code and response headers
# File lib/ship_engine/api/tracking_api.rb, line 39 def get_tracking_log_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TrackingApi.get_tracking_log ...' end if @api_client.config.client_side_validation && !opts[:'carrier_code'].nil? && opts[:'carrier_code'].to_s.length < 1 fail ArgumentError, 'invalid value for "opts[:"carrier_code"]" when calling TrackingApi.get_tracking_log, the character length must be great than or equal to 1.' end if @api_client.config.client_side_validation && !opts[:'tracking_number'].nil? && opts[:'tracking_number'].to_s.length < 1 fail ArgumentError, 'invalid value for "opts[:"tracking_number"]" when calling TrackingApi.get_tracking_log, the character length must be great than or equal to 1.' end # resource path local_var_path = '/v1/tracking' # query parameters query_params = opts[:query_params] || {} query_params[:'carrier_code'] = opts[:'carrier_code'] if !opts[:'carrier_code'].nil? query_params[:'tracking_number'] = opts[:'tracking_number'] if !opts[:'tracking_number'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'GetTrackingLogResponseBody' # auth_names auth_names = opts[:auth_names] || ['api_key'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: TrackingApi#get_tracking_log\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
Start Tracking a Package
Allows you to subscribe to tracking updates for a package. You specify the carrier_code and tracking_number of the package, and receive notifications via webhooks whenever the shipping status changes. @param [Hash] opts the optional parameters @option opts [String] :carrier_code Carrier
code used to retrieve tracking information @option opts [String] :tracking_number The tracking number associated with a shipment @return [String]
# File lib/ship_engine/api/tracking_api.rb, line 98 def start_tracking(opts = {}) data, _status_code, _headers = start_tracking_with_http_info(opts) data end
Start Tracking a Package
Allows you to subscribe to tracking updates for a package. You specify the carrier_code and tracking_number of the package, and receive notifications via webhooks whenever the shipping status changes. @param [Hash] opts the optional parameters @option opts [String] :carrier_code Carrier
code used to retrieve tracking information @option opts [String] :tracking_number The tracking number associated with a shipment @return [Array<(String, Integer, Hash)>] String data, response status code and response headers
# File lib/ship_engine/api/tracking_api.rb, line 109 def start_tracking_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TrackingApi.start_tracking ...' end if @api_client.config.client_side_validation && !opts[:'carrier_code'].nil? && opts[:'carrier_code'].to_s.length < 1 fail ArgumentError, 'invalid value for "opts[:"carrier_code"]" when calling TrackingApi.start_tracking, the character length must be great than or equal to 1.' end if @api_client.config.client_side_validation && !opts[:'tracking_number'].nil? && opts[:'tracking_number'].to_s.length < 1 fail ArgumentError, 'invalid value for "opts[:"tracking_number"]" when calling TrackingApi.start_tracking, the character length must be great than or equal to 1.' end # resource path local_var_path = '/v1/tracking/start' # query parameters query_params = opts[:query_params] || {} query_params[:'carrier_code'] = opts[:'carrier_code'] if !opts[:'carrier_code'].nil? query_params[:'tracking_number'] = opts[:'tracking_number'] if !opts[:'tracking_number'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'String' # auth_names auth_names = opts[:auth_names] || ['api_key'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: TrackingApi#start_tracking\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
Stop Tracking a Package
Unsubscribe from tracking updates for a package. @param [Hash] opts the optional parameters @option opts [String] :carrier_code Carrier
code used to retrieve tracking information @option opts [String] :tracking_number The tracking number associated with a shipment @return [String]
# File lib/ship_engine/api/tracking_api.rb, line 168 def stop_tracking(opts = {}) data, _status_code, _headers = stop_tracking_with_http_info(opts) data end
Stop Tracking a Package
Unsubscribe from tracking updates for a package. @param [Hash] opts the optional parameters @option opts [String] :carrier_code Carrier
code used to retrieve tracking information @option opts [String] :tracking_number The tracking number associated with a shipment @return [Array<(String, Integer, Hash)>] String data, response status code and response headers
# File lib/ship_engine/api/tracking_api.rb, line 179 def stop_tracking_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TrackingApi.stop_tracking ...' end if @api_client.config.client_side_validation && !opts[:'carrier_code'].nil? && opts[:'carrier_code'].to_s.length < 1 fail ArgumentError, 'invalid value for "opts[:"carrier_code"]" when calling TrackingApi.stop_tracking, the character length must be great than or equal to 1.' end if @api_client.config.client_side_validation && !opts[:'tracking_number'].nil? && opts[:'tracking_number'].to_s.length < 1 fail ArgumentError, 'invalid value for "opts[:"tracking_number"]" when calling TrackingApi.stop_tracking, the character length must be great than or equal to 1.' end # resource path local_var_path = '/v1/tracking/stop' # query parameters query_params = opts[:query_params] || {} query_params[:'carrier_code'] = opts[:'carrier_code'] if !opts[:'carrier_code'].nil? query_params[:'tracking_number'] = opts[:'tracking_number'] if !opts[:'tracking_number'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'String' # auth_names auth_names = opts[:auth_names] || ['api_key'] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: TrackingApi#stop_tracking\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end