Class: Readiness::Calendly::Organizations

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

Overview

Defines the class Organizations 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 = {}) ⇒ Organizations

Creates a new Readiness::Calendly::Organizations instance

Examples:

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

Parameters:

Author:

  • Jason Colyer

Since:

  • 1.0.12



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

def initialize(object = {})
  @created_at = object['created_at']
  @name = object['name']
  @plan = object['plan']
  @stage = object['stage']
  @updated_at = object['updated_at']
  @uri = object['uri']
end

Instance Attribute Details

#created_atObject

Since:

  • 1.0.12



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

def created_at
  @created_at
end

#nameObject

Since:

  • 1.0.12



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

def name
  @name
end

#planObject

Since:

  • 1.0.12



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

def plan
  @plan
end

#stageObject

Since:

  • 1.0.12



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

def stage
  @stage
end

#updated_atObject

Since:

  • 1.0.12



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

def updated_at
  @updated_at
end

#uriObject

Since:

  • 1.0.12



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

def uri
  @uri
end

Class Method Details

.current(client) ⇒ Object

Returns the current user’s organization within Calendly.

Examples:

require 'support_readiness'
config = Readiness::Calendly::Configuration.new
config.token = 'test123abc'
client = Readiness::Calendly::Client.new(config)
org = Readiness::Calendly::Organizations.current(client)
pp org.name
# => "GitLab Support"

Parameters:

  • client (Object)

    An instance of Client

Returns:

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.12



49
50
51
52
# File 'lib/support_readiness/calendly/organizations.rb', line 49

def self.current(client)
  user = Users.current(client)
  Organizations.find(client, user.current_organization.split('/').last)
end

.find(client, oid) ⇒ Object

Locates an organization within Calendly. This will not exit on error (except Authentication errors)

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')
pp org.name
# => "GitLab Support"

Parameters:

  • client (Object)

    An instance of Client

  • oid (String)

    The organization ID to find

Returns:

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.12



71
72
73
74
75
# File 'lib/support_readiness/calendly/organizations.rb', line 71

def self.find(client, oid)
  response = client.connection.get "organizations/#{oid}"
  handle_request_error(0, 'Calendly', response.status,  { action: 'get', id: oid }) unless response.status == 200
  Organizations.new(Oj.load(response.body)['resource'])
end

.find!(client, oid) ⇒ Object

Locates an organization within Calendly. This will exit on error

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')
pp org.name
# => "GitLab Support"

Parameters:

  • client (Object)

    An instance of Client

  • oid (String)

    The organization ID to find

Returns:

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.12



94
95
96
97
98
# File 'lib/support_readiness/calendly/organizations.rb', line 94

def self.find!(client, oid)
  response = client.connection.get "organizations/#{oid}"
  handle_request_error(1, 'Calendly', response.status, { action: 'Find organization', id: oid }) unless response.status == 200
  Organizations.new(Oj.load(response.body)['resource'])
end

.members(client, organization) ⇒ Array

Provides a list of organization memberships. A wrapper for Readiness::Calendly::OrganizationMemberships.list

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



118
119
120
# File 'lib/support_readiness/calendly/organizations.rb', line 118

def self.members(client, organization)
  Readiness::Calendly::OrganizationMemberships.list(client, organization)
end