Skip to content

Commit fe557ca

Browse files
authored
feat: add transaction link to account (#179)
Resolves #178.
1 parent 45e4671 commit fe557ca

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

api/docs.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,10 @@ const docTemplate = `{
17821782
"self": {
17831783
"type": "string",
17841784
"example": "https://example.com/api/v1/accounts/af892e10-7e0a-4fb8-b1bc-4b6d88401ed2"
1785+
},
1786+
"transactions": {
1787+
"type": "string",
1788+
"example": "https://example.com/api/v1/transactions?=af892e10-7e0a-4fb8-b1bc-4b6d88401ed2"
17851789
}
17861790
}
17871791
},

api/swagger.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,6 +1770,10 @@
17701770
"self": {
17711771
"type": "string",
17721772
"example": "https://example.com/api/v1/accounts/af892e10-7e0a-4fb8-b1bc-4b6d88401ed2"
1773+
},
1774+
"transactions": {
1775+
"type": "string",
1776+
"example": "https://example.com/api/v1/transactions?=af892e10-7e0a-4fb8-b1bc-4b6d88401ed2"
17731777
}
17741778
}
17751779
},

api/swagger.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ definitions:
3535
self:
3636
example: https://example.com/api/v1/accounts/af892e10-7e0a-4fb8-b1bc-4b6d88401ed2
3737
type: string
38+
transactions:
39+
example: https://example.com/api/v1/transactions?=af892e10-7e0a-4fb8-b1bc-4b6d88401ed2
40+
type: string
3841
type: object
3942
controllers.AccountListResponse:
4043
properties:

pkg/controllers/account.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ type Account struct {
2424
}
2525

2626
type AccountLinks struct {
27-
Self string `json:"self" example:"https://example.com/api/v1/accounts/af892e10-7e0a-4fb8-b1bc-4b6d88401ed2"`
27+
Self string `json:"self" example:"https://example.com/api/v1/accounts/af892e10-7e0a-4fb8-b1bc-4b6d88401ed2"`
28+
Transactions string `json:"transactions" example:"https://example.com/api/v1/transactions?=af892e10-7e0a-4fb8-b1bc-4b6d88401ed2"`
2829
}
2930

3031
// RegisterAccountRoutes registers the routes for accounts with
@@ -245,8 +246,10 @@ func getAccountObject(c *gin.Context, id uuid.UUID) (Account, error) {
245246
// with mixed named and unnamed parameters.
246247
func getAccountLinks(c *gin.Context, id uuid.UUID) AccountLinks {
247248
url := httputil.RequestPathV1(c) + fmt.Sprintf("/accounts/%s", id)
249+
t := httputil.RequestPathV1(c) + fmt.Sprintf("/transactions?account=%s", id)
248250

249251
return AccountLinks{
250-
Self: url,
252+
Self: url,
253+
Transactions: t,
251254
}
252255
}

0 commit comments

Comments
 (0)