From e11650ef34370d62beaca962e440dd45707ec7e7 Mon Sep 17 00:00:00 2001 From: Madhav Mansuriya <51825933+madhavmansuriya40@users.noreply.github.com> Date: Thu, 2 Nov 2023 14:48:56 +0530 Subject: [PATCH] feat: Dismiss duplicates bulk endpoint in platform (#382) --- reference/spender.yaml | 102 ++++++++++++++++++ src/components/schemas/expense.yaml | 17 +++ src/spender/openapi.yaml | 2 + ...nder@expenses@dismiss_duplicates@bulk.yaml | 56 ++++++++++ 4 files changed, 177 insertions(+) create mode 100644 src/spender/paths/spender@expenses@dismiss_duplicates@bulk.yaml diff --git a/reference/spender.yaml b/reference/spender.yaml index 73fb47350..aa4aace4e 100644 --- a/reference/spender.yaml +++ b/reference/spender.yaml @@ -6192,6 +6192,53 @@ components: - 12423 description: | List of IDs of expense fields which are mandatory but are missing. + spender_expense_dismiss_duplicates_in: + type: object + required: + - id + - duplicate_expense_ids + additionalProperties: false + properties: + id: + $ref: '#/components/schemas/id_string' + duplicate_expense_ids: + type: array + nullable: false + items: + $ref: '#/components/schemas/id_string' + example: + - txwoirwlwwg + - txwlgwkgw42 + description: | + List of expense IDs that needs to be dismissed as a duplicate from the target expense + bulk_error: + type: object + properties: + error: + type: string + example: BulkError + message: + type: string + nullable: true + data: + type: array + items: + type: object + properties: + row: + type: integer + description: | + This holds the info of which row contains bad data. + key: + oneOf: + - type: string + - type: integer + description: | + This helps in identifying the error by unique key. + message: + type: string + description: | + This explains what the error is in `human readable` text parameters: q: in: query @@ -8521,3 +8568,58 @@ paths: application/json: schema: $ref: '#/components/schemas/404' + /spender/expenses/dismiss_duplicates/bulk: + post: + tags: + - Expenses + summary: Dismiss Duplicate expenses + description: | + This API helps dismissing similar expenses as a duplicates. + operationId: dismiss_duplicates_bulk_post + requestBody: + required: true + content: + application/json: + schema: + type: object + additionalProperties: false + required: + - data + properties: + data: + type: array + items: + $ref: '#/components/schemas/spender_expense_dismiss_duplicates_in' + responses: + '200': + description: OK + '400': + description: Bad request + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/bulk_error' + - type: object + properties: + error: + type: string + nullable: true + message: + type: string + nullable: true + data: + type: string + nullable: true + '401': + description: Unauthorised request + content: + application/json: + schema: + $ref: '#/components/schemas/401' + '403': + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/403' diff --git a/src/components/schemas/expense.yaml b/src/components/schemas/expense.yaml index 6b859f238..3bdd2ddf9 100644 --- a/src/components/schemas/expense.yaml +++ b/src/components/schemas/expense.yaml @@ -1474,3 +1474,20 @@ expense_check_mandatory_fields_in: allOf: - $ref: ./expense.yaml#/spender_expense_check_mandatory_fields_in +spender_expense_dismiss_duplicates_in: + type: object + required: + - id + - duplicate_expense_ids + additionalProperties: False + properties: + id: + $ref: './fields.yaml#/id_string' + duplicate_expense_ids: + type: array + nullable: False + items: + $ref: './fields.yaml#/id_string' + example: ['txwoirwlwwg', 'txwlgwkgw42'] + description: | + List of expense IDs that needs to be dismissed as a duplicate from the target expense \ No newline at end of file diff --git a/src/spender/openapi.yaml b/src/spender/openapi.yaml index 297d0a65e..3a6c7b01e 100644 --- a/src/spender/openapi.yaml +++ b/src/spender/openapi.yaml @@ -203,3 +203,5 @@ paths: $ref: paths/spender@automations@report_submissions@next_at.yaml /spender/expenses/check_mandatory_fields: $ref: paths/spender@expenses@check_mandatory_fields.yaml + /spender/expenses/dismiss_duplicates/bulk: + $ref: paths/spender@expenses@dismiss_duplicates@bulk.yaml diff --git a/src/spender/paths/spender@expenses@dismiss_duplicates@bulk.yaml b/src/spender/paths/spender@expenses@dismiss_duplicates@bulk.yaml new file mode 100644 index 000000000..a90adac25 --- /dev/null +++ b/src/spender/paths/spender@expenses@dismiss_duplicates@bulk.yaml @@ -0,0 +1,56 @@ +post: + tags: + - Expenses + summary: Dismiss Duplicate expenses + description: | + This API helps dismissing similar expenses as a duplicates. + operationId: dismiss_duplicates_bulk_post + requestBody: + required: True + content: + application/json: + schema: + type: object + additionalProperties: False + required: + - data + properties: + data: + type: array + items: + $ref: '../../components/schemas/expense.yaml#/spender_expense_dismiss_duplicates_in' + responses: + '200': + description: OK + '400': + description: Bad request + content: + application/json: + schema: + oneOf: + - $ref: '../../components/schemas/bulk_error.yaml' + - type: object + properties: + error: + type: string + nullable: True + message: + type: string + nullable: True + data: + type: string + nullable: True + '401': + description: Unauthorised request + content: + application/json: + schema: + $ref: "../../components/schemas/401.yaml" + '403': + description: Forbidden + content: + application/json: + schema: + $ref: "../../components/schemas/403.yaml" + +