etracking 2.5.2 → 2.5.5
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 +4 -4
- data/lib/etracking/client.rb +12 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 715acb934095a4c2f47d8b53ab5101da4fba4e6559bfc3f71d2a365bf938b923
|
4
|
+
data.tar.gz: c217fc61f0dcc2f9c65e53fd5ae1fd4fb86a5feb7b2ab8c8af0b0360eeb2ef67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a1662cf9c33c66e13f812ed35edb38e23b274e9a786e33e826a928df5b7bb1a562c3b23851ab3c9a3af3f4f3848a2593ee41ab6c80a77d662c814b3042974e9
|
7
|
+
data.tar.gz: 6db337c716ffcdca658b1ced56df642b211de86c0f083be1bc2ff7280e92bd45d1476ac91b55a4130378e27a33771849319e6c5186619847063e6f2f4e3e972b
|
data/lib/etracking/client.rb
CHANGED
@@ -14,7 +14,7 @@ module Etracking
|
|
14
14
|
|
15
15
|
class Client
|
16
16
|
# @return [String]
|
17
|
-
attr_accessor :api_key, :key_secret, :language
|
17
|
+
attr_accessor :api_key, :key_secret, :language
|
18
18
|
|
19
19
|
# Initialize a new client.
|
20
20
|
#
|
@@ -31,33 +31,23 @@ module Etracking
|
|
31
31
|
'https://etrackings.com/api/v2/tracks/'
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def rest_api(path, payload)
|
35
35
|
api_key_required
|
36
36
|
key_secret_required
|
37
37
|
|
38
|
-
|
39
|
-
request['etracking-key-secret'] = key_secret
|
40
|
-
request['accept-language'] = language || 'TH'
|
41
|
-
request['content-type'] = 'application/json'
|
38
|
+
url = URI("#{endpoint}#{path}")
|
42
39
|
|
43
|
-
|
44
|
-
|
40
|
+
https = Net::HTTP.new(url.host, url.port);
|
41
|
+
https.use_ssl = true
|
45
42
|
|
46
|
-
|
47
|
-
|
48
|
-
request =
|
49
|
-
request =
|
43
|
+
request = Net::HTTP::Post.new(url)
|
44
|
+
request["etracking-api-key"] = api_key
|
45
|
+
request["etracking-key-secret"] = key_secret
|
46
|
+
request["content-type"] = ["application/json", "text/plain"]
|
50
47
|
request.body = payload.to_json
|
48
|
+
response = https.request(request)
|
51
49
|
|
52
|
-
|
53
|
-
use_ssl: uri.scheme == "https",
|
54
|
-
}
|
55
|
-
|
56
|
-
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
57
|
-
http.request(request)
|
58
|
-
end
|
59
|
-
|
60
|
-
JSON.parse(response.body, { symbolize_names: true } )
|
50
|
+
JSON.parse(response.read_body, { symbolize_names: true } )
|
61
51
|
end
|
62
52
|
|
63
53
|
def track(service_name, tracking_number)
|
@@ -95,7 +85,7 @@ module Etracking
|
|
95
85
|
def thailand_post(tracking_number)
|
96
86
|
thailand_post_api_key
|
97
87
|
|
98
|
-
api('thailand_post', payload_tracking_number(tracking_number))
|
88
|
+
api('/thailand_post', payload_tracking_number(tracking_number))
|
99
89
|
end
|
100
90
|
|
101
91
|
def payload_with_service_and_tracking_number(service_name, tracking_number)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: etracking
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saharak Manoo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|