Class: SupportOps::Calendly::OrganizationMemberships

Inherits:
Base
  • Object
show all
Defined in:
lib/support_ops_calendly/calendly/organization_memberships.rb

Overview

Defines the module Organizations within the module SupportOps::Calendly.

Author:

  • Jason Colyer

Since:

  • 1.0.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

attributes, client, #client=, configure, define_attributes, #find, #find!, #initialize, #members, readonly_attributes, #save!, #store_original_attributes

Constructor Details

This class inherits a constructor from SupportOps::Calendly::Base

Instance Attribute Details

#created_atString

The moment when the membership record was created (e.g. “2020-01-02T03:04:05.678123Z”)

Returns:

  • (String)

    the current value of created_at



18
19
20
# File 'lib/support_ops_calendly/calendly/organization_memberships.rb', line 18

def created_at
  @created_at
end

#organizationString

A unique reference to the organization

Returns:

  • (String)

    the current value of organization



18
19
20
# File 'lib/support_ops_calendly/calendly/organization_memberships.rb', line 18

def organization
  @organization
end

#roleString

The user’s role in the organization

Returns:

  • (String)

    the current value of role



18
19
20
# File 'lib/support_ops_calendly/calendly/organization_memberships.rb', line 18

def role
  @role
end

#updated_atString

The moment when the membership record was last updated (e.g. “2020-01-02T03:04:05.678123Z”)

Returns:

  • (String)

    the current value of updated_at



18
19
20
# File 'lib/support_ops_calendly/calendly/organization_memberships.rb', line 18

def updated_at
  @updated_at
end

#uriString

Canonical reference (unique identifier) for the membership

Returns:

  • (String)

    the current value of uri



18
19
20
# File 'lib/support_ops_calendly/calendly/organization_memberships.rb', line 18

def uri
  @uri
end

#userObject

An instance of Users

Returns:

  • (Object)

    the current value of user



18
19
20
# File 'lib/support_ops_calendly/calendly/organization_memberships.rb', line 18

def user
  @user
end

Class Method Details

.get(object) ⇒ Object

Returns information about a specified Organization Membership

Examples:

require 'support_ops_calendly'

SupportOps::Calendly::Configuration.configure do |config|
  config.token = 'abc123'
end

member = SupportOps::Calendly::OrganizationMemberships.get('CCCCCCCCCCCCCCCC')
pp member.user.uuid
# => "AAAAAAAAAAAAAAAA"

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



151
152
153
154
155
156
157
# File 'lib/support_ops_calendly/calendly/organization_memberships.rb', line 151

def self.get(object)
  if object.is_a? OrganizationMemberships
    OrganizationMemberships.new(uri: uri).find
  else
    OrganizationMemberships.new(uri: object).find
  end
end

.get!(object) ⇒ Object

Returns information about a specified Organization Membership

Examples:

require 'support_ops_calendly'

SupportOps::Calendly::Configuration.configure do |config|
  config.token = 'abc123'
end

member = SupportOps::Calendly::OrganizationMemberships.get!('CCCCCCCCCCCCCCCC')
pp member.user.uuid
# => "AAAAAAAAAAAAAAAA"

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



177
178
179
180
181
182
183
# File 'lib/support_ops_calendly/calendly/organization_memberships.rb', line 177

def self.get!(object)
  if object.is_a? OrganizationMemberships
    OrganizationMemberships.new(uri: uri).find!
  else
    OrganizationMemberships.new(uri: object).find!
  end
end

.list(object) ⇒ Object

Returns a list of Organization Memberships for a specified Organization

Examples:

require 'support_ops_calendly'

SupportOps::Calendly::Configuration.configure do |config|
  config.token = 'abc123'
end

org = SupportOps::Calendly::Organizations.get!('BBBBBBBBBBBBBBBB')
members = SupportOps::Calendly::OrganizationMemberships(org)
pp members.count
# => 27
pp members.first.user.uuid
# => "AAAAAAAAAAAAAAAA"
require 'support_ops_calendly'

SupportOps::Calendly::Configuration.configure do |config|
  config.token = 'abc123'
end

members = SupportOps::Calendly::OrganizationMemberships('https://api.calendly.com/organizations/BBBBBBBBBBBBBBBB')
pp members.count
# => 27
pp members.first.user.uuid
# => "AAAAAAAAAAAAAAAA"
require 'support_ops_calendly'

SupportOps::Calendly::Configuration.configure do |config|
  config.token = 'abc123'
end

members = SupportOps::Calendly::OrganizationMemberships('BBBBBBBBBBBBBBBB')
pp members.count
# => 27
pp members.first.user.uuid
# => "AAAAAAAAAAAAAAAA"

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/support_ops_calendly/calendly/organization_memberships.rb', line 109

def self.list(object)
  id = if object.is_a? Organizations
         object.uri
       elsif object =~ /^https/
         object
       else
         "https://api.calendly.com/organizations/#{object}"
       end
  data = { organization: id, count: 100 }
  array = []
  loop do
    response = client.connection.get('organization_memberships', data)
    body = Oj.load(response.body)
    body['collection'].each_with_index do |member, index|
      body['collection'][index]['user'] = Users.new(member['user'])
    end
    array += body['collection'].map { |c| OrganizationMemberships.new(c) }
    break if body['pagination']['next_page_token'].nil?

    data = { organization: id, count: 100, page_token: body['pagination']['next_page_token'] }
  end
  array
end

Instance Method Details

#delete!Object

Note:

This is inherited from Base#delete!

Removes a membership from an organization

Examples:

require 'support_ops_calendly'

SupportOps::Calendly::Configuration.configure do |config|
  config.token = 'abc123'
end

org = SupportOps::Calendly::Organizations.current
members = SupportOps::Calendly::OrganizationMemberships.list('BBBBBBBBBBBBBBBB')
pp members.last.delete!
#=> "CCCCCCCCCCCCCCCC"

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



20
# File 'lib/support_ops_calendly/calendly/organization_memberships.rb', line 20

def delete!; end

#uuidString

Note:

This is inherited from Base#uuid

Returns the UUID of an organization membership

Examples:

require 'support_ops_calendly'

SupportOps::Calendly::Configuration.configure do |config|
  config.token = 'abc123'
end

org = SupportOps::Calendly::Organizations.current
members = SupportOps::Calendly::OrganizationMemberships.list('BBBBBBBBBBBBBBBB')
pp members.first.uuid
#=> "CCCCCCCCCCCCCCCC"

Returns:

  • (String)

    The UUID

Author:

  • Jason Colyer

Since:

  • 1.0.0



18
# File 'lib/support_ops_calendly/calendly/organization_memberships.rb', line 18

def uuid; end