Skip to content

Commit

Permalink
feat: allocation setting shortcuts for spend and budgeted amount of l…
Browse files Browse the repository at this point in the history
…ast month
  • Loading branch information
morremeyer committed Aug 15, 2022
1 parent ea0c310 commit 46588a0
Show file tree
Hide file tree
Showing 11 changed files with 494 additions and 35 deletions.
62 changes: 60 additions & 2 deletions api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,55 @@ const docTemplate = `{
}
},
"/v1/budgets/{budgetId}/{month}/allocations": {
"post": {
"description": "Sets allocations for a month for all envelopes that do not have an allocation yet",
"tags": [
"Budgets"
],
"summary": "Set allocations for a month",
"parameters": [
{
"type": "string",
"description": "The month in YYYY-MM format",
"name": "month",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Budget ID formatted as string",
"name": "budgetId",
"in": "path",
"required": true
},
{
"description": "Budget",
"name": "mode",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/controllers.BudgetAllocationMode"
}
}
],
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httperrors.HTTPError"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/httperrors.HTTPError"
}
}
}
},
"delete": {
"description": "Deletes all allocation for the specified month",
"tags": [
Expand Down Expand Up @@ -2211,6 +2260,15 @@ const docTemplate = `{
}
}
},
"controllers.BudgetAllocationMode": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"example": "ALLOCATE_LAST_MONTH_SPEND"
}
}
},
"controllers.BudgetLinks": {
"type": "object",
"properties": {
Expand All @@ -2227,12 +2285,12 @@ const docTemplate = `{
"example": "https://example.com/api/v1/envelopes?budget=550dc009-cea6-4c12-b2a5-03446eb7b7cf"
},
"month": {
"description": "This 'YYYY-MM' for clients to use replace with the actual year and month.",
"description": "This 'YYYY-MM' for clients to replace with the actual year and month.",
"type": "string",
"example": "https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf/YYYY-MM"
},
"monthAllocations": {
"description": "This uses 'YYYY-MM' for clients to use replace with the actual year and month.",
"description": "This uses 'YYYY-MM' for clients to replace with the actual year and month.",
"type": "string",
"example": "https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf/YYYY-MM/allocations"
},
Expand Down
62 changes: 60 additions & 2 deletions api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,55 @@
}
},
"/v1/budgets/{budgetId}/{month}/allocations": {
"post": {
"description": "Sets allocations for a month for all envelopes that do not have an allocation yet",
"tags": [
"Budgets"
],
"summary": "Set allocations for a month",
"parameters": [
{
"type": "string",
"description": "The month in YYYY-MM format",
"name": "month",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Budget ID formatted as string",
"name": "budgetId",
"in": "path",
"required": true
},
{
"description": "Budget",
"name": "mode",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/controllers.BudgetAllocationMode"
}
}
],
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/httperrors.HTTPError"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/httperrors.HTTPError"
}
}
}
},
"delete": {
"description": "Deletes all allocation for the specified month",
"tags": [
Expand Down Expand Up @@ -2199,6 +2248,15 @@
}
}
},
"controllers.BudgetAllocationMode": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"example": "ALLOCATE_LAST_MONTH_SPEND"
}
}
},
"controllers.BudgetLinks": {
"type": "object",
"properties": {
Expand All @@ -2215,12 +2273,12 @@
"example": "https://example.com/api/v1/envelopes?budget=550dc009-cea6-4c12-b2a5-03446eb7b7cf"
},
"month": {
"description": "This 'YYYY-MM' for clients to use replace with the actual year and month.",
"description": "This 'YYYY-MM' for clients to replace with the actual year and month.",
"type": "string",
"example": "https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf/YYYY-MM"
},
"monthAllocations": {
"description": "This uses 'YYYY-MM' for clients to use replace with the actual year and month.",
"description": "This uses 'YYYY-MM' for clients to replace with the actual year and month.",
"type": "string",
"example": "https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf/YYYY-MM/allocations"
},
Expand Down
48 changes: 44 additions & 4 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ definitions:
example: "2022-04-17T20:14:01.048145Z"
type: string
type: object
controllers.BudgetAllocationMode:
properties:
mode:
example: ALLOCATE_LAST_MONTH_SPEND
type: string
type: object
controllers.BudgetLinks:
properties:
accounts:
Expand All @@ -154,13 +160,13 @@ definitions:
example: https://example.com/api/v1/envelopes?budget=550dc009-cea6-4c12-b2a5-03446eb7b7cf
type: string
month:
description: This 'YYYY-MM' for clients to use replace with the actual year
and month.
description: This 'YYYY-MM' for clients to replace with the actual year and
month.
example: https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf/YYYY-MM
type: string
monthAllocations:
description: This uses 'YYYY-MM' for clients to use replace with the actual
year and month.
description: This uses 'YYYY-MM' for clients to replace with the actual year
and month.
example: https://example.com/api/v1/budgets/550dc009-cea6-4c12-b2a5-03446eb7b7cf/YYYY-MM/allocations
type: string
self:
Expand Down Expand Up @@ -1308,6 +1314,40 @@ paths:
summary: Allowed HTTP verbs
tags:
- Budgets
post:
description: Sets allocations for a month for all envelopes that do not have
an allocation yet
parameters:
- description: The month in YYYY-MM format
in: path
name: month
required: true
type: string
- description: Budget ID formatted as string
in: path
name: budgetId
required: true
type: string
- description: Budget
in: body
name: mode
required: true
schema:
$ref: '#/definitions/controllers.BudgetAllocationMode'
responses:
"204":
description: No Content
"400":
description: Bad Request
schema:
$ref: '#/definitions/httperrors.HTTPError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/httperrors.HTTPError'
summary: Set allocations for a month
tags:
- Budgets
/v1/categories:
get:
description: Returns a list of categories
Expand Down
Loading

0 comments on commit 46588a0

Please sign in to comment.