Sha256: 4488e1da87a45746e7a625d9bb283de6975bb097940e4fff627094f27d2d1646

Contents?: true

Size: 830 Bytes

Versions: 2

Compression:

Stored size: 830 Bytes

Contents

module ParcelApi

  # The ParcelPickUp API that notifies PACE or CourierPost to come and pick up your parcel.
  # The integrator provides the pick up location in the form of a site id or an address to create the pick up record.

  class Pickup
    PARCELPICKUP_URL = '/ParcelPickUp/3.0/bookings'

    # Creates a new ParcelApi::Pickup instance.

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

    # Create a new parcel booking
    # @param pickup_options [Hash]
    # @return Object of pickup details

    def create(pickup_options)
      response = @connection.post PARCELPICKUP_URL, body: pickup_options.to_json.to_ascii, 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.2.1 lib/parcel_api/pickup.rb
parcel_api-1.2.0 lib/parcel_api/pickup.rb