Skip to content

Commit

Permalink
feat: Added support to options in send status (#2096)
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Mar 7, 2024
1 parent 79a10c0 commit 1aa0735
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/api/layers/status.layer.ts
Expand Up @@ -24,6 +24,7 @@ import {
fileToBase64,
downloadFileToBase64,
} from '../helpers';
import { SendStatusOptions } from '@wppconnect/wa-js/dist/status';

export class StatusLayer extends LabelsLayer {
constructor(public page: Page, session?: string, options?: CreateConfig) {
Expand All @@ -37,9 +38,18 @@ export class StatusLayer extends LabelsLayer {
* ```javascript
* client.sendImageStatus('data:image/jpeg;base64,<a long base64 file...>');
* ```
*
* @example
* ```javascript
* // Send with caption
* client.sendImageStatus('data:image/jpeg;base64,<a long base64 file...>', { caption: 'example test' } );
* ```
* @param pathOrBase64 Path or base 64 image
*/
public async sendImageStatus(pathOrBase64: string) {
public async sendImageStatus(
pathOrBase64: string,
options?: SendStatusOptions & { caption?: string }
) {
let base64: string = '';
if (pathOrBase64.startsWith('data:')) {
base64 = pathOrBase64;
Expand Down Expand Up @@ -81,7 +91,7 @@ export class StatusLayer extends LabelsLayer {
return await evaluateAndReturn(
this.page,
({ base64 }) => {
WPP.status.sendImageStatus(base64);
WPP.status.sendImageStatus(base64, options);
},
{ base64 }
);
Expand All @@ -94,9 +104,17 @@ export class StatusLayer extends LabelsLayer {
* ```javascript
* client.sendVideoStatus('data:video/mp4;base64,<a long base64 file...>');
* ```
* @example
* ```javascript
* // Send with caption
* client.sendVideoStatus('data:video/mp4;base64,<a long base64 file...>', { caption: 'example test' } );
* ```
* @param pathOrBase64 Path or base 64 image
*/
public async sendVideoStatus(pathOrBase64: string) {
public async sendVideoStatus(
pathOrBase64: string,
options?: SendStatusOptions & { caption?: string }
) {
let base64: string = '';
if (pathOrBase64.startsWith('data:')) {
base64 = pathOrBase64;
Expand All @@ -121,7 +139,7 @@ export class StatusLayer extends LabelsLayer {
return await evaluateAndReturn(
this.page,
({ base64 }) => {
WPP.status.sendVideoStatus(base64);
WPP.status.sendVideoStatus(base64, options);
},
{ base64 }
);
Expand Down

0 comments on commit 1aa0735

Please sign in to comment.