dhl_api 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b9e7851e32f915f557f1f81c90d0e2b7b9ef7f5eae20e9d8613ccff62de0d77
4
- data.tar.gz: 3888aef749658440d8190416d2ff1b82e5b725b974f6634457ab40d7e9d952ea
3
+ metadata.gz: 38fd924f15b98dc8f683c50ae9f377b7d79ab3dec1f0cbfc5d3641653a51350d
4
+ data.tar.gz: 1d7d0afcf7949e90026ea3b2ee81912423f3c61a71f6a3b97b7b36082a29d56f
5
5
  SHA512:
6
- metadata.gz: 286fd63847484916402a2ad6edb8f67325e283fd22f48415e91279bad0ad1b38310ffb4ca85757f556a86aa4aff2692163698ce59ce32dc1d522e7932b6bd29a
7
- data.tar.gz: 617b1f4841fe8721f79e7210485bd74b53452330304a1663b21fc45eab66fe1bdd763e671a4d9a876adb75fe6d4b01187bf1922ecddfdb85f2f603b3f60b397d
6
+ metadata.gz: 12709605fc3a4c59c9be84afd4764c14d72c75b88e544d77436f7b670bd89bbc90e7e84aa1f1d505d0201cd2289f847336066a32d75713f0b04ca49469eb5715
7
+ data.tar.gz: d65f5bdeae686f719320815e817b183ccaca6be69869919600c754fc11f779b0a5f6002fff557e93e89818f89258a853364f10446b7a6e07d2c7c166b9b396e3
data/Gemfile CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- # Specify your gem's dependencies in dhl.gemspec
5
+ # Specify your gem's dependencies in dhl_api.gemspec
6
6
  gemspec
7
7
 
8
8
  gem 'rake', '~> 13.0'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dhl (0.1.0)
4
+ dhl_api (0.1.0)
5
5
  activesupport (>= 4.0.2)
6
6
  http (~> 5.0)
7
7
 
@@ -142,7 +142,7 @@ PLATFORMS
142
142
  arm64-darwin-21
143
143
 
144
144
  DEPENDENCIES
145
- dhl!
145
+ dhl_api!
146
146
  dotenv
147
147
  gem-release
148
148
  guard-rspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # DHL
1
+ # DHLAPI
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dhl`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dhl_api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
5
5
  TODO: Delete this and the text above, and describe your gem
6
6
 
@@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'dhl'
12
+ gem 'dhl_api'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -18,25 +18,25 @@ And then execute:
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- $ gem install dhl
21
+ $ gem install dhl_api
22
22
 
23
23
  ## Usage
24
24
 
25
25
  ```ruby
26
- DHL.configure do |config|
26
+ DHLAPI.configure do |config|
27
27
  config.api_key = "your api key"
28
28
  config.testing = true # or false
29
29
  end
30
30
 
31
- # DHL Retoure
31
+ # DHL Retoure (https://developer.dhl.com/api-reference/dhl-parcel-de-returns-post-parcel-germany)
32
32
  #
33
- retoure_client = DHL::RetoureClient.new(username: 'retoure username', password: 'retoure password')
33
+ retoure_client = DHLAPI::RetoureClient.new(username: 'retoure username', password: 'retoure password')
34
34
  #
35
35
  # OR if you only creating label for 1 account all the time,
36
- # you can set the ENV variables: DHL_RETOURE_USERNAME, DHL_RETOURE_PASSWORD,
36
+ # you can set the ENV variables: DHLAPI_RETOURE_USERNAME, DHLAPI_RETOURE_PASSWORD,
37
37
  # and then just initialize the client like below:
38
38
  #
39
- # retoure_client = DHL::RetoureClient.new
39
+ # retoure_client = DHLAPI::RetoureClient.new
40
40
 
41
41
  label = retoure_client.create_label(
42
42
  "receiver_id": 'deu',
@@ -49,7 +49,7 @@ label = retoure_client.create_label(
49
49
  "address_street": 'Charles-de-Gaulle Str.',
50
50
  "address_house": '20',
51
51
  "city": 'Bonn',
52
- "email": 'Max.Mustermann@dhl.local',
52
+ "email": 'Max.Mustermann@dhl_api.local',
53
53
  "phone": '+49 421 987654321',
54
54
  "postal_code": '53113',
55
55
  "state": 'NRW'
@@ -64,11 +64,11 @@ label = retoure_client.create_label(
64
64
  }
65
65
  )
66
66
 
67
- # DHL Tracking
67
+ # Tracking (https://developer.dhl.com/api-reference/shipment-tracking)
68
68
  #
69
- track_client=DHL::TrackingClient.new
69
+ track_client=DHLAPI::TrackingClient.new
70
70
  # Also accept service:, origin_country_code:, requester_country_code:
71
- tracking = track_client.track(tracking_number: 611665700181)
71
+ tracking = track_client.track(tracking_number: '420025369374810912402173942693')
72
72
 
73
73
  # You can access the raw response by calling by calling the #response:
74
74
  retoure_client.response
@@ -88,7 +88,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
88
88
 
89
89
  ## Contributing
90
90
 
91
- Bug reports and pull requests are welcome on GitHub at https://github.com/postco/dhl. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/postco/dhl/blob/main/CODE_OF_CONDUCT.md).
91
+ Bug reports and pull requests are welcome on GitHub at https://github.com/postco/dhl_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/postco/dhl_api/blob/main/CODE_OF_CONDUCT.md).
92
92
 
93
93
  ## License
94
94
 
@@ -96,4 +96,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
96
96
 
97
97
  ## Code of Conduct
98
98
 
99
- Everyone interacting in the DHL project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/postco/dhl/blob/main/CODE_OF_CONDUCT.md).
99
+ Everyone interacting in the DHLAPI project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/postco/dhl_api/blob/main/CODE_OF_CONDUCT.md).
data/bin/console CHANGED
@@ -6,7 +6,7 @@ require 'bundler/setup'
6
6
  require 'dotenv/load'
7
7
  require 'dev/zeitwerk_loader'
8
8
  require 'dev/config'
9
- require 'dhl'
9
+ require 'dhl_api'
10
10
 
11
11
  # You can add fixtures and/or initialization code here to make experimenting
12
12
  # with your gem easier. You can also use a different console, if you like.
data/lib/dev/config.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'dotenv/load'
2
2
 
3
3
  def set_config
4
- DHL.configure do |config|
4
+ DHLAPI.configure do |config|
5
5
  config.api_key = ENV['API_KEY']
6
6
  end
7
7
  end
@@ -3,11 +3,11 @@ require_relative 'config'
3
3
 
4
4
  loader = Zeitwerk::Loader.for_gem
5
5
  loader.inflector.inflect(
6
- 'dhl' => 'DHL'
6
+ 'dhl_api' => 'DHLAPI'
7
7
  )
8
8
  loader.push_dir('./lib')
9
- loader.collapse('./lib/dhl/clients')
10
- loader.collapse('./lib/dhl/objects')
9
+ loader.collapse('./lib/dhl_api/clients')
10
+ loader.collapse('./lib/dhl_api/objects')
11
11
  loader.ignore("#{__dir__}/config.rb")
12
12
  loader.enable_reloading
13
13
  # loader.log!
@@ -1,12 +1,12 @@
1
1
  require 'http'
2
2
 
3
- module DHL
3
+ module DHLAPI
4
4
  class BaseClient
5
5
  attr_writer :http_client
6
6
  attr_reader :response
7
7
 
8
8
  def connection
9
- @connection ||= HTTP.headers(content_type: 'application/json', dhl_api_key: DHL.config.api_key)
9
+ @connection ||= HTTP.headers(content_type: 'application/json', dhl_api_key: DHLAPI.config.api_key)
10
10
  end
11
11
 
12
12
  private
@@ -14,7 +14,7 @@ module DHL
14
14
  attr_writer :response
15
15
 
16
16
  def url
17
- DHL.config.testing ? self.class::TEST_URL : self.class::URL
17
+ DHLAPI.config.testing ? self.class::TEST_URL : self.class::URL
18
18
  end
19
19
 
20
20
  def handle_response
@@ -33,7 +33,7 @@ module DHL
33
33
  raise Error, "The API rate limit for your application has been exceeded. #{error_message}"
34
34
  when 500
35
35
  raise Error,
36
- "An unhandled error with the . Contact the DHL team if problems persist. #{error_message}"
36
+ "An unhandled error with the . Contact the DHLAPI team if problems persist. #{error_message}"
37
37
  when 503
38
38
  raise Error,
39
39
  "API is currently unavailable – typically due to a scheduled outage – try again soon. #{error_message}"
@@ -1,4 +1,4 @@
1
- module DHL
1
+ module DHLAPI
2
2
  class RetoureClient < BaseClient
3
3
  URL = 'https://api-eu.dhl.com/parcel/de/shipping/returns/v1/orders'
4
4
  TEST_URL = 'https://api-sandbox.dhl.com/parcel/de/shipping/returns/v1/orders'
@@ -28,11 +28,11 @@ module DHL
28
28
  private
29
29
 
30
30
  def username
31
- @username ||= ENV['DHL_RETOURE_USERNAME']
31
+ @username ||= ENV['DHLAPI_RETOURE_USERNAME']
32
32
  end
33
33
 
34
34
  def password
35
- @password ||= ENV['DHL_RETOURE_PASSWORD']
35
+ @password ||= ENV['DHLAPI_RETOURE_PASSWORD']
36
36
  end
37
37
  end
38
38
  end
@@ -1,4 +1,4 @@
1
- module DHL
1
+ module DHLAPI
2
2
  class TrackingClient < BaseClient
3
3
  URL = 'https://api-eu.dhl.com/track/shipments'
4
4
  TEST_URL = 'https://api-test.dhl.com/track/shipments'
@@ -1,4 +1,4 @@
1
- module DHL
1
+ module DHLAPI
2
2
  class Configuration
3
3
  attr_accessor :api_key, :testing
4
4
  end
@@ -16,7 +16,7 @@ module DHL
16
16
  def after_configure
17
17
  config.testing ||= false
18
18
 
19
- # register special mime type for DHL error responses
19
+ # register special mime type for DHLAPI error responses
20
20
  HTTP::MimeType.register_adapter 'application/problem+json', HTTP::MimeType::JSON
21
21
  end
22
22
  end
@@ -1,3 +1,3 @@
1
- module DHL
1
+ module DHLAPI
2
2
  class Error < StandardError; end
3
3
  end
@@ -1,4 +1,4 @@
1
- module DHL
1
+ module DHLAPI
2
2
  class BaseObject < OpenStruct
3
3
  attr_reader :attributes
4
4
 
@@ -1,4 +1,4 @@
1
- module DHL
1
+ module DHLAPI
2
2
  class RetoureLabel < BaseObject
3
3
  end
4
4
  end
@@ -1,4 +1,4 @@
1
- module DHL
1
+ module DHLAPI
2
2
  class Tracking < BaseObject
3
3
  end
4
4
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module DHL
4
- VERSION = '0.1.0'
3
+ module DHLAPI
4
+ VERSION = '0.1.1'
5
5
  end
data/lib/dhl_api.rb ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'dhl_api/version'
4
+ require 'active_support/core_ext/hash/keys'
5
+ require 'active_support/core_ext/string/inflections'
6
+
7
+ require 'http'
8
+
9
+ module DHLAPI
10
+ require 'dhl_api/configuration'
11
+
12
+ autoload :Error, 'dhl_api/error'
13
+
14
+ autoload :BaseClient, 'dhl_api/clients/base_client'
15
+ autoload :RetoureClient, 'dhl_api/clients/retoure_client'
16
+ autoload :TrackingClient, 'dhl_api/clients/tracking_client'
17
+
18
+ autoload :BaseObject, 'dhl_api/objects/base_object'
19
+ autoload :RetoureLabel, 'dhl_api/objects/retoure_label'
20
+ autoload :Tracking, 'dhl_api/objects/tracking'
21
+ end
data/sig/dhl_api.rbs CHANGED
@@ -1,4 +1,4 @@
1
- module DHL
1
+ module DHLAPI
2
2
  VERSION: String
3
3
  # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dhl_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Chong
@@ -143,25 +143,25 @@ files:
143
143
  - bin/setup
144
144
  - lib/dev/config.rb
145
145
  - lib/dev/zeitwerk_loader.rb
146
- - lib/dhl.rb
147
- - lib/dhl/clients/base_client.rb
148
- - lib/dhl/clients/retoure_client.rb
149
- - lib/dhl/clients/tracking_client.rb
150
- - lib/dhl/configuration.rb
151
- - lib/dhl/error.rb
152
- - lib/dhl/objects/base_object.rb
153
- - lib/dhl/objects/retoure_label.rb
154
- - lib/dhl/objects/tracking.rb
155
- - lib/dhl/version.rb
146
+ - lib/dhl_api.rb
147
+ - lib/dhl_api/clients/base_client.rb
148
+ - lib/dhl_api/clients/retoure_client.rb
149
+ - lib/dhl_api/clients/tracking_client.rb
150
+ - lib/dhl_api/configuration.rb
151
+ - lib/dhl_api/error.rb
152
+ - lib/dhl_api/objects/base_object.rb
153
+ - lib/dhl_api/objects/retoure_label.rb
154
+ - lib/dhl_api/objects/tracking.rb
155
+ - lib/dhl_api/version.rb
156
156
  - sig/dhl_api.rbs
157
- homepage: https://github.com/PostCo/dhl
157
+ homepage: https://github.com/PostCo/dhl_api
158
158
  licenses:
159
159
  - MIT
160
160
  metadata:
161
161
  allowed_push_host: https://rubygems.org
162
- homepage_uri: https://github.com/PostCo/dhl
163
- source_code_uri: https://github.com/PostCo/dhl
164
- changelog_uri: https://github.com/PostCo/dhl/blob/main/CHANGELOG.md
162
+ homepage_uri: https://github.com/PostCo/dhl_api
163
+ source_code_uri: https://github.com/PostCo/dhl_api
164
+ changelog_uri: https://github.com/PostCo/dhl_api/blob/main/CHANGELOG.md
165
165
  post_install_message:
166
166
  rdoc_options: []
167
167
  require_paths:
@@ -180,5 +180,5 @@ requirements: []
180
180
  rubygems_version: 3.2.32
181
181
  signing_key:
182
182
  specification_version: 4
183
- summary: Ruby API Wrapper for DHL
183
+ summary: Ruby API Wrapper for DHL API
184
184
  test_files: []
data/lib/dhl.rb DELETED
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'dhl/version'
4
- require 'active_support/core_ext/hash/keys'
5
- require 'active_support/core_ext/string/inflections'
6
-
7
- require 'http'
8
-
9
- module DHL
10
- require 'dhl/configuration'
11
-
12
- autoload :Error, 'dhl/error'
13
-
14
- autoload :BaseClient, 'dhl/clients/base_client'
15
- autoload :RetoureClient, 'dhl/clients/retoure_client'
16
- autoload :TrackingClient, 'dhl/clients/tracking_client'
17
-
18
- autoload :BaseObject, 'dhl/objects/base_object'
19
- autoload :RetoureLabel, 'dhl/objects/retoure_label'
20
- autoload :Tracking, 'dhl/objects/tracking'
21
-
22
- end