New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

trackingmore

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trackingmore

  • 0.1.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

trackingmore-sdk-ruby

The Ruby SDK of Trackingmore API

Contact: manage@trackingmore.org

Official document

Document

Index

  1. Installation
  2. Testing
  3. Error Handling
  4. SDK
    1. Couriers
    2. Trackings
    3. Air Waybill

Installation

gem install trackingmore

Quick Start

require  'trackingmore'

TrackingMore.api_key = 'you api key'

begin
  response = TrackingMore::Courier.get_all_couriers
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
rescue StandardError => e
   puts "Caught Standard Error: #{e.message}"
end

Testing

rspec

Error handling

Throw by the new SDK client

require  'trackingmore'

TrackingMore.api_key = ''

begin
  response = TrackingMore::Courier.get_all_couriers
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
end

# API Key is missing

Throw by the parameter validation in function

require  'trackingmore'

TrackingMore.api_key = 'you api key'

begin
  params  = {"tracking_number" => ""}
  response = TrackingMore::Courier.detect(params)
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
end

# Tracking number cannot be empty

Examples

Couriers

Return a list of all supported couriers.

https://api.trackingmore.com/v4/couriers/all

begin
  response = TrackingMore::Courier.get_all_couriers
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
rescue StandardError => e
   puts "Caught Standard Error: #{e.message}"
end
Return a list of matched couriers based on submitted tracking number.

https://api.trackingmore.com/v4/couriers/detect

begin
  params  = {"tracking_number" => "92612903029511573030094547"}
  response = TrackingMore::Courier.detect(params)
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
rescue StandardError => e
   puts "Caught Standard Error: #{e.message}"
end

Trackings

Create a tracking.

https://api.trackingmore.com/v4/trackings/create

begin
  params  = {"tracking_number" => "92612913029511573130094547","courier_code"=>"usps"}
  response = TrackingMore::Tracking.create_tracking(params)
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
rescue StandardError => e
   puts "Caught Standard Error: #{e.message}"
end
Get tracking results of multiple trackings.

https://api.trackingmore.com/v4/trackings/get

begin
  # Perform queries based on various conditions
  # params  = {"tracking_numbers" => "92612903029511573130094547","courier_code"=>"usps"}
  # params  = {"tracking_numbers" => "92612903029511573130094547,92612903029511573030094548","courier_code"=>"usps"}
  params  = {"created_date_min" => "2023-08-23T14:00:00+08:00","created_date_max"=>"2023-08-23T15:04:00+08:00"}
  response = TrackingMore::Tracking.get_tracking_results(params)
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
rescue StandardError => e
   puts "Caught Standard Error: #{e.message}"
end
Create multiple trackings (Max. 40 tracking numbers create in one call).

https://api.trackingmore.com/v4/trackings/batch

begin
  params  = [{"tracking_number" => "92612903029611573130094547","courier_code"=>"usps"},{"tracking_number" => "92612903029711573130094547","courier_code"=>"usps"}]
  response = TrackingMore::Tracking.batch_create_trackings(params)
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
rescue StandardError => e
   puts "Caught Standard Error: #{e.message}"
end
Update a tracking by ID.

https://api.trackingmore.com/v4/trackings/update/{id}

begin
  params  = {"customer_name" => "New name","note"=>"New tests order note"}
  id_string = '9a3aec583781c7096cf744d68287d3d1'
  response = TrackingMore::Tracking.update_tracking_by_id(id_string, params)
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
rescue StandardError => e
   puts "Caught Standard Error: #{e.message}"
end
Delete a tracking by ID.

https://api.trackingmore.com/v4/trackings/delete/{id}

begin
  id_string = '9a3aec583781c7096cf744d68287d3d1'
  response = TrackingMore::Tracking.delete_tracking_by_id(id_string)
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
rescue StandardError => e
   puts "Caught Standard Error: #{e.message}"
end
Retrack expired tracking by ID.

https://api.trackingmore.com/v4/trackings/retrack/{id}

begin
  id_string = '9a3aec583781c7096cf744d68287d3d1'
  response = TrackingMore::Tracking.retrack_tracking_by_id(id_string)
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
rescue StandardError => e
   puts "Caught Standard Error: #{e.message}"
end

Air Waybill

Create an air waybill.

https://api.trackingmore.com/v4/awb

begin
  params  = {"awb_number" => "235-69030430"}
  response = TrackingMore::AirWaybill.create_an_air_waybill(params)
  puts response
rescue TrackingMore::TrackingMoreException => e
  puts "Caught Custom Exception: #{e.message}"
rescue StandardError => e
   puts "Caught Standard Error: #{e.message}"
end

Response Code

Trackingmore uses conventional HTTP response codes to indicate success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that resulted from the provided information (e.g. a required parameter was missing, a charge failed, etc.), and codes in the 5xx range indicate an TrackingMore's server error.

Http CODEMETA CODETYPEMESSAGE
200200SuccessRequest response is successful
400400BadRequestRequest type error. Please check the API documentation for the request type of this API.
4004101BadRequestTracking No. already exists.
4004102BadRequestTracking No. no exists. Please use 「Create a tracking」 API first to create shipment.
4004103BadRequestYou have exceeded the shipment quantity of API call. The maximum quantity is 40 shipments per call.
4004110BadRequestThe value of tracking_number is invalid.
4004111BadRequestTracking_number is required.
4004112BadRequestInvalid Tracking ID.
4004113BadRequestRetrack is not allowed. You can only retrack an expired tracking.
4004120BadRequestThe value of courier_code is invalid.
4004121BadRequestCannot detect courier.
4004122BadRequestMissing or invalid value of the special required fields for this courier.
4004130BadRequestThe format of Field name is invalid.
4004160BadRequestThe awb_number is required or invaild format.
4004161BadRequestThe awb airline does not support yet.
4004190BadRequestYou are reaching the maximum quota limitation, please upgrade your current plan.
401401UnauthorizedAuthentication failed or has no permission. Please check and ensure your API Key is correct.
403403ForbiddenAccess prohibited. The request has been refused or access is not allowed.
404404NotFoundPage does not exist. Please check and ensure your link is correct.
429429TooManyRequestsExceeded API request limits, please try again later. Please check the API documentation for the limit of this API.
500511ServerErrorServer error. Please contact us: service@trackingmore.org.
500512ServerErrorServer error. Please contact us: service@trackingmore.org.
500513ServerErrorServer error. Please contact us: service@trackingmore.org.

FAQs

Package last updated on 07 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc