UNPKG

@azure/communication-sms

Version:

SDK for Azure Communication SMS service which facilitates the sending of SMS messages.

104 lines 3.73 kB
"use strict"; /* * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.OptOutsImpl = void 0; const tslib_1 = require("tslib"); const tracing_js_1 = require("../tracing.js"); const coreClient = tslib_1.__importStar(require("@azure/core-client")); const Mappers = tslib_1.__importStar(require("../models/mappers.js")); const Parameters = tslib_1.__importStar(require("../models/parameters.js")); /** Class containing OptOuts operations. */ class OptOutsImpl { /** * Initialize a new instance of the class OptOuts class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Add phone numbers to the optouts list which shall stop receiving messages from a sender number. * @param body An opt out request. * @param options The options parameters. */ async add(body, options) { return tracing_js_1.tracingClient.withSpan("SmsApiClient.add", options !== null && options !== void 0 ? options : {}, async (options) => { return this.client.sendOperationRequest({ body, options }, addOperationSpec); }); } /** * Remove phone numbers from the optouts list. * @param body An opt out request. * @param options The options parameters. */ async remove(body, options) { return tracing_js_1.tracingClient.withSpan("SmsApiClient.remove", options !== null && options !== void 0 ? options : {}, async (options) => { return this.client.sendOperationRequest({ body, options }, removeOperationSpec); }); } /** * Check the opt out status for a recipient phone number with a sender phone number. * @param body An opt out request. * @param options The options parameters. */ async check(body, options) { return tracing_js_1.tracingClient.withSpan("SmsApiClient.check", options !== null && options !== void 0 ? options : {}, async (options) => { return this.client.sendOperationRequest({ body, options }, checkOperationSpec); }); } } exports.OptOutsImpl = OptOutsImpl; // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const addOperationSpec = { path: "/sms/optouts:add", httpMethod: "POST", responses: { 200: { bodyMapper: Mappers.OptOutResponse, }, }, requestBody: Parameters.body, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint], headerParameters: [Parameters.contentType, Parameters.accept], mediaType: "json", serializer, }; const removeOperationSpec = { path: "/sms/optouts:remove", httpMethod: "POST", responses: { 200: { bodyMapper: Mappers.OptOutResponse, }, }, requestBody: Parameters.body, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint], headerParameters: [Parameters.contentType, Parameters.accept], mediaType: "json", serializer, }; const checkOperationSpec = { path: "/sms/optouts:check", httpMethod: "POST", responses: { 200: { bodyMapper: Mappers.OptOutResponse, }, }, requestBody: Parameters.body, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.endpoint], headerParameters: [Parameters.contentType, Parameters.accept], mediaType: "json", serializer, }; //# sourceMappingURL=optOuts.js.map