Class: Updox::Models::Location

Inherits:
Model
  • Object
show all
Extended by:
Extensions::Exists, Extensions::Sync
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 included from Extensions::Sync

Extensions::Sync::RECOMMENDED_BATCH_SIZE

Constants inherited from Model

Model::ITEM_TYPE

Instance Attribute Summary

Attributes inherited from Model

#updox_status

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Extensions::Exists

exists?

Methods included from Extensions::Sync

sync

Methods inherited from Model

#as_json, #error_message, from_response, request, #response_code, #response_message, #successful?

Class Method Details

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



44
45
46
47
48
# File 'lib/updox/models/location.rb', line 44

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



50
51
52
# File 'lib/updox/models/location.rb', line 50

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



40
41
42
# File 'lib/updox/models/location.rb', line 40

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