Skip to content

Commit

Permalink
Feat: add stats endpoint for personal card transactions (#571)
Browse files Browse the repository at this point in the history
* Feat: add stats endpoint for personal card transactions

* Auto generate API docs

---------

Co-authored-by: Siva <siva@fylehq.com>
  • Loading branch information
tirth-bhagwat and snarayanank2 authored Nov 7, 2024
1 parent fcacc99 commit 5cb980a
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 1 deletion.
85 changes: 85 additions & 0 deletions reference/spender.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8548,6 +8548,36 @@ components:
properties:
id:
$ref: '#/components/schemas/id_string'
personal_card_transactions_stats_in:
properties:
query_params:
nullable: false
type: string
description: |
- This field contains the query param string similar to the query params passed in personal card transactions GET call for displaying transactions in the list view.
- Supported query params: personal_card_id, state, spent_at, created_at, updated_at, foreign_amount, amount, id
example: personal_card_id=eq.bacctW9DfNhwOt&state=eq.HIDDEN
personal_card_transactions_stats_out:
type: object
properties:
count:
type: integer
nullable: false
description: |
This field indicates the count of personal card transactions.
example: 1
debit_amount:
allOf:
- $ref: '#/components/schemas/amount'
description: |
This field indicates the sum of amount of the debit type personal card transactions.
example: 1239
credit_amount:
allOf:
- $ref: '#/components/schemas/amount'
description: |
This field indicates the sum of amount of the credit type personal card transactions.
example: 101
parameters:
q:
in: query
Expand Down Expand Up @@ -13360,3 +13390,58 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/401'
/spender/personal_card_transactions/stats:
post:
tags:
- Personal Card Transactions
summary: Personal Card Transaction Stats
description: |
Personal Card Transaction Stats
operationId: personal_card_transactions_stats
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: false
required:
- data
properties:
data:
$ref: '#/components/schemas/personal_card_transactions_stats_in'
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
additionalProperties: false
properties:
data:
$ref: '#/components/schemas/personal_card_transactions_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'
34 changes: 33 additions & 1 deletion src/components/schemas/personal_card_transaction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,36 @@ personal_card_transaction_hide_in:

personal_card_transaction_expense_suggestions:
type: object
additionalProperties: False
additionalProperties: False

personal_card_transactions_stats_in:
properties:
query_params:
nullable: false
type: string
description: |
- This field contains the query param string similar to the query params passed in personal card transactions GET call for displaying transactions in the list view.
- Supported query params: personal_card_id, state, spent_at, created_at, updated_at, foreign_amount, amount, id
example: personal_card_id=eq.bacctW9DfNhwOt&state=eq.HIDDEN

personal_card_transactions_stats_out:
type: object
properties:
count:
type: integer
nullable: false
description: |
This field indicates the count of personal card transactions.
example: 1
debit_amount:
allOf:
- $ref: "./fields.yaml#/amount"
description: |
This field indicates the sum of amount of the debit type personal card transactions.
example: 1239.0
credit_amount:
allOf:
- $ref: "./fields.yaml#/amount"
description: |
This field indicates the sum of amount of the credit type personal card transactions.
example: 101.0
2 changes: 2 additions & 0 deletions src/spender/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,5 @@ paths:
$ref: paths/spender@personal_card_transactions@hide@bulk.yaml
/spender/personal_card_transactions/expense_suggestion:
$ref: paths/spender@personal_card_transactions@expense_suggestion.yaml
/spender/personal_card_transactions/stats:
$ref: paths/spender@personal_card_transactions@stats.yaml
54 changes: 54 additions & 0 deletions src/spender/paths/spender@personal_card_transactions@stats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
post:
tags:
- Personal Card Transactions
summary: Personal Card Transaction Stats
description: |
Personal Card Transaction Stats
operationId: personal_card_transactions_stats
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: False
required:
- data
properties:
data:
$ref: '../../components/schemas/personal_card_transaction.yaml#/personal_card_transactions_stats_in'
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
additionalProperties: False
properties:
data:
$ref: '../../components/schemas/personal_card_transaction.yaml#/personal_card_transactions_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'

0 comments on commit 5cb980a

Please sign in to comment.