Class: Bosta::Pickup
- Inherits:
-
Object
- Object
- Bosta::Pickup
- Defined in:
- lib/bosta/pickups/pickup.rb
Overview
Find, create, update, and delete pickups
Class Method Summary collapse
-
.create(business_location_id, scheduled_date, scheduled_time_slot, contact_person, notes = nil) ⇒ Object
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. -
.delete_pickup(pickup_id) ⇒ Object
-
delete specific pickup using
pickup_id
.
-
-
.find_pickup_by_id(pickup_id) ⇒ Object
-
retrieve specific pickup using
pickup_id
.
-
-
.find_pickup_locations ⇒ Object
-
get all your pickup locations that you will use in creating pickups.
-
-
.find_pickups(page_id = 0) ⇒ Object
-
get all your created pickups.
-
-
.update(pickup_id, business_location_id = nil, scheduled_date = nil, scheduled_time_slot = nil, contact_person = nil, notes = nil) ⇒ Object
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.
Class Method Details
.create(business_location_id, scheduled_date, scheduled_time_slot, contact_person, notes = nil) ⇒ Object
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
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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) ⇒ Object
-
delete specific pickup using
pickup_id
93 94 95 |
# 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) ⇒ Object
-
retrieve specific pickup using
pickup_id
85 86 87 |
# 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 ⇒ Object
-
get all your pickup locations that you will use in creating pickups
69 70 71 |
# 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) ⇒ Object
-
get all your created pickups
77 78 79 |
# 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) ⇒ Object
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
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# 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 |