Sha256: dc90e3513fef5e609a09f6fed486e61c0d515f31bbd5185012a9be1b12e44863

Contents?: true

Size: 905 Bytes

Versions: 2

Compression:

Stored size: 905 Bytes

Contents

module ParcelApi

  # 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.

  class Notification
    PARCELNOTIFICATION_URL = '/parcelnotifications/v1/subscription/pcd'

    # Creates a new ParcelApi::Notification instance.

    def initialize(connection=nil)
      @connection ||= connection || ParcelApi::Client.connection
    end

    # Create a new parcel notification
    # @param notification_options [Hash]
    # @return Object of notification details

    def create(notification_options)
      response = @connection.post PARCELNOTIFICATION_URL, body: notification_options.to_json, headers: { 'Content-Type' => 'application/json' }
      RecursiveOpenStruct.new(response.parsed, recurse_over_arrays: true)
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parcel_api-1.1.1 lib/parcel_api/notification.rb
parcel_api-1.1.0 lib/parcel_api/notification.rb