Module: Code42::API::Org

Included in:
Client
Defined in:
lib/code42/api/org.rb

Instance Method Summary collapse

Instance Method Details

#create_org(attrs = {}) ⇒ Code42::Org

Creates an org

Examples:

client.create_org(:name => 'Acme Org', :parent_id => 2)


20
21
22
# File 'lib/code42/api/org.rb', line 20

def create_org(attrs = {})
  object_from_response(Code42::Org, :post, "org", attrs)
end

#create_pro_org(attrs = {}) ⇒ Code42::Org

Creates blue org as well as user for the org

Examples:

client.create_org(:company => "test", :email => "[email protected]", :firstname => "test", :lastname => "test")


11
12
13
# File 'lib/code42/api/org.rb', line 11

def create_pro_org(attrs = {})
  object_from_response(Code42::Org, :post, "proOrgChannel", attrs)
end

#find_org_by_name(name) ⇒ Code42::Org

Returns an org for a given name FIXME: This needs to change when the API implements a better way.



35
36
37
# File 'lib/code42/api/org.rb', line 35

def find_org_by_name(name)
  search_orgs(name).select { |o| o.name == name }.first
end

#org(id = "my", params = {}) ⇒ Code42::Org

Returns information for a given org



27
28
29
# File 'lib/code42/api/org.rb', line 27

def org(id = "my", params = {})
  object_from_response(Code42::Org, :get, "org/#{id}", params)
end

#orgs(params = {}) ⇒ Array

Returns a list of up to 100 orgs



49
50
51
52
# File 'lib/code42/api/org.rb', line 49

def orgs(params = {})
  params.merge!(key: 'orgs')
  objects_from_response(Code42::Org, :get, 'org', params)
end

#search_orgs(query) ⇒ Array

Searches orgs for a query string



42
43
44
# File 'lib/code42/api/org.rb', line 42

def search_orgs(query)
  orgs(q: query)
end

#update_org(id = 'my', attrs = {}) ⇒ Object



54
55
56
# File 'lib/code42/api/org.rb', line 54

def update_org(id = 'my', attrs = {})
  object_from_response(Code42::Org, :put, "org/#{id}", attrs)
end