UNPKG

@azure/communication-sms

Version:

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

99 lines 3.46 kB
/* * 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. */ import { tracingClient } from "../tracing.js"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers.js"; import * as Parameters from "../models/parameters.js"; /** Class containing OptOuts operations. */ export 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 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 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 tracingClient.withSpan("SmsApiClient.check", options !== null && options !== void 0 ? options : {}, async (options) => { return this.client.sendOperationRequest({ body, options }, checkOperationSpec); }); } } // 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