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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdcd9ebea24a37f29ed1417078791e96ae59470b
4
- data.tar.gz: 10626cce08a88d97bd32692ad2aeb0eb3b67f095
3
+ metadata.gz: e278f6f435884f1fbb1a9cd7995ea76d3abe62d0
4
+ data.tar.gz: b15d8b9a3817821c4f2d9cb9d4ac26e014d45772
5
5
  SHA512:
6
- metadata.gz: f959eed9357c58808b3305f5f5fbfb58fb32c7eec335c9614f40a9848af2d88bf02878fe0315478f13800e951428c4a1c9760373eb3555aad2831160607bc9e4
7
- data.tar.gz: add3bf34df5be59889a28e7f091ac70547903f07fd914e7f671da025e149202d9be28679a909eaffbee0589dab2c72a3f96d8a6f58c86a1a1e45ab2d7d3b9a62
6
+ metadata.gz: 321f295e0e881ebe615e1bb1b565c47a816fafaf0a9b4123ea9f59eef47790d816f690855733560d54f0641296ec717a847ae134668a729a54b1c083fc99f969
7
+ data.tar.gz: 935c5fcc08fd7de9874371060bd5aa7aa505abe166d3032d28162b02714dcf422e6ef8522a3a18cce25bdb0de0ffcaed12cba2f27218d7824ebfbb65185579bb
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parcel_api (1.0.0)
4
+ parcel_api (1.1.0)
5
5
  activesupport (~> 4.2)
6
6
  oauth2 (~> 1.0)
7
7
  recursive-open-struct (~> 0.6)
@@ -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}"}
@@ -6,6 +6,7 @@ require 'parcel_api/track'
6
6
  require 'parcel_api/label'
7
7
  require 'parcel_api/shipping_options'
8
8
  require 'parcel_api/pickup'
9
+ require 'parcel_api/notification'
9
10
  require 'parcel_api/client'
10
11
 
11
12
  module ParcelApi; end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ParcelApi
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
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.0.0
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-09-28 00:00:00.000000000 Z
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