Skip to content

Commit f220f20

Browse files
committed
Add support for organization roles endpoint
1 parent 08d8728 commit f220f20

5 files changed

Lines changed: 39 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Or install it yourself as:
2222
* Credentials
2323
* Budgets
2424
* Reporting
25+
* Organizations (Including invitations and roles.)
2526

2627
Feel free to shoot me an email at colby@cloudability.com if you have any questions or need help.
2728

@@ -41,6 +42,8 @@ Feel free to shoot me an email at colby@cloudability.com if you have any questio
4142

4243
c = Cloudability::Organizations.new(auth_token: 'xxxxxxxxxxxxxxxxxxxx')
4344
c.invite_user(email: 'colby@cloudability.com', name: 'Colby Aley')
45+
c.roles
46+
c.invitations
4447

4548
## TODO:
4649
* More tests!

lib/cloudability/organizations.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require 'json'
2-
31
module Cloudability
42
class Organizations
53
include HTTParty
@@ -24,6 +22,11 @@ def invitations
2422
convert_to_mashes(response)
2523
end
2624

25+
def roles
26+
response = get_url("/organizations/roles?auth_token=#{@auth_token}")
27+
convert_to_mashes(response)
28+
end
29+
2730
# Invite a user to your organization
2831
#
2932
# @param [Hash] args to pass to HTTParty

spec/cloduability/organizations_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@
3434
end
3535
end
3636

37+
describe '#roles' do
38+
it 'should be an Array' do
39+
stub_get('/1/organizations/roles?auth_token=token', 'organization_roles')
40+
@cloudability.roles.class.should == Array
41+
end
42+
43+
it 'should be an array of Hashie::Mashes' do
44+
stub_get('/1/organizations/roles?auth_token=token', 'organization_roles')
45+
@cloudability.roles.each{|role| role.class.should == Hashie::Mash }
46+
end
47+
end
48+
3749
describe '#invite_user' do
3850
it 'should be a Hashie::Mash' do
3951
stub_post('/1/organizations/invitations?auth_token=token&email=colbyaleyrb%40gmail.com', 'organization_invitation')

spec/fixtures/organization_roles

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
HTTP/1.1 200 OK
2+
Server: nginx/1.4.4
3+
Date: Wed, 25 Dec 2013 06:00:08 GMT
4+
Content-Type: application/json
5+
Content-Length: 85
6+
Connection: keep-alive
7+
Status: 200 OK
8+
Strict-Transport-Security: max-age=31536000
9+
Set-Cookie: _mkra_ctxt=7b713ce79009c9db2eaea4cde43268e9--200; path=/; secure
10+
X-UA-Compatible: IE=Edge,chrome=1
11+
ETag: "4ccf5f4c217aaffe5601d88739504032"
12+
Cache-Control: max-age=0, private, must-revalidate
13+
X-Request-Id: 01a7274813811338beb87e23669afdda
14+
X-Runtime: 0.024049
15+
X-Rack-Cache: miss
16+
Origin: app.cloudability.com
17+
18+
[{"id":1,"key":"admin","label":"Administrator"},{"id":2,"key":"user","label":"User"}]

spec/fixtures/report_by_account

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ X-Runtime: 0.221266
1515
X-Rack-Cache: miss
1616
Origin: app.cloudability.com
1717

18-
[{"account_id":null,"account_name":null,"credential_id":22975,"credential_name":"Capsule CRM 1","vendor_id":77,"vendor_name":"Capsule CRM","spend":11111.0,"currency":"USD"},{"account_id":11731,"account_name":"xxx","credential_id":8778,"credential_name":"SL54339","vendor_id":67,"vendor_name":"SoftLayer","spend":11111.11,"currency":"USD"},{"account_id":12019,"account_name":"17474","credential_id":8884,"credential_name":"Acme Co. NewRelic","vendor_id":25,"vendor_name":"New Relic","spend":1111.0,"currency":"USD"},{"account_id":82,"account_name":"xxx","credential_id":136,"credential_name":"Acme Co","vendor_id":2,"vendor_name":"Heroku","spend":1111.47,"currency":"USD"},{"account_id":12021,"account_name":"xxx","credential_id":8885,"credential_name":"IAUC SendGrid","vendor_id":54,"vendor_name":"SendGrid","spend":111.46,"currency":"USD"},{"account_id":12020,"account_name":"26117","credential_id":8887,"credential_name":"IAUC Zencoder","vendor_id":30,"vendor_name":"Zencoder","spend":111.11,"currency":"USD"},{"account_id":26,"account_name":"1111-1111-1111","credential_id":15457,"credential_name":"Acme Co. Production","vendor_id":1,"vendor_name":"Amazon","spend":111111.11,"currency":"USD"},{"account_id":12343,"account_name":"61268799130651","credential_id":10091,"credential_name":"HP Cloud (Acme Co.)","vendor_id":124,"vendor_name":"Hpcloud","spend":11.1,"currency":"USD"},{"account_id":1928,"account_name":"xxx","credential_id":8771,"credential_name":"MailChimp","vendor_id":11,"vendor_name":"MailChimp","spend":111.1,"currency":"USD"}]
18+
[{"account_id":null,"account_name":null,"credential_id":22975,"credential_name":"Capsule CRM 1","vendor_id":77,"vendor_name":"Capsule CRM","spend":11111.0,"currency":"USD"},{"account_id":11731,"account_name":"xxx","credential_id":8778,"credential_name":"SL54339","vendor_id":67,"vendor_name":"SoftLayer","spend":11111.11,"currency":"USD"}]

0 commit comments

Comments
 (0)