Sha256: 43929595d0595d104fb38e245d913af9dc9dbbd13c35a6e0f1555fdd814418f3

Contents?: true

Size: 821 Bytes

Versions: 3

Compression:

Stored size: 821 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, headers: { 'Content-Type' => 'application/json' }
      RecursiveOpenStruct.new(response.parsed, recurse_over_arrays: true)
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
parcel_api-1.1.1 lib/parcel_api/pickup.rb
parcel_api-1.1.0 lib/parcel_api/pickup.rb
parcel_api-1.0.0 lib/parcel_api/pickup.rb