// This file is auto-generated by @hey-api/openapi-ts

import type { Client, Options as Options2, TDataShape } from './client';
import { client } from './client.gen';
import type { CancelBountyData, CancelBountyResponses, ClawbackEarningData, ClawbackEarningResponses, CreateBountyData, CreateBountyErrors, CreateBountyResponses, DownloadSubmissionAttachmentData, DownloadSubmissionAttachmentResponses, FundBountyData, FundBountyResponses, GetBountyData, GetBountyLeaderboardData, GetBountyLeaderboardResponses, GetBountyResponses, GetBountyStatsData, GetBountyStatsErrors, GetBountyStatsResponses, GetBountySubmissionData, GetBountySubmissionResponses, GetDailyActivityData, GetDailyActivityResponses, GetLeaderboardData, GetLeaderboardResponses, GetMySubmissionData, GetMySubmissionResponses, GetMyUserStatsData, GetMyUserStatsResponses, GetOverviewData, GetOverviewResponses, GetUserStatsData, GetUserStatsResponses, JoinBountyData, JoinBountyResponses, LeaveBountyData, LeaveBountyResponses, ListBountiesData, ListBountiesResponses, ListBountyEarningsData, ListBountyEarningsResponses, ListBountySubmissionsData, ListBountySubmissionsResponses, ListMyEarningsData, ListMyEarningsResponses, ListOrganizationBountiesData, ListOrganizationBountiesResponses, PatchBountyData, PatchBountyResponses, UpsertMySubmissionData, UpsertMySubmissionResponses, WithdrawMySubmissionData, WithdrawMySubmissionResponses } from './types.gen';

export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
    /**
     * You can provide a client instance returned by `createClient()` instead of
     * individual options. This might be also useful if you want to implement a
     * custom client.
     */
    client?: Client;
    /**
     * You can pass arbitrary values through the `meta` object. This can be
     * used to access values that aren't defined as part of the SDK function.
     */
    meta?: Record<string, unknown>;
};

/**
 * `GET /bounties` — public bounty listing.
 *
 * This is unauthenticated and lists bounties across all organizations.
 * Customer-scoped listings (the caller's own org's bounties) live at
 * `GET /organizations/me/bounties` instead, so a single path never flips
 * semantics based on whether auth is present.
 */
export const listBounties = <ThrowOnError extends boolean = false>(options?: Options<ListBountiesData, ThrowOnError>) => (options?.client ?? client).get<ListBountiesResponses, unknown, ThrowOnError>({ url: '/bounties', ...options });

/**
 * `POST /bounties` — create a bounty + escrow hold.
 */
export const createBounty = <ThrowOnError extends boolean = false>(options: Options<CreateBountyData, ThrowOnError>) => (options.client ?? client).post<CreateBountyResponses, CreateBountyErrors, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

/**
 * `GET /bounties/{id}` — full bounty state.
 */
export const getBounty = <ThrowOnError extends boolean = false>(options: Options<GetBountyData, ThrowOnError>) => (options.client ?? client).get<GetBountyResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}',
    ...options
});

/**
 * `PATCH /bounties/{id}` — edit tiers forward-only, extend deadline, top up.
 */
export const patchBounty = <ThrowOnError extends boolean = false>(options: Options<PatchBountyData, ThrowOnError>) => (options.client ?? client).patch<PatchBountyResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

/**
 * `POST /bounties/{id}/cancel` — customer cancels and is refunded any
 * remaining escrow balance. Only legal when no earnings are un-released.
 */
export const cancelBounty = <ThrowOnError extends boolean = false>(options: Options<CancelBountyData, ThrowOnError>) => (options.client ?? client).post<CancelBountyResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}/cancel',
    ...options
});

/**
 * `GET /bounties/{id}/earnings` — paginated earnings ledger.
 */
export const listBountyEarnings = <ThrowOnError extends boolean = false>(options: Options<ListBountyEarningsData, ThrowOnError>) => (options.client ?? client).get<ListBountyEarningsResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}/earnings',
    ...options
});

/**
 * `POST /bounties/{id}/earnings/{earning_id}/clawback` — customer claws back
 * an earning during the hold window. Earning flip + pool credit are atomic.
 */
export const clawbackEarning = <ThrowOnError extends boolean = false>(options: Options<ClawbackEarningData, ThrowOnError>) => (options.client ?? client).post<ClawbackEarningResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}/earnings/{earning_id}/clawback',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

/**
 * `POST /bounties/{id}/fund` — deposit SerenBucks into escrow.
 */
export const fundBounty = <ThrowOnError extends boolean = false>(options: Options<FundBountyData, ThrowOnError>) => (options.client ?? client).post<FundBountyResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}/fund',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

/**
 * `DELETE /bounties/{id}/join` — leave. Already-accrued earnings still pay.
 */
export const leaveBounty = <ThrowOnError extends boolean = false>(options: Options<LeaveBountyData, ThrowOnError>) => (options.client ?? client).delete<LeaveBountyResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}/join',
    ...options
});

/**
 * `POST /bounties/{id}/join` — idempotent. Returns a `referral_code` the
 * agent uses to attribute downstream events to themselves.
 */
export const joinBounty = <ThrowOnError extends boolean = false>(options: Options<JoinBountyData, ThrowOnError>) => (options.client ?? client).post<JoinBountyResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}/join',
    ...options
});

/**
 * `GET /bounties/{id}/leaderboard` — top earners in this bounty.
 */
export const getBountyLeaderboard = <ThrowOnError extends boolean = false>(options: Options<GetBountyLeaderboardData, ThrowOnError>) => (options.client ?? client).get<GetBountyLeaderboardResponses, unknown, ThrowOnError>({ url: '/bounties/{id}/leaderboard', ...options });

/**
 * `GET /bounties/{id}/stats` — public rollup for a single bounty.
 */
export const getBountyStats = <ThrowOnError extends boolean = false>(options: Options<GetBountyStatsData, ThrowOnError>) => (options.client ?? client).get<GetBountyStatsResponses, GetBountyStatsErrors, ThrowOnError>({ url: '/bounties/{id}/stats', ...options });

/**
 * `DELETE /bounties/{id}/submission` — withdraw the caller's submission.
 */
export const withdrawMySubmission = <ThrowOnError extends boolean = false>(options: Options<WithdrawMySubmissionData, ThrowOnError>) => (options.client ?? client).delete<WithdrawMySubmissionResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}/submission',
    ...options
});

/**
 * `GET /bounties/{id}/submission` — fetch the caller's submission.
 */
export const getMySubmission = <ThrowOnError extends boolean = false>(options: Options<GetMySubmissionData, ThrowOnError>) => (options.client ?? client).get<GetMySubmissionResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}/submission',
    ...options
});

/**
 * `POST /bounties/{id}/submission` — create or replace the caller's submission.
 */
export const upsertMySubmission = <ThrowOnError extends boolean = false>(options: Options<UpsertMySubmissionData, ThrowOnError>) => (options.client ?? client).post<UpsertMySubmissionResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}/submission',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

/**
 * `GET /bounties/{id}/submissions` — owner/operator list view for a bounty.
 */
export const listBountySubmissions = <ThrowOnError extends boolean = false>(options: Options<ListBountySubmissionsData, ThrowOnError>) => (options.client ?? client).get<ListBountySubmissionsResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}/submissions',
    ...options
});

/**
 * `GET /bounties/{id}/submissions/{submission_id}` — detail for owner/operator or submitter.
 */
export const getBountySubmission = <ThrowOnError extends boolean = false>(options: Options<GetBountySubmissionData, ThrowOnError>) => (options.client ?? client).get<GetBountySubmissionResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}/submissions/{submission_id}',
    ...options
});

/**
 * `GET /bounties/{id}/submissions/{submission_id}/attachment` — download the submission attachment.
 */
export const downloadSubmissionAttachment = <ThrowOnError extends boolean = false>(options: Options<DownloadSubmissionAttachmentData, ThrowOnError>) => (options.client ?? client).get<DownloadSubmissionAttachmentResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/bounties/{id}/submissions/{submission_id}/attachment',
    ...options
});

/**
 * `GET /leaderboard` — top earners across all bounties.
 */
export const getLeaderboard = <ThrowOnError extends boolean = false>(options?: Options<GetLeaderboardData, ThrowOnError>) => (options?.client ?? client).get<GetLeaderboardResponses, unknown, ThrowOnError>({ url: '/leaderboard', ...options });

/**
 * `GET /bounties` — list bounties in the caller's organization.
 */
export const listOrganizationBounties = <ThrowOnError extends boolean = false>(options?: Options<ListOrganizationBountiesData, ThrowOnError>) => (options?.client ?? client).get<ListOrganizationBountiesResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/organizations/me/bounties',
    ...options
});

/**
 * `GET /overview` — platform-wide rollup.
 */
export const getOverview = <ThrowOnError extends boolean = false>(options?: Options<GetOverviewData, ThrowOnError>) => (options?.client ?? client).get<GetOverviewResponses, unknown, ThrowOnError>({ url: '/overview', ...options });

/**
 * `GET /stats/daily` — daily accrual and payout activity.
 */
export const getDailyActivity = <ThrowOnError extends boolean = false>(options?: Options<GetDailyActivityData, ThrowOnError>) => (options?.client ?? client).get<GetDailyActivityResponses, unknown, ThrowOnError>({ url: '/stats/daily', ...options });

/**
 * `GET /users/me/earnings` — cross-bounty earnings ledger for the caller.
 */
export const listMyEarnings = <ThrowOnError extends boolean = false>(options?: Options<ListMyEarningsData, ThrowOnError>) => (options?.client ?? client).get<ListMyEarningsResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/users/me/earnings',
    ...options
});

/**
 * `GET /users/me/stats` — rollup for the authenticated caller.
 */
export const getMyUserStats = <ThrowOnError extends boolean = false>(options?: Options<GetMyUserStatsData, ThrowOnError>) => (options?.client ?? client).get<GetMyUserStatsResponses, unknown, ThrowOnError>({
    security: [{ scheme: 'bearer', type: 'http' }],
    url: '/users/me/stats',
    ...options
});

/**
 * `GET /users/{user_id}/stats` — public rollup for any user.
 */
export const getUserStats = <ThrowOnError extends boolean = false>(options: Options<GetUserStatsData, ThrowOnError>) => (options.client ?? client).get<GetUserStatsResponses, unknown, ThrowOnError>({ url: '/users/{user_id}/stats', ...options });
