From b88cf3b1a1c82e9a60774a0393993e1e55f41132 Mon Sep 17 00:00:00 2001 From: Prabhakar Mishra Date: Fri, 24 Jan 2025 13:10:38 +0530 Subject: [PATCH 1/2] feat: API spec for spender bulk edit expenses API --- reference/spender.yaml | 60 ++++++++++++++++++++ src/spender/openapi.yaml | 2 + src/spender/paths/spender@expenses@bulk.yaml | 52 +++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 src/spender/paths/spender@expenses@bulk.yaml diff --git a/reference/spender.yaml b/reference/spender.yaml index 85c8e375c..c3ab5475a 100644 --- a/reference/spender.yaml +++ b/reference/spender.yaml @@ -2458,6 +2458,13 @@ components: - ROUND_TRIP - NO_DEDUCTION - null + spender_expenses_bulk_in: + type: array + additionalProperties: false + description: | + Array of expenses to be validated against expense policy rules in one request. + items: + $ref: '#/components/schemas/items' expense_add_comment_action_in: type: object required: @@ -9569,6 +9576,59 @@ paths: application/json: schema: $ref: '#/components/schemas/403' + /spender/expenses/bulk: + post: + tags: + - Expenses + summary: Update expenses in bulk + description: | + Update expenses in bulk. + operationId: expenses_post_bulk + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + data: + $ref: '#/components/schemas/spender_expenses_bulk_in' + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + data: + type: array + items: + $ref: '#/components/schemas/expense_out' + '400': + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/400' + '401': + description: Unauthorized request + content: + application/json: + schema: + $ref: '#/components/schemas/401' + '403': + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/403' + '404': + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/404' /spender/expenses/add_comment: post: tags: diff --git a/src/spender/openapi.yaml b/src/spender/openapi.yaml index a2f58cab2..46535df32 100644 --- a/src/spender/openapi.yaml +++ b/src/spender/openapi.yaml @@ -118,6 +118,8 @@ paths: $ref: 'paths/spender@departments.yaml' /spender/expenses: $ref: 'paths/spender@expenses.yaml' + /spender/expenses/bulk: + $ref: 'paths/spender@expenses@bulk.yaml' /spender/expenses/add_comment: $ref: 'paths/spender@expenses@add_comment.yaml' /spender/expenses/attach_receipt: diff --git a/src/spender/paths/spender@expenses@bulk.yaml b/src/spender/paths/spender@expenses@bulk.yaml new file mode 100644 index 000000000..dc552913d --- /dev/null +++ b/src/spender/paths/spender@expenses@bulk.yaml @@ -0,0 +1,52 @@ +post: + tags: + - Expenses + summary: Update expenses in bulk + description: | + Update expenses in bulk. + operationId: expenses_post_bulk + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + data: + $ref: '../../components/schemas/expense.yaml#/spender_expenses_bulk_in' + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + data: + type: array + items: + $ref: '../../components/schemas/expense.yaml#/expense_out' + '400': + description: Bad request + content: + application/json: + schema: + $ref: '../../components/schemas/400.yaml' + '401': + description: Unauthorized request + content: + application/json: + schema: + $ref: '../../components/schemas/401.yaml' + '403': + description: Forbidden + content: + application/json: + schema: + $ref: '../../components/schemas/403.yaml' + '404': + description: Not Found + content: + application/json: + schema: + $ref: '../../components/schemas/404.yaml' From 3b231121c7c4f009db57cbf3b892e5ec5fdb09f3 Mon Sep 17 00:00:00 2001 From: Siva Date: Fri, 24 Jan 2025 07:47:43 +0000 Subject: [PATCH 2/2] Auto generate API docs --- reference/spender.yaml | 100 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/reference/spender.yaml b/reference/spender.yaml index c3ab5475a..d43557fe2 100644 --- a/reference/spender.yaml +++ b/reference/spender.yaml @@ -2462,9 +2462,105 @@ components: type: array additionalProperties: false description: | - Array of expenses to be validated against expense policy rules in one request. + Array of expenses to be updated in bulk by the spender. items: - $ref: '#/components/schemas/items' + type: object + required: + - id + - category_id + properties: + id: + allOf: + - $ref: '#/components/schemas/id_string' + description: | + Expense id of the expense to be updated. + example: txwownwrng + merchant: + $ref: '#/components/schemas/merchant' + nullable: true + description: | + String denoting the name of the merchant to which the expense was made. + example: Uber + purpose: + type: string + nullable: true + description: | + Purpose of this expense. + example: Team lunch + cost_center_id: + allOf: + - $ref: '#/components/schemas/fk_integer' + nullable: true + description: | + This represents the cost_center's id given by Fyle during creation of cost center + for which this expense is created. + example: 1049 + category_id: + allOf: + - $ref: '#/components/schemas/fk_integer' + nullable: false + description: | + This represents the category's id given by Fyle during creation of category + for which this expense is created. + example: 49058 + project_id: + allOf: + - $ref: '#/components/schemas/fk_integer' + nullable: true + description: | + This represents the project's id given by Fyle during creation of project + for which this expense is created. + example: 92895 + is_billable: + $ref: '#/components/schemas/is_billable' + nullable: true + description: This fields marks whether a given expense is billable or not. + example: true + custom_fields: + $ref: '#/components/schemas/custom_fields' + nullable: false + started_at: + $ref: '#/components/schemas/timestamptz_pst' + nullable: true + description: | + Start date for travel or per diem related expenses. + ended_at: + $ref: '#/components/schemas/timestamptz_pst' + nullable: true + description: | + End date for travel or per diem related expenses. + travel_classes: + $ref: '#/components/schemas/travel_classes' + nullable: false + description: | + This field is applicable only for `Flight`, `Train`, `Bus`, `Taxi` category. + index 0 holds onward journey class, index 1 holds return journey travel class. + example: + - ECONOMY + - BUSINESS + locations: + $ref: '#/components/schemas/locations' + nullable: false + description: | + This field will be present for travel related categories. + For travel between Place A to Place B, this array will contain two items, From location at array index 0 and To location at array index 1. + distance: + $ref: '#/components/schemas/distance' + nullable: true + description: Actual distance travelled by employee in travel related expenses. + distance_unit: + enum: + - KM + - MILES + - null + nullable: true + description: Unit of distance travelled. + example: MILES + hotel_is_breakfast_provided: + type: boolean + nullable: true + description: | + This field is applicable for only `Hotel` category. expense_add_comment_action_in: type: object required: