postnord 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/postnord/base.rb +8 -4
- data/lib/postnord/client.rb +12 -8
- data/lib/postnord/transport.rb +21 -0
- data/lib/postnord/version.rb +1 -1
- data/postnord.gemspec +7 -5
- metadata +35 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efbb94922821893e0064515ac73d715223091827c6eeedb3582f0ae0d09ba424
|
4
|
+
data.tar.gz: 6514fe300a663b340bff90b85f12be7cbd3124a7973a240f424d77c4e2242124
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4cf493d897ee0cd3adf167b36c0a2188bce2f48bb71bfd711ddaf2537d4a6eae3dc126a2eb8a66852f4f405e4b3b6e81879d10809d145bebd2cef1c02e9acac
|
7
|
+
data.tar.gz: fac89cecc8067a8a999f7bb972179c6f3c92b0f2d821491d13b8c27602ed1e8530b2cc99e2fcee473b4d039383897ab2048f9634f1d709c12a570eaaf58e4f9c
|
data/lib/postnord/base.rb
CHANGED
@@ -9,7 +9,7 @@ module Postnord
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.client
|
12
|
-
@client ||= Client.new
|
12
|
+
@client ||= Client.new(options)
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
@@ -23,15 +23,19 @@ module Postnord
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.action
|
26
|
-
self.name.split(
|
26
|
+
self.name.split("::").last.tap { |e| e[0] = e[0].downcase }
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.mandatory_params
|
30
|
-
fail NotImplementedError,
|
30
|
+
fail NotImplementedError, "mandatory_params"
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.endpoint
|
34
|
-
fail NotImplementedError,
|
34
|
+
fail NotImplementedError, "endpoint"
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.options
|
38
|
+
{}
|
35
39
|
end
|
36
40
|
end
|
37
41
|
end
|
data/lib/postnord/client.rb
CHANGED
@@ -6,7 +6,11 @@ module Postnord
|
|
6
6
|
@api_key = options[:api_key] || Config.api_key
|
7
7
|
@api_endpoint = options[:api_endpoint] || Config.api_endpoint
|
8
8
|
@locale = options[:locale] || Config.locale
|
9
|
-
@return_type = options
|
9
|
+
@return_type = if options.has_key?(:return_type)
|
10
|
+
options[:return_type]
|
11
|
+
else
|
12
|
+
Config.return_type
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
def do_request(service, endpoint, params={})
|
@@ -27,13 +31,13 @@ module Postnord
|
|
27
31
|
private
|
28
32
|
|
29
33
|
def build_uri(service, endpoint)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
)
|
34
|
+
url = @api_endpoint +
|
35
|
+
"/" + service +
|
36
|
+
"/" + @api_version +
|
37
|
+
"/" + endpoint
|
38
|
+
url += "." + @return_type if @return_type
|
39
|
+
|
40
|
+
URI(url)
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
data/lib/postnord/transport.rb
CHANGED
@@ -12,6 +12,27 @@ module Postnord
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
class AddressToAddress < Transport
|
16
|
+
def self.mandatory_params
|
17
|
+
[
|
18
|
+
"startTime",
|
19
|
+
"serviceGroup",
|
20
|
+
"originPostCode",
|
21
|
+
"originCountryCode",
|
22
|
+
"destinationPostCode",
|
23
|
+
"destinationCountryCode",
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.action
|
28
|
+
self.name.split('::').last.downcase
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.options
|
32
|
+
{ return_type: nil }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
15
36
|
class GetTransitTimeInformation < Transport
|
16
37
|
def self.mandatory_params
|
17
38
|
[
|
data/lib/postnord/version.rb
CHANGED
data/postnord.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "postnord/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "postnord"
|
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Stefan Åhman"]
|
10
10
|
spec.email = ["stefan.ahman@apoex.se"]
|
11
11
|
|
12
|
-
spec.summary = %q{A gem for Postnord
|
13
|
-
spec.homepage =
|
12
|
+
spec.summary = %q{A gem for Postnord"s API}
|
13
|
+
spec.homepage = "https://github.com/apoex/postnord"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -18,10 +18,12 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency
|
21
|
+
spec.add_dependency "faraday"
|
22
22
|
spec.add_development_dependency "webmock"
|
23
23
|
spec.add_development_dependency "bundler"
|
24
24
|
spec.add_development_dependency "rake", ">= 10.0"
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_development_dependency "pry-byebug"
|
27
|
+
spec.add_development_dependency "pry-byebyebug"
|
26
28
|
spec.add_development_dependency "simplecov", "~> 0.17.1"
|
27
29
|
end
|
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.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Åhman
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-byebyebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: simplecov
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,7 +122,7 @@ dependencies:
|
|
94
122
|
- - "~>"
|
95
123
|
- !ruby/object:Gem::Version
|
96
124
|
version: 0.17.1
|
97
|
-
description:
|
125
|
+
description:
|
98
126
|
email:
|
99
127
|
- stefan.ahman@apoex.se
|
100
128
|
executables: []
|
@@ -127,7 +155,7 @@ homepage: https://github.com/apoex/postnord
|
|
127
155
|
licenses:
|
128
156
|
- MIT
|
129
157
|
metadata: {}
|
130
|
-
post_install_message:
|
158
|
+
post_install_message:
|
131
159
|
rdoc_options: []
|
132
160
|
require_paths:
|
133
161
|
- lib
|
@@ -143,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
171
|
version: '0'
|
144
172
|
requirements: []
|
145
173
|
rubygems_version: 3.1.2
|
146
|
-
signing_key:
|
174
|
+
signing_key:
|
147
175
|
specification_version: 4
|
148
|
-
summary: A gem for Postnord
|
176
|
+
summary: A gem for Postnord"s API
|
149
177
|
test_files: []
|