trackingmore 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 87f2ee8d19d80d245ba813e56188b527371f2a347813c1d5a12748d6e2527a1b
4
+ data.tar.gz: 6b8c4ae66a5a06ae69d9cfbbafe76039a0cd1d10c6423c61aa598b232e3c092d
5
+ SHA512:
6
+ metadata.gz: 0dfb6b7e27675402772ea4ea0fd65b9f6719a9c42640c6cadc6e825667cc2a615221dd9e0a67a09d0d67f77bc372209df2cdf67daadf741523f434f9fbc00ec8
7
+ data.tar.gz: 5d6b4c56a6bba54fc4267f0e634fa28a226178f3e01612be97515a4d07da87a20edcbf68fae3e35fe2351c02d60c332b9a7b95d81760c1e4dd1bdb0dbc843d09
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in trackingmore.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 liaoaiping
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,230 @@
1
+ trackingmore-sdk-ruby
2
+ =================
3
+
4
+ The Ruby SDK of Trackingmore API
5
+
6
+ Contact: <manage@trackingmore.org>
7
+
8
+ ## Official document
9
+
10
+ [Document](https://www.trackingmore.com/docs/trackingmore/d5ac362fc3cda-api-quick-start)
11
+
12
+
13
+ ## Index
14
+ 1. [Installation](https://github.com/TrackingMores/trackingmore-sdk-ruby#installation)
15
+ 2. [Testing](https://github.com/TrackingMores/trackingmore-sdk-ruby#testing)
16
+ 3. [Error Handling](https://github.com/TrackingMores/trackingmore-sdk-ruby#error-handling)
17
+ 4. SDK
18
+ 1. [Couriers](https://github.com/TrackingMores/trackingmore-sdk-ruby#couriers)
19
+ 2. [Trackings](https://github.com/TrackingMores/trackingmore-sdk-ruby#trackings)
20
+ 3. [Air Waybill](https://github.com/TrackingMores/trackingmore-sdk-ruby#air-waybill)
21
+
22
+
23
+ ## Installation
24
+
25
+ ```
26
+ gem install trackingmore
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ ```ruby
32
+ require 'trackingmore'
33
+
34
+ TrackingMore.api_key = 'you api key'
35
+
36
+ begin
37
+ response = TrackingMore::Courier.get_all_couriers
38
+ puts response
39
+ rescue TrackingMore::TrackingMoreException => e
40
+ puts "Caught Custom Exception: #{e.message}"
41
+ end
42
+
43
+ ```
44
+
45
+ ## Testing
46
+ ```
47
+ rspec
48
+ ```
49
+
50
+ ## Error handling
51
+
52
+ **Throw** by the new SDK client
53
+
54
+ ```ruby
55
+ require 'trackingmore'
56
+
57
+ TrackingMore.api_key = ''
58
+
59
+ begin
60
+ response = TrackingMore::Courier.get_all_couriers
61
+ puts response
62
+ rescue TrackingMore::TrackingMoreException => e
63
+ puts "Caught Custom Exception: #{e.message}"
64
+ end
65
+
66
+ # API Key is missing
67
+ ```
68
+
69
+ **Throw** by the parameter validation in function
70
+
71
+ ```ruby
72
+ require 'trackingmore'
73
+
74
+ TrackingMore.api_key = 'you api key'
75
+
76
+ begin
77
+ params = {"tracking_number" => ""}
78
+ response = TrackingMore::Courier.detect(params)
79
+ puts response
80
+ rescue TrackingMore::TrackingMoreException => e
81
+ puts "Caught Custom Exception: #{e.message}"
82
+ end
83
+
84
+ # Tracking number cannot be empty
85
+ ```
86
+ ## Examples
87
+
88
+ ## Couriers
89
+ ##### Return a list of all supported couriers.
90
+ https://api.trackingmore.com/v4/couriers/all
91
+ ```ruby
92
+ begin
93
+ response = TrackingMore::Courier.get_all_couriers
94
+ puts response
95
+ rescue TrackingMore::TrackingMoreException => e
96
+ puts "Caught Custom Exception: #{e.message}"
97
+ end
98
+ ```
99
+
100
+ ##### Return a list of matched couriers based on submitted tracking number.
101
+ https://api.trackingmore.com/v4/couriers/detect
102
+ ```ruby
103
+ begin
104
+ params = {"tracking_number" => "92612903029511573030094547"}
105
+ response = TrackingMore::Courier.detect(params)
106
+ puts response
107
+ rescue TrackingMore::TrackingMoreException => e
108
+ puts "Caught Custom Exception: #{e.message}"
109
+ end
110
+ ```
111
+
112
+ ## Trackings
113
+ ##### Create a tracking.
114
+ https://api.trackingmore.com/v4/trackings/create
115
+ ```ruby
116
+ begin
117
+ params = {"tracking_number" => "92612913029511573130094547","courier_code"=>"usps"}
118
+ response = TrackingMore::Tracking.create_tracking(params)
119
+ puts response
120
+ rescue TrackingMore::TrackingMoreException => e
121
+ puts "Caught Custom Exception: #{e.message}"
122
+ end
123
+ ```
124
+
125
+ ##### Get tracking results of multiple trackings.
126
+ https://api.trackingmore.com/v4/trackings/get
127
+ ```ruby
128
+ begin
129
+ # Perform queries based on various conditions
130
+ # params = {"tracking_numbers" => "92612903029511573130094547","courier_code"=>"usps"}
131
+ # params = {"tracking_numbers" => "92612903029511573130094547,92612903029511573030094548","courier_code"=>"usps"}
132
+ params = {"created_date_min" => "2023-08-23T14:00:00+08:00","created_date_max"=>"2023-08-23T15:04:00+08:00"}
133
+ response = TrackingMore::Tracking.get_tracking_results(params)
134
+ puts response
135
+ rescue TrackingMore::TrackingMoreException => e
136
+ puts "Caught Custom Exception: #{e.message}"
137
+ end
138
+ ```
139
+
140
+ ##### Create multiple trackings (Max. 40 tracking numbers create in one call).
141
+ https://api.trackingmore.com/v4/trackings/batch
142
+ ```ruby
143
+ begin
144
+ params = [{"tracking_number" => "92612903029611573130094547","courier_code"=>"usps"},{"tracking_number" => "92612903029711573130094547","courier_code"=>"usps"}]
145
+ response = TrackingMore::Tracking.batch_create_trackings(params)
146
+ puts response
147
+ rescue TrackingMore::TrackingMoreException => e
148
+ puts "Caught Custom Exception: #{e.message}"
149
+ end
150
+ ```
151
+
152
+ ##### Update a tracking by ID.
153
+ https://api.trackingmore.com/v4/trackings/update/{id}
154
+ ```ruby
155
+ begin
156
+ params = {"customer_name" => "New name","note"=>"New tests order note"}
157
+ id_string = '9a3aec583781c7096cf744d68287d3d1'
158
+ response = TrackingMore::Tracking.update_tracking_by_id(id_string, params)
159
+ puts response
160
+ rescue TrackingMore::TrackingMoreException => e
161
+ puts "Caught Custom Exception: #{e.message}"
162
+ end
163
+ ```
164
+
165
+ ##### Delete a tracking by ID.
166
+ https://api.trackingmore.com/v4/trackings/delete/{id}
167
+ ```ruby
168
+ begin
169
+ id_string = '9a3aec583781c7096cf744d68287d3d1'
170
+ response = TrackingMore::Tracking.delete_tracking_by_id(id_string)
171
+ puts response
172
+ rescue TrackingMore::TrackingMoreException => e
173
+ puts "Caught Custom Exception: #{e.message}"
174
+ end
175
+ ```
176
+
177
+ ##### Retrack expired tracking by ID.
178
+ https://api.trackingmore.com/v4/trackings/retrack/{id}
179
+ ```ruby
180
+ begin
181
+ id_string = '9a3aec583781c7096cf744d68287d3d1'
182
+ response = TrackingMore::Tracking.retrack_tracking_by_id(id_string)
183
+ puts response
184
+ rescue TrackingMore::TrackingMoreException => e
185
+ puts "Caught Custom Exception: #{e.message}"
186
+ end
187
+ ```
188
+ ## Air Waybill
189
+ ##### Create an air waybill.
190
+ https://api.trackingmore.com/v4/awb
191
+ ```ruby
192
+ begin
193
+ params = {"awb_number" => "235-69030430"}
194
+ response = TrackingMore::AirWaybill.create_an_air_waybill(params)
195
+ puts response
196
+ rescue TrackingMore::TrackingMoreException => e
197
+ puts "Caught Custom Exception: #{e.message}"
198
+ end
199
+ ```
200
+
201
+ ## Response Code
202
+
203
+ 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.
204
+
205
+
206
+ Http CODE|META CODE|TYPE | MESSAGE
207
+ ----|-----|--------------|-------------------------------
208
+ 200 |200 | <code>Success</code> | Request response is successful
209
+ 400 |400 | <code>BadRequest</code> | Request type error. Please check the API documentation for the request type of this API.
210
+ 400 |4101 | <code>BadRequest</code> | Tracking No. already exists.
211
+ 400 |4102 | <code>BadRequest</code> | Tracking No. no exists. Please use 「Create a tracking」 API first to create shipment.
212
+ 400 |4103 | <code>BadRequest</code> | You have exceeded the shipment quantity of API call. The maximum quantity is 40 shipments per call.
213
+ 400 |4110 | <code>BadRequest</code> | The value of tracking_number is invalid.
214
+ 400 |4111 | <code>BadRequest</code> | Tracking_number is required.
215
+ 400 |4112 | <code>BadRequest</code> | Invalid Tracking ID.
216
+ 400 |4113 | <code>BadRequest</code> | Retrack is not allowed. You can only retrack an expired tracking.
217
+ 400 |4120 | <code>BadRequest</code> | The value of courier_code is invalid.
218
+ 400 |4121 | <code>BadRequest</code> | Cannot detect courier.
219
+ 400 |4122 | <code>BadRequest</code> | Missing or invalid value of the special required fields for this courier.
220
+ 400 |4130 | <code>BadRequest</code> | The format of Field name is invalid.
221
+ 400 |4160 | <code>BadRequest</code> | The awb_number is required or invaild format.
222
+ 400 |4161 | <code>BadRequest</code> | The awb airline does not support yet.
223
+ 400 |4190 | <code>BadRequest</code> | You are reaching the maximum quota limitation, please upgrade your current plan.
224
+ 401 |401 | <code>Unauthorized</code> | Authentication failed or has no permission. Please check and ensure your API Key is correct.
225
+ 403 |403 | <code>Forbidden</code> | Access prohibited. The request has been refused or access is not allowed.
226
+ 404 |404 | <code>NotFound</code> | Page does not exist. Please check and ensure your link is correct.
227
+ 429 |429 | <code>TooManyRequests</code>| Exceeded API request limits, please try again later. Please check the API documentation for the limit of this API.
228
+ 500 |511 | <code>ServerError</code> | Server error. Please contact us: service@trackingmore.org.
229
+ 500 |512 | <code>ServerError</code> | Server error. Please contact us: service@trackingmore.org.
230
+ 500 |513 | <code>ServerError</code> | Server error. Please contact us: service@trackingmore.org.
@@ -0,0 +1,12 @@
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 = {"awb_number" => "235-69030430"}
8
+ response = TrackingMore::AirWaybill.create_an_air_waybill(params)
9
+ puts response
10
+ rescue TrackingMore::TrackingMoreException => e
11
+ puts "Caught Custom Exception: #{e.message}"
12
+ end
@@ -0,0 +1,20 @@
1
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
2
+ require 'trackingmore'
3
+
4
+ TrackingMore.api_key = 'you api key'
5
+
6
+ begin
7
+ response = TrackingMore::Courier.get_all_couriers
8
+ puts response
9
+ rescue TrackingMore::TrackingMoreException => e
10
+ puts "Caught Custom Exception: #{e.message}"
11
+ end
12
+
13
+
14
+ begin
15
+ params = {"tracking_number" => "92612903029511573030094547"}
16
+ response = TrackingMore::Courier.detect(params)
17
+ puts response
18
+ rescue TrackingMore::TrackingMoreException => e
19
+ puts "Caught Custom Exception: #{e.message}"
20
+ end
@@ -0,0 +1,55 @@
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,0 +1,15 @@
1
+ require File.dirname(__FILE__) + '/request'
2
+
3
+ module TrackingMore
4
+ class AirWaybill
5
+ def self.create_an_air_waybill(params = {})
6
+ if params["awb_number"].to_s.empty?
7
+ raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrMissingAwbNumber)
8
+ end
9
+ if params["awb_number"].length != 12
10
+ raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrInvalidAirWaybillFormat)
11
+ end
12
+ TrackingMore::Request.make_request('post',"awb",params)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+
2
+ module TrackingMore
3
+ class Consts
4
+ ErrEmptyAPIKey = 'API Key is missing';
5
+ ErrMissingTrackingNumber = 'Tracking number cannot be empty';
6
+ ErrMissingCourierCode = 'Courier Code cannot be empty';
7
+ ErrMissingAwbNumber = 'Awb number cannot be empty';
8
+ ErrMaxTrackingNumbersExceeded = 'Max. 40 tracking numbers create in one call';
9
+ ErrEmptyId = 'Id cannot be empty';
10
+ ErrInvalidAirWaybillFormat = 'The air waybill number format is invalid and can only be 12 digits in length';
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/request'
2
+
3
+ module TrackingMore
4
+ class Courier
5
+ @@api_module = 'couriers'
6
+ def self.get_all_couriers
7
+ TrackingMore::Request.make_request('get',"#@@api_module/all")
8
+ end
9
+ def self.detect(params = {})
10
+ if params["tracking_number"].to_s.empty?
11
+ raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrMissingTrackingNumber)
12
+ end
13
+ TrackingMore::Request.make_request('post',"#@@api_module/detect",params)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+
2
+ module TrackingMore
3
+ class TrackingMoreException < StandardError
4
+ def initialize(message = '')
5
+ super(message)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,82 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'json'
4
+
5
+ module TrackingMore
6
+ class Request
7
+ @@apiBaseUrl = 'api.trackingmore.com'
8
+ @@apiPort = 443
9
+ @@apiVersion = 'v4'
10
+ @@timeout = 10
11
+ @@proxy_host = '192.168.2.198'
12
+ @@proxy_port = 7890
13
+
14
+ def self.get_request_url(path)
15
+ pact = @@apiPort == 443 ? 'https' : 'http'
16
+ url = pact+'://'+@@apiBaseUrl+'/'+@@apiVersion+'/'+path
17
+ return url
18
+ end
19
+
20
+ def self.get_request_header(apiKey)
21
+ headers = {}
22
+ headers['Accept'] = 'application/json'
23
+ headers['Content-Type'] = 'application/json'
24
+ headers['Tracking-Api-Key'] = apiKey
25
+ return headers
26
+ end
27
+
28
+ def self.make_request(method = 'GET', path = '', params = nil)
29
+
30
+ if TrackingMore.api_key.to_s.empty?
31
+ raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrEmptyAPIKey)
32
+ end
33
+
34
+ url = get_request_url(path)
35
+
36
+ headers = get_request_header(TrackingMore.api_key)
37
+
38
+
39
+ uri = URI.parse(url)
40
+
41
+ if method.downcase == 'get' && params!=nil
42
+ query_string = URI.encode_www_form(params)
43
+ uri.query = query_string
44
+ end
45
+
46
+ http = Net::HTTP.new(uri.host, uri.port,@@proxy_host,@@proxy_port)
47
+ http.use_ssl = uri.scheme == 'https'
48
+
49
+ http.open_timeout = 10
50
+
51
+ http.read_timeout = 10
52
+
53
+ request_class = case method.downcase
54
+ when 'get' then Net::HTTP::Get
55
+ when 'post' then Net::HTTP::Post
56
+ when 'put' then Net::HTTP::Put
57
+ when 'delete' then Net::HTTP::Delete
58
+ else raise ArgumentError, "Invalid HTTP method: #{method}"
59
+ end
60
+
61
+ request = request_class.new(uri.request_uri)
62
+
63
+ headers.each { |key, value| request[key] = value }
64
+
65
+ if params!=nil && (method.downcase == 'post' || method.downcase == 'put')
66
+ request.body = params.to_json
67
+ end
68
+
69
+ begin
70
+ response = http.request(request)
71
+ begin
72
+ parsed_response = JSON.parse(response.body)
73
+ parsed_response
74
+ rescue JSON::ParserError
75
+ response.body
76
+ end
77
+ rescue StandardError => e
78
+ { 'error' => e.message }
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,57 @@
1
+ require File.dirname(__FILE__) + '/request'
2
+
3
+ module TrackingMore
4
+ class Tracking
5
+ @@api_module = 'trackings'
6
+
7
+ def self.create_tracking(params = {})
8
+ if params["tracking_number"].to_s.empty?
9
+ raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrMissingTrackingNumber)
10
+ end
11
+ if params["courier_code"].to_s.empty?
12
+ raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrMissingCourierCode)
13
+ end
14
+ TrackingMore::Request.make_request('post',"#@@api_module/create",params)
15
+ end
16
+
17
+ def self.get_tracking_results(params = {})
18
+ TrackingMore::Request.make_request('get',"#@@api_module/get",params)
19
+ end
20
+
21
+ def self.batch_create_trackings(params = [])
22
+ if params.length > 40
23
+ raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrMaxTrackingNumbersExceeded)
24
+ end
25
+ params.each do |item|
26
+ if item["tracking_number"].to_s.empty?
27
+ raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrMissingTrackingNumber)
28
+ end
29
+ if item["courier_code"].to_s.empty?
30
+ raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrMissingCourierCode)
31
+ end
32
+ end
33
+ TrackingMore::Request.make_request('post',"#@@api_module/batch",params)
34
+ end
35
+
36
+ def self.update_tracking_by_id(id_string, params = {})
37
+ if id_string.to_s.empty?
38
+ raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrEmptyId)
39
+ end
40
+ TrackingMore::Request.make_request('put',"#@@api_module/update/"+id_string,params)
41
+ end
42
+
43
+ def self.delete_tracking_by_id(id_string)
44
+ if id_string.to_s.empty?
45
+ raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrEmptyId)
46
+ end
47
+ TrackingMore::Request.make_request('delete',"#@@api_module/delete/"+id_string)
48
+ end
49
+
50
+ def self.retrack_tracking_by_id(id_string)
51
+ if id_string.to_s.empty?
52
+ raise TrackingMore::TrackingMoreException.new(TrackingMore::Consts::ErrEmptyId)
53
+ end
54
+ TrackingMore::Request.make_request('post',"#@@api_module/retrack/"+id_string)
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,16 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require 'trackingmore/const'
4
+ require 'trackingmore/exception'
5
+ require 'trackingmore/courier'
6
+ require 'trackingmore/tracking'
7
+ require 'trackingmore/air_waybill'
8
+
9
+ module TrackingMore
10
+ class << self
11
+ attr_accessor :api_key
12
+ end
13
+
14
+ VERSION = '0.1.0'
15
+ end
16
+
@@ -0,0 +1,40 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "trackingmore"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "trackingmore"
8
+ spec.version = TrackingMore::VERSION
9
+ spec.authors = ["trackingmore"]
10
+ spec.email = ["manage@trackingmore.org"]
11
+
12
+ spec.summary = "The Ruby SDK of Trackingmore API"
13
+ spec.description = "Developed for easy integration with TrackingMore"
14
+ spec.homepage = "https://www.trackingmore.com/"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "https://github.com/TrackingMores/trackingmore-sdk-ruby"
21
+ #
22
+ # spec.metadata["homepage_uri"] = spec.homepage
23
+ # spec.metadata["source_code_uri"] = "https://github.com/TrackingMores/trackingmore-sdk-ruby.git"
24
+ # else
25
+ # raise "RubyGems 2.0 or newer is required to protect against " \
26
+ # "public gem pushes."
27
+ # end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_development_dependency "bundler", "~> 1.17"
39
+ spec.add_development_dependency "rspec", "~> 3.12"
40
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trackingmore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - trackingmore
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-09-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.12'
41
+ description: Developed for easy integration with TrackingMore
42
+ email:
43
+ - manage@trackingmore.org
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - examples/air_waybill_example.rb
53
+ - examples/courier_example.rb
54
+ - examples/tracking_example.rb
55
+ - lib/trackingmore.rb
56
+ - lib/trackingmore/air_waybill.rb
57
+ - lib/trackingmore/const.rb
58
+ - lib/trackingmore/courier.rb
59
+ - lib/trackingmore/exception.rb
60
+ - lib/trackingmore/request.rb
61
+ - lib/trackingmore/tracking.rb
62
+ - trackingmore.gemspec
63
+ homepage: https://www.trackingmore.com/
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubygems_version: 3.0.3.1
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: The Ruby SDK of Trackingmore API
86
+ test_files: []