Class: Updox::Models::Calendar

Inherits:
Model
  • Object
show all
Extended by:
Extensions::Exists
Defined in:
lib/updox/models/calendar.rb

Constant Summary collapse

SYNC_ENDPOINT =
'/CalendarsSync'.freeze
LIST_ENDPOINT =
'/PracticeCalendarsRetrieve'.freeze
LIST_TYPE =
'calendars'
LIST_NAME =
LIST_TYPE

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 inherited from Model

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

Class Method Details

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



31
32
33
34
35
# File 'lib/updox/models/calendar.rb', line 31

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

  obj.calendars.find {|calendar| calendar_id.to_s == calendar.external_id.to_s }
end

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



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

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

#create(account_id:) ⇒ Object



27
28
29
# File 'lib/updox/models/calendar.rb', line 27

def create(account_id: )
  self.class.request(endpoint: SYNC_ENDPOINT, body: self.to_h, auth: {accountId: }, required_auths: Updox::Models::Auth::AUTH_ACCT)
end