Skip to content

Commit

Permalink
project id filter on get accounts (#29)
Browse files Browse the repository at this point in the history
* project id filter on get accounts

* assertion for project id
  • Loading branch information
kpdhulipala authored Feb 12, 2024
1 parent ed49263 commit 73b7de9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
9 changes: 5 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,11 @@ func (e UpdateError) Error() string {

// Account describes Network Edge customer account details
type Account struct {
Name *string
Number *string
Status *string
UCMID *string
Name *string
Number *string
Status *string
UCMID *string
ProjectID *string
}

// Device describes Network Edge device
Expand Down
15 changes: 8 additions & 7 deletions internal/api/account.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package api

//AccountResponse describes response to Network Edge
//billing account query
// AccountResponse describes response to Network Edge
// billing account query
type AccountResponse struct {
Accounts []Account `json:"accounts,omitempty"`
}

//Account describes Network Edge billing account
// Account describes Network Edge billing account
type Account struct {
Name *string `json:"accountName,omitempty"`
Number *string `json:"accountNumber,omitempty"`
UCMID *string `json:"accountUcmId,omitempty"`
Status *string `json:"accountStatus,omitempty"`
Name *string `json:"accountName,omitempty"`
Number *string `json:"accountNumber,omitempty"`
UCMID *string `json:"accountUcmId,omitempty"`
Status *string `json:"accountStatus,omitempty"`
ProjectID *string `json:"projectId,omitempty"`
}
11 changes: 6 additions & 5 deletions rest_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/equinix/ne-go/internal/api"
)

//GetAccounts retrieves accounts and their details for a given metro code using Network Edge API
// GetAccounts retrieves accounts and their details for a given metro code using Network Edge API
func (c RestClient) GetAccounts(metroCode string) ([]Account, error) {
path := "/ne/v1/accounts/" + url.PathEscape(metroCode)
respBody := api.AccountResponse{}
Expand All @@ -23,10 +23,11 @@ func mapAccountsAPIToDomain(apiAccounts []api.Account) []Account {
transformed := make([]Account, len(apiAccounts))
for i := range apiAccounts {
transformed[i] = Account{
Name: apiAccounts[i].Name,
Number: apiAccounts[i].Number,
UCMID: apiAccounts[i].UCMID,
Status: apiAccounts[i].Status,
Name: apiAccounts[i].Name,
Number: apiAccounts[i].Number,
UCMID: apiAccounts[i].UCMID,
Status: apiAccounts[i].Status,
ProjectID: apiAccounts[i].ProjectID,
}
}
return transformed
Expand Down
1 change: 1 addition & 0 deletions rest_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ func verifyAccount(t *testing.T, apiAccount api.Account, account Account) {
assert.Equal(t, apiAccount.Number, account.Number, "Account Number matches")
assert.Equal(t, apiAccount.Status, account.Status, "Account Status matches")
assert.Equal(t, apiAccount.UCMID, account.UCMID, "Account UCMID matches")
assert.Equal(t, apiAccount.ProjectID, account.ProjectID, "ProjectID matches")
}

0 comments on commit 73b7de9

Please sign in to comment.