@azure/communication-sms 1.2.0-alpha.20250618.1 → 1.2.0-alpha.20250723.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/extractOperationOptions.js +1 -2
- package/dist/browser/extractOperationOptions.js.map +1 -1
- package/dist/browser/generated/src/operations/optOuts.js +4 -3
- package/dist/browser/generated/src/operations/optOuts.js.map +1 -1
- package/dist/browser/generated/src/operations/sms.js +2 -1
- package/dist/browser/generated/src/operations/sms.js.map +1 -1
- package/dist/browser/generated/src/smsApiClient.js +11 -3
- package/dist/browser/generated/src/smsApiClient.js.map +1 -1
- package/dist/browser/optOutsClient.js +5 -7
- package/dist/browser/optOutsClient.js.map +1 -1
- package/dist/browser/smsClient.js +13 -4
- package/dist/browser/smsClient.js.map +1 -1
- package/dist/browser/utils/smsUtils.js +6 -3
- package/dist/browser/utils/smsUtils.js.map +1 -1
- package/dist/commonjs/extractOperationOptions.js +1 -2
- package/dist/commonjs/extractOperationOptions.js.map +1 -1
- package/dist/commonjs/generated/src/operations/optOuts.js +4 -3
- package/dist/commonjs/generated/src/operations/optOuts.js.map +1 -1
- package/dist/commonjs/generated/src/operations/sms.js +2 -1
- package/dist/commonjs/generated/src/operations/sms.js.map +1 -1
- package/dist/commonjs/generated/src/smsApiClient.js +11 -3
- package/dist/commonjs/generated/src/smsApiClient.js.map +1 -1
- package/dist/commonjs/optOutsClient.js +5 -7
- package/dist/commonjs/optOutsClient.js.map +1 -1
- package/dist/commonjs/smsClient.js +13 -4
- package/dist/commonjs/smsClient.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/commonjs/utils/smsUtils.js +6 -3
- package/dist/commonjs/utils/smsUtils.js.map +1 -1
- package/dist/esm/extractOperationOptions.js +1 -2
- package/dist/esm/extractOperationOptions.js.map +1 -1
- package/dist/esm/generated/src/operations/optOuts.js +4 -3
- package/dist/esm/generated/src/operations/optOuts.js.map +1 -1
- package/dist/esm/generated/src/operations/sms.js +2 -1
- package/dist/esm/generated/src/operations/sms.js.map +1 -1
- package/dist/esm/generated/src/smsApiClient.js +11 -3
- package/dist/esm/generated/src/smsApiClient.js.map +1 -1
- package/dist/esm/optOutsClient.js +5 -7
- package/dist/esm/optOutsClient.js.map +1 -1
- package/dist/esm/smsClient.js +13 -4
- package/dist/esm/smsClient.js.map +1 -1
- package/dist/esm/utils/smsUtils.js +6 -3
- package/dist/esm/utils/smsUtils.js.map +1 -1
- package/dist/react-native/extractOperationOptions.js +1 -2
- package/dist/react-native/extractOperationOptions.js.map +1 -1
- package/dist/react-native/generated/src/operations/optOuts.js +4 -3
- package/dist/react-native/generated/src/operations/optOuts.js.map +1 -1
- package/dist/react-native/generated/src/operations/sms.js +2 -1
- package/dist/react-native/generated/src/operations/sms.js.map +1 -1
- package/dist/react-native/generated/src/smsApiClient.js +11 -3
- package/dist/react-native/generated/src/smsApiClient.js.map +1 -1
- package/dist/react-native/optOutsClient.js +5 -7
- package/dist/react-native/optOutsClient.js.map +1 -1
- package/dist/react-native/smsClient.js +13 -4
- package/dist/react-native/smsClient.js.map +1 -1
- package/dist/react-native/utils/smsUtils.js +6 -3
- package/dist/react-native/utils/smsUtils.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smsApiClient.js","sourceRoot":"","sources":["../../../../src/generated/src/smsApiClient.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,uEAAiD;AAMjD,oDAA6D;AAI7D,MAAa,YAAa,SAAQ,UAAU,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"smsApiClient.js","sourceRoot":"","sources":["../../../../src/generated/src/smsApiClient.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,uEAAiD;AAMjD,oDAA6D;AAI7D,MAAa,YAAa,SAAQ,UAAU,CAAC,aAAa;IACxD,QAAQ,CAAS;IACjB,UAAU,CAAS;IAEnB;;;;OAIG;I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AAgB,GAAG;YACvB,IAAI,EAAE,wBAAwB;YAC9B,KAAK,CAAC,WAAW,CACf,OAAwB,EACxB,IAAiB;gBAEjB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACrC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACrB,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;wBACjD,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;4BACrC,OAAO,cAAc,GAAG,UAAU,CAAC;wBACrC,CAAC;6BAAM,CAAC;4BACN,OAAO,IAAI,CAAC;wBACd,CAAC;oBACH,CAAC,CAAC,CAAC;oBACH,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACrD,CAAC;gBACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;SACF,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,GAAG,CAAM;IACT,OAAO,CAAU;CAClB;AA7ED,oCA6EC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport {\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { SmsImpl, OptOutsImpl } from \"./operations/index.js\";\nimport { Sms, OptOuts } from \"./operationsInterfaces/index.js\";\nimport { SmsApiClientOptionalParams } from \"./models/index.js\";\n\nexport class SmsApiClient extends coreClient.ServiceClient {\n endpoint: string;\n apiVersion: string;\n\n /**\n * Initializes a new instance of the SmsApiClient class.\n * @param endpoint The communication resource, for example https://my-resource.communication.azure.com\n * @param options The parameter options\n */\n constructor(endpoint: string, options?: SmsApiClientOptionalParams) {\n if (endpoint === undefined) {\n throw new Error(\"'endpoint' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: SmsApiClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\",\n };\n\n const packageDetails = `azsdk-js-communication-sms/1.2.0-beta.4`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n endpoint: options.endpoint ?? options.baseUri ?? \"{endpoint}\",\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.endpoint = endpoint;\n\n // Assigning values to Constant parameters\n this.apiVersion = options.apiVersion || \"2025-05-29-preview\";\n this.sms = new SmsImpl(this);\n this.optOuts = new OptOutsImpl(this);\n this.addCustomApiVersionPolicy(options.apiVersion);\n }\n\n /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */\n private addCustomApiVersionPolicy(apiVersion?: string) {\n if (!apiVersion) {\n return;\n }\n const apiVersionPolicy = {\n name: \"CustomApiVersionPolicy\",\n async sendRequest(\n request: PipelineRequest,\n next: SendRequest,\n ): Promise<PipelineResponse> {\n const param = request.url.split(\"?\");\n if (param.length > 1) {\n const newParams = param[1].split(\"&\").map((item) => {\n if (item.indexOf(\"api-version\") > -1) {\n return \"api-version=\" + apiVersion;\n } else {\n return item;\n }\n });\n request.url = param[0] + \"?\" + newParams.join(\"&\");\n }\n return next(request);\n },\n };\n this.pipeline.addPolicy(apiVersionPolicy);\n }\n\n sms: Sms;\n optOuts: OptOuts;\n}\n"]}
|
|
@@ -11,6 +11,7 @@ const extractOperationOptions_js_1 = require("./extractOperationOptions.js");
|
|
|
11
11
|
* to call Opt Out Management Api methods.
|
|
12
12
|
*/
|
|
13
13
|
class OptOutsClient {
|
|
14
|
+
api;
|
|
14
15
|
constructor(api) {
|
|
15
16
|
this.api = api;
|
|
16
17
|
}
|
|
@@ -26,11 +27,10 @@ class OptOutsClient {
|
|
|
26
27
|
return tracing_js_1.tracingClient.withSpan("OptOuts-Remove", operationOptions, async (updatedOptions) => {
|
|
27
28
|
const response = await this.api.optOuts.remove((0, smsUtils_js_1.generateOptOutRequest)(from, to), updatedOptions);
|
|
28
29
|
return response.value.map((optOutResponseItem) => {
|
|
29
|
-
var _a;
|
|
30
30
|
return {
|
|
31
31
|
to: optOutResponseItem.to,
|
|
32
32
|
httpStatusCode: optOutResponseItem.httpStatusCode,
|
|
33
|
-
errorMessage:
|
|
33
|
+
errorMessage: optOutResponseItem.errorMessage ?? "",
|
|
34
34
|
};
|
|
35
35
|
});
|
|
36
36
|
});
|
|
@@ -47,11 +47,10 @@ class OptOutsClient {
|
|
|
47
47
|
return tracing_js_1.tracingClient.withSpan("OptOuts-Add", operationOptions, async (updatedOptions) => {
|
|
48
48
|
const response = await this.api.optOuts.add((0, smsUtils_js_1.generateOptOutRequest)(from, to), updatedOptions);
|
|
49
49
|
return response.value.map((optOutResponseItem) => {
|
|
50
|
-
var _a;
|
|
51
50
|
return {
|
|
52
51
|
to: optOutResponseItem.to,
|
|
53
52
|
httpStatusCode: optOutResponseItem.httpStatusCode,
|
|
54
|
-
errorMessage:
|
|
53
|
+
errorMessage: optOutResponseItem.errorMessage ?? "",
|
|
55
54
|
};
|
|
56
55
|
});
|
|
57
56
|
});
|
|
@@ -68,12 +67,11 @@ class OptOutsClient {
|
|
|
68
67
|
return tracing_js_1.tracingClient.withSpan("OptOuts-Check", operationOptions, async (updatedOptions) => {
|
|
69
68
|
const response = await this.api.optOuts.check((0, smsUtils_js_1.generateOptOutRequest)(from, to), updatedOptions);
|
|
70
69
|
return response.value.map((optOutResponseItem) => {
|
|
71
|
-
var _a, _b;
|
|
72
70
|
return {
|
|
73
71
|
to: optOutResponseItem.to,
|
|
74
|
-
isOptedOut:
|
|
72
|
+
isOptedOut: optOutResponseItem.isOptedOut ?? false,
|
|
75
73
|
httpStatusCode: optOutResponseItem.httpStatusCode,
|
|
76
|
-
errorMessage:
|
|
74
|
+
errorMessage: optOutResponseItem.errorMessage ?? "",
|
|
77
75
|
};
|
|
78
76
|
});
|
|
79
77
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optOutsClient.js","sourceRoot":"","sources":["../../src/optOutsClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,2DAA2D;AAG3D,qDAA4D;AAC5D,6EAAuE;AA4EvE;;;GAGG;AACH,MAAa,aAAa;
|
|
1
|
+
{"version":3,"file":"optOutsClient.js","sourceRoot":"","sources":["../../src/optOutsClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,2DAA2D;AAG3D,qDAA4D;AAC5D,6EAAuE;AA4EvE;;;GAGG;AACH,MAAa,aAAa;IACP,GAAG,CAAe;IAEnC,YAAY,GAAiB;QAC3B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,MAAM,CACjB,IAAY,EACZ,EAAY,EACZ,UAAyB,EAAE;QAE3B,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAA,oDAAuB,EAAC,OAAO,CAAC,CAAC;QAC9D,OAAO,0BAAa,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;YACzF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAC5C,IAAA,mCAAqB,EAAC,IAAI,EAAE,EAAE,CAAC,EAC/B,cAAc,CACf,CAAC;YAEF,OAAO,QAAQ,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M,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAC3C,IAAA,mCAAqB,EAAC,IAAI,EAAE,EAAE,CAAC,EAC/B,cAAc,CACf,CAAC;YAEF,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,kBAAsC,EAAE,EAAE;gBACnE,OAAO;oBACL,EAAE,EAAE,kBAAkB,CAAC,EAAE;oBACzB,UAAU,EAAE,kBAAkB,CAAC,UAAU,IAAI,KAAK;oBAClD,cAAc,EAAE,kBAAkB,CAAC,cAAc;oBACjD,YAAY,EAAE,kBAAkB,CAAC,YAAY,IAAI,EAAE;iBACpD,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3FD,sCA2FC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { tracingClient } from \"./generated/src/tracing.js\";\nimport type { OptOutResponseItem } from \"./generated/src/index.js\";\nimport type { SmsApiClient } from \"./generated/src/smsApiClient.js\";\nimport { generateOptOutRequest } from \"./utils/smsUtils.js\";\nimport { extractOperationOptions } from \"./extractOperationOptions.js\";\nimport type { OperationOptions } from \"@azure/core-client\";\n\n/**\n * The result of Opt Out Check request.\n */\nexport interface OptOutCheckResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * Indicates if the recipient's phone number in opted out from receiving messages or not.\n */\n isOptedOut: boolean;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * The result of Opt Out Add request.\n */\nexport interface OptOutAddResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * The result of Opt Out Remove request.\n */\nexport interface OptOutRemoveResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * Client options used to configure OptOuts Client API Check requests.\n */\nexport interface CheckOptions extends OperationOptions {}\n\n/**\n * Client options used to configure OptOuts Client API Add requests.\n */\nexport interface AddOptions extends OperationOptions {}\n\n/**\n * Client options used to configure OptOuts Client API Remove requests.\n */\nexport interface RemoveOptions extends OperationOptions {}\n\n/**\n * A OptOutsClient represents a Client to the Azure Communication Sms service allowing you\n * to call Opt Out Management Api methods.\n */\nexport class OptOutsClient {\n private readonly api: SmsApiClient;\n\n constructor(api: SmsApiClient) {\n this.api = api;\n }\n\n /**\n * Removes phone numbers from the optouts list.\n *\n * @param from - The sender's phone number\n * @param to - The recipient's phone numbers\n * @param options - Additional request options\n */\n public async remove(\n from: string,\n to: string[],\n options: RemoveOptions = {},\n ): Promise<OptOutRemoveResult[]> {\n const { operationOptions } = extractOperationOptions(options);\n return tracingClient.withSpan(\"OptOuts-Remove\", operationOptions, async (updatedOptions) => {\n const response = await this.api.optOuts.remove(\n generateOptOutRequest(from, to),\n updatedOptions,\n );\n\n return response.value.map((optOutResponseItem: OptOutResponseItem) => {\n return {\n to: optOutResponseItem.to,\n httpStatusCode: optOutResponseItem.httpStatusCode,\n errorMessage: optOutResponseItem.errorMessage ?? \"\",\n };\n });\n });\n }\n\n /**\n * Adds phone numbers to the optouts list.\n *\n * @param from - The sender's phone number\n * @param to - The recipient's phone numbers\n * @param options - Additional request options\n */\n public async add(\n from: string,\n to: string[],\n options: AddOptions = {},\n ): Promise<OptOutAddResult[]> {\n const { operationOptions } = extractOperationOptions(options);\n return tracingClient.withSpan(\"OptOuts-Add\", operationOptions, async (updatedOptions) => {\n const response = await this.api.optOuts.add(generateOptOutRequest(from, to), updatedOptions);\n\n return response.value.map((optOutResponseItem: OptOutResponseItem) => {\n return {\n to: optOutResponseItem.to,\n httpStatusCode: optOutResponseItem.httpStatusCode,\n errorMessage: optOutResponseItem.errorMessage ?? \"\",\n };\n });\n });\n }\n\n /**\n * Checks if phone numbers are in the optouts list.\n *\n * @param from - The sender's phone number\n * @param to - The recipient's phone numbers\n * @param options - Additional request options\n */\n public async check(\n from: string,\n to: string[],\n options: CheckOptions = {},\n ): Promise<OptOutCheckResult[]> {\n const { operationOptions } = extractOperationOptions(options);\n return tracingClient.withSpan(\"OptOuts-Check\", operationOptions, async (updatedOptions) => {\n const response = await this.api.optOuts.check(\n generateOptOutRequest(from, to),\n updatedOptions,\n );\n\n return response.value.map((optOutResponseItem: OptOutResponseItem) => {\n return {\n to: optOutResponseItem.to,\n isOptedOut: optOutResponseItem.isOptedOut ?? false,\n httpStatusCode: optOutResponseItem.httpStatusCode,\n errorMessage: optOutResponseItem.errorMessage ?? \"\",\n };\n });\n });\n }\n}\n"]}
|
|
@@ -23,14 +23,23 @@ const isSmsClientOptions = (options) => !!options && !(0, core_auth_1.isTokenCre
|
|
|
23
23
|
* to send SMS messages.
|
|
24
24
|
*/
|
|
25
25
|
class SmsClient {
|
|
26
|
+
api;
|
|
27
|
+
/**
|
|
28
|
+
* A OptOutsClient represents a Client to the Azure Communication Sms service allowing you
|
|
29
|
+
* to call Opt Out Management Api methods.
|
|
30
|
+
*/
|
|
31
|
+
optOuts;
|
|
26
32
|
constructor(connectionStringOrUrl, credentialOrOptions, maybeOptions = {}) {
|
|
27
33
|
const { url, credential } = (0, communication_common_1.parseClientArguments)(connectionStringOrUrl, credentialOrOptions);
|
|
28
34
|
const options = isSmsClientOptions(credentialOrOptions) ? credentialOrOptions : maybeOptions;
|
|
29
|
-
const internalPipelineOptions =
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
const internalPipelineOptions = {
|
|
36
|
+
...options,
|
|
37
|
+
...{
|
|
38
|
+
loggingOptions: {
|
|
39
|
+
logger: logger_js_1.logger.info,
|
|
40
|
+
},
|
|
32
41
|
},
|
|
33
|
-
}
|
|
42
|
+
};
|
|
34
43
|
const authPolicy = (0, communication_common_1.createCommunicationAuthPolicy)(credential);
|
|
35
44
|
this.api = new smsApiClient_js_1.SmsApiClient(url, internalPipelineOptions);
|
|
36
45
|
this.api.pipeline.addPolicy(authPolicy);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smsClient.js","sourceRoot":"","sources":["../../src/smsClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;AAClC,4CAA4C;;;AAE5C,sEAIqC;AAErC,gDAAqD;AAGrD,qEAA+D;AAC/D,6EAAuE;AACvE,qDAAiE;AACjE,2CAAqC;AACrC,2DAA2D;AAC3D,yDAAwE;AAyLxE;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,CAAC,OAAY,EAA+B,EAAE,CACvE,CAAC,CAAC,OAAO,IAAI,CAAC,IAAA,6BAAiB,EAAC,OAAO,CAAC,IAAI,CAAC,IAAA,sCAAe,EAAC,OAAO,CAAC,CAAC;AAExE;;;GAGG;AACH,MAAa,SAAS;IAgCpB,YACE,qBAA6B,EAC7B,mBAAwE,EACxE,eAAiC,EAAE;QAEnC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAA,2CAAoB,EAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;QAC7F,MAAM,OAAO,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,YAAY,CAAC;QAE7F,MAAM,uBAAuB,mCACxB,OAAO,GACP;YACD,cAAc,EAAE;gBACd,MAAM,EAAE,kBAAM,CAAC,IAAI;aACpB;SACF,CACF,CAAC;QAEF,MAAM,UAAU,GAAG,IAAA,oDAA6B,EAAC,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,GAAG,GAAG,IAAI,8BAAY,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC;QAC1D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,IAAI,gCAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CACf,WAA2B,EAC3B,UAA0B,EAAE,oBAAoB,EAAE,KAAK,EAAE;QAEzD,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,GAAG,IAAA,oDAAuB,EAAC,OAAO,CAAC,CAAC;QAC3E,OAAO,0BAAa,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;YACzF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CACtC,IAAA,wCAA0B,EAAC,WAAW,EAAE,WAAW,CAAC,EACpD,cAAc,CACf,CAAC;YACF,OAAO,QAAQ,CAAC,KAAK,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA1ED,8BA0EC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n/// <reference lib=\"esnext.asynciterable\" />\n\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport type { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { SmsApiClient } from \"./generated/src/smsApiClient.js\";\nimport { extractOperationOptions } from \"./extractOperationOptions.js\";\nimport { generateSendMessageRequest } from \"./utils/smsUtils.js\";\nimport { logger } from \"./logger.js\";\nimport { tracingClient } from \"./generated/src/tracing.js\";\nimport { OptOutsClient as OptOutsClientImpl } from \"./optOutsClient.js\";\n\n/**\n * Client options used to configure SMS Client API requests.\n */\nexport interface SmsClientOptions extends CommonClientOptions {}\n\n/**\n * Values used to configure Sms message\n */\nexport interface SmsSendRequest {\n /**\n * The sender's phone number in E.164 format that is owned by the authenticated account.\n */\n from: string;\n /**\n * The list of recipient's phone number in E.164 format.\n */\n to: string[];\n /**\n * The contents of the message that will be sent to the recipient. The allowable content is\n * defined by RFC 5724.\n */\n message: string;\n}\n\n/**\n * Options to configure Sms requests.\n */\nexport interface SmsSendOptions extends OperationOptions {\n /**\n * Enable this flag to receive a delivery report for this message on the Azure Resource\n * EventGrid. Default value: false.\n */\n enableDeliveryReport?: boolean;\n /**\n * Use this field to provide metadata that will then be sent back in the corresponding Delivery\n * Report.\n */\n tag?: string;\n /** Time to wait for a delivery report. After this time a delivery report with timeout error code is generated. */\n deliveryReportTimeoutInSeconds?: number;\n\n /** Defines optional parameters for connecting with the Messaging Connect Partner to deliver SMS. */\n messagingConnect?: MessagingConnectOptions;\n}\n\n/** Defines optional parameters for connecting with the Messaging Connect Partner to deliver SMS. */\nexport interface MessagingConnectOptions {\n /** Represents the API key associated with the customer's account in the Messaging Connect Partner portal. */\n apiKey: string;\n /** Specifies the partner associated with the API key. */\n partner: string;\n}\n\n/**\n * The result of Sms send request.\n */\nexport interface SmsSendResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * The identifier of the outgoing Sms message. Only present if message processed.\n */\n messageId?: string;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Indicates if the message is processed successfully or not.\n */\n successful: boolean;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * A OptOutsClient represents a Client to the Azure Communication Sms service allowing you\n * to call Opt Out Management Api methods.\n */\nexport interface OptOutsClient {\n /**\n * Adds phone numbers to the optouts list.\n *\n * @param from - The sender's phone number\n * @param to - The recipient's phone numbers\n * @param options - Additional request options\n */\n add(from: string, to: string[], options?: AddOptions): Promise<OptOutAddResult[]>;\n /**\n * Checks if phone numbers are in the optouts list.\n *\n * @param from - The sender's phone number\n * @param to - The recipient's phone numbers\n * @param options - Additional request options\n */\n check(from: string, to: string[], options?: CheckOptions): Promise<OptOutCheckResult[]>;\n /**\n * Removes phone numbers from the optouts list.\n *\n * @param from - The sender's phone number\n * @param to - The recipient's phone numbers\n * @param options - Additional request options\n */\n remove(from: string, to: string[], options?: RemoveOptions): Promise<OptOutRemoveResult[]>;\n}\n\n/**\n * Client options used to configure OptOuts Client API Add requests.\n */\nexport interface AddOptions extends OperationOptions {}\n\n/**\n * Client options used to configure OptOuts Client API Check requests.\n */\nexport interface CheckOptions extends OperationOptions {}\n\n/**\n * Client options used to configure OptOuts Client API Remove requests.\n */\nexport interface RemoveOptions extends OperationOptions {}\n\n/**\n * The result of Opt Out Check request.\n */\nexport interface OptOutCheckResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * Indicates if the recipient's phone number in opted out from receiving messages or not.\n */\n isOptedOut: boolean;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * The result of Opt Out Add request.\n */\nexport interface OptOutAddResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * The result of Opt Out Remove request.\n */\nexport interface OptOutRemoveResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * Checks whether the type of a value is SmsClientOptions or not.\n *\n * @param options - The value being checked.\n */\nconst isSmsClientOptions = (options: any): options is SmsClientOptions =>\n !!options && !isTokenCredential(options) && !isKeyCredential(options);\n\n/**\n * A SmsClient represents a Client to the Azure Communication Sms service allowing you\n * to send SMS messages.\n */\nexport class SmsClient {\n private readonly api: SmsApiClient;\n /**\n * A OptOutsClient represents a Client to the Azure Communication Sms service allowing you\n * to call Opt Out Management Api methods.\n */\n public optOuts: OptOutsClient;\n\n /**\n * Initializes a new instance of the SmsClient class.\n * @param connectionString - Connection string to connect to an Azure Communication Service resource.\n * Example: \"endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret\";\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n constructor(connectionString: string, options?: SmsClientOptions);\n\n /**\n * Initializes a new instance of the SmsClient class using an Azure KeyCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - An object that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n constructor(endpoint: string, credential: KeyCredential, options?: SmsClientOptions);\n\n /**\n * Initializes a new instance of the SmsClient class using a TokenCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n constructor(endpoint: string, credential: TokenCredential, options?: SmsClientOptions);\n\n constructor(\n connectionStringOrUrl: string,\n credentialOrOptions?: KeyCredential | TokenCredential | SmsClientOptions,\n maybeOptions: SmsClientOptions = {},\n ) {\n const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions);\n const options = isSmsClientOptions(credentialOrOptions) ? credentialOrOptions : maybeOptions;\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.api = new SmsApiClient(url, internalPipelineOptions);\n this.api.pipeline.addPolicy(authPolicy);\n this.optOuts = new OptOutsClientImpl(this.api);\n }\n\n /**\n * Sends an SMS from a phone number that is acquired by the authenticated account, to another phone number.\n *\n * @param sendRequest - Provides the sender's and recipient's phone numbers, and the contents of the message\n * @param options - Additional request options\n */\n public async send(\n sendRequest: SmsSendRequest,\n options: SmsSendOptions = { enableDeliveryReport: false },\n ): Promise<SmsSendResult[]> {\n const { operationOptions, restOptions } = extractOperationOptions(options);\n return tracingClient.withSpan(\"SmsClient-Send\", operationOptions, async (updatedOptions) => {\n const response = await this.api.sms.send(\n generateSendMessageRequest(sendRequest, restOptions),\n updatedOptions,\n );\n return response.value;\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"smsClient.js","sourceRoot":"","sources":["../../src/smsClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;AAClC,4CAA4C;;;AAE5C,sEAIqC;AAErC,gDAAqD;AAGrD,qEAA+D;AAC/D,6EAAuE;AACvE,qDAAiE;AACjE,2CAAqC;AACrC,2DAA2D;AAC3D,yDAAwE;AAyLxE;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,CAAC,OAAY,EAA+B,EAAE,CACvE,CAAC,CAAC,OAAO,IAAI,CAAC,IAAA,6BAAiB,EAAC,OAAO,CAAC,IAAI,CAAC,IAAA,sCAAe,EAAC,OAAO,CAAC,CAAC;AAExE;;;GAGG;AACH,MAAa,SAAS;IACH,GAAG,CAAe;IACnC;;;OAGG;IACI,OAAO,CAAgB;IA0B9B,YACE,qBAA6B,EAC7B,mBAAwE,EACxE,eAAiC,EAAE;QAEnC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAA,2CAAoB,EAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;QAC7F,MAAM,OAAO,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,YAAY,CAAC;QAE7F,MAAM,uBAAuB,GAA4B;YACvD,GAAG,OAAO;YACV,GAAG;gBACD,cAAc,EAAE;oBACd,MAAM,EAAE,kBAAM,CAAC,IAAI;iBACpB;aACF;SACF,CAAC;QAEF,MAAM,UAAU,GAAG,IAAA,oDAA6B,EAAC,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,GAAG,GAAG,IAAI,8BAAY,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC;QAC1D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,IAAI,gCAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CACf,WAA2B,EAC3B,UAA0B,EAAE,oBAAoB,EAAE,KAAK,EAAE;QAEzD,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,GAAG,IAAA,oDAAuB,EAAC,OAAO,CAAC,CAAC;QAC3E,OAAO,0BAAa,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;YACzF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CACtC,IAAA,wCAA0B,EAAC,WAAW,EAAE,WAAW,CAAC,EACpD,cAAc,CACf,CAAC;YACF,OAAO,QAAQ,CAAC,KAAK,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA1ED,8BA0EC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n/// <reference lib=\"esnext.asynciterable\" />\n\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport type { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { SmsApiClient } from \"./generated/src/smsApiClient.js\";\nimport { extractOperationOptions } from \"./extractOperationOptions.js\";\nimport { generateSendMessageRequest } from \"./utils/smsUtils.js\";\nimport { logger } from \"./logger.js\";\nimport { tracingClient } from \"./generated/src/tracing.js\";\nimport { OptOutsClient as OptOutsClientImpl } from \"./optOutsClient.js\";\n\n/**\n * Client options used to configure SMS Client API requests.\n */\nexport interface SmsClientOptions extends CommonClientOptions {}\n\n/**\n * Values used to configure Sms message\n */\nexport interface SmsSendRequest {\n /**\n * The sender's phone number in E.164 format that is owned by the authenticated account.\n */\n from: string;\n /**\n * The list of recipient's phone number in E.164 format.\n */\n to: string[];\n /**\n * The contents of the message that will be sent to the recipient. The allowable content is\n * defined by RFC 5724.\n */\n message: string;\n}\n\n/**\n * Options to configure Sms requests.\n */\nexport interface SmsSendOptions extends OperationOptions {\n /**\n * Enable this flag to receive a delivery report for this message on the Azure Resource\n * EventGrid. Default value: false.\n */\n enableDeliveryReport?: boolean;\n /**\n * Use this field to provide metadata that will then be sent back in the corresponding Delivery\n * Report.\n */\n tag?: string;\n /** Time to wait for a delivery report. After this time a delivery report with timeout error code is generated. */\n deliveryReportTimeoutInSeconds?: number;\n\n /** Defines optional parameters for connecting with the Messaging Connect Partner to deliver SMS. */\n messagingConnect?: MessagingConnectOptions;\n}\n\n/** Defines optional parameters for connecting with the Messaging Connect Partner to deliver SMS. */\nexport interface MessagingConnectOptions {\n /** Represents the API key associated with the customer's account in the Messaging Connect Partner portal. */\n apiKey: string;\n /** Specifies the partner associated with the API key. */\n partner: string;\n}\n\n/**\n * The result of Sms send request.\n */\nexport interface SmsSendResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * The identifier of the outgoing Sms message. Only present if message processed.\n */\n messageId?: string;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Indicates if the message is processed successfully or not.\n */\n successful: boolean;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * A OptOutsClient represents a Client to the Azure Communication Sms service allowing you\n * to call Opt Out Management Api methods.\n */\nexport interface OptOutsClient {\n /**\n * Adds phone numbers to the optouts list.\n *\n * @param from - The sender's phone number\n * @param to - The recipient's phone numbers\n * @param options - Additional request options\n */\n add(from: string, to: string[], options?: AddOptions): Promise<OptOutAddResult[]>;\n /**\n * Checks if phone numbers are in the optouts list.\n *\n * @param from - The sender's phone number\n * @param to - The recipient's phone numbers\n * @param options - Additional request options\n */\n check(from: string, to: string[], options?: CheckOptions): Promise<OptOutCheckResult[]>;\n /**\n * Removes phone numbers from the optouts list.\n *\n * @param from - The sender's phone number\n * @param to - The recipient's phone numbers\n * @param options - Additional request options\n */\n remove(from: string, to: string[], options?: RemoveOptions): Promise<OptOutRemoveResult[]>;\n}\n\n/**\n * Client options used to configure OptOuts Client API Add requests.\n */\nexport interface AddOptions extends OperationOptions {}\n\n/**\n * Client options used to configure OptOuts Client API Check requests.\n */\nexport interface CheckOptions extends OperationOptions {}\n\n/**\n * Client options used to configure OptOuts Client API Remove requests.\n */\nexport interface RemoveOptions extends OperationOptions {}\n\n/**\n * The result of Opt Out Check request.\n */\nexport interface OptOutCheckResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * Indicates if the recipient's phone number in opted out from receiving messages or not.\n */\n isOptedOut: boolean;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * The result of Opt Out Add request.\n */\nexport interface OptOutAddResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * The result of Opt Out Remove request.\n */\nexport interface OptOutRemoveResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * Checks whether the type of a value is SmsClientOptions or not.\n *\n * @param options - The value being checked.\n */\nconst isSmsClientOptions = (options: any): options is SmsClientOptions =>\n !!options && !isTokenCredential(options) && !isKeyCredential(options);\n\n/**\n * A SmsClient represents a Client to the Azure Communication Sms service allowing you\n * to send SMS messages.\n */\nexport class SmsClient {\n private readonly api: SmsApiClient;\n /**\n * A OptOutsClient represents a Client to the Azure Communication Sms service allowing you\n * to call Opt Out Management Api methods.\n */\n public optOuts: OptOutsClient;\n\n /**\n * Initializes a new instance of the SmsClient class.\n * @param connectionString - Connection string to connect to an Azure Communication Service resource.\n * Example: \"endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret\";\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n constructor(connectionString: string, options?: SmsClientOptions);\n\n /**\n * Initializes a new instance of the SmsClient class using an Azure KeyCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - An object that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n constructor(endpoint: string, credential: KeyCredential, options?: SmsClientOptions);\n\n /**\n * Initializes a new instance of the SmsClient class using a TokenCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n constructor(endpoint: string, credential: TokenCredential, options?: SmsClientOptions);\n\n constructor(\n connectionStringOrUrl: string,\n credentialOrOptions?: KeyCredential | TokenCredential | SmsClientOptions,\n maybeOptions: SmsClientOptions = {},\n ) {\n const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions);\n const options = isSmsClientOptions(credentialOrOptions) ? credentialOrOptions : maybeOptions;\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.api = new SmsApiClient(url, internalPipelineOptions);\n this.api.pipeline.addPolicy(authPolicy);\n this.optOuts = new OptOutsClientImpl(this.api);\n }\n\n /**\n * Sends an SMS from a phone number that is acquired by the authenticated account, to another phone number.\n *\n * @param sendRequest - Provides the sender's and recipient's phone numbers, and the contents of the message\n * @param options - Additional request options\n */\n public async send(\n sendRequest: SmsSendRequest,\n options: SmsSendOptions = { enableDeliveryReport: false },\n ): Promise<SmsSendResult[]> {\n const { operationOptions, restOptions } = extractOperationOptions(options);\n return tracingClient.withSpan(\"SmsClient-Send\", operationOptions, async (updatedOptions) => {\n const response = await this.api.sms.send(\n generateSendMessageRequest(sendRequest, restOptions),\n updatedOptions,\n );\n return response.value;\n });\n }\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.52.8"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.52.8"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -6,9 +6,8 @@ exports.generateSendMessageRequest = generateSendMessageRequest;
|
|
|
6
6
|
exports.generateOptOutRequest = generateOptOutRequest;
|
|
7
7
|
const uuid_js_1 = require("./uuid.js");
|
|
8
8
|
function generateSendMessageRequest(smsRequest, options = {}) {
|
|
9
|
-
var _a, _b;
|
|
10
9
|
const _smsSendOptions = {
|
|
11
|
-
enableDeliveryReport:
|
|
10
|
+
enableDeliveryReport: options.enableDeliveryReport ?? false,
|
|
12
11
|
};
|
|
13
12
|
if (options.tag) {
|
|
14
13
|
_smsSendOptions["tag"] = options.tag;
|
|
@@ -23,7 +22,11 @@ function generateSendMessageRequest(smsRequest, options = {}) {
|
|
|
23
22
|
};
|
|
24
23
|
}),
|
|
25
24
|
message: smsRequest.message,
|
|
26
|
-
smsSendOptions:
|
|
25
|
+
smsSendOptions: {
|
|
26
|
+
enableDeliveryReport: options.enableDeliveryReport ?? false,
|
|
27
|
+
...(options.tag && { tag: options.tag }),
|
|
28
|
+
...(options.messagingConnect && { messagingConnect: options.messagingConnect }),
|
|
29
|
+
},
|
|
27
30
|
};
|
|
28
31
|
}
|
|
29
32
|
function generateOptOutRequest(from, to) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smsUtils.js","sourceRoot":"","sources":["../../../src/utils/smsUtils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAOlC,gEA2BC;AAED,sDASC;AAzCD,uCAAiC;AAGjC,SAAgB,0BAA0B,CACxC,UAA0B,EAC1B,UAA0B,EAAE
|
|
1
|
+
{"version":3,"file":"smsUtils.js","sourceRoot":"","sources":["../../../src/utils/smsUtils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAOlC,gEA2BC;AAED,sDASC;AAzCD,uCAAiC;AAGjC,SAAgB,0BAA0B,CACxC,UAA0B,EAC1B,UAA0B,EAAE;IAE5B,MAAM,eAAe,GAAoB;QACvC,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,IAAI,KAAK;KAC5D,CAAC;IACF,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,eAAe,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IACvC,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,aAAa,EAAE,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE;YAClD,OAAO;gBACL,EAAE,EAAE,cAAc;gBAClB,sBAAsB,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE;gBAC1D,sBAAsB,EAAE,cAAI,CAAC,YAAY,EAAE;aAC5C,CAAC;QACJ,CAAC,CAAC;QACF,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,cAAc,EAAE;YACd,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,IAAI,KAAK;YAC3D,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;YACxC,GAAG,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,EAAE,CAAC;SAChF;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,qBAAqB,CAAC,IAAY,EAAE,EAAY;IAC9D,OAAO;QACL,IAAI,EAAE,IAAI;QACV,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE;YACpC,OAAO;gBACL,EAAE,EAAE,cAAc;aACnB,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { SendMessageRequest, OptOutRequest } from \"../generated/src/models/index.js\";\nimport type { SmsSendOptions, SmsSendRequest } from \"../smsClient.js\";\nimport { Uuid } from \"./uuid.js\";\nimport type { SmsSendOptions as InternalOptions } from \"../generated/src/models/index.js\";\n\nexport function generateSendMessageRequest(\n smsRequest: SmsSendRequest,\n options: SmsSendOptions = {},\n): SendMessageRequest {\n const _smsSendOptions: InternalOptions = {\n enableDeliveryReport: options.enableDeliveryReport ?? false,\n };\n if (options.tag) {\n _smsSendOptions[\"tag\"] = options.tag;\n }\n\n return {\n from: smsRequest.from,\n smsRecipients: smsRequest.to.map((phoneNumberStr) => {\n return {\n to: phoneNumberStr,\n repeatabilityFirstSent: new Date(Date.now()).toUTCString(),\n repeatabilityRequestId: Uuid.generateUuid(),\n };\n }),\n message: smsRequest.message,\n smsSendOptions: {\n enableDeliveryReport: options.enableDeliveryReport ?? false,\n ...(options.tag && { tag: options.tag }),\n ...(options.messagingConnect && { messagingConnect: options.messagingConnect }),\n },\n };\n}\n\nexport function generateOptOutRequest(from: string, to: string[]): OptOutRequest {\n return {\n from: from,\n recipients: to.map((phoneNumberStr) => {\n return {\n to: phoneNumberStr,\n };\n }),\n };\n}\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { __rest } from "tslib";
|
|
4
3
|
export const extractOperationOptions = (obj) => {
|
|
5
|
-
const { abortSignal, onResponse, requestOptions, serializerOptions, tracingOptions
|
|
4
|
+
const { abortSignal, onResponse, requestOptions, serializerOptions, tracingOptions, ...restOptions } = obj;
|
|
6
5
|
return {
|
|
7
6
|
operationOptions: {
|
|
8
7
|
abortSignal,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractOperationOptions.js","sourceRoot":"","sources":["../../src/extractOperationOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC
|
|
1
|
+
{"version":3,"file":"extractOperationOptions.js","sourceRoot":"","sources":["../../src/extractOperationOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,GAAM,EAIN,EAAE;IACF,MAAM,EACJ,WAAW,EACX,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,GAAG,WAAW,EACf,GAAG,GAAG,CAAC;IAER,OAAO;QACL,gBAAgB,EAAE;YAChB,WAAW;YACX,cAAc;YACd,cAAc;SACf;QACD,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OperationOptions } from \"@azure/core-client\";\n\nexport const extractOperationOptions = <T extends OperationOptions>(\n obj: T,\n): {\n operationOptions: OperationOptions;\n restOptions: Pick<T, Exclude<keyof T, keyof OperationOptions>>;\n} => {\n const {\n abortSignal,\n onResponse,\n requestOptions,\n serializerOptions,\n tracingOptions,\n ...restOptions\n } = obj;\n\n return {\n operationOptions: {\n abortSignal,\n requestOptions,\n tracingOptions,\n },\n restOptions,\n };\n};\n"]}
|
|
@@ -11,6 +11,7 @@ import * as Mappers from "../models/mappers.js";
|
|
|
11
11
|
import * as Parameters from "../models/parameters.js";
|
|
12
12
|
/** Class containing OptOuts operations. */
|
|
13
13
|
export class OptOutsImpl {
|
|
14
|
+
client;
|
|
14
15
|
/**
|
|
15
16
|
* Initialize a new instance of the class OptOuts class.
|
|
16
17
|
* @param client Reference to the service client
|
|
@@ -24,7 +25,7 @@ export class OptOutsImpl {
|
|
|
24
25
|
* @param options The options parameters.
|
|
25
26
|
*/
|
|
26
27
|
async add(body, options) {
|
|
27
|
-
return tracingClient.withSpan("SmsApiClient.add", options
|
|
28
|
+
return tracingClient.withSpan("SmsApiClient.add", options ?? {}, async (options) => {
|
|
28
29
|
return this.client.sendOperationRequest({ body, options }, addOperationSpec);
|
|
29
30
|
});
|
|
30
31
|
}
|
|
@@ -34,7 +35,7 @@ export class OptOutsImpl {
|
|
|
34
35
|
* @param options The options parameters.
|
|
35
36
|
*/
|
|
36
37
|
async remove(body, options) {
|
|
37
|
-
return tracingClient.withSpan("SmsApiClient.remove", options
|
|
38
|
+
return tracingClient.withSpan("SmsApiClient.remove", options ?? {}, async (options) => {
|
|
38
39
|
return this.client.sendOperationRequest({ body, options }, removeOperationSpec);
|
|
39
40
|
});
|
|
40
41
|
}
|
|
@@ -44,7 +45,7 @@ export class OptOutsImpl {
|
|
|
44
45
|
* @param options The options parameters.
|
|
45
46
|
*/
|
|
46
47
|
async check(body, options) {
|
|
47
|
-
return tracingClient.withSpan("SmsApiClient.check", options
|
|
48
|
+
return tracingClient.withSpan("SmsApiClient.check", options ?? {}, async (options) => {
|
|
48
49
|
return this.client.sendOperationRequest({ body, options }, checkOperationSpec);
|
|
49
50
|
});
|
|
50
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optOuts.js","sourceRoot":"","sources":["../../../../../src/generated/src/operations/optOuts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAC;AAYtD,2CAA2C;AAC3C,MAAM,OAAO,WAAW;
|
|
1
|
+
{"version":3,"file":"optOuts.js","sourceRoot":"","sources":["../../../../../src/generated/src/operations/optOuts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAC;AAYtD,2CAA2C;AAC3C,MAAM,OAAO,WAAW;IACL,MAAM,CAAe;IAEtC;;;OAGG;IACH,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CACP,IAAmB,EACnB,OAAkC;QAElC,OAAO,aAAa,CAAC,QAAQ,CAC3B,kBAAkB,EAClB,OAAO,IAAI,EAAE,EACb,KAAK,EAAE,OAAO,EAAE,EAAE;YAChB,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CACrC,EAAE,IAAI,EAAE,OAAO,EAAE,EACjB,gBAAgB,CACc,CAAC;QACnC,CAAC,CACF,CAAC;IACJ,CAAC;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SAAS,EAAE;QACT,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,cAAc;SACnC;KACF;IACD,WAAW,EAAE,UAAU,CAAC,IAAI;IAC5B,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;IACxC,aAAa,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;IACpC,gBAAgB,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC;IAC7D,SAAS,EAAE,MAAM;IACjB,UAAU;CACX,CAAC;AACF,MAAM,kBAAkB,GAA6B;IACnD,IAAI,EAAE,oBAAoB;IAC1B,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,cAAc;SACnC;KACF;IACD,WAAW,EAAE,UAAU,CAAC,IAAI;IAC5B,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;IACxC,aAAa,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;IACpC,gBAAgB,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC;IAC7D,SAAS,EAAE,MAAM;IACjB,UAAU;CACX,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport { tracingClient } from \"../tracing.js\";\nimport { OptOuts } from \"../operationsInterfaces/index.js\";\nimport * as coreClient from \"@azure/core-client\";\nimport * as Mappers from \"../models/mappers.js\";\nimport * as Parameters from \"../models/parameters.js\";\nimport { SmsApiClient } from \"../smsApiClient.js\";\nimport {\n OptOutRequest,\n OptOutsAddOptionalParams,\n OptOutsAddResponse,\n OptOutsRemoveOptionalParams,\n OptOutsRemoveResponse,\n OptOutsCheckOptionalParams,\n OptOutsCheckResponse,\n} from \"../models/index.js\";\n\n/** Class containing OptOuts operations. */\nexport class OptOutsImpl implements OptOuts {\n private readonly client: SmsApiClient;\n\n /**\n * Initialize a new instance of the class OptOuts class.\n * @param client Reference to the service client\n */\n constructor(client: SmsApiClient) {\n this.client = client;\n }\n\n /**\n * Add phone numbers to the optouts list which shall stop receiving messages from a sender number.\n * @param body An opt out request.\n * @param options The options parameters.\n */\n async add(\n body: OptOutRequest,\n options?: OptOutsAddOptionalParams,\n ): Promise<OptOutsAddResponse> {\n return tracingClient.withSpan(\n \"SmsApiClient.add\",\n options ?? {},\n async (options) => {\n return this.client.sendOperationRequest(\n { body, options },\n addOperationSpec,\n ) as Promise<OptOutsAddResponse>;\n },\n );\n }\n\n /**\n * Remove phone numbers from the optouts list.\n * @param body An opt out request.\n * @param options The options parameters.\n */\n async remove(\n body: OptOutRequest,\n options?: OptOutsRemoveOptionalParams,\n ): Promise<OptOutsRemoveResponse> {\n return tracingClient.withSpan(\n \"SmsApiClient.remove\",\n options ?? {},\n async (options) => {\n return this.client.sendOperationRequest(\n { body, options },\n removeOperationSpec,\n ) as Promise<OptOutsRemoveResponse>;\n },\n );\n }\n\n /**\n * Check the opt out status for a recipient phone number with a sender phone number.\n * @param body An opt out request.\n * @param options The options parameters.\n */\n async check(\n body: OptOutRequest,\n options?: OptOutsCheckOptionalParams,\n ): Promise<OptOutsCheckResponse> {\n return tracingClient.withSpan(\n \"SmsApiClient.check\",\n options ?? {},\n async (options) => {\n return this.client.sendOperationRequest(\n { body, options },\n checkOperationSpec,\n ) as Promise<OptOutsCheckResponse>;\n },\n );\n }\n}\n// Operation Specifications\nconst serializer = coreClient.createSerializer(Mappers, /* isXml */ false);\n\nconst addOperationSpec: coreClient.OperationSpec = {\n path: \"/sms/optouts:add\",\n httpMethod: \"POST\",\n responses: {\n 200: {\n bodyMapper: Mappers.OptOutResponse,\n },\n },\n requestBody: Parameters.body,\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.endpoint],\n headerParameters: [Parameters.contentType, Parameters.accept],\n mediaType: \"json\",\n serializer,\n};\nconst removeOperationSpec: coreClient.OperationSpec = {\n path: \"/sms/optouts:remove\",\n httpMethod: \"POST\",\n responses: {\n 200: {\n bodyMapper: Mappers.OptOutResponse,\n },\n },\n requestBody: Parameters.body,\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.endpoint],\n headerParameters: [Parameters.contentType, Parameters.accept],\n mediaType: \"json\",\n serializer,\n};\nconst checkOperationSpec: coreClient.OperationSpec = {\n path: \"/sms/optouts:check\",\n httpMethod: \"POST\",\n responses: {\n 200: {\n bodyMapper: Mappers.OptOutResponse,\n },\n },\n requestBody: Parameters.body,\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.endpoint],\n headerParameters: [Parameters.contentType, Parameters.accept],\n mediaType: \"json\",\n serializer,\n};\n"]}
|
|
@@ -11,6 +11,7 @@ import * as Mappers from "../models/mappers.js";
|
|
|
11
11
|
import * as Parameters from "../models/parameters.js";
|
|
12
12
|
/** Class containing Sms operations. */
|
|
13
13
|
export class SmsImpl {
|
|
14
|
+
client;
|
|
14
15
|
/**
|
|
15
16
|
* Initialize a new instance of the class Sms class.
|
|
16
17
|
* @param client Reference to the service client
|
|
@@ -24,7 +25,7 @@ export class SmsImpl {
|
|
|
24
25
|
* @param options The options parameters.
|
|
25
26
|
*/
|
|
26
27
|
async send(sendMessageRequest, options) {
|
|
27
|
-
return tracingClient.withSpan("SmsApiClient.send", options
|
|
28
|
+
return tracingClient.withSpan("SmsApiClient.send", options ?? {}, async (options) => {
|
|
28
29
|
return this.client.sendOperationRequest({ sendMessageRequest, options }, sendOperationSpec);
|
|
29
30
|
});
|
|
30
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sms.js","sourceRoot":"","sources":["../../../../../src/generated/src/operations/sms.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAA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AAa,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;IACpC,gBAAgB,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC;IAC7D,SAAS,EAAE,MAAM;IACjB,UAAU;CACX,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport { tracingClient } from \"../tracing.js\";\nimport { Sms } from \"../operationsInterfaces/index.js\";\nimport * as coreClient from \"@azure/core-client\";\nimport * as Mappers from \"../models/mappers.js\";\nimport * as Parameters from \"../models/parameters.js\";\nimport { SmsApiClient } from \"../smsApiClient.js\";\nimport {\n SendMessageRequest,\n SmsSendOptionalParams,\n SmsSendOperationResponse,\n} from \"../models/index.js\";\n\n/** Class containing Sms operations. */\nexport class SmsImpl implements Sms {\n private readonly client: SmsApiClient;\n\n /**\n * Initialize a new instance of the class Sms class.\n * @param client Reference to the service client\n */\n constructor(client: SmsApiClient) {\n this.client = client;\n }\n\n /**\n * Sends a SMS message from a phone number that belongs to the authenticated account.\n * @param sendMessageRequest Represents the body of the send message request.\n * @param options The options parameters.\n */\n async send(\n sendMessageRequest: SendMessageRequest,\n options?: SmsSendOptionalParams,\n ): Promise<SmsSendOperationResponse> {\n return tracingClient.withSpan(\n \"SmsApiClient.send\",\n options ?? {},\n async (options) => {\n return this.client.sendOperationRequest(\n { sendMessageRequest, options },\n sendOperationSpec,\n ) as Promise<SmsSendOperationResponse>;\n },\n );\n }\n}\n// Operation Specifications\nconst serializer = coreClient.createSerializer(Mappers, /* isXml */ false);\n\nconst sendOperationSpec: coreClient.OperationSpec = {\n path: \"/sms\",\n httpMethod: \"POST\",\n responses: {\n 202: {\n bodyMapper: Mappers.SmsSendResponse,\n },\n },\n requestBody: Parameters.sendMessageRequest,\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.endpoint],\n headerParameters: [Parameters.contentType, Parameters.accept],\n mediaType: \"json\",\n serializer,\n};\n"]}
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
import * as coreClient from "@azure/core-client";
|
|
9
9
|
import { SmsImpl, OptOutsImpl } from "./operations/index.js";
|
|
10
10
|
export class SmsApiClient extends coreClient.ServiceClient {
|
|
11
|
+
endpoint;
|
|
12
|
+
apiVersion;
|
|
11
13
|
/**
|
|
12
14
|
* Initializes a new instance of the SmsApiClient class.
|
|
13
15
|
* @param endpoint The communication resource, for example https://my-resource.communication.azure.com
|
|
14
16
|
* @param options The parameter options
|
|
15
17
|
*/
|
|
16
18
|
constructor(endpoint, options) {
|
|
17
|
-
var _a, _b;
|
|
18
19
|
if (endpoint === undefined) {
|
|
19
20
|
throw new Error("'endpoint' cannot be null");
|
|
20
21
|
}
|
|
@@ -29,9 +30,14 @@ export class SmsApiClient extends coreClient.ServiceClient {
|
|
|
29
30
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
30
31
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
31
32
|
: `${packageDetails}`;
|
|
32
|
-
const optionsWithDefaults =
|
|
33
|
+
const optionsWithDefaults = {
|
|
34
|
+
...defaults,
|
|
35
|
+
...options,
|
|
36
|
+
userAgentOptions: {
|
|
33
37
|
userAgentPrefix,
|
|
34
|
-
},
|
|
38
|
+
},
|
|
39
|
+
endpoint: options.endpoint ?? options.baseUri ?? "{endpoint}",
|
|
40
|
+
};
|
|
35
41
|
super(optionsWithDefaults);
|
|
36
42
|
// Parameter assignments
|
|
37
43
|
this.endpoint = endpoint;
|
|
@@ -66,5 +72,7 @@ export class SmsApiClient extends coreClient.ServiceClient {
|
|
|
66
72
|
};
|
|
67
73
|
this.pipeline.addPolicy(apiVersionPolicy);
|
|
68
74
|
}
|
|
75
|
+
sms;
|
|
76
|
+
optOuts;
|
|
69
77
|
}
|
|
70
78
|
//# sourceMappingURL=smsApiClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smsApiClient.js","sourceRoot":"","sources":["../../../../src/generated/src/smsApiClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAMjD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAI7D,MAAM,OAAO,YAAa,SAAQ,UAAU,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"smsApiClient.js","sourceRoot":"","sources":["../../../../src/generated/src/smsApiClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAMjD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAI7D,MAAM,OAAO,YAAa,SAAQ,UAAU,CAAC,aAAa;IACxD,QAAQ,CAAS;IACjB,UAAU,CAAS;IAEnB;;;;OAIG;IACH,YAAY,QAAgB,EAAE,OAAoC;QAChE,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC/C,CAAC;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,GAA+B;YAC3C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,yCAAyC,CAAC;QACjE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,GAAG;YAC1B,GAAG,QAAQ;YACX,GAAG,OAAO;YACV,gBAAgB,EAAE;gBA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AS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACrD,CAAC;gBACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;SACF,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,GAAG,CAAM;IACT,OAAO,CAAU;CAClB","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport {\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { SmsImpl, OptOutsImpl } from \"./operations/index.js\";\nimport { Sms, OptOuts } from \"./operationsInterfaces/index.js\";\nimport { SmsApiClientOptionalParams } from \"./models/index.js\";\n\nexport class SmsApiClient extends coreClient.ServiceClient {\n endpoint: string;\n apiVersion: string;\n\n /**\n * Initializes a new instance of the SmsApiClient class.\n * @param endpoint The communication resource, for example https://my-resource.communication.azure.com\n * @param options The parameter options\n */\n constructor(endpoint: string, options?: SmsApiClientOptionalParams) {\n if (endpoint === undefined) {\n throw new Error(\"'endpoint' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: SmsApiClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\",\n };\n\n const packageDetails = `azsdk-js-communication-sms/1.2.0-beta.4`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n endpoint: options.endpoint ?? options.baseUri ?? \"{endpoint}\",\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.endpoint = endpoint;\n\n // Assigning values to Constant parameters\n this.apiVersion = options.apiVersion || \"2025-05-29-preview\";\n this.sms = new SmsImpl(this);\n this.optOuts = new OptOutsImpl(this);\n this.addCustomApiVersionPolicy(options.apiVersion);\n }\n\n /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */\n private addCustomApiVersionPolicy(apiVersion?: string) {\n if (!apiVersion) {\n return;\n }\n const apiVersionPolicy = {\n name: \"CustomApiVersionPolicy\",\n async sendRequest(\n request: PipelineRequest,\n next: SendRequest,\n ): Promise<PipelineResponse> {\n const param = request.url.split(\"?\");\n if (param.length > 1) {\n const newParams = param[1].split(\"&\").map((item) => {\n if (item.indexOf(\"api-version\") > -1) {\n return \"api-version=\" + apiVersion;\n } else {\n return item;\n }\n });\n request.url = param[0] + \"?\" + newParams.join(\"&\");\n }\n return next(request);\n },\n };\n this.pipeline.addPolicy(apiVersionPolicy);\n }\n\n sms: Sms;\n optOuts: OptOuts;\n}\n"]}
|
|
@@ -8,6 +8,7 @@ import { extractOperationOptions } from "./extractOperationOptions.js";
|
|
|
8
8
|
* to call Opt Out Management Api methods.
|
|
9
9
|
*/
|
|
10
10
|
export class OptOutsClient {
|
|
11
|
+
api;
|
|
11
12
|
constructor(api) {
|
|
12
13
|
this.api = api;
|
|
13
14
|
}
|
|
@@ -23,11 +24,10 @@ export class OptOutsClient {
|
|
|
23
24
|
return tracingClient.withSpan("OptOuts-Remove", operationOptions, async (updatedOptions) => {
|
|
24
25
|
const response = await this.api.optOuts.remove(generateOptOutRequest(from, to), updatedOptions);
|
|
25
26
|
return response.value.map((optOutResponseItem) => {
|
|
26
|
-
var _a;
|
|
27
27
|
return {
|
|
28
28
|
to: optOutResponseItem.to,
|
|
29
29
|
httpStatusCode: optOutResponseItem.httpStatusCode,
|
|
30
|
-
errorMessage:
|
|
30
|
+
errorMessage: optOutResponseItem.errorMessage ?? "",
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
33
|
});
|
|
@@ -44,11 +44,10 @@ export class OptOutsClient {
|
|
|
44
44
|
return tracingClient.withSpan("OptOuts-Add", operationOptions, async (updatedOptions) => {
|
|
45
45
|
const response = await this.api.optOuts.add(generateOptOutRequest(from, to), updatedOptions);
|
|
46
46
|
return response.value.map((optOutResponseItem) => {
|
|
47
|
-
var _a;
|
|
48
47
|
return {
|
|
49
48
|
to: optOutResponseItem.to,
|
|
50
49
|
httpStatusCode: optOutResponseItem.httpStatusCode,
|
|
51
|
-
errorMessage:
|
|
50
|
+
errorMessage: optOutResponseItem.errorMessage ?? "",
|
|
52
51
|
};
|
|
53
52
|
});
|
|
54
53
|
});
|
|
@@ -65,12 +64,11 @@ export class OptOutsClient {
|
|
|
65
64
|
return tracingClient.withSpan("OptOuts-Check", operationOptions, async (updatedOptions) => {
|
|
66
65
|
const response = await this.api.optOuts.check(generateOptOutRequest(from, to), updatedOptions);
|
|
67
66
|
return response.value.map((optOutResponseItem) => {
|
|
68
|
-
var _a, _b;
|
|
69
67
|
return {
|
|
70
68
|
to: optOutResponseItem.to,
|
|
71
|
-
isOptedOut:
|
|
69
|
+
isOptedOut: optOutResponseItem.isOptedOut ?? false,
|
|
72
70
|
httpStatusCode: optOutResponseItem.httpStatusCode,
|
|
73
|
-
errorMessage:
|
|
71
|
+
errorMessage: optOutResponseItem.errorMessage ?? "",
|
|
74
72
|
};
|
|
75
73
|
});
|
|
76
74
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optOutsClient.js","sourceRoot":"","sources":["../../src/optOutsClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AA4EvE;;;GAGG;AACH,MAAM,OAAO,aAAa;
|
|
1
|
+
{"version":3,"file":"optOutsClient.js","sourceRoot":"","sources":["../../src/optOutsClient.ts"],"names":[],"mappings":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licensed under the MIT License.\n\nimport { tracingClient } from \"./generated/src/tracing.js\";\nimport type { OptOutResponseItem } from \"./generated/src/index.js\";\nimport type { SmsApiClient } from \"./generated/src/smsApiClient.js\";\nimport { generateOptOutRequest } from \"./utils/smsUtils.js\";\nimport { extractOperationOptions } from \"./extractOperationOptions.js\";\nimport type { OperationOptions } from \"@azure/core-client\";\n\n/**\n * The result of Opt Out Check request.\n */\nexport interface OptOutCheckResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * Indicates if the recipient's phone number in opted out from receiving messages or not.\n */\n isOptedOut: boolean;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * The result of Opt Out Add request.\n */\nexport interface OptOutAddResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * The result of Opt Out Remove request.\n */\nexport interface OptOutRemoveResult {\n /**\n * The recipient's phone number in E.164 format.\n */\n to: string;\n /**\n * HTTP Status code.\n */\n httpStatusCode: number;\n /**\n * Optional error message in case of 4xx/5xx/repeatable errors.\n */\n errorMessage?: string;\n}\n\n/**\n * Client options used to configure OptOuts Client API Check requests.\n */\nexport interface CheckOptions extends OperationOptions {}\n\n/**\n * Client options used to configure OptOuts Client API Add requests.\n */\nexport interface AddOptions extends OperationOptions {}\n\n/**\n * Client options used to configure OptOuts Client API Remove requests.\n */\nexport interface RemoveOptions extends OperationOptions {}\n\n/**\n * A OptOutsClient represents a Client to the Azure Communication Sms service allowing you\n * to call Opt Out Management Api methods.\n */\nexport class OptOutsClient {\n private readonly api: SmsApiClient;\n\n constructor(api: SmsApiClient) {\n this.api = api;\n }\n\n /**\n * Removes phone numbers from the optouts list.\n *\n * @param from - The sender's phone number\n * @param to - The recipient's phone numbers\n * @param options - Additional request options\n */\n public async remove(\n from: string,\n to: string[],\n options: RemoveOptions = {},\n ): Promise<OptOutRemoveResult[]> {\n const { operationOptions } = extractOperationOptions(options);\n return tracingClient.withSpan(\"OptOuts-Remove\", operationOptions, async (updatedOptions) => {\n const response = await this.api.optOuts.remove(\n generateOptOutRequest(from, to),\n updatedOptions,\n );\n\n return response.value.map((optOutResponseItem: OptOutResponseItem) => {\n return {\n to: optOutResponseItem.to,\n httpStatusCode: optOutResponseItem.httpStatusCode,\n errorMessage: optOutResponseItem.errorMessage ?? \"\",\n };\n });\n });\n }\n\n /**\n * Adds phone numbers to the optouts list.\n *\n * @param from - The sender's phone number\n * @param to - The recipient's phone numbers\n * @param options - Additional request options\n */\n public async add(\n from: string,\n to: string[],\n options: AddOptions = {},\n ): Promise<OptOutAddResult[]> {\n const { operationOptions } = extractOperationOptions(options);\n return tracingClient.withSpan(\"OptOuts-Add\", operationOptions, async (updatedOptions) => {\n const response = await this.api.optOuts.add(generateOptOutRequest(from, to), updatedOptions);\n\n return response.value.map((optOutResponseItem: OptOutResponseItem) => {\n return {\n to: optOutResponseItem.to,\n httpStatusCode: optOutResponseItem.httpStatusCode,\n errorMessage: optOutResponseItem.errorMessage ?? \"\",\n };\n });\n });\n }\n\n /**\n * Checks if phone numbers are in the optouts list.\n *\n * @param from - The sender's phone number\n * @param to - The recipient's phone numbers\n * @param options - Additional request options\n */\n public async check(\n from: string,\n to: string[],\n options: CheckOptions = {},\n ): Promise<OptOutCheckResult[]> {\n const { operationOptions } = extractOperationOptions(options);\n return tracingClient.withSpan(\"OptOuts-Check\", operationOptions, async (updatedOptions) => {\n const response = await this.api.optOuts.check(\n generateOptOutRequest(from, to),\n updatedOptions,\n );\n\n return response.value.map((optOutResponseItem: OptOutResponseItem) => {\n return {\n to: optOutResponseItem.to,\n isOptedOut: optOutResponseItem.isOptedOut ?? false,\n httpStatusCode: optOutResponseItem.httpStatusCode,\n errorMessage: optOutResponseItem.errorMessage ?? \"\",\n };\n });\n });\n }\n}\n"]}
|
package/dist/esm/smsClient.js
CHANGED
|
@@ -20,14 +20,23 @@ const isSmsClientOptions = (options) => !!options && !isTokenCredential(options)
|
|
|
20
20
|
* to send SMS messages.
|
|
21
21
|
*/
|
|
22
22
|
export class SmsClient {
|
|
23
|
+
api;
|
|
24
|
+
/**
|
|
25
|
+
* A OptOutsClient represents a Client to the Azure Communication Sms service allowing you
|
|
26
|
+
* to call Opt Out Management Api methods.
|
|
27
|
+
*/
|
|
28
|
+
optOuts;
|
|
23
29
|
constructor(connectionStringOrUrl, credentialOrOptions, maybeOptions = {}) {
|
|
24
30
|
const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions);
|
|
25
31
|
const options = isSmsClientOptions(credentialOrOptions) ? credentialOrOptions : maybeOptions;
|
|
26
|
-
const internalPipelineOptions =
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
const internalPipelineOptions = {
|
|
33
|
+
...options,
|
|
34
|
+
...{
|
|
35
|
+
loggingOptions: {
|
|
36
|
+
logger: logger.info,
|
|
37
|
+
},
|
|
29
38
|
},
|
|
30
|
-
}
|
|
39
|
+
};
|
|
31
40
|
const authPolicy = createCommunicationAuthPolicy(credential);
|
|
32
41
|
this.api = new SmsApiClient(url, internalPipelineOptions);
|
|
33
42
|
this.api.pipeline.addPolicy(authPolicy);
|