-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
17 changed files
with
99 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 0 additions & 79 deletions
79
app/controllers/spree/api/v2/storefront/template_guests_controller.rb
This file was deleted.
Oops, something went wrong.
60 changes: 57 additions & 3 deletions
60
app/interactors/spree_cm_commissioner/guest_id_card_manager.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,61 @@ | ||
module SpreeCmCommissioner | ||
class GuestIdCardManager < IdCardManager | ||
def guestable | ||
@guestable ||= SpreeCmCommissioner::Guest.find(context.guestable_id) | ||
class GuestIdCardManager < BaseInteractor | ||
delegate :card_type, :front_image_url, :back_image_url, :guest_id, to: :context | ||
|
||
def call | ||
if guest.id_card.blank? && front_image_url.present? | ||
create_guest_id_card | ||
elsif guest.id_card.present? | ||
update_guest_id_card | ||
else | ||
context.fail!(message: 'Image url can not be empty') | ||
end | ||
end | ||
|
||
def create_guest_id_card | ||
id_card = guest.build_id_card(card_type: card_type) | ||
|
||
manage_front_image(id_card) | ||
manage_back_image(id_card) if back_image_url.present? | ||
|
||
context.fail!(message: 'Failed to create Id card') unless context.success? && id_card.save | ||
context.result = guest.id_card | ||
end | ||
|
||
def update_guest_id_card | ||
manage_card_type(guest.id_card) if card_type.present? | ||
manage_front_image(guest.id_card) if front_image_url.present? | ||
manage_back_image(guest.id_card) if back_image_url.present? | ||
|
||
context.fail!(message: 'Failed to update Id card') unless context.success? && guest.id_card.save | ||
context.result = guest.id_card | ||
end | ||
|
||
def guest | ||
SpreeCmCommissioner::Guest.find(guest_id) | ||
end | ||
|
||
def manage_card_type(id_card) | ||
id_card.update(card_type: card_type) | ||
end | ||
|
||
def manage_front_image(id_card) | ||
context = SpreeCmCommissioner::IdCardImageUpdater.call( | ||
id_card: id_card, | ||
image_url: front_image_url, | ||
type: 'front_image' | ||
) | ||
|
||
context.fail!(message: 'Failed to update front image') unless context.success? | ||
end | ||
|
||
def manage_back_image(id_card) | ||
context = SpreeCmCommissioner::IdCardImageUpdater.call( | ||
id_card: id_card, | ||
image_url: back_image_url, | ||
type: 'back_image' | ||
) | ||
context.fail!(message: 'Failed to update back image') unless context.success? | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
app/interactors/spree_cm_commissioner/template_guest_id_card_manager.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
app/serializers/spree_cm_commissioner/v2/storefront/template_guest_serializer.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
db/migrate/20240926100138_create_spree_cm_commissioner_template_guests.rb
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
db/migrate/20240926120947_add_template_guest_id_to_spree_cm_commissioner_guest.rb
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
db/migrate/20240927082749_migrate_guest_id_to_polymorphic_in_cm_id_cards.rb
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.