Class: SpreeCmCommissioner::InviteGuestClaimedTelegramMessageFactory
- Inherits:
-
TelegramMessageFactory
- Object
- TelegramMessageFactory
- SpreeCmCommissioner::InviteGuestClaimedTelegramMessageFactory
- Defined in:
- app/factory/spree_cm_commissioner/invite_guest_claimed_telegram_message_factory.rb
Instance Attribute Summary collapse
-
#guest ⇒ Object
readonly
Returns the value of attribute guest.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#show_details_link ⇒ Object
readonly
Returns the value of attribute show_details_link.
-
#vendor ⇒ Object
readonly
Returns the value of attribute vendor.
Attributes inherited from TelegramMessageFactory
Instance Method Summary collapse
-
#body ⇒ Object
override.
-
#initialize(title:, order:, guest:, **options) ⇒ InviteGuestClaimedTelegramMessageFactory
constructor
A new instance of InviteGuestClaimedTelegramMessageFactory.
- #pretty_date_for(line_item) ⇒ Object
- #selected_line_items ⇒ Object
Methods inherited from TelegramMessageFactory
#bold, #footer, #header, #inline_code, #italic, #message, #parse_mode, #pretty_date
Constructor Details
#initialize(title:, order:, guest:, **options) ⇒ InviteGuestClaimedTelegramMessageFactory
Returns a new instance of InviteGuestClaimedTelegramMessageFactory.
19 20 21 22 23 24 25 26 |
# File 'app/factory/spree_cm_commissioner/invite_guest_claimed_telegram_message_factory.rb', line 19 def initialize(title:, order:, guest:, **) @order = order @vendor = [:vendor] @guest = guest @show_details_link = [:show_details_link] || false super(title: title, subtitle: [:subtitle]) end |
Instance Attribute Details
#guest ⇒ Object (readonly)
Returns the value of attribute guest.
17 18 19 |
# File 'app/factory/spree_cm_commissioner/invite_guest_claimed_telegram_message_factory.rb', line 17 def guest @guest end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
17 18 19 |
# File 'app/factory/spree_cm_commissioner/invite_guest_claimed_telegram_message_factory.rb', line 17 def order @order end |
#show_details_link ⇒ Object (readonly)
Returns the value of attribute show_details_link.
17 18 19 |
# File 'app/factory/spree_cm_commissioner/invite_guest_claimed_telegram_message_factory.rb', line 17 def show_details_link @show_details_link end |
#vendor ⇒ Object (readonly)
Returns the value of attribute vendor.
17 18 19 |
# File 'app/factory/spree_cm_commissioner/invite_guest_claimed_telegram_message_factory.rb', line 17 def vendor @vendor end |
Instance Method Details
#body ⇒ Object
override
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/factory/spree_cm_commissioner/invite_guest_claimed_telegram_message_factory.rb', line 33 def body text = [] text << bold('🙍 Claimed By') text << "Name: #{guest.first_name} #{guest.last_name}" text << "Tel: #{inline_code(guest.phone_number)}" text << '' # Each invitation_link leads to one order with one line_item, claimed by one guest so quantity is always 1. selected_line_items.each do |item| text << bold(item.product.name.to_s) text << '🎟️ Quantity: 1' text << italic("👉 #{item.options_text}") if item..present? text << italic(pretty_date_for(item)) if item.date_present? text << '' end text << bold('Order Number:') text << inline_code(order.number) text.compact.join("\n") end |
#pretty_date_for(line_item) ⇒ Object
56 57 58 59 60 61 |
# File 'app/factory/spree_cm_commissioner/invite_guest_claimed_telegram_message_factory.rb', line 56 def pretty_date_for(line_item) from_date = pretty_date(line_item.from_date) to_date = pretty_date(line_item.to_date) from_date == to_date ? "🗓️ #{from_date}" : "🗓️ #{from_date} -> #{to_date}" end |
#selected_line_items ⇒ Object
28 29 30 |
# File 'app/factory/spree_cm_commissioner/invite_guest_claimed_telegram_message_factory.rb', line 28 def selected_line_items vendor.present? ? order.line_items.for_vendor(vendor) : order.line_items end |