Class: Updox::Models::Location

Inherits:
Model
  • Object
show all
Defined in:
lib/updox/models/location.rb

Constant Summary collapse

SYNC_ENDPOINT =
'/LocationsSync'.freeze
LIST_ENDPOINT =
'/PracticeLocationsRetrieve'.freeze
LIST_TYPE =
'locations'.freeze
LIST_NAME =
LIST_TYPE
SYNC_LIST_TYPE =
LIST_TYPE

Constants inherited from Model

Model::ITEM_TYPE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#error_message, exists?, from_response, request, #response_code, #response_message, #successful?, sync

Class Method Details

.find(location_id, account_id:, cached_query: nil) ⇒ Object



41
42
43
44
45
# File 'lib/updox/models/location.rb', line 41

def self.find(location_id, account_id: , cached_query: nil)
  obj = cached_query || self.query(account_id: )

  obj.locations.find {|location| location_id.to_s == location.external_id.to_s }
end

.query(account_id:, active_only: false) ⇒ Object



47
48
49
# File 'lib/updox/models/location.rb', line 47

def self.query(account_id: , active_only: false)
  request(endpoint: LIST_ENDPOINT, body: { activeOnly: active_only }, auth: {accountId: }, required_auths: Updox::Models::Auth::AUTH_ACCT)
end

Instance Method Details

#save(account_id:) ⇒ Object



37
38
39
# File 'lib/updox/models/location.rb', line 37

def save(account_id: )
  self.class.sync([self], account_id: )
end