class OpenapiClient::AddressesApi
Attributes
Public Class Methods
# File lib/openapi_client/api/addresses_api.rb, line 19 def initialize(api_client = ApiClient.default) @api_client = api_client end
Public Instance Methods
Parse an address The address-recognition API makes it easy for you to extract address data from unstructured text, including the recipient name, line 1, line 2, city, postal code, and more. Data often enters your system as unstructured text (for example: emails, SMS messages, support tickets, or other documents). ShipEngine's address-recognition API helps you extract meaningful, structured data from this unstructured text. The parsed address data is returned in the same structure that's used for other ShipEngine APIs, such as address validation, rate quotes, and shipping labels. > Note: Address
recognition is currently supported for the United States, Canada, Australia, New Zealand, the United Kingdom, and Ireland. @param parse_address_request_body [ParseAddressRequestBody] The only required field is `text`, which is the text to be parsed. You can optionally also provide an `address` containing already-known values. For example, you may already know the recipient's name, city, and country, and only want to parse the street address into separate lines. @param [Hash] opts the optional parameters @return [ParseAddressResponseBody]
# File lib/openapi_client/api/addresses_api.rb, line 27 def parse_address(parse_address_request_body, opts = {}) data, _status_code, _headers = parse_address_with_http_info(parse_address_request_body, opts) data end
Parse an address The address-recognition API makes it easy for you to extract address data from unstructured text, including the recipient name, line 1, line 2, city, postal code, and more. Data often enters your system as unstructured text (for example: emails, SMS messages, support tickets, or other documents). ShipEngine's address-recognition API helps you extract meaningful, structured data from this unstructured text. The parsed address data is returned in the same structure that's used for other ShipEngine APIs, such as address validation, rate quotes, and shipping labels. > Note: Address
recognition is currently supported for the United States, Canada, Australia, New Zealand, the United Kingdom, and Ireland. @param parse_address_request_body [ParseAddressRequestBody] The only required field is `text`, which is the text to be parsed. You can optionally also provide an `address` containing already-known values. For example, you may already know the recipient's name, city, and country, and only want to parse the street address into separate lines. @param [Hash] opts the optional parameters @return [Array<(ParseAddressResponseBody
, Integer, Hash)>] ParseAddressResponseBody
data, response status code and response headers
# File lib/openapi_client/api/addresses_api.rb, line 37 def parse_address_with_http_info(parse_address_request_body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AddressesApi.parse_address ...' end # verify the required parameter 'parse_address_request_body' is set if @api_client.config.client_side_validation && parse_address_request_body.nil? fail ArgumentError, "Missing the required parameter 'parse_address_request_body' when calling AddressesApi.parse_address" end # resource path local_var_path = '/v1/addresses/recognize' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(parse_address_request_body) # return_type return_type = opts[:return_type] || 'ParseAddressResponseBody' # 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(:PUT, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AddressesApi#parse_address\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
Validate An Address
Address
validation ensures accurate addresses and can lead to reduced shipping costs by preventing address correction surcharges. ShipEngine cross references multiple databases to validate addresses and identify potential deliverability issues. @param address_to_validate [Array<AddressToValidate>] @param [Hash] opts the optional parameters @return [Array<AddressValidationResult>]
# File lib/openapi_client/api/addresses_api.rb, line 91 def validate_address(address_to_validate, opts = {}) data, _status_code, _headers = validate_address_with_http_info(address_to_validate, opts) data end
Validate An Address
Address
validation ensures accurate addresses and can lead to reduced shipping costs by preventing address correction surcharges. ShipEngine cross references multiple databases to validate addresses and identify potential deliverability issues. @param address_to_validate [Array<AddressToValidate>] @param [Hash] opts the optional parameters @return [Array<(Array<AddressValidationResult>, Integer, Hash)>] Array<AddressValidationResult> data, response status code and response headers
# File lib/openapi_client/api/addresses_api.rb, line 101 def validate_address_with_http_info(address_to_validate, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AddressesApi.validate_address ...' end # verify the required parameter 'address_to_validate' is set if @api_client.config.client_side_validation && address_to_validate.nil? fail ArgumentError, "Missing the required parameter 'address_to_validate' when calling AddressesApi.validate_address" end # resource path local_var_path = '/v1/addresses/validate' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] || @api_client.object_to_http_body(address_to_validate) # return_type return_type = opts[:return_type] || 'Array<AddressValidationResult>' # 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: AddressesApi#validate_address\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end