Skip to content

Commit

Permalink
feat: Added WPP.profile.editBusinessProfile function
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta authored and edgardmessias committed Aug 10, 2022
1 parent 5c8e57a commit 30f18b2
Show file tree
Hide file tree
Showing 5 changed files with 231 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/contact/functions/index.ts
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

export { getProfilePictureUrl } from './getProfilePictureUrl';
export { getBusinessProfile } from './getBusinessProfile';
export { getProfilePictureUrl } from './getProfilePictureUrl';
export { getStatus } from './getStatus';
export { ContactListOptions, list } from './list';
export { queryExists } from './queryExists';
195 changes: 195 additions & 0 deletions src/profile/functions/editBusinessProfile.ts
@@ -0,0 +1,195 @@
/*!
* Copyright 2021 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {
BusinessProfileModel,
BusinessProfileStore,
Conn,
UserPrefs,
} from '../../whatsapp';
import { editBusinessProfile as editProfile } from '../../whatsapp/functions';

/**
* Update your business profile
*
* @example
* ```javascript
* await WPP.profile.editBusinessProfile({description: 'New description for profile'});
* ```
*
* ```javascript
* await WPP.profile.editBusinessProfile({categories: {
id: "133436743388217",
localized_display_name: "Artes e entretenimento",
not_a_biz: false,
}});
* ```
*
* ```javascript
* await WPP.profile.editBusinessProfile({adress: 'Street 01, New York'});
* ```
*
* ```javascript
* await WPP.profile.editBusinessProfile({adress: 'Street 01, New York'});
* ```
*
* ```javascript
* await WPP.profile.editBusinessProfile({email: 'test@test.com.br'});
* ```
*
* Change website of profile (max 2 sites)
* ```javascript
* await WPP.profile.editBusinessProfile({website: [
"https://www.wppconnect.io",
"https://www.teste2.com.br",
]});
* ```
*
* Change businessHours for Specific Hours
* ```javascript
* await WPP.profile.editBusinessProfile({ businessHours: {
* {
tue: {
mode: "specific_hours",
hours: [
[
540,
1080,
],
],
},
wed: {
mode: "specific_hours",
hours: [
[
540,
1080,
],
],
},
thu: {
mode: "specific_hours",
hours: [
[
540,
1080,
],
],
},
fri: {
mode: "specific_hours",
hours: [
[
540,
1080,
],
],
},
sat: {
mode: "specific_hours",
hours: [
[
540,
1080,
],
],
},
sun: {
mode: "specific_hours",
hours: [
[
540,
1080,
],
],
},
}
},
timezone: "America/Sao_Paulo"
});
*
* Change businessHours for Always Opened
* ```javascript
* await WPP.profile.editBusinessProfile({ businessHours: {
{
mon: {
mode: "open_24h",
},
tue: {
mode: "open_24h",
},
wed: {
mode: "open_24h",
},
thu: {
mode: "open_24h",
},
fri: {
mode: "open_24h",
},
sat: {
mode: "open_24h",
},
sun: {
mode: "open_24h",
},
}
timezone: "America/Sao_Paulo"
});
*
* Change businessHours for Appointment Only
* ```javascript
* await WPP.profile.editBusinessProfile({ businessHours: { {
mon: {
mode: "appointment_only",
},
tue: {
mode: "appointment_only",
},
wed: {
mode: "appointment_only",
},
thu: {
mode: "appointment_only",
},
fri: {
mode: "appointment_only",
},
sat: {
mode: "appointment_only",
},
sun: {
mode: "appointment_only",
},
}
timezone: "America/Sao_Paulo"
});
*
*
* ```
* @category Profile
*/

export async function editBusinessProfile(params: BusinessProfileModel) {
if (!Conn.isSMB) {
return;
}
await editProfile(params);
const profile = await BusinessProfileStore.fetchBizProfile(
UserPrefs.getMaybeMeUser()
);
return profile;
}
1 change: 1 addition & 0 deletions src/profile/functions/index.ts
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

export { editBusinessProfile } from './editBusinessProfile';
export { getMyStatus } from './getMyStatus';
export { isBusiness } from './isBusiness';
export { setMyProfilePicture } from './setMyProfilePicture';
Expand Down
33 changes: 33 additions & 0 deletions src/whatsapp/functions/editBusinessProfile.ts
@@ -0,0 +1,33 @@
/*!
* Copyright 2021 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { exportModule } from '../exportModule';
import { BusinessProfileModel } from '../models';

/**
* @whatsapp 461561
*/
export declare function editBusinessProfile(
arguments: BusinessProfileModel
): Promise<any>;

exportModule(
exports,
{
editBusinessProfile: 'editBusinessProfile',
},
(m) => m.editBusinessProfile
);
1 change: 1 addition & 0 deletions src/whatsapp/functions/index.ts
Expand Up @@ -18,6 +18,7 @@ export * from './addAndSendMsgToChat';
export * from './blockContact';
export * from './createMsgProtobuf';
export * from './createOrUpdateReactions';
export * from './editBusinessProfile';
export * from './encodeMaybeMediaType';
export * from './encryptAndSendGroupMsg';
export * from './encryptAndSendMsg';
Expand Down

0 comments on commit 30f18b2

Please sign in to comment.