@shibacore/apis
Advanced tools
Comparing version 1.0.1 to 1.0.2
import { InteractionButtonComponent, InteractiveListComponent, LanguageCode, Media, PhoneNumberId, TemplateComponents, Location } from "./parameter-types"; | ||
import { HeaderOtions, ShibaApiBase, Version } from "./shiba-api-base"; | ||
import { HeaderOtions, ShibaApiBase, TokenType, Version } from "./shiba-api-base"; | ||
export declare class WhatsappMessages extends ShibaApiBase { | ||
private phoneNumberId; | ||
constructor(access_token: string, version: Version, phoneNumberId: PhoneNumberId, headerOptions?: HeaderOtions); | ||
constructor(access_token: string, version: Version, phoneNumberId: PhoneNumberId, headerOptions?: HeaderOtions, tokenType?: TokenType); | ||
template(to: string, templateName: string, language_code: LanguageCode, components?: TemplateComponents): Promise<any>; | ||
@@ -7,0 +7,0 @@ text(to: string, bodyText: string, preview_url?: boolean): Promise<any>; |
@@ -15,4 +15,4 @@ "use strict"; | ||
class WhatsappMessages extends shiba_api_base_1.ShibaApiBase { | ||
constructor(access_token, version, phoneNumberId, headerOptions) { | ||
super(access_token, version, headerOptions); | ||
constructor(access_token, version, phoneNumberId, headerOptions, tokenType) { | ||
super(access_token, version, headerOptions, tokenType); | ||
this.phoneNumberId = phoneNumberId; | ||
@@ -19,0 +19,0 @@ } |
@@ -1,8 +0,10 @@ | ||
import { Axios, HeadersDefaults } from "axios"; | ||
import { Axios, RawAxiosRequestHeaders } from "axios"; | ||
export type Version = `v${number}`; | ||
export type HeaderOtions = HeadersDefaults["options"]; | ||
export type HeaderOtions = RawAxiosRequestHeaders; | ||
export type TokenType = "Bearer" | "OAuth"; | ||
export declare abstract class ShibaApiBase { | ||
protected accessToken: string; | ||
protected readonly api: Axios; | ||
constructor(access_token: string, version: Version, headerOptions?: HeaderOtions); | ||
protected token_type: TokenType; | ||
constructor(access_token: string, version: Version, headerOptions?: HeaderOtions, tokenType?: TokenType); | ||
} |
@@ -9,5 +9,6 @@ "use strict"; | ||
class ShibaApiBase { | ||
constructor(access_token, version, headerOptions) { | ||
constructor(access_token, version, headerOptions = {}, tokenType = "Bearer") { | ||
this.accessToken = access_token; | ||
const headers = {}; | ||
this.token_type = tokenType; | ||
const headers = Object.assign({ "Content-Type": "application/json", Authorization: `${tokenType} ${access_token}` }, headerOptions); | ||
headers["Content-Type"] = "application/json"; | ||
@@ -19,3 +20,3 @@ if (headerOptions) { | ||
} | ||
headers.Authorization = `Bearer ${access_token}`; | ||
headers.Authorization = `${tokenType} ${access_token}`; | ||
this.api = axios_1.default.create({ | ||
@@ -22,0 +23,0 @@ baseURL: `https://graph.facebook.com/${version}`, |
{ | ||
"name": "@shibacore/apis", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./build/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13416
343