Skip to content

Commit 5b6aab5

Browse files
authored
feat: add rename rules for transaction import (#734)
* refactor: use pointer for resource manipulation * feat: add rename rules for transaction import This adds rules that enable renaming transactions on import. Rename rules support globbing to make them versatile.
1 parent 6f4ab32 commit 5b6aab5

File tree

15 files changed

+1588
-16
lines changed

15 files changed

+1588
-16
lines changed

api/docs.go

Lines changed: 389 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger.json

Lines changed: 389 additions & 0 deletions
Large diffs are not rendered by default.

api/swagger.yaml

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,29 @@ definitions:
229229
data:
230230
$ref: '#/definitions/models.Month'
231231
type: object
232+
controllers.RenameRuleListResponse:
233+
properties:
234+
data:
235+
items:
236+
$ref: '#/definitions/models.RenameRule'
237+
type: array
238+
type: object
239+
controllers.RenameRuleResponse:
240+
properties:
241+
data:
242+
$ref: '#/definitions/models.RenameRule'
243+
type: object
244+
controllers.ResponseRenameRule:
245+
properties:
246+
data:
247+
allOf:
248+
- $ref: '#/definitions/models.RenameRule'
249+
description: This field contains the model data
250+
error:
251+
description: This field contains a human readable error message
252+
example: A human readable error message
253+
type: string
254+
type: object
232255
controllers.ResponseTransactionV2:
233256
properties:
234257
data:
@@ -810,6 +833,60 @@ definitions:
810833
x-enum-varnames:
811834
- AffectAvailable
812835
- AffectEnvelope
836+
models.RenameRule:
837+
properties:
838+
accountId:
839+
description: The account to map matching transactions to
840+
example: f9e873c2-fb96-4367-bfb6-7ecd9bf4a6b5
841+
type: string
842+
createdAt:
843+
description: Time the resource was created
844+
example: "2022-04-02T19:28:44.491514Z"
845+
type: string
846+
deletedAt:
847+
description: Time the resource was marked as deleted
848+
example: "2022-04-22T21:01:05.058161Z"
849+
type: string
850+
id:
851+
description: UUID for the resource
852+
example: 65392deb-5e92-4268-b114-297faad6cdce
853+
type: string
854+
links:
855+
properties:
856+
self:
857+
example: https://example.com/api/v2/rename-rules/95685c82-53c6-455d-b235-f49960b73b21
858+
type: string
859+
type: object
860+
match:
861+
description: The matching applied to the opposite account. This is a glob
862+
pattern. Multiple globs are allowed. Globbing is case sensitive.
863+
example: Bank*
864+
type: string
865+
priority:
866+
description: The priority of the rename rule
867+
example: 3
868+
type: integer
869+
updatedAt:
870+
description: Last time the resource was updated
871+
example: "2022-04-17T20:14:01.048145Z"
872+
type: string
873+
type: object
874+
models.RenameRuleCreate:
875+
properties:
876+
accountId:
877+
description: The account to map matching transactions to
878+
example: f9e873c2-fb96-4367-bfb6-7ecd9bf4a6b5
879+
type: string
880+
match:
881+
description: The matching applied to the opposite account. This is a glob
882+
pattern. Multiple globs are allowed. Globbing is case sensitive.
883+
example: Bank*
884+
type: string
885+
priority:
886+
description: The priority of the rename rule
887+
example: 3
888+
type: integer
889+
type: object
813890
models.Transaction:
814891
properties:
815892
amount:
@@ -1012,6 +1089,10 @@ definitions:
10121089
type: object
10131090
router.V2Links:
10141091
properties:
1092+
rename-rules:
1093+
description: URL of rename-rule list endpoint
1094+
example: https://example.com/api/v2/rename-rules
1095+
type: string
10151096
transactions:
10161097
description: URL of transaction list endpoint
10171098
example: https://example.com/api/v2/transactions
@@ -2967,6 +3048,195 @@ paths:
29673048
summary: Allowed HTTP verbs
29683049
tags:
29693050
- v2
3051+
/v2/rename-rules:
3052+
get:
3053+
description: Returns a list of renameRules
3054+
parameters:
3055+
- description: Filter by priority
3056+
in: query
3057+
name: priority
3058+
type: integer
3059+
- description: Filter by match
3060+
in: query
3061+
name: match
3062+
type: string
3063+
- description: Filter by account ID
3064+
in: query
3065+
name: account
3066+
type: string
3067+
produces:
3068+
- application/json
3069+
responses:
3070+
"200":
3071+
description: OK
3072+
schema:
3073+
$ref: '#/definitions/controllers.RenameRuleListResponse'
3074+
"400":
3075+
description: Bad Request
3076+
schema:
3077+
$ref: '#/definitions/httperrors.HTTPError'
3078+
"404":
3079+
description: Not Found
3080+
"500":
3081+
description: Internal Server Error
3082+
schema:
3083+
$ref: '#/definitions/httperrors.HTTPError'
3084+
summary: Get renameRules
3085+
tags:
3086+
- RenameRules
3087+
options:
3088+
description: Returns an empty response with the HTTP Header "allow" set to the
3089+
allowed HTTP verbs
3090+
responses:
3091+
"204":
3092+
description: No Content
3093+
summary: Allowed HTTP verbs
3094+
tags:
3095+
- RenameRules
3096+
post:
3097+
description: Creates renameRules from the list of submitted renameRule data.
3098+
The response code is the highest response code number that a single renameRule
3099+
creation would have caused. If it is not equal to 201, at least one renameRule
3100+
has an error.
3101+
parameters:
3102+
- description: RenameRules
3103+
in: body
3104+
name: renameRules
3105+
required: true
3106+
schema:
3107+
items:
3108+
$ref: '#/definitions/models.RenameRuleCreate'
3109+
type: array
3110+
produces:
3111+
- application/json
3112+
responses:
3113+
"201":
3114+
description: Created
3115+
schema:
3116+
items:
3117+
$ref: '#/definitions/controllers.ResponseRenameRule'
3118+
type: array
3119+
"400":
3120+
description: Bad Request
3121+
schema:
3122+
items:
3123+
$ref: '#/definitions/controllers.ResponseRenameRule'
3124+
type: array
3125+
"404":
3126+
description: Not Found
3127+
"500":
3128+
description: Internal Server Error
3129+
schema:
3130+
items:
3131+
$ref: '#/definitions/controllers.ResponseRenameRule'
3132+
type: array
3133+
summary: Create renameRules
3134+
tags:
3135+
- RenameRules
3136+
/v2/rename-rules/{renameRuleId}:
3137+
delete:
3138+
description: Deletes an renameRule
3139+
parameters:
3140+
- description: ID formatted as string
3141+
in: path
3142+
name: renameRuleId
3143+
required: true
3144+
type: string
3145+
responses:
3146+
"204":
3147+
description: No Content
3148+
"400":
3149+
description: Bad Request
3150+
schema:
3151+
$ref: '#/definitions/httperrors.HTTPError'
3152+
"404":
3153+
description: Not Found
3154+
"500":
3155+
description: Internal Server Error
3156+
schema:
3157+
$ref: '#/definitions/httperrors.HTTPError'
3158+
summary: Delete renameRule
3159+
tags:
3160+
- RenameRules
3161+
get:
3162+
description: Returns a specific renameRule
3163+
parameters:
3164+
- description: ID formatted as string
3165+
in: path
3166+
name: renameRuleId
3167+
required: true
3168+
type: string
3169+
produces:
3170+
- application/json
3171+
responses:
3172+
"200":
3173+
description: OK
3174+
schema:
3175+
$ref: '#/definitions/controllers.RenameRuleResponse'
3176+
"400":
3177+
description: Bad Request
3178+
schema:
3179+
$ref: '#/definitions/httperrors.HTTPError'
3180+
"404":
3181+
description: Not Found
3182+
"500":
3183+
description: Internal Server Error
3184+
schema:
3185+
$ref: '#/definitions/httperrors.HTTPError'
3186+
summary: Get renameRule
3187+
tags:
3188+
- RenameRules
3189+
options:
3190+
description: Returns an empty response with the HTTP Header "allow" set to the
3191+
allowed HTTP verbs
3192+
parameters:
3193+
- description: ID formatted as string
3194+
in: path
3195+
name: renameRuleId
3196+
required: true
3197+
type: string
3198+
responses:
3199+
"204":
3200+
description: No Content
3201+
summary: Allowed HTTP verbs
3202+
tags:
3203+
- RenameRules
3204+
patch:
3205+
consumes:
3206+
- application/json
3207+
description: Update an renameRule. Only values to be updated need to be specified.
3208+
parameters:
3209+
- description: ID formatted as string
3210+
in: path
3211+
name: renameRuleId
3212+
required: true
3213+
type: string
3214+
- description: RenameRule
3215+
in: body
3216+
name: renameRule
3217+
required: true
3218+
schema:
3219+
$ref: '#/definitions/models.RenameRuleCreate'
3220+
produces:
3221+
- application/json
3222+
responses:
3223+
"200":
3224+
description: OK
3225+
schema:
3226+
$ref: '#/definitions/controllers.RenameRuleResponse'
3227+
"400":
3228+
description: Bad Request
3229+
schema:
3230+
$ref: '#/definitions/httperrors.HTTPError'
3231+
"404":
3232+
description: Not Found
3233+
"500":
3234+
description: Internal Server Error
3235+
schema:
3236+
$ref: '#/definitions/httperrors.HTTPError'
3237+
summary: Update renameRule
3238+
tags:
3239+
- RenameRules
29703240
/v2/transactions:
29713241
options:
29723242
description: Returns an empty response with the HTTP Header "allow" set to the

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ require (
5858
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
5959
github.com/pmezard/go-difflib v1.0.0 // indirect
6060
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
61+
github.com/ryanuber/go-glob v1.0.0
6162
github.com/ugorji/go/codec v1.2.11 // indirect
6263
golang.org/x/crypto v0.11.0 // indirect
6364
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
127127
github.com/rs/zerolog v1.20.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo=
128128
github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c=
129129
github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w=
130+
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
131+
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
130132
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
131133
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
132134
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

0 commit comments

Comments
 (0)