import * as API from "../../common/api"; import { CollectionDoc, Events, Gigabytes, QueryParams, Resource, ResourceId, Scope, SingleDoc, State, Task, Time } from "../../common/structures"; import * as Accounts from "../accounts"; import { Environment } from "../environments"; import * as Teams from "../teams"; import * as Tiers from "../tiers/tiers"; import { Term } from "./common"; export declare function document(): typeof CollectionRequest; export declare function document(id: ResourceId): SingleRequest; export interface Collection extends CollectionDoc { data: Invoice[]; includes?: { environments: { [key: string]: Environment; }; owners: { accounts: { [key: string]: Accounts.Account; }; teams: { [key: string]: Teams.Team; }; }; }; } export interface Single extends SingleDoc { data: Invoice | null; includes?: { environments: { [key: string]: Environment; }; }; } export interface Invoice extends Resource { owner: Scope; items: LineItem[]; approved: boolean; term: Term; charges: number; late_fees: LateFee[]; payments: Payment[]; credits: Credit[]; state: State; events: Events & { billed: Time; paid: Time; due: Time; overdue: Time; credited: Time; voided: Time; }; meta?: { amount_due?: number; }; } export declare type SingleActions = "pay"; export declare type InvoiceState = "new" | "billing" | "billed" | "processing" | "partially-paid" | "paid" | "refunding" | "refunded" | "crediting" | "credited" | "voiding" | "voided"; export declare type BillingCategory = string; export interface Payment { id: ResourceId; time: Time; description: string; amount: number; amount_refunded: number; refunds: Refund[]; method: string; result: { success: boolean; error: string; }; } export interface Credit { id: ResourceId; time: Time; description: string; amount: number; account_credit: string; } export interface LateFee { id: ResourceId; time: Time; amount: number; description: string; } export interface Refund { id: ResourceId; time: Time; description: string; amount: number; } export interface LineItem { id: ResourceId; term: Term; tier: Tiers.Tier; storage?: StorageUsage; bandwidth?: BandwidthUsage; category: BillingCategory; description: string; due: number; discount: number; } export interface StorageUsage { used: Gigabytes; } export interface BandwidthUsage { used: Gigabytes; } export declare class CollectionRequest { private static target; static get(query?: QueryParams): Promise>; } export declare class SingleRequest { private target; constructor(id: ResourceId); get(query?: QueryParams): Promise>; pay(): Promise>>; task(action: SingleActions, contents?: object, query?: QueryParams): Promise>>; }