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
- ASSOCIATION =
{current_organization: Organization}.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 ⇒ 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.
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.
37 38 39 |
# File 'lib/calendly/models/user.rb', line 37 def avatar_url @avatar_url end |
#created_at ⇒ Time
Moment when user record was first created.
49 50 51 |
# File 'lib/calendly/models/user.rb', line 49 def created_at @created_at end |
#current_organization ⇒ Organization
user’s current organization
57 58 59 |
# File 'lib/calendly/models/user.rb', line 57 def current_organization @current_organization end |
#email ⇒ String
User’s email address.
33 34 35 |
# File 'lib/calendly/models/user.rb', line 33 def email @email end |
#name ⇒ String
User’s human-readable name.
25 26 27 |
# File 'lib/calendly/models/user.rb', line 25 def name @name end |
#scheduling_url ⇒ String
URL of user’s event page.
41 42 43 |
# File 'lib/calendly/models/user.rb', line 41 def scheduling_url @scheduling_url end |
#slug ⇒ String
Unique readable value used in page URL.
29 30 31 |
# File 'lib/calendly/models/user.rb', line 29 def slug @slug end |
#timezone ⇒ String
Timezone offest to use when presenting time information to user.
45 46 47 |
# File 'lib/calendly/models/user.rb', line 45 def timezone @timezone end |
#updated_at ⇒ Time
Moment when user record was last updated.
53 54 55 |
# File 'lib/calendly/models/user.rb', line 53 def updated_at @updated_at end |
#uri ⇒ String
Canonical resource reference.
21 22 23 |
# File 'lib/calendly/models/user.rb', line 21 def uri @uri end |
#uuid ⇒ String
unique id of the User object.
17 18 19 |
# File 'lib/calendly/models/user.rb', line 17 def uuid @uuid end |
Instance Method Details
#create_webhook(url, events, signing_key: nil) ⇒ Calendly::WebhookSubscription
Create a user scope webhook associated with self.
185 186 187 188 |
# File 'lib/calendly/models/user.rb', line 185 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.
Accepts comma-separated list of field:direction values.
104 105 106 107 108 109 |
# File 'lib/calendly/models/user.rb', line 104 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
112 113 114 115 |
# File 'lib/calendly/models/user.rb', line 112 def event_types!(options: nil) @cached_event_types = nil event_types options: end |
#fetch ⇒ Calendly::User
Get basic information associated with self.
66 67 68 |
# File 'lib/calendly/models/user.rb', line 66 def fetch client.user uuid end |
#organization_membership ⇒ Calendly::OrganizationMembership
Get an organization membership information associated with self.
76 77 78 79 80 81 82 83 |
# File 'lib/calendly/models/user.rb', line 76 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
86 87 88 89 |
# File 'lib/calendly/models/user.rb', line 86 def organization_membership! @cached_organization_membership = nil organization_membership end |
#scheduled_events(options: nil) ⇒ Array<Calendly::Event>
Returns all Scheduled Events associated with self.
Accepts comma-separated list of field:direction values.
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.
Accepts comma-separated list of field:direction values.
159 160 161 162 163 164 165 |
# File 'lib/calendly/models/user.rb', line 159 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
168 169 170 171 |
# File 'lib/calendly/models/user.rb', line 168 def webhooks!(options: nil) @cached_webhooks = nil webhooks options: end |