Skip to content

Commit 7e43c1c

Browse files
authored
feat: add accounts API v2 get collection endpoint, improve recentEnvelopes (#792)
This adds the `GET /api/v2/accounts` endpoint. For this endpoint, `recentEnvelopes` now returns only returns the IDs of the recently used envelopes. This takes into account the last 50 transactions and returns the 5 most common envelopes for the account as transaction destination. Envelopes with the same frequency are returned with the most recently created envelope first.
1 parent 56e20c3 commit 7e43c1c

20 files changed

+1659
-501
lines changed

api/docs.go

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const docTemplate = `{
101101
"Accounts"
102102
],
103103
"summary": "List accounts",
104+
"deprecated": true,
104105
"parameters": [
105106
{
106107
"type": "string",
@@ -2615,6 +2616,7 @@ const docTemplate = `{
26152616
"Transactions"
26162617
],
26172618
"summary": "Create transaction",
2619+
"deprecated": true,
26182620
"parameters": [
26192621
{
26202622
"description": "Transaction",
@@ -2847,6 +2849,106 @@ const docTemplate = `{
28472849
}
28482850
}
28492851
},
2852+
"/v2/accounts": {
2853+
"get": {
2854+
"description": "Returns a list of accounts",
2855+
"produces": [
2856+
"application/json"
2857+
],
2858+
"tags": [
2859+
"Accounts"
2860+
],
2861+
"summary": "List accounts",
2862+
"parameters": [
2863+
{
2864+
"type": "string",
2865+
"description": "Filter by name",
2866+
"name": "name",
2867+
"in": "query"
2868+
},
2869+
{
2870+
"type": "string",
2871+
"description": "Filter by note",
2872+
"name": "note",
2873+
"in": "query"
2874+
},
2875+
{
2876+
"type": "string",
2877+
"description": "Filter by budget ID",
2878+
"name": "budget",
2879+
"in": "query"
2880+
},
2881+
{
2882+
"type": "boolean",
2883+
"description": "Is the account on-budget?",
2884+
"name": "onBudget",
2885+
"in": "query"
2886+
},
2887+
{
2888+
"type": "boolean",
2889+
"description": "Is the account external?",
2890+
"name": "external",
2891+
"in": "query"
2892+
},
2893+
{
2894+
"type": "boolean",
2895+
"description": "Is the account hidden?",
2896+
"name": "hidden",
2897+
"in": "query"
2898+
},
2899+
{
2900+
"type": "string",
2901+
"description": "Search for this text in name and note",
2902+
"name": "search",
2903+
"in": "query"
2904+
}
2905+
],
2906+
"responses": {
2907+
"200": {
2908+
"description": "OK",
2909+
"schema": {
2910+
"$ref": "#/definitions/controllers.AccountListResponse"
2911+
}
2912+
},
2913+
"400": {
2914+
"description": "Bad Request",
2915+
"schema": {
2916+
"$ref": "#/definitions/httperrors.HTTPError"
2917+
}
2918+
},
2919+
"404": {
2920+
"description": "Not Found"
2921+
},
2922+
"500": {
2923+
"description": "Internal Server Error",
2924+
"schema": {
2925+
"$ref": "#/definitions/httperrors.HTTPError"
2926+
}
2927+
}
2928+
}
2929+
},
2930+
"options": {
2931+
"description": "Returns an empty response with the HTTP Header \"allow\" set to the allowed HTTP verbs",
2932+
"tags": [
2933+
"Accounts"
2934+
],
2935+
"summary": "Allowed HTTP verbs",
2936+
"responses": {
2937+
"204": {
2938+
"description": "No Content"
2939+
},
2940+
"400": {
2941+
"description": "Bad Request",
2942+
"schema": {
2943+
"$ref": "#/definitions/httperrors.HTTPError"
2944+
}
2945+
},
2946+
"404": {
2947+
"description": "Not Found"
2948+
}
2949+
}
2950+
}
2951+
},
28502952
"/v2/match-rules": {
28512953
"get": {
28522954
"description": "Returns a list of matchRules",
@@ -5107,6 +5209,11 @@ const docTemplate = `{
51075209
"router.V2Links": {
51085210
"type": "object",
51095211
"properties": {
5212+
"accounts": {
5213+
"description": "URL of transaction list endpoint",
5214+
"type": "string",
5215+
"example": "https://example.com/api/v2/accounts"
5216+
},
51105217
"match-rules": {
51115218
"description": "URL of match-rule list endpoint",
51125219
"type": "string",

api/swagger.json

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"Accounts"
9191
],
9292
"summary": "List accounts",
93+
"deprecated": true,
9394
"parameters": [
9495
{
9596
"type": "string",
@@ -2604,6 +2605,7 @@
26042605
"Transactions"
26052606
],
26062607
"summary": "Create transaction",
2608+
"deprecated": true,
26072609
"parameters": [
26082610
{
26092611
"description": "Transaction",
@@ -2836,6 +2838,106 @@
28362838
}
28372839
}
28382840
},
2841+
"/v2/accounts": {
2842+
"get": {
2843+
"description": "Returns a list of accounts",
2844+
"produces": [
2845+
"application/json"
2846+
],
2847+
"tags": [
2848+
"Accounts"
2849+
],
2850+
"summary": "List accounts",
2851+
"parameters": [
2852+
{
2853+
"type": "string",
2854+
"description": "Filter by name",
2855+
"name": "name",
2856+
"in": "query"
2857+
},
2858+
{
2859+
"type": "string",
2860+
"description": "Filter by note",
2861+
"name": "note",
2862+
"in": "query"
2863+
},
2864+
{
2865+
"type": "string",
2866+
"description": "Filter by budget ID",
2867+
"name": "budget",
2868+
"in": "query"
2869+
},
2870+
{
2871+
"type": "boolean",
2872+
"description": "Is the account on-budget?",
2873+
"name": "onBudget",
2874+
"in": "query"
2875+
},
2876+
{
2877+
"type": "boolean",
2878+
"description": "Is the account external?",
2879+
"name": "external",
2880+
"in": "query"
2881+
},
2882+
{
2883+
"type": "boolean",
2884+
"description": "Is the account hidden?",
2885+
"name": "hidden",
2886+
"in": "query"
2887+
},
2888+
{
2889+
"type": "string",
2890+
"description": "Search for this text in name and note",
2891+
"name": "search",
2892+
"in": "query"
2893+
}
2894+
],
2895+
"responses": {
2896+
"200": {
2897+
"description": "OK",
2898+
"schema": {
2899+
"$ref": "#/definitions/controllers.AccountListResponse"
2900+
}
2901+
},
2902+
"400": {
2903+
"description": "Bad Request",
2904+
"schema": {
2905+
"$ref": "#/definitions/httperrors.HTTPError"
2906+
}
2907+
},
2908+
"404": {
2909+
"description": "Not Found"
2910+
},
2911+
"500": {
2912+
"description": "Internal Server Error",
2913+
"schema": {
2914+
"$ref": "#/definitions/httperrors.HTTPError"
2915+
}
2916+
}
2917+
}
2918+
},
2919+
"options": {
2920+
"description": "Returns an empty response with the HTTP Header \"allow\" set to the allowed HTTP verbs",
2921+
"tags": [
2922+
"Accounts"
2923+
],
2924+
"summary": "Allowed HTTP verbs",
2925+
"responses": {
2926+
"204": {
2927+
"description": "No Content"
2928+
},
2929+
"400": {
2930+
"description": "Bad Request",
2931+
"schema": {
2932+
"$ref": "#/definitions/httperrors.HTTPError"
2933+
}
2934+
},
2935+
"404": {
2936+
"description": "Not Found"
2937+
}
2938+
}
2939+
}
2940+
},
28392941
"/v2/match-rules": {
28402942
"get": {
28412943
"description": "Returns a list of matchRules",
@@ -5096,6 +5198,11 @@
50965198
"router.V2Links": {
50975199
"type": "object",
50985200
"properties": {
5201+
"accounts": {
5202+
"description": "URL of transaction list endpoint",
5203+
"type": "string",
5204+
"example": "https://example.com/api/v2/accounts"
5205+
},
50995206
"match-rules": {
51005207
"description": "URL of match-rule list endpoint",
51015208
"type": "string",

api/swagger.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,10 @@ definitions:
12021202
type: object
12031203
router.V2Links:
12041204
properties:
1205+
accounts:
1206+
description: URL of transaction list endpoint
1207+
example: https://example.com/api/v2/accounts
1208+
type: string
12051209
match-rules:
12061210
description: URL of match-rule list endpoint
12071211
example: https://example.com/api/v2/match-rules
@@ -1293,6 +1297,7 @@ paths:
12931297
- v1
12941298
/v1/accounts:
12951299
get:
1300+
deprecated: true
12961301
description: Returns a list of accounts
12971302
parameters:
12981303
- description: Filter by name
@@ -3012,6 +3017,7 @@ paths:
30123017
tags:
30133018
- Transactions
30143019
post:
3020+
deprecated: true
30153021
description: Creates a new transaction
30163022
parameters:
30173023
- description: Transaction
@@ -3165,6 +3171,73 @@ paths:
31653171
summary: Allowed HTTP verbs
31663172
tags:
31673173
- v2
3174+
/v2/accounts:
3175+
get:
3176+
description: Returns a list of accounts
3177+
parameters:
3178+
- description: Filter by name
3179+
in: query
3180+
name: name
3181+
type: string
3182+
- description: Filter by note
3183+
in: query
3184+
name: note
3185+
type: string
3186+
- description: Filter by budget ID
3187+
in: query
3188+
name: budget
3189+
type: string
3190+
- description: Is the account on-budget?
3191+
in: query
3192+
name: onBudget
3193+
type: boolean
3194+
- description: Is the account external?
3195+
in: query
3196+
name: external
3197+
type: boolean
3198+
- description: Is the account hidden?
3199+
in: query
3200+
name: hidden
3201+
type: boolean
3202+
- description: Search for this text in name and note
3203+
in: query
3204+
name: search
3205+
type: string
3206+
produces:
3207+
- application/json
3208+
responses:
3209+
"200":
3210+
description: OK
3211+
schema:
3212+
$ref: '#/definitions/controllers.AccountListResponse'
3213+
"400":
3214+
description: Bad Request
3215+
schema:
3216+
$ref: '#/definitions/httperrors.HTTPError'
3217+
"404":
3218+
description: Not Found
3219+
"500":
3220+
description: Internal Server Error
3221+
schema:
3222+
$ref: '#/definitions/httperrors.HTTPError'
3223+
summary: List accounts
3224+
tags:
3225+
- Accounts
3226+
options:
3227+
description: Returns an empty response with the HTTP Header "allow" set to the
3228+
allowed HTTP verbs
3229+
responses:
3230+
"204":
3231+
description: No Content
3232+
"400":
3233+
description: Bad Request
3234+
schema:
3235+
$ref: '#/definitions/httperrors.HTTPError'
3236+
"404":
3237+
description: Not Found
3238+
summary: Allowed HTTP verbs
3239+
tags:
3240+
- Accounts
31683241
/v2/match-rules:
31693242
get:
31703243
description: Returns a list of matchRules

0 commit comments

Comments
 (0)