Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specifyBasePath: specify custom basePath #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions lib/MessageApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@ export type MessagesResponse = CMTypes.MessagesResponse;
export class MessageApiClient {

private readonly productToken: string;
private readonly basePath: string;

/**
* Create a new client instance with a provided authentication key
* @param productToken Private autorization token for CM.com
*/
constructor(productToken: string) {
constructor(productToken: string, basePath: string) {
this.productToken = productToken;
this.basePath = basePath;
}

/**
* Create a new message builder
*/
public createMessage() : Message {
return new Message(this.productToken);
return new Message(this.productToken, this.basePath);
}

/**
Expand All @@ -35,7 +37,7 @@ export class MessageApiClient {
public SendTextMessage(to: string, from: string, message: string, reference: string = undefined) {
return this.SendTextMessages([to], from, message, reference);
}

/**
* @deprecated use .sendTextMessages(...) instead
*/
Expand All @@ -45,9 +47,9 @@ export class MessageApiClient {

/**
* Send an SMS message
* @param to array of recipients for the message, specify the numbers in international format with leading 00
* @param to array of recipients for the message, specify the numbers in international format with leading 00
* For Twitter: use the Twitter Snowflake ID
* @param from the sender of the message, specify valid Sender ID.
* @param from the sender of the message, specify valid Sender ID.
* For Twitter: use the Twitter Snowflake ID of the account you want to use as sender.
* @param message the body of the SMS message to be sent
* @param reference (optional) reference to the message to query it later in the CM.platform.
Expand All @@ -63,26 +65,26 @@ export class MessageApiClient {
* Message object to send via the CM.com platform
*/
export class Message extends CMTypes.MessageEnvelope {

private api: CMTypes.MessagesApi;

/**
* @deprecated Please use the MessageApiClient.createMessage instead.
*/
constructor(productToken: string) {
constructor(productToken: string, basePath: string) {
super();

this.api = new CMTypes.MessagesApi();
this.api = new CMTypes.MessagesApi(basePath);
this.messages = new CMTypes.Messages();
this.messages.authentication = new CMTypes.Authentication();
this.messages.authentication.productToken = productToken;
}

/**
* Sets the essential message parameters.
* @param to array of recipients for the message, specify the numbers in international format with leading 00.
* Sets the essential message parameters.
* @param to array of recipients for the message, specify the numbers in international format with leading 00.
* For Twitter: use the Twitter Snowflake ID
* @param from the sender of the message, specify valid Sender ID.
* @param from the sender of the message, specify valid Sender ID.
* For Twitter: use the Twitter Snowflake ID of the account you want to use as sender.
* @param message the body of the SMS message to be sent
* @param reference (optional) reference to the message to query it later in the CM.platform.
Expand All @@ -106,7 +108,7 @@ export class Message extends CMTypes.MessageEnvelope {

/**
* Sets the allowed channels to use. Default is to allow any channel configured for your account
* @param channels array of allowed channels.
* @param channels array of allowed channels.
* Any of "SMS", "Viber", "RCS", "Apple Business Chat", "WhatsApp" and "Twitter"
*/
public setAllowedChannels(channels: Channel[]): Message {
Expand All @@ -115,7 +117,7 @@ export class Message extends CMTypes.MessageEnvelope {
}

/**
* Sets the rich message conversation
* Sets the rich message conversation
* @param conversation array of rich message conversation objects
*/
public setConversation(conversation: RichMessage[]): Message {
Expand All @@ -124,7 +126,7 @@ export class Message extends CMTypes.MessageEnvelope {
}

/**
* Sets the rich message suggestions
* Sets the rich message suggestions
* @param conversation array of rich message suggestion objects
*/
public setSuggestion(suggestions: Suggestion[]): Message {
Expand All @@ -133,7 +135,7 @@ export class Message extends CMTypes.MessageEnvelope {
}

/**
* Sets the rich message template
* Sets the rich message template
* @param template template definition and usage object
*/
public setTemplate(template: Template): Message {
Expand All @@ -142,7 +144,7 @@ export class Message extends CMTypes.MessageEnvelope {
}

/**
* Sends the message to the CM.com Platform
* Sends the message to the CM.com Platform
*/
public send(): Promise<{ body: MessagesResponse; response: http.IncomingMessage }> {
return this.api.messagesSendMessage(this);
Expand Down
6 changes: 3 additions & 3 deletions typescript-node-client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version: v1
*
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
Expand Down Expand Up @@ -1880,9 +1880,9 @@ export class MessagesApi {
(this.authentications as any)[MessagesApiApiKeys[key]].apiKey = value;
}
/**
*
*
* @summary CM's Messaging Gateway enables you to send text messages to mobile phones all around the world in very high volume. The Messaging Gateway API covers the interface between your application and the CM Platform by means of the HTTP protocol. Only bulk (free of charge for the end user) text messages are supported.
* @param message
* @param message
* @param {*} [options] Override http request options.
*/
public messagesSendMessage (message: MessageEnvelope, options: any = {}) : Promise<{ response: http.IncomingMessage; body: MessagesResponse; }> {
Expand Down