Class: Calendly::OrganizationMembership

Inherits:
Object
  • Object
show all
Includes:
ModelUtils
Defined in:
lib/calendly/models/organization_membership.rb

Overview

Calendly’s organization membership model.

Constant Summary collapse

UUID_RE =
%r{\A#{Client::API_HOST}/organization_memberships/(\w+)\z}.freeze
TIME_FIELDS =
i[created_at updated_at].freeze
ASSOCIATION =
{user: User, organization: Organization}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ModelUtils

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

Instance Attribute Details

#created_atTime

Moment when user record was first created.

Returns:

  • (Time)


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

def created_at
  @created_at
end

#organizationOrganization

Reference to Organization associated with this membership.

Returns:



38
39
40
# File 'lib/calendly/models/organization_membership.rb', line 38

def organization
  @organization
end

#roleString

User’s role within the organization

Returns:

  • (String)


24
25
26
# File 'lib/calendly/models/organization_membership.rb', line 24

def role
  @role
end

#updated_atTime

Moment when user record was last updated.

Returns:

  • (Time)


30
31
32
# File 'lib/calendly/models/organization_membership.rb', line 30

def updated_at
  @updated_at
end

#uriString

Canonical resource reference.

Returns:

  • (String)


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

def uri
  @uri
end

#userCalendly::User

Primary account details of a specific user.

Returns:



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

def user
  @user
end

#uuidString

unique id of the OrganizationMembership object.

Returns:

  • (String)


18
19
20
# File 'lib/calendly/models/organization_membership.rb', line 18

def uuid
  @uuid
end

Instance Method Details

#create_user_scope_webhook(url, events) ⇒ 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

Returns:

Raises:

Since:

  • 0.1.3



100
101
102
103
104
# File 'lib/calendly/models/organization_membership.rb', line 100

def create_user_scope_webhook(url, events)
  org_uri = organization.uri if organization
  user_uri = user.uri if user
  client.create_webhook url, events, org_uri, user_uri
end

#deleteObject

Remove self from associated Organization.

Raises:

Since:

  • 0.1.0



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

def delete
  client.delete_membership uuid
end

#fetchCalendly::OrganizationMembership

Get Organization Membership associated with self.

Returns:

Raises:

Since:

  • 0.1.0



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

def fetch
  client.membership uuid
end

#user_scope_webhooks(opts = {}) ⇒ Array<Calendly::WebhookSubscription>

Get List of user scope Webhooks 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 directin. Accepts comma-separated list of field:direction values.

Returns:

Raises:

Since:

  • 0.1.3



74
75
76
77
78
79
80
81
# File 'lib/calendly/models/organization_membership.rb', line 74

def user_scope_webhooks(opts = {})
  return @cached_user_scope_webhooks if @cached_user_scope_webhooks

  org_uri = organization.uri if organization
  user_uri = user.uri if user
  request_proc = proc { |options| client.user_scope_webhooks org_uri, user_uri, options }
  @cached_user_scope_webhooks = auto_pagination request_proc, opts
end

#user_scope_webhooks!(opts = {}) ⇒ Object

Since:

  • 0.2.0



84
85
86
87
# File 'lib/calendly/models/organization_membership.rb', line 84

def user_scope_webhooks!(opts = {})
  @cached_user_scope_webhooks = nil
  user_scope_webhooks opts
end