Class: ParcelApi::Notification
- Inherits:
-
Object
- Object
- ParcelApi::Notification
- Defined in:
- lib/parcel_api/notification.rb
Overview
Creates a PCD (collection point) subscription with provided delivery email address and tracking reference. Customers will receive an email when the parcel reaches the collection point and then subsequent reminders.
Constant Summary collapse
- PARCELNOTIFICATION_URL =
'/parcelnotifications/v1/subscription/pcd'
Instance Method Summary collapse
-
#create(notification_options)
Create a new parcel notification.
-
#initialize(connection = nil) ⇒ Notification
constructor
Creates a new ParcelApi::Notification instance.
Constructor Details
#initialize(connection = nil) ⇒ Notification
Creates a new ParcelApi::Notification instance.
12 13 14 |
# File 'lib/parcel_api/notification.rb', line 12
def initialize(connection=nil)
@connection ||= connection || ParcelApi::Client.connection
end
|
Instance Method Details
#create(notification_options)
Create a new parcel notification
20 21 22 23 |
# File 'lib/parcel_api/notification.rb', line 20
def create(notification_options)
response = @connection.post PARCELNOTIFICATION_URL, body: notification_options.to_json.to_ascii, headers: { 'Content-Type' => 'application/json' }
RecursiveOpenStruct.new(response.parsed, recurse_over_arrays: true)
end
|