|
| 1 | +$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) |
| 2 | +require 'trackingmore' |
| 3 | + |
| 4 | +TrackingMore.api_key = 'you api key' |
| 5 | + |
| 6 | +begin |
| 7 | + params = {"tracking_number" => "92612913029511573130094547","courier_code"=>"usps"} |
| 8 | + response = TrackingMore::Tracking.create_tracking(params) |
| 9 | + puts response |
| 10 | +rescue TrackingMore::TrackingMoreException => e |
| 11 | + puts "Caught Custom Exception: #{e.message}" |
| 12 | +end |
| 13 | + |
| 14 | +begin |
| 15 | + # params = {"tracking_numbers" => "92612903029511573130094547","courier_code"=>"usps"} |
| 16 | + # params = {"tracking_numbers" => "92612903029511573130094547,92612903029511573030094548","courier_code"=>"usps"} |
| 17 | + params = {"created_date_min" => "2023-08-23T14:00:00+08:00","created_date_max"=>"2023-08-23T15:04:00+08:00"} |
| 18 | + response = TrackingMore::Tracking.get_tracking_results(params) |
| 19 | + puts response |
| 20 | +rescue TrackingMore::TrackingMoreException => e |
| 21 | + puts "Caught Custom Exception: #{e.message}" |
| 22 | +end |
| 23 | + |
| 24 | +begin |
| 25 | + params = [{"tracking_number" => "92612903029611573130094547","courier_code"=>"usps"},{"tracking_number" => "92612903029711573130094547","courier_code"=>"usps"}] |
| 26 | + response = TrackingMore::Tracking.batch_create_trackings(params) |
| 27 | + puts response |
| 28 | +rescue TrackingMore::TrackingMoreException => e |
| 29 | + puts "Caught Custom Exception: #{e.message}" |
| 30 | +end |
| 31 | + |
| 32 | +begin |
| 33 | + params = {"customer_name" => "New name","note"=>"New tests order note"} |
| 34 | + id_string = '9a3aec583781c7096cf744d68287d3d1' |
| 35 | + response = TrackingMore::Tracking.update_tracking_by_id(id_string, params) |
| 36 | + puts response |
| 37 | +rescue TrackingMore::TrackingMoreException => e |
| 38 | + puts "Caught Custom Exception: #{e.message}" |
| 39 | +end |
| 40 | + |
| 41 | +begin |
| 42 | + id_string = '9a3aec583781c7096cf744d68287d3d1' |
| 43 | + response = TrackingMore::Tracking.delete_tracking_by_id(id_string) |
| 44 | + puts response |
| 45 | +rescue TrackingMore::TrackingMoreException => e |
| 46 | + puts "Caught Custom Exception: #{e.message}" |
| 47 | +end |
| 48 | + |
| 49 | +begin |
| 50 | + id_string = '9a3aec583781c7096cf744d68287d3d1' |
| 51 | + response = TrackingMore::Tracking.retrack_tracking_by_id(id_string) |
| 52 | + puts response |
| 53 | +rescue TrackingMore::TrackingMoreException => e |
| 54 | + puts "Caught Custom Exception: #{e.message}" |
| 55 | +end |
0 commit comments