spree_cm_commissioner 2.5.2.pre.pre1 → 2.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbcd427457c152b80d8c5aa1f87a1633e29ba0c39b99c3ee856f88187e54ff6e
4
- data.tar.gz: 372de4f3e2a8ab6df9fb2ba94287a5ae2f676633808c02593685ae93f5b201a8
3
+ metadata.gz: 415383ae7339303ff881a06d0642275576a1aa2e0bd685d2dfbf239cda829f6e
4
+ data.tar.gz: da42ba2da856fff29f83d67f574d6e07cd06c1066a1baa0ef30b92268533d8b0
5
5
  SHA512:
6
- metadata.gz: 7d944b5af7b8fc624cce7d0ce5428060b7094429eb1619147790d606102d13dbf88702686d4723208feb531339eac39d87c9011320bb8f18b897a12267e699a3
7
- data.tar.gz: 5a2896cb596c6bf3ed41c2a860e794ced42c3a317f7af71de69873fec33869a146cbc2cc4953eddce256d7a36d2a45f5b8e1319bc8d0836692b7a1a37dc1e397
6
+ metadata.gz: b3590bf3744645b2af02f779ccf4d6797879e71a47c9c01e524514428396813cc6752f25e361cf1489e0f1a2f106ba9987f43581d97788ce19ed290848a7fc68
7
+ data.tar.gz: 6d0b09ce6143a18db3118c284ae0c1b334bbd29baf9dcf106ec4253144afbdb5da6e78f952219821ccc782601eee2ac20f7f1ccf7f22148290ac9ae0f1a3a012
data/Gemfile.lock CHANGED
@@ -34,7 +34,7 @@ GIT
34
34
  PATH
35
35
  remote: .
36
36
  specs:
37
- spree_cm_commissioner (2.5.2.pre.pre1)
37
+ spree_cm_commissioner (2.5.2.pre.pre2)
38
38
  activerecord-multi-tenant
39
39
  activerecord_json_validator (~> 2.1, >= 2.1.3)
40
40
  aws-sdk-cloudfront
@@ -0,0 +1,111 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ module Storefront
5
+ class InviteGuestsController < ::Spree::Api::V2::ResourceController
6
+ before_action :load_invite_guest_by_token, only: %i[update]
7
+ before_action :require_spree_current_user, only: :update
8
+
9
+ def update
10
+ return if invite_unavailable?
11
+
12
+ order = @invite_guest.order
13
+ return unless ensure_order_belongs_to_current_user(order)
14
+
15
+ @line_item = @invite_guest.order.line_items.first
16
+ guest = find_unassigned_guest(@line_item)
17
+ return render_error_payload('No available guest to assign', 422) unless guest
18
+
19
+ assign_guest_from_user(guest)
20
+
21
+ finalize_guest_claim(guest)
22
+ end
23
+
24
+ private
25
+
26
+ def send_guest_claimed_invitation_telegram_alert_to_vendor(guest)
27
+ title = '📣 --- [NEW GUEST CLAIMED INVITATION] ---' # Style/StringLiterals
28
+ chat_id = guest.event&.vendor&.preferred_telegram_chat_id
29
+ return if chat_id.blank?
30
+
31
+ factory = SpreeCmCommissioner::InviteGuestClaimedTelegramMessageFactory.new(
32
+ title: title,
33
+ order: @invite_guest.order,
34
+ guest: guest,
35
+ vendor: guest.event.vendor
36
+ )
37
+ SpreeCmCommissioner::TelegramNotificationSenderJob.perform_later(
38
+ chat_id: chat_id,
39
+ message: factory.message,
40
+ parse_mode: factory.parse_mode
41
+ )
42
+ end
43
+
44
+ def load_invite_guest_by_token
45
+ @invite_guest = SpreeCmCommissioner::InviteGuest.find_by!(token: params[:id])
46
+ rescue ActiveRecord::RecordNotFound
47
+ render_error_payload(I18n.t('invite.url_not_found'))
48
+ end
49
+
50
+ def invite_unavailable?
51
+ return render_error(:revoked) if @invite_guest.revoked?
52
+ return render_error(:closed) if @invite_guest.expired?
53
+ return render_error(:fully_claimed) if @invite_guest.claimed? || @invite_guest.fully_claimed?
54
+
55
+ false
56
+ end
57
+
58
+ def ensure_order_belongs_to_current_user(order)
59
+ if order.user.nil?
60
+ order.update(user: spree_current_user)
61
+ return true
62
+ end
63
+
64
+ return true if order.user == spree_current_user
65
+
66
+ render_error_payload('You are not authorized to access this page.', 403)
67
+ false
68
+ end
69
+
70
+ def find_unassigned_guest(line_item)
71
+ return line_item.guests.build(event_id: @invite_guest&.event_id) if line_item.guests.blank?
72
+
73
+ line_item.guests.detect { |g| g.user.nil? }
74
+ end
75
+
76
+ def assign_guest_from_user(guest)
77
+ guest.first_name ||= spree_current_user.first_name
78
+ guest.last_name ||= spree_current_user.last_name
79
+ guest.phone_number ||= spree_current_user.try(:phone) || spree_current_user.try(:phone_number)
80
+ guest.dob ||= spree_current_user.try(:dob)
81
+ guest.gender ||= spree_current_user.try(:gender)
82
+
83
+ guest.line_item ||= @line_item
84
+ guest.event_id ||= @invite_guest.event_id
85
+ guest.user ||= spree_current_user
86
+ end
87
+
88
+ def finalize_guest_claim(guest)
89
+ if guest.save
90
+ @invite_guest.update(claimed_status: :claimed) if @line_item.guests.count == @invite_guest.quantity
91
+ send_guest_claimed_invitation_telegram_alert_to_vendor(guest) if guest.event&.vendor&.preferred_telegram_chat_id.present?
92
+
93
+ order = @invite_guest.order
94
+ render_serialized_payload { serialize_resource(order) }
95
+ else
96
+ render_error_payload(guest.errors.full_messages.to_sentence)
97
+ end
98
+ end
99
+
100
+ def render_error(message)
101
+ render json: { errors: message }
102
+ end
103
+
104
+ def resource_serializer
105
+ Spree::V2::Storefront::OrderSerializer
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
@@ -36,7 +36,10 @@ module SpreeCmCommissioner
36
36
  def create_variant!(vendor, trip_form)
37
37
  first_stop = trip_form.trip_stops.first
38
38
  vehicle_type = SpreeCmCommissioner::VehicleType.find(first_stop.vehicle_type_id)
39
- capacity = vehicle_type.number_of_seats
39
+ capacity = vehicle_type.seat_layout&.total_seats || vehicle_type.number_of_seats
40
+
41
+ raise StandardError, 'Vehicle type must be selected' if vehicle_type.blank?
42
+ raise StandardError, 'Vehicle type seat capacity must be greater than 0' if capacity <= 0
40
43
 
41
44
  result = SpreeCmCommissioner::Trips::Variants::Create.call(
42
45
  vendor: vendor,
@@ -45,7 +48,7 @@ module SpreeCmCommissioner
45
48
  capacity: capacity
46
49
  )
47
50
 
48
- raise result.error unless result.success?
51
+ raise StandardError, result.error unless result.success?
49
52
 
50
53
  result.value[:variant]
51
54
  end
@@ -57,14 +60,18 @@ module SpreeCmCommissioner
57
60
  last_stop = trip_form.trip_stops.last
58
61
 
59
62
  locations = vendor.locations.where(id: trip_form.trip_stops.map(&:location_id)).index_by(&:id)
60
- stops = vendor.stops.where(id: trip_form.trip_stops.map(&:stop_id)).index_by(&:id)
63
+
64
+ # vendor_places are either stops or branches
65
+ vendor_places = SpreeCmCommissioner::VendorPlace
66
+ .where(id: trip_form.trip_stops.map(&:stop_id), vendor: vendor)
67
+ .index_by(&:id)
61
68
 
62
69
  trip = vendor.trips.create!(
63
70
  product: variant.product,
64
71
  vehicle_type: SpreeCmCommissioner::VehicleType.find_by(id: first_stop.vehicle_type_id),
65
72
  vehicle: SpreeCmCommissioner::Vehicle.find_by(id: first_stop.vehicle_id),
66
- origin_place: locations[first_stop.location_id].place,
67
- destination_place: locations[last_stop.location_id].place,
73
+ origin_place_id: locations[first_stop.location_id.to_i].place_id,
74
+ destination_place_id: locations[last_stop.location_id.to_i].place_id,
68
75
  route: vendor.routes.find(trip_form.route_id),
69
76
  departure_time: first_stop.departure_time,
70
77
  duration: trip_form.total_duration_seconds,
@@ -73,23 +80,21 @@ module SpreeCmCommissioner
73
80
  route_type: trip_form.route_type || vendor.routes.find(trip_form.route_id)&.route_type
74
81
  )
75
82
 
76
- create_trip_stops(trip, trip_form, locations, stops)
83
+ create_trip_stops(trip, trip_form, locations, vendor_places)
77
84
  trip
78
85
  end
79
86
 
80
87
  # Creates individual trip stops based on the trip form stops.
81
88
  # Each stop includes arrival/departure times and boarding/drop-off permissions.
82
- def create_trip_stops(trip, trip_form, locations, stops)
89
+ def create_trip_stops(trip, trip_form, locations, vendor_places)
83
90
  previous_departure = nil
84
-
85
- trip_form.trip_stops.each do |ts|
91
+ Array(trip_form.trip_stops).each do |ts|
86
92
  arrival_time = previous_departure || ts.departure_time
87
-
88
93
  trip.trip_stops.create!(
89
- stop_place: stops[ts.stop_id].place,
90
- location_place: locations[ts.location_id].place,
94
+ stop_place: vendor_places[ts.stop_id.to_i].place,
95
+ location_place: locations[ts.location_id.to_i].place,
91
96
  allow_boarding: ts.allow_boarding?,
92
- allow_drop_off: ts.allow_drop_off,
97
+ allow_drop_off: ts.allow_drop_off?,
93
98
  arrival_time: arrival_time,
94
99
  departure_time: ts.departure_time
95
100
  )
@@ -109,7 +114,7 @@ module SpreeCmCommissioner
109
114
  exception_rules: calendar_form.exception_rules || []
110
115
  )
111
116
 
112
- raise res.error unless res.success?
117
+ raise StandardError, res.error unless res.success?
113
118
 
114
119
  res.value[:calendar]
115
120
  end
@@ -25,7 +25,7 @@ module SpreeCmCommissioner
25
25
  error_message: e.message
26
26
  }
27
27
  )
28
- failure(nil, 'Failed to update trip')
28
+ failure(nil, e)
29
29
  end
30
30
 
31
31
  private
@@ -47,6 +47,8 @@ module SpreeCmCommissioner
47
47
 
48
48
  # Iterates through stops and applies updates only if attributes are present.
49
49
  def update_trip_stops(trip, trip_form)
50
+ return if trip_form.trip_stops.blank?
51
+
50
52
  trip.trip_stops.each_with_index do |stop, idx|
51
53
  ts_form = trip_form.trip_stops[idx]
52
54
  next unless ts_form
@@ -71,7 +73,7 @@ module SpreeCmCommissioner
71
73
  exception_rules: calendar_form.exception_rules || []
72
74
  )
73
75
 
74
- raise result.error unless result.success?
76
+ raise StandardError, 'Failed to update service calendar' unless result.success?
75
77
 
76
78
  result.value[:calendar]
77
79
  end
@@ -40,12 +40,12 @@ module SpreeCmCommissioner
40
40
  # Creates a transit product with name based on stops, assigns vendor, type, and options.
41
41
  # Includes seat-type option type and default store association.
42
42
  def create_product!(vendor, trip_form)
43
- vendor_stops = stops(vendor, trip_form)
44
- first_stop = vendor_stops[trip_form.trip_stops.first.stop_id].place
45
- last_stop = vendor_stops[trip_form.trip_stops.last.stop_id].place
43
+ vendor_stops = branches(vendor, trip_form)
44
+ first_stop = vendor_stops[trip_form.trip_stops.first.stop_id]
45
+ last_stop = vendor_stops[trip_form.trip_stops.last.stop_id]
46
46
 
47
47
  Spree::Product.create!(
48
- name: trip_form.name.presence || "#{first_stop.name} - #{last_stop.name}",
48
+ name: trip_form.name.presence || "#{first_stop&.name} - #{last_stop&.name}",
49
49
  short_name: trip_form.short_name,
50
50
  vendor: vendor,
51
51
  product_type: 'transit',
@@ -59,8 +59,8 @@ module SpreeCmCommissioner
59
59
  end
60
60
 
61
61
  # Retrieves and indexes stops from the vendor for the trip form's stop IDs.
62
- def stops(vendor, trip_form)
63
- vendor.stops.where(id: trip_form.trip_stops.map(&:stop_id)).index_by(&:id)
62
+ def branches(vendor, trip_form)
63
+ vendor.branches.where(id: trip_form.trip_stops.map(&:stop_id)).index_by(&:id)
64
64
  end
65
65
 
66
66
  # Sets up or finds the seat-type option type and creates normal option value.
data/config/routes.rb CHANGED
@@ -483,7 +483,6 @@ Spree::Core::Engine.add_routes do
483
483
  resource :s3_signed_urls
484
484
  resources :invites
485
485
  resources :invite_crews, only: %i[show update]
486
- resources :invite_guests, only: %i[show update]
487
486
  end
488
487
 
489
488
  namespace :tenant do
@@ -711,6 +710,7 @@ Spree::Core::Engine.add_routes do
711
710
  resources :seat_layouts, only: %i[show index]
712
711
  resources :inventory_items, only: %i[index]
713
712
  resources :event_matches, only: %i[index]
713
+ resources :invite_guests, only: %i[show update]
714
714
  namespace :transit do
715
715
  resources :draft_orders, only: %i[create]
716
716
  end
@@ -97,6 +97,34 @@ module SpreeCmCommissioner::Transit
97
97
  grouped
98
98
  end
99
99
 
100
+ def by_location_id_with_data
101
+ return {} if @stops.empty?
102
+
103
+ # Extract unique vendor_place_ids from all stops
104
+ vendor_place_ids = @stops.map(&:vendor_place_id).compact.uniq
105
+ return {} if vendor_place_ids.empty?
106
+
107
+ # Single query: fetch all vendor places with their locations
108
+ # index_by(:id) creates a hash for O(1) lookup: { vendor_place_id => vendor_place_obj }
109
+ vendor_places = SpreeCmCommissioner::VendorPlace.where(id: vendor_place_ids).includes(:location).index_by(&:id)
110
+
111
+ grouped = {}
112
+ @stops.each do |stop|
113
+ # Set the vendor_place object on the stop for later use
114
+ stop.vendor_place = vendor_places[stop.vendor_place_id]
115
+
116
+ # Get the location from the vendor_place (e.g., "Bangkok" location)
117
+ location = stop.vendor_place&.location
118
+ next if location.nil?
119
+
120
+ # Group stops by location id
121
+ grouped[location.id] ||= []
122
+ grouped[location.id] << stop
123
+ end
124
+
125
+ grouped
126
+ end
127
+
100
128
  # Groups route stops by their location in sequence order
101
129
  # Returns an array of hashes where each hash contains:
102
130
  # - location: the VendorPlace representing the location
@@ -0,0 +1,51 @@
1
+ module SpreeCmCommissioner::Transit
2
+ class ServiceCalendarForm
3
+ include ActiveModel::Model
4
+
5
+ attr_accessor :name,
6
+ :start_date,
7
+ :end_date,
8
+ :monday,
9
+ :tuesday,
10
+ :wednesday,
11
+ :thursday,
12
+ :friday,
13
+ :saturday,
14
+ :sunday,
15
+ :exception_rules
16
+
17
+ def initialize(attrs = {})
18
+ super
19
+ @exception_rules ||= []
20
+ end
21
+
22
+ def weekdays
23
+ {
24
+ 'monday' => monday,
25
+ 'tuesday' => tuesday,
26
+ 'wednesday' => wednesday,
27
+ 'thursday' => thursday,
28
+ 'friday' => friday,
29
+ 'saturday' => saturday,
30
+ 'sunday' => sunday
31
+ }
32
+ end
33
+
34
+ def weekdays=(hash)
35
+ hash = hash.transform_keys(&:to_s)
36
+ @monday = cast_bool(hash['monday'])
37
+ @tuesday = cast_bool(hash['tuesday'])
38
+ @wednesday = cast_bool(hash['wednesday'])
39
+ @thursday = cast_bool(hash['thursday'])
40
+ @friday = cast_bool(hash['friday'])
41
+ @saturday = cast_bool(hash['saturday'])
42
+ @sunday = cast_bool(hash['sunday'])
43
+ end
44
+
45
+ private
46
+
47
+ def cast_bool(val)
48
+ ActiveModel::Type::Boolean.new.cast(val)
49
+ end
50
+ end
51
+ end
@@ -12,6 +12,30 @@ module SpreeCmCommissioner::Transit
12
12
  :trip_stops, # TripStopForm[]
13
13
  :service_calendar # monday, tuesday, wednesday, thursday, friday, saturday, sunday, start_date, end_date
14
14
 
15
+ # Convert params hashes into TripStopForm objects
16
+ def trip_stops_attributes=(arr)
17
+ items = arr.is_a?(Hash) ? arr.values : Array(arr)
18
+ @trip_stops = items.map do |h|
19
+ h = h.to_h.symbolize_keys
20
+ TripStopForm.new.tap do |ts|
21
+ ts.location_id = h[:location_id]
22
+ ts.stop_id = h[:stop_id]
23
+ ts.departure_time = h[:departure_time]
24
+ ts.duration_in_hours = h[:duration_in_hours]
25
+ ts.route_type = h[:route_type]
26
+ ts.vehicle_type_id = h[:vehicle_type_id]
27
+ ts.vehicle_id = h[:vehicle_id]
28
+ ts.board_to_trip_id = h[:board_to_trip_id]
29
+ ts.allow_boarding = h[:allow_boarding]
30
+ ts.allow_drop_off = h[:allow_drop_off]
31
+ ts.allow_seat_selection = h[:allow_seat_selection]
32
+ ts.allow_booking = h[:allow_booking]
33
+ ts.sequence = h[:sequence]
34
+ ts.vendor_id = h[:vendor_id]
35
+ end
36
+ end
37
+ end
38
+
15
39
  def multi_leg?
16
40
  trip_stops.map(&:location_id).uniq.size > 2
17
41
  end
@@ -46,7 +46,11 @@ module SpreeCmCommissioner::Transit
46
46
  :sequence,
47
47
  #
48
48
  # set from create service
49
- :vendor_id
49
+ :vendor_id,
50
+ # branch or stop
51
+ :stop_type,
52
+ # (optional) for view lookup
53
+ :vendor_place
50
54
 
51
55
  def allow_boarding?
52
56
  ActiveModel::Type::Boolean.new.cast(allow_boarding)
@@ -1,5 +1,5 @@
1
1
  module SpreeCmCommissioner
2
- VERSION = '2.5.2-pre1'.freeze
2
+ VERSION = '2.5.2.pre.pre2'.freeze
3
3
 
4
4
  module_function
5
5
 
@@ -27,6 +27,7 @@ require 'spree_cm_commissioner/transit/route_stop'
27
27
  require 'spree_cm_commissioner/transit/route_stop_collection'
28
28
  require 'spree_cm_commissioner/transit/trip_form'
29
29
  require 'spree_cm_commissioner/transit/trip_stop_form'
30
+ require 'spree_cm_commissioner/transit/service_calendar_form'
30
31
  require 'spree_cm_commissioner/intercity_taxi/map_place'
31
32
  require 'spree_cm_commissioner/distance'
32
33
 
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.5.2.pre.pre1
4
+ version: 2.5.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: 2026-01-28 00:00:00.000000000 Z
11
+ date: 2026-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree
@@ -919,7 +919,6 @@ files:
919
919
  - app/controllers/spree/api/v2/organizer/base_controller.rb
920
920
  - app/controllers/spree/api/v2/organizer/images_controller.rb
921
921
  - app/controllers/spree/api/v2/organizer/invite_crews_controller.rb
922
- - app/controllers/spree/api/v2/organizer/invite_guests_controller.rb
923
922
  - app/controllers/spree/api/v2/organizer/invites_controller.rb
924
923
  - app/controllers/spree/api/v2/organizer/s3_signed_urls_controller.rb
925
924
  - app/controllers/spree/api/v2/organizer/ticket_images_controller.rb
@@ -965,6 +964,7 @@ files:
965
964
  - app/controllers/spree/api/v2/storefront/intercity_taxi/distance_calculator_controller.rb
966
965
  - app/controllers/spree/api/v2/storefront/intercity_taxi/draft_orders_controller.rb
967
966
  - app/controllers/spree/api/v2/storefront/inventory_items_controller.rb
967
+ - app/controllers/spree/api/v2/storefront/invite_guests_controller.rb
968
968
  - app/controllers/spree/api/v2/storefront/line_item_qrs_controller.rb
969
969
  - app/controllers/spree/api/v2/storefront/line_items_controller.rb
970
970
  - app/controllers/spree/api/v2/storefront/nearby_places_controller.rb
@@ -3151,6 +3151,7 @@ files:
3151
3151
  - lib/spree_cm_commissioner/transit/route_stop.rb
3152
3152
  - lib/spree_cm_commissioner/transit/route_stop_collection.rb
3153
3153
  - lib/spree_cm_commissioner/transit/seat_selection.rb
3154
+ - lib/spree_cm_commissioner/transit/service_calendar_form.rb
3154
3155
  - lib/spree_cm_commissioner/transit/trip_form.rb
3155
3156
  - lib/spree_cm_commissioner/transit/trip_stop_form.rb
3156
3157
  - lib/spree_cm_commissioner/trip_query_result.rb
@@ -1,91 +0,0 @@
1
- module Spree
2
- module Api
3
- module V2
4
- module Organizer
5
- class InviteGuestsController < ::Spree::Api::V2::Organizer::BaseController
6
- before_action :load_invite_guest_by_token, only: :show
7
- before_action :load_invite_guest, :assign_line_item_data, only: :update
8
-
9
- def show
10
- render_serialized_payload { serialize_resource(@invite_guest) }
11
- end
12
-
13
- def update
14
- return render_error(:revoked) if @invite_guest.revoked?
15
- return render_error(:closed) if @invite_guest.expired?
16
- return render_error(:fully_claimed) if @invite_guest.fully_claimed?
17
-
18
- guest = @line_item.guests.new(guest_params)
19
- guest.event_id = @invite_guest.event_id
20
-
21
- if guest.save
22
- @invite_guest.update(claimed_status: :claimed) if @line_item.guests.count == @invite_guest.quantity
23
- send_guest_claimed_invitation_telegram_alert_to_vendor(guest) if guest.event.vendor.preferred_telegram_chat_id.present?
24
-
25
- render json: SpreeCmCommissioner::V2::Storefront::GuestSerializer.new(guest.reload).serializable_hash
26
- else
27
- render_error_payload(guest.errors.full_messages.to_sentence)
28
- end
29
- end
30
-
31
- private
32
-
33
- def send_guest_claimed_invitation_telegram_alert_to_vendor(guest)
34
- title = '📣 --- [NEW GUEST CLAIMED INVITATION] ---' # Style/StringLiterals
35
- chat_id = guest.event.vendor.preferred_telegram_chat_id
36
- return if chat_id.blank?
37
-
38
- factory = SpreeCmCommissioner::InviteGuestClaimedTelegramMessageFactory.new(
39
- title: title,
40
- order: @invite_guest.order,
41
- guest: guest,
42
- vendor: guest.event.vendor
43
- )
44
- SpreeCmCommissioner::TelegramNotificationSenderJob.perform_later(
45
- chat_id: chat_id,
46
- message: factory.message,
47
- parse_mode: factory.parse_mode
48
- )
49
- end
50
-
51
- def load_invite_guest_by_token
52
- @invite_guest = SpreeCmCommissioner::InviteGuest.find_by(token: params[:id])
53
- rescue ActiveRecord::RecordNotFound
54
- render_error_payload(I18n.t('invite.url_not_found'))
55
- end
56
-
57
- def load_invite_guest
58
- @invite_guest = SpreeCmCommissioner::InviteGuest.find(params[:id])
59
- end
60
-
61
- def assign_line_item_data
62
- @line_item = @invite_guest.order.line_items.first
63
- @guests = @line_item.guests
64
- end
65
-
66
- def render_error(message)
67
- render json: { errors: message }
68
- end
69
-
70
- def guest_params
71
- params.require(:invite_guest).permit(
72
- :first_name,
73
- :last_name,
74
- :dob,
75
- :gender,
76
- :age,
77
- :emergency_contact,
78
- :phone_number,
79
- :address,
80
- :other_organization
81
- )
82
- end
83
-
84
- def resource_serializer
85
- ::Spree::V2::Organizer::InviteGuestSerializer
86
- end
87
- end
88
- end
89
- end
90
- end
91
- end