shopee-openapi-v2
Version:
shopee open api sdk
198 lines (197 loc) • 5.35 kB
TypeScript
import { ApiShopMethod, BaseRes, ShopReq } from "./utils/request";
import * as FormData from 'form-data';
import { AxiosResponse } from "axios";
export declare type MessageContent = {
text?: string;
sticker_package_id?: string;
sticker_id?: string;
url?: string;
video_url?: string;
thumb_url?: string;
order_sn?: string;
item_id?: number;
translation?: {
text: string;
source: string;
target_language: string;
source_language: string;
};
mid?: {
text: string;
source: string;
target_language: string;
source_language: string;
};
};
export declare type Conversation = {
conversation_id: string;
to_id: number;
to_name: string;
to_avatar: string;
shop_id: number;
unread_count: number;
pinned: boolean;
last_read_message_id: string;
latest_message_id: string;
latest_message_type: string;
latest_message_content: MessageContent;
latest_message_from_id: number;
last_message_timestamp: number;
last_message_option: number;
max_general_option_hide_time: string;
};
export declare class ChatApi {
getMessage: ApiShopMethod<{
offset?: string;
page_size?: number;
conversation_id: BigInt;
}, {
response: {
messages: {
message_id: string;
message_type: string;
from_id: number;
from_shop_id: number;
to_id: number;
to_shop_id: number;
conversation_id: string;
created_timestamp: number;
region: string;
status: string;
source: string;
content: MessageContent;
message_option: number;
source_content: {
order_sn: string;
item_id: number;
};
}[];
page_result: {
next_offset: string;
page_size: number;
};
};
}>;
sendMessage: ApiShopMethod<{
to_id: number;
message_type: 'text' | 'sticker' | 'image' | 'item' | 'order';
content: {
text?: string;
sticker_id?: string;
sticker_package_id?: string;
image_url?: string;
item_id?: number;
order_sn?: string;
};
}, {
response: {
content: MessageContent;
region: string;
to_id: number;
created_timestamp: number;
conversation_id: string;
message_type: string;
message_id: string;
message_option: number;
};
}>;
getConversationList: ApiShopMethod<{
direction: 'latest' | 'older';
type: 'all' | 'pinned' | 'unread';
next_timestamp_nano?: number;
page_size?: number;
}, {
response: {
page_result: {
page_size: number;
next_cursor: {
next_message_time_nano: string;
conversation_id: string;
};
more: boolean;
};
conversations: Conversation[];
};
}>;
getOneConversation: ApiShopMethod<{
conversation_id: BigInt;
}, {
response: Conversation;
}>;
deleteConversation: ApiShopMethod<{
conversation_id: BigInt;
}, {
response: {};
}>;
getUnreadConversationCount: ApiShopMethod<{}, {
response: {
total_unread_count: number;
};
}>;
pinConversation: ApiShopMethod<{
conversation_id: BigInt;
}, {
response: {};
}>;
unpinConversation: ApiShopMethod<{
conversation_id: BigInt;
}, {
response: {};
}>;
readConversation: ApiShopMethod<{
conversation_id: BigInt;
last_read_message_id: string;
}, {
response: {};
}>;
unreadConversation: ApiShopMethod<{
conversation_id: BigInt;
}, {
response: {};
}>;
getOfferToggleStatus: ApiShopMethod<{}, {
response: {
shop_id: number;
make_offer_status: 'disabled' | 'enabled';
};
}>;
setOfferToggleStatus: ApiShopMethod<{
make_offer_status: 'disabled' | 'enabled';
}, {
response: {};
}>;
/**
* can only support "jpg","jpeg","png","gif". The max size of the file is 2MB
*/
uploadImage: (data: {
file: FormData;
} & ShopReq) => Promise<AxiosResponse<{
response: {
url: string;
thumbnail: string;
file_server_id?: number;
thumb_height?: number;
thumb_width?: number;
url_hash?: string;
};
} & BaseRes>>;
sendAutoreplyMessage: ApiShopMethod<{
to_id: number;
content: {
text: string;
};
}, {
response: {
message_id: string;
to_id: number;
message_type: string;
content: {
text: string;
};
conversation_id: string;
created_timestamp: number;
message_option: number;
source_content: {};
};
}>;
}