Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payouts endpoints #124

Merged
merged 18 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
0697a5a
Add line item and shipping cost aggregation for payout balance calcul…
jamalsoueidan Mar 31, 2024
84c0783
Refactor payout log schema to support multiple reference types
jamalsoueidan Mar 31, 2024
8eb2eae
Allow custom customerId in getOriginObject and refine createShipping …
jamalsoueidan Mar 31, 2024
d264589
Add indexing to current_quantity, fulfillable_quantity, and fulfillme…
jamalsoueidan Mar 31, 2024
9cc544b
Remove default_address from dummyDataBalance in payout fixtures
jamalsoueidan Mar 31, 2024
6b94bf7
Add tests and implementation for CustomerPayoutServiceCreate
jamalsoueidan Mar 31, 2024
b3bd380
Add shipping cost to payout calculation in CustomerPayoutServiceCreate
jamalsoueidan Mar 31, 2024
6936c1a
Add CustomerServicePayoutLogList functionality with tests
jamalsoueidan Mar 31, 2024
22a8942
Refactor payout aggregation and enhance logging for shipping and lin…
jamalsoueidan Mar 31, 2024
fdc45a7
Update PayoutLogZodSchema and createShipping function types
jamalsoueidan Mar 31, 2024
acaac93
Set up fake timers in tests and remove toDate from availability service
jamalsoueidan Mar 31, 2024
f36e72c
Add NotFoundError handling to CustomerPayoutServiceGet and implement…
jamalsoueidan Mar 31, 2024
f712470
Refactor pagination and rename 'total' to 'totalCount' in API responses
jamalsoueidan Mar 31, 2024
8b12e3c
Refactor pagination in CustomerPayoutServiceList to use page numbers …
jamalsoueidan Mar 31, 2024
9709847
Add Customer Payout API endpoints and update payout balance calculation
jamalsoueidan Mar 31, 2024
8a05818
Renamed payout log list to paginate and updated to support pagination…
jamalsoueidan Mar 31, 2024
a34d045
Refactor payout log pagination in customer module
jamalsoueidan Mar 31, 2024
a40a296
Add Customer Payout Log pagination and response schemas
jamalsoueidan Mar 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ components:
$ref: paths/customer/payout-account/_types/payout-account.yaml
CustomerPayoutAccountType:
$ref: paths/customer/payout-account/_types/payout-account-type.yaml
CustomerPayoutAccountCreateBody:
$ref: paths/customer/payout-account/create/body.yaml
CustomerPayoutAccountCreateResponse:
$ref: paths/customer/payout-account/create/response.yaml
CustomerPayoutAccountDestroy:
$ref: paths/customer/payout-account/destroy/destroy.yaml
CustomerPayoutAccountDestroyResponse:
$ref: paths/customer/payout-account/destroy/response.yaml
CustomerPayoutAccountGetResponse:
$ref: paths/customer/payout-account/get/response.yaml
CustomerPayoutMobilePay:
$ref: paths/customer/payout-account/_types/payout-account-mobile-pay.yaml
CustomerPayoutBankAccount:
Expand Down Expand Up @@ -160,6 +170,22 @@ components:
CustomerBlockedRangeResponse:
$ref: paths/customer/blocked/range/response.yaml

# Payout
CustomerPayout:
$ref: paths/customer/payout/_types/payout.yaml
CustomerPayoutBalancePayload:
$ref: paths/customer/payout/balance/payload.yaml
CustomerPayoutBalanceResponse:
$ref: paths/customer/payout/balance/response.yaml
CustomerPayoutGetResponse:
$ref: paths/customer/payout/get/response.yaml
CustomerPayoutPaginateResponse:
$ref: paths/customer/payout/paginate/response.yaml

# Payout Log
CustomerPayoutLogResponse:
$ref: paths/customer/payout-log/paginate/response.yaml

# Booking
CustomerBooking:
$ref: paths/customer/booking/_types/booking.yaml
Expand Down Expand Up @@ -347,6 +373,18 @@ paths:
/customer/{customerId}/orders/{orderId}:
$ref: "paths/customer/order/get/index.yaml"

# Customer Payout Management
/customer/{customerId}/payout:
$ref: "./paths/customer/payout/paginate/index.yaml"
/customer/{customerId}/payout/balance:
$ref: "./paths/customer/payout/balance/index.yaml"
/customer/{customerId}/payout/{payoutId}:
$ref: "./paths/customer/payout/get/index.yaml"

# Customer Payout Log Management
/customer/{customerId}/payout-log/{payoutId}:
$ref: "./paths/customer/payout-log/paginate/index.yaml"

# Customer Payout Account Management
/customer/{customerId}/payout-account:
$ref: "./paths/customer/payout-account/payout-account.yaml"
Expand Down
2 changes: 1 addition & 1 deletion openapi/paths/customer/payout-account/get/response.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ properties:
payload:
allOf:
- $ref: "../_types/payout-account.yaml"
nullable: true
nullable: true
required:
- success
- payload
53 changes: 53 additions & 0 deletions openapi/paths/customer/payout-log/paginate/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
get:
parameters:
- name: customerId
in: path
description: The ID of the customerId
required: true
schema:
type: string
- name: payoutId
in: path
description: The ID of the payoutId
required: true
schema:
type: string
- name: page
in: query
description: The page number
required: true
schema:
type: string
- name: sortOrder
in: query
description: The sort order either asc eller desc = default desc
schema:
type: string
- name: limit
in: query
description: The limit = default to 10
schema:
type: string
tags:
- CustomerPayoutLog
operationId: customerPayoutLogPaginate
summary: GET get all payout logs for specific payout using paginate
description: This endpoint get all payout logs for specific payout

responses:
"200":
description: Response with payouts payload
content:
application/json:
schema:
$ref: "./response.yaml"
"400":
$ref: "../../../../responses/bad.yaml"
"401":
$ref: "../../../../responses/unauthorized.yaml"
"403":
$ref: "../../../../responses/forbidden.yaml"
"404":
$ref: "../../../../responses/not-found.yaml"

security: []
14 changes: 14 additions & 0 deletions openapi/paths/customer/payout-log/paginate/response.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type: object
properties:
success:
type: boolean
example: true
payload:
type: array
items:
oneOf:
- $ref: "../../_types/order/line-item.yaml"
- $ref: ../../../shipping/_types/shipping.yaml
required:
- success
- payload
31 changes: 31 additions & 0 deletions openapi/paths/customer/payout/_types/payout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
type: object
properties:
customerId:
type: number
date:
type: string
format: date-time
amount:
type: number
format: double
currencyCode:
type: string
example: "DKK"
status:
type: string
enum:
- "Pending"
- "Processed"
- "Failed"
payoutType:
$ref: ../../payout-account/_types/payout-account-type.yaml
payoutDetails:
oneOf:
- $ref: ../../payout-account/_types/payout-account-mobile-pay.yaml
- $ref: ../../payout-account/_types/payout-account-bank-account.yaml
required:
- customerId
- date
- amount
- currencyCode
- status
31 changes: 31 additions & 0 deletions openapi/paths/customer/payout/balance/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
get:
parameters:
- name: customerId
in: path
description: The ID of the customerId
required: true
schema:
type: string
tags:
- CustomerPayout
operationId: customerPayoutBalance
summary: GET get payout balance
description: This endpoint get payout balance

responses:
"200":
description: Response with payout balance payload
content:
application/json:
schema:
$ref: "./response.yaml"
"400":
$ref: "../../../../responses/bad.yaml"
"401":
$ref: "../../../../responses/unauthorized.yaml"
"403":
$ref: "../../../../responses/forbidden.yaml"
"404":
$ref: "../../../../responses/not-found.yaml"

security: []
12 changes: 12 additions & 0 deletions openapi/paths/customer/payout/balance/payload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type: object
properties:
totalAmount:
type: number
totalLineItems:
type: number
totalShippingAmount:
type: number
required:
- totalAmount
- totalLineItems
- totalShippingAmount
10 changes: 10 additions & 0 deletions openapi/paths/customer/payout/balance/response.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type: object
properties:
success:
type: boolean
example: true
payload:
$ref: payload.yaml
required:
- success
- payload
37 changes: 37 additions & 0 deletions openapi/paths/customer/payout/get/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
get:
parameters:
- name: customerId
in: path
description: The ID of the customerId
required: true
schema:
type: string
- name: payoutId
in: path
description: The ID of the payoudId
required: true
schema:
type: string
tags:
- CustomerPayout
operationId: customerPayoutGet
summary: GET get payout
description: This endpoint get payout

responses:
"200":
description: Response with payout payload
content:
application/json:
schema:
$ref: "./response.yaml"
"400":
$ref: "../../../../responses/bad.yaml"
"401":
$ref: "../../../../responses/unauthorized.yaml"
"403":
$ref: "../../../../responses/forbidden.yaml"
"404":
$ref: "../../../../responses/not-found.yaml"

security: []
10 changes: 10 additions & 0 deletions openapi/paths/customer/payout/get/response.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type: object
properties:
success:
type: boolean
example: true
payload:
$ref: "../_types/payout.yaml"
required:
- success
- payload
47 changes: 47 additions & 0 deletions openapi/paths/customer/payout/paginate/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
get:
parameters:
- name: customerId
in: path
description: The ID of the customerId
required: true
schema:
type: string
- name: page
in: query
description: The page number
required: true
schema:
type: string
- name: sortOrder
in: query
description: The sort order either asc eller desc = default desc
schema:
type: string
- name: limit
in: query
description: The limit = default to 10
schema:
type: string
tags:
- CustomerPayout
operationId: customerPayoutPaginate
summary: GET get all payouts using paginate
description: This endpoint get all payouts

responses:
"200":
description: Response with payouts payload
content:
application/json:
schema:
$ref: "./response.yaml"
"400":
$ref: "../../../../responses/bad.yaml"
"401":
$ref: "../../../../responses/unauthorized.yaml"
"403":
$ref: "../../../../responses/forbidden.yaml"
"404":
$ref: "../../../../responses/not-found.yaml"

security: []
12 changes: 12 additions & 0 deletions openapi/paths/customer/payout/paginate/response.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type: object
properties:
success:
type: boolean
example: true
payload:
type: array
items:
$ref: ../_types/payout.yaml
required:
- success
- payload
2 changes: 1 addition & 1 deletion openapi/paths/user/list/response.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ properties:
type: array
items:
$ref: "../_types/user.yaml"
total:
totalCount:
type: number
required:
- results
Expand Down
12 changes: 12 additions & 0 deletions src/functions/customer-payout-log.function.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import "module-alias/register";

import { app } from "@azure/functions";

import { CustomerPayoutLogControllerPaginate } from "./customer/controllers/payout-log/paginate";

app.http("customerPayoutLogPaginate", {
methods: ["GET"],
authLevel: "anonymous",
route: "customer/{customerId?}/payout-log/{payoutId}",
handler: CustomerPayoutLogControllerPaginate,
});
28 changes: 28 additions & 0 deletions src/functions/customer-payout.functions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import "module-alias/register";

import { app } from "@azure/functions";

import { CustomerPayoutControllerBalance } from "./customer/controllers/payout/balance";
import { CustomerPayoutControllerGet } from "./customer/controllers/payout/get";
import { CustomerPayoutControllerPaginate } from "./customer/controllers/payout/paginate";

app.http("customerPayoutGet", {
methods: ["GET"],
authLevel: "anonymous",
route: "customer/{customerId?}/payout/{payoutId?}",
handler: CustomerPayoutControllerGet,
});

app.http("customerPayoutBalance", {
methods: ["GET"],
authLevel: "anonymous",
route: "customer/{customerId?}/payout/balance",
handler: CustomerPayoutControllerBalance,
});

app.http("customerPayoutPaginate", {
methods: ["GET"],
authLevel: "anonymous",
route: "customer/{customerId?}/payout",
handler: CustomerPayoutControllerPaginate,
});
Loading
Loading