mnotify-ts-sdk
Version:
Third-Party TypeScript SDK for mNotify BMS API
48 lines • 1.92 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContactService = void 0;
const zod_1 = require("zod");
const ContactSchema = zod_1.z.object({
_id: zod_1.z.string(),
phone: zod_1.z.string(),
title: zod_1.z.string().optional(),
firstname: zod_1.z.string(),
lastname: zod_1.z.string(),
email: zod_1.z.array(zod_1.z.string()).optional(),
dbo: zod_1.z.string().optional(),
});
class ContactService {
constructor(client) {
this.client = client;
}
createContact(contact) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.client.request({
method: 'POST',
url: '/contacts',
data: contact
});
return ContactSchema.parse(response);
});
}
getContacts() {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.client.request({
method: 'GET',
url: '/contacts'
});
return zod_1.z.array(ContactSchema).parse(response);
});
}
}
exports.ContactService = ContactService;
//# sourceMappingURL=ContactService.js.map