parcel_api 1.0.0 → 1.1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/example/mock.rb +14 -0
- data/lib/parcel_api.rb +1 -0
- data/lib/parcel_api/notification.rb +27 -0
- data/lib/parcel_api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e278f6f435884f1fbb1a9cd7995ea76d3abe62d0
|
4
|
+
data.tar.gz: b15d8b9a3817821c4f2d9cb9d4ac26e014d45772
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 321f295e0e881ebe615e1bb1b565c47a816fafaf0a9b4123ea9f59eef47790d816f690855733560d54f0641296ec717a847ae134668a729a54b1c083fc99f969
|
7
|
+
data.tar.gz: 935c5fcc08fd7de9874371060bd5aa7aa505abe166d3032d28162b02714dcf422e6ef8522a3a18cce25bdb0de0ffcaed12cba2f27218d7824ebfbb65185579bb
|
data/Gemfile.lock
CHANGED
data/example/mock.rb
CHANGED
@@ -265,3 +265,17 @@ pickup_params = {
|
|
265
265
|
pickup = ParcelApi::Pickup.new(client.connection) # use a custom connection
|
266
266
|
pickup_results = pickup.create(pickup_params)
|
267
267
|
pickup_results.to_h.each {|k, v| puts "#{k}: #{v}"}
|
268
|
+
|
269
|
+
# Notification Example
|
270
|
+
|
271
|
+
notification_params = {
|
272
|
+
tracking_reference: 'LE123454152NZ',
|
273
|
+
email: 'j.receiver@example.com',
|
274
|
+
receiver_first_name: 'John',
|
275
|
+
receiver_last_name: 'Receiver',
|
276
|
+
collection_location_id: '84320',
|
277
|
+
}
|
278
|
+
|
279
|
+
notification = ParcelApi::Notification.new
|
280
|
+
notification_results = notification.create(notification_params)
|
281
|
+
notification_results.to_h.each {|k, v| puts "#{k}: #{v}"}
|
data/lib/parcel_api.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
module ParcelApi
|
2
|
+
|
3
|
+
# Creates a PCD (collection point) subscription with provided delivery email address
|
4
|
+
# and tracking reference. Customers will receive an email when the parcel reaches the
|
5
|
+
# collection point and then subsequent reminders.
|
6
|
+
|
7
|
+
class Notification
|
8
|
+
PARCELNOTIFICATION_URL = '/parcelnotifications/v1/subscription/pcd'
|
9
|
+
|
10
|
+
# Creates a new ParcelApi::Notification instance.
|
11
|
+
|
12
|
+
def initialize(connection=nil)
|
13
|
+
@connection ||= connection || ParcelApi::Client.connection
|
14
|
+
end
|
15
|
+
|
16
|
+
# Create a new parcel notification
|
17
|
+
# @param notification_options [Hash]
|
18
|
+
# @return Object of notification details
|
19
|
+
|
20
|
+
def create(notification_options)
|
21
|
+
response = @connection.post PARCELNOTIFICATION_URL, body: notification_options.to_json, headers: { 'Content-Type' => 'application/json' }
|
22
|
+
RecursiveOpenStruct.new(response.parsed, recurse_over_arrays: true)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/parcel_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parcel_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Coleman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- lib/parcel_api/cli.rb
|
204
204
|
- lib/parcel_api/client.rb
|
205
205
|
- lib/parcel_api/label.rb
|
206
|
+
- lib/parcel_api/notification.rb
|
206
207
|
- lib/parcel_api/pickup.rb
|
207
208
|
- lib/parcel_api/shipping_options.rb
|
208
209
|
- lib/parcel_api/track.rb
|