Class: Spree::Api::V2::Storefront::IdCardsController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Spree::Api::V2::Storefront::IdCardsController
- Defined in:
- app/controllers/spree/api/v2/storefront/id_cards_controller.rb
Instance Method Summary collapse
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/storefront/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.) end end |
#destroy ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/spree/api/v2/storefront/id_cards_controller.rb', line 36 def destroy id_card = SpreeCmCommissioner::IdCard.find(params[:id]) if id_card.destroy render_serialized_payload(204) { serialize_resource(id_card) } else render_error_payload(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/storefront/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.) end end |