diff --git a/app/components/Hero.tsx b/app/components/Hero.tsx index 9e98d80b..e75f0e59 100644 --- a/app/components/Hero.tsx +++ b/app/components/Hero.tsx @@ -66,7 +66,7 @@ export function Hero({ - }> + }> {({payload}) => } diff --git a/app/lib/api/bookingShopifyApi.ts b/app/lib/api/bookingShopifyApi.ts index 5a19efa6..ee57f9d3 100644 --- a/app/lib/api/bookingShopifyApi.ts +++ b/app/lib/api/bookingShopifyApi.ts @@ -28,10 +28,17 @@ import type { CustomerLocationUpdateBody, CustomerLocationUpdateResponse, CustomerOrderGetResponse, - CustomerPayoutAccountCreate200, CustomerPayoutAccountCreateBody, - CustomerPayoutAccountDestroy200, - CustomerPayoutAccountGet200, + CustomerPayoutAccountCreateResponse, + CustomerPayoutAccountDestroyResponse, + CustomerPayoutAccountGetResponse, + CustomerPayoutBalanceResponse, + CustomerPayoutCreateResponse, + CustomerPayoutGetResponse, + CustomerPayoutLogPaginateParams, + CustomerPayoutLogResponse, + CustomerPayoutPaginateParams, + CustomerPayoutPaginateResponse, CustomerProductCreateVariantBody, CustomerProductCreateVariantResponse, CustomerProductDestroyResponse, @@ -315,6 +322,70 @@ export const getBookingShopifyApi = () => { }); }; + /** + * This endpoint get all payouts + * @summary GET get all payouts using paginate + */ + const customerPayoutPaginate = ( + customerId: string, + params: CustomerPayoutPaginateParams, + ) => { + return queryClient({ + url: `/customer/${customerId}/payouts/paginate`, + method: 'GET', + params, + }); + }; + + /** + * This endpoint get payout balance + * @summary GET get payout balance + */ + const customerPayoutBalance = (customerId: string) => { + return queryClient({ + url: `/customer/${customerId}/payouts/balance`, + method: 'GET', + }); + }; + + /** + * This endpoint get payout + * @summary GET get payout + */ + const customerPayoutGet = (customerId: string, payoutId: string) => { + return queryClient({ + url: `/customer/${customerId}/payout/${payoutId}`, + method: 'GET', + }); + }; + + /** + * This endpoint create payout + * @summary POST Create payout + */ + const customerPayoutCreate = (customerId: string) => { + return queryClient({ + url: `/customer/${customerId}/payout/create`, + method: 'POST', + }); + }; + + /** + * This endpoint get all payout logs for specific payout + * @summary GET get all payout logs for specific payout using paginate + */ + const customerPayoutLogPaginate = ( + customerId: string, + payoutId: string, + params: CustomerPayoutLogPaginateParams, + ) => { + return queryClient({ + url: `/customer/${customerId}/payout-logs/${payoutId}/paginate`, + method: 'GET', + params, + }); + }; + /** * This endpoint create new payout account * @summary POST Create payout account @@ -323,7 +394,7 @@ export const getBookingShopifyApi = () => { customerId: string, customerPayoutAccountCreateBody: BodyType, ) => { - return queryClient({ + return queryClient({ url: `/customer/${customerId}/payout-account`, method: 'POST', headers: {'Content-Type': 'application/json'}, @@ -336,7 +407,7 @@ export const getBookingShopifyApi = () => { * @summary GET get payout account */ const customerPayoutAccountGet = (customerId: string) => { - return queryClient({ + return queryClient({ url: `/customer/${customerId}/payout-account`, method: 'GET', }); @@ -347,7 +418,7 @@ export const getBookingShopifyApi = () => { * @summary DEL destroy payout account */ const customerPayoutAccountDestroy = (customerId: string) => { - return queryClient({ + return queryClient({ url: `/customer/${customerId}/payout-account`, method: 'DELETE', }); @@ -899,6 +970,11 @@ export const getBookingShopifyApi = () => { customerLocationCreate, customerLocationList, customerOrderGet, + customerPayoutPaginate, + customerPayoutBalance, + customerPayoutGet, + customerPayoutCreate, + customerPayoutLogPaginate, customerPayoutAccountCreate, customerPayoutAccountGet, customerPayoutAccountDestroy, @@ -1031,6 +1107,35 @@ export type CustomerOrderGetResult = NonNullable< ReturnType['customerOrderGet']> > >; +export type CustomerPayoutPaginateResult = NonNullable< + Awaited< + ReturnType< + ReturnType['customerPayoutPaginate'] + > + > +>; +export type CustomerPayoutBalanceResult = NonNullable< + Awaited< + ReturnType['customerPayoutBalance']> + > +>; +export type CustomerPayoutGetResult = NonNullable< + Awaited< + ReturnType['customerPayoutGet']> + > +>; +export type CustomerPayoutCreateResult = NonNullable< + Awaited< + ReturnType['customerPayoutCreate']> + > +>; +export type CustomerPayoutLogPaginateResult = NonNullable< + Awaited< + ReturnType< + ReturnType['customerPayoutLogPaginate'] + > + > +>; export type CustomerPayoutAccountCreateResult = NonNullable< Awaited< ReturnType< diff --git a/app/lib/api/model/customerPayout.ts b/app/lib/api/model/customerPayout.ts new file mode 100644 index 00000000..8209c47d --- /dev/null +++ b/app/lib/api/model/customerPayout.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ +import type {CustomerPayoutPayoutDetails} from './customerPayoutPayoutDetails'; +import type {CustomerPayoutAccountType} from './customerPayoutAccountType'; +import type {CustomerPayoutStatus} from './customerPayoutStatus'; + +export interface CustomerPayout { + _id?: string; + amount: number; + currencyCode: string; + date: string; + payoutDetails?: CustomerPayoutPayoutDetails; + payoutType?: CustomerPayoutAccountType; + status: CustomerPayoutStatus; +} diff --git a/app/lib/api/model/customerPayoutAccountCreateBody.ts b/app/lib/api/model/customerPayoutAccountCreateBody.ts index 6c16e0c8..cb3f6c1a 100644 --- a/app/lib/api/model/customerPayoutAccountCreateBody.ts +++ b/app/lib/api/model/customerPayoutAccountCreateBody.ts @@ -7,7 +7,7 @@ import type {CustomerPayoutAccountCreateBodyPayoutDetails} from './customerPayoutAccountCreateBodyPayoutDetails'; import type {CustomerPayoutAccountType} from './customerPayoutAccountType'; -export type CustomerPayoutAccountCreateBody = { +export interface CustomerPayoutAccountCreateBody { payoutDetails: CustomerPayoutAccountCreateBodyPayoutDetails; payoutType: CustomerPayoutAccountType; -}; +} diff --git a/app/lib/api/model/customerPayoutAccountGet200Payload.ts b/app/lib/api/model/customerPayoutAccountCreateResponse.ts similarity index 63% rename from app/lib/api/model/customerPayoutAccountGet200Payload.ts rename to app/lib/api/model/customerPayoutAccountCreateResponse.ts index ded55c9f..5c3126b9 100644 --- a/app/lib/api/model/customerPayoutAccountGet200Payload.ts +++ b/app/lib/api/model/customerPayoutAccountCreateResponse.ts @@ -6,4 +6,7 @@ */ import type {CustomerPayoutAccount} from './customerPayoutAccount'; -export type CustomerPayoutAccountGet200Payload = CustomerPayoutAccount | null; +export interface CustomerPayoutAccountCreateResponse { + payload: CustomerPayoutAccount; + success: boolean; +} diff --git a/app/lib/api/model/customerPayoutAccountDestroy200Payload.ts b/app/lib/api/model/customerPayoutAccountDestroy.ts similarity index 74% rename from app/lib/api/model/customerPayoutAccountDestroy200Payload.ts rename to app/lib/api/model/customerPayoutAccountDestroy.ts index 4efbb45a..66e12409 100644 --- a/app/lib/api/model/customerPayoutAccountDestroy200Payload.ts +++ b/app/lib/api/model/customerPayoutAccountDestroy.ts @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type CustomerPayoutAccountDestroy200Payload = { +export interface CustomerPayoutAccountDestroy { acknowledged: boolean; deletedCount: number; -}; +} diff --git a/app/lib/api/model/customerPayoutAccountDestroy200.ts b/app/lib/api/model/customerPayoutAccountDestroy200.ts deleted file mode 100644 index 26460384..00000000 --- a/app/lib/api/model/customerPayoutAccountDestroy200.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v6.25.0 🍺 - * Do not edit manually. - * Booking Shopify Api - * OpenAPI spec version: 1.0.0 - */ -import type {CustomerPayoutAccountDestroy200Payload} from './customerPayoutAccountDestroy200Payload'; - -export type CustomerPayoutAccountDestroy200 = { - payload: CustomerPayoutAccountDestroy200Payload; - success: boolean; -}; diff --git a/app/lib/api/model/customerPayoutAccountDestroyResponse.ts b/app/lib/api/model/customerPayoutAccountDestroyResponse.ts new file mode 100644 index 00000000..7b7727d2 --- /dev/null +++ b/app/lib/api/model/customerPayoutAccountDestroyResponse.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ +import type {CustomerPayoutAccountDestroy} from './customerPayoutAccountDestroy'; + +export interface CustomerPayoutAccountDestroyResponse { + payload: CustomerPayoutAccountDestroy; + success: boolean; +} diff --git a/app/lib/api/model/customerPayoutAccountGet200.ts b/app/lib/api/model/customerPayoutAccountGet200.ts deleted file mode 100644 index ba8b23ac..00000000 --- a/app/lib/api/model/customerPayoutAccountGet200.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v6.25.0 🍺 - * Do not edit manually. - * Booking Shopify Api - * OpenAPI spec version: 1.0.0 - */ -import type {CustomerPayoutAccountGet200Payload} from './customerPayoutAccountGet200Payload'; - -export type CustomerPayoutAccountGet200 = { - payload: CustomerPayoutAccountGet200Payload; - success: boolean; -}; diff --git a/app/lib/api/model/customerPayoutAccountCreate200.ts b/app/lib/api/model/customerPayoutAccountGetResponse.ts similarity index 81% rename from app/lib/api/model/customerPayoutAccountCreate200.ts rename to app/lib/api/model/customerPayoutAccountGetResponse.ts index e530a570..64e45906 100644 --- a/app/lib/api/model/customerPayoutAccountCreate200.ts +++ b/app/lib/api/model/customerPayoutAccountGetResponse.ts @@ -6,7 +6,7 @@ */ import type {CustomerPayoutAccount} from './customerPayoutAccount'; -export type CustomerPayoutAccountCreate200 = { +export interface CustomerPayoutAccountGetResponse { payload: CustomerPayoutAccount; success: boolean; -}; +} diff --git a/app/lib/api/model/customerPayoutBalancePayload.ts b/app/lib/api/model/customerPayoutBalancePayload.ts new file mode 100644 index 00000000..553d95c0 --- /dev/null +++ b/app/lib/api/model/customerPayoutBalancePayload.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ + +export interface CustomerPayoutBalancePayload { + totalAmount: number; + totalLineItems: number; + totalShippingAmount: number; +} diff --git a/app/lib/api/model/customerPayoutBalanceResponse.ts b/app/lib/api/model/customerPayoutBalanceResponse.ts new file mode 100644 index 00000000..8d435157 --- /dev/null +++ b/app/lib/api/model/customerPayoutBalanceResponse.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ +import type {CustomerPayoutBalancePayload} from './customerPayoutBalancePayload'; + +export interface CustomerPayoutBalanceResponse { + payload: CustomerPayoutBalancePayload; + success: boolean; +} diff --git a/app/lib/api/model/customerPayoutCreateResponse.ts b/app/lib/api/model/customerPayoutCreateResponse.ts new file mode 100644 index 00000000..8057050a --- /dev/null +++ b/app/lib/api/model/customerPayoutCreateResponse.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ +import type {CustomerPayout} from './customerPayout'; + +export interface CustomerPayoutCreateResponse { + payload: CustomerPayout; + success: boolean; +} diff --git a/app/lib/api/model/customerPayoutGetResponse.ts b/app/lib/api/model/customerPayoutGetResponse.ts new file mode 100644 index 00000000..2cc6567e --- /dev/null +++ b/app/lib/api/model/customerPayoutGetResponse.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ +import type {CustomerPayout} from './customerPayout'; + +export interface CustomerPayoutGetResponse { + payload: CustomerPayout; + success: boolean; +} diff --git a/app/lib/api/model/customerPayoutLog.ts b/app/lib/api/model/customerPayoutLog.ts new file mode 100644 index 00000000..ec8d68aa --- /dev/null +++ b/app/lib/api/model/customerPayoutLog.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ +import type {CustomerPayoutLogReferenceDocument} from './customerPayoutLogReferenceDocument'; +import type {CustomerPayoutLogType} from './customerPayoutLogType'; + +export interface CustomerPayoutLog { + _id: string; + createdAt: string; + customerId: number; + orderCreatedAt: string; + orderId: number; + payout: string; + referenceDocument: CustomerPayoutLogReferenceDocument; + referenceId: string; + referenceType: CustomerPayoutLogType; +} diff --git a/app/lib/api/model/customerPayoutLogPaginateParams.ts b/app/lib/api/model/customerPayoutLogPaginateParams.ts new file mode 100644 index 00000000..74d888f3 --- /dev/null +++ b/app/lib/api/model/customerPayoutLogPaginateParams.ts @@ -0,0 +1,21 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ + +export type CustomerPayoutLogPaginateParams = { + /** + * The page number + */ + page: string; + /** + * The sort order either asc eller desc = default desc + */ + sortOrder?: string; + /** + * The limit = default to 10 + */ + limit?: string; +}; diff --git a/app/lib/api/model/customerPayoutLogPayload.ts b/app/lib/api/model/customerPayoutLogPayload.ts new file mode 100644 index 00000000..14c75a77 --- /dev/null +++ b/app/lib/api/model/customerPayoutLogPayload.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ +import type {CustomerPayoutLog} from './customerPayoutLog'; + +export interface CustomerPayoutLogPayload { + currentPage: number; + hasNextPage: boolean; + results: CustomerPayoutLog[]; + totalCount: number; + totalPages: number; +} diff --git a/app/lib/api/model/customerPayoutLogReferenceDocument.ts b/app/lib/api/model/customerPayoutLogReferenceDocument.ts new file mode 100644 index 00000000..cc592416 --- /dev/null +++ b/app/lib/api/model/customerPayoutLogReferenceDocument.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ +import type {CustomeBaserOrderLineItem} from './customeBaserOrderLineItem'; +import type {Shipping} from './shipping'; + +export type CustomerPayoutLogReferenceDocument = + | CustomeBaserOrderLineItem + | Shipping; diff --git a/app/lib/api/model/customerPayoutLogResponse.ts b/app/lib/api/model/customerPayoutLogResponse.ts new file mode 100644 index 00000000..3e06ec35 --- /dev/null +++ b/app/lib/api/model/customerPayoutLogResponse.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ +import type {CustomerPayoutLogPayload} from './customerPayoutLogPayload'; + +export interface CustomerPayoutLogResponse { + payload: CustomerPayoutLogPayload; + success: boolean; +} diff --git a/app/lib/api/model/customerPayoutLogType.ts b/app/lib/api/model/customerPayoutLogType.ts new file mode 100644 index 00000000..3a041a4e --- /dev/null +++ b/app/lib/api/model/customerPayoutLogType.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ + +export type CustomerPayoutLogType = + (typeof CustomerPayoutLogType)[keyof typeof CustomerPayoutLogType]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const CustomerPayoutLogType = { + Shipping: 'Shipping', + LineItem: 'LineItem', +} as const; diff --git a/app/lib/api/model/customerPayoutPaginateParams.ts b/app/lib/api/model/customerPayoutPaginateParams.ts new file mode 100644 index 00000000..24500e71 --- /dev/null +++ b/app/lib/api/model/customerPayoutPaginateParams.ts @@ -0,0 +1,21 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ + +export type CustomerPayoutPaginateParams = { + /** + * The page number + */ + page: string; + /** + * The sort order either asc eller desc = default desc + */ + sortOrder?: string; + /** + * The limit = default to 10 + */ + limit?: string; +}; diff --git a/app/lib/api/model/customerPayoutPaginatePayload.ts b/app/lib/api/model/customerPayoutPaginatePayload.ts new file mode 100644 index 00000000..7e7db353 --- /dev/null +++ b/app/lib/api/model/customerPayoutPaginatePayload.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ +import type {CustomerPayout} from './customerPayout'; + +export interface CustomerPayoutPaginatePayload { + currentPage: number; + hasNextPage: boolean; + results: CustomerPayout[]; + totalCount: number; + totalPages: number; +} diff --git a/app/lib/api/model/customerPayoutPaginateResponse.ts b/app/lib/api/model/customerPayoutPaginateResponse.ts new file mode 100644 index 00000000..6261a79f --- /dev/null +++ b/app/lib/api/model/customerPayoutPaginateResponse.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ +import type {CustomerPayoutPaginatePayload} from './customerPayoutPaginatePayload'; + +export interface CustomerPayoutPaginateResponse { + payload: CustomerPayoutPaginatePayload; + success: boolean; +} diff --git a/app/lib/api/model/customerPayoutPayoutDetails.ts b/app/lib/api/model/customerPayoutPayoutDetails.ts new file mode 100644 index 00000000..23375177 --- /dev/null +++ b/app/lib/api/model/customerPayoutPayoutDetails.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ +import type {CustomerPayoutMobilePay} from './customerPayoutMobilePay'; +import type {CustomerPayoutBankAccount} from './customerPayoutBankAccount'; + +export type CustomerPayoutPayoutDetails = + | CustomerPayoutMobilePay + | CustomerPayoutBankAccount; diff --git a/app/lib/api/model/customerPayoutStatus.ts b/app/lib/api/model/customerPayoutStatus.ts new file mode 100644 index 00000000..8d85d3e8 --- /dev/null +++ b/app/lib/api/model/customerPayoutStatus.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v6.25.0 🍺 + * Do not edit manually. + * Booking Shopify Api + * OpenAPI spec version: 1.0.0 + */ + +export type CustomerPayoutStatus = + (typeof CustomerPayoutStatus)[keyof typeof CustomerPayoutStatus]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const CustomerPayoutStatus = { + Pending: 'Pending', + Processed: 'Processed', + Failed: 'Failed', +} as const; diff --git a/app/lib/api/model/index.ts b/app/lib/api/model/index.ts index 979763ac..578ce986 100644 --- a/app/lib/api/model/index.ts +++ b/app/lib/api/model/index.ts @@ -76,20 +76,35 @@ export * from './customerOrderAllOf'; export * from './customerOrderGetResponse'; export * from './customerOrderLineItem'; export * from './customerOrderLineItemAllOf'; +export * from './customerPayout'; export * from './customerPayoutAccount'; -export * from './customerPayoutAccountCreate200'; export * from './customerPayoutAccountCreateBody'; export * from './customerPayoutAccountCreateBodyPayoutDetails'; +export * from './customerPayoutAccountCreateResponse'; export * from './customerPayoutAccountCustomerId'; -export * from './customerPayoutAccountDestroy200'; -export * from './customerPayoutAccountDestroy200Payload'; -export * from './customerPayoutAccountGet200'; -export * from './customerPayoutAccountGet200Payload'; +export * from './customerPayoutAccountDestroy'; +export * from './customerPayoutAccountDestroyResponse'; +export * from './customerPayoutAccountGetResponse'; export * from './customerPayoutAccountPayoutDetails'; export * from './customerPayoutAccountType'; +export * from './customerPayoutBalancePayload'; +export * from './customerPayoutBalanceResponse'; export * from './customerPayoutBankAccount'; +export * from './customerPayoutCreateResponse'; +export * from './customerPayoutGetResponse'; +export * from './customerPayoutLog'; +export * from './customerPayoutLogPaginateParams'; +export * from './customerPayoutLogPayload'; +export * from './customerPayoutLogReferenceDocument'; +export * from './customerPayoutLogResponse'; +export * from './customerPayoutLogType'; export * from './customerPayoutMobilePay'; export * from './customerPayoutMobilePayPhoneNumber'; +export * from './customerPayoutPaginateParams'; +export * from './customerPayoutPaginatePayload'; +export * from './customerPayoutPaginateResponse'; +export * from './customerPayoutPayoutDetails'; +export * from './customerPayoutStatus'; export * from './customerProduct'; export * from './customerProductAllOf'; export * from './customerProductBase'; diff --git a/app/lib/api/model/shippingAllOf.ts b/app/lib/api/model/shippingAllOf.ts index 2a40e6d7..a8c0aad1 100644 --- a/app/lib/api/model/shippingAllOf.ts +++ b/app/lib/api/model/shippingAllOf.ts @@ -8,6 +8,8 @@ import type {CustomerLocation} from './customerLocation'; export type ShippingAllOf = { _id: string; + created_at: string; location: string; origin: CustomerLocation; + updated_at: string; }; diff --git a/app/lib/api/model/usersListResponsePayload.ts b/app/lib/api/model/usersListResponsePayload.ts index 405442cd..e9ece8c5 100644 --- a/app/lib/api/model/usersListResponsePayload.ts +++ b/app/lib/api/model/usersListResponsePayload.ts @@ -9,5 +9,5 @@ import type {User} from './user'; export type UsersListResponsePayload = { nextCursor?: string; results: User[]; - total: number; + totalCount?: number; }; diff --git a/app/lib/zod/bookingShopifyApi.ts b/app/lib/zod/bookingShopifyApi.ts index 73ba64c1..7b2b539c 100644 --- a/app/lib/zod/bookingShopifyApi.ts +++ b/app/lib/zod/bookingShopifyApi.ts @@ -619,6 +619,8 @@ export const customerBookingGetByGroupResponse = zod.object({ startFee: zod.number(), }), ), + created_at: zod.string(), + updated_at: zod.string(), }), ) .optional(), @@ -1058,6 +1060,8 @@ export const customerBookingRangeResponse = zod.object({ startFee: zod.number(), }), ), + created_at: zod.string(), + updated_at: zod.string(), }), ) .optional(), @@ -1829,6 +1833,8 @@ export const customerOrderGetResponse = zod.object({ startFee: zod.number(), }), ), + created_at: zod.string(), + updated_at: zod.string(), }), ) .optional(), @@ -1839,6 +1845,279 @@ export const customerOrderGetResponse = zod.object({ ), }); +/** + * This endpoint get all payouts + * @summary GET get all payouts using paginate + */ +export const customerPayoutPaginateParams = zod.object({ + customerId: zod.string(), +}); + +export const customerPayoutPaginateQueryParams = zod.object({ + page: zod.string(), + sortOrder: zod.string().optional(), + limit: zod.string().optional(), +}); + +export const customerPayoutPaginateResponse = zod.object({ + success: zod.boolean(), + payload: zod.object({ + results: zod.array( + zod.object({ + _id: zod.string().optional(), + date: zod.string(), + amount: zod.number(), + currencyCode: zod.string(), + status: zod.enum(['Pending', 'Processed', 'Failed']), + payoutType: zod.enum(['MOBILE_PAY', 'BANK_ACCOUNT']).optional(), + payoutDetails: zod + .object({ + phoneNumber: zod.string().or(zod.number()), + }) + .or( + zod.object({ + bankName: zod.string(), + regNum: zod.number(), + accountNum: zod.number(), + }), + ) + .optional(), + }), + ), + currentPage: zod.number(), + totalPages: zod.number(), + hasNextPage: zod.boolean(), + totalCount: zod.number(), + }), +}); + +/** + * This endpoint get payout balance + * @summary GET get payout balance + */ +export const customerPayoutBalanceParams = zod.object({ + customerId: zod.string(), +}); + +export const customerPayoutBalanceResponse = zod.object({ + success: zod.boolean(), + payload: zod.object({ + totalAmount: zod.number(), + totalLineItems: zod.number(), + totalShippingAmount: zod.number(), + }), +}); + +/** + * This endpoint get payout + * @summary GET get payout + */ +export const customerPayoutGetParams = zod.object({ + customerId: zod.string(), + payoutId: zod.string(), +}); + +export const customerPayoutGetResponse = zod.object({ + success: zod.boolean(), + payload: zod.object({ + _id: zod.string().optional(), + date: zod.string(), + amount: zod.number(), + currencyCode: zod.string(), + status: zod.enum(['Pending', 'Processed', 'Failed']), + payoutType: zod.enum(['MOBILE_PAY', 'BANK_ACCOUNT']).optional(), + payoutDetails: zod + .object({ + phoneNumber: zod.string().or(zod.number()), + }) + .or( + zod.object({ + bankName: zod.string(), + regNum: zod.number(), + accountNum: zod.number(), + }), + ) + .optional(), + }), +}); + +/** + * This endpoint create payout + * @summary POST Create payout + */ +export const customerPayoutCreateParams = zod.object({ + customerId: zod.string(), +}); + +export const customerPayoutCreateResponse = zod.object({ + success: zod.boolean(), + payload: zod.object({ + _id: zod.string().optional(), + date: zod.string(), + amount: zod.number(), + currencyCode: zod.string(), + status: zod.enum(['Pending', 'Processed', 'Failed']), + payoutType: zod.enum(['MOBILE_PAY', 'BANK_ACCOUNT']).optional(), + payoutDetails: zod + .object({ + phoneNumber: zod.string().or(zod.number()), + }) + .or( + zod.object({ + bankName: zod.string(), + regNum: zod.number(), + accountNum: zod.number(), + }), + ) + .optional(), + }), +}); + +/** + * This endpoint get all payout logs for specific payout + * @summary GET get all payout logs for specific payout using paginate + */ +export const customerPayoutLogPaginateParams = zod.object({ + customerId: zod.string(), + payoutId: zod.string(), +}); + +export const customerPayoutLogPaginateQueryParams = zod.object({ + page: zod.string(), + sortOrder: zod.string().optional(), + limit: zod.string().optional(), +}); + +export const customerPayoutLogPaginateResponse = zod.object({ + success: zod.boolean(), + payload: zod.object({ + results: zod.array( + zod.object({ + _id: zod.string(), + customerId: zod.number(), + orderId: zod.number(), + orderCreatedAt: zod.string(), + referenceType: zod.enum(['Shipping', 'LineItem']), + referenceId: zod.string(), + payout: zod.string(), + createdAt: zod.string(), + referenceDocument: zod + .object({ + id: zod.number(), + admin_graphql_api_id: zod.string(), + fulfillable_quantity: zod.number(), + fulfillment_service: zod.string(), + fulfillment_status: zod.string().optional(), + gift_card: zod.boolean(), + grams: zod.number(), + name: zod.string(), + price: zod.string(), + price_set: zod.object({ + shop_money: zod.object({ + amount: zod.string(), + currency_code: zod.string(), + }), + presentment_money: zod.object({ + amount: zod.string(), + currency_code: zod.string(), + }), + }), + product_exists: zod.boolean(), + product_id: zod.number(), + properties: zod.object({ + customer_id: zod.number(), + from: zod.string(), + to: zod.string(), + locationId: zod.string(), + groupId: zod.string(), + shippingId: zod.string().optional(), + }), + quantity: zod.number(), + requires_shipping: zod.boolean(), + sku: zod.string().optional(), + taxable: zod.boolean(), + title: zod.string(), + total_discount: zod.string(), + total_discount_set: zod.object({ + shop_money: zod.object({ + amount: zod.string(), + currency_code: zod.string(), + }), + presentment_money: zod.object({ + amount: zod.string(), + currency_code: zod.string(), + }), + }), + variant_id: zod.number(), + variant_inventory_management: zod.string().optional(), + variant_title: zod.string().optional(), + vendor: zod.string().optional(), + }) + .or( + zod + .object({ + duration: zod.object({ + text: zod.string(), + value: zod.number(), + }), + distance: zod.object({ + text: zod.string(), + value: zod.number(), + }), + }) + .and( + zod.object({ + destination: zod.object({ + name: zod.string(), + fullAddress: zod.string(), + }), + cost: zod.object({ + currency: zod.string(), + value: zod.number(), + }), + }), + ) + .and( + zod.object({ + _id: zod.string(), + location: zod.string(), + origin: zod + .object({ + locationType: zod.enum(['origin', 'destination']), + customerId: zod.string(), + originType: zod.enum(['home', 'commercial']), + name: zod.string(), + fullAddress: zod.string(), + }) + .and( + zod.object({ + _id: zod.string(), + geoLocation: zod.object({ + type: zod.enum(['Point']), + coordinates: zod.array(zod.number()), + }), + distanceForFree: zod.number(), + distanceHourlyRate: zod.number(), + fixedRatePerKm: zod.number(), + minDriveDistance: zod.number(), + maxDriveDistance: zod.number(), + startFee: zod.number(), + }), + ), + created_at: zod.string(), + updated_at: zod.string(), + }), + ), + ), + }), + ), + currentPage: zod.number(), + totalPages: zod.number(), + hasNextPage: zod.boolean(), + totalCount: zod.number(), + }), +}); + /** * This endpoint create new payout account * @summary POST Create payout account @@ -1891,23 +2170,21 @@ export const customerPayoutAccountGetParams = zod.object({ export const customerPayoutAccountGetResponse = zod.object({ success: zod.boolean(), - payload: zod - .object({ - customerId: zod.string().or(zod.number()), - payoutType: zod.enum(['MOBILE_PAY', 'BANK_ACCOUNT']), - payoutDetails: zod - .object({ - phoneNumber: zod.string().or(zod.number()), - }) - .or( - zod.object({ - bankName: zod.string(), - regNum: zod.number(), - accountNum: zod.number(), - }), - ), - }) - .nullable(), + payload: zod.object({ + customerId: zod.string().or(zod.number()), + payoutType: zod.enum(['MOBILE_PAY', 'BANK_ACCOUNT']), + payoutDetails: zod + .object({ + phoneNumber: zod.string().or(zod.number()), + }) + .or( + zod.object({ + bankName: zod.string(), + regNum: zod.number(), + accountNum: zod.number(), + }), + ), + }), }); /** @@ -2876,6 +3153,8 @@ export const shippingCreateResponse = zod.object({ startFee: zod.number(), }), ), + created_at: zod.string(), + updated_at: zod.string(), }), ), }); @@ -2944,6 +3223,8 @@ export const shippingCalculateResponse = zod.object({ startFee: zod.number(), }), ), + created_at: zod.string(), + updated_at: zod.string(), }), ), }); @@ -3008,6 +3289,8 @@ export const shippingGetResponse = zod.object({ startFee: zod.number(), }), ), + created_at: zod.string(), + updated_at: zod.string(), }), ), }); @@ -3082,6 +3365,8 @@ export const userAvailabilityGenerateResponse = zod.object({ startFee: zod.number(), }), ), + created_at: zod.string(), + updated_at: zod.string(), }), ) .optional(), @@ -3183,6 +3468,8 @@ export const userAvailabilityGetResponse = zod.object({ startFee: zod.number(), }), ), + created_at: zod.string(), + updated_at: zod.string(), }), ) .optional(), @@ -3878,7 +4165,7 @@ export const usersListResponse = zod.object({ }), }), ), - total: zod.number(), + totalCount: zod.number().optional(), }), }); diff --git a/app/routes/($locale).account.payouts.$id.tsx b/app/routes/($locale).account.payouts.$id.tsx new file mode 100644 index 00000000..9c58829f --- /dev/null +++ b/app/routes/($locale).account.payouts.$id.tsx @@ -0,0 +1,174 @@ +import {Card, Stack, Table, Text} from '@mantine/core'; +import {defer, type LoaderFunctionArgs} from '@shopify/remix-oxygen'; +import {getCustomer} from '~/lib/get-customer'; + +import {Await, useLoaderData} from '@remix-run/react'; + +import {format} from 'date-fns'; +import {da} from 'date-fns/locale'; +import {Suspense} from 'react'; +import {AccountContent} from '~/components/account/AccountContent'; +import {AccountTitle} from '~/components/account/AccountTitle'; +import {getBookingShopifyApi} from '~/lib/api/bookingShopifyApi'; +import type { + CustomerPayoutGetResponse, + CustomerPayoutLogReferenceDocument, + CustomerPayoutLogResponse, + Shipping, +} from '~/lib/api/model'; +import {isMobilePay} from './($locale).account.payouts'; + +export function isShipping( + details: CustomerPayoutLogReferenceDocument, +): details is Shipping { + return (details as Shipping).cost !== undefined; +} + +export async function loader({context, params}: LoaderFunctionArgs) { + const customer = await getCustomer({context}); + const {id} = params; + + const payout = getBookingShopifyApi().customerPayoutGet( + customer.id, + id || '', + ); + + const payoutLogs = getBookingShopifyApi().customerPayoutLogPaginate( + customer.id, + id || '', + { + page: '1', + }, + ); + + return defer({payout, payoutLogs}); +} + +export default function AccountPayoutsId() { + const data = useLoaderData(); + + return ( + <> + + + + + + + + + + ); +} + +const PayoutLogs = ({data}: {data: Promise}) => { + return ( + Vent et øjeblik}> + + {({payload}) => { + return ( + + + + # + Type + Title + Beløb + Dato + + + + {payload.totalCount > 0 ? ( + + {payload.results.map((payout, index) => { + return ( + + Vis order + {isShipping(payout.referenceDocument) ? ( + <> + Forsendelse + + {payout.referenceDocument.origin.name} -{' '} + {payout.referenceDocument.destination.name} + + + {payout.referenceDocument.cost.value} DKK + + + ) : ( + <> + Behandlinger + + {payout.referenceDocument.title} + + + {payout.referenceDocument.price} DKK + + + )} + + {format(new Date(payout.orderCreatedAt), 'PPPP', { + locale: da, + })} + + + ); + })} + + ) : ( + + + Der er sket en fejl! + + + )} +
+ ); + }} +
+
+ ); +}; + +const Payout = ({data}: {data: Promise}) => { + return ( + asd}> + + {({payload}) => { + return ( + + + + Total: {payload.amount} {payload.currencyCode} + + Dato: {payload.date.toString()} + Betalingsmetode: {payload.payoutType} + {payload.payoutDetails ? ( + <> + {isMobilePay(payload.payoutDetails) ? ( + <> + + MobilePay: {payload.payoutDetails.phoneNumber} + + + ) : ( + <> + + Bank overførsel: {payload.payoutDetails.bankName} + + + {payload.payoutDetails.regNum} /{' '} + {payload.payoutDetails.accountNum} + + + )} + + ) : null} + + + ); + }} + + + ); +}; diff --git a/app/routes/($locale).account.payouts._index.tsx b/app/routes/($locale).account.payouts._index.tsx index 9013aa6e..0c0af20f 100644 --- a/app/routes/($locale).account.payouts._index.tsx +++ b/app/routes/($locale).account.payouts._index.tsx @@ -3,113 +3,202 @@ import { Button, Card, SimpleGrid, + Skeleton, Stack, Table, Text, Title, } from '@mantine/core'; -import {Form, Link, useLoaderData} from '@remix-run/react'; -import {json, type LoaderFunctionArgs} from '@shopify/remix-oxygen'; +import {Await, Form, Link, useLoaderData} from '@remix-run/react'; +import {defer, type LoaderFunctionArgs} from '@shopify/remix-oxygen'; import {format} from 'date-fns'; import {da} from 'date-fns/locale'; +import {Suspense} from 'react'; +import {AccountContent} from '~/components/account/AccountContent'; +import {AccountTitle} from '~/components/account/AccountTitle'; import {getBookingShopifyApi} from '~/lib/api/bookingShopifyApi'; +import type { + CustomerPayoutAccountGetResponse, + CustomerPayoutBalanceResponse, +} from '~/lib/api/model'; import {getCustomer} from '~/lib/get-customer'; import {isMobilePay} from './($locale).account.payouts'; export async function loader({context}: LoaderFunctionArgs) { const customer = await getCustomer({context}); - const {payload} = await getBookingShopifyApi().customerPayoutAccountGet( + const payoutAccount = getBookingShopifyApi().customerPayoutAccountGet( customer.id, ); - return json({payoutAccount: payload}); -} + const payoutBalance = getBookingShopifyApi().customerPayoutBalance( + customer.id, + ); -const elements = [ - {position: 6, mass: 12.011, symbol: 'C', name: 'Carbon'}, - {position: 7, mass: 14.007, symbol: 'N', name: 'Nitrogen'}, - {position: 39, mass: 88.906, symbol: 'Y', name: 'Yttrium'}, - {position: 56, mass: 137.33, symbol: 'Ba', name: 'Barium'}, - {position: 58, mass: 140.12, symbol: 'Ce', name: 'Cerium'}, -]; + const payouts = getBookingShopifyApi().customerPayoutPaginate(customer.id, { + page: '1', + }); + + return defer({payoutAccount, payoutBalance, payouts}); +} export default function AccountPayoutsIndex() { const data = useLoaderData(); - const rows = elements.map((element) => ( - - {format(new Date(), 'yyyy-MM-dd', {locale: da})} - - Overført - - 0.00 DKK - - )); return ( - - - - - {data.payoutAccount ? ( - <> - {isMobilePay(data.payoutAccount.payoutDetails) ? ( + <> + + + + + + + + + +
+ Historik + Listen af alle udbetalinger der er foretagt +
+ + Henter udbetalingshistorik...}> + + {({payload}) => { + return ( + + + + + Dato + Status + Beløb + + + + + {payload.totalCount > 0 ? ( + + {payload.results.map((payout) => ( + + + {format(new Date(), 'yyyy-MM-dd', {locale: da})} + + + {payout.status} + + {payout.amount} DKK + + + + + ))} + + ) : ( + + + + Der er ikke oprettet udbetalinger endnu! + + + + )} +
+
+ ); + }} +
+
+
+
+ + ); +} + +const PayoutBalance = ({ + payoutBalance, +}: { + payoutBalance: Promise; +}) => { + return ( + }> + + {({payload}) => { + return ( + + Balance + Total: {payload.totalAmount} DKK + Kørsel: {payload.totalShippingAmount} DKK + Behandlinger: {payload.totalLineItems} + {payload.totalAmount > 0 ? ( +
+ +
+ ) : null} +
+ ); + }} +
+
+ ); +}; + +const PayoutAccount = ({ + payoutAccount, +}: { + payoutAccount: Promise; +}) => { + return ( + }> + + {({payload}) => { + return ( + + + {payload ? ( <> - MobilePay overførsel - {data.payoutAccount.payoutDetails.phoneNumber} + {isMobilePay(payload.payoutDetails) ? ( + <> + MobilePay overførsel + {payload.payoutDetails.phoneNumber} + + ) : ( + <> + Bank overførsel + {payload.payoutDetails.bankName} + + {payload.payoutDetails.regNum} /{' '} + {payload.payoutDetails.accountNum} + + + )} +
+ +
) : ( <> - Bank overførsel - {data.payoutAccount.payoutDetails.bankName} - - {data.payoutAccount.payoutDetails.regNum} /{' '} - {data.payoutAccount.payoutDetails.accountNum} - + Overførselsmetode + Du har ikke valgt en overførselsmetode. + )} -
- -
- - ) : ( - <> - - For at kunne modtag betaling, skal du vælge overførselsmetode - du ønsker - - - - )} -
-
-
- -
- Historik - Listen af alle udbetalinger der er foretagt -
- - - - - - Dato - Status - Beløb - - - {rows} -
-
-
+ + + ); + }} + +
); -} +}; diff --git a/app/routes/($locale).account.payouts.create.tsx b/app/routes/($locale).account.payouts.create.tsx index 18474c32..98d0789f 100644 --- a/app/routes/($locale).account.payouts.create.tsx +++ b/app/routes/($locale).account.payouts.create.tsx @@ -21,6 +21,8 @@ import { } from '@conform-to/react'; import {Form, useActionData} from '@remix-run/react'; +import {AccountContent} from '~/components/account/AccountContent'; +import {AccountTitle} from '~/components/account/AccountTitle'; import {SubmitButton} from '~/components/form/SubmitButton'; import {getBookingShopifyApi} from '~/lib/api/bookingShopifyApi'; import {CustomerPayoutAccountType} from '~/lib/api/model'; @@ -94,75 +96,97 @@ export default function AccountPayoutsSettings() { const payoutType = useInputControl(fields.payoutType); return ( -
- -
- Bank konto - - Vi skal bruge din regnr og kontonummer for at sende dig din - udbetalinger. - -
+ <> + - - {getCollectionProps(fields.payoutType, { - type: 'radio', - options: [ - CustomerPayoutAccountType.BANK_ACCOUNT, - CustomerPayoutAccountType.MOBILE_PAY, - ], - }).map((props) => ( - - ))} - + + + +
+ Bank konto + + Vi skal bruge din regnr og kontonummer for at sende dig din + udbetalinger. + +
- {payoutType.value === CustomerPayoutAccountType.BANK_ACCOUNT ? ( - <> - - - + + {getCollectionProps(fields.payoutType, { + type: 'radio', + options: [ + CustomerPayoutAccountType.BANK_ACCOUNT, + CustomerPayoutAccountType.MOBILE_PAY, + ], + }).map((props) => ( + + ))} + + + {payoutType.value === CustomerPayoutAccountType.BANK_ACCOUNT ? ( + <> + + + + + + + ) : ( - - - ) : ( - - )} + )} - Gem -
- + Gem +
+ + + ); } diff --git a/app/routes/($locale).account.payouts.request.ts b/app/routes/($locale).account.payouts.request.ts new file mode 100644 index 00000000..d64c2f8d --- /dev/null +++ b/app/routes/($locale).account.payouts.request.ts @@ -0,0 +1,11 @@ +import {redirect, type ActionFunction} from '@shopify/remix-oxygen'; +import {getBookingShopifyApi} from '~/lib/api/bookingShopifyApi'; +import {getCustomer} from '~/lib/get-customer'; + +export const action: ActionFunction = async ({context, params}) => { + const customer = await getCustomer({context}); + + await getBookingShopifyApi().customerPayoutCreate(customer.id); + + return redirect(`/account/payouts`); +}; diff --git a/app/routes/($locale).account.payouts.tsx b/app/routes/($locale).account.payouts.tsx index 9d976b5a..a8cfa971 100644 --- a/app/routes/($locale).account.payouts.tsx +++ b/app/routes/($locale).account.payouts.tsx @@ -1,14 +1,10 @@ import {Outlet} from '@remix-run/react'; -import {json, type LoaderFunctionArgs} from '@shopify/remix-oxygen'; -import {AccountContent} from '~/components/account/AccountContent'; -import {AccountTitle} from '~/components/account/AccountTitle'; import type { CustomerPayoutAccountPayoutDetails, CustomerPayoutBankAccount, CustomerPayoutMobilePay, } from '~/lib/api/model'; -import {getCustomer} from '~/lib/get-customer'; export function isMobilePay( details: CustomerPayoutAccountPayoutDetails, @@ -22,19 +18,6 @@ export function isBankAccount( return (details as CustomerPayoutBankAccount).bankName !== undefined; } -export async function loader({context}: LoaderFunctionArgs) { - const customer = await getCustomer({context}); - return json({}); -} - export default function AccountPayouts() { - return ( - <> - - - - - - - ); + return ; } diff --git a/openapi.yaml b/openapi.yaml index e171764f..41c68abe 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -138,6 +138,63 @@ components: enum: - MOBILE_PAY - BANK_ACCOUNT + CustomerPayoutAccountCreateBody: + type: object + properties: + payoutType: + $ref: '#/components/schemas/CustomerPayoutAccountType' + payoutDetails: + oneOf: + - $ref: '#/components/schemas/CustomerPayoutMobilePay' + - $ref: '#/components/schemas/CustomerPayoutBankAccount' + required: + - payoutType + - payoutDetails + CustomerPayoutAccountCreateResponse: + type: object + properties: + success: + type: boolean + example: true + payload: + $ref: '#/components/schemas/CustomerPayoutAccount' + required: + - success + - payload + CustomerPayoutAccountDestroy: + type: object + properties: + deletedCount: + type: number + acknowledged: + type: boolean + required: + - deletedCount + - acknowledged + CustomerPayoutAccountDestroyResponse: + type: object + properties: + success: + type: boolean + example: true + payload: + $ref: '#/components/schemas/CustomerPayoutAccountDestroy' + required: + - success + - payload + CustomerPayoutAccountGetResponse: + type: object + properties: + success: + type: boolean + example: true + payload: + allOf: + - $ref: '#/components/schemas/CustomerPayoutAccount' + nullable: true + required: + - success + - payload CustomerPayoutMobilePay: type: object properties: @@ -1284,6 +1341,186 @@ components: required: - success - payload + CustomerPayout: + type: object + properties: + _id: + type: string + date: + type: string + amount: + type: number + format: double + currencyCode: + type: string + example: DKK + status: + type: string + enum: + - Pending + - Processed + - Failed + payoutType: + $ref: '#/components/schemas/CustomerPayoutAccountType' + payoutDetails: + oneOf: + - $ref: '#/components/schemas/CustomerPayoutMobilePay' + - $ref: '#/components/schemas/CustomerPayoutBankAccount' + required: + - customerId + - date + - amount + - currencyCode + - status + CustomerPayoutBalancePayload: + type: object + properties: + totalAmount: + type: number + totalLineItems: + type: number + totalShippingAmount: + type: number + required: + - totalAmount + - totalLineItems + - totalShippingAmount + CustomerPayoutBalanceResponse: + type: object + properties: + success: + type: boolean + example: true + payload: + $ref: '#/components/schemas/CustomerPayoutBalancePayload' + required: + - success + - payload + CustomerPayoutGetResponse: + type: object + properties: + success: + type: boolean + example: true + payload: + $ref: '#/components/schemas/CustomerPayout' + required: + - success + - payload + CustomerPayoutPaginatePayload: + type: object + properties: + results: + type: array + items: + $ref: '#/components/schemas/CustomerPayout' + currentPage: + type: number + totalPages: + type: number + hasNextPage: + type: boolean + totalCount: + type: number + required: + - results + - currentPage + - totalPages + - hasNextPage + - totalCount + CustomerPayoutPaginateResponse: + type: object + properties: + success: + type: boolean + example: true + payload: + $ref: '#/components/schemas/CustomerPayoutPaginatePayload' + required: + - success + - payload + CustomerPayoutCreateResponse: + type: object + properties: + success: + type: boolean + example: true + payload: + $ref: '#/components/schemas/CustomerPayout' + required: + - success + - payload + CustomerPayoutLogType: + type: string + enum: + - Shipping + - LineItem + CustomerPayoutLog: + type: object + properties: + _id: + type: string + customerId: + type: number + orderId: + type: number + orderCreatedAt: + type: string + referenceType: + $ref: '#/components/schemas/CustomerPayoutLogType' + referenceId: + type: string + payout: + type: string + format: objectId + createdAt: + type: string + referenceDocument: + oneOf: + - $ref: '#/components/schemas/CustomeBaserOrderLineItem' + - $ref: '#/components/schemas/Shipping' + required: + - _id + - customerId + - orderId + - orderCreatedAt + - referenceType + - referenceId + - referenceDocument + - payout + - createdAt + CustomerPayoutLogPayload: + type: object + properties: + results: + type: array + items: + $ref: '#/components/schemas/CustomerPayoutLog' + currentPage: + type: number + totalPages: + type: number + hasNextPage: + type: boolean + totalCount: + type: number + required: + - results + - currentPage + - totalPages + - hasNextPage + - totalCount + CustomerPayoutLogResponse: + type: object + properties: + success: + type: boolean + example: true + payload: + $ref: '#/components/schemas/CustomerPayoutLogPayload' + required: + - success + - payload CustomerBooking: allOf: - $ref: '#/components/schemas/CustomerBaseOrder' @@ -2066,7 +2303,7 @@ components: type: array items: $ref: '#/components/schemas/User' - total: + totalCount: type: number required: - results @@ -2379,10 +2616,16 @@ components: type: string origin: $ref: '#/components/schemas/CustomerLocation' + created_at: + type: string + updated_at: + type: string required: - _id - location - origin + - created_at + - updated_at ShippingCostDestination: type: object properties: @@ -3188,6 +3431,200 @@ paths: '404': $ref: '#/components/responses/NotFoundResponse' security: [] + '/customer/{customerId}/payouts/paginate': + 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: '#/components/schemas/CustomerPayoutPaginateResponse' + '400': + $ref: '#/components/responses/BadResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + security: [] + '/customer/{customerId}/payouts/balance': + 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: '#/components/schemas/CustomerPayoutBalanceResponse' + '400': + $ref: '#/components/responses/BadResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + security: [] + '/customer/{customerId}/payout/{payoutId}': + 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: '#/components/schemas/CustomerPayoutGetResponse' + '400': + $ref: '#/components/responses/BadResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + security: [] + '/customer/{customerId}/payout/create': + post: + parameters: + - name: customerId + in: path + description: The ID of the customerId + required: true + schema: + type: string + tags: + - CustomerPayout + operationId: customerPayoutCreate + summary: POST Create payout + description: This endpoint create payout + responses: + '200': + description: Response with payout payload + content: + application/json: + schema: + $ref: '#/components/schemas/CustomerPayoutCreateResponse' + '400': + $ref: '#/components/responses/BadResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + security: [] + '/customer/{customerId}/payout-logs/{payoutId}/paginate': + 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: '#/components/schemas/CustomerPayoutLogResponse' + '400': + $ref: '#/components/responses/BadResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + security: [] '/customer/{customerId}/payout-account': post: parameters: @@ -3207,33 +3644,14 @@ paths: content: application/json: schema: - type: object - properties: - payoutType: - $ref: '#/components/schemas/CustomerPayoutAccountType' - payoutDetails: - oneOf: - - $ref: '#/components/schemas/CustomerPayoutMobilePay' - - $ref: '#/components/schemas/CustomerPayoutBankAccount' - required: - - payoutType - - payoutDetails + $ref: '#/components/schemas/CustomerPayoutAccountCreateBody' responses: '200': description: Response with payout account payload content: application/json: schema: - type: object - properties: - success: - type: boolean - example: true - payload: - $ref: '#/components/schemas/CustomerPayoutAccount' - required: - - success - - payload + $ref: '#/components/schemas/CustomerPayoutAccountCreateResponse' '400': $ref: '#/components/responses/BadResponse' '401': @@ -3262,18 +3680,7 @@ paths: content: application/json: schema: - type: object - properties: - success: - type: boolean - example: true - payload: - allOf: - - $ref: '#/components/schemas/CustomerPayoutAccount' - nullable: true - required: - - success - - payload + $ref: '#/components/schemas/CustomerPayoutAccountGetResponse' '400': $ref: '#/components/responses/BadResponse' '401': @@ -3302,24 +3709,7 @@ paths: content: application/json: schema: - type: object - properties: - success: - type: boolean - example: true - payload: - type: object - properties: - deletedCount: - type: number - acknowledged: - type: boolean - required: - - deletedCount - - acknowledged - required: - - success - - payload + $ref: '#/components/schemas/CustomerPayoutAccountDestroyResponse' '400': $ref: '#/components/responses/BadResponse' '401':