forked from salsita/go-pivotaltracker
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from faktas2/master
Adding Accounts Service
- Loading branch information
Showing
5 changed files
with
133 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/oschwald/go-pivotaltracker | ||
|
||
go 1.20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package pivotal | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"time" | ||
) | ||
|
||
type Account struct { | ||
CreatedAt *time.Time `json:"created_at"` | ||
ID int `json:"id"` | ||
Kind string `json:"kind"` | ||
Name string `json:"name"` | ||
Plan string `json:"plan"` | ||
Status string `json:"status"` | ||
UpdatedAt *time.Time `json:"updated_at"` | ||
} | ||
|
||
type AccountsService struct { | ||
client *Client | ||
} | ||
|
||
func newAccountsService(client *Client) *AccountsService { | ||
return &AccountsService{client} | ||
} | ||
|
||
func (service *AccountsService) Get(accountID int) (*Account, *http.Response, error) { | ||
u := fmt.Sprintf("accounts/%d", accountID) | ||
req, err := service.client.NewRequest("GET", u, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
var account Account | ||
resp, err := service.client.Do(req, &account) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return &account, resp, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters