vk-io
Version:
Modern VK API SDK for Node.js
63 lines (62 loc) • 1.67 kB
TypeScript
import { API } from '../../api';
import { kSerializeData, AttachmentType } from '../../utils/constants';
/**
* Parse attachments
*/
export declare const parseAttachmentRe: RegExp;
export interface ISharedAttachmentPayload {
id: number;
owner_id: number;
access_key?: string;
}
export interface IAttachmentOptions<P, Type extends string = string> {
api: API;
type: Type;
payload: Partial<ISharedAttachmentPayload> & P;
}
export type AttachmentFactoryOptions<P> = Omit<IAttachmentOptions<P>, 'type'>;
export declare class Attachment<P = object, Type extends string | AttachmentType = string> {
type: Type;
protected $filled: boolean;
protected api: API;
protected payload: ISharedAttachmentPayload & P;
/**
* Constructor
*/
constructor(options: IAttachmentOptions<P, Type>);
get id(): number;
get ownerId(): number;
get accessKey(): string | undefined;
/**
* Returns custom tag
*/
get [Symbol.toStringTag](): string;
/**
* Parse attachment with string
*/
static fromString(attachment: string, api: API): Attachment;
/**
* Returns whether the attachment is filled
*/
get isFilled(): boolean;
/**
* Can be attached via string representation
*/
get canBeAttached(): boolean;
/**
* Checks that the attachment is equivalent with object
*/
equals(attachment: Attachment | string): boolean;
/**
* Returns a string to attach a VK
*/
toString(): string;
/**
* Returns data for JSON
*/
toJSON(): object;
/**
* Returns the custom data
*/
[kSerializeData](): object;
}