/* tslint:disable */
/* eslint-disable */
/**
 * Vitron API
 * API documentation for Vitron backend
 *
 * The version of the OpenAPI document: v1
 * Contact: support@yourcompany.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import * as runtime from '../runtime';
import type {
  BankAccount,
  BankAccountCreate,
  BankAccountDeleteResponse,
  PaymentURLResponse,
  PayoutRequest,
  PayoutRequestCreate,
  SellerBalance,
  TransactionCreate,
  Wallet,
} from '../models';

export interface ApiWalletV1BankAccountsCreateRequest {
    data: BankAccountCreate;
}

export interface ApiWalletV1BankAccountsDeleteRequest {
    id: string;
}

export interface ApiWalletV1ChargeCreateRequest {
    data: TransactionCreate;
}

export interface ApiWalletV1PayoutRequestCreateCreateRequest {
    data: PayoutRequestCreate;
}

export interface ApiWalletV1PayoutRequestListRequest {
    dateFilter?: ApiWalletV1PayoutRequestListDateFilterEnum;
    fromDate?: string;
    toDate?: string;
}

export interface ApiWalletV1PayoutRequestListListRequest {
    dateFilter?: ApiWalletV1PayoutRequestListListDateFilterEnum;
    fromDate?: string;
    toDate?: string;
}

export interface ApiWalletV1VerifyListRequest {
    authority: string;
    status: string;
    authorityId: string;
}

/**
 * 
 */
export class WalletManagementApi extends runtime.BaseAPI {

    /**
     * Allows a seller to register a bank account for payout requests.
     * Register bank account
     */
    async apiWalletV1BankAccountsCreateRaw(requestParameters: ApiWalletV1BankAccountsCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BankAccountCreate>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiWalletV1BankAccountsCreate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/wallet/v1/bank-accounts/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Allows a seller to register a bank account for payout requests.
     * Register bank account
     */
    async apiWalletV1BankAccountsCreate(requestParameters: ApiWalletV1BankAccountsCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BankAccountCreate> {
        const response = await this.apiWalletV1BankAccountsCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Allows a seller (or superadmin) to delete their own bank account — verified or unverified.
     * Delete bank account
     */
    async apiWalletV1BankAccountsDeleteRaw(requestParameters: ApiWalletV1BankAccountsDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BankAccountDeleteResponse>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling apiWalletV1BankAccountsDelete.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/wallet/v1/bank-accounts/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Allows a seller (or superadmin) to delete their own bank account — verified or unverified.
     * Delete bank account
     */
    async apiWalletV1BankAccountsDelete(requestParameters: ApiWalletV1BankAccountsDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BankAccountDeleteResponse> {
        const response = await this.apiWalletV1BankAccountsDeleteRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Returns a list of all bank accounts registered by the logged-in seller.
     * List seller bank accounts
     */
    async apiWalletV1BankAccountsListListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<BankAccount>>> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/wallet/v1/bank-accounts/list/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Returns a list of all bank accounts registered by the logged-in seller.
     * List seller bank accounts
     */
    async apiWalletV1BankAccountsListList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<BankAccount>> {
        const response = await this.apiWalletV1BankAccountsListListRaw(initOverrides);
        return await response.value();
    }

    /**
     * Creates a deposit transaction and returns Zarinpal payment URL.
     * Initiate wallet charge via Zarinpal
     */
    async apiWalletV1ChargeCreateRaw(requestParameters: ApiWalletV1ChargeCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<PaymentURLResponse>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiWalletV1ChargeCreate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/wallet/v1/charge/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Creates a deposit transaction and returns Zarinpal payment URL.
     * Initiate wallet charge via Zarinpal
     */
    async apiWalletV1ChargeCreate(requestParameters: ApiWalletV1ChargeCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<PaymentURLResponse> {
        const response = await this.apiWalletV1ChargeCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Create payout request for logged-in seller.
     * Request payout
     */
    async apiWalletV1PayoutRequestCreateCreateRaw(requestParameters: ApiWalletV1PayoutRequestCreateCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<PayoutRequestCreate>> {
        if (requestParameters.data === null || requestParameters.data === undefined) {
            throw new runtime.RequiredError('data','Required parameter requestParameters.data was null or undefined when calling apiWalletV1PayoutRequestCreateCreate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/wallet/v1/payout-request/create/`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.data,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Create payout request for logged-in seller.
     * Request payout
     */
    async apiWalletV1PayoutRequestCreateCreate(requestParameters: ApiWalletV1PayoutRequestCreateCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<PayoutRequestCreate> {
        const response = await this.apiWalletV1PayoutRequestCreateCreateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     *  Returns payout requests for the logged-in seller.  Optional `date_filter` values: - `today` - `last_7` - `last_30` - `custom` (requires `from_date` and/or `to_date`) 
     * List seller payout requests (with Persian-style date filter)
     */
    async apiWalletV1PayoutRequestListRaw(requestParameters: ApiWalletV1PayoutRequestListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<PayoutRequest>>> {
        const queryParameters: any = {};

        if (requestParameters.dateFilter !== undefined) {
            queryParameters['date_filter'] = requestParameters.dateFilter;
        }

        if (requestParameters.fromDate !== undefined) {
            queryParameters['from_date'] = requestParameters.fromDate;
        }

        if (requestParameters.toDate !== undefined) {
            queryParameters['to_date'] = requestParameters.toDate;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/wallet/v1/payout-request/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     *  Returns payout requests for the logged-in seller.  Optional `date_filter` values: - `today` - `last_7` - `last_30` - `custom` (requires `from_date` and/or `to_date`) 
     * List seller payout requests (with Persian-style date filter)
     */
    async apiWalletV1PayoutRequestList(requestParameters: ApiWalletV1PayoutRequestListRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<PayoutRequest>> {
        const response = await this.apiWalletV1PayoutRequestListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     *  Returns payout requests for the logged-in seller.  Optional `date_filter` values: - `today` - `last_7` - `last_30` - `custom` (requires `from_date` and/or `to_date`) 
     * List seller payout requests (with Persian-style date filter)
     */
    async apiWalletV1PayoutRequestListListRaw(requestParameters: ApiWalletV1PayoutRequestListListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<PayoutRequest>>> {
        const queryParameters: any = {};

        if (requestParameters.dateFilter !== undefined) {
            queryParameters['date_filter'] = requestParameters.dateFilter;
        }

        if (requestParameters.fromDate !== undefined) {
            queryParameters['from_date'] = requestParameters.fromDate;
        }

        if (requestParameters.toDate !== undefined) {
            queryParameters['to_date'] = requestParameters.toDate;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/wallet/v1/payout-request/list/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     *  Returns payout requests for the logged-in seller.  Optional `date_filter` values: - `today` - `last_7` - `last_30` - `custom` (requires `from_date` and/or `to_date`) 
     * List seller payout requests (with Persian-style date filter)
     */
    async apiWalletV1PayoutRequestListList(requestParameters: ApiWalletV1PayoutRequestListListRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<PayoutRequest>> {
        const response = await this.apiWalletV1PayoutRequestListListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Get seller\'s available funds. Only seller or superadmin can access.
     * Retrieve seller balance
     */
    async apiWalletV1SellerBalanceReadRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SellerBalance>> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/wallet/v1/seller-balance/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Get seller\'s available funds. Only seller or superadmin can access.
     * Retrieve seller balance
     */
    async apiWalletV1SellerBalanceRead(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SellerBalance> {
        const response = await this.apiWalletV1SellerBalanceReadRaw(initOverrides);
        return await response.value();
    }

    /**
     * Verifies a payment after the user returns from the Zarinpal gateway. Redirects to success or failure page with query parameters.
     * Verify Zarinpal Payment
     */
    async apiWalletV1VerifyListRaw(requestParameters: ApiWalletV1VerifyListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.authority === null || requestParameters.authority === undefined) {
            throw new runtime.RequiredError('authority','Required parameter requestParameters.authority was null or undefined when calling apiWalletV1VerifyList.');
        }

        if (requestParameters.status === null || requestParameters.status === undefined) {
            throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling apiWalletV1VerifyList.');
        }

        if (requestParameters.authorityId === null || requestParameters.authorityId === undefined) {
            throw new runtime.RequiredError('authorityId','Required parameter requestParameters.authorityId was null or undefined when calling apiWalletV1VerifyList.');
        }

        const queryParameters: any = {};

        if (requestParameters.authority !== undefined) {
            queryParameters['Authority'] = requestParameters.authority;
        }

        if (requestParameters.status !== undefined) {
            queryParameters['Status'] = requestParameters.status;
        }

        if (requestParameters.authorityId !== undefined) {
            queryParameters['authority_id'] = requestParameters.authorityId;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/wallet/v1/verify/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Verifies a payment after the user returns from the Zarinpal gateway. Redirects to success or failure page with query parameters.
     * Verify Zarinpal Payment
     */
    async apiWalletV1VerifyList(requestParameters: ApiWalletV1VerifyListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiWalletV1VerifyListRaw(requestParameters, initOverrides);
    }

    /**
     * Returns the balance and last updated time of the authenticated user\'s wallet.
     * Get wallet balance
     */
    async apiWalletV1WalletListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Wallet>> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        const response = await this.request({
            path: `/api/wallet/v1/wallet/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response);
    }

    /**
     * Returns the balance and last updated time of the authenticated user\'s wallet.
     * Get wallet balance
     */
    async apiWalletV1WalletList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Wallet> {
        const response = await this.apiWalletV1WalletListRaw(initOverrides);
        return await response.value();
    }

}

/**
 * @export
 */
export const ApiWalletV1PayoutRequestListDateFilterEnum = {
    Today: 'today',
    Last7: 'last_7',
    Last30: 'last_30',
    Custom: 'custom'
} as const;
export type ApiWalletV1PayoutRequestListDateFilterEnum = typeof ApiWalletV1PayoutRequestListDateFilterEnum[keyof typeof ApiWalletV1PayoutRequestListDateFilterEnum];
/**
 * @export
 */
export const ApiWalletV1PayoutRequestListListDateFilterEnum = {
    Today: 'today',
    Last7: 'last_7',
    Last30: 'last_30',
    Custom: 'custom'
} as const;
export type ApiWalletV1PayoutRequestListListDateFilterEnum = typeof ApiWalletV1PayoutRequestListListDateFilterEnum[keyof typeof ApiWalletV1PayoutRequestListListDateFilterEnum];
