Class: SpreeCmCommissioner::EventTicketGoogleWallet

Inherits:
GoogleWallet
  • Object
show all
Defined in:
app/models/spree_cm_commissioner/event_ticket_google_wallet.rb

Constant Summary

Constants inherited from GoogleWallet

GoogleWallet::TYPES

Instance Method Summary collapse

Instance Method Details

#class_creatorObject



69
70
71
# File 'app/models/spree_cm_commissioner/event_ticket_google_wallet.rb', line 69

def class_creator
  SpreeCmCommissioner::GoogleWallets::EventTicketClassCreator.new(self)
end

#class_updaterObject



73
74
75
# File 'app/models/spree_cm_commissioner/event_ticket_google_wallet.rb', line 73

def class_updater
  SpreeCmCommissioner::GoogleWallets::EventTicketClassUpdater.new(self)
end

#event_end_dateObject



59
60
61
# File 'app/models/spree_cm_commissioner/event_ticket_google_wallet.rb', line 59

def event_end_date
  product.event&.to_date
end

#event_start_dateObject



55
56
57
# File 'app/models/spree_cm_commissioner/event_ticket_google_wallet.rb', line 55

def event_start_date
  product.event&.from_date
end

#object_builderObject



77
78
79
# File 'app/models/spree_cm_commissioner/event_ticket_google_wallet.rb', line 77

def object_builder
  SpreeCmCommissioner::GoogleWallets::EventTicketObjectBuilder
end

#set_class_idObject



63
64
65
66
67
# File 'app/models/spree_cm_commissioner/event_ticket_google_wallet.rb', line 63

def set_class_id
  return unless class_id.nil?

  self.class_id = product.slug
end

#set_default_preferencesObject



24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/spree_cm_commissioner/event_ticket_google_wallet.rb', line 24

def set_default_preferences
  self.preferred_issuer_name ||= product.vendor.name
  self.preferred_event_name ||= product.name
  self.preferred_venue_name ||= product.venue.place.name
  self.preferred_venue_address ||= product.venue.place.vicinity
  self.preferred_start_date = event_start_date unless event_start_date.nil?
  self.preferred_end_date = event_end_date unless event_end_date.nil?
  self.preferred_background_color = '#000000'
  self.preferred_response = nil
  self.preferred_verified_at = nil
end

#verified?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/models/spree_cm_commissioner/event_ticket_google_wallet.rb', line 36

def verified?
  preferred_verified_at.present? && preferred_response.present?
end

#verified_atObject



51
52
53
# File 'app/models/spree_cm_commissioner/event_ticket_google_wallet.rb', line 51

def verified_at
  DateTime.parse(preferred_verified_at).strftime('%B %d, %Y %I:%M %p') if preferred_verified_at.present?
end

#verify!Object



46
47
48
49
# File 'app/models/spree_cm_commissioner/event_ticket_google_wallet.rb', line 46

def verify!
  self.preferred_verified_at = DateTime.current
  save!
end

#verify_create!(response) ⇒ Object



40
41
42
43
44
# File 'app/models/spree_cm_commissioner/event_ticket_google_wallet.rb', line 40

def verify_create!(response)
  self.preferred_verified_at = DateTime.current
  self.preferred_response = response if response.present?
  save!
end