Skip to content

Commit 8fb5ca0

Browse files
authored
feat: add /v3/transactions collection endpoint with GET support (#835)
1 parent bb8d6db commit 8fb5ca0

30 files changed

+1810
-161
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ VERSION ?= $(shell git rev-parse HEAD)
2727
build:
2828
go build -ldflags "-X github.com/envelope-zero/backend/v3/pkg/router.version=${VERSION}"
2929

30-
3130
.PHONY: docs
3231
docs:
3332
swag init --parseDependency --output ./api

api/docs.go

Lines changed: 347 additions & 1 deletion
Large diffs are not rendered by default.

api/swagger.json

Lines changed: 347 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3789,6 +3789,177 @@
37893789
}
37903790
}
37913791
},
3792+
"/v3": {
3793+
"get": {
3794+
"description": "Returns general information about the v3 API",
3795+
"tags": [
3796+
"v3"
3797+
],
3798+
"summary": "v3 API",
3799+
"responses": {
3800+
"200": {
3801+
"description": "OK",
3802+
"schema": {
3803+
"$ref": "#/definitions/router.V3Response"
3804+
}
3805+
}
3806+
}
3807+
},
3808+
"options": {
3809+
"description": "Returns an empty response with the HTTP Header \"allow\" set to the allowed HTTP verbs",
3810+
"tags": [
3811+
"v3"
3812+
],
3813+
"summary": "Allowed HTTP verbs",
3814+
"responses": {
3815+
"204": {
3816+
"description": "No Content"
3817+
}
3818+
}
3819+
}
3820+
},
3821+
"/v3/transactions": {
3822+
"get": {
3823+
"description": "Returns a list of transactions",
3824+
"produces": [
3825+
"application/json"
3826+
],
3827+
"tags": [
3828+
"Transactions"
3829+
],
3830+
"summary": "Get transactions",
3831+
"parameters": [
3832+
{
3833+
"type": "string",
3834+
"description": "Date of the transaction. Ignores exact time, matches on the day of the RFC3339 timestamp provided.",
3835+
"name": "date",
3836+
"in": "query"
3837+
},
3838+
{
3839+
"type": "string",
3840+
"description": "Transactions at and after this date. Ignores exact time, matches on the day of the RFC3339 timestamp provided.",
3841+
"name": "fromDate",
3842+
"in": "query"
3843+
},
3844+
{
3845+
"type": "string",
3846+
"description": "Transactions before and at this date. Ignores exact time, matches on the day of the RFC3339 timestamp provided.",
3847+
"name": "untilDate",
3848+
"in": "query"
3849+
},
3850+
{
3851+
"type": "string",
3852+
"description": "Filter by amount",
3853+
"name": "amount",
3854+
"in": "query"
3855+
},
3856+
{
3857+
"type": "string",
3858+
"description": "Amount less than or equal to this",
3859+
"name": "amountLessOrEqual",
3860+
"in": "query"
3861+
},
3862+
{
3863+
"type": "string",
3864+
"description": "Amount more than or equal to this",
3865+
"name": "amountMoreOrEqual",
3866+
"in": "query"
3867+
},
3868+
{
3869+
"type": "string",
3870+
"description": "Filter by note",
3871+
"name": "note",
3872+
"in": "query"
3873+
},
3874+
{
3875+
"type": "string",
3876+
"description": "Filter by budget ID",
3877+
"name": "budget",
3878+
"in": "query"
3879+
},
3880+
{
3881+
"type": "string",
3882+
"description": "Filter by ID of associated account, regardeless of source or destination",
3883+
"name": "account",
3884+
"in": "query"
3885+
},
3886+
{
3887+
"type": "string",
3888+
"description": "Filter by source account ID",
3889+
"name": "source",
3890+
"in": "query"
3891+
},
3892+
{
3893+
"type": "string",
3894+
"description": "Filter by destination account ID",
3895+
"name": "destination",
3896+
"in": "query"
3897+
},
3898+
{
3899+
"type": "string",
3900+
"description": "Filter by envelope ID",
3901+
"name": "envelope",
3902+
"in": "query"
3903+
},
3904+
{
3905+
"type": "boolean",
3906+
"description": "Reconcilication state in source account",
3907+
"name": "reconciledSource",
3908+
"in": "query"
3909+
},
3910+
{
3911+
"type": "boolean",
3912+
"description": "Reconcilication state in destination account",
3913+
"name": "reconciledDestination",
3914+
"in": "query"
3915+
},
3916+
{
3917+
"type": "integer",
3918+
"description": "The offset of the first Transaction returned. Defaults to 0.",
3919+
"name": "offset",
3920+
"in": "query"
3921+
},
3922+
{
3923+
"type": "integer",
3924+
"description": " Maximum number of transactions to return. Defaults to 50.",
3925+
"name": "limit",
3926+
"in": "query"
3927+
}
3928+
],
3929+
"responses": {
3930+
"200": {
3931+
"description": "OK",
3932+
"schema": {
3933+
"$ref": "#/definitions/controllers.TransactionListResponseV3"
3934+
}
3935+
},
3936+
"400": {
3937+
"description": "Bad Request",
3938+
"schema": {
3939+
"$ref": "#/definitions/httperrors.HTTPError"
3940+
}
3941+
},
3942+
"500": {
3943+
"description": "Internal Server Error",
3944+
"schema": {
3945+
"$ref": "#/definitions/httperrors.HTTPError"
3946+
}
3947+
}
3948+
}
3949+
},
3950+
"options": {
3951+
"description": "Returns an empty response with the HTTP Header \"allow\" set to the allowed HTTP verbs",
3952+
"tags": [
3953+
"Transactions"
3954+
],
3955+
"summary": "Allowed HTTP verbs",
3956+
"responses": {
3957+
"204": {
3958+
"description": "No Content"
3959+
}
3960+
}
3961+
}
3962+
},
37923963
"/version": {
37933964
"get": {
37943965
"description": "Returns the software version of the API",
@@ -4545,6 +4716,27 @@
45454716
}
45464717
}
45474718
},
4719+
"controllers.Pagination": {
4720+
"type": "object",
4721+
"properties": {
4722+
"count": {
4723+
"description": "The amount of records returned in this response",
4724+
"type": "integer"
4725+
},
4726+
"limit": {
4727+
"description": "The maximum amount of resources to return for this request",
4728+
"type": "integer"
4729+
},
4730+
"offset": {
4731+
"description": "The offset for the first record returned",
4732+
"type": "integer"
4733+
},
4734+
"total": {
4735+
"description": "The total number of resources matching the query",
4736+
"type": "integer"
4737+
}
4738+
}
4739+
},
45484740
"controllers.RenameRuleListResponse": {
45494741
"type": "object",
45504742
"properties": {
@@ -4720,6 +4912,30 @@
47204912
}
47214913
}
47224914
},
4915+
"controllers.TransactionListResponseV3": {
4916+
"type": "object",
4917+
"properties": {
4918+
"data": {
4919+
"description": "List of transactions",
4920+
"type": "array",
4921+
"items": {
4922+
"$ref": "#/definitions/controllers.TransactionV3"
4923+
}
4924+
},
4925+
"error": {
4926+
"description": "The error, if any occurred",
4927+
"type": "string"
4928+
},
4929+
"pagination": {
4930+
"description": "Pagination information",
4931+
"allOf": [
4932+
{
4933+
"$ref": "#/definitions/controllers.Pagination"
4934+
}
4935+
]
4936+
}
4937+
}
4938+
},
47234939
"controllers.TransactionResponse": {
47244940
"type": "object",
47254941
"properties": {
@@ -4796,7 +5012,109 @@
47965012
"self": {
47975013
"description": "The transaction itself",
47985014
"type": "string",
4799-
"example": "https://example.com/api/v1/transactions/d430d7c3-d14c-4712-9336-ee56965a6673"
5015+
"example": "https://example.com/api/v2/transactions/d430d7c3-d14c-4712-9336-ee56965a6673"
5016+
}
5017+
}
5018+
},
5019+
"note": {
5020+
"description": "A note",
5021+
"type": "string",
5022+
"example": "Lunch"
5023+
},
5024+
"reconciled": {
5025+
"description": "DEPRECATED. Do not use, this field does not work as intended. See https://github.com/envelope-zero/backend/issues/528. Use reconciledSource and reconciledDestination instead.",
5026+
"type": "boolean",
5027+
"default": false,
5028+
"example": true
5029+
},
5030+
"reconciledDestination": {
5031+
"description": "Is the transaction reconciled in the destination account?",
5032+
"type": "boolean",
5033+
"default": false,
5034+
"example": true
5035+
},
5036+
"reconciledSource": {
5037+
"description": "Is the transaction reconciled in the source account?",
5038+
"type": "boolean",
5039+
"default": false,
5040+
"example": true
5041+
},
5042+
"sourceAccountId": {
5043+
"description": "ID of the source account",
5044+
"type": "string",
5045+
"example": "fd81dc45-a3a2-468e-a6fa-b2618f30aa45"
5046+
},
5047+
"updatedAt": {
5048+
"description": "Last time the resource was updated",
5049+
"type": "string",
5050+
"example": "2022-04-17T20:14:01.048145Z"
5051+
}
5052+
}
5053+
},
5054+
"controllers.TransactionV3": {
5055+
"type": "object",
5056+
"properties": {
5057+
"amount": {
5058+
"description": "The maximum value is \"999999999999.99999999\", swagger unfortunately rounds this.",
5059+
"type": "number",
5060+
"maximum": 1000000000000,
5061+
"minimum": 1e-8,
5062+
"multipleOf": 1e-8,
5063+
"example": 14.03
5064+
},
5065+
"availableFrom": {
5066+
"description": "The date from which on the transaction amount is available for budgeting. Only used for income transactions. Defaults to the transaction date.",
5067+
"type": "string",
5068+
"example": "2021-11-17T00:00:00Z"
5069+
},
5070+
"budgetId": {
5071+
"description": "ID of the budget",
5072+
"type": "string",
5073+
"example": "55eecbd8-7c46-4b06-ada9-f287802fb05e"
5074+
},
5075+
"createdAt": {
5076+
"description": "Time the resource was created",
5077+
"type": "string",
5078+
"example": "2022-04-02T19:28:44.491514Z"
5079+
},
5080+
"date": {
5081+
"description": "Date of the transaction. Time is currently only used for sorting",
5082+
"type": "string",
5083+
"example": "1815-12-10T18:43:00.271152Z"
5084+
},
5085+
"deletedAt": {
5086+
"description": "Time the resource was marked as deleted",
5087+
"type": "string",
5088+
"example": "2022-04-22T21:01:05.058161Z"
5089+
},
5090+
"destinationAccountId": {
5091+
"description": "ID of the destination account",
5092+
"type": "string",
5093+
"example": "8e16b456-a719-48ce-9fec-e115cfa7cbcc"
5094+
},
5095+
"envelopeId": {
5096+
"description": "ID of the envelope",
5097+
"type": "string",
5098+
"example": "2649c965-7999-4873-ae16-89d5d5fa972e"
5099+
},
5100+
"id": {
5101+
"description": "UUID for the resource",
5102+
"type": "string",
5103+
"example": "65392deb-5e92-4268-b114-297faad6cdce"
5104+
},
5105+
"importHash": {
5106+
"description": "The SHA256 hash of a unique combination of values to use in duplicate detection",
5107+
"type": "string",
5108+
"example": "867e3a26dc0baf73f4bff506f31a97f6c32088917e9e5cf1a5ed6f3f84a6fa70"
5109+
},
5110+
"links": {
5111+
"description": "Links for the transaction",
5112+
"type": "object",
5113+
"properties": {
5114+
"self": {
5115+
"description": "The transaction itself",
5116+
"type": "string",
5117+
"example": "https://example.com/api/v3/transactions/d430d7c3-d14c-4712-9336-ee56965a6673"
48005118
}
48015119
}
48025120
},
@@ -5510,6 +5828,11 @@
55105828
"type": "string",
55115829
"example": "https://example.com/api/v2"
55125830
},
5831+
"v3": {
5832+
"description": "List endpoint for all v3 endpoints",
5833+
"type": "string",
5834+
"example": "https://example.com/api/v3"
5835+
},
55135836
"version": {
55145837
"description": "Endpoint returning the version of the backend",
55155838
"type": "string",
@@ -5626,6 +5949,29 @@
56265949
}
56275950
}
56285951
},
5952+
"router.V3Links": {
5953+
"type": "object",
5954+
"properties": {
5955+
"transactions": {
5956+
"description": "URL of transaction collection endpoint",
5957+
"type": "string",
5958+
"example": "https://example.com/api/v3/transactions"
5959+
}
5960+
}
5961+
},
5962+
"router.V3Response": {
5963+
"type": "object",
5964+
"properties": {
5965+
"links": {
5966+
"description": "Links for the v2 API",
5967+
"allOf": [
5968+
{
5969+
"$ref": "#/definitions/router.V3Links"
5970+
}
5971+
]
5972+
}
5973+
}
5974+
},
56295975
"router.VersionObject": {
56305976
"type": "object",
56315977
"properties": {

0 commit comments

Comments
 (0)