Skip to content

Commit

Permalink
account: add team field
Browse files Browse the repository at this point in the history
  • Loading branch information
bentranter committed Jul 18, 2023
1 parent ba810da commit e84aaa9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
15 changes: 15 additions & 0 deletions lib/droplet_kit/mappings/account_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ class AccountMapping
property :email
property :uuid
property :email_verified
property :team
end
end
end

class AccountTeamMapping
include Kartograph::DSL

kartograph do
root_key singular: 'team', scopes: [:read]
mapping AccountTeam

scoped :read do
property :uuid
property :name
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions lib/droplet_kit/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ class Account < BaseModel
attribute :email
attribute :uuid
attribute :email_verified
attribute :team
end

class AccountTeam < BaseModel
attribute :uuid
attribute :name
end
end
8 changes: 6 additions & 2 deletions spec/fixtures/account/info.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"account": {
"droplet_limit": 200,
"name": "Sammy the Shark",
"email": "droplet_kit@digitalocean.com",
"name": "Sammy the Shark",
"uuid": "alksdjfhlakjdsfh12983712",
"email_verified": true
"email_verified": true,
"team": {
"uuid": "00000000-0000-4000-00000000000000000",
"name": "My Team"
}
}
}
3 changes: 2 additions & 1 deletion spec/lib/droplet_kit/resources/account_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
expect(account_info.droplet_limit).to eq(parsed['account']['droplet_limit'])
expect(account_info.floating_ip_limit).to eq(parsed['account']['floating_ip_limit'])
expect(account_info.email).to eq(parsed['account']['email'])
expect(account_info.email).to eq(parsed['account']['email'])
expect(account_info.name).to eq(parsed['account']['name'])
expect(account_info.uuid).to eq(parsed['account']['uuid'])
expect(account_info.email_verified).to eq(parsed['account']['email_verified'])
expect(account_info.team).to eq(parsed['account']['team'])
end

it_behaves_like 'resource that handles common errors' do
Expand Down

0 comments on commit e84aaa9

Please sign in to comment.