Skip to content

Commit

Permalink
Apply formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
domwebber committed Nov 20, 2024
1 parent 27c00af commit dc48302
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 25 deletions.
17 changes: 11 additions & 6 deletions src/BusinessProfile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
*/

import ky, { Options as KyOptions } from "ky";
import {
GetBusinessProfileFields,
GetBusinessProfileOptions,
GetBusinessProfilePayload,
UpdateBusinessProfileOptions,
UpdateBusinessProfilePayload,
} from "../types/BusinessProfile/index.js";
import { PhoneNumberID } from "../types/PhoneNumber.js";
import { GetBusinessProfileFields, GetBusinessProfileOptions, GetBusinessProfilePayload, UpdateBusinessProfileOptions, UpdateBusinessProfilePayload } from "../types/BusinessProfile/index.js";

interface MethodOptions {
request?: KyOptions;
Expand All @@ -30,7 +36,9 @@ export default class BusinessProfile {
...this._request,
method: "GET",
searchParams: {
fields: Object.entries(fields ?? {}).map(([key]) => key).join(","),
fields: Object.entries(fields ?? {})
.map(([key]) => key)
.join(","),
},
})<GetBusinessProfilePayload<Fields>>(
this.getEndpoint(phoneNumberID),
Expand All @@ -50,9 +58,6 @@ export default class BusinessProfile {
messaging_product: "whatsapp",
...json,
},
})<UpdateBusinessProfilePayload>(
this.getEndpoint(phoneNumberID),
request,
);
})<UpdateBusinessProfilePayload>(this.getEndpoint(phoneNumberID), request);
}
}
48 changes: 29 additions & 19 deletions src/types/BusinessProfile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @see https://greatdetail.com
*/

import { PhoneNumberID } from "../PhoneNumber.js"
import { PhoneNumberID } from "../PhoneNumber.js";

export type GetBusinessProfileFields = {
about?: boolean;
Expand All @@ -18,24 +18,34 @@ export type GetBusinessProfileFields = {
vertical?: boolean;
};

export type GetBusinessProfileOptions<Fields extends GetBusinessProfileFields = object> = {
export type GetBusinessProfileOptions<
Fields extends GetBusinessProfileFields = object,
> = {
phoneNumberID: PhoneNumberID;
fields?: Fields;
}
};

export type GetBusinessProfilePayload<Fields extends GetBusinessProfileFields = object> = {
data: [{
about: Fields extends { about: true } ? string : undefined;
address: Fields extends { address: true } ? string : undefined;
description: Fields extends { description: true } ? string : undefined;
email: Fields extends { email: true } ? string : undefined;
messaging_product: "whatsapp";
profile_picture_url: Fields extends { profile_picture_url: true } ? string : undefined;
vertical: Fields extends { vertical: true }
? ("" | (string & NonNullable<unknown>))
: undefined;
websites: Fields extends { websites: true } ? ([string] | [string, string] | (string[] & NonNullable<unknown>)) : undefined;
}];
export type GetBusinessProfilePayload<
Fields extends GetBusinessProfileFields = object,
> = {
data: [
{
about: Fields extends { about: true } ? string : undefined;
address: Fields extends { address: true } ? string : undefined;
description: Fields extends { description: true } ? string : undefined;
email: Fields extends { email: true } ? string : undefined;
messaging_product: "whatsapp";
profile_picture_url: Fields extends { profile_picture_url: true }
? string
: undefined;
vertical: Fields extends { vertical: true }
? "" | (string & NonNullable<unknown>)
: undefined;
websites: Fields extends { websites: true }
? [string] | [string, string] | (string[] & NonNullable<unknown>)
: undefined;
},
];
};

export type UpdateBusinessProfileOptions = {
Expand All @@ -45,10 +55,10 @@ export type UpdateBusinessProfileOptions = {
description?: string;
email?: string;
profile_picture_handle?: string;
vertical?: ("" | (string & NonNullable<unknown>));
vertical?: "" | (string & NonNullable<unknown>);
websites?: [string] | [string, string] | (string[] & NonNullable<unknown>);
}
};

export type UpdateBusinessProfilePayload = {
success: boolean;
}
};

0 comments on commit dc48302

Please sign in to comment.