Module: Code42::API::Org
- Included in:
- Client
- Defined in:
- lib/code42/api/org.rb
Instance Method Summary collapse
- #activate_org(id = 'my', attrs = {}) ⇒ Object
- #block_org(id = 'my', attrs = {}) ⇒ Object
-
#create_org(attrs = {}) ⇒ Code42::Org
Creates an org.
-
#create_pro_org(attrs = {}) ⇒ Code42::Org
Creates blue org as well as user for the org.
- #deactivate_org(id = 'my', attrs = {}) ⇒ Object
-
#find_inactive_org_by_name(name, params = {}) ⇒ Object
Returns the first org that starts with a given name.
-
#find_org_by_name(name, params = {}) ⇒ Code42::Org
Returns an org for a given name.
-
#org(id = "my", params = {}) ⇒ Code42::Org
Returns information for a given org.
- #org_share_destinations(id) ⇒ Object
-
#orgs(params = {}) ⇒ Array
Returns a list of up to 100 orgs.
-
#search_orgs(query, params = {}) ⇒ Array
Searches orgs for a query string.
- #unblock_org(id = 'my', attrs = {}) ⇒ Object
- #update_org(id = 'my', attrs = {}) ⇒ Object
Instance Method Details
#activate_org(id = 'my', attrs = {}) ⇒ Object
70 71 72 |
# File 'lib/code42/api/org.rb', line 70 def activate_org(id = 'my', attrs = {}) object_from_response(Code42::Org, :delete, "OrgDeactivation/#{id}", attrs) end |
#block_org(id = 'my', attrs = {}) ⇒ Object
78 79 80 |
# File 'lib/code42/api/org.rb', line 78 def block_org(id = 'my', attrs = {}) object_from_response(Code42::Org, :put, "orgBlock/#{id}", attrs) end |
#create_org(attrs = {}) ⇒ Code42::Org
Creates an org
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
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 |
#deactivate_org(id = 'my', attrs = {}) ⇒ Object
74 75 76 |
# File 'lib/code42/api/org.rb', line 74 def deactivate_org(id = 'my', attrs = {}) object_from_response(Code42::Org, :put, "OrgDeactivation/#{id}", attrs) end |
#find_inactive_org_by_name(name, params = {}) ⇒ Object
Returns the first org that starts with a given name. Since orgs are renamed when they are deactivated, it is impossible to guarantee a match by name alone.
46 47 48 |
# File 'lib/code42/api/org.rb', line 46 def find_inactive_org_by_name(name, params = {}) search_orgs(name, params.merge!(:active => false)).first end |
#find_org_by_name(name, params = {}) ⇒ Code42::Org
Returns an org for a given name. If multiple orgs are found, the first found will be returned. FIXME: This needs to change when the API implements a better way.
37 38 39 |
# File 'lib/code42/api/org.rb', line 37 def find_org_by_name(name, params = {}) search_orgs(name, params).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 |
#org_share_destinations(id) ⇒ Object
86 87 88 |
# File 'lib/code42/api/org.rb', line 86 def org_share_destinations(id) get("orgShareDestinations/#{id}")['data'] end |
#orgs(params = {}) ⇒ Array
Returns a list of up to 100 orgs
61 62 63 64 |
# File 'lib/code42/api/org.rb', line 61 def orgs(params = {}) params.merge!(key: 'orgs') objects_from_response(Code42::Org, :get, 'org', params) end |
#search_orgs(query, params = {}) ⇒ Array
Searches orgs for a query string
53 54 55 56 |
# File 'lib/code42/api/org.rb', line 53 def search_orgs(query, params = {}) params.merge!(q: query) orgs(params) end |