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/(\w+)\z}.freeze
TIME_FIELDS =
%i[created_at updated_at].freeze

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)


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

def avatar_url
  @avatar_url
end

#created_atTime

Moment when user record was first created.

Returns:

  • (Time)


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

def created_at
  @created_at
end

#emailString

User’s email address.

Returns:

  • (String)


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

def email
  @email
end

#nameString

User’s human-readable name.

Returns:

  • (String)


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

def name
  @name
end

#scheduling_urlString

URL of user’s event page.

Returns:

  • (String)


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

def scheduling_url
  @scheduling_url
end

#slugString

Unique readable value used in page URL.

Returns:

  • (String)


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

def slug
  @slug
end

#timezoneString

Timezone offest to use when presenting time information to user.

Returns:

  • (String)


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

def timezone
  @timezone
end

#updated_atTime

Moment when user record was last updated.

Returns:

  • (Time)


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

def updated_at
  @updated_at
end

#uriString

Canonical resource reference.

Returns:

  • (String)


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

def uri
  @uri
end

#uuidString

unique id of the User object.

Returns:

  • (String)


16
17
18
# File 'lib/calendly/models/user.rb', line 16

def uuid
  @uuid
end

Instance Method Details

#event_types(opts = {}) ⇒ Array<Calendly::EventType>

Returns all Event Types associated with self.

Accepts comma-separated list of field:direction values.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional request parameters.

Options Hash (opts):

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



87
88
89
90
91
92
# File 'lib/calendly/models/user.rb', line 87

def event_types(opts = {})
  return @cached_event_types if @cached_event_types

  request_proc = proc { |options| client.event_types uri, options }
  @cached_event_types = auto_pagination request_proc, opts
end

#event_types!(opts = {}) ⇒ Object

Since:

  • 0.2.0



95
96
97
98
# File 'lib/calendly/models/user.rb', line 95

def event_types!(opts = {})
  @cached_event_types = nil
  event_types opts
end

#fetchCalendly::User

Get basic information associated with self.

Returns:

Raises:

Since:

  • 0.1.0



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

def fetch
  client.user uuid
end

#organization_membershipCalendly::OrganizationMembership

Get an organization membership information associated with self.

Returns:

Raises:

Since:

  • 0.1.0



62
63
64
65
66
67
# File 'lib/calendly/models/user.rb', line 62

def organization_membership
  return @cached_organization_membership if @cached_organization_membership

  mems, = client.memberships_by_user uri
  @cached_organization_membership = mems.first
end

#organization_membership!Object

Since:

  • 0.2.0



70
71
72
73
# File 'lib/calendly/models/user.rb', line 70

def organization_membership!
  @cached_organization_membership = nil
  organization_membership
end

#scheduled_events(opts = {}) ⇒ Array<Calendly::Event>

Returns all Scheduled Events associated with self.

Accepts comma-separated list of field:direction values.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional request parameters.

Options Hash (opts):

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



116
117
118
119
120
121
# File 'lib/calendly/models/user.rb', line 116

def scheduled_events(opts = {})
  return @cached_scheduled_events if @cached_scheduled_events

  request_proc = proc { |options| client.scheduled_events_by_user uri, options }
  @cached_scheduled_events = auto_pagination request_proc, opts
end

#scheduled_events!(opts = {}) ⇒ Object

Since:

  • 0.2.0



124
125
126
127
# File 'lib/calendly/models/user.rb', line 124

def scheduled_events!(opts = {})
  @cached_scheduled_events = nil
  scheduled_events opts
end