postnord 0.2.3 → 1.0.0

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
- SHA1:
3
- metadata.gz: 8c5f62dbb4577260e7c50dcaccb1534ff94ff46c
4
- data.tar.gz: 7b16b9fed310aa9e084d84a2263d8d3bdbe02bb8
2
+ SHA256:
3
+ metadata.gz: efbb94922821893e0064515ac73d715223091827c6eeedb3582f0ae0d09ba424
4
+ data.tar.gz: 6514fe300a663b340bff90b85f12be7cbd3124a7973a240f424d77c4e2242124
5
5
  SHA512:
6
- metadata.gz: d8eba2fb2c46debbb076c8e2ede04ee6f15ec6d170332335660940ba3879e0d856887d6ef7c99b90d2ae228eed76c813a33c77ee164570a55764effe2921d185
7
- data.tar.gz: 56d61da20c0c8b8ab1f50ee08de53c381e77ca5822d2daf98f049619098430e11a8481817dd27ef1223841b51489a8d15a4df273323d3fbb603fd5c7cfbbdab3
6
+ metadata.gz: b4cf493d897ee0cd3adf167b36c0a2188bce2f48bb71bfd711ddaf2537d4a6eae3dc126a2eb8a66852f4f405e4b3b6e81879d10809d145bebd2cef1c02e9acac
7
+ data.tar.gz: fac89cecc8067a8a999f7bb972179c6f3c92b0f2d821491d13b8c27602ed1e8530b2cc99e2fcee473b4d039383897ab2048f9634f1d709c12a570eaaf58e4f9c
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ postnord
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.0
data/.travis.yml CHANGED
@@ -1,5 +1,17 @@
1
+ env:
2
+ global:
3
+ secure: Afcpwug4eQV5t+A/q19BM3Dm9i6K4J/7NaFEUy+Vo+YMXnYsAFl0DE0eJccW8SrLBa3j5tBbQE9Bl0Uup7K71gf2EjN5TKT0iOW59l4/g6Oe7mPESopVn+738nIyqH0Vk3G389K4YsgwbChHcxmUdAeLnKPX6H8nMk7LkZZVDhZPwp0xVgofmnj85b+mLQ4roNJr0CmpeO4t/hNXc6+IDg/lnH+rYrXb/hFdugv92SQCWqE486xuMa3Pmfjp+/wfYHcxSu/0DpPlsS/pBHtijc3ej41kMvCLXr08OWCDxdVqmpFjswNM6KL5Zl8FQmsjE7GreREXoY7S1KmtFefYS5bfmwbRK4LW6RmzqOO5pcIunRjTC7c6sABM8R7heSz3P48Nqdy8W8ikWKptwolIbTxVoqLoYUlNBoCcGIElSeRXTUQrDwFzMzSsbIZPFHv/Z9rXv3ES0QjXDfKHINqwK2eqJBnbbZOntsIIK/gnWS5cn8B/uWtTi6bODkEkSASLDw6NMI5srZb8Qp74cNufBm7TuzcWVaNork0PANtqnD5uKbu4KB+qghqUUs+pukBniHJScXC1+DGBEKHcGaAusOkGa5Zz1bwSvBjsgUPny/rUAT7sB5139ukET+k64DfYDhHX5eWajtwvAnlmICvFS2xpBjawaB3yQrqn6H8R8vQ=
1
4
  sudo: false
2
5
  language: ruby
6
+ cache: bundler
3
7
  rvm:
4
- - 2.1.5
5
- before_install: gem install bundler -v 1.12.3
8
+ - 2.5.1
9
+ - 2.7.0
10
+ before_script:
11
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
12
+ - chmod +x ./cc-test-reporter
13
+ - ./cc-test-reporter before-build
14
+ script:
15
+ - bundle exec rake
16
+ after_script:
17
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/README.md CHANGED
@@ -37,7 +37,6 @@ How to fetch a package with the test identifier from [developer documentation](h
37
37
  ```ruby
38
38
  > response = Postnord.find_by_identifier('84971563697SE')
39
39
  > response.code # => 200
40
- > response.status # => OK
41
40
  > response.data # => {"TrackingInformationResponse"=>{"shipments"=>[]}}
42
41
  ```
43
42
 
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('::').last.tap { |e| e[0] = e[0].downcase }
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, 'mandatory_params'
30
+ fail NotImplementedError, "mandatory_params"
31
31
  end
32
32
 
33
33
  def self.endpoint
34
- fail NotImplementedError, 'endpoint'
34
+ fail NotImplementedError, "endpoint"
35
+ end
36
+
37
+ def self.options
38
+ {}
35
39
  end
36
40
  end
37
41
  end
@@ -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[:return_type] || Config.return_type
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={})
@@ -18,11 +22,8 @@ module Postnord
18
22
  )
19
23
 
20
24
  uri.query = URI.encode_www_form(params)
21
- req = Net::HTTP::Get.new(uri)
22
25
 
23
- res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
24
- http.request(req)
25
- end
26
+ res = Faraday.get(uri)
26
27
 
27
28
  Response.new(res)
28
29
  end
@@ -30,13 +31,13 @@ module Postnord
30
31
  private
31
32
 
32
33
  def build_uri(service, endpoint)
33
- URI(
34
- @api_endpoint +
35
- '/' + service +
36
- '/' + @api_version +
37
- '/' + endpoint +
38
- '.' + @return_type
39
- )
34
+ url = @api_endpoint +
35
+ "/" + service +
36
+ "/" + @api_version +
37
+ "/" + endpoint
38
+ url += "." + @return_type if @return_type
39
+
40
+ URI(url)
40
41
  end
41
42
  end
42
43
  end
@@ -1,17 +1,10 @@
1
1
  module Postnord
2
2
  class Response
3
+ attr_reader :code
4
+
3
5
  def initialize(data)
4
6
  @data = data
5
- @code = data.code
6
- @status = data.msg
7
- end
8
-
9
- def code
10
- @data.code
11
- end
12
-
13
- def status
14
- @data.status
7
+ @code = data.status
15
8
  end
16
9
 
17
10
  def data
@@ -22,8 +15,7 @@ module Postnord
22
15
 
23
16
  def to_h
24
17
  {
25
- code: @code,
26
- status: @status,
18
+ code: code,
27
19
  data: data,
28
20
  }
29
21
  end
@@ -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
  [
@@ -1,3 +1,3 @@
1
1
  module Postnord
2
- VERSION = "0.2.3"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/postnord.rb CHANGED
@@ -1,6 +1,5 @@
1
+ require 'faraday'
1
2
  require 'uri'
2
- require 'net/http'
3
- require 'net/https'
4
3
  require 'json'
5
4
  require 'openssl'
6
5
 
data/postnord.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'postnord/version'
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's API}
13
- spec.homepage = 'https://github.com/apoex/postnord'
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,8 +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_development_dependency "bundler", "~> 1.12"
22
- spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_dependency "faraday"
22
+ spec.add_development_dependency "webmock"
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "rake", ">= 10.0"
23
25
  spec.add_development_dependency "rspec", "~> 3.0"
24
- spec.add_development_dependency "simplecov"
26
+ spec.add_development_dependency "pry-byebug"
27
+ spec.add_development_dependency "pry-byebyebug"
28
+ spec.add_development_dependency "simplecov", "~> 0.17.1"
25
29
  end
metadata CHANGED
@@ -1,41 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postnord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
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: 2016-11-21 00:00:00.000000000 Z
11
+ date: 2023-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: webmock
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: bundler
15
43
  requirement: !ruby/object:Gem::Requirement
16
44
  requirements:
17
- - - "~>"
45
+ - - ">="
18
46
  - !ruby/object:Gem::Version
19
- version: '1.12'
47
+ version: '0'
20
48
  type: :development
21
49
  prerelease: false
22
50
  version_requirements: !ruby/object:Gem::Requirement
23
51
  requirements:
24
- - - "~>"
52
+ - - ">="
25
53
  - !ruby/object:Gem::Version
26
- version: '1.12'
54
+ version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rake
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
- - - "~>"
59
+ - - ">="
32
60
  - !ruby/object:Gem::Version
33
61
  version: '10.0'
34
62
  type: :development
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
- - - "~>"
66
+ - - ">="
39
67
  - !ruby/object:Gem::Version
40
68
  version: '10.0'
41
69
  - !ruby/object:Gem::Dependency
@@ -53,7 +81,21 @@ dependencies:
53
81
  - !ruby/object:Gem::Version
54
82
  version: '3.0'
55
83
  - !ruby/object:Gem::Dependency
56
- name: simplecov
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
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
101
  - - ">="
@@ -66,7 +108,21 @@ dependencies:
66
108
  - - ">="
67
109
  - !ruby/object:Gem::Version
68
110
  version: '0'
69
- description:
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.17.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.17.1
125
+ description:
70
126
  email:
71
127
  - stefan.ahman@apoex.se
72
128
  executables: []
@@ -75,6 +131,8 @@ extra_rdoc_files: []
75
131
  files:
76
132
  - ".gitignore"
77
133
  - ".rspec"
134
+ - ".ruby-gemset"
135
+ - ".ruby-version"
78
136
  - ".simplecov"
79
137
  - ".travis.yml"
80
138
  - Gemfile
@@ -97,7 +155,7 @@ homepage: https://github.com/apoex/postnord
97
155
  licenses:
98
156
  - MIT
99
157
  metadata: {}
100
- post_install_message:
158
+ post_install_message:
101
159
  rdoc_options: []
102
160
  require_paths:
103
161
  - lib
@@ -112,9 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
170
  - !ruby/object:Gem::Version
113
171
  version: '0'
114
172
  requirements: []
115
- rubyforge_project:
116
- rubygems_version: 2.5.1
117
- signing_key:
173
+ rubygems_version: 3.1.2
174
+ signing_key:
118
175
  specification_version: 4
119
- summary: A gem for Postnord's API
176
+ summary: A gem for Postnord"s API
120
177
  test_files: []