Class: TqlOtrFactoringDataExchange::LoadsApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/tql_otr_factoring_data_exchange/apis/loads_api.rb

Overview

LoadsApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from TqlOtrFactoringDataExchange::BaseApi

Instance Method Details

#get_load(load_number) ⇒ ApiResponse

Retrieve basic details for a TQL load by its load number. Use this to verify a load exists in TQL’s system and to confirm carrier assignment, load status, and shipment dates before submitting an invoice.

Parameters:

  • load_number (String)

    Required parameter: The TQL load number.

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tql_otr_factoring_data_exchange/apis/loads_api.rb', line 14

def get_load(load_number)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/loads/{loadNumber}',
                                 Server::DEFAULT)
               .template_param(new_parameter(load_number, key: 'loadNumber')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('bearerAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(LoadDetail.method(:from_hash))
                .is_api_response(true)
                .local_error('404',
                             "Load not found — no load exists with the specified load number'\
                              '.\n",
                             ProblemDetailsErrorException))
    .execute
end

#search_loads(body) ⇒ ApiResponse

Search for TQL loads using optional filter criteria. Returns a paginated list of load summaries. Use this to find loads by carrier, date range, or status. Scoping: Results are scoped to loads where the authenticated factoring company’s assigned carriers are the carrier on the load. **Filter logic:** Filters use AND across different fields and OR within array-valued fields. pagination parameters. All filter fields are optional — omit a field to skip that filter.

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/tql_otr_factoring_data_exchange/apis/loads_api.rb', line 46

def search_loads(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/loads/search',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('bearerAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(LoadSearchResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             "Validation error — invalid filter criteria or pagination'\
                              ' parameters.\n",
                             ProblemDetailsErrorException))
    .execute
end