Module: BookingSync::Engine::Models::MultiApplicationsAccount::ClassMethods

Defined in:
lib/bookingsync/engine/models/multi_applications_account.rb

Instance Method Summary collapse

Instance Method Details

#find_by_host_and_synced_id(host, synced_id) ⇒ Object



25
26
27
# File 'lib/bookingsync/engine/models/multi_applications_account.rb', line 25

def find_by_host_and_synced_id(host, synced_id)
  find_by(host: host, synced_id: synced_id)
end

#from_omniauth(auth, host) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bookingsync/engine/models/multi_applications_account.rb', line 10

def from_omniauth(auth, host)
  if host.blank?
    raise ArgumentError, "The `host` variable must be passed when using BookingSync Engine with " \
                         "multi application support"
  end

   = find_or_initialize_by(host: host, synced_id: auth.uid, provider: auth.provider)

  .tap do ||
    .name = auth.info.business_name
    .update_token(auth.credentials)
    .save!
  end
end