Class: Calendly::Client

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/calendly/client.rb

Overview

Calendly apis client.

Constant Summary collapse

API_HOST =
'https://api.calendly.com'
AUTH_API_HOST =
'https://auth.calendly.com'

Instance Method Summary collapse

Methods included from Loggable

#debug_log, #error_log, #info_log, #warn_log

Constructor Details

#initialize(token = nil) ⇒ Client

Returns a new instance of Client.

Parameters:

  • token (String) (defaults to: nil)

    a Calendly’s access token.

Raises:



16
17
18
19
20
21
22
# File 'lib/calendly/client.rb', line 16

def initialize(token = nil)
  @config = Calendly.configuration
  @token = token || Calendly.configuration.token

  check_not_empty @token, 'token'
  check_token
end

Instance Method Details

#access_tokenOAuth2::AccessToken

Get access token object.

Returns:

  • (OAuth2::AccessToken)

Since:

  • 0.0.1



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/calendly/client.rb', line 29

def access_token
  return @access_token if defined?(@access_token) && @access_token

  client = OAuth2::Client.new(@config.client_id,
                              @config.client_secret, client_options)
  @access_token = OAuth2::AccessToken.new(
    client, @token,
    refresh_token: @config.refresh_token,
    expires_at: @config.token_expires_at
  )
end

#activity_log_entries(org_uri, options: nil) ⇒ Array<Array<Calendly::ActivityLogEntry>, Hash, Hash>

Returns a list of activity log entries.

Parameters:

  • org_uri (String)

    Return activity log entries from the organization associated with this URI.

  • options (Hash) (defaults to: nil)

    the optional request parameters. Optional.

Options Hash (options:):

  • :action (Array<String>)

    The action(s) associated with the entries.

  • :actor (Array<String>)

    Return entries from the user(s) associated with the provided URIs.

  • :count (Integer)

    The number of rows to return.

  • :max_occurred_at (String)

    include entries that occurred prior to this time.

  • :min_occurred_at (String)

    Include entries that occurred after this time.

  • :namespace (Array<String>)

    The categories of the entries.

  • :page_token (String)

    The token to pass to get the next portion of the collection.

  • :search_term (String)

    Filters entries based on the search term.

  • :sort (Array<String>)

    Order results by the specified field and direction. List of field:direction values.

Returns:

  • (Array<Array<Calendly::ActivityLogEntry>, Hash, Hash>)
    • Array<Calendly::ActivityLogEntry>

      log_entries

    • Hash

      next_params the parameters to get next data. if thre is no next it returns nil.

    • Hash

      raw_response

Raises:

Since:

  • 0.14.0



424
425
426
427
428
429
430
431
432
433
434
435
# File 'lib/calendly/client.rb', line 424

def activity_log_entries(org_uri, options: nil)
  check_not_empty org_uri, 'org_uri'

  opts_keys = %i[action actor count max_occurred_at min_occurred_at namespace page_token search_term sort]
  params = {organization: org_uri}
  params = merge_options options, opts_keys, params
  body = request :get, 'activity_log_entries', params: params

  items = body[:collection] || []
  log_entries = items.map { |item| ActivityLogEntry.new item, self }
  [log_entries, next_page_params(body), body]
end

#cancel_event(uuid, options: nil) ⇒ Calendly::InviteeCancellation

Cancels specified event.

Parameters:

  • uuid (String)

    the event’s unique indentifier.

  • options (Hash) (defaults to: nil)

    the optional request parameters. Optional.

Options Hash (options:):

  • :reason (String)

    reason for cancellation.

Returns:

Raises:

Since:

  • 0.11.0



247
248
249
250
251
252
253
254
255
# File 'lib/calendly/client.rb', line 247

def cancel_event(uuid, options: nil)
  check_not_empty uuid, 'uuid'

  opts_keys = %i[reason]
  params = merge_options options, opts_keys

  body = request :post, "scheduled_events/#{uuid}/cancellation", body: params
  InviteeCancellation.new body[:resource], self
end

#create_invitation(uuid, email) ⇒ Calendly::OrganizationInvitation

Invite a person to an Organization.

Parameters:

  • uuid (String)

    the specified organization (organization’s uuid).

  • email (String)

    Email of the person being invited.

Returns:

Raises:

Since:

  • 0.0.7



575
576
577
578
579
580
581
582
583
584
# File 'lib/calendly/client.rb', line 575

def create_invitation(uuid, email)
  check_not_empty uuid, 'uuid'
  check_not_empty email, 'email'
  body = request(
    :post,
    "organizations/#{uuid}/invitations",
    body: {email: email}
  )
  OrganizationInvitation.new body[:resource], self
end

#create_invitee_no_show(invitee_uri) ⇒ Calendly::InviteeNoShow

Create Invitee No Show Marks an Invitee as a No Show.

Parameters:

  • invitee_uri (String)

    the specified invitee’s uri.

Returns:

Raises:

Since:

  • 0.9.0



359
360
361
362
363
364
365
366
367
# File 'lib/calendly/client.rb', line 359

def create_invitee_no_show(invitee_uri)
  check_not_empty invitee_uri, 'invitee_uri'
  body = request(
    :post,
    'invitee_no_shows',
    body: {invitee: invitee_uri}
  )
  InviteeNoShow.new body[:resource], self
end

Create a scheduling link.

e.g.

booking_url: "https://calendly.com/s/FOO-BAR-SLUG",
owner: "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2",
owner_type: "EventType"

Parameters:

  • uri (String)

    A link to the resource that owns this scheduling Link.

  • max_event_count (String) (defaults to: 1)

    The max number of events that can be scheduled using this scheduling link.

  • owner_type (String) (defaults to: 'EventType')

    Resource type.

Returns:

  • (Hash)

Raises:

Since:

  • 0.5.2



818
819
820
821
822
823
824
825
826
827
828
829
# File 'lib/calendly/client.rb', line 818

def create_schedule_link(uri, max_event_count: 1, owner_type: 'EventType')
  check_not_empty uri, 'uri'
  check_not_empty max_event_count, 'max_event_count'
  check_not_empty owner_type, 'owner_type'
  params = {
    max_event_count: max_event_count,
    owner: uri,
    owner_type: owner_type
  }
  body = request :post, 'scheduling_links', body: params
  body[:resource]
end

#create_webhook(url, events, org_uri, user_uri: nil, signing_key: nil) ⇒ Calendly::WebhookSubscription

Create a webhook subscription for an organization or user.

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 or routing_form_submission.created

  • org_uri (String)

    The unique reference to the organization that the webhook will be tied to.

  • user_uri (String) (defaults to: nil)

    The unique reference to the user that the webhook will be tied to. Optional.

  • signing_key (String) (defaults to: nil)

    secret key shared between your application and Calendly. Optional.

Returns:

Raises:

Since:

  • 0.1.3



686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
# File 'lib/calendly/client.rb', line 686

def create_webhook(url, events, org_uri, user_uri: nil, signing_key: nil) # rubocop:disable Metrics/ParameterLists
  check_not_empty url, 'url'
  check_not_empty events, 'events'
  check_not_empty org_uri, 'org_uri'

  params = {url: url, events: events, organization: org_uri}
  params[:signing_key] = signing_key if signing_key

  if user_uri
    params[:scope] = 'user'
    params[:user] = user_uri
  else
    params[:scope] = 'organization'
  end
  body = request :post, 'webhook_subscriptions', body: params
  WebhookSubscription.new body[:resource], self
end

#current_userCalendly::User Also known as: me

Get basic information about current user.

Returns:

Raises:

Since:

  • 0.0.1



63
64
65
66
67
# File 'lib/calendly/client.rb', line 63

def current_user
  return @cached_current_user if defined?(@cached_current_user) && @cached_current_user

  @cached_current_user = user
end

#current_user!Object Also known as: me!

Since:

  • 0.2.0



72
73
74
75
# File 'lib/calendly/client.rb', line 72

def current_user!
  @cached_current_user = nil
  current_user
end

#delete_invitation(org_uuid, inv_uuid) ⇒ true

Revoke Organization Invitation.

Parameters:

  • org_uuid (String)

    the specified organization (organization’s uuid).

  • inv_uuid (String)

    the specified invitation (organization invitation’s uuid).

Returns:

  • (true)

Raises:

Since:

  • 0.0.7



596
597
598
599
600
601
# File 'lib/calendly/client.rb', line 596

def delete_invitation(org_uuid, inv_uuid)
  check_not_empty org_uuid, 'org_uuid'
  check_not_empty inv_uuid, 'inv_uuid'
  request :delete, "organizations/#{org_uuid}/invitations/#{inv_uuid}"
  true
end

#delete_invitee_data(emails) ⇒ true

Delete Invitee Data To submit a request to remove invitee data from all previously booked events in your organization.

Parameters:

  • emails (Array<String>)

    invitees’ emails

Returns:

  • (true)

Raises:

Since:

  • 0.10.0



393
394
395
396
397
398
399
400
401
# File 'lib/calendly/client.rb', line 393

def delete_invitee_data(emails)
  check_not_empty emails, 'emails'
  request(
    :post,
    'data_compliance/deletion/invitees',
    body: {emails: emails}
  )
  true
end

#delete_invitee_no_show(uuid) ⇒ true

Delete Invitee No Show Undoes marking an Invitee as a No Show.

Parameters:

  • uuid (String)

    the specified no show.

Returns:

  • (true)

Raises:

Since:

  • 0.9.0



378
379
380
381
382
# File 'lib/calendly/client.rb', line 378

def delete_invitee_no_show(uuid)
  check_not_empty uuid, 'uuid'
  request :delete, "invitee_no_shows/#{uuid}"
  true
end

#delete_membership(uuid) ⇒ true

Remove a User from an Organization.

Parameters:

  • uuid (String)

    the specified memberhip (organization memberhips’s uuid).

Returns:

  • (true)

Raises:

Since:

  • 0.0.7



513
514
515
516
517
# File 'lib/calendly/client.rb', line 513

def delete_membership(uuid)
  check_not_empty uuid, 'uuid'
  request :delete, "organization_memberships/#{uuid}"
  true
end

#delete_webhook(uuid) ⇒ true

Delete a webhook subscription for an organization or user with a specified UUID.

Parameters:

  • uuid (String)

    the specified webhook (webhook’s uuid).

Returns:

  • (true)

Raises:

Since:

  • 0.1.3



712
713
714
715
716
# File 'lib/calendly/client.rb', line 712

def delete_webhook(uuid)
  check_not_empty uuid, 'uuid'
  request :delete, "webhook_subscriptions/#{uuid}"
  true
end

#event_invitee(ev_uuid, inv_uuid) ⇒ Calendly::Invitee

Get Invitee of an Event Returns a single Invitee by their URI.

Parameters:

  • ev_uuid (String)

    the specified event (event’s uuid).

  • inv_uuid (String)

    the specified invitee (invitee’s uuid).

Returns:

Raises:

Since:

  • 0.0.4



300
301
302
303
304
305
# File 'lib/calendly/client.rb', line 300

def event_invitee(ev_uuid, inv_uuid)
  check_not_empty ev_uuid, 'ev_uuid'
  check_not_empty inv_uuid, 'inv_uuid'
  body = request :get, "scheduled_events/#{ev_uuid}/invitees/#{inv_uuid}"
  Invitee.new body[:resource], self
end

#event_invitees(uuid, options: nil) ⇒ Array<Array<Calendly::Invitee>, Hash>

Get List of Event Invitees.

Parameters:

  • uuid (String)

    the specified event (event’s uuid).

  • options (Hash) (defaults to: nil)

    the optional request parameters. Optional.

Options Hash (options:):

  • :count (Integer)

    Number of rows to return.

  • :email (String)

    Filter by email.

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

  • (Array<Array<Calendly::Invitee>, Hash>)
    • Array<Calendly::Invitee>

      invitees

    • Hash

      next_params the parameters to get next data. if thre is no next it returns nil.

Raises:

Since:

  • 0.0.4



323
324
325
326
327
328
329
330
331
332
333
# File 'lib/calendly/client.rb', line 323

def event_invitees(uuid, options: nil)
  check_not_empty uuid, 'uuid'

  opts_keys = %i[count email page_token sort status]
  params = merge_options options, opts_keys
  body = request :get, "scheduled_events/#{uuid}/invitees", params: params

  items = body[:collection] || []
  evs = items.map { |item| Invitee.new item, self }
  [evs, next_page_params(body)]
end

#event_type(uuid) ⇒ Calendly::EventType

Returns a single Event Type by its UUID.

Parameters:

  • uuid (String)

    the specified event type (event type’s uuid).

Returns:

Raises:

Since:

  • 0.4.1



101
102
103
104
105
# File 'lib/calendly/client.rb', line 101

def event_type(uuid)
  check_not_empty uuid, 'uuid'
  body = request :get, "event_types/#{uuid}"
  EventType.new body[:resource], self
end

#event_type_available_times(event_type_uri, start_time: nil, end_time: nil) ⇒ Array<Calendly::EventTypeAvailableTime>

Returns a list of available times for an event type within a specified date range. Date range can be no greater than 1 week (7 days).

Parameters:

  • event_type_uri (String)

    The uri associated with the event type.

  • start_time (String) (defaults to: nil)

    Start time of the requested availability range.

  • end_time (String) (defaults to: nil)

    End time of the requested availability range.

Returns:

Raises:

Since:

  • 0.13.0



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/calendly/client.rb', line 174

def event_type_available_times(event_type_uri, start_time: nil, end_time: nil)
  check_not_empty event_type_uri, 'event_type_uri'

  start_time_buffer = 60 # For working around an invalid request which be caused by specifying a past time
  max_date_range = 60 * 60 * 24 * 7 # 7 days

  # If start_time is undefined, set it to now.
  start_time ||= (Time.now + start_time_buffer).utc.iso8601
  # If end_time is undefined, set it to in the max date range from start_time.
  end_time ||= (Time.parse(start_time) + max_date_range).utc.iso8601

  params = {event_type: event_type_uri, start_time: start_time, end_time: end_time}
  body = request :get, 'event_type_available_times', params: params

  items = body[:collection] || []
  items.map { |item| EventTypeAvailableTime.new item, self }
end

#event_types(org_uri, options: nil) ⇒ Array<Array<Calendly::EventType>, Hash>

Returns all Event Types associated with a specified organization.

Parameters:

  • org_uri (String)

    the specified organization (organization’s uri).

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

  • (Array<Array<Calendly::EventType>, Hash>)
    • Array<Calendly::EventType>

      event types

    • Hash

      next_params the parameters to get next data. if thre is no next it returns nil.

Raises:

Since:

  • 0.6.0



122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/calendly/client.rb', line 122

def event_types(org_uri, options: nil)
  check_not_empty org_uri, 'org_uri'

  opts_keys = %i[active count page_token sort]
  params = {organization: org_uri}
  params = merge_options options, opts_keys, params
  body = request :get, 'event_types', params: params

  items = body[:collection] || []
  ev_types = items.map { |item| EventType.new item, self }
  [ev_types, next_page_params(body)]
end

#event_types_by_user(user_uri, options: nil) ⇒ Array<Array<Calendly::EventType>, Hash>

Returns all Event Types associated with a specified user.

Parameters:

  • user_uri (String)

    the specified user (user’s uri).

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

  • (Array<Array<Calendly::EventType>, Hash>)
    • Array<Calendly::EventType>

      event types

    • Hash

      next_params the parameters to get next data. if thre is no next it returns nil.

Raises:

Since:

  • 0.0.2



150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/calendly/client.rb', line 150

def event_types_by_user(user_uri, options: nil)
  check_not_empty user_uri, 'user_uri'

  opts_keys = %i[active count page_token sort]
  params = {user: user_uri}
  params = merge_options options, opts_keys, params
  body = request :get, 'event_types', params: params

  items = body[:collection] || []
  ev_types = items.map { |item| EventType.new item, self }
  [ev_types, next_page_params(body)]
end

#invitation(org_uuid, inv_uuid) ⇒ Calendly::OrganizationInvitation

Returns an Organization Invitation.

Parameters:

  • org_uuid (String)

    the specified organization (organization’s uuid).

  • inv_uuid (String)

    the specified invitation (organization invitation’s uuid).

Returns:

Raises:

Since:

  • 0.0.6



529
530
531
532
533
534
535
# File 'lib/calendly/client.rb', line 529

def invitation(org_uuid, inv_uuid)
  check_not_empty org_uuid, 'org_uuid'
  check_not_empty inv_uuid, 'inv_uuid'

  body = request :get, "organizations/#{org_uuid}/invitations/#{inv_uuid}"
  OrganizationInvitation.new body[:resource], self
end

#invitations(uuid, options: nil) ⇒ <Array<Array<Calendly::OrganizationInvitation>, Hash>] - [Array<Calendly::OrganizationInvitation>] organizations - [Hash] next_params the parameters to get next data. if thre is no next it returns nil.

Get Organization Invitations.

Parameters:

  • uuid (String)

    the specified organization (organization’s uuid).

  • options (Hash) (defaults to: nil)

    the optional request parameters. Optional.

Options Hash (options:):

  • :count (Integer)

    Number of rows to return.

  • :email (String)

    Filter by email.

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

    Filter by status.

Returns:

  • (<Array<Array<Calendly::OrganizationInvitation>, Hash>] - [Array<Calendly::OrganizationInvitation>] organizations - [Hash] next_params the parameters to get next data. if thre is no next it returns nil.)

    <Array<Array<Calendly::OrganizationInvitation>, Hash>]

    • Array<Calendly::OrganizationInvitation>

      organizations

    • Hash

      next_params the parameters to get next data. if thre is no next it returns nil.

Raises:

Since:

  • 0.0.6



553
554
555
556
557
558
559
560
561
562
563
# File 'lib/calendly/client.rb', line 553

def invitations(uuid, options: nil)
  check_not_empty uuid, 'uuid'

  opts_keys = %i[count email page_token sort status]
  params = merge_options options, opts_keys

  body = request :get, "organizations/#{uuid}/invitations", params: params
  items = body[:collection] || []
  evs = items.map { |item| OrganizationInvitation.new item, self }
  [evs, next_page_params(body)]
end

#invitee_no_show(uuid) ⇒ Calendly::InviteeNoShow

Get Invitee No Show Returns information about a specified Invitee No Show.

Parameters:

  • uuid (String)

    the specified no show.

Returns:

Raises:

Since:

  • 0.9.0



344
345
346
347
348
# File 'lib/calendly/client.rb', line 344

def invitee_no_show(uuid)
  check_not_empty uuid, 'uuid'
  body = request :get, "invitee_no_shows/#{uuid}"
  InviteeNoShow.new body[:resource], self
end

#membership(uuid) ⇒ Calendly::OrganizationMembership

Returns information about a user’s organization membership

Parameters:

  • uuid (String)

    the specified membership (organization membership’s uuid).

Returns:

Raises:

Since:

  • 0.0.5



445
446
447
448
449
# File 'lib/calendly/client.rb', line 445

def membership(uuid)
  check_not_empty uuid, 'uuid'
  body = request :get, "organization_memberships/#{uuid}"
  OrganizationMembership.new body[:resource], self
end

#memberships(org_uri, options: nil) ⇒ Array<Array<Calendly::OrganizationMembership>, Hash>

Get List of memberships belonging to specific an organization.

Parameters:

  • org_uri (String)

    the specified organization (organization’s uri).

  • options (Hash) (defaults to: nil)

    the optional request parameters. Optional.

Options Hash (options:):

  • :count (Integer)

    Number of rows to return.

  • :email (String)

    Filter by email.

  • :page_token (String)

    Pass this to get the next portion of collection.

Returns:

  • (Array<Array<Calendly::OrganizationMembership>, Hash>)
    • Array<Calendly::OrganizationMembership>

      memberships

    • Hash

      next_params the parameters to get next data. if thre is no next it returns nil.

Raises:

Since:

  • 0.0.5



465
466
467
468
469
470
471
472
473
474
475
476
# File 'lib/calendly/client.rb', line 465

def memberships(org_uri, options: nil)
  check_not_empty org_uri, 'org_uri'

  opts_keys = %i[count email page_token]
  params = {organization: org_uri}
  params = merge_options options, opts_keys, params
  body = request :get, 'organization_memberships', params: params

  items = body[:collection] || []
  memberships = items.map { |item| OrganizationMembership.new item, self }
  [memberships, next_page_params(body)]
end

#memberships_by_user(user_uri, options: nil) ⇒ Array<Array<Calendly::OrganizationMembership>, Hash>

Get List of memberships belonging to specific a user.

Parameters:

  • user_uri (String)

    the specified user (user’s uri).

  • options (Hash) (defaults to: nil)

    the optional request parameters. Optional.

Options Hash (options:):

  • :count (Integer)

    Number of rows to return.

  • :email (String)

    Filter by email.

  • :page_token (String)

    Pass this to get the next portion of collection.

Returns:

  • (Array<Array<Calendly::OrganizationMembership>, Hash>)
    • Array<Calendly::OrganizationMembership>

      memberships

    • Hash

      next_params the parameters to get next data. if thre is no next it returns nil.

Raises:

Since:

  • 0.0.5



492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/calendly/client.rb', line 492

def memberships_by_user(user_uri, options: nil)
  check_not_empty user_uri, 'user_uri'

  opts_keys = %i[count email page_token]
  params = {user: user_uri}
  params = merge_options options, opts_keys, params
  body = request :get, 'organization_memberships', params: params

  items = body[:collection] || []
  memberships = items.map { |item| OrganizationMembership.new item, self }
  [memberships, next_page_params(body)]
end

#refresh!Object

Refresh access token.

Raises:

Since:

  • 0.0.7



48
49
50
51
52
53
54
55
# File 'lib/calendly/client.rb', line 48

def refresh!
  check_not_empty @config.client_id, 'client_id'
  check_not_empty @config.client_secret, 'client_secret'
  @access_token = access_token.refresh!
rescue OAuth2::Error => e
  res = e.response.response
  raise ApiError.new res, e
end

#routing_form(uuid) ⇒ Calendly::RoutingForm

Get a specified Routing Form.

Parameters:

  • uuid (String)

    the specified routing form (routing form’s uuid).

Returns:

Raises:

Since:

  • 0.12.0



726
727
728
729
730
# File 'lib/calendly/client.rb', line 726

def routing_form(uuid)
  check_not_empty uuid, 'uuid'
  body = request :get, "routing_forms/#{uuid}"
  RoutingForm.new body[:resource], self
end

#routing_form_submission(uuid) ⇒ Calendly::RoutingFormSubmission

Get a specified Routing Form Submission.

Parameters:

  • uuid (String)

    the specified routing form submission (routing form submission’s uuid).

Returns:

Raises:

Since:

  • 0.12.0



767
768
769
770
771
# File 'lib/calendly/client.rb', line 767

def routing_form_submission(uuid)
  check_not_empty uuid, 'uuid'
  body = request :get, "routing_form_submissions/#{uuid}"
  RoutingFormSubmission.new body[:resource], self
end

#routing_form_submissions(form_uri, options: nil) ⇒ Array<Array<Calendly::RoutingFormSubmission>, Hash>

Get a list of Routing Form Submissions for a specified Routing Form.

Parameters:

  • form_uri (String)

    the specified organization (routing form’s uri).

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

Returns:

  • (Array<Array<Calendly::RoutingFormSubmission>, Hash>)
    • Array<Calendly::RoutingFormSubmission>

      routing form submissions

    • Hash

      next_params the parameters to get next data. if thre is no next it returns nil.

Raises:

Since:

  • 0.12.0



787
788
789
790
791
792
793
794
795
796
797
798
# File 'lib/calendly/client.rb', line 787

def routing_form_submissions(form_uri, options: nil)
  check_not_empty form_uri, 'form_uri'

  opts_keys = %i[count page_token sort]
  params = {form: form_uri}
  params = merge_options options, opts_keys, params
  body = request :get, 'routing_form_submissions', params: params

  items = body[:collection] || []
  submissions = items.map { |item| RoutingFormSubmission.new item, self }
  [submissions, next_page_params(body)]
end

#routing_forms(org_uri, options: nil) ⇒ Array<Array<Calendly::RoutingForm>, Hash>

Get a list of Routing Forms for a specified Organization.

Parameters:

  • org_uri (String)

    the specified organization (organization’s uri).

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

Returns:

  • (Array<Array<Calendly::RoutingForm>, Hash>)
    • Array<Calendly::RoutingForm>

      routing forms

    • Hash

      next_params the parameters to get next data. if thre is no next it returns nil.

Raises:

Since:

  • 0.12.0



746
747
748
749
750
751
752
753
754
755
756
757
# File 'lib/calendly/client.rb', line 746

def routing_forms(org_uri, options: nil)
  check_not_empty org_uri, 'org_uri'

  opts_keys = %i[count page_token sort]
  params = {organization: org_uri}
  params = merge_options options, opts_keys, params
  body = request :get, 'routing_forms', params: params

  items = body[:collection] || []
  forms = items.map { |item| RoutingForm.new item, self }
  [forms, next_page_params(body)]
end

#scheduled_event(uuid) ⇒ Calendly::Event

Returns a single Event by its URI.

Parameters:

  • uuid (String)

    the specified event (event’s uuid).

Returns:

Raises:

Since:

  • 0.0.3



200
201
202
203
204
# File 'lib/calendly/client.rb', line 200

def scheduled_event(uuid)
  check_not_empty uuid, 'uuid'
  body = request :get, "scheduled_events/#{uuid}"
  Event.new body[:resource], self
end

#scheduled_events(org_uri, options: nil) ⇒ Array<Array<Calendly::Event>, Hash>

Get List of scheduled events belonging to a specific organization.

Parameters:

  • org_uri (String)

    the specified organization (organization’s uri).

  • 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_time (String)

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

  • (Array<Array<Calendly::Event>, Hash>)
    • Array<Calendly::Event>

      events

    • Hash

      next_params the parameters to get next data. if thre is no next it returns nil.

Raises:

Since:

  • 0.5.0



224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/calendly/client.rb', line 224

def scheduled_events(org_uri, options: nil)
  check_not_empty org_uri, 'org_uri'

  opts_keys = %i[count invitee_email max_start_time min_start_time page_token sort status]
  params = {organization: org_uri}
  params = merge_options options, opts_keys, params
  body = request :get, 'scheduled_events', params: params

  items = body[:collection] || []
  evs = items.map { |item| Event.new item, self }
  [evs, next_page_params(body)]
end

#scheduled_events_by_user(user_uri, options: nil) ⇒ Array<Array<Calendly::Event>, Hash>

Get List of scheduled events belonging to a specific user.

Parameters:

  • user_uri (String)

    the specified user (user’s uri).

  • options (Hash) (defaults to: nil)

    the optional request parameters. Optional.

Options Hash (options:):

  • :organization (String)

    the specified organization (organization’s uri).

  • :count (Integer)

    Number of rows to return.

  • :invitee_email (String)

    Return events scheduled with the specified invitee email.

  • :max_start_time (String)

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

  • (Array<Array<Calendly::Event>, Hash>)
    • Array<Calendly::Event>

      events

    • Hash

      next_params the parameters to get next data. if thre is no next it returns nil.

Raises:

Since:

  • 0.0.3



276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/calendly/client.rb', line 276

def scheduled_events_by_user(user_uri, options: nil)
  check_not_empty user_uri, 'user_uri'

  opts_keys = %i[organization count invitee_email max_start_time min_start_time page_token sort status]
  params = {user: user_uri}
  params = merge_options options, opts_keys, params
  body = request :get, 'scheduled_events', params: params

  items = body[:collection] || []
  evs = items.map { |item| Event.new item, self }
  [evs, next_page_params(body)]
end

#user(uuid = 'me') ⇒ Calendly::User

Get basic information about a user

Parameters:

  • uuid (String) (defaults to: 'me')

    User unique identifier, or the constant “me” to reference the caller

Returns:

Raises:

Since:

  • 0.0.1



87
88
89
90
91
# File 'lib/calendly/client.rb', line 87

def user(uuid = 'me')
  check_not_empty uuid, 'uuid'
  body = request :get, "users/#{uuid}"
  User.new body[:resource], self
end

#user_scope_webhooks(org_uri, user_uri, options: nil) ⇒ Array<Array<Calendly::WebhookSubscription>, Hash>

Get List of user scope Webhooks.

Parameters:

  • org_uri (String)

    the specified organization (organization’s uri).

  • user_uri (String)

    the specified user (user’s uri).

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

  • (Array<Array<Calendly::WebhookSubscription>, Hash>)
    • Array<Calendly::WebhookSubscription>

      webhooks

    • Hash

      next_params the parameters to get next data. if thre is no next it returns nil.

Raises:

Since:

  • 0.1.3



659
660
661
662
663
664
665
666
667
668
669
670
# File 'lib/calendly/client.rb', line 659

def user_scope_webhooks(org_uri, user_uri, options: nil)
  check_not_empty org_uri, 'org_uri'
  check_not_empty user_uri, 'user_uri'

  opts_keys = %i[count page_token sort]
  params = {organization: org_uri, user: user_uri, scope: 'user'}
  params = merge_options options, opts_keys, params
  body = request :get, 'webhook_subscriptions', params: params
  items = body[:collection] || []
  evs = items.map { |item| WebhookSubscription.new item, self }
  [evs, next_page_params(body)]
end

#webhook(uuid) ⇒ Calendly::WebhookSubscription

Get a webhook subscription for an organization or user with a specified UUID.

Parameters:

  • uuid (String)

    the specified webhook (webhook’s uuid).

Returns:

Raises:

Since:

  • 0.1.3



611
612
613
614
615
# File 'lib/calendly/client.rb', line 611

def webhook(uuid)
  check_not_empty uuid, 'uuid'
  body = request :get, "webhook_subscriptions/#{uuid}"
  WebhookSubscription.new body[:resource], self
end

#webhooks(org_uri, options: nil) ⇒ Array<Array<Calendly::WebhookSubscription>, Hash>

Get List of organization scope Webhooks.

Parameters:

  • org_uri (String)

    the specified organization (organization’s uri).

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

  • (Array<Array<Calendly::WebhookSubscription>, Hash>)
    • Array<Calendly::WebhookSubscription>

      webhooks

    • Hash

      next_params the parameters to get next data. if thre is no next it returns nil.

Raises:

Since:

  • 0.1.3



631
632
633
634
635
636
637
638
639
640
641
# File 'lib/calendly/client.rb', line 631

def webhooks(org_uri, options: nil)
  check_not_empty org_uri, 'org_uri'

  opts_keys = %i[count page_token sort]
  params = {organization: org_uri, scope: 'organization'}
  params = merge_options options, opts_keys, params
  body = request :get, 'webhook_subscriptions', params: params
  items = body[:collection] || []
  evs = items.map { |item| WebhookSubscription.new item, self }
  [evs, next_page_params(body)]
end