Class: Readiness::Calendly::OrganizationMemberships

Inherits:
Readiness::Client show all
Defined in:
lib/support_readiness/calendly/organization_memberships.rb

Overview

Defines the class OrganizationMemberships within the module Readiness::Calendly.

Author:

  • Jason Colyer

Since:

  • 1.0.12

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Readiness::Client

auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries

Constructor Details

#initialize(object = {}) ⇒ OrganizationMemberships

Examples:

require 'support_readiness'
Readiness::Calendly::OrganizationMemberships.new

Parameters:

Author:

  • Jason Colyer

Since:

  • 1.0.12



24
25
26
27
28
29
30
31
# File 'lib/support_readiness/calendly/organization_memberships.rb', line 24

def initialize(object = {})
  @created_at = object['created_at']
  @organization = object['organization']
  @role = object['role']
  @updated_at = object['updated_at']
  @uri = object['uri']
  @user = (object['user'].nil? ? Users.new : Users.new(object['user']))
end

Instance Attribute Details

#created_atObject

Since:

  • 1.0.12



13
14
15
# File 'lib/support_readiness/calendly/organization_memberships.rb', line 13

def created_at
  @created_at
end

#organizationObject

Since:

  • 1.0.12



13
14
15
# File 'lib/support_readiness/calendly/organization_memberships.rb', line 13

def organization
  @organization
end

#roleObject

Since:

  • 1.0.12



13
14
15
# File 'lib/support_readiness/calendly/organization_memberships.rb', line 13

def role
  @role
end

#updated_atObject

Since:

  • 1.0.12



13
14
15
# File 'lib/support_readiness/calendly/organization_memberships.rb', line 13

def updated_at
  @updated_at
end

#uriObject

Since:

  • 1.0.12



13
14
15
# File 'lib/support_readiness/calendly/organization_memberships.rb', line 13

def uri
  @uri
end

#userObject

Since:

  • 1.0.12



13
14
15
# File 'lib/support_readiness/calendly/organization_memberships.rb', line 13

def user
  @user
end

Class Method Details

.list(client, organization) ⇒ Array

Provides a list of organization memberships.

Examples:

require 'support_readiness'
config = Readiness::Calendly::Configuration.new
config.token = 'test123abc'
client = Readiness::Calendly::Client.new(config)
org = Readiness::Calendly::Organizations.find!(client, 'abc123')
members = Readiness::Calendly::Organizations.members(client, org)
pp members.first.name
# => "Jason Colyer"

Parameters:

Returns:

  • (Array)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.12



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/support_readiness/calendly/organization_memberships.rb', line 51

def self.list(client, organization)
  members = []
  opts = { organization: organization.uri, count: 100 }
  loop do
    response = client.connection.get "organization_memberships", opts
    handle_request_error(0, 'Calendly', response.status,  { action: 'get', id: organization.uri.split('/').last }) unless response.status == 200
    body = Oj.load(response.body)
    members += body['collection'].map { |c| OrganizationMemberships.new(c) }
    break if body['pagination']['next_page_token'].nil?

    opts = { organization: organization.uri, count: 100, page_token: body['pagination']['next_page_token'] }
  end
  members
end