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 =
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
19 20 21 |
# File 'app/models/party_authenticable_linked_party_finder.rb', line 19 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.
13 14 15 |
# File 'app/models/party_authenticable_linked_party_finder.rb', line 13 def self.call(email_input) new(email_input).result end |
Instance Method Details
#result ⇒ Hash?
Returns when permitted, includes :account and :party; otherwise nil.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/party_authenticable_linked_party_finder.rb', line 24 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 |