Class: Spree::Api::V2::Tenant::IdCardsController
- Inherits:
-
BaseController
- Object
- ResourceController
- BaseController
- Spree::Api::V2::Tenant::IdCardsController
show all
- Defined in:
- app/controllers/spree/api/v2/tenant/id_cards_controller.rb
Instance Method Summary
collapse
#render_serialized_payload, #require_tenant, #scope
Instance Method Details
#create ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/controllers/spree/api/v2/tenant/id_cards_controller.rb', line 6
def create
context = SpreeCmCommissioner::GuestIdCardManager.call(
card_type: id_card_params[:card_type],
front_image_url: id_card_params[:front_image_url],
back_image_url: id_card_params[:back_image_url],
guest_id: id_card_params[:guest_id]
)
if context.success?
render_serialized_payload { serialize_resource(context.result) }
else
render_error_payload(context.message)
end
end
|
#destroy ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/spree/api/v2/tenant/id_cards_controller.rb', line 36
def destroy
id_card = SpreeCmCommissioner::IdCard.find(params[:id])
if id_card.destroy
head :no_content
else
render_error_payload('Failed to destroy ID card', 400)
end
end
|
#update ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/spree/api/v2/tenant/id_cards_controller.rb', line 21
def update
context = SpreeCmCommissioner::GuestIdCardManager.call(
card_type: id_card_params[:card_type],
front_image_url: id_card_params[:front_image_url],
back_image_url: id_card_params[:back_image_url],
guest_id: id_card_params[:guest_id]
)
if context.success?
render_serialized_payload { serialize_resource(context.result) }
else
render_error_payload(context.message)
end
end
|