Class: PartyAuthenticableLinkedPartyFinder
- Inherits:
-
Object
- Object
- PartyAuthenticableLinkedPartyFinder
- Defined in:
- app/models/party_authenticable_linked_party_finder.rb
Overview
Resolves a Party + Account pair for “checkout as” / linked authenticable flows
when an email exists only on ContactPoint rows (see PartyAccount.search_for_authenticable_linked_party_by_email).
Constant Summary collapse
- CUSTOMER_SINCE_CUTOFF =
DateTime.parse('2001-1-1').freeze
Class Method Summary collapse
-
.call(email_input) ⇒ Hash?
When permitted, includes
:accountand:party; otherwisenil.
Instance Method Summary collapse
- #initialize(email_input) ⇒ void constructor
-
#result ⇒ Hash?
When permitted, includes
:accountand:party; otherwisenil.
Constructor Details
#initialize(email_input) ⇒ void
18 19 20 |
# File 'app/models/party_authenticable_linked_party_finder.rb', line 18 def initialize(email_input) @email = email_input.to_s.strip.downcase end |
Class Method Details
.call(email_input) ⇒ Hash?
Returns when permitted, includes :account and :party; otherwise nil.
12 13 14 |
# File 'app/models/party_authenticable_linked_party_finder.rb', line 12 def self.call(email_input) new(email_input).result end |
Instance Method Details
#result ⇒ Hash?
Returns when permitted, includes :account and :party; otherwise nil.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/party_authenticable_linked_party_finder.rb', line 23 def result return nil if @email.blank? || Account.exists?(email: @email) party = first_party_matching_email return nil if party&.customer.blank? account = party.customer.account return nil unless permitted?(party, account) { account:, party: } end |