class Bosta::Pickup

Find, create, update, and delete pickups

Public Class Methods

create(business_location_id, scheduled_date, scheduled_time_slot, contact_person, notes = nil) click to toggle source

Create A new pickup

* +business_location_id+ should be on of your business locations ids
* +scheduled_date+ is the date to be scheduled for pickup
* +scheduled_time_slot+ should be one of TIME_SLOT_10_TO_13, TIME_SLOT_13_TO_16 in Bosta
* +contact_person+ should be of type ContactPerson
* +notes+ (optional) String
# File lib/bosta/pickups/pickup.rb, line 14
def self.create(business_location_id, scheduled_date, scheduled_time_slot, contact_person, notes = nil)
  unless contact_person.instance_of?(Bosta::ContactPerson)
    raise 'contact_person should be of Class Bosta::ContactPerson'
  end

  pickup_hash = {
    businessLocationId: business_location_id,
    scheduledDate: scheduled_date,
    scheduledTimeSlot: scheduled_time_slot,
    contactPerson: contact_person.format_obj
  }

  pickup_hash[:notes] = notes unless notes.nil?

  Bosta::Resource.send('post', 'pickups', pickup_hash)
end
delete_pickup(pickup_id) click to toggle source
  • delete specific pickup using pickup_id

# File lib/bosta/pickups/pickup.rb, line 93
def self.delete_pickup(pickup_id)
  Bosta::Resource.send('delete', "pickups/#{pickup_id}")
end
find_pickup_by_id(pickup_id) click to toggle source
  • retrieve specific pickup using pickup_id

# File lib/bosta/pickups/pickup.rb, line 85
def self.find_pickup_by_id(pickup_id)
  Bosta::Resource.send('get', "pickups/#{pickup_id}")
end
find_pickup_locations() click to toggle source
  • get all your pickup locations that you will use in creating pickups

# File lib/bosta/pickups/pickup.rb, line 69
def self.find_pickup_locations
  Bosta::Resource.send('get', 'pickup-locations')
end
find_pickups(page_id = 0) click to toggle source
  • get all your created pickups

# File lib/bosta/pickups/pickup.rb, line 77
def self.find_pickups(page_id = 0)
  Bosta::Resource.send('get', 'pickups', {}, { pageId: page_id })
end
update(pickup_id, business_location_id = nil, scheduled_date = nil, scheduled_time_slot = nil, contact_person = nil, notes = nil) click to toggle source

Edit A created pickup

* +pickup_id+ the id of the pickup to be updated
* +business_location_id+ (optional) should be on of your business locations ids
* +scheduled_date+ (optional) is the date to be scheduled for pickup
* +scheduled_time_slot+ (optional) should be one of TIME_SLOT_10_TO_13, TIME_SLOT_13_TO_16 in Bosta
* +contact_person+ (optional) should be of type ContactPerson
* +notes+ (optional) String
# File lib/bosta/pickups/pickup.rb, line 40
def self.update(pickup_id, business_location_id = nil,
                scheduled_date = nil,
                scheduled_time_slot = nil,
                contact_person = nil,
                notes = nil)

  unless contact_person.nil?
    unless contact_person.instance_of?(Bosta::ContactPerson)
      raise 'contact_person should be of Class Bosta::ContactPerson'
    end

    contact_person = contact_person.format_obj
  end
  pickup_hash = {
    businessLocationId: business_location_id,
    scheduledDate: scheduled_date,
    scheduledTimeSlot: scheduled_time_slot,
    contactPerson: contact_person,
    notes: notes
  }

  pickup_hash = pickup_hash.compact
  Bosta::Resource.send('put', "pickups/#{pickup_id}", pickup_hash)
end