export type GetApiPartnerAppAppIdUsageArgs = {Authorization?: string | undefined, from?: string | undefined, to?: string | undefined, appId: string}; export type GetApiPartnerAppAppIdUsageOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get App's Daily Usage * * GET /partner/app/{appId}/usage */ export const getApiPartnerAppAppIdUsage = async (args: GetApiPartnerAppAppIdUsageArgs, options?: GetApiPartnerAppAppIdUsageOptions) => { const {baseUrl = "https://partner.gupshup.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) const url = `${baseUrl.replace(/\/+$/, '')}/partner/app/${encodeURIComponent(String(args.appId))}/usage${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };