Class: Calendly::User

Inherits:
Object
  • Object
show all
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

ModelUtils::UUID_FORMAT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ModelUtils

#client, #id, included, #initialize, #inspect

Instance Attribute Details

#avatar_urlString

URL of user’s avatar image.

Returns:

  • (String)


37
38
39
# File 'lib/calendly/models/user.rb', line 37

def avatar_url
  @avatar_url
end

#created_atTime

Moment when user record was first created.

Returns:

  • (Time)


49
50
51
# File 'lib/calendly/models/user.rb', line 49

def created_at
  @created_at
end

#current_organizationOrganization

user’s current organization

Returns:



57
58
59
# File 'lib/calendly/models/user.rb', line 57

def current_organization
  @current_organization
end

#emailString

User’s email address.

Returns:

  • (String)


33
34
35
# File 'lib/calendly/models/user.rb', line 33

def email
  @email
end

#nameString

User’s human-readable name.

Returns:

  • (String)


25
26
27
# File 'lib/calendly/models/user.rb', line 25

def name
  @name
end

#scheduling_urlString

URL of user’s event page.

Returns:

  • (String)


41
42
43
# File 'lib/calendly/models/user.rb', line 41

def scheduling_url
  @scheduling_url
end

#slugString

Unique readable value used in page URL.

Returns:

  • (String)


29
30
31
# File 'lib/calendly/models/user.rb', line 29

def slug
  @slug
end

#timezoneString

Timezone offest to use when presenting time information to user.

Returns:

  • (String)


45
46
47
# File 'lib/calendly/models/user.rb', line 45

def timezone
  @timezone
end

#updated_atTime

Moment when user record was last updated.

Returns:

  • (Time)


53
54
55
# File 'lib/calendly/models/user.rb', line 53

def updated_at
  @updated_at
end

#uriString

Canonical resource reference.

Returns:

  • (String)


21
22
23
# File 'lib/calendly/models/user.rb', line 21

def uri
  @uri
end

#uuidString

unique id of the User object.

Returns:

  • (String)


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.

Parameters:

  • url (String)

    Canonical reference (unique identifier) for the resource.

  • events (Array<String>)

    List of user events to subscribe to. options: invitee.created or invitee.canceled

  • signing_key (String) (defaults to: nil)

    secret key shared between your application and Calendly. Optional.

Returns:

Raises:

Since:

  • 0.6.0



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.

Parameters:

  • options (Hash) (defaults to: nil)

    the optional request parameters. Optional.

Options Hash (options:):

  • :active (Boolean)

    Return only active event types if true, only inactive if false, or all event types if this parameter is omitted.

  • :count (Integer)

    Number of rows to return.

  • :page_token (String)

    Pass this to get the next portion of collection.

  • :sort (String)

    Order results by the specified field and direction.

Returns:

Raises:

Since:

  • 0.1.0



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, options
end

#event_types!(options: nil) ⇒ Object

Since:

  • 0.2.0



112
113
114
115
# File 'lib/calendly/models/user.rb', line 112

def event_types!(options: nil)
  @cached_event_types = nil
  event_types options: options
end

#fetchCalendly::User

Get basic information associated with self.

Returns:

Raises:

Since:

  • 0.1.0



66
67
68
# File 'lib/calendly/models/user.rb', line 66

def fetch
  client.user uuid
end

#organization_membershipCalendly::OrganizationMembership

Get an organization membership information associated with self.

Returns:

Raises:

Since:

  • 0.1.0



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

Since:

  • 0.2.0



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.

Parameters:

  • options (Hash) (defaults to: nil)

    the optional request parameters. Optional.

Options Hash (options:):

  • :count (Integer)

    Number of rows to return.

  • :invitee_email (String)

    Return events scheduled with the specified invitee email

  • :max_start_timeUpper (String)

    bound (inclusive) for an event’s start time to filter by.

  • :min_start_time (String)

    Lower bound (inclusive) for an event’s start time to filter by.

  • :page_token (String)

    Pass this to get the next portion of collection.

  • :sort (String)

    Order results by the specified field and directin.

  • :status (String)

    Whether the scheduled event is active or canceled

Returns:

Raises:

Since:

  • 0.1.0



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, options
end

#scheduled_events!(options: nil) ⇒ Object

Since:

  • 0.2.0



141
142
143
144
# File 'lib/calendly/models/user.rb', line 141

def scheduled_events!(options: nil)
  @cached_scheduled_events = nil
  scheduled_events options: 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.

Parameters:

  • options (Hash) (defaults to: nil)

    the optional request parameters. Optional.

Options Hash (options:):

  • :count (Integer)

    Number of rows to return.

  • :page_token (String)

    Pass this to get the next portion of collection.

  • :sort (String)

    Order results by the specified field and directin. Accepts comma-separated list of field:direction values.

Returns:

Raises:

Since:

  • 0.6.0



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, options
end

#webhooks!(options: nil) ⇒ Object

Since:

  • 0.6.0



168
169
170
171
# File 'lib/calendly/models/user.rb', line 168

def webhooks!(options: nil)
  @cached_webhooks = nil
  webhooks options: options
end