This commit is contained in:
parent
c96686fba1
commit
e22013331d
|
|
@ -53,16 +53,23 @@ export declare class WechatPublicInstance {
|
|||
gender: string | undefined;
|
||||
avatar: string;
|
||||
}>;
|
||||
createTag(tag: {
|
||||
createTag(params: {
|
||||
name: string;
|
||||
}): Promise<any>;
|
||||
getTags(): Promise<any>;
|
||||
editTag(tag: {}): Promise<void>;
|
||||
editTag(tag: {
|
||||
id: number;
|
||||
name: string;
|
||||
}): Promise<any>;
|
||||
deleteTag(tag: {
|
||||
id: number;
|
||||
}): Promise<any>;
|
||||
getCurrentMenu(): Promise<any>;
|
||||
getMenu(): Promise<any>;
|
||||
createMenu(menuConfig: any): Promise<any>;
|
||||
createConditionalMenu(menuConfig: any): Promise<any>;
|
||||
deleteConditionalMenu(menuId: number): Promise<any>;
|
||||
deleteMenu(): Promise<any>;
|
||||
private refreshAccessToken;
|
||||
getQrCode(options: {
|
||||
sceneId?: number;
|
||||
|
|
|
|||
|
|
@ -131,18 +131,18 @@ export class WechatPublicInstance {
|
|||
avatar: headimgurl,
|
||||
};
|
||||
}
|
||||
async createTag(tag) {
|
||||
async createTag(params) {
|
||||
const myInit = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ tag }),
|
||||
body: JSON.stringify({ tag: params }),
|
||||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/tags/create?access_token=${token}`, undefined, myInit);
|
||||
const { errcode } = result;
|
||||
if (errcode === 0) {
|
||||
const { tag } = result;
|
||||
if (tag) {
|
||||
return Object.assign({ success: true }, result);
|
||||
}
|
||||
return Object.assign({ success: false }, result);
|
||||
|
|
@ -158,7 +158,32 @@ export class WechatPublicInstance {
|
|||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/tags/get?access_token=${token}`, undefined, myInit);
|
||||
return result;
|
||||
}
|
||||
async editTag(tag) { }
|
||||
async editTag(tag) {
|
||||
const myInit = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ tag }),
|
||||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/tags/update?access_token=${token}`, undefined, myInit);
|
||||
return result;
|
||||
;
|
||||
}
|
||||
async deleteTag(tag) {
|
||||
const myInit = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ tag }),
|
||||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=${token}`, undefined, myInit);
|
||||
return result;
|
||||
;
|
||||
}
|
||||
async getCurrentMenu() {
|
||||
const myInit = {
|
||||
method: 'GET',
|
||||
|
|
@ -191,11 +216,7 @@ export class WechatPublicInstance {
|
|||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/menu/create?access_token=${token}`, undefined, myInit);
|
||||
const { errcode } = result;
|
||||
if (errcode === 0) {
|
||||
return Object.assign({ success: true }, result);
|
||||
}
|
||||
return Object.assign({ success: false }, result);
|
||||
return result;
|
||||
}
|
||||
async createConditionalMenu(menuConfig) {
|
||||
const myInit = {
|
||||
|
|
@ -207,11 +228,7 @@ export class WechatPublicInstance {
|
|||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token=${token}`, undefined, myInit);
|
||||
const { errcode } = result;
|
||||
if (errcode === 0) {
|
||||
return Object.assign({ success: true }, result);
|
||||
}
|
||||
return Object.assign({ success: false }, result);
|
||||
return result;
|
||||
}
|
||||
async deleteConditionalMenu(menuId) {
|
||||
const myInit = {
|
||||
|
|
@ -225,11 +242,15 @@ export class WechatPublicInstance {
|
|||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/menu/delconditional?access_token=${token}`, undefined, myInit);
|
||||
const { errcode } = result;
|
||||
if (errcode === 0) {
|
||||
return Object.assign({ success: true }, result);
|
||||
}
|
||||
return Object.assign({ success: false }, result);
|
||||
return result;
|
||||
}
|
||||
async deleteMenu() {
|
||||
const myInit = {
|
||||
method: 'GET',
|
||||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=${token}`, undefined, myInit);
|
||||
return result;
|
||||
}
|
||||
async refreshAccessToken(url, init) {
|
||||
const result = this.externalRefreshFn
|
||||
|
|
|
|||
|
|
@ -53,16 +53,23 @@ export declare class WechatPublicInstance {
|
|||
gender: string | undefined;
|
||||
avatar: string;
|
||||
}>;
|
||||
createTag(tag: {
|
||||
createTag(params: {
|
||||
name: string;
|
||||
}): Promise<any>;
|
||||
getTags(): Promise<any>;
|
||||
editTag(tag: {}): Promise<void>;
|
||||
editTag(tag: {
|
||||
id: number;
|
||||
name: string;
|
||||
}): Promise<any>;
|
||||
deleteTag(tag: {
|
||||
id: number;
|
||||
}): Promise<any>;
|
||||
getCurrentMenu(): Promise<any>;
|
||||
getMenu(): Promise<any>;
|
||||
createMenu(menuConfig: any): Promise<any>;
|
||||
createConditionalMenu(menuConfig: any): Promise<any>;
|
||||
deleteConditionalMenu(menuId: number): Promise<any>;
|
||||
deleteMenu(): Promise<any>;
|
||||
private refreshAccessToken;
|
||||
getQrCode(options: {
|
||||
sceneId?: number;
|
||||
|
|
|
|||
|
|
@ -135,18 +135,18 @@ class WechatPublicInstance {
|
|||
avatar: headimgurl,
|
||||
};
|
||||
}
|
||||
async createTag(tag) {
|
||||
async createTag(params) {
|
||||
const myInit = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ tag }),
|
||||
body: JSON.stringify({ tag: params }),
|
||||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/tags/create?access_token=${token}`, undefined, myInit);
|
||||
const { errcode } = result;
|
||||
if (errcode === 0) {
|
||||
const { tag } = result;
|
||||
if (tag) {
|
||||
return Object.assign({ success: true }, result);
|
||||
}
|
||||
return Object.assign({ success: false }, result);
|
||||
|
|
@ -162,7 +162,32 @@ class WechatPublicInstance {
|
|||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/tags/get?access_token=${token}`, undefined, myInit);
|
||||
return result;
|
||||
}
|
||||
async editTag(tag) { }
|
||||
async editTag(tag) {
|
||||
const myInit = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ tag }),
|
||||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/tags/update?access_token=${token}`, undefined, myInit);
|
||||
return result;
|
||||
;
|
||||
}
|
||||
async deleteTag(tag) {
|
||||
const myInit = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ tag }),
|
||||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=${token}`, undefined, myInit);
|
||||
return result;
|
||||
;
|
||||
}
|
||||
async getCurrentMenu() {
|
||||
const myInit = {
|
||||
method: 'GET',
|
||||
|
|
@ -195,11 +220,7 @@ class WechatPublicInstance {
|
|||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/menu/create?access_token=${token}`, undefined, myInit);
|
||||
const { errcode } = result;
|
||||
if (errcode === 0) {
|
||||
return Object.assign({ success: true }, result);
|
||||
}
|
||||
return Object.assign({ success: false }, result);
|
||||
return result;
|
||||
}
|
||||
async createConditionalMenu(menuConfig) {
|
||||
const myInit = {
|
||||
|
|
@ -211,11 +232,7 @@ class WechatPublicInstance {
|
|||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token=${token}`, undefined, myInit);
|
||||
const { errcode } = result;
|
||||
if (errcode === 0) {
|
||||
return Object.assign({ success: true }, result);
|
||||
}
|
||||
return Object.assign({ success: false }, result);
|
||||
return result;
|
||||
}
|
||||
async deleteConditionalMenu(menuId) {
|
||||
const myInit = {
|
||||
|
|
@ -229,11 +246,15 @@ class WechatPublicInstance {
|
|||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/menu/delconditional?access_token=${token}`, undefined, myInit);
|
||||
const { errcode } = result;
|
||||
if (errcode === 0) {
|
||||
return Object.assign({ success: true }, result);
|
||||
}
|
||||
return Object.assign({ success: false }, result);
|
||||
return result;
|
||||
}
|
||||
async deleteMenu() {
|
||||
const myInit = {
|
||||
method: 'GET',
|
||||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(`https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=${token}`, undefined, myInit);
|
||||
return result;
|
||||
}
|
||||
async refreshAccessToken(url, init) {
|
||||
const result = this.externalRefreshFn
|
||||
|
|
|
|||
|
|
@ -205,13 +205,13 @@ export class WechatPublicInstance {
|
|||
};
|
||||
}
|
||||
|
||||
async createTag(tag: { name: string }) {
|
||||
async createTag(params: { name: string }) {
|
||||
const myInit = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ tag }),
|
||||
body: JSON.stringify({ tag: params }),
|
||||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(
|
||||
|
|
@ -219,8 +219,8 @@ export class WechatPublicInstance {
|
|||
undefined,
|
||||
myInit
|
||||
);
|
||||
const { errcode } = result;
|
||||
if (errcode === 0) {
|
||||
const { tag } = result;
|
||||
if (tag) {
|
||||
return Object.assign({ success: true }, result);
|
||||
}
|
||||
return Object.assign({ success: false }, result);
|
||||
|
|
@ -242,7 +242,39 @@ export class WechatPublicInstance {
|
|||
return result;
|
||||
}
|
||||
|
||||
async editTag(tag: {}) {}
|
||||
async editTag(tag: { id: number, name: string }) {
|
||||
const myInit = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ tag }),
|
||||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(
|
||||
`https://api.weixin.qq.com/cgi-bin/tags/update?access_token=${token}`,
|
||||
undefined,
|
||||
myInit
|
||||
);
|
||||
return result;;
|
||||
}
|
||||
|
||||
async deleteTag(tag: { id: number }) {
|
||||
const myInit = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ tag }),
|
||||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(
|
||||
`https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=${token}`,
|
||||
undefined,
|
||||
myInit
|
||||
);
|
||||
return result;;
|
||||
}
|
||||
|
||||
async getCurrentMenu() {
|
||||
const myInit = {
|
||||
|
|
@ -290,11 +322,7 @@ export class WechatPublicInstance {
|
|||
undefined,
|
||||
myInit
|
||||
);
|
||||
const { errcode } = result;
|
||||
if (errcode === 0) {
|
||||
return Object.assign({ success: true }, result);
|
||||
}
|
||||
return Object.assign({ success: false }, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
async createConditionalMenu(menuConfig: any) {
|
||||
|
|
@ -311,11 +339,7 @@ export class WechatPublicInstance {
|
|||
undefined,
|
||||
myInit
|
||||
);
|
||||
const { errcode } = result;
|
||||
if (errcode === 0) {
|
||||
return Object.assign({ success: true }, result);
|
||||
}
|
||||
return Object.assign({ success: false }, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
async deleteConditionalMenu(menuId: number) {
|
||||
|
|
@ -334,11 +358,20 @@ export class WechatPublicInstance {
|
|||
undefined,
|
||||
myInit
|
||||
);
|
||||
const { errcode } = result;
|
||||
if (errcode === 0) {
|
||||
return Object.assign({ success: true }, result);
|
||||
}
|
||||
return Object.assign({ success: false }, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
async deleteMenu() {
|
||||
const myInit = {
|
||||
method: 'GET',
|
||||
};
|
||||
const token = await this.getAccessToken();
|
||||
const result = await this.access(
|
||||
`https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=${token}`,
|
||||
undefined,
|
||||
myInit
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
private async refreshAccessToken(url?: string, init?: RequestInit) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue