Class: TrackingMore::Tracking
- Inherits:
-
Object
- Object
- TrackingMore::Tracking
- Defined in:
- lib/trackingmore/tracking.rb
Constant Summary collapse
- @@api_module =
'trackings'
Class Method Summary collapse
- .batch_create_trackings(params = []) ⇒ Object
- .create_tracking(params = {}) ⇒ Object
- .delete_tracking_by_id(id_string) ⇒ Object
- .get_tracking_results(params = {}) ⇒ Object
- .retrack_tracking_by_id(id_string) ⇒ Object
- .update_tracking_by_id(id_string, params = {}) ⇒ Object
Class Method Details
.batch_create_trackings(params = []) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/trackingmore/tracking.rb', line 21 def self.batch_create_trackings(params = []) if params.length > 40 raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrMaxTrackingNumbersExceeded) end params.each do |item| if item["tracking_number"].to_s.empty? raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrMissingTrackingNumber) end if item["courier_code"].to_s.empty? raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrMissingCourierCode) end end TrackingMore::Request.make_request('post',"#@@api_module/batch",params) end |
.create_tracking(params = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/trackingmore/tracking.rb', line 7 def self.create_tracking(params = {}) if params["tracking_number"].to_s.empty? raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrMissingTrackingNumber) end if params["courier_code"].to_s.empty? raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrMissingCourierCode) end TrackingMore::Request.make_request('post',"#@@api_module/create",params) end |
.delete_tracking_by_id(id_string) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/trackingmore/tracking.rb', line 43 def self.delete_tracking_by_id(id_string) if id_string.to_s.empty? raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrEmptyId) end TrackingMore::Request.make_request('delete',"#@@api_module/delete/"+id_string) end |
.get_tracking_results(params = {}) ⇒ Object
17 18 19 |
# File 'lib/trackingmore/tracking.rb', line 17 def self.get_tracking_results(params = {}) TrackingMore::Request.make_request('get',"#@@api_module/get",params) end |
.retrack_tracking_by_id(id_string) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/trackingmore/tracking.rb', line 50 def self.retrack_tracking_by_id(id_string) if id_string.to_s.empty? raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrEmptyId) end TrackingMore::Request.make_request('post',"#@@api_module/retrack/"+id_string) end |
.update_tracking_by_id(id_string, params = {}) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/trackingmore/tracking.rb', line 36 def self.update_tracking_by_id(id_string, params = {}) if id_string.to_s.empty? raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrEmptyId) end TrackingMore::Request.make_request('put',"#@@api_module/update/"+id_string,params) end |