Class: DeliveryChannel::CourierBase
- Inherits:
-
Object
- Object
- DeliveryChannel::CourierBase
show all
- Includes:
- DefaultErrorContainer
- Defined in:
- app/my_lib/delivery_channel/courier_base.rb
Overview
Class Method Summary
collapse
Instance Method Summary
collapse
#error, #error_message_simple, #merge_errors
Class Method Details
.country_to_iso(country_code) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 14
def self.country_to_iso(country_code)
case country_code
when 'TH'
'th_TH'
else
country_code
end
end
|
.generate_delivery_time(time_zone, date, start_time_format) ⇒ Object
23
24
25
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 23
def self.generate_delivery_time(time_zone, date, start_time_format)
"#{time_zone}:#{date}:#{start_time_format}"
end
|
Instance Method Details
#cancel_order(*args) ⇒ Object
39
40
41
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 39
def cancel_order(*args)
raise NotImplementedError
end
|
#cancel_order_from_reservation_later(reservation, skip_reorder: default_skip_reorder_value) ⇒ Object
remove delivery_channel_id from DeliveryAddress and destroy Driver
48
49
50
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 48
def cancel_order_from_reservation_later(reservation, skip_reorder: default_skip_reorder_value)
raise NotImplementedError
end
|
#destroy_reservation_driver(reservation) ⇒ Object
86
87
88
89
90
91
92
93
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 86
def destroy_reservation_driver(reservation)
reservation.update! driver_called: false
driver = reservation.driver
if driver && driver.persisted? && driver.order && driver.order.persisted? && !driver.order.frozen?
driver.order.destroy!
end
driver.destroy! if driver && driver.persisted? && !driver.frozen?
end
|
#driver_detail(*args) ⇒ Object
35
36
37
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 35
def driver_detail(*args)
raise NotImplementedError
end
|
#find_delivery_channel ⇒ Object
31
32
33
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 31
def find_delivery_channel
DeliveryChannel.fetch_by_lib_class(self.class.to_s)
end
|
#force_cancel_order(reservation, skip_reorder: default_skip_reorder_value) ⇒ Object
74
75
76
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 74
def force_cancel_order(reservation, skip_reorder: default_skip_reorder_value)
raise NotImplementedError
end
|
#generate_tracking_link(reservation) ⇒ Object
10
11
12
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 10
def generate_tracking_link(reservation)
raise NotImplementedError
end
|
#get_quotation_from_reservation(_reservation) ⇒ Object
Returns Hash :total_fee [String] :total_fee_currency [String].
55
56
57
58
59
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 55
def get_quotation_from_reservation(_reservation)
ActiveSupport::Deprecation.warn("#{self.class} doesn't implement get_quotation_from_reservation")
{ "total_fee": '0', "total_fee_currency": 'THB' }
end
|
#order_detail(*args) ⇒ Object
27
28
29
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 27
def order_detail(*args)
raise NotImplementedError
end
|
#order_model ⇒ Object
5
6
7
8
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 5
def order_model
klass = self.class.to_s.split('::').last
"Externals::#{klass}::Order".constantize
end
|
#place_an_order_from_reservation(reservation) ⇒ Object
create Driver and Order record, then assign delivery_channel_id to DeliveryAddress
62
63
64
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 62
def place_an_order_from_reservation(reservation)
raise NotImplementedError
end
|
#place_an_order_from_reservation_later(reservation) ⇒ Object
66
67
68
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 66
def place_an_order_from_reservation_later(reservation)
raise NotImplementedError
end
|
#reset_delivery_channel(reservation) ⇒ Object
95
96
97
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 95
def reset_delivery_channel(reservation)
reservation.update! delivery_channel_id: nil
end
|
#self_deliver? ⇒ Boolean
43
44
45
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 43
def self_deliver?
false
end
|
#should_reorder_driver(reservation) ⇒ Object
78
79
80
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 78
def should_reorder_driver(reservation)
reservation.skip_reorder_driver == false
end
|
#skip_reorder_driver(reservation) ⇒ Object
82
83
84
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 82
def skip_reorder_driver(reservation)
reservation.update! skip_reorder_driver: true
end
|
#valid_reservation?(_reservation) ⇒ Boolean
70
71
72
|
# File 'app/my_lib/delivery_channel/courier_base.rb', line 70
def valid_reservation?(_reservation)
true
end
|