Class: OwnerMailer
- Inherits:
-
ApplicationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- OwnerMailer
- Defined in:
- app/mailers/owner_mailer.rb
Overview
typed: ignore frozen_string_literal: true
Instance Method Summary collapse
- #assist_group_booking(reservation_id) ⇒ Object
- #booking_cancel(reservation_id) ⇒ Object
- #booking_confirmation(reservation_id) ⇒ Object
- #has_no_reservation_report(restaurant_id, subject, start_date_str, to_receivers, cc_receivers = []) ⇒ Object
- #menu_items_report(body, subject, receivers) ⇒ Object
- #notify_managers(restaurant_id, subject, message) ⇒ Object
- #owner_confirmation(owner_id, _locale) ⇒ Object
- #owner_getstarted(owner_id, locale) ⇒ Object
- #owner_welcome(owner_id, _locale) ⇒ Object
- #packages_list_report(body, subject, receivers) ⇒ Object
- #performance_review_report(body, subject, receivers) ⇒ Object
- #report_user_review(review_id) ⇒ Object
- #reservation_report(restaurant_id, body, subject, to_receivers, cc_receivers = []) ⇒ Object
- #ticket_confirmation(ticket_transaction_id) ⇒ Object
- #vouchers_list_report(body, subject, receivers) ⇒ Object
Methods inherited from ApplicationMailer
Methods included from Workers::Helpers
Instance Method Details
#assist_group_booking(reservation_id) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'app/mailers/owner_mailer.rb', line 152 def assist_group_booking(reservation_id) @reservation = Reservation.fetch(reservation_id).decorate @restaurant = @reservation.restaurant owner = @restaurant.owner @manage_link_as_owner = owner_confirmation_reservation_url(owner.to_url_hash, @reservation.to_url_hash) @menu_link = (@reservation) @as_qr_code = "#{url_helpers.root_url}id_to_qrcode?id=#{@reservation.id}" subject = 'Group Booking request for Large Group' to, cc = booking_report_receivers(owner) mail(to: to, cc: cc, subject: subject, from: BOOKINGS_EMAIL) log_mailer({ reservation_id: reservation_id, restaurant_id: @reservation.restaurant_id, email: to, cc: cc, name: 'OwnerMailer#assist_group_booking', subject: subject, from: BOOKINGS_EMAIL, }) end |
#booking_cancel(reservation_id) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/mailers/owner_mailer.rb', line 44 def booking_cancel(reservation_id) @reservation = Reservation.fetch(reservation_id).decorate template_name = 'booking_cancelled_2022' @restaurant = @reservation.restaurant @owner_show_reservation_link = owner_show_reservation_link(@restaurant.owner) subject = "Reservation Cancelled at #{@restaurant.name} - ID #{reservation_id}" reply_to = [@reservation.email, SUPPORT_EMAIL].compact.join(', ') to, cc = booking_report_receivers(@restaurant.owner) mail(subject: subject, to: to, from: BOOKINGS_EMAIL, cc: cc, template_name: template_name, reply_to: reply_to) do |format| format.html do render template: "owner_mailer/#{template_name}", locals: { subject: subject, reservation: @reservation, restaurant: @restaurant, owner_show_reservation_link: @owner_show_reservation_link, year: year(@restaurant.time_zone), } end end log_mailer({ reservation_id: reservation_id, restaurant_id: @restaurant.id, template_name: template_name, subject: subject, reply_to: reply_to, from: BOOKINGS_EMAIL, cc: cc, to: to }) end |
#booking_confirmation(reservation_id) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/mailers/owner_mailer.rb', line 22 def booking_confirmation(reservation_id) @reservation = Reservation.fetch(reservation_id).decorate @restaurant = @reservation.restaurant template_name = 'v4-restaurant-booking-confirm' set_view_variables to, cc = booking_report_receivers(@restaurant.owner) reply_to = [@reservation.email, SUPPORT_EMAIL].compact.join(', ') mail(subject: booking_confirmation_subject(@reservation), to: to, cc: cc, template_name: template_name, from: BOOKINGS_EMAIL, reply_to: reply_to) log_mailer({ reservation_id: reservation_id, restaurant_id: @restaurant.id, subject: booking_confirmation_subject(@reservation), template_name: template_name, from: BOOKINGS_EMAIL, cc: cc, to: to, reply_to: reply_to }) end |
#has_no_reservation_report(restaurant_id, subject, start_date_str, to_receivers, cc_receivers = []) ⇒ Object
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'app/mailers/owner_mailer.rb', line 197 def has_no_reservation_report(restaurant_id, subject, start_date_str, to_receivers, cc_receivers = []) @restaurant = Restaurant.fetch(restaurant_id) finance_email = finance_email_for_country(@restaurant.country_id) to_receivers = Array(to_receivers) + [finance_email, RAVI_EMAIL] start_date = begin Date.parse(start_date_str) rescue StandardError nil end @report_date = start_date&.strftime('%B %Y') || 'Unknown Date' template_name = 'has_no_reservation_report' mail( to: to_receivers, cc: cc_receivers, subject: subject, # We need to send this email from finance email because it is the only email # that has been verified in AWS SES from: FINANCE_EMAIL_SENDER, reply_to: finance_email, template_name: template_name, ) log_mailer({ subject: subject, restaurant_id: restaurant_id, email_to: to_receivers, email_cc: cc_receivers, template_name: template_name }) end |
#menu_items_report(body, subject, receivers) ⇒ Object
235 236 237 238 239 240 241 242 243 244 |
# File 'app/mailers/owner_mailer.rb', line 235 def (body, subject, receivers) @body = body mail(to: receivers, subject: subject) log_mailer({ email: receivers, name: 'OwnerMailer#menu_items_report', subject: subject, }) end |
#notify_managers(restaurant_id, subject, message) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'app/mailers/owner_mailer.rb', line 11 def notify_managers(restaurant_id, subject, ) owner = Restaurant.fetch(restaurant_id).fetch_owner to, cc = booking_report_receivers(owner) @message = mail(to: to, cc: cc, subject: subject, from: BOOKINGS_EMAIL) log_mailer({ restaurant_id: restaurant_id, email: to, cc: cc, name: 'OwnerMailer#notify_managers', subject: subject, from: BOOKINGS_EMAIL }) end |
#owner_confirmation(owner_id, _locale) ⇒ Object
99 100 101 102 103 104 105 106 107 |
# File 'app/mailers/owner_mailer.rb', line 99 def owner_confirmation(owner_id, _locale) # We disable owner sign up right now # mail( subject: 'Hungry Hub Owner Verification', # to: @owner.email, # cc: cc_email, # 'Importance' => 'high', # 'X-Priority' => 1, # template_name: template_name) end |
#owner_getstarted(owner_id, locale) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'app/mailers/owner_mailer.rb', line 128 def owner_getstarted(owner_id, locale) @owner = Owner.fetch(owner_id) template_name = if locale == 'th' 'restaurant-sign-up-get-started-th' else 'restaurant-sign-up-get-started' end subject = if locale == 'th' 'HungryHub ยืนยันการเปิดใช้งานระบบจองโต๊ะ (เวอร์ชั่นฟร)' else 'You are successfully signup on HungryHub Reservation system (Free version)' end @owner_dashbord_v2 = url_helpers.dashboard_v2_reservations_url mail(subject: subject, to: @owner.email, template_name: template_name) log_mailer({ restaurant_id: @owner.restaurant_id, email: @owner.email, name: 'OwnerMailer#owner_getstarted', subject: subject, }) end |
#owner_welcome(owner_id, _locale) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'app/mailers/owner_mailer.rb', line 109 def owner_welcome(owner_id, _locale) @owner = Owner.fetch(owner_id) template_name = 'restaurant-signup-welcome' cc_email = @owner.restaurant.user&.email @owner_dashbord_v2 = url_helpers.dashboard_v2_reservations_url subject = "Welcome #{@owner.restaurant.name}" mail(subject: subject, to: @owner.email, cc: cc_email, template_name: template_name) log_mailer({ restaurant_id: @owner.restaurant_id, email: @owner.email, cc: cc_email, name: 'OwnerMailer#owner_welcome', subject: subject, }) end |
#packages_list_report(body, subject, receivers) ⇒ Object
246 247 248 249 250 251 252 253 254 255 |
# File 'app/mailers/owner_mailer.rb', line 246 def packages_list_report(body, subject, receivers) @body = body mail(to: receivers, subject: subject) log_mailer({ email: receivers, name: 'OwnerMailer#packages_list_report', subject: subject, }) end |
#performance_review_report(body, subject, receivers) ⇒ Object
257 258 259 260 261 262 263 264 265 266 |
# File 'app/mailers/owner_mailer.rb', line 257 def performance_review_report(body, subject, receivers) @body = body mail(to: receivers, subject: subject) log_mailer({ email: receivers, name: 'OwnerMailer#performance_review_report', subject: subject, }) end |
#report_user_review(review_id) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/mailers/owner_mailer.rb', line 73 def report_user_review(review_id) @review = Review.find_by id: review_id return if @review.blank? template_name = 'review-report-to-restaurant' subject = if @review.reservation.present? "You got a #{@review.} star rating - #{@review.reservation.id}" else "You got a #{@review.} star rating - no reservation data" end receivers = review_report_receivers(@review.reservation.restaurant.owner) @review_public_url = url_helpers.restaurant_review_url(restaurant_id: @review.reservation.restaurant.id, id: @review.encrypted_id, format: :html) mail(subject: subject, to: receivers, template_name: template_name) log_mailer({ restaurant_id: @review.reservation&.restaurant_id, email: receivers, name: 'OwnerMailer#report_user_review', subject: subject, other: { review_id: review_id }, }) end |
#reservation_report(restaurant_id, body, subject, to_receivers, cc_receivers = []) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'app/mailers/owner_mailer.rb', line 174 def reservation_report(restaurant_id, body, subject, to_receivers, cc_receivers = []) restaurant = Restaurant.fetch(restaurant_id) finance_email = finance_email_for_country(restaurant.country_id) to_receivers = Array(to_receivers) + [finance_email, RAVI_EMAIL] @body = body mail( to: to_receivers, cc: cc_receivers, subject: subject, # We need to send this email from finance email because it is the only email # that has been verified in AWS SES from: FINANCE_EMAIL_SENDER, reply_to: finance_email, ) do |format| format.html { render inline: @body } end log_mailer({ subject: subject, restaurant_id: restaurant_id, email_to: to_receivers, email_cc: cc_receivers, body: body, name: 'OwnerMailer#reservation_report' }) end |
#ticket_confirmation(ticket_transaction_id) ⇒ Object
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'app/mailers/owner_mailer.rb', line 268 def ticket_confirmation(ticket_transaction_id) subject = 'Voucher Confirmation' ticket_transaction = TicketTransaction.find(ticket_transaction_id) owner = ticket_transaction.restaurant.owner results = get_ticket_transaction(ticket_transaction_id) total_ticket_amount_cents = get_ticket_sum(ticket_transaction_id) template_name = 'ticket_confirmation' mail(subject: subject, to: owner.email, template_name: template_name) do |format| format.html do render template: "owner_mailer/#{template_name}", locals: { ticket_transaction: ticket_transaction, results: results, total_ticket_amount_cents: total_ticket_amount_cents, currency_code: results.first&.amount_currency || Country::THAI_CURRENCY_CODE, year: year(ticket_transaction.restaurant&.time_zone), } end end log_mailer({ restaurant_id: ticket_transaction.restaurant_id, email: owner.email, name: 'OwnerMailer#ticket_confirmation', subject: subject, other: { ticket_transaction_id: ticket_transaction_id }, }) end |
#vouchers_list_report(body, subject, receivers) ⇒ Object
224 225 226 227 228 229 230 231 232 233 |
# File 'app/mailers/owner_mailer.rb', line 224 def vouchers_list_report(body, subject, receivers) @body = body mail(to: receivers, subject: subject) log_mailer({ email: receivers, name: 'OwnerMailer#vouchers_list_report', subject: subject, }) end |