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

Constants included from ModelUtils

ModelUtils::UUID_FORMAT

Instance Attribute Summary collapse

Class Method 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)


39
40
41
# File 'lib/calendly/models/user.rb', line 39

def avatar_url
  @avatar_url
end

#created_atTime

Moment when user record was first created.

Returns:

  • (Time)


51
52
53
# File 'lib/calendly/models/user.rb', line 51

def created_at
  @created_at
end

#current_organizationCalendly::Organization

user’s current organization



59
60
61
# File 'lib/calendly/models/user.rb', line 59

def current_organization
  @current_organization
end

#emailString

User’s email address.

Returns:

  • (String)


35
36
37
# File 'lib/calendly/models/user.rb', line 35

def email
  @email
end

#nameString

User’s human-readable name.

Returns:

  • (String)


27
28
29
# File 'lib/calendly/models/user.rb', line 27

def name
  @name
end

#scheduling_urlString

URL of user’s event page.

Returns:

  • (String)


43
44
45
# File 'lib/calendly/models/user.rb', line 43

def scheduling_url
  @scheduling_url
end

#slugString

Unique readable value used in page URL.

Returns:

  • (String)


31
32
33
# File 'lib/calendly/models/user.rb', line 31

def slug
  @slug
end

#timezoneString

Timezone offest to use when presenting time information to user.

Returns:

  • (String)


47
48
49
# File 'lib/calendly/models/user.rb', line 47

def timezone
  @timezone
end

#updated_atTime

Moment when user record was last updated.

Returns:

  • (Time)


55
56
57
# File 'lib/calendly/models/user.rb', line 55

def updated_at
  @updated_at
end

#uriString

Canonical resource reference.

Returns:

  • (String)


23
24
25
# File 'lib/calendly/models/user.rb', line 23

def uri
  @uri
end

#uuidString

unique id of the User object.

Returns:

  • (String)


19
20
21
# File 'lib/calendly/models/user.rb', line 19

def uuid
  @uuid
end

Class Method Details

.associationObject



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.

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



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.

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. Accepts comma-separated list of field:direction values.

Returns:

Raises:

Since:

  • 0.1.0



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

#event_types!(options: nil) ⇒ Object

Since:

  • 0.2.0



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

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



68
69
70
# File 'lib/calendly/models/user.rb', line 68

def fetch
  client.user uuid
end

#organization_membershipCalendly::OrganizationMembership

Get an organization membership information associated with self.

Returns:

Raises:

Since:

  • 0.1.0



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

Since:

  • 0.2.0



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.

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. Accepts comma-separated list of field:direction values.

  • :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.

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



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

#webhooks!(options: nil) ⇒ Object

Since:

  • 0.6.0



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

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