Class: Calendly::User
- Inherits:
-
Object
- Object
- Calendly::User
- Includes:
- ModelUtils
- Defined in:
- lib/calendly/models/user.rb
Overview
Calendly’s user model. Primary account details of a specific user.
Constant Summary collapse
- UUID_RE =
%r{\A#{Client::API_HOST}/users/(#{UUID_FORMAT})\z}.freeze
- TIME_FIELDS =
%i[created_at updated_at].freeze
Constants included from ModelUtils
Instance Attribute Summary collapse
-
#avatar_url ⇒ String
URL of user’s avatar image.
-
#created_at ⇒ Time
Moment when user record was first created.
-
#current_organization ⇒ Calendly::Organization
user’s current organization.
-
#email ⇒ String
User’s email address.
-
#name ⇒ String
User’s human-readable name.
-
#scheduling_url ⇒ String
URL of user’s event page.
-
#slug ⇒ String
Unique readable value used in page URL.
-
#timezone ⇒ String
Timezone offest to use when presenting time information to user.
-
#updated_at ⇒ Time
Moment when user record was last updated.
-
#uri ⇒ String
Canonical resource reference.
-
#uuid ⇒ String
unique id of the User object.
Class Method Summary collapse
Instance Method Summary collapse
-
#create_webhook(url, events, signing_key: nil) ⇒ Calendly::WebhookSubscription
Create a user scope webhook associated with self.
-
#event_types(options: nil) ⇒ Array<Calendly::EventType>
Returns all Event Types associated with self.
- #event_types!(options: nil) ⇒ Object
-
#fetch ⇒ Calendly::User
Get basic information associated with self.
-
#organization_membership ⇒ Calendly::OrganizationMembership
Get an organization membership information associated with self.
- #organization_membership! ⇒ Object
-
#scheduled_events(options: nil) ⇒ Array<Calendly::Event>
Returns all Scheduled Events associated with self.
- #scheduled_events!(options: nil) ⇒ Object
-
#webhooks(options: nil) ⇒ Array<Calendly::WebhookSubscription>
Get List of user scope Webhooks associated with self.
- #webhooks!(options: nil) ⇒ Object
Methods included from ModelUtils
#client, #id, included, #initialize, #inspect
Instance Attribute Details
#avatar_url ⇒ String
URL of user’s avatar image.
39 40 41 |
# File 'lib/calendly/models/user.rb', line 39 def avatar_url @avatar_url end |
#created_at ⇒ Time
Moment when user record was first created.
51 52 53 |
# File 'lib/calendly/models/user.rb', line 51 def created_at @created_at end |
#current_organization ⇒ Calendly::Organization
user’s current organization
59 60 61 |
# File 'lib/calendly/models/user.rb', line 59 def current_organization @current_organization end |
#email ⇒ String
User’s email address.
35 36 37 |
# File 'lib/calendly/models/user.rb', line 35 def email @email end |
#name ⇒ String
User’s human-readable name.
27 28 29 |
# File 'lib/calendly/models/user.rb', line 27 def name @name end |
#scheduling_url ⇒ String
URL of user’s event page.
43 44 45 |
# File 'lib/calendly/models/user.rb', line 43 def scheduling_url @scheduling_url end |
#slug ⇒ String
Unique readable value used in page URL.
31 32 33 |
# File 'lib/calendly/models/user.rb', line 31 def slug @slug end |
#timezone ⇒ String
Timezone offest to use when presenting time information to user.
47 48 49 |
# File 'lib/calendly/models/user.rb', line 47 def timezone @timezone end |
#updated_at ⇒ Time
Moment when user record was last updated.
55 56 57 |
# File 'lib/calendly/models/user.rb', line 55 def updated_at @updated_at end |
#uri ⇒ String
Canonical resource reference.
23 24 25 |
# File 'lib/calendly/models/user.rb', line 23 def uri @uri end |
#uuid ⇒ String
unique id of the User object.
19 20 21 |
# File 'lib/calendly/models/user.rb', line 19 def uuid @uuid end |
Class Method Details
.association ⇒ Object
11 12 13 14 15 |
# File 'lib/calendly/models/user.rb', line 11 def self.association { current_organization: Organization } end |
Instance Method Details
#create_webhook(url, events, signing_key: nil) ⇒ Calendly::WebhookSubscription
Create a user scope webhook associated with self.
184 185 186 187 |
# File 'lib/calendly/models/user.rb', line 184 def create_webhook(url, events, signing_key: nil) org_uri = current_organization&.uri client.create_webhook url, events, org_uri, user_uri: uri, signing_key: signing_key end |
#event_types(options: nil) ⇒ Array<Calendly::EventType>
Returns all Event Types associated with self.
105 106 107 108 109 110 |
# File 'lib/calendly/models/user.rb', line 105 def event_types(options: nil) return @cached_event_types if defined?(@cached_event_types) && @cached_event_types request_proc = proc { |opts| client.event_types_by_user uri, options: opts } @cached_event_types = auto_pagination request_proc, end |
#event_types!(options: nil) ⇒ Object
113 114 115 116 |
# File 'lib/calendly/models/user.rb', line 113 def event_types!(options: nil) @cached_event_types = nil event_types options: end |
#fetch ⇒ Calendly::User
Get basic information associated with self.
68 69 70 |
# File 'lib/calendly/models/user.rb', line 68 def fetch client.user uuid end |
#organization_membership ⇒ Calendly::OrganizationMembership
Get an organization membership information associated with self.
78 79 80 81 82 83 84 85 |
# File 'lib/calendly/models/user.rb', line 78 def organization_membership if defined?(@cached_organization_membership) && @cached_organization_membership return @cached_organization_membership end mems, = client.memberships_by_user uri @cached_organization_membership = mems.first end |
#organization_membership! ⇒ Object
88 89 90 91 |
# File 'lib/calendly/models/user.rb', line 88 def organization_membership! @cached_organization_membership = nil organization_membership end |
#scheduled_events(options: nil) ⇒ Array<Calendly::Event>
Returns all Scheduled Events associated with self.
133 134 135 136 137 138 |
# File 'lib/calendly/models/user.rb', line 133 def scheduled_events(options: nil) return @cached_scheduled_events if defined?(@cached_scheduled_events) && @cached_scheduled_events request_proc = proc { |opts| client.scheduled_events_by_user uri, options: opts } @cached_scheduled_events = auto_pagination request_proc, end |
#scheduled_events!(options: nil) ⇒ Object
141 142 143 144 |
# File 'lib/calendly/models/user.rb', line 141 def scheduled_events!(options: nil) @cached_scheduled_events = nil scheduled_events options: end |
#webhooks(options: nil) ⇒ Array<Calendly::WebhookSubscription>
Get List of user scope Webhooks associated with self.
158 159 160 161 162 163 164 |
# File 'lib/calendly/models/user.rb', line 158 def webhooks(options: nil) return @cached_webhooks if defined?(@cached_webhooks) && @cached_webhooks org_uri = current_organization&.uri request_proc = proc { |opts| client.user_scope_webhooks org_uri, uri, options: opts } @cached_webhooks = auto_pagination request_proc, end |
#webhooks!(options: nil) ⇒ Object
167 168 169 170 |
# File 'lib/calendly/models/user.rb', line 167 def webhooks!(options: nil) @cached_webhooks = nil webhooks options: end |