postnord 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/lib/postnord/client.rb +10 -14
- data/lib/postnord/config.rb +25 -0
- data/lib/postnord/version.rb +1 -1
- data/lib/postnord.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64d4ba6b14b700635c64c2e90aea89dc4d82200d
|
4
|
+
data.tar.gz: 079dec50d0d9aa8d31157ffcd1bc36dcc6804888
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d42673ba91413f1ea84c75584425f3d3e50cedb71f5e3ab433b3708b94aa34a8218ac82c541ba47a21086f7fab193076962389dcd0ca0ec71519bc3d5d03a2a
|
7
|
+
data.tar.gz: ebbdc99020299261962388c77b2b8c5d1679f1d677145913b72d8bc24908081da43147ce3c2210921f745394750494b7593d964c1e2ac0a7a0d2e241d1b30a0a
|
data/README.md
CHANGED
@@ -32,8 +32,6 @@ POSTNORD_LOCALE = 'en' # default
|
|
32
32
|
POSTNORD_RETURN_TYPE = 'json' # default
|
33
33
|
```
|
34
34
|
|
35
|
-
```
|
36
|
-
|
37
35
|
How to fetch a package with the test identifier from [developer documentation](https://developer.postnord.com/docs#!/trackandtrace/findByIdentifier) using a helper method:
|
38
36
|
|
39
37
|
```ruby
|
data/lib/postnord/client.rb
CHANGED
@@ -1,24 +1,20 @@
|
|
1
1
|
module Postnord
|
2
2
|
class Client
|
3
|
-
POSTNORD_API_KEY = ''
|
4
|
-
POSTNORD_API_VERSION = 'v1'
|
5
|
-
POSTNORD_API_ENDPOINT = 'https://api2.postnord.com/rest'
|
6
|
-
POSTNORD_LOCALE = 'en'
|
7
|
-
POSTNORD_RETURN_TYPE = 'json'
|
8
3
|
|
9
4
|
def initialize(options={})
|
10
|
-
@api_version
|
11
|
-
@api_key
|
12
|
-
@
|
13
|
-
@
|
5
|
+
@api_version = options[:api_version] || Config.api_version
|
6
|
+
@api_key = options[:api_key] || Config.api_key
|
7
|
+
@api_endpoint = options[:api_endpoint] || Config.api_endpoint
|
8
|
+
@locale = options[:locale] || Config.locale
|
9
|
+
@return_type = options[:return_type] || Config.return_type
|
14
10
|
end
|
15
11
|
|
16
12
|
def do_request(service, endpoint, params={})
|
17
13
|
uri = build_uri(service, endpoint)
|
18
14
|
|
19
15
|
params.merge!(
|
20
|
-
apikey:
|
21
|
-
locale:
|
16
|
+
apikey: @api_key,
|
17
|
+
locale: @locale,
|
22
18
|
)
|
23
19
|
|
24
20
|
uri.query = URI.encode_www_form(params)
|
@@ -35,11 +31,11 @@ module Postnord
|
|
35
31
|
|
36
32
|
def build_uri(service, endpoint)
|
37
33
|
URI(
|
38
|
-
|
34
|
+
@api_endpoint +
|
39
35
|
'/' + service +
|
40
|
-
'/' +
|
36
|
+
'/' + @api_version +
|
41
37
|
'/' + endpoint +
|
42
|
-
'.' +
|
38
|
+
'.' + @return_type
|
43
39
|
)
|
44
40
|
end
|
45
41
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Postnord
|
2
|
+
class Config
|
3
|
+
|
4
|
+
def self.api_key
|
5
|
+
(defined? POSTNORD_API_KEY) ? POSTNORD_API_KEY : ''
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.api_version
|
9
|
+
(defined? POSTNORD_API_VERSION) ? POSTNORD_API_VERSION : 'v1'
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.api_endpoint
|
13
|
+
(defined? POSTNORD_API_ENDPOINT) ? POSTNORD_API_ENDPOINT : 'https://api2.postnord.com/rest'
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.locale
|
17
|
+
(defined? POSTNORD_LOCALE) ? POSTNORD_LOCALE : 'en'
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.return_type
|
21
|
+
(defined? POSTNORD_RETURN_TYPE) ? POSTNORD_RETURN_TYPE : 'json'
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/lib/postnord/version.rb
CHANGED
data/lib/postnord.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postnord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Åhman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/postnord/base.rb
|
88
88
|
- lib/postnord/business_location.rb
|
89
89
|
- lib/postnord/client.rb
|
90
|
+
- lib/postnord/config.rb
|
90
91
|
- lib/postnord/response.rb
|
91
92
|
- lib/postnord/shipment.rb
|
92
93
|
- lib/postnord/transport.rb
|