spree_cm_commissioner 2.3.1.pre.pre2 → 2.3.2.pre.pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/spree/api/v2/storefront/intercity_taxi/draft_orders_controller.rb +44 -2
- data/app/controllers/spree/api/v2/tenant/intercity_taxi/draft_orders_controller.rb +43 -3
- data/app/request_schemas/spree_cm_commissioner/intercity_taxi_draft_order_schema.rb +10 -0
- data/app/request_schemas/spree_cm_commissioner/intercity_taxi_draft_order_update_schema.rb +10 -0
- data/app/services/spree_cm_commissioner/intercity_taxi_order/create.rb +6 -6
- data/app/services/spree_cm_commissioner/intercity_taxi_order/update.rb +6 -53
- data/config/routes.rb +5 -1
- data/lib/spree_cm_commissioner/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4090589caa9f83b8b2020e1ed20383647e2671b87692bcecf57f2f455bee7a58
|
|
4
|
+
data.tar.gz: 8cd128d3b2764b6ba6b309c8e0c9b71108b7057ccdd4e03fe92ec4e9d8702d9a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 692a3b8079e7f44d84556a826f8519ece6226334b28f78b194829f908f005902a4aaa34f18683aecbb161450197f3c808a82d84545fcc868975306ae45b396a5
|
|
7
|
+
data.tar.gz: e5e0191151979f1476f7ba43fe46ce13dd346c9d44d729d18da9fcff587004c21c7f028bc814356fa2c08a3a32dc867e3bd155ccc0f7659761ab7a9a6201b9b9
|
data/Gemfile.lock
CHANGED
|
@@ -4,12 +4,16 @@ module Spree
|
|
|
4
4
|
module Storefront
|
|
5
5
|
module IntercityTaxi
|
|
6
6
|
class DraftOrdersController < ::Spree::Api::V2::ResourceController
|
|
7
|
+
include Spree::Api::V2::Storefront::OrderConcern
|
|
8
|
+
include SpreeCmCommissioner::OrderConcern
|
|
9
|
+
|
|
10
|
+
before_action :ensure_order, only: :update
|
|
7
11
|
def create
|
|
8
12
|
order = SpreeCmCommissioner::IntercityTaxiOrder::Create.call(
|
|
9
13
|
trip_id: params[:trip_id],
|
|
10
14
|
from_date: params[:from_date],
|
|
11
15
|
to_date: params[:to_date],
|
|
12
|
-
|
|
16
|
+
user: spree_current_user,
|
|
13
17
|
quantity: params[:quantity]
|
|
14
18
|
)
|
|
15
19
|
|
|
@@ -20,7 +24,8 @@ module Spree
|
|
|
20
24
|
|
|
21
25
|
def update
|
|
22
26
|
order = SpreeCmCommissioner::IntercityTaxiOrder::Update.call(
|
|
23
|
-
|
|
27
|
+
order: spree_current_order,
|
|
28
|
+
order_params: intercity_taxi_update_order_params
|
|
24
29
|
)
|
|
25
30
|
|
|
26
31
|
render_serialized_payload { serialize_resource(order) }
|
|
@@ -28,6 +33,43 @@ module Spree
|
|
|
28
33
|
render_error_payload(e.message)
|
|
29
34
|
end
|
|
30
35
|
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def intercity_taxi_update_order_params
|
|
39
|
+
params.require(:order).permit(
|
|
40
|
+
line_items_attributes: %i[
|
|
41
|
+
id
|
|
42
|
+
pickup_place_name
|
|
43
|
+
drop_off_place_name
|
|
44
|
+
from_date
|
|
45
|
+
pickup_lat
|
|
46
|
+
pickup_lng
|
|
47
|
+
pickup_oob_confirmed
|
|
48
|
+
drop_off_lat
|
|
49
|
+
drop_off_lng
|
|
50
|
+
drop_off_oob_confirmed
|
|
51
|
+
distance_km
|
|
52
|
+
ordered_points
|
|
53
|
+
base_km
|
|
54
|
+
detour_pickup_km
|
|
55
|
+
detour_dropoff_km
|
|
56
|
+
extra_pickup_km
|
|
57
|
+
extra_dropoff_km
|
|
58
|
+
estimated_time_minutes
|
|
59
|
+
remark
|
|
60
|
+
passenger_count
|
|
61
|
+
]
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def required_schema
|
|
66
|
+
if action_name == 'create'
|
|
67
|
+
SpreeCmCommissioner::IntercityTaxiDraftOrderSchema
|
|
68
|
+
else
|
|
69
|
+
SpreeCmCommissioner::IntercityTaxiDraftOrderUpdateSchema
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
31
73
|
def resource_serializer
|
|
32
74
|
SpreeCmCommissioner::V2::Storefront::IntercityTaxiCartSerializer
|
|
33
75
|
end
|
|
@@ -4,13 +4,17 @@ module Spree
|
|
|
4
4
|
module Tenant
|
|
5
5
|
module IntercityTaxi
|
|
6
6
|
class DraftOrdersController < BaseController
|
|
7
|
+
include Spree::Api::V2::Storefront::OrderConcern
|
|
8
|
+
include SpreeCmCommissioner::OrderConcern
|
|
9
|
+
|
|
10
|
+
before_action :ensure_order, only: :update
|
|
7
11
|
def create
|
|
8
12
|
order = SpreeCmCommissioner::IntercityTaxiOrder::Create.call(
|
|
9
13
|
trip_id: params[:trip_id],
|
|
10
14
|
from_date: params[:from_date],
|
|
11
15
|
to_date: params[:to_date],
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
quantity: params[:quantity],
|
|
17
|
+
user: spree_current_user
|
|
14
18
|
)
|
|
15
19
|
|
|
16
20
|
render_serialized_payload { serialize_resource(order) }
|
|
@@ -20,7 +24,8 @@ module Spree
|
|
|
20
24
|
|
|
21
25
|
def update
|
|
22
26
|
order = SpreeCmCommissioner::IntercityTaxiOrder::Update.call(
|
|
23
|
-
|
|
27
|
+
order: spree_current_order,
|
|
28
|
+
order_params: intercity_taxi_update_order_params
|
|
24
29
|
)
|
|
25
30
|
|
|
26
31
|
render_serialized_payload { serialize_resource(order) }
|
|
@@ -30,6 +35,41 @@ module Spree
|
|
|
30
35
|
|
|
31
36
|
private
|
|
32
37
|
|
|
38
|
+
def intercity_taxi_update_order_params
|
|
39
|
+
params.require(:order).permit(
|
|
40
|
+
line_items_attributes: %i[
|
|
41
|
+
id
|
|
42
|
+
pickup_place_name
|
|
43
|
+
drop_off_place_name
|
|
44
|
+
from_date
|
|
45
|
+
pickup_lat
|
|
46
|
+
pickup_lng
|
|
47
|
+
pickup_oob_confirmed
|
|
48
|
+
drop_off_lat
|
|
49
|
+
drop_off_lng
|
|
50
|
+
drop_off_oob_confirmed
|
|
51
|
+
distance_km
|
|
52
|
+
ordered_points
|
|
53
|
+
base_km
|
|
54
|
+
detour_pickup_km
|
|
55
|
+
detour_dropoff_km
|
|
56
|
+
extra_pickup_km
|
|
57
|
+
extra_dropoff_km
|
|
58
|
+
estimated_time_minutes
|
|
59
|
+
remark
|
|
60
|
+
passenger_count
|
|
61
|
+
]
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def required_schema
|
|
66
|
+
if action_name == 'create'
|
|
67
|
+
SpreeCmCommissioner::IntercityTaxiDraftOrderSchema
|
|
68
|
+
else
|
|
69
|
+
SpreeCmCommissioner::IntercityTaxiDraftOrderUpdateSchema
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
33
73
|
def resource_serializer
|
|
34
74
|
SpreeCmCommissioner::V2::Storefront::IntercityTaxiCartSerializer
|
|
35
75
|
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module SpreeCmCommissioner
|
|
2
|
+
class IntercityTaxiDraftOrderSchema < ApplicationRequestSchema
|
|
3
|
+
params do
|
|
4
|
+
required(:trip_id).value(:integer)
|
|
5
|
+
required(:from_date).value(:date)
|
|
6
|
+
required(:to_date).value(:date)
|
|
7
|
+
required(:quantity).value(:integer)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module SpreeCmCommissioner
|
|
2
|
+
class IntercityTaxiDraftOrderUpdateSchema < ApplicationRequestSchema
|
|
3
|
+
params do
|
|
4
|
+
required(:order).hash do
|
|
5
|
+
# Rails nested attributes send line_items_attributes as hash with numeric string keys (e.g., "0", "1")
|
|
6
|
+
required(:line_items_attributes).hash
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
module SpreeCmCommissioner
|
|
2
2
|
module IntercityTaxiOrder
|
|
3
3
|
class Create
|
|
4
|
-
attr_reader :trip_id, :from_date, :to_date, :
|
|
4
|
+
attr_reader :trip_id, :from_date, :to_date, :user, :quantity
|
|
5
5
|
|
|
6
|
-
def self.call(trip_id:, from_date:, to_date:,
|
|
6
|
+
def self.call(trip_id:, from_date:, to_date:, user: nil, quantity: 1)
|
|
7
7
|
new(
|
|
8
8
|
trip_id: trip_id,
|
|
9
9
|
from_date: from_date,
|
|
10
10
|
to_date: to_date,
|
|
11
|
-
|
|
11
|
+
user: user,
|
|
12
12
|
quantity: quantity
|
|
13
13
|
).call
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def initialize(trip_id:, from_date:, to_date:,
|
|
16
|
+
def initialize(trip_id:, from_date:, to_date:, user:, quantity:)
|
|
17
17
|
@trip_id = trip_id
|
|
18
18
|
@from_date = from_date
|
|
19
19
|
@to_date = to_date
|
|
20
|
-
@
|
|
20
|
+
@user = user
|
|
21
21
|
@quantity = quantity.to_i <= 0 ? 1 : quantity.to_i
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -29,7 +29,7 @@ module SpreeCmCommissioner
|
|
|
29
29
|
variant = trip.product.variants.first
|
|
30
30
|
raise ArgumentError, 'No variant found for trip' if variant.blank?
|
|
31
31
|
|
|
32
|
-
order = Spree::Order.new(state: 'cart', use_billing: true,
|
|
32
|
+
order = Spree::Order.new(state: 'cart', use_billing: true, user: user)
|
|
33
33
|
|
|
34
34
|
line_item = order.line_items.new(
|
|
35
35
|
variant_id: variant.id,
|
|
@@ -1,69 +1,22 @@
|
|
|
1
1
|
module SpreeCmCommissioner
|
|
2
2
|
module IntercityTaxiOrder
|
|
3
3
|
class Update
|
|
4
|
-
attr_reader :
|
|
4
|
+
attr_reader :order, :order_params
|
|
5
5
|
|
|
6
|
-
def self.call(
|
|
7
|
-
new(
|
|
6
|
+
def self.call(order:, order_params:)
|
|
7
|
+
new(order: order, order_params: order_params).call
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def initialize(
|
|
11
|
-
@
|
|
10
|
+
def initialize(order:, order_params:)
|
|
11
|
+
@order = order
|
|
12
|
+
@order_params = order_params
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def call
|
|
15
|
-
order = find_order!
|
|
16
16
|
order.update!(order_params)
|
|
17
17
|
|
|
18
18
|
order
|
|
19
19
|
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
def ensure_parameters(params)
|
|
24
|
-
return params if params.is_a?(::ActionController::Parameters)
|
|
25
|
-
|
|
26
|
-
::ActionController::Parameters.new(params)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def find_order!
|
|
30
|
-
raise(ArgumentError, 'Order token is required') if order_token.blank?
|
|
31
|
-
|
|
32
|
-
Spree::Order.find_by!(token: order_token)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def order_token
|
|
36
|
-
params[:order_token]
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def order_params
|
|
40
|
-
params.require(:order).permit(
|
|
41
|
-
line_items_attributes: %i[
|
|
42
|
-
id
|
|
43
|
-
pickup_place_name
|
|
44
|
-
drop_off_place_name
|
|
45
|
-
from_date
|
|
46
|
-
pickup_lat
|
|
47
|
-
pickup_lng
|
|
48
|
-
pickup_oob_confirmed
|
|
49
|
-
drop_off_lat
|
|
50
|
-
drop_off_lng
|
|
51
|
-
drop_off_oob_confirmed
|
|
52
|
-
distance_km
|
|
53
|
-
ordered_points
|
|
54
|
-
base_km
|
|
55
|
-
detour_pickup_km
|
|
56
|
-
detour_dropoff_km
|
|
57
|
-
extra_pickup_km
|
|
58
|
-
extra_dropoff_km
|
|
59
|
-
extra_pickup_charge_usd
|
|
60
|
-
extra_dropoff_charge_usd
|
|
61
|
-
estimated_time_minutes
|
|
62
|
-
remark
|
|
63
|
-
passenger_count
|
|
64
|
-
]
|
|
65
|
-
)
|
|
66
|
-
end
|
|
67
20
|
end
|
|
68
21
|
end
|
|
69
22
|
end
|
data/config/routes.rb
CHANGED
|
@@ -701,7 +701,11 @@ Spree::Core::Engine.add_routes do
|
|
|
701
701
|
resources :draft_orders, only: %i[create]
|
|
702
702
|
end
|
|
703
703
|
namespace :intercity_taxi do
|
|
704
|
-
resources :draft_orders, only:
|
|
704
|
+
resources :draft_orders, only: [:create] do
|
|
705
|
+
collection do
|
|
706
|
+
patch :update
|
|
707
|
+
end
|
|
708
|
+
end
|
|
705
709
|
end
|
|
706
710
|
end
|
|
707
711
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_cm_commissioner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.
|
|
4
|
+
version: 2.3.2.pre.pre2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- You
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-12-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: spree
|
|
@@ -1753,6 +1753,8 @@ files:
|
|
|
1753
1753
|
- app/queries/spree_cm_commissioner/users_by_event_fetcher_query.rb
|
|
1754
1754
|
- app/request_schemas/spree_cm_commissioner/accommodation_request_schema.rb
|
|
1755
1755
|
- app/request_schemas/spree_cm_commissioner/application_request_schema.rb
|
|
1756
|
+
- app/request_schemas/spree_cm_commissioner/intercity_taxi_draft_order_schema.rb
|
|
1757
|
+
- app/request_schemas/spree_cm_commissioner/intercity_taxi_draft_order_update_schema.rb
|
|
1756
1758
|
- app/request_schemas/spree_cm_commissioner/inventory_item_schema.rb
|
|
1757
1759
|
- app/request_schemas/spree_cm_commissioner/profile_image_request_schema.rb
|
|
1758
1760
|
- app/request_schemas/spree_cm_commissioner/seat_layout_schema.rb
|