6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/services/spree_cm_commissioner/routes/update.rb', line 6
def call(vendor:, route:, route_params:)
attrs = ::Spree::PermittedAttributes.route_attributes
.index_with { |attr_key| route_params[attr_key] }
.except(:vendor_id, :tenant_id, :route_stops, :origin_place_id, :destination_place_id)
.compact
route = vendor.routes.find_by(id: route.id)
return failure(nil, :route_not_found) if route.nil?
if route.update(attrs)
success(route: route)
else
failure(route.errors)
end
end
|