Skip to content

Commit cd7f16a

Browse files
authored
fix: API v2 Transaction links (#805)
This fixes the API v2 Transaction links by performing the same refactor that was already performed for the Accounts.
1 parent 04deed5 commit cd7f16a

File tree

10 files changed

+819
-387
lines changed

10 files changed

+819
-387
lines changed

api/docs.go

Lines changed: 207 additions & 105 deletions
Large diffs are not rendered by default.

api/swagger.json

Lines changed: 207 additions & 105 deletions
Large diffs are not rendered by default.

api/swagger.yaml

Lines changed: 177 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -251,28 +251,202 @@ definitions:
251251
properties:
252252
data:
253253
allOf:
254-
- $ref: '#/definitions/models.Transaction'
254+
- $ref: '#/definitions/controllers.TransactionV2'
255255
description: This field contains the transaction data
256256
error:
257257
description: This field contains a human readable error message
258258
example: A human readable error message
259259
type: string
260260
type: object
261+
controllers.Transaction:
262+
properties:
263+
amount:
264+
description: The maximum value is "999999999999.99999999", swagger unfortunately
265+
rounds this.
266+
example: 14.03
267+
maximum: 1000000000000
268+
minimum: 1e-08
269+
multipleOf: 1e-08
270+
type: number
271+
availableFrom:
272+
description: The date from which on the transaction amount is available for
273+
budgeting. Only used for income transactions. Defaults to the transaction
274+
date.
275+
example: "2021-11-17T00:00:00Z"
276+
type: string
277+
budgetId:
278+
description: ID of the budget
279+
example: 55eecbd8-7c46-4b06-ada9-f287802fb05e
280+
type: string
281+
createdAt:
282+
description: Time the resource was created
283+
example: "2022-04-02T19:28:44.491514Z"
284+
type: string
285+
date:
286+
description: Date of the transaction. Time is currently only used for sorting
287+
example: "1815-12-10T18:43:00.271152Z"
288+
type: string
289+
deletedAt:
290+
description: Time the resource was marked as deleted
291+
example: "2022-04-22T21:01:05.058161Z"
292+
type: string
293+
destinationAccountId:
294+
description: ID of the destination account
295+
example: 8e16b456-a719-48ce-9fec-e115cfa7cbcc
296+
type: string
297+
envelopeId:
298+
description: ID of the envelope
299+
example: 2649c965-7999-4873-ae16-89d5d5fa972e
300+
type: string
301+
id:
302+
description: UUID for the resource
303+
example: 65392deb-5e92-4268-b114-297faad6cdce
304+
type: string
305+
importHash:
306+
description: The SHA256 hash of a unique combination of values to use in duplicate
307+
detection
308+
example: 867e3a26dc0baf73f4bff506f31a97f6c32088917e9e5cf1a5ed6f3f84a6fa70
309+
type: string
310+
links:
311+
description: Links for the transaction
312+
properties:
313+
self:
314+
description: The transaction itself
315+
example: https://example.com/api/v1/transactions/d430d7c3-d14c-4712-9336-ee56965a6673
316+
type: string
317+
type: object
318+
note:
319+
description: A note
320+
example: Lunch
321+
type: string
322+
reconciled:
323+
default: false
324+
description: DEPRECATED. Do not use, this field does not work as intended.
325+
See https://github.com/envelope-zero/backend/issues/528. Use reconciledSource
326+
and reconciledDestination instead.
327+
example: true
328+
type: boolean
329+
reconciledDestination:
330+
default: false
331+
description: Is the transaction reconciled in the destination account?
332+
example: true
333+
type: boolean
334+
reconciledSource:
335+
default: false
336+
description: Is the transaction reconciled in the source account?
337+
example: true
338+
type: boolean
339+
sourceAccountId:
340+
description: ID of the source account
341+
example: fd81dc45-a3a2-468e-a6fa-b2618f30aa45
342+
type: string
343+
updatedAt:
344+
description: Last time the resource was updated
345+
example: "2022-04-17T20:14:01.048145Z"
346+
type: string
347+
type: object
261348
controllers.TransactionListResponse:
262349
properties:
263350
data:
264351
description: List of transactions
265352
items:
266-
$ref: '#/definitions/models.Transaction'
353+
$ref: '#/definitions/controllers.Transaction'
267354
type: array
268355
type: object
269356
controllers.TransactionResponse:
270357
properties:
271358
data:
272359
allOf:
273-
- $ref: '#/definitions/models.Transaction'
360+
- $ref: '#/definitions/controllers.Transaction'
274361
description: Data for the transaction
275362
type: object
363+
controllers.TransactionV2:
364+
properties:
365+
amount:
366+
description: The maximum value is "999999999999.99999999", swagger unfortunately
367+
rounds this.
368+
example: 14.03
369+
maximum: 1000000000000
370+
minimum: 1e-08
371+
multipleOf: 1e-08
372+
type: number
373+
availableFrom:
374+
description: The date from which on the transaction amount is available for
375+
budgeting. Only used for income transactions. Defaults to the transaction
376+
date.
377+
example: "2021-11-17T00:00:00Z"
378+
type: string
379+
budgetId:
380+
description: ID of the budget
381+
example: 55eecbd8-7c46-4b06-ada9-f287802fb05e
382+
type: string
383+
createdAt:
384+
description: Time the resource was created
385+
example: "2022-04-02T19:28:44.491514Z"
386+
type: string
387+
date:
388+
description: Date of the transaction. Time is currently only used for sorting
389+
example: "1815-12-10T18:43:00.271152Z"
390+
type: string
391+
deletedAt:
392+
description: Time the resource was marked as deleted
393+
example: "2022-04-22T21:01:05.058161Z"
394+
type: string
395+
destinationAccountId:
396+
description: ID of the destination account
397+
example: 8e16b456-a719-48ce-9fec-e115cfa7cbcc
398+
type: string
399+
envelopeId:
400+
description: ID of the envelope
401+
example: 2649c965-7999-4873-ae16-89d5d5fa972e
402+
type: string
403+
id:
404+
description: UUID for the resource
405+
example: 65392deb-5e92-4268-b114-297faad6cdce
406+
type: string
407+
importHash:
408+
description: The SHA256 hash of a unique combination of values to use in duplicate
409+
detection
410+
example: 867e3a26dc0baf73f4bff506f31a97f6c32088917e9e5cf1a5ed6f3f84a6fa70
411+
type: string
412+
links:
413+
description: Links for the transaction
414+
properties:
415+
self:
416+
description: The transaction itself
417+
example: https://example.com/api/v1/transactions/d430d7c3-d14c-4712-9336-ee56965a6673
418+
type: string
419+
type: object
420+
note:
421+
description: A note
422+
example: Lunch
423+
type: string
424+
reconciled:
425+
default: false
426+
description: DEPRECATED. Do not use, this field does not work as intended.
427+
See https://github.com/envelope-zero/backend/issues/528. Use reconciledSource
428+
and reconciledDestination instead.
429+
example: true
430+
type: boolean
431+
reconciledDestination:
432+
default: false
433+
description: Is the transaction reconciled in the destination account?
434+
example: true
435+
type: boolean
436+
reconciledSource:
437+
default: false
438+
description: Is the transaction reconciled in the source account?
439+
example: true
440+
type: boolean
441+
sourceAccountId:
442+
description: ID of the source account
443+
example: fd81dc45-a3a2-468e-a6fa-b2618f30aa45
444+
type: string
445+
updatedAt:
446+
description: Last time the resource was updated
447+
example: "2022-04-17T20:14:01.048145Z"
448+
type: string
449+
type: object
276450
httperrors.HTTPError:
277451
properties:
278452
error:
@@ -982,93 +1156,6 @@ definitions:
9821156
x-enum-varnames:
9831157
- AffectAvailable
9841158
- AffectEnvelope
985-
models.Transaction:
986-
properties:
987-
amount:
988-
description: The maximum value is "999999999999.99999999", swagger unfortunately
989-
rounds this.
990-
example: 14.03
991-
maximum: 1000000000000
992-
minimum: 1e-08
993-
multipleOf: 1e-08
994-
type: number
995-
availableFrom:
996-
description: The date from which on the transaction amount is available for
997-
budgeting. Only used for income transactions. Defaults to the transaction
998-
date.
999-
example: "2021-11-17T00:00:00Z"
1000-
type: string
1001-
budgetId:
1002-
description: ID of the budget
1003-
example: 55eecbd8-7c46-4b06-ada9-f287802fb05e
1004-
type: string
1005-
createdAt:
1006-
description: Time the resource was created
1007-
example: "2022-04-02T19:28:44.491514Z"
1008-
type: string
1009-
date:
1010-
description: Date of the transaction. Time is currently only used for sorting
1011-
example: "1815-12-10T18:43:00.271152Z"
1012-
type: string
1013-
deletedAt:
1014-
description: Time the resource was marked as deleted
1015-
example: "2022-04-22T21:01:05.058161Z"
1016-
type: string
1017-
destinationAccountId:
1018-
description: ID of the destination account
1019-
example: 8e16b456-a719-48ce-9fec-e115cfa7cbcc
1020-
type: string
1021-
envelopeId:
1022-
description: ID of the envelope
1023-
example: 2649c965-7999-4873-ae16-89d5d5fa972e
1024-
type: string
1025-
id:
1026-
description: UUID for the resource
1027-
example: 65392deb-5e92-4268-b114-297faad6cdce
1028-
type: string
1029-
importHash:
1030-
description: The SHA256 hash of a unique combination of values to use in duplicate
1031-
detection
1032-
example: 867e3a26dc0baf73f4bff506f31a97f6c32088917e9e5cf1a5ed6f3f84a6fa70
1033-
type: string
1034-
links:
1035-
description: Links for the transaction
1036-
properties:
1037-
self:
1038-
description: The transaction itself
1039-
example: https://example.com/api/v1/transactions/d430d7c3-d14c-4712-9336-ee56965a6673
1040-
type: string
1041-
type: object
1042-
note:
1043-
description: A note
1044-
example: Lunch
1045-
type: string
1046-
reconciled:
1047-
default: false
1048-
description: DEPRECATED. Do not use, this field does not work as intended.
1049-
See https://github.com/envelope-zero/backend/issues/528. Use reconciledSource
1050-
and reconciledDestination instead.
1051-
example: true
1052-
type: boolean
1053-
reconciledDestination:
1054-
default: false
1055-
description: Is the transaction reconciled in the destination account?
1056-
example: true
1057-
type: boolean
1058-
reconciledSource:
1059-
default: false
1060-
description: Is the transaction reconciled in the source account?
1061-
example: true
1062-
type: boolean
1063-
sourceAccountId:
1064-
description: ID of the source account
1065-
example: fd81dc45-a3a2-468e-a6fa-b2618f30aa45
1066-
type: string
1067-
updatedAt:
1068-
description: Last time the resource was updated
1069-
example: "2022-04-17T20:14:01.048145Z"
1070-
type: string
1071-
type: object
10721159
models.TransactionCreate:
10731160
properties:
10741161
amount:

commitlint.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
module.exports = {
22
extends: ["@commitlint/config-conventional"],
3-
rules: {},
3+
rules: {
4+
"subject-case": () => [
5+
2,
6+
"never",
7+
["snake-case", "pascal-case", "upper-case"],
8+
],
9+
"body-max-line-length": [0, "always", Infinity],
10+
},
411
};

pkg/controllers/responses.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
)
99

1010
type ResponseTransactionV2 struct {
11-
Error string `json:"error" example:"A human readable error message"` // This field contains a human readable error message
12-
Data models.Transaction `json:"data"` // This field contains the transaction data
11+
Error string `json:"error" example:"A human readable error message"` // This field contains a human readable error message
12+
Data TransactionV2 `json:"data"` // This field contains the transaction data
1313
}
1414

1515
type ResponseMatchRule struct {

0 commit comments

Comments
 (0)