dpd_ie_api 0.2.1 → 0.3.0

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: cb11635fe7a354bb8985d5edb82b4e61ae916ed43010849df6add2ef62d6c439
4
- data.tar.gz: f29f052b67496fd4558640cc53bbaf381ff8e6e8baaaa94cb1bb57079d6d3e96
3
+ metadata.gz: 6b5b88bb8e13571ef8c0c054f91249ce27b2e8b96c150502f7c221857f3ee8ee
4
+ data.tar.gz: bd6ca4477ced7a57505a6160505a9f21da1a375745bed39aeb62b64265f0a58c
5
5
  SHA512:
6
- metadata.gz: 11361928734bebad3eeb835f74cc7c2c3801010617f417fdb9c7187966ef12d8f25f0072c633ae2edea68580516ae160bc35b128604fba54ede9867819c735b0
7
- data.tar.gz: 6c2fb2b988f85e0e0cda8fa5f5aa54209c5ad675b863361ccf647538c68571f1e17f6ead4493e8bf870122800dc1d58985293e10fcd4ec98ce6b9ed4e75725ff
6
+ metadata.gz: d0d6555fc183eae6676c651aab5c4a2c31767db9d83cd071c2604d88c15a7a1f831bc5cbe16601570f8ba46e5d185cb47fb886c095f17b71a4ecbec57f6ab826
7
+ data.tar.gz: 1a95e8bbcd680bfba8759a01ca8b20d2cea89f75156a6b5bfe9bf71c3d86ed784ddc0ff39166ee51967932635469af7e7b61e3a1595343dd85f9dfaf4ddb78d5
data/README.md CHANGED
@@ -20,11 +20,12 @@ gem install dpd_ie_api
20
20
 
21
21
  The gem provides a **uniform Ruby interface** across all endpoints. You always work with Ruby hashes and objects — the gem picks the best format (JSON or XML) for each endpoint internally:
22
22
 
23
- | Endpoint | Request Format | Response Format |
24
- |----------|---------------|-----------------|
25
- | Authorize | JSON | JSON |
26
- | PreAdvice | XML | XML |
27
- | Track | XML | JSON |
23
+ | Endpoint | Request Format | Response Format |
24
+ | --------- | -------------- | --------------- |
25
+ | Authorize | JSON | JSON |
26
+ | PreAdvice | XML | XML |
27
+ | Track | XML | JSON |
28
+ | Locator | JSON | JSON |
28
29
 
29
30
  JSON is used wherever the DPD API supports it (simpler, no XML parsing overhead). XML is used only where the API requires it. This is entirely invisible to gem consumers.
30
31
 
@@ -161,6 +162,48 @@ The `tracking_type` defaults to `"consignment"` but can be overridden:
161
162
  tracking = client.track.find("800436802", tracking_type: "parcel")
162
163
  ```
163
164
 
165
+ ### Locator
166
+
167
+ #### List
168
+
169
+ Retrieve DPD Ireland drop-off locations. Test and deactivated locations are automatically filtered out.
170
+
171
+ ```ruby
172
+ locations = client.locator.list
173
+
174
+ locations.each do |location|
175
+ puts location.location_name
176
+ puts location.location_type # "Pickup" or "Depot" or "Locker"
177
+ puts location.location_id
178
+ puts location.location_address_line1
179
+ puts location.location_code
180
+ puts location.county
181
+ puts location.country
182
+ puts location.gps_lat
183
+ puts location.gps_long
184
+ puts location.depot_no
185
+ puts location.province
186
+ puts location.facilities
187
+ puts location.group_pudo_id
188
+ end
189
+ ```
190
+
191
+ Filter by type or specific location ID:
192
+
193
+ ```ruby
194
+ # Only depots
195
+ locations = client.locator.list(type: "Depot")
196
+
197
+ # Only pickups
198
+ locations = client.locator.list(type: "Pickup")
199
+
200
+ # Only lockers
201
+ locations = client.locator.list(type: "Locker")
202
+
203
+ # Specific location
204
+ locations = client.locator.list(location_id: "5308")
205
+ ```
206
+
164
207
  ### Response Objects
165
208
 
166
209
  All endpoints return response objects that provide:
@@ -30,5 +30,9 @@ module DpdIeApi
30
30
  def track
31
31
  Resources::Track.new(self)
32
32
  end
33
+
34
+ def locator
35
+ Resources::Locator.new(self)
36
+ end
33
37
  end
34
38
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DpdIeApi
4
+ module Objects
5
+ class Locator < Base
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module DpdIeApi
6
+ module Resources
7
+ class Locator
8
+ LOCATOR_PATH = '/common/api/dpdlocation'
9
+
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ def list(type: nil, location_id: nil)
15
+ response = post_request(type, location_id)
16
+ parsed = parse_response(response)
17
+ filter_locations(parsed)
18
+ end
19
+
20
+ private
21
+
22
+ def post_request(type, location_id)
23
+ response = @client.connection.post(LOCATOR_PATH) do |req|
24
+ req.headers['Content-Type'] = 'application/json'
25
+ req.headers['Accept'] = 'application/json'
26
+ req.body = {
27
+ 'CountryCode' => 'IE',
28
+ 'Type' => type.to_s,
29
+ 'LocationID' => location_id.to_s
30
+ }.to_json
31
+ end
32
+
33
+ unless response.success?
34
+ raise DpdIeApi::Error.new(
35
+ "Failed to fetch locations: #{response.status} - #{response.body}",
36
+ response_http_code: response.status,
37
+ response_body: response.body
38
+ )
39
+ end
40
+
41
+ response
42
+ end
43
+
44
+ def parse_response(response)
45
+ parsed = JSON.parse(response.body)
46
+
47
+ if parsed['Status'] != 'OK'
48
+ raise DpdIeApi::Error.new(
49
+ "Locator error: #{parsed['Status']}",
50
+ response_http_code: response.status,
51
+ response_body: response.body
52
+ )
53
+ end
54
+
55
+ parsed
56
+ end
57
+
58
+ def filter_locations(parsed)
59
+ locations = parsed['Location']
60
+ locations = [locations] if locations.is_a?(Hash)
61
+ locations = [] if locations.nil?
62
+
63
+ locations
64
+ .reject { |loc| loc['locationName']&.match?(/test|do not reactivate/i) }
65
+ .map { |loc| Objects::Locator.new(loc) }
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DpdIeApi
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
data/lib/dpd_ie_api.rb CHANGED
@@ -5,12 +5,14 @@ require_relative 'dpd_ie_api/objects/base'
5
5
  require_relative 'dpd_ie_api/objects/auth'
6
6
  require_relative 'dpd_ie_api/objects/preadvice'
7
7
  require_relative 'dpd_ie_api/objects/track'
8
+ require_relative 'dpd_ie_api/objects/locator'
8
9
  require_relative 'dpd_ie_api/xml_builder'
9
10
  require_relative 'dpd_ie_api/xml_parser'
10
11
  require_relative 'dpd_ie_api/auth'
11
12
  require_relative 'dpd_ie_api/client'
12
13
  require_relative 'dpd_ie_api/resources/preadvice'
13
14
  require_relative 'dpd_ie_api/resources/track'
15
+ require_relative 'dpd_ie_api/resources/locator'
14
16
 
15
17
  module DpdIeApi
16
18
  class Error < StandardError
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpd_ie_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linh Ho
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-03-16 00:00:00.000000000 Z
11
+ date: 2026-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -99,8 +99,10 @@ files:
99
99
  - lib/dpd_ie_api/client.rb
100
100
  - lib/dpd_ie_api/objects/auth.rb
101
101
  - lib/dpd_ie_api/objects/base.rb
102
+ - lib/dpd_ie_api/objects/locator.rb
102
103
  - lib/dpd_ie_api/objects/preadvice.rb
103
104
  - lib/dpd_ie_api/objects/track.rb
105
+ - lib/dpd_ie_api/resources/locator.rb
104
106
  - lib/dpd_ie_api/resources/preadvice.rb
105
107
  - lib/dpd_ie_api/resources/track.rb
106
108
  - lib/dpd_ie_api/version.rb