From c93ab930c4b40c1bbdf5b8fa6d4dbbe926211600 Mon Sep 17 00:00:00 2001 From: Devadathan M B Date: Fri, 6 Dec 2024 00:31:03 +0530 Subject: [PATCH 1/5] feat: Add API spec for corporate_card_transactions/expenses/stats API --- .../schemas/corporate_card_transaction.yaml | 74 +++++++++++++++++++ src/spender/openapi.yaml | 3 +- ...rate_card_transactions@expenses@stats.yaml | 54 ++++++++++++++ 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 src/spender/paths/spender@corporate_card_transactions@expenses@stats.yaml diff --git a/src/components/schemas/corporate_card_transaction.yaml b/src/components/schemas/corporate_card_transaction.yaml index 1d9b96ccb..55728a56f 100644 --- a/src/components/schemas/corporate_card_transaction.yaml +++ b/src/components/schemas/corporate_card_transaction.yaml @@ -2457,3 +2457,77 @@ corporate_card_transaction_reassign_in: required: - id - user_id + +corporate_card_transactions_expenses_stats_in: + type: object + required: + - data + properties: + query_params: + type: string + description: | + Query param string for filtering corporate card transactions. Response data is grouped by card number + and expense state. + nullable: false + example: created_at=gt.2024-01-01 + +corporate_card_transactions_expenses_stats_out: + type: array + description: | + Array containing stats objects grouped by corporate card numbers and expense state. Returns an empty array if no + transactions are found matching the criteria. + items: + type: object + required: + - card_number + - bank_name + - state + - count + - total_amount + properties: + card_number: + type: string + nullable: false + description: | + Masked card number (showing first 6 and last 4 digits). + example: "411111******1111" + bank_name: + type: string + nullable: false + description: | + Name of the bank that issued the card. + example: "VISA_BANK" + state: + type: string + nullable: false + description: | + State of the corporate card transactions. + example: "COMPLETE" + count: + type: integer + nullable: false + description: | + Number of transactions for this card number. + example: 7 + total_amount: + type: number + nullable: false + description: | + Sum of transaction amounts for this card number. + example: 500.86 + example: + - state: "COMPLETE" + bank_name: "VISA_BANK" + card_number: "411111******1111" + count: 7 + total_amount: 500.86 + - state: "COMPLETE" + bank_name: "MASTERCARD_BANK" + card_number: "422222******2222" + count: 3 + total_amount: 3209.98 + - state: "DRAFT" + bank_name: "VISA_BANK" + card_number: "444444******4444" + count: 3 + total_amount: 336.81 \ No newline at end of file diff --git a/src/spender/openapi.yaml b/src/spender/openapi.yaml index 3204ac7b7..dc25a6d4a 100644 --- a/src/spender/openapi.yaml +++ b/src/spender/openapi.yaml @@ -178,7 +178,8 @@ paths: $ref: paths/spender@corporate_cards.yaml /spender/corporate_card_transactions: $ref: paths/spender@corporate_card_transactions.yaml - + /spender/corporate_card_transactions/expenses/stats: + $ref: paths/spender@corporate_card_transactions@expenses@stats.yaml /spender/corporate_card_transactions/mark_personal: $ref: paths/spender@corporate_card_transactions@mark_personal.yaml # /spender/corporate_card_transactions/mark_personal/bulk: diff --git a/src/spender/paths/spender@corporate_card_transactions@expenses@stats.yaml b/src/spender/paths/spender@corporate_card_transactions@expenses@stats.yaml new file mode 100644 index 000000000..7d6e7c526 --- /dev/null +++ b/src/spender/paths/spender@corporate_card_transactions@expenses@stats.yaml @@ -0,0 +1,54 @@ +post: + tags: + - Corporate Card Transactions + summary: Get corporate card transactions expenses stats + description: | + Get stats of corporate card transaction expenses grouped by card number and expense state. + operationId: corporate_card_transactions_expenses_stats + requestBody: + required: true + content: + application/json: + schema: + type: object + additionalProperties: False + required: + - data + properties: + data: + $ref: '../../components/schemas/corporate_card_transaction.yaml#/corporate_card_transactions_expenses_stats_in' + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + additionalProperties: False + properties: + data: + $ref: '../../components/schemas/corporate_card_transaction.yaml#/corporate_card_transactions_expenses_stats_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' \ No newline at end of file From fe94336863f9e408fc91cd9e39fac86074c0d39e Mon Sep 17 00:00:00 2001 From: Devadathan M B Date: Tue, 10 Dec 2024 15:56:57 +0530 Subject: [PATCH 2/5] fix failing tests --- src/components/schemas/corporate_card_transaction.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/schemas/corporate_card_transaction.yaml b/src/components/schemas/corporate_card_transaction.yaml index 55728a56f..5cae7c533 100644 --- a/src/components/schemas/corporate_card_transaction.yaml +++ b/src/components/schemas/corporate_card_transaction.yaml @@ -2460,8 +2460,6 @@ corporate_card_transaction_reassign_in: corporate_card_transactions_expenses_stats_in: type: object - required: - - data properties: query_params: type: string From c4b854d0d16f39c9fbe191dc235d4d1a66487cc7 Mon Sep 17 00:00:00 2001 From: Devadathan M B Date: Tue, 10 Dec 2024 16:23:45 +0530 Subject: [PATCH 3/5] Trigger workflow From 48839a1f327810779cb2833c99a594077e2b6d82 Mon Sep 17 00:00:00 2001 From: Devadathan M B Date: Tue, 10 Dec 2024 17:34:38 +0530 Subject: [PATCH 4/5] fix stuff --- src/components/schemas/corporate_card_transaction.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/schemas/corporate_card_transaction.yaml b/src/components/schemas/corporate_card_transaction.yaml index 5cae7c533..0007fff70 100644 --- a/src/components/schemas/corporate_card_transaction.yaml +++ b/src/components/schemas/corporate_card_transaction.yaml @@ -2464,8 +2464,7 @@ corporate_card_transactions_expenses_stats_in: query_params: type: string description: | - Query param string for filtering corporate card transactions. Response data is grouped by card number - and expense state. + Query param string for filtering corporate card transactions. nullable: false example: created_at=gt.2024-01-01 From b2eea4c44a4bc936e01eac6fcb75dba326c12ade Mon Sep 17 00:00:00 2001 From: Siva Date: Tue, 10 Dec 2024 12:05:17 +0000 Subject: [PATCH 5/5] Auto generate API docs --- reference/spender.yaml | 124 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/reference/spender.yaml b/reference/spender.yaml index 0e720866c..4f4fdf8a0 100644 --- a/reference/spender.yaml +++ b/reference/spender.yaml @@ -4878,6 +4878,75 @@ components: - last_user_matched_at - is_exported - metadata + corporate_card_transactions_expenses_stats_in: + type: object + properties: + query_params: + type: string + description: | + Query param string for filtering corporate card transactions. + nullable: false + example: created_at=gt.2024-01-01 + corporate_card_transactions_expenses_stats_out: + type: array + description: | + Array containing stats objects grouped by corporate card numbers and expense state. Returns an empty array if no + transactions are found matching the criteria. + items: + type: object + required: + - card_number + - bank_name + - state + - count + - total_amount + properties: + card_number: + type: string + nullable: false + description: | + Masked card number (showing first 6 and last 4 digits). + example: 411111******1111 + bank_name: + type: string + nullable: false + description: | + Name of the bank that issued the card. + example: VISA_BANK + state: + type: string + nullable: false + description: | + State of the corporate card transactions. + example: COMPLETE + count: + type: integer + nullable: false + description: | + Number of transactions for this card number. + example: 7 + total_amount: + type: number + nullable: false + description: | + Sum of transaction amounts for this card number. + example: 500.86 + example: + - state: COMPLETE + bank_name: VISA_BANK + card_number: 411111******1111 + count: 7 + total_amount: 500.86 + - state: COMPLETE + bank_name: MASTERCARD_BANK + card_number: 422222******2222 + count: 3 + total_amount: 3209.98 + - state: DRAFT + bank_name: VISA_BANK + card_number: 444444******4444 + count: 3 + total_amount: 336.81 corporate_card_transaction_id_in: type: object properties: @@ -11028,6 +11097,61 @@ paths: application/json: schema: $ref: '#/components/schemas/401' + /spender/corporate_card_transactions/expenses/stats: + post: + tags: + - Corporate Card Transactions + summary: Get corporate card transactions expenses stats + description: | + Get stats of corporate card transaction expenses grouped by card number and expense state. + operationId: corporate_card_transactions_expenses_stats + requestBody: + required: true + content: + application/json: + schema: + type: object + additionalProperties: false + required: + - data + properties: + data: + $ref: '#/components/schemas/corporate_card_transactions_expenses_stats_in' + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + additionalProperties: false + properties: + data: + $ref: '#/components/schemas/corporate_card_transactions_expenses_stats_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/corporate_card_transactions/mark_personal: post: tags: