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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75f9e8df2080f7e23f36543686c5e2dab0125eee
4
- data.tar.gz: b32d825f1a538313ea3e578fcb08a94003b99f6d
3
+ metadata.gz: 64d4ba6b14b700635c64c2e90aea89dc4d82200d
4
+ data.tar.gz: 079dec50d0d9aa8d31157ffcd1bc36dcc6804888
5
5
  SHA512:
6
- metadata.gz: 096f446d4b8d98e9d3acbedfcdb736b3c431570601753c22c9fe60beba455ce02b8230518b9f81d5853efb329db89e485b4bf329d7fac917ed742a06a31b0ca6
7
- data.tar.gz: f53dd902206ba1dae0c14802722357c65452de49e557502f57e840af0605b8990e6a593876bfe13c50da3a634b64b0d0e716432fc6f81d99e298ee0f46fc84e9
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
@@ -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 = options[:api_version] || POSTNORD_API_VERSION
11
- @api_key = options[:api_key] || POSTNORD_API_KEY
12
- @locale = options[:locale] || POSTNORD_LOCALE || 'en'
13
- @returntype = options[:returntype] || POSTNORD_RETURN_TYPE || 'json'
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: POSTNORD_API_KEY,
21
- locale: POSTNORD_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
- POSTNORD_API_ENDPOINT +
34
+ @api_endpoint +
39
35
  '/' + service +
40
- '/' + POSTNORD_API_VERSION +
36
+ '/' + @api_version +
41
37
  '/' + endpoint +
42
- '.' + POSTNORD_RETURN_TYPE
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
@@ -1,3 +1,3 @@
1
1
  module Postnord
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/lib/postnord.rb CHANGED
@@ -4,6 +4,7 @@ require 'net/https'
4
4
  require 'json'
5
5
  require 'openssl'
6
6
 
7
+ require 'postnord/config'
7
8
  require 'postnord/client'
8
9
  require 'postnord/response'
9
10
  require 'postnord/base'
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.1
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-06-17 00:00:00.000000000 Z
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