ContactMemberCreate
Register a new contact in the phone book
{{:: 'controllers.documentation.chooseFramework' | translate }}
npm install --save
niksms.library.javascript
import { ApiV2, ApiV2ContactMember,
LibOperationResultStatus,
} from 'niksms';
export default class NikSmsApiV2Client{
private service: ApiV2
constructor(username: string, password: string){
this.service = new ApiV2(username, password);
}
public async ContactMemberCreate(): Promise<ApiV2ContactMember> {
const member = <ApiV2ContactMember>{
BirthDate: new Date(1986, 5, 13),
Description: "Contact description",
Email: "contact email",
FullName: "contact first and last name",
GroupId: groupId,
Male: isContactMale,
Married: isContactMarried,
Mobile: "contact mobile number",
State: "contact state name"
};
const result = await this.service.ContactMemberCreate(member);
switch (result.Status)
{
case LibOperationResultStatus.Success:
return result.Data;
case LibOperationResultStatus.InvalidModel:
throw new Error("Some required inputs are misssing...");
case LibOperationResultStatus.UnAuthorized:
throw new Error("Some thing is wrong with your account (call support!)");
case LibOperationResultStatus.Failed:
throw new Error("Ooops its our fault!");
default:
throw new Error("You sould not be here... :D");
}
}
}