diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 4223968fdfce..567dcfaa085d 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -216,10 +216,22 @@ "filename": "sdk/communication/communication-email/review/**/*.md", "words": ["rpmsg", "xlsb"] }, + { "filename": "sdk/containerregistry/container-registry/review/**/*.md", "words": ["Illumos", "illumos", "mipsle", "riscv"] }, + { + "filename": "sdk/communication/communication-ten-dlc/review/**/*.md", + "words": [ + "GIIN", + "Ucaas", + "Icex", + "Sehk", + "Szse", + "Twse" + ] + }, { "filename": "sdk/core/core-amqp/review/**/*.md", "words": ["EHOSTDOWN", "ENONET", "sastoken"] diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 2e43b5874141..b800b68f0754 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -868,6 +868,9 @@ importers: '@rush-temp/communication-sms': specifier: file:./projects/communication-sms.tgz version: file:projects/communication-sms.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.3))(vite@5.4.11(@types/node@22.7.9)) + '@rush-temp/communication-ten-dlc': + specifier: file:./projects/communication-ten-dlc.tgz + version: file:projects/communication-ten-dlc.tgz '@rush-temp/communication-tiering': specifier: file:./projects/communication-tiering.tgz version: file:projects/communication-tiering.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.3))(vite@5.4.11(@types/node@22.7.9)) @@ -2725,11 +2728,11 @@ packages: version: 0.0.0 '@rush-temp/arm-computefleet@file:projects/arm-computefleet.tgz': - resolution: {integrity: sha512-0cXmYkP6BC+rpZF30nOPzX72QzBfHP0iamJAUKGriMelkP/CvSHLzlc0iSChtrvLF+f+7Irm0Rq2CS8fRR8PGA==, tarball: file:projects/arm-computefleet.tgz} + resolution: {integrity: sha512-dHEiVJCBXoDiwRqnRqCf5ia8PtkGBLUuYc0aJSreNxdDbAAncfEfHBY2o38AGVWpCU6FlIrhVsrA2x6C3mlaUg==, tarball: file:projects/arm-computefleet.tgz} version: 0.0.0 '@rush-temp/arm-computeschedule@file:projects/arm-computeschedule.tgz': - resolution: {integrity: sha512-c/+NgTKQURRLUShIyScM53VoFwieM+cr9h+WpoAqCHHvYHW2nvljuSfPoPQHuXMiDVRuiDlHQ+kt4Nq1ZJDguw==, tarball: file:projects/arm-computeschedule.tgz} + resolution: {integrity: sha512-ib3pXHOqIcDQ6gtwwYl5zxa/HVC4zt6G0McgfgKemX+qsXm6XDFNsah1iDrmQh4G3Gmb2/4WDtxhsff9DCqzww==, tarball: file:projects/arm-computeschedule.tgz} version: 0.0.0 '@rush-temp/arm-confidentialledger@file:projects/arm-confidentialledger.tgz': @@ -3624,6 +3627,10 @@ packages: resolution: {integrity: sha512-HCXJQnm4PLnKjfZutc1vHXh9ed2iq1e5CI6rvjzRw0SzCgfs1GmtwMtt05bJyanzeunaiWLXWMfKHVoQa9MlsA==, tarball: file:projects/communication-sms.tgz} version: 0.0.0 + '@rush-temp/communication-ten-dlc@file:projects/communication-ten-dlc.tgz': + resolution: {integrity: sha512-G7uY96RSsMx8qW9C219doVAEpIvK70MXxY9+1TiC65Us2xGkaIKApujxA3ybr3rK6KpB7lOVxCoDPcrxuGT2mQ==, tarball: file:projects/communication-ten-dlc.tgz} + version: 0.0.0 + '@rush-temp/communication-tiering@file:projects/communication-tiering.tgz': resolution: {integrity: sha512-UqpcP6tGe7h8mJpfdq3qLXa7F6ctb6QHGbJr1cHw7GrUeICfRd8IGX4o2YOtwi7WoRIxcakFLtR3DmJT/aS3sg==, tarball: file:projects/communication-tiering.tgz} version: 0.0.0 @@ -3789,7 +3796,7 @@ packages: version: 0.0.0 '@rush-temp/keyvault-admin@file:projects/keyvault-admin.tgz': - resolution: {integrity: sha512-9nrkkH+RxeVz3ygp5vzRYD3DszYzyUch+Zp91THbSTktEAFHRMxfuUD56glXmTTxf//KN1y+HxYAJNfxCO+AdQ==, tarball: file:projects/keyvault-admin.tgz} + resolution: {integrity: sha512-NizLT7d7g7FIam+lwQJpaMWvoM1SIdA0x1rpi4AN/U99Qw4L3PAAEwZjSa+LQmIco2o8/vBNXgmqTt1OFnGcUQ==, tarball: file:projects/keyvault-admin.tgz} version: 0.0.0 '@rush-temp/keyvault-certificates@file:projects/keyvault-certificates.tgz': @@ -3993,7 +4000,7 @@ packages: version: 0.0.0 '@rush-temp/purview-scanning@file:projects/purview-scanning.tgz': - resolution: {integrity: sha512-3//USsp+OcONrh4BsZVi8bkx7KCMhq2rAvA/UKiZeUg9dwPyYQobK5f5z3fCBc27Km2JqvJeaBvMr6rhVtFvYA==, tarball: file:projects/purview-scanning.tgz} + resolution: {integrity: sha512-HJFfAYdCIriBJK7H2DtIyP6nUNFjDorEk2NfKDYGnk/q9b/xFcTY1ypEz53vbhUkgpMFTQDZ2GgrsitXizTx5w==, tarball: file:projects/purview-scanning.tgz} version: 0.0.0 '@rush-temp/purview-sharing@file:projects/purview-sharing.tgz': @@ -6280,6 +6287,9 @@ packages: karma-env-preprocessor@0.1.1: resolution: {integrity: sha512-3FAuA0B1lS4DXNyOpD1Y+BjteVmnfX0WXUpsZ19aYykTk/GPz0kqnjzdApDiEe4sapreVeVSme2qTALnbHJb/A==} + karma-firefox-launcher@1.3.0: + resolution: {integrity: sha512-Fi7xPhwrRgr+94BnHX0F5dCl1miIW4RHnzjIGxF8GaIEp7rNqX7LSi7ok63VXs3PS/5MQaQMhGxw+bvD+pibBQ==} + karma-firefox-launcher@2.1.3: resolution: {integrity: sha512-LMM2bseebLbYjODBOVt7TCPP9OI2vZIXCavIXhkO9m+10Uj5l7u/SKoeRmYx8FYHTVGZSpk6peX+3BMHC1WwNw==} @@ -11699,7 +11709,6 @@ snapshots: dotenv: 16.4.7 eslint: 9.18.0 playwright: 1.49.1 - prettier: 3.4.2 tslib: 2.8.1 typescript: 5.7.3 vitest: 2.1.8(@types/node@18.19.70)(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.3)) @@ -17034,6 +17043,45 @@ snapshots: - vite - webdriverio + '@rush-temp/communication-ten-dlc@file:projects/communication-ten-dlc.tgz': + dependencies: + '@azure-tools/test-credential': 1.3.1 + '@azure-tools/test-recorder': 3.5.2 + '@azure/core-lro': 2.7.2 + '@microsoft/api-extractor': 7.49.1(@types/node@18.19.70) + '@types/chai': 4.3.20 + '@types/mocha': 10.0.10 + '@types/node': 18.19.70 + '@types/sinon': 17.0.3 + chai: 4.5.0 + cross-env: 7.0.3 + dotenv: 16.4.7 + eslint: 8.57.1 + inherits: 2.0.4 + karma: 6.4.4 + karma-chrome-launcher: 3.2.0 + karma-coverage: 2.2.1 + karma-env-preprocessor: 0.1.1 + karma-firefox-launcher: 1.3.0 + karma-junit-reporter: 2.0.1(karma@6.4.4) + karma-mocha: 2.0.1 + karma-mocha-reporter: 2.2.5(karma@6.4.4) + karma-sourcemap-loader: 0.3.8 + mocha: 10.8.2 + nyc: 17.1.0 + rimraf: 5.0.10 + sinon: 17.0.1 + ts-node: 10.9.2(@types/node@18.19.70)(typescript@5.5.4) + tslib: 2.8.1 + typescript: 5.5.4 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - bufferutil + - debug + - supports-color + - utf-8-validate + '@rush-temp/communication-tiering@file:projects/communication-tiering.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.3))(vite@5.4.11(@types/node@22.7.9))': dependencies: '@azure/core-lro': 2.7.2 @@ -18480,7 +18528,6 @@ snapshots: '@rush-temp/keyvault-admin@file:projects/keyvault-admin.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.3))(vite@5.4.11(@types/node@22.7.9))': dependencies: - '@azure/core-lro': 2.7.2 '@types/node': 18.19.70 '@vitest/browser': 2.1.8(@types/node@18.19.70)(playwright@1.49.1)(typescript@5.7.3)(vite@5.4.11(@types/node@22.7.9))(vitest@2.1.8) '@vitest/coverage-istanbul': 2.1.8(vitest@2.1.8) @@ -20925,11 +20972,11 @@ snapshots: '@types/body-parser@1.19.5': dependencies: '@types/connect': 3.4.38 - '@types/node': 18.19.70 + '@types/node': 22.7.9 '@types/bunyan@1.8.9': dependencies: - '@types/node': 18.19.70 + '@types/node': 22.7.9 '@types/chai-as-promised@7.1.8': dependencies: @@ -20947,7 +20994,7 @@ snapshots: '@types/connect@3.4.38': dependencies: - '@types/node': 18.19.70 + '@types/node': 22.7.9 '@types/cookie@0.4.1': {} @@ -20955,7 +21002,7 @@ snapshots: '@types/cors@2.8.17': dependencies: - '@types/node': 18.19.70 + '@types/node': 22.7.9 '@types/debug@4.1.12': dependencies: @@ -20978,7 +21025,7 @@ snapshots: '@types/express-serve-static-core@4.19.6': dependencies: - '@types/node': 18.19.70 + '@types/node': 22.7.9 '@types/qs': 6.9.18 '@types/range-parser': 1.2.7 '@types/send': 0.17.4 @@ -20993,7 +21040,7 @@ snapshots: '@types/fs-extra@11.0.4': dependencies: '@types/jsonfile': 6.1.4 - '@types/node': 18.19.70 + '@types/node': 22.7.9 '@types/fs-extra@8.1.5': dependencies: @@ -21002,7 +21049,7 @@ snapshots: '@types/glob@7.2.0': dependencies: '@types/minimatch': 5.1.2 - '@types/node': 18.19.70 + '@types/node': 22.7.9 '@types/http-errors@2.0.4': {} @@ -21019,7 +21066,7 @@ snapshots: '@types/jsonfile@6.1.4': dependencies: - '@types/node': 18.19.70 + '@types/node': 22.7.9 '@types/jsonwebtoken@9.0.7': dependencies: @@ -21056,11 +21103,11 @@ snapshots: '@types/mysql@2.15.26': dependencies: - '@types/node': 18.19.70 + '@types/node': 22.7.9 '@types/node-fetch@2.6.12': dependencies: - '@types/node': 18.19.70 + '@types/node': 22.7.9 form-data: 4.0.1 '@types/node@18.19.70': @@ -21085,7 +21132,7 @@ snapshots: '@types/pg@8.6.1': dependencies: - '@types/node': 18.19.70 + '@types/node': 22.7.9 pg-protocol: 1.7.0 pg-types: 2.2.0 @@ -21102,7 +21149,7 @@ snapshots: '@types/readdir-glob@1.1.5': dependencies: - '@types/node': 18.19.70 + '@types/node': 22.7.9 '@types/resolve@1.20.2': {} @@ -21113,12 +21160,12 @@ snapshots: '@types/send@0.17.4': dependencies: '@types/mime': 1.3.5 - '@types/node': 18.19.70 + '@types/node': 22.7.9 '@types/serve-static@1.15.7': dependencies: '@types/http-errors': 2.0.4 - '@types/node': 18.19.70 + '@types/node': 22.7.9 '@types/send': 0.17.4 '@types/shimmer@1.2.0': {} @@ -21137,7 +21184,7 @@ snapshots: '@types/through@0.0.33': dependencies: - '@types/node': 18.19.70 + '@types/node': 22.7.9 '@types/tough-cookie@4.0.5': {} @@ -22163,7 +22210,7 @@ snapshots: dependencies: '@types/cookie': 0.4.1 '@types/cors': 2.8.17 - '@types/node': 18.19.70 + '@types/node': 22.7.9 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.7.2 @@ -23289,6 +23336,10 @@ snapshots: karma-env-preprocessor@0.1.1: {} + karma-firefox-launcher@1.3.0: + dependencies: + is-wsl: 2.2.0 + karma-firefox-launcher@2.1.3: dependencies: is-wsl: 2.2.0 @@ -24299,7 +24350,7 @@ snapshots: '@protobufjs/path': 1.1.2 '@protobufjs/pool': 1.1.0 '@protobufjs/utf8': 1.1.0 - '@types/node': 18.19.70 + '@types/node': 22.7.9 long: 5.2.4 proxy-addr@2.0.7: @@ -25066,6 +25117,24 @@ snapshots: '@ts-morph/common': 0.26.0 code-block-writer: 13.0.3 + ts-node@10.9.2(@types/node@18.19.70)(typescript@5.5.4): + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.11 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.4 + '@types/node': 18.19.70 + acorn: 8.14.0 + acorn-walk: 8.3.4 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 5.5.4 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + ts-node@10.9.2(@types/node@18.19.70)(typescript@5.7.3): dependencies: '@cspotcode/source-map-support': 0.8.1 diff --git a/rush.json b/rush.json index 33ba5b5cdfa1..21c68bf7a235 100644 --- a/rush.json +++ b/rush.json @@ -450,6 +450,11 @@ "projectFolder": "sdk/communication/communication-alpha-ids", "versionPolicyName": "client" }, + { + "packageName": "@azure-tools/communication-ten-dlc", + "projectFolder": "sdk/communication/communication-ten-dlc", + "versionPolicyName": "client" + }, { "packageName": "@azure-tools/communication-toll-free-verification", "projectFolder": "sdk/communication/communication-toll-free-verification", diff --git a/sdk/communication/ci.yml b/sdk/communication/ci.yml index ab78bd724066..707f9cc3f891 100644 --- a/sdk/communication/ci.yml +++ b/sdk/communication/ci.yml @@ -55,6 +55,8 @@ extends: safeName: azurerestcommunicationjobrouter - name: azure-rest-communication-messages safeName: azurerestcommunicationmessages + - name: azure-tools-communication-ten-dlc + safeName: azuretoolscommunicationtendlc - name: azure-tools-communication-toll-free-verification safeName: azuretoolscommunicationtollfreeverification - name: azure-communication-call-automation diff --git a/sdk/communication/communication-ten-dlc/.gitignore b/sdk/communication/communication-ten-dlc/.gitignore new file mode 100644 index 000000000000..1fe99ef1ca31 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/.gitignore @@ -0,0 +1 @@ +/**/code-model-v* diff --git a/sdk/communication/communication-ten-dlc/.nycrc b/sdk/communication/communication-ten-dlc/.nycrc new file mode 100644 index 000000000000..67064d0c1c56 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/.nycrc @@ -0,0 +1,18 @@ +{ + "include": [ + "dist-esm/src/**/*.js" + ], + "exclude": [ + "**/*.d.ts" + ], + "reporter": [ + "text-summary", + "html", + "cobertura" + ], + "exclude-after-remap": false, + "sourceMap": true, + "produce-source-map": true, + "instrument": true, + "all": true +} diff --git a/sdk/communication/communication-ten-dlc/CHANGELOG.md b/sdk/communication/communication-ten-dlc/CHANGELOG.md new file mode 100644 index 000000000000..02205f24279b --- /dev/null +++ b/sdk/communication/communication-ten-dlc/CHANGELOG.md @@ -0,0 +1,6 @@ +# Release History + +## 1.0.0-beta.1 (2024-03-04) + +### Features Added +- Setting up Ten Dlc SDK diff --git a/sdk/communication/communication-ten-dlc/README.md b/sdk/communication/communication-ten-dlc/README.md new file mode 100644 index 000000000000..e4a9e4d587cf --- /dev/null +++ b/sdk/communication/communication-ten-dlc/README.md @@ -0,0 +1,97 @@ +# Azure Communication 10 DLC client library for JavaScript + +10DLC is a program, recently launched by mobile carriers in the United States, that enables A2P SMS messaging for local numbers. + +## Getting started + +### Prerequisites + +- An [Azure subscription][azure_sub]. +- An existing Communication Services resource. If you need to create the resource, you can use the [Azure Portal][azure_portal], the [Azure PowerShell][azure_powershell], or the [Azure CLI][azure_cli]. + +### Installing + +```bash +npm install @azure-tools/communication-ten-dlc +``` + +### Browser support + +#### JavaScript Bundle + +To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). + +## Key concepts + +## Examples + +## Authentication + +To create a client object to access the Communication Services API, you will need a `connection string` or the `endpoint` of your Communication Services resource and a `credential`. The 10 DLC client can use either Azure Active Directory credentials or an API key credential to authenticate. + +You can get a key and/or connection string from your Communication Services resource in the [Azure Portal][azure_portal]. You can also find the endpoint for your Communication Services resource in the [Azure Portal][azure_portal]. + +Once you have a key, you can authenticate the `TenDlcClient` with any of the following methods: + +### Using a connection string + +```javascript +const { TenDlcClient } = require("@azure-tools/communication-ten-dlc"); + +const connectionString = "endpoint=;accessKey="; +const client = new TenDlcClient(connectionString); +``` + +### Using an access key with `AzureKeyCredential` + +If you use a key to initialize the client you will also need to provide the appropriate endpoint. You can get this endpoint from your Communication Services resource in [Azure Portal][azure_portal]. Once you have a key and endpoint, you can authenticate with the following code: + +```javascript +const { AzureKeyCredential } = require("@azure/core-auth"); +const { TenDlcClient } = require("@azure-tools/communication-ten-dlc"); + +const credential = new AzureKeyCredential(""); +const client = new TenDlcClient("", credential); +``` + +### Using an Azure Active Directory Credential + +Connection string authentication is used in most of the examples, but you can also authenticate with Azure Active Directory using the [Azure Identity library][azure_identity]. To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the [`@azure/identity`][azure_identity] package: + +```bash +npm install @azure/identity +``` + +The [`@azure/identity`][azure_identity] package provides a variety of credential types that your application can use to do this. The [README for `@azure/identity`][azure_identity_readme] provides more details and samples to get you started. + +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); +const { TenDlcClient } = require("@azure-tools/communication-ten-dlc"); + +const credential = new DefaultAzureCredential(); +const client = new TenDlcClient("", credential); +``` + +## Usage + +## Troubleshooting + +## Next steps + +Please take a look at the samples directory for detailed examples on how to use this library. + +## Contributing + +If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code. + +## Related projects + +- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) + +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_sub]: https://azure.microsoft.com/free/ +[azure_portal]: https://portal.azure.com +[azure_powershell]: https://docs.microsoft.com/powershell/module/az.communication/new-azcommunicationservice +[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential +[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity +[azure_identity_readme]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md diff --git a/sdk/communication/communication-ten-dlc/api-extractor.json b/sdk/communication/communication-ten-dlc/api-extractor.json new file mode 100644 index 000000000000..5e98a5c7bcd9 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/api-extractor.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "types/src/index.d.ts", + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/communication-ten-dlc.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-forgotten-export": { + "logLevel": "error", + "addToApiReportFile": false + }, + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "error" + } + } + } +} diff --git a/sdk/communication/communication-ten-dlc/assets.json b/sdk/communication/communication-ten-dlc/assets.json new file mode 100644 index 000000000000..f869d62eadea --- /dev/null +++ b/sdk/communication/communication-ten-dlc/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "js", + "TagPrefix": "js/communication/communication-ten-dlc", + "Tag": "js/communication/communication-ten-dlc_619f6ba794" +} diff --git a/sdk/communication/communication-ten-dlc/karma.conf.js b/sdk/communication/communication-ten-dlc/karma.conf.js new file mode 100644 index 000000000000..c4e01d2f3852 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/karma.conf.js @@ -0,0 +1,126 @@ +// https://github.com/karma-runner/karma-chrome-launcher +process.env.CHROME_BIN = require("puppeteer").executablePath(); +require("dotenv").config(); +const { relativeRecordingsPath } = require("@azure-tools/test-recorder"); + +process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath(); +module.exports = function (config) { + config.set({ + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: "./", + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ["mocha"], + + plugins: [ + "karma-mocha", + "karma-mocha-reporter", + "karma-chrome-launcher", + "karma-firefox-launcher", + "karma-env-preprocessor", + "karma-coverage", + "karma-sourcemap-loader", + "karma-junit-reporter", + ], + + // list of files / patterns to load in the browser + files: ["dist-test/index.browser.js"], + + // list of files / patterns to exclude + exclude: [], + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + "**/*.js": ["sourcemap", "env"], + // IMPORTANT: COMMENT following line if you want to debug in your browsers!! + // Preprocess source file to calculate code coverage, however this will make source file unreadable + //"dist-test/index.browser.js": ["coverage"] + }, + + // inject following environment values into browser testing with window.__env__ + // environment values MUST be exported or set with same console running "karma start" + // https://www.npmjs.com/package/karma-env-preprocessor + envPreprocessor: [ + "TEST_MODE", + "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING", + "AZURE_CLIENT_ID", + "AZURE_CLIENT_SECRET", + "AZURE_TENANT_ID", + "RECORDINGS_RELATIVE_PATH", + "AZURE_USERAGENT_OVERRIDE", + ], + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ["mocha", "coverage", "junit"], + + coverageReporter: { + // specify a common output directory + dir: "coverage-browser/", + reporters: [ + { type: "json", subdir: ".", file: "coverage.json" }, + { type: "lcovonly", subdir: ".", file: "lcov.info" }, + { type: "html", subdir: "html" }, + { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }, + ], + }, + + junitReporter: { + outputDir: "", // results will be saved as $outputDir/$browserName.xml + outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile + suite: "", // suite will become the package name attribute in xml testsuite element + useBrowserName: false, // add browser name to report and classes names + nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element + classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element + properties: {}, // key value pair of properties to add to the section of the report + }, + + // web server port + port: 9876, + + // enable / disable colors in the output (reporters and logs) + colors: true, + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: false, + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + // 'ChromeHeadless', 'Chrome', 'Firefox', 'Edge', 'IE' + browsers: ["HeadlessChrome"], + + customLaunchers: { + HeadlessChrome: { + base: "ChromeHeadless", + flags: ["--no-sandbox", "--disable-web-security"], + }, + }, + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: true, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: 1, + + browserNoActivityTimeout: 600000, + browserDisconnectTimeout: 10000, + browserDisconnectTolerance: 3, + + client: { + mocha: { + // change Karma's debug.html to the mocha web reporter + reporter: "html", + timeout: "600000", + }, + }, + }); +}; diff --git a/sdk/communication/communication-ten-dlc/package.json b/sdk/communication/communication-ten-dlc/package.json new file mode 100644 index 000000000000..bb727a23fb82 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/package.json @@ -0,0 +1,137 @@ +{ + "name": "@azure-tools/communication-ten-dlc", + "version": "1.0.0-beta.1", + "description": "SDK for Azure Communication Services which facilitates 10 DLC administration.", + "sdk-type": "client", + "main": "dist/index.js", + "module": "dist-esm/src/index.js", + "types": "types/communication-ten-dlc.d.ts", + "scripts": { + "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", + "build": "npm run clean && tsc -p . && dev-tool run bundle && dev-tool run extract-api", + "build:autorest": "autorest --typescript ./swagger/README.md && rushx format", + "build:clean": "rush update --recheck && rush rebuild && npm run build", + "build:browser": "tsc -p . && dev-tool run bundle", + "build:node": "tsc -p . && dev-tool run bundle", + "build:samples": "dev-tool samples publish --force", + "build:test": "tsc -p . && dev-tool run bundle", + "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", + "clean": "rimraf --glob dist dist-* types *.tgz *.log", + "execute:samples": "dev-tool samples run samples-dev", + "extract-api": "tsc -p . && dev-tool run extract-api", + "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", + "integration-test:browser": "dev-tool run test:browser", + "integration-test:node": "dev-tool run test:node-js-input -- --timeout 300000 'dist-esm/test/**/*.spec.js'", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "lint": "eslint package.json api-extractor.json README.md src test", + "lint:fix": "eslint package.json api-extractor.json README.md src test --fix --fix-type [problem,suggestion]", + "pack": "npm pack 2>&1", + "test": "rimraf --glob dist-test && npm run build:test && npm run unit-test && npm run integration-test", + "test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser", + "test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node", + "test:watch": "npm run test -- --watch --reporter min", + "unit-test:browser": "dev-tool run test:browser", + "unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'", + "unit-test": "npm run unit-test:node && npm run unit-test:browser" + }, + "files": [ + "dist/", + "dist-esm/src/", + "types/communication-ten-dlc.d.ts", + "README.md", + "LICENSE" + ], + "keywords": [ + "azure", + "cloud", + "communication" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-alpha-ids/", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "sideEffects": false, + "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", + "dependencies": { + "@azure/abort-controller": "^2.0.0", + "@azure/communication-common": "^2.2.0", + "@azure/core-auth": "^1.3.0", + "@azure/core-client": "^1.5.0", + "@azure/core-lro": "^2.2.4", + "@azure/core-paging": "^1.1.1", + "@azure/core-rest-pipeline": "^1.8.0", + "@azure/core-tracing": "^1.0.0", + "@azure/logger": "^1.0.0", + "tslib": "^2.2.0" + }, + "devDependencies": { + "@azure/dev-tool": "^1.0.0", + "@azure/eslint-plugin-azure-sdk": "^3.0.0", + "@azure-tools/test-utils": "^1.0.1", + "@azure-tools/test-credential": "^1.0.0", + "@azure-tools/test-recorder": "^3.5.2", + "@azure/identity": "^4.0.1", + "@azure/core-util": "^1.9.0", + "@microsoft/api-extractor": "^7.31.1", + "@types/chai": "^4.1.6", + "@types/mocha": "^10.0.0", + "@types/sinon": "^17.0.0", + "@types/node": "^18.19.39", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "dotenv": "^16.0.0", + "eslint": "^8.0.0", + "inherits": "^2.0.3", + "karma-chrome-launcher": "^3.0.0", + "karma-coverage": "^2.0.0", + "karma-env-preprocessor": "^0.1.1", + "karma-firefox-launcher": "^1.1.0", + "karma-junit-reporter": "^2.0.1", + "karma-mocha-reporter": "^2.2.5", + "karma-mocha": "^2.0.1", + "karma-sourcemap-loader": "^0.3.8", + "karma": "^6.2.0", + "mocha": "^10.0.0", + "nyc": "^17.0.0", + "rimraf": "^5.0.5", + "sinon": "^17.0.0", + "typescript": "~5.5.3", + "ts-node": "^10.0.0" + }, + "//metadata": { + "constantPaths": [ + { + "path": "src/generated/src/TenDlcClient.ts", + "prefix": "packageDetails" + }, + { + "path": "src/generated/src/tracing.ts", + "prefix": "packageVersion" + }, + { + "path": "src/utils/constants.ts", + "prefix": "SDK_VERSION" + }, + { + "path": "swagger/README.md", + "prefix": "package-version" + } + ] + }, + "//sampleConfiguration": { + "productName": "Azure Communication Services - 10 DLC", + "productSlugs": [ + "azure", + "azure-communication-services" + ], + "requiredResources": { + "Azure Communication Services account": "https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource" + } + } +} diff --git a/sdk/communication/communication-ten-dlc/review/communication-ten-dlc.api.md b/sdk/communication/communication-ten-dlc/review/communication-ten-dlc.api.md new file mode 100644 index 000000000000..4b1e59bbae40 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/review/communication-ten-dlc.api.md @@ -0,0 +1,306 @@ +## API Report File for "@azure-tools/communication-ten-dlc" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import type { CommonClientOptions } from '@azure/core-client'; +import * as coreClient from '@azure/core-client'; +import { KeyCredential } from '@azure/core-auth'; +import type { PagedAsyncIterableIterator } from '@azure/core-paging'; +import { TokenCredential } from '@azure/core-auth'; + +// @public +export interface Address { + city?: string; + country?: string; + line1?: string; + line2?: string; + postalCode?: string; + state?: string; +} + +// @public +export type AlternateBusinessIdType = "Duns" | "Lei" | "Giin"; + +// @public +export type BillingFrequency = "Monthly" | "Once"; + +// @public +export interface BrandDetails { + address?: Address; + alternateBusinessId?: string; + alternateBusinessIdType?: AlternateBusinessIdType; + companyName?: string; + companyVertical?: CompanyVertical; + contactInformation?: ContactInformation; + entityType?: EntityType; + name?: string; + stockExchange?: StockExchange; + stockSymbol?: string; + taxNumber?: string; + taxNumberIssuingCountry?: string; + url?: string; +} + +// @public +export type BrandStatus = "Draft" | "Submitted" | "Cancelled" | "PendingCancellation" | "Denied" | "Approved" | "MicrosoftSupportEngaged" | "VettingSubmitted"; + +// @public +export interface CampaignDetails { + callToAction?: string; + description?: string; +} + +// @public +export type CampaignStatus = "Draft" | "Submitted" | "Cancelled" | "PendingCancellation" | "Denied" | "Approved" | "MicrosoftSupportEngaged"; + +// @public +export type CompanyVertical = "Agriculture" | "Communication" | "Construction" | "Education" | "Energy" | "Entertainment" | "Financial" | "Gambling" | "Government" | "Healthcare" | "Hospitality" | "HumanResources" | "Insurance" | "Legal" | "Manufacturing" | "Ngo" | "Political" | "Postal" | "Professional" | "RealEstate" | "Retail" | "Technology" | "Transportation"; + +// @public +export interface ContactInformation { + email?: string; + phone?: string; +} + +// @public +export type ContentType = "AccountNotification" | "CustomerCare" | "DeliveryNotification" | "FraudAlert" | "HigherEducation" | "LowVolume" | "MachineToMachine" | "Marketing" | "Mixed" | "PollingVoting" | "PublicServiceAnnouncement" | "SecurityAlert" | "TwoFactorAuthentication"; + +// @public +export interface DeleteBrandOptionalParams extends TenDlcDeleteUSBrandOptionalParams { +} + +// @public +export interface DeleteCampaignOptionalParams extends TenDlcDeleteUSCampaignOptionalParams { +} + +// @public +export type EntityType = "PrivateProfit" | "PublicProfit" | "NonProfit" | "Government"; + +// @public +export interface GetBrandOptionalParams extends TenDlcGetUSBrandOptionalParams { +} + +// @public +export interface GetBrandsOptionalParams extends TenDlcGetUSBrandsOptionalParams { +} + +// @public +export interface GetCampaignOptionalParams extends TenDlcGetUSCampaignOptionalParams { +} + +// @public +export interface ListCampaignsOptionalParams extends TenDlcGetUSCampaignsOptionalParams { +} + +// @public +export interface ListCostsOptions extends TenDlcGetCostsOptionalParams { +} + +// @public +export interface MessageDetails { + hasAgeGatedContent?: boolean; + hasDirectLending?: boolean; + hasEmbeddedLink?: boolean; + hasEmbeddedPhone?: boolean; + helpAnswerToUser?: string; + helpAnswerToUserRequired?: boolean; + // (undocumented) + optInMessageToUser?: string; + optInMessageToUserRequired?: boolean; + optOutAnswerToUser?: string; + optOutAnswerToUserRequired?: boolean; + termsAndConditionsAccepted?: boolean; + useCase?: UseCase; +} + +// @public +export interface ReviewNote { + date?: Date; + message?: string; +} + +// @public +export type StockExchange = "Nasdaq" | "Nyse" | "Amex" | "Amx" | "Asx" | "B3" | "Bme" | "Bse" | "Fra" | "Icex" | "Jpx" | "Jse" | "Krx" | "Lon" | "Nse" | "Omx" | "Sehk" | "Sgx" | "Sse" | "Sto" | "Swx" | "Szse" | "Tsx" | "Twse" | "Vse" | "Other"; + +// @public +export type SubContentType = "TwoFactorAuthentication" | "AccountNotification" | "CustomerCare" | "DeliveryNotification" | "FraudAlert" | "HigherEducation" | "Marketing" | "PollingVoting" | "PublicServiceAnnouncement" | "SecurityAlert"; + +// @public +export interface SubmitBrandOptionalParams extends TenDlcSubmitUSBrandOptionalParams { +} + +// @public +export interface SubmitCampaignOptionalParams extends TenDlcSubmitUSCampaignOptionalParams { +} + +// @public +export interface TenDlcCancelUSBrandOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type TenDlcCancelUSBrandResponse = USBrand; + +// @public +export interface TenDlcCancelUSCampaignOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type TenDlcCancelUSCampaignResponse = USCampaign; + +// @public +export class TenDlcClient { + constructor(connectionString: string, options?: TenDlcClientOptions); + constructor(endpoint: string, credential: KeyCredential, options?: TenDlcClientOptions); + constructor(endpoint: string, credential: TokenCredential, options?: TenDlcClientOptions); + cancelUSBrand(brandId: string, options?: TenDlcCancelUSBrandOptionalParams): Promise; + cancelUSCampaign(campaignId: string, options?: TenDlcCancelUSCampaignOptionalParams): Promise; + deleteUSBrand(brandId: string, options?: DeleteBrandOptionalParams): Promise; + deleteUSCampaign(campaignId: string, options?: DeleteCampaignOptionalParams): Promise; + getUSBrand(brandId: string, options?: GetBrandOptionalParams): Promise; + getUSCampaign(campaignId: string, options?: GetCampaignOptionalParams): Promise; + listCosts(options?: ListCostsOptions): PagedAsyncIterableIterator; + listUSBrands(options?: GetBrandsOptionalParams): PagedAsyncIterableIterator; + listUSCampaigns(options?: ListCampaignsOptionalParams): PagedAsyncIterableIterator; + submitUSBrand(brandId: string, options?: SubmitBrandOptionalParams): Promise; + submitUSCampaign(campaignId: string, options?: SubmitCampaignOptionalParams): Promise; + upsertUSBrand(brandId: string, options?: UpsertUSBrandOptions): Promise; + upsertUSCampaign(campaingId: string, options?: UpsertUSCampaignOptions): Promise; +} + +// @public +export interface TenDlcClientOptions extends CommonClientOptions { +} + +// @public +export interface TenDlcCost { + amount?: number; + billingFrequency?: BillingFrequency; + countryCode?: string; + currencyCode?: string; + type?: TenDlcCostType; +} + +// @public +export interface TenDlcCosts { + costs?: TenDlcCost[]; + nextLink?: string; +} + +// @public +export type TenDlcCostType = "Brand" | "StandardCampaign"; + +// @public +export interface TenDlcDeleteUSBrandOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface TenDlcDeleteUSCampaignOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface TenDlcGetCostsOptionalParams extends coreClient.OperationOptions { + skip?: number; + top?: number; +} + +// @public +export interface TenDlcGetUSBrandOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface TenDlcGetUSBrandsOptionalParams extends coreClient.OperationOptions { + // (undocumented) + filter?: string; + // (undocumented) + skip?: number; + // (undocumented) + top?: number; +} + +// @public +export interface TenDlcGetUSCampaignOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface TenDlcGetUSCampaignsOptionalParams extends coreClient.OperationOptions { + // (undocumented) + filter?: string; + // (undocumented) + skip?: number; + // (undocumented) + top?: number; +} + +// @public +export interface TenDlcSubmitUSBrandOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface TenDlcSubmitUSCampaignOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface UpsertUSBrandOptions extends TenDlcGetUSBrandOptionalParams { + // (undocumented) + brandDetails: BrandDetails | undefined; +} + +// @public +export interface UpsertUSCampaignOptions extends TenDlcGetUSCampaignOptionalParams { + // (undocumented) + brandId: string | undefined; + // (undocumented) + campaignDetails: CampaignDetails | undefined; + // (undocumented) + messageDetails: MessageDetails | undefined; +} + +// @public +export interface USBrand { + brandDetails?: BrandDetails; + costs?: TenDlcCost[]; + id: string; + reviewNotes?: ReviewNote[]; + status?: BrandStatus; + statusUpdatedDate?: Date; + submissionDate?: Date; +} + +// @public +export interface USBrands { + brands?: USBrand[]; + nextLink?: string; +} + +// @public +export interface USCampaign { + brandId?: string; + campaignDetails?: CampaignDetails; + costs?: TenDlcCost[]; + id: string; + messageDetails?: MessageDetails; + phoneNumberCount?: number; + reviewNotes?: ReviewNote[]; + status?: CampaignStatus; + statusUpdatedDate?: Date; + submissionDate?: Date; +} + +// @public +export interface USCampaigns { + campaigns?: USCampaign[]; + nextLink?: string; +} + +// @public +export interface UseCase { + contentType?: ContentType; + sampleMessages?: string[]; + subContentTypes?: SubContentType[]; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/communication/communication-ten-dlc/sample.env b/sdk/communication/communication-ten-dlc/sample.env new file mode 100644 index 000000000000..ecc5467f2006 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/sample.env @@ -0,0 +1,3 @@ +# Used in most samples. Retrieve these values from a Communication Services instance +# in the Azure Portal. +COMMUNICATION_SAMPLES_CONNECTION_STRING="endpoint=https://.communication.azure.net/;accessKey=" diff --git a/sdk/communication/communication-ten-dlc/samples-dev/getUsBrand.ts b/sdk/communication/communication-ten-dlc/samples-dev/getUsBrand.ts new file mode 100644 index 000000000000..fd546c0b9497 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/samples-dev/getUsBrand.ts @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * @summary Get a Campaign Brief. + */ + +import { USBrand, TenDlcClient } from "@azure-tools/communication-ten-dlc"; + +// Load the .env file if it exists +import * as dotenv from "dotenv"; +dotenv.config(); + +export async function main() { + console.log("\n== Get a USBrand ==\n"); + + // You will need to set this environment variable or edit the following values + const connectionString = + process.env.COMMUNICATION_SAMPLES_CONNECTION_STRING || + "endpoint=https://resourceName.communication.azure.net/;accessKey=test-key"; + + // create new client + const client = new TenDlcClient(connectionString); + + // a dummy campaign brief Id + const uSBrandId = "63215741-b596-4eb4-a9c0-b2905ce22cb0"; + + // get a campaign brief + const usBrand: USBrand = await client.getUSBrand(uSBrandId); + + console.log(usBrand); +} + +main().catch((error) => { + console.log("The sample getCampaignBrief encountered an error:", error); + process.exit(1); +}); diff --git a/sdk/communication/communication-ten-dlc/src/generated/src/index.ts b/sdk/communication/communication-ten-dlc/src/generated/src/index.ts new file mode 100644 index 000000000000..48eb9ac3b157 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/generated/src/index.ts @@ -0,0 +1,13 @@ +/* + * 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. + */ + +/// +export { getContinuationToken } from "./pagingHelper"; +export * from "./models"; +export { TenDLCClient } from "./tenDLCClient"; +export * from "./operationsInterfaces"; diff --git a/sdk/communication/communication-ten-dlc/src/generated/src/models/index.ts b/sdk/communication/communication-ten-dlc/src/generated/src/models/index.ts new file mode 100644 index 000000000000..59044fea2dc3 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/generated/src/models/index.ts @@ -0,0 +1,515 @@ +/* + * 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 * as coreClient from "@azure/core-client"; + +/** Represents a US 10DLC brand with details and status information. */ +export interface USBrand { + /** Unique identifier that corresponds to a brand */ + id: string; + /** Last date and time when the 10DLC status was updated */ + statusUpdatedDate?: Date; + /** 10 Dlc status e.g. 'submitted', 'approved', etc */ + status?: BrandStatus; + /** Represents the costs tied to the brand */ + costs?: TenDlcCost[]; + /** Date and time when the 10DLC was submitted */ + submissionDate?: Date; + /** + * Notes added to the 10DLC Brand after being reviewed to help customer understand + * review results and necessary follow up actions. + */ + reviewNotes?: ReviewNote[]; + /** General information for a 10DLC brand. */ + brandDetails?: BrandDetails; +} + +/** The cost of a 10DLC Brand or Campaign */ +export interface TenDlcCost { + /** The type of cost. */ + type?: TenDlcCostType; + /** The cost amount. */ + amount?: number; + /** The ISO 4217 currency code for the cost amount, e.g. USD. */ + currencyCode?: string; + /** The ISO 3166-2 code of the phone number's country, e.g. US. */ + countryCode?: string; + /** The frequency with which the cost gets billed. */ + billingFrequency?: BillingFrequency; +} + +/** Holds a note about a Program Brief that has gone thru stages of review process. */ +export interface ReviewNote { + /** Note related to a Brand or Campaign that may imply changes needed from the client. */ + message?: string; + /** Date and time when the note was added to the Brand or Campaign. */ + date?: Date; +} + +/** General information for a 10DLC brand. */ +export interface BrandDetails { + /** Gets or sets Name */ + name?: string; + /** Gets or sets Company Name */ + companyName?: string; + /** Category of companies motive/use case */ + companyVertical?: CompanyVertical; + /** Represent contact information for the brand. */ + contactInformation?: ContactInformation; + /** Represents postal address. */ + address?: Address; + /** Legal structure or form a company takes */ + entityType?: EntityType; + /** Marketplace where stocks, bonds, etc... are bought and sold */ + stockExchange?: StockExchange; + /** Stock Exchange */ + stockSymbol?: string; + /** Alternate Business Id Type */ + alternateBusinessIdType?: AlternateBusinessIdType; + /** Alternate Business Id */ + alternateBusinessId?: string; + /** Business Id that corresponds to your business */ + taxNumber?: string; + /** Tax Issuing Country */ + taxNumberIssuingCountry?: string; + /** URL */ + url?: string; +} + +/** Represent contact information for the brand. */ +export interface ContactInformation { + /** Contact phone number for the authorized user for the customer. Use E164 format. e.g. +14086111111 */ + phone?: string; + /** Contact email address number for the authorized user for the customer */ + email?: string; +} + +/** Represents postal address. */ +export interface Address { + /** Address line 1 */ + line1?: string; + /** Address line 2 */ + line2?: string; + /** The city for the addresses, for example Los Angeles. */ + city?: string; + /** The state for the addresses, for example California. */ + state?: string; + /** Postal code */ + postalCode?: string; + /** Country */ + country?: string; +} + +/** The Communication Services error. */ +export interface CommunicationErrorResponse { + /** The Communication Services error. */ + error: CommunicationError; +} + +/** The Communication Services error. */ +export interface CommunicationError { + /** The error code. */ + code: string; + /** The error message. */ + message: string; + /** + * The error target. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly target?: string; + /** + * Further details about specific errors that led to this error. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly details?: CommunicationError[]; + /** + * The inner error if any. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly innerError?: CommunicationError; +} + +/** A wrapper for a list of USBrands. */ +export interface USBrands { + /** List of USBrands */ + brands?: USBrand[]; + /** Represents the URL link to the next page */ + nextLink?: string; +} + +/** Represents a US 10DLC campaign. */ +export interface USCampaign { + /** Unique identifier that corresponds to a campaign */ + id: string; + /** Unique identifier that corresponds to a brand */ + brandId?: string; + /** 10DLC status e.g. 'submitted', 'approved', etc */ + status?: CampaignStatus; + /** Last date and time when the 10DLC status was updated */ + statusUpdatedDate?: Date; + /** Represents the costs tied to the campaign */ + costs?: TenDlcCost[]; + /** Date and time when the 10DLC was submitted */ + submissionDate?: Date; + /** + * Notes added to the 10DLC Campaign after being reviewed to help customer understand + * review results and necessary follow up actions. + */ + reviewNotes?: ReviewNote[]; + /** Count of local phone numbers currently associated to the 10DLC Campaign. */ + phoneNumberCount?: number; + /** Information about the campaign. */ + campaignDetails?: CampaignDetails; + /** Compiles details describing how the messaging campaign will work, for example whether opt-in and opt-out will be required and how will the messages for those actions look like. */ + messageDetails?: MessageDetails; +} + +/** Information about the campaign. */ +export interface CampaignDetails { + /** Call to action text. To be provided when InteractiveVoiceResponse is specified as call to action type */ + callToAction?: string; + /** Describes how and why the number will be used for messaging as part of the program. */ + description?: string; +} + +/** Compiles details describing how the messaging campaign will work, for example whether opt-in and opt-out will be required and how will the messages for those actions look like. */ +export interface MessageDetails { + /** Compiles information describing the user case for a 10DLC messaging campaign. */ + useCase?: UseCase; + /** Boolean to determine if HelpAnswerToUser is required */ + helpAnswerToUserRequired?: boolean; + /** + * Message text for mobile terminated message associated with HELP keyword + * e.g 'This is the HELP message test.'. + */ + helpAnswerToUser?: string; + /** Boolean to determine if optOutAnswerToUser is required */ + optOutAnswerToUserRequired?: boolean; + /** + * "Message text for mobile terminated message associated with STOP keyword + * e.g. 'This is the STOP message test.'. + */ + optOutAnswerToUser?: string; + /** Boolean to determine if optInMessage is required */ + optInMessageToUserRequired?: boolean; + optInMessageToUser?: string; + /** Indicates whether the message has an embedded link. */ + hasEmbeddedLink?: boolean; + /** Indicates whether the message has an embedded phone number. */ + hasEmbeddedPhone?: boolean; + /** Indicates whether the terms and conditions have been accepted. */ + termsAndConditionsAccepted?: boolean; + /** Indicates whether the message contains age-gated content. */ + hasAgeGatedContent?: boolean; + /** Indicates whether the message involves direct lending. */ + hasDirectLending?: boolean; +} + +/** Compiles information describing the user case for a 10DLC messaging campaign. */ +export interface UseCase { + /** Type of user content */ + contentType?: ContentType; + /** Type of user sub-content */ + subContentTypes?: SubContentType[]; + /** Sample messages that a user might send, as a proof of concept */ + sampleMessages?: string[]; +} + +/** A wrapper for a list of USCampaigns */ +export interface USCampaigns { + /** List of USCampaigns */ + campaigns?: USCampaign[]; + /** Represents the URL link to the next page */ + nextLink?: string; +} + +/** A wrapper for a list of 10DLC cost entities */ +export interface TenDlcCosts { + /** List of 10DLC costs. */ + costs?: TenDlcCost[]; + /** Represents the URL link to the next page of local 10DLC costs results. */ + nextLink?: string; +} + +/** Defines values for BrandStatus. */ +export type BrandStatus = + | "Draft" + | "Submitted" + | "Cancelled" + | "PendingCancellation" + | "Denied" + | "Approved" + | "MicrosoftSupportEngaged" + | "VettingSubmitted"; +/** Defines values for TenDlcCostType. */ +export type TenDlcCostType = "Brand" | "StandardCampaign"; +/** Defines values for BillingFrequency. */ +export type BillingFrequency = "Monthly" | "Once"; +/** Defines values for CompanyVertical. */ +export type CompanyVertical = + | "Agriculture" + | "Communication" + | "Construction" + | "Education" + | "Energy" + | "Entertainment" + | "Financial" + | "Gambling" + | "Government" + | "Healthcare" + | "Hospitality" + | "HumanResources" + | "Insurance" + | "Legal" + | "Manufacturing" + | "Ngo" + | "Political" + | "Postal" + | "Professional" + | "RealEstate" + | "Retail" + | "Technology" + | "Transportation"; +/** Defines values for EntityType. */ +export type EntityType = + | "PrivateProfit" + | "PublicProfit" + | "NonProfit" + | "Government"; +/** Defines values for StockExchange. */ +export type StockExchange = + | "Nasdaq" + | "Nyse" + | "Amex" + | "Amx" + | "Asx" + | "B3" + | "Bme" + | "Bse" + | "Fra" + | "Icex" + | "Jpx" + | "Jse" + | "Krx" + | "Lon" + | "Nse" + | "Omx" + | "Sehk" + | "Sgx" + | "Sse" + | "Sto" + | "Swx" + | "Szse" + | "Tsx" + | "Twse" + | "Vse" + | "Other"; +/** Defines values for AlternateBusinessIdType. */ +export type AlternateBusinessIdType = "Duns" | "Lei" | "Giin"; +/** Defines values for CampaignStatus. */ +export type CampaignStatus = + | "Draft" + | "Submitted" + | "Cancelled" + | "PendingCancellation" + | "Denied" + | "Approved" + | "MicrosoftSupportEngaged"; +/** Defines values for ContentType. */ +export type ContentType = + | "AccountNotification" + | "CustomerCare" + | "DeliveryNotification" + | "FraudAlert" + | "HigherEducation" + | "LowVolume" + | "MachineToMachine" + | "Marketing" + | "Mixed" + | "PollingVoting" + | "PublicServiceAnnouncement" + | "SecurityAlert" + | "TwoFactorAuthentication"; +/** Defines values for SubContentType. */ +export type SubContentType = + | "TwoFactorAuthentication" + | "AccountNotification" + | "CustomerCare" + | "DeliveryNotification" + | "FraudAlert" + | "HigherEducation" + | "Marketing" + | "PollingVoting" + | "PublicServiceAnnouncement" + | "SecurityAlert"; + +/** Optional parameters. */ +export interface TenDlcUpsertUSBrandOptionalParams + extends coreClient.OperationOptions { + /** Last date and time when the 10DLC status was updated */ + statusUpdatedDate?: Date; + /** 10 Dlc status e.g. 'submitted', 'approved', etc */ + status?: BrandStatus; + /** Represents the costs tied to the brand */ + costs?: TenDlcCost[]; + /** Date and time when the 10DLC was submitted */ + submissionDate?: Date; + /** + * Notes added to the 10DLC Brand after being reviewed to help customer understand + * review results and necessary follow up actions. + */ + reviewNotes?: ReviewNote[]; + /** General information for a 10DLC brand. */ + brandDetails?: BrandDetails; +} + +/** Contains response data for the upsertUSBrand operation. */ +export type TenDlcUpsertUSBrandResponse = USBrand; + +/** Optional parameters. */ +export interface TenDlcDeleteUSBrandOptionalParams + extends coreClient.OperationOptions {} + +/** Optional parameters. */ +export interface TenDlcGetUSBrandOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the getUSBrand operation. */ +export type TenDlcGetUSBrandResponse = USBrand; + +/** Optional parameters. */ +export interface TenDlcSubmitUSBrandOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the submitUSBrand operation. */ +export type TenDlcSubmitUSBrandResponse = USBrand; + +/** Optional parameters. */ +export interface TenDlcGetUSBrandsOptionalParams + extends coreClient.OperationOptions { + skip?: number; + top?: number; + filter?: string; +} + +/** Contains response data for the getUSBrands operation. */ +export type TenDlcGetUSBrandsResponse = USBrands; + +/** Optional parameters. */ +export interface TenDlcCancelUSBrandOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the cancelUSBrand operation. */ +export type TenDlcCancelUSBrandResponse = USBrand; + +/** Optional parameters. */ +export interface TenDlcUpsertUSCampaignOptionalParams + extends coreClient.OperationOptions { + /** Unique identifier that corresponds to a brand */ + brandId?: string; + /** 10DLC status e.g. 'submitted', 'approved', etc */ + status?: CampaignStatus; + /** Last date and time when the 10DLC status was updated */ + statusUpdatedDate?: Date; + /** Represents the costs tied to the campaign */ + costs?: TenDlcCost[]; + /** Date and time when the 10DLC was submitted */ + submissionDate?: Date; + /** + * Notes added to the 10DLC Campaign after being reviewed to help customer understand + * review results and necessary follow up actions. + */ + reviewNotes?: ReviewNote[]; + /** Count of local phone numbers currently associated to the 10DLC Campaign. */ + phoneNumberCount?: number; + /** Information about the campaign. */ + campaignDetails?: CampaignDetails; + /** Compiles details describing how the messaging campaign will work, for example whether opt-in and opt-out will be required and how will the messages for those actions look like. */ + messageDetails?: MessageDetails; +} + +/** Contains response data for the upsertUSCampaign operation. */ +export type TenDlcUpsertUSCampaignResponse = USCampaign; + +/** Optional parameters. */ +export interface TenDlcDeleteUSCampaignOptionalParams + extends coreClient.OperationOptions {} + +/** Optional parameters. */ +export interface TenDlcGetUSCampaignOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the getUSCampaign operation. */ +export type TenDlcGetUSCampaignResponse = USCampaign; + +/** Optional parameters. */ +export interface TenDlcSubmitUSCampaignOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the submitUSCampaign operation. */ +export type TenDlcSubmitUSCampaignResponse = USCampaign; + +/** Optional parameters. */ +export interface TenDlcGetUSCampaignsOptionalParams + extends coreClient.OperationOptions { + skip?: number; + top?: number; + filter?: string; +} + +/** Contains response data for the getUSCampaigns operation. */ +export type TenDlcGetUSCampaignsResponse = USCampaigns; + +/** Optional parameters. */ +export interface TenDlcCancelUSCampaignOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the cancelUSCampaign operation. */ +export type TenDlcCancelUSCampaignResponse = USCampaign; + +/** Optional parameters. */ +export interface TenDlcGetCostsOptionalParams + extends coreClient.OperationOptions { + /** The number of items to skip in the result set (default: 0). */ + skip?: number; + /** The maximum number of items to return in the result set (default: 100). */ + top?: number; +} + +/** Contains response data for the getCosts operation. */ +export type TenDlcGetCostsResponse = TenDlcCosts; + +/** Optional parameters. */ +export interface TenDlcGetUSBrandsNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the getUSBrandsNext operation. */ +export type TenDlcGetUSBrandsNextResponse = USBrands; + +/** Optional parameters. */ +export interface TenDlcGetUSCampaignsNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the getUSCampaignsNext operation. */ +export type TenDlcGetUSCampaignsNextResponse = USCampaigns; + +/** Optional parameters. */ +export interface TenDlcGetCostsNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the getCostsNext operation. */ +export type TenDlcGetCostsNextResponse = TenDlcCosts; + +/** Optional parameters. */ +export interface TenDLCClientOptionalParams + extends coreClient.ServiceClientOptions { + /** Api Version */ + apiVersion?: string; + /** Overrides client endpoint. */ + endpoint?: string; +} diff --git a/sdk/communication/communication-ten-dlc/src/generated/src/models/mappers.ts b/sdk/communication/communication-ten-dlc/src/generated/src/models/mappers.ts new file mode 100644 index 000000000000..df06892e5b32 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/generated/src/models/mappers.ts @@ -0,0 +1,702 @@ +/* + * 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 * as coreClient from "@azure/core-client"; + +export const USBrand: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "USBrand", + modelProperties: { + id: { + serializedName: "id", + required: true, + type: { + name: "Uuid", + }, + }, + statusUpdatedDate: { + serializedName: "statusUpdatedDate", + type: { + name: "DateTime", + }, + }, + status: { + serializedName: "status", + type: { + name: "String", + }, + }, + costs: { + serializedName: "costs", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "TenDlcCost", + }, + }, + }, + }, + submissionDate: { + serializedName: "submissionDate", + type: { + name: "DateTime", + }, + }, + reviewNotes: { + serializedName: "reviewNotes", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ReviewNote", + }, + }, + }, + }, + brandDetails: { + serializedName: "brandDetails", + type: { + name: "Composite", + className: "BrandDetails", + }, + }, + }, + }, +}; + +export const TenDlcCost: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "TenDlcCost", + modelProperties: { + type: { + serializedName: "type", + type: { + name: "String", + }, + }, + amount: { + serializedName: "amount", + type: { + name: "Number", + }, + }, + currencyCode: { + serializedName: "currencyCode", + type: { + name: "String", + }, + }, + countryCode: { + serializedName: "countryCode", + type: { + name: "String", + }, + }, + billingFrequency: { + serializedName: "billingFrequency", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const ReviewNote: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ReviewNote", + modelProperties: { + message: { + serializedName: "message", + type: { + name: "String", + }, + }, + date: { + serializedName: "date", + type: { + name: "DateTime", + }, + }, + }, + }, +}; + +export const BrandDetails: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "BrandDetails", + modelProperties: { + name: { + constraints: { + MaxLength: 255, + }, + serializedName: "name", + type: { + name: "String", + }, + }, + companyName: { + constraints: { + MaxLength: 255, + }, + serializedName: "companyName", + type: { + name: "String", + }, + }, + companyVertical: { + serializedName: "companyVertical", + type: { + name: "String", + }, + }, + contactInformation: { + serializedName: "contactInformation", + type: { + name: "Composite", + className: "ContactInformation", + }, + }, + address: { + serializedName: "address", + type: { + name: "Composite", + className: "Address", + }, + }, + entityType: { + serializedName: "entityType", + type: { + name: "String", + }, + }, + stockExchange: { + serializedName: "stockExchange", + type: { + name: "String", + }, + }, + stockSymbol: { + constraints: { + MaxLength: 10, + }, + serializedName: "stockSymbol", + type: { + name: "String", + }, + }, + alternateBusinessIdType: { + serializedName: "alternateBusinessIdType", + type: { + name: "String", + }, + }, + alternateBusinessId: { + constraints: { + MaxLength: 50, + }, + serializedName: "alternateBusinessId", + type: { + name: "String", + }, + }, + taxNumber: { + constraints: { + MaxLength: 21, + }, + serializedName: "taxNumber", + type: { + name: "String", + }, + }, + taxNumberIssuingCountry: { + serializedName: "taxNumberIssuingCountry", + type: { + name: "String", + }, + }, + url: { + constraints: { + MaxLength: 100, + }, + serializedName: "url", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const ContactInformation: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ContactInformation", + modelProperties: { + phone: { + serializedName: "phone", + type: { + name: "String", + }, + }, + email: { + constraints: { + MaxLength: 100, + }, + serializedName: "email", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const Address: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Address", + modelProperties: { + line1: { + serializedName: "line1", + type: { + name: "String", + }, + }, + line2: { + serializedName: "line2", + type: { + name: "String", + }, + }, + city: { + constraints: { + MaxLength: 100, + }, + serializedName: "city", + type: { + name: "String", + }, + }, + state: { + constraints: { + MaxLength: 20, + }, + serializedName: "state", + type: { + name: "String", + }, + }, + postalCode: { + constraints: { + MaxLength: 10, + }, + serializedName: "postalCode", + type: { + name: "String", + }, + }, + country: { + serializedName: "country", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const CommunicationErrorResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CommunicationErrorResponse", + modelProperties: { + error: { + serializedName: "error", + type: { + name: "Composite", + className: "CommunicationError", + }, + }, + }, + }, +}; + +export const CommunicationError: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CommunicationError", + modelProperties: { + code: { + serializedName: "code", + required: true, + type: { + name: "String", + }, + }, + message: { + serializedName: "message", + required: true, + type: { + name: "String", + }, + }, + target: { + serializedName: "target", + readOnly: true, + type: { + name: "String", + }, + }, + details: { + serializedName: "details", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "CommunicationError", + }, + }, + }, + }, + innerError: { + serializedName: "innererror", + type: { + name: "Composite", + className: "CommunicationError", + }, + }, + }, + }, +}; + +export const USBrands: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "USBrands", + modelProperties: { + brands: { + serializedName: "brands", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "USBrand", + }, + }, + }, + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const USCampaign: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "USCampaign", + modelProperties: { + id: { + serializedName: "id", + required: true, + type: { + name: "Uuid", + }, + }, + brandId: { + serializedName: "brandId", + type: { + name: "Uuid", + }, + }, + status: { + serializedName: "status", + type: { + name: "String", + }, + }, + statusUpdatedDate: { + serializedName: "statusUpdatedDate", + type: { + name: "DateTime", + }, + }, + costs: { + serializedName: "costs", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "TenDlcCost", + }, + }, + }, + }, + submissionDate: { + serializedName: "submissionDate", + type: { + name: "DateTime", + }, + }, + reviewNotes: { + serializedName: "reviewNotes", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ReviewNote", + }, + }, + }, + }, + phoneNumberCount: { + serializedName: "phoneNumberCount", + type: { + name: "Number", + }, + }, + campaignDetails: { + serializedName: "campaignDetails", + type: { + name: "Composite", + className: "CampaignDetails", + }, + }, + messageDetails: { + serializedName: "messageDetails", + type: { + name: "Composite", + className: "MessageDetails", + }, + }, + }, + }, +}; + +export const CampaignDetails: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CampaignDetails", + modelProperties: { + callToAction: { + serializedName: "callToAction", + type: { + name: "String", + }, + }, + description: { + serializedName: "description", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const MessageDetails: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "MessageDetails", + modelProperties: { + useCase: { + serializedName: "useCase", + type: { + name: "Composite", + className: "UseCase", + }, + }, + helpAnswerToUserRequired: { + serializedName: "helpAnswerToUserRequired", + type: { + name: "Boolean", + }, + }, + helpAnswerToUser: { + serializedName: "helpAnswerToUser", + type: { + name: "String", + }, + }, + optOutAnswerToUserRequired: { + serializedName: "optOutAnswerToUserRequired", + type: { + name: "Boolean", + }, + }, + optOutAnswerToUser: { + serializedName: "optOutAnswerToUser", + type: { + name: "String", + }, + }, + optInMessageToUserRequired: { + serializedName: "optInMessageToUserRequired", + type: { + name: "Boolean", + }, + }, + optInMessageToUser: { + serializedName: "optInMessageToUser", + type: { + name: "String", + }, + }, + hasEmbeddedLink: { + serializedName: "hasEmbeddedLink", + type: { + name: "Boolean", + }, + }, + hasEmbeddedPhone: { + serializedName: "hasEmbeddedPhone", + type: { + name: "Boolean", + }, + }, + termsAndConditionsAccepted: { + serializedName: "termsAndConditionsAccepted", + type: { + name: "Boolean", + }, + }, + hasAgeGatedContent: { + serializedName: "hasAgeGatedContent", + type: { + name: "Boolean", + }, + }, + hasDirectLending: { + serializedName: "hasDirectLending", + type: { + name: "Boolean", + }, + }, + }, + }, +}; + +export const UseCase: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "UseCase", + modelProperties: { + contentType: { + serializedName: "contentType", + type: { + name: "String", + }, + }, + subContentTypes: { + serializedName: "subContentTypes", + type: { + name: "Sequence", + element: { + type: { + name: "Enum", + allowedValues: [ + "TwoFactorAuthentication", + "AccountNotification", + "CustomerCare", + "DeliveryNotification", + "FraudAlert", + "HigherEducation", + "Marketing", + "PollingVoting", + "PublicServiceAnnouncement", + "SecurityAlert", + ], + }, + }, + }, + }, + sampleMessages: { + serializedName: "sampleMessages", + type: { + name: "Sequence", + element: { + type: { + name: "String", + }, + }, + }, + }, + }, + }, +}; + +export const USCampaigns: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "USCampaigns", + modelProperties: { + campaigns: { + serializedName: "campaigns", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "USCampaign", + }, + }, + }, + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String", + }, + }, + }, + }, +}; + +export const TenDlcCosts: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "TenDlcCosts", + modelProperties: { + costs: { + serializedName: "costs", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "TenDlcCost", + }, + }, + }, + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String", + }, + }, + }, + }, +}; diff --git a/sdk/communication/communication-ten-dlc/src/generated/src/models/parameters.ts b/sdk/communication/communication-ten-dlc/src/generated/src/models/parameters.ts new file mode 100644 index 000000000000..8b530ff0c326 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/generated/src/models/parameters.ts @@ -0,0 +1,216 @@ +/* + * 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 { + OperationParameter, + OperationURLParameter, + OperationQueryParameter, +} from "@azure/core-client"; +import { + USBrand as USBrandMapper, + USCampaign as USCampaignMapper, +} from "../models/mappers"; + +export const contentType: OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/merge-patch+json", + isConstant: true, + serializedName: "Content-Type", + type: { + name: "String", + }, + }, +}; + +export const accept: OperationParameter = { + parameterPath: "accept", + mapper: { + defaultValue: "application/json", + isConstant: true, + serializedName: "Accept", + type: { + name: "String", + }, + }, +}; + +export const id: OperationParameter = { + parameterPath: "id", + mapper: USBrandMapper, +}; + +export const statusUpdatedDate: OperationParameter = { + parameterPath: ["options", "statusUpdatedDate"], + mapper: USBrandMapper, +}; + +export const status: OperationParameter = { + parameterPath: ["options", "status"], + mapper: USBrandMapper, +}; + +export const costs: OperationParameter = { + parameterPath: ["options", "costs"], + mapper: USBrandMapper, +}; + +export const submissionDate: OperationParameter = { + parameterPath: ["options", "submissionDate"], + mapper: USBrandMapper, +}; + +export const reviewNotes: OperationParameter = { + parameterPath: ["options", "reviewNotes"], + mapper: USBrandMapper, +}; + +export const brandDetails: OperationParameter = { + parameterPath: ["options", "brandDetails"], + mapper: USBrandMapper, +}; + +export const endpoint: OperationURLParameter = { + parameterPath: "endpoint", + mapper: { + serializedName: "endpoint", + required: true, + type: { + name: "String", + }, + }, + skipEncoding: true, +}; + +export const brandId: OperationURLParameter = { + parameterPath: "brandId", + mapper: { + serializedName: "brandId", + required: true, + type: { + name: "Uuid", + }, + }, +}; + +export const apiVersion: OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + defaultValue: "2024-05-01-preview", + isConstant: true, + serializedName: "api-version", + type: { + name: "String", + }, + }, +}; + +export const skip: OperationQueryParameter = { + parameterPath: ["options", "skip"], + mapper: { + defaultValue: 0, + serializedName: "skip", + type: { + name: "Number", + }, + }, +}; + +export const top: OperationQueryParameter = { + parameterPath: ["options", "top"], + mapper: { + defaultValue: 100, + serializedName: "top", + type: { + name: "Number", + }, + }, +}; + +export const filter: OperationQueryParameter = { + parameterPath: ["options", "filter"], + mapper: { + serializedName: "filter", + type: { + name: "String", + }, + }, +}; + +export const id1: OperationParameter = { + parameterPath: "id", + mapper: USCampaignMapper, +}; + +export const brandId1: OperationParameter = { + parameterPath: ["options", "brandId"], + mapper: USCampaignMapper, +}; + +export const status1: OperationParameter = { + parameterPath: ["options", "status"], + mapper: USCampaignMapper, +}; + +export const statusUpdatedDate1: OperationParameter = { + parameterPath: ["options", "statusUpdatedDate"], + mapper: USCampaignMapper, +}; + +export const costs1: OperationParameter = { + parameterPath: ["options", "costs"], + mapper: USCampaignMapper, +}; + +export const submissionDate1: OperationParameter = { + parameterPath: ["options", "submissionDate"], + mapper: USCampaignMapper, +}; + +export const reviewNotes1: OperationParameter = { + parameterPath: ["options", "reviewNotes"], + mapper: USCampaignMapper, +}; + +export const phoneNumberCount: OperationParameter = { + parameterPath: ["options", "phoneNumberCount"], + mapper: USCampaignMapper, +}; + +export const campaignDetails: OperationParameter = { + parameterPath: ["options", "campaignDetails"], + mapper: USCampaignMapper, +}; + +export const messageDetails: OperationParameter = { + parameterPath: ["options", "messageDetails"], + mapper: USCampaignMapper, +}; + +export const campaignId: OperationURLParameter = { + parameterPath: "campaignId", + mapper: { + serializedName: "campaignId", + required: true, + type: { + name: "Uuid", + }, + }, +}; + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", + mapper: { + serializedName: "nextLink", + required: true, + type: { + name: "String", + }, + }, + skipEncoding: true, +}; diff --git a/sdk/communication/communication-ten-dlc/src/generated/src/operations/index.ts b/sdk/communication/communication-ten-dlc/src/generated/src/operations/index.ts new file mode 100644 index 000000000000..e3deb8476c0a --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/generated/src/operations/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export * from "./tenDlc"; diff --git a/sdk/communication/communication-ten-dlc/src/generated/src/operations/tenDlc.ts b/sdk/communication/communication-ten-dlc/src/generated/src/operations/tenDlc.ts new file mode 100644 index 000000000000..10e0044a78af --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/generated/src/operations/tenDlc.ts @@ -0,0 +1,836 @@ +/* + * 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"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { TenDlc } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { TenDLCClient } from "../tenDLCClient"; +import { + USBrand, + TenDlcGetUSBrandsNextOptionalParams, + TenDlcGetUSBrandsOptionalParams, + TenDlcGetUSBrandsResponse, + USCampaign, + TenDlcGetUSCampaignsNextOptionalParams, + TenDlcGetUSCampaignsOptionalParams, + TenDlcGetUSCampaignsResponse, + TenDlcCost, + TenDlcGetCostsNextOptionalParams, + TenDlcGetCostsOptionalParams, + TenDlcGetCostsResponse, + TenDlcUpsertUSBrandOptionalParams, + TenDlcUpsertUSBrandResponse, + TenDlcDeleteUSBrandOptionalParams, + TenDlcGetUSBrandOptionalParams, + TenDlcGetUSBrandResponse, + TenDlcSubmitUSBrandOptionalParams, + TenDlcSubmitUSBrandResponse, + TenDlcCancelUSBrandOptionalParams, + TenDlcCancelUSBrandResponse, + TenDlcUpsertUSCampaignOptionalParams, + TenDlcUpsertUSCampaignResponse, + TenDlcDeleteUSCampaignOptionalParams, + TenDlcGetUSCampaignOptionalParams, + TenDlcGetUSCampaignResponse, + TenDlcSubmitUSCampaignOptionalParams, + TenDlcSubmitUSCampaignResponse, + TenDlcCancelUSCampaignOptionalParams, + TenDlcCancelUSCampaignResponse, + TenDlcGetUSBrandsNextResponse, + TenDlcGetUSCampaignsNextResponse, + TenDlcGetCostsNextResponse, +} from "../models"; + +/// +/** Class containing TenDlc operations. */ +export class TenDlcImpl implements TenDlc { + private readonly client: TenDLCClient; + + /** + * Initialize a new instance of the class TenDlc class. + * @param client Reference to the service client + */ + constructor(client: TenDLCClient) { + this.client = client; + } + + /** @param options The options parameters. */ + public listUSBrands( + options?: TenDlcGetUSBrandsOptionalParams, + ): PagedAsyncIterableIterator { + const iter = this.getUSBrandsPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.getUSBrandsPagingPage(options, settings); + }, + }; + } + + private async *getUSBrandsPagingPage( + options?: TenDlcGetUSBrandsOptionalParams, + settings?: PageSettings, + ): AsyncIterableIterator { + let result: TenDlcGetUSBrandsResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._getUSBrands(options); + let page = result.brands || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._getUSBrandsNext(continuationToken, options); + continuationToken = result.nextLink; + let page = result.brands || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *getUSBrandsPagingAll( + options?: TenDlcGetUSBrandsOptionalParams, + ): AsyncIterableIterator { + for await (const page of this.getUSBrandsPagingPage(options)) { + yield* page; + } + } + + /** @param options The options parameters. */ + public listUSCampaigns( + options?: TenDlcGetUSCampaignsOptionalParams, + ): PagedAsyncIterableIterator { + const iter = this.getUSCampaignsPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.getUSCampaignsPagingPage(options, settings); + }, + }; + } + + private async *getUSCampaignsPagingPage( + options?: TenDlcGetUSCampaignsOptionalParams, + settings?: PageSettings, + ): AsyncIterableIterator { + let result: TenDlcGetUSCampaignsResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._getUSCampaigns(options); + let page = result.campaigns || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._getUSCampaignsNext(continuationToken, options); + continuationToken = result.nextLink; + let page = result.campaigns || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *getUSCampaignsPagingAll( + options?: TenDlcGetUSCampaignsOptionalParams, + ): AsyncIterableIterator { + for await (const page of this.getUSCampaignsPagingPage(options)) { + yield* page; + } + } + + /** + * This method supports pagination via the "skip" and "top" query parameters. + * @param options The options parameters. + */ + public listCosts( + options?: TenDlcGetCostsOptionalParams, + ): PagedAsyncIterableIterator { + const iter = this.getCostsPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.getCostsPagingPage(options, settings); + }, + }; + } + + private async *getCostsPagingPage( + options?: TenDlcGetCostsOptionalParams, + settings?: PageSettings, + ): AsyncIterableIterator { + let result: TenDlcGetCostsResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._getCosts(options); + let page = result.costs || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._getCostsNext(continuationToken, options); + continuationToken = result.nextLink; + let page = result.costs || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *getCostsPagingAll( + options?: TenDlcGetCostsOptionalParams, + ): AsyncIterableIterator { + for await (const page of this.getCostsPagingPage(options)) { + yield* page; + } + } + + /** + * @param brandId + * @param id Unique identifier that corresponds to a brand + * @param options The options parameters. + */ + async upsertUSBrand( + brandId: string, + id: string, + options?: TenDlcUpsertUSBrandOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient.upsertUSBrand", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { brandId, id, options }, + upsertUSBrandOperationSpec, + ) as Promise; + }, + ); + } + + /** + * @param brandId + * @param options The options parameters. + */ + async deleteUSBrand( + brandId: string, + options?: TenDlcDeleteUSBrandOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient.deleteUSBrand", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { brandId, options }, + deleteUSBrandOperationSpec, + ) as Promise; + }, + ); + } + + /** + * @param brandId + * @param options The options parameters. + */ + async getUSBrand( + brandId: string, + options?: TenDlcGetUSBrandOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient.getUSBrand", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { brandId, options }, + getUSBrandOperationSpec, + ) as Promise; + }, + ); + } + + /** + * @param brandId + * @param options The options parameters. + */ + async submitUSBrand( + brandId: string, + options?: TenDlcSubmitUSBrandOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient.submitUSBrand", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { brandId, options }, + submitUSBrandOperationSpec, + ) as Promise; + }, + ); + } + + /** @param options The options parameters. */ + private async _getUSBrands( + options?: TenDlcGetUSBrandsOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient._getUSBrands", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { options }, + getUSBrandsOperationSpec, + ) as Promise; + }, + ); + } + + /** + * @param brandId + * @param options The options parameters. + */ + async cancelUSBrand( + brandId: string, + options?: TenDlcCancelUSBrandOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient.cancelUSBrand", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { brandId, options }, + cancelUSBrandOperationSpec, + ) as Promise; + }, + ); + } + + /** + * @param campaignId + * @param id Unique identifier that corresponds to a campaign + * @param options The options parameters. + */ + async upsertUSCampaign( + campaignId: string, + id: string, + options?: TenDlcUpsertUSCampaignOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient.upsertUSCampaign", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { campaignId, id, options }, + upsertUSCampaignOperationSpec, + ) as Promise; + }, + ); + } + + /** + * @param campaignId + * @param options The options parameters. + */ + async deleteUSCampaign( + campaignId: string, + options?: TenDlcDeleteUSCampaignOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient.deleteUSCampaign", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { campaignId, options }, + deleteUSCampaignOperationSpec, + ) as Promise; + }, + ); + } + + /** + * @param campaignId + * @param options The options parameters. + */ + async getUSCampaign( + campaignId: string, + options?: TenDlcGetUSCampaignOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient.getUSCampaign", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { campaignId, options }, + getUSCampaignOperationSpec, + ) as Promise; + }, + ); + } + + /** + * @param campaignId + * @param options The options parameters. + */ + async submitUSCampaign( + campaignId: string, + options?: TenDlcSubmitUSCampaignOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient.submitUSCampaign", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { campaignId, options }, + submitUSCampaignOperationSpec, + ) as Promise; + }, + ); + } + + /** @param options The options parameters. */ + private async _getUSCampaigns( + options?: TenDlcGetUSCampaignsOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient._getUSCampaigns", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { options }, + getUSCampaignsOperationSpec, + ) as Promise; + }, + ); + } + + /** + * @param campaignId + * @param options The options parameters. + */ + async cancelUSCampaign( + campaignId: string, + options?: TenDlcCancelUSCampaignOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient.cancelUSCampaign", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { campaignId, options }, + cancelUSCampaignOperationSpec, + ) as Promise; + }, + ); + } + + /** + * This method supports pagination via the "skip" and "top" query parameters. + * @param options The options parameters. + */ + private async _getCosts( + options?: TenDlcGetCostsOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient._getCosts", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { options }, + getCostsOperationSpec, + ) as Promise; + }, + ); + } + + /** + * GetUSBrandsNext + * @param nextLink The nextLink from the previous successful call to the GetUSBrands method. + * @param options The options parameters. + */ + private async _getUSBrandsNext( + nextLink: string, + options?: TenDlcGetUSBrandsNextOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient._getUSBrandsNext", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { nextLink, options }, + getUSBrandsNextOperationSpec, + ) as Promise; + }, + ); + } + + /** + * GetUSCampaignsNext + * @param nextLink The nextLink from the previous successful call to the GetUSCampaigns method. + * @param options The options parameters. + */ + private async _getUSCampaignsNext( + nextLink: string, + options?: TenDlcGetUSCampaignsNextOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient._getUSCampaignsNext", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { nextLink, options }, + getUSCampaignsNextOperationSpec, + ) as Promise; + }, + ); + } + + /** + * GetCostsNext + * @param nextLink The nextLink from the previous successful call to the GetCosts method. + * @param options The options parameters. + */ + private async _getCostsNext( + nextLink: string, + options?: TenDlcGetCostsNextOptionalParams, + ): Promise { + return tracingClient.withSpan( + "TenDLCClient._getCostsNext", + options ?? {}, + async (options) => { + return this.client.sendOperationRequest( + { nextLink, options }, + getCostsNextOperationSpec, + ) as Promise; + }, + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const upsertUSBrandOperationSpec: coreClient.OperationSpec = { + path: "/tendlc/countries/US/brands/{brandId}", + httpMethod: "PATCH", + responses: { + 200: { + bodyMapper: Mappers.USBrand, + }, + 201: { + bodyMapper: Mappers.USBrand, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + requestBody: { + parameterPath: { + id: ["id"], + statusUpdatedDate: ["options", "statusUpdatedDate"], + status: ["options", "status"], + costs: ["options", "costs"], + submissionDate: ["options", "submissionDate"], + reviewNotes: ["options", "reviewNotes"], + brandDetails: ["options", "brandDetails"], + }, + mapper: { ...Mappers.USBrand, required: true }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.endpoint, Parameters.brandId], + headerParameters: [Parameters.contentType, Parameters.accept], + mediaType: "json", + serializer, +}; +const deleteUSBrandOperationSpec: coreClient.OperationSpec = { + path: "/tendlc/countries/US/brands/{brandId}", + httpMethod: "DELETE", + responses: { + 204: {}, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.endpoint, Parameters.brandId], + headerParameters: [Parameters.accept], + serializer, +}; +const getUSBrandOperationSpec: coreClient.OperationSpec = { + path: "/tendlc/countries/US/brands/{brandId}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.USBrand, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.endpoint, Parameters.brandId], + headerParameters: [Parameters.accept], + serializer, +}; +const submitUSBrandOperationSpec: coreClient.OperationSpec = { + path: "/tendlc/countries/US/brands/{brandId}:submit", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.USBrand, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.endpoint, Parameters.brandId], + headerParameters: [Parameters.accept], + serializer, +}; +const getUSBrandsOperationSpec: coreClient.OperationSpec = { + path: "/tendlc/countries/US/brands", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.USBrands, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + queryParameters: [ + Parameters.apiVersion, + Parameters.skip, + Parameters.top, + Parameters.filter, + ], + urlParameters: [Parameters.endpoint], + headerParameters: [Parameters.accept], + serializer, +}; +const cancelUSBrandOperationSpec: coreClient.OperationSpec = { + path: "/tendlc/countries/US/brands/{brandId}:cancel", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.USBrand, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.endpoint, Parameters.brandId], + headerParameters: [Parameters.accept], + serializer, +}; +const upsertUSCampaignOperationSpec: coreClient.OperationSpec = { + path: "/tendlc/countries/US/campaigns/{campaignId}", + httpMethod: "PATCH", + responses: { + 200: { + bodyMapper: Mappers.USCampaign, + }, + 201: { + bodyMapper: Mappers.USCampaign, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + requestBody: { + parameterPath: { + id: ["id"], + brandId: ["options", "brandId"], + status: ["options", "status"], + statusUpdatedDate: ["options", "statusUpdatedDate"], + costs: ["options", "costs"], + submissionDate: ["options", "submissionDate"], + reviewNotes: ["options", "reviewNotes"], + phoneNumberCount: ["options", "phoneNumberCount"], + campaignDetails: ["options", "campaignDetails"], + messageDetails: ["options", "messageDetails"], + }, + mapper: { ...Mappers.USCampaign, required: true }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.endpoint, Parameters.campaignId], + headerParameters: [Parameters.contentType, Parameters.accept], + mediaType: "json", + serializer, +}; +const deleteUSCampaignOperationSpec: coreClient.OperationSpec = { + path: "/tendlc/countries/US/campaigns/{campaignId}", + httpMethod: "DELETE", + responses: { + 204: {}, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.endpoint, Parameters.campaignId], + headerParameters: [Parameters.accept], + serializer, +}; +const getUSCampaignOperationSpec: coreClient.OperationSpec = { + path: "/tendlc/countries/US/campaigns/{campaignId}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.USCampaign, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.endpoint, Parameters.campaignId], + headerParameters: [Parameters.accept], + serializer, +}; +const submitUSCampaignOperationSpec: coreClient.OperationSpec = { + path: "/tendlc/countries/US/campaigns/{campaignId}:submit", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.USCampaign, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.endpoint, Parameters.campaignId], + headerParameters: [Parameters.accept], + serializer, +}; +const getUSCampaignsOperationSpec: coreClient.OperationSpec = { + path: "/tendlc/countries/US/campaigns", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.USCampaigns, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + queryParameters: [ + Parameters.apiVersion, + Parameters.skip, + Parameters.top, + Parameters.filter, + ], + urlParameters: [Parameters.endpoint], + headerParameters: [Parameters.accept], + serializer, +}; +const cancelUSCampaignOperationSpec: coreClient.OperationSpec = { + path: "/tendlc/countries/US/campaigns/{campaignId}:cancel", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.USCampaign, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.endpoint, Parameters.campaignId], + headerParameters: [Parameters.accept], + serializer, +}; +const getCostsOperationSpec: coreClient.OperationSpec = { + path: "/tendlc/costs", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.TenDlcCosts, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + queryParameters: [Parameters.apiVersion, Parameters.skip, Parameters.top], + urlParameters: [Parameters.endpoint], + headerParameters: [Parameters.accept], + serializer, +}; +const getUSBrandsNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.USBrands, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + urlParameters: [Parameters.endpoint, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer, +}; +const getUSCampaignsNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.USCampaigns, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + urlParameters: [Parameters.endpoint, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer, +}; +const getCostsNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.TenDlcCosts, + }, + default: { + bodyMapper: Mappers.CommunicationErrorResponse, + }, + }, + urlParameters: [Parameters.endpoint, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer, +}; diff --git a/sdk/communication/communication-ten-dlc/src/generated/src/operationsInterfaces/index.ts b/sdk/communication/communication-ten-dlc/src/generated/src/operationsInterfaces/index.ts new file mode 100644 index 000000000000..e3deb8476c0a --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/generated/src/operationsInterfaces/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export * from "./tenDlc"; diff --git a/sdk/communication/communication-ten-dlc/src/generated/src/operationsInterfaces/tenDlc.ts b/sdk/communication/communication-ten-dlc/src/generated/src/operationsInterfaces/tenDlc.ts new file mode 100644 index 000000000000..f88a16124cb2 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/generated/src/operationsInterfaces/tenDlc.ts @@ -0,0 +1,139 @@ +/* + * 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 { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { + USBrand, + TenDlcGetUSBrandsOptionalParams, + USCampaign, + TenDlcGetUSCampaignsOptionalParams, + TenDlcCost, + TenDlcGetCostsOptionalParams, + TenDlcUpsertUSBrandOptionalParams, + TenDlcUpsertUSBrandResponse, + TenDlcDeleteUSBrandOptionalParams, + TenDlcGetUSBrandOptionalParams, + TenDlcGetUSBrandResponse, + TenDlcSubmitUSBrandOptionalParams, + TenDlcSubmitUSBrandResponse, + TenDlcCancelUSBrandOptionalParams, + TenDlcCancelUSBrandResponse, + TenDlcUpsertUSCampaignOptionalParams, + TenDlcUpsertUSCampaignResponse, + TenDlcDeleteUSCampaignOptionalParams, + TenDlcGetUSCampaignOptionalParams, + TenDlcGetUSCampaignResponse, + TenDlcSubmitUSCampaignOptionalParams, + TenDlcSubmitUSCampaignResponse, + TenDlcCancelUSCampaignOptionalParams, + TenDlcCancelUSCampaignResponse, +} from "../models"; + +/// +/** Interface representing a TenDlc. */ +export interface TenDlc { + /** @param options The options parameters. */ + listUSBrands( + options?: TenDlcGetUSBrandsOptionalParams, + ): PagedAsyncIterableIterator; + /** @param options The options parameters. */ + listUSCampaigns( + options?: TenDlcGetUSCampaignsOptionalParams, + ): PagedAsyncIterableIterator; + /** + * This method supports pagination via the "skip" and "top" query parameters. + * @param options The options parameters. + */ + listCosts( + options?: TenDlcGetCostsOptionalParams, + ): PagedAsyncIterableIterator; + /** + * @param brandId + * @param id Unique identifier that corresponds to a brand + * @param options The options parameters. + */ + upsertUSBrand( + brandId: string, + id: string, + options?: TenDlcUpsertUSBrandOptionalParams, + ): Promise; + /** + * @param brandId + * @param options The options parameters. + */ + deleteUSBrand( + brandId: string, + options?: TenDlcDeleteUSBrandOptionalParams, + ): Promise; + /** + * @param brandId + * @param options The options parameters. + */ + getUSBrand( + brandId: string, + options?: TenDlcGetUSBrandOptionalParams, + ): Promise; + /** + * @param brandId + * @param options The options parameters. + */ + submitUSBrand( + brandId: string, + options?: TenDlcSubmitUSBrandOptionalParams, + ): Promise; + /** + * @param brandId + * @param options The options parameters. + */ + cancelUSBrand( + brandId: string, + options?: TenDlcCancelUSBrandOptionalParams, + ): Promise; + /** + * @param campaignId + * @param id Unique identifier that corresponds to a campaign + * @param options The options parameters. + */ + upsertUSCampaign( + campaignId: string, + id: string, + options?: TenDlcUpsertUSCampaignOptionalParams, + ): Promise; + /** + * @param campaignId + * @param options The options parameters. + */ + deleteUSCampaign( + campaignId: string, + options?: TenDlcDeleteUSCampaignOptionalParams, + ): Promise; + /** + * @param campaignId + * @param options The options parameters. + */ + getUSCampaign( + campaignId: string, + options?: TenDlcGetUSCampaignOptionalParams, + ): Promise; + /** + * @param campaignId + * @param options The options parameters. + */ + submitUSCampaign( + campaignId: string, + options?: TenDlcSubmitUSCampaignOptionalParams, + ): Promise; + /** + * @param campaignId + * @param options The options parameters. + */ + cancelUSCampaign( + campaignId: string, + options?: TenDlcCancelUSCampaignOptionalParams, + ): Promise; +} diff --git a/sdk/communication/communication-ten-dlc/src/generated/src/pagingHelper.ts b/sdk/communication/communication-ten-dlc/src/generated/src/pagingHelper.ts new file mode 100644 index 000000000000..205cccc26592 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/generated/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * 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. + */ + +export interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from + * that point later. + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined, +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/communication/communication-ten-dlc/src/generated/src/tenDLCClient.ts b/sdk/communication/communication-ten-dlc/src/generated/src/tenDLCClient.ts new file mode 100644 index 000000000000..995ad141b6d3 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/generated/src/tenDLCClient.ts @@ -0,0 +1,94 @@ +/* + * 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 * as coreClient from "@azure/core-client"; +import { + PipelineRequest, + PipelineResponse, + SendRequest, +} from "@azure/core-rest-pipeline"; +import { TenDlcImpl } from "./operations"; +import { TenDlc } from "./operationsInterfaces"; +import { TenDLCClientOptionalParams } from "./models"; + +export class TenDLCClient extends coreClient.ServiceClient { + endpoint: string; + apiVersion: string; + + /** + * Initializes a new instance of the TenDLCClient class. + * @param endpoint The communication resource, for example https://resourcename.communication.azure.com + * @param options The parameter options + */ + constructor(endpoint: string, options?: TenDLCClientOptionalParams) { + if (endpoint === undefined) { + throw new Error("'endpoint' cannot be null"); + } + + // Initializing default values for options + if (!options) { + options = {}; + } + const defaults: TenDLCClientOptionalParams = { + requestContentType: "application/json; charset=utf-8", + }; + + const packageDetails = `azsdk-js-communication-ten-dlc/1.0.0-beta.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` + : `${packageDetails}`; + + const optionsWithDefaults = { + ...defaults, + ...options, + userAgentOptions: { + userAgentPrefix, + }, + endpoint: options.endpoint ?? options.baseUri ?? "{endpoint}", + }; + super(optionsWithDefaults); + // Parameter assignments + this.endpoint = endpoint; + + // Assigning values to Constant parameters + this.apiVersion = options.apiVersion || "2024-05-01-preview"; + this.tenDlc = new TenDlcImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest, + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return "api-version=" + apiVersion; + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + }, + }; + this.pipeline.addPolicy(apiVersionPolicy); + } + + tenDlc: TenDlc; +} diff --git a/sdk/communication/communication-ten-dlc/src/generated/src/tracing.ts b/sdk/communication/communication-ten-dlc/src/generated/src/tracing.ts new file mode 100644 index 000000000000..38e19c44d1ef --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/generated/src/tracing.ts @@ -0,0 +1,15 @@ +/* + * 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 { createTracingClient } from "@azure/core-tracing"; + +export const tracingClient = createTracingClient({ + namespace: "Microsoft.Communication", + packageName: "@azure/communication-ten-dlc", + packageVersion: "1.0.0-beta.1" +}); diff --git a/sdk/communication/communication-ten-dlc/src/index.ts b/sdk/communication/communication-ten-dlc/src/index.ts new file mode 100644 index 000000000000..d82913a2842f --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/index.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export * from "./models"; +export * from "./tenDlcClient"; diff --git a/sdk/communication/communication-ten-dlc/src/models.ts b/sdk/communication/communication-ten-dlc/src/models.ts new file mode 100644 index 000000000000..9c7ddcd2bc0d --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/models.ts @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { + BrandDetails, + CampaignDetails, + TenDlcDeleteUSBrandOptionalParams, + TenDlcDeleteUSCampaignOptionalParams, + TenDlcGetUSBrandOptionalParams, + TenDlcGetUSBrandsOptionalParams, + TenDlcGetUSCampaignOptionalParams, + TenDlcGetUSCampaignsOptionalParams, + TenDlcGetCostsOptionalParams, + TenDlcSubmitUSBrandOptionalParams, + TenDlcSubmitUSCampaignOptionalParams, + MessageDetails, +} from "./generated/src/models"; + +/** + * Additional options for the Create or update brand request. + */ +export interface UpsertUSBrandOptions extends TenDlcGetUSBrandOptionalParams { + brandDetails: BrandDetails | undefined; +} + +/** + * Additional options for the Create or update campaign request. + */ +export interface UpsertUSCampaignOptions extends TenDlcGetUSCampaignOptionalParams { + brandId: string | undefined; + campaignDetails: CampaignDetails | undefined; + messageDetails: MessageDetails | undefined; +} + +/** + * Additional options for the Delete brand request. + */ +export interface DeleteBrandOptionalParams extends TenDlcDeleteUSBrandOptionalParams {} + +/** + * Additional options for the Delete campaign request. + */ +export interface DeleteCampaignOptionalParams extends TenDlcDeleteUSCampaignOptionalParams {} + +/** + * Additional options for the Get brand request. + */ +export interface GetBrandOptionalParams extends TenDlcGetUSBrandOptionalParams {} + +/** + * Additional options for the Get brands request. + */ +export interface GetBrandsOptionalParams extends TenDlcGetUSBrandsOptionalParams {} + +/** + * Additional options for the Get campaign request. + */ +export interface GetCampaignOptionalParams extends TenDlcGetUSCampaignOptionalParams {} + +/** + * Additional options for the List Campaigns request. + */ +export interface ListCampaignsOptionalParams extends TenDlcGetUSCampaignsOptionalParams {} + +/** + * Additional options for the List local number costs request. + */ +export interface ListCostsOptions extends TenDlcGetCostsOptionalParams {} + +/** + * Additional options for the Submit brand request. + */ +export interface SubmitBrandOptionalParams extends TenDlcSubmitUSBrandOptionalParams {} + +/** + * Additional options for the Submit campaign request. + */ +export interface SubmitCampaignOptionalParams extends TenDlcSubmitUSCampaignOptionalParams {} + +export { + Address, + AlternateBusinessIdType, + BillingFrequency, + BrandDetails, + BrandStatus, + CampaignDetails, + CampaignStatus, + CompanyVertical, + ContactInformation, + ContentType, + EntityType, + MessageDetails, + ReviewNote, + StockExchange, + SubContentType, + TenDlcCost, + TenDlcCosts, + TenDlcCostType, + TenDlcCancelUSBrandOptionalParams, + TenDlcCancelUSCampaignOptionalParams, + TenDlcDeleteUSBrandOptionalParams, + TenDlcDeleteUSCampaignOptionalParams, + TenDlcGetUSBrandOptionalParams, + TenDlcGetUSBrandsOptionalParams, + TenDlcGetUSCampaignOptionalParams, + TenDlcGetUSCampaignsOptionalParams, + TenDlcGetCostsOptionalParams, + TenDlcSubmitUSBrandOptionalParams, + TenDlcSubmitUSCampaignOptionalParams, + TenDlcCancelUSBrandResponse, + TenDlcCancelUSCampaignResponse, + USBrand, + USBrands, + USCampaign, + USCampaigns, + UseCase, +} from "./generated/src/models/"; diff --git a/sdk/communication/communication-ten-dlc/src/tenDlcClient.ts b/sdk/communication/communication-ten-dlc/src/tenDlcClient.ts new file mode 100644 index 000000000000..a84858fbd745 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/tenDlcClient.ts @@ -0,0 +1,399 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { CommonClientOptions, InternalClientPipelineOptions } from "@azure/core-client"; +import { type KeyCredential, type TokenCredential, isTokenCredential } from "@azure/core-auth"; +import { + createCommunicationAuthPolicy, + isKeyCredential, + parseClientArguments, +} from "@azure/communication-common"; +import { TenDLCClient as TenDlcGeneratedClient } from "./generated/src/tenDLCClient"; +import type { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { tracingClient } from "./generated/src/tracing"; +import { logger } from "./utils/logger"; +import { createTenDlcPagingPolicy } from "./utils/customPipelinePolicies"; +import type { + TenDlcCancelUSBrandOptionalParams, + TenDlcCancelUSBrandResponse, + TenDlcCancelUSCampaignOptionalParams, + TenDlcCancelUSCampaignResponse, + TenDlcCost, + TenDlcSubmitUSBrandOptionalParams, + TenDlcSubmitUSCampaignOptionalParams, + USBrand, + USCampaign, +} from "./generated/src/models"; +import type { + DeleteBrandOptionalParams, + DeleteCampaignOptionalParams, + GetBrandOptionalParams, + GetBrandsOptionalParams, + GetCampaignOptionalParams, + ListCampaignsOptionalParams, + ListCostsOptions, + SubmitBrandOptionalParams, + SubmitCampaignOptionalParams, + UpsertUSBrandOptions, + UpsertUSCampaignOptions, +} from "./models"; + +/** + * Client options used to configure the TenDlcClient API requests. + */ +export interface TenDlcClientOptions extends CommonClientOptions {} + +const isTenDlcClientOptions = (options: any): options is TenDlcClientOptions => + options && !isKeyCredential(options) && !isTokenCredential(options); + +/** + * Client class for interacting with Azure Communication Services 10DLC Administration. + */ +export class TenDlcClient { + /** + * A reference to the auto-generated 10 DLC HTTP client. + */ + private readonly client: TenDlcGeneratedClient; + + public constructor(connectionString: string, options?: TenDlcClientOptions); + + public constructor(endpoint: string, credential: KeyCredential, options?: TenDlcClientOptions); + + public constructor(endpoint: string, credential: TokenCredential, options?: TenDlcClientOptions); + + public constructor( + connectionStringOrUrl: string, + credentialOrOptions?: KeyCredential | TokenCredential | TenDlcClientOptions, + maybeOptions: TenDlcClientOptions = {}, + ) { + const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions); + const options = isTenDlcClientOptions(credentialOrOptions) ? credentialOrOptions : maybeOptions; + + const internalPipelineOptions: InternalClientPipelineOptions = { + ...options, + ...{ + loggingOptions: { + logger: logger.info, + }, + }, + }; + + this.client = new TenDlcGeneratedClient(url, internalPipelineOptions); + const authPolicy = createCommunicationAuthPolicy(credential); + this.client.pipeline.addPolicy(authPolicy); + // This policy is temporary workarounds to address compatibility issues with Azure Core V2. + const tenDlcPagingPolicy = createTenDlcPagingPolicy(url); + this.client.pipeline.addPolicy(tenDlcPagingPolicy); + } + + /** + * Upserts a US brand with the given brand ID. + * + * @param brandId - The unique identifier for the brand. + * @param options - Optional parameters for upserting the US brand. + * @returns The upserted US brand. + */ + public upsertUSBrand( + brandId: string, + options: UpsertUSBrandOptions = { + brandDetails: {}, + }, + ): Promise { + const { span, updatedOptions } = tracingClient.startSpan("TenDlcClient-upsertUSBrand", options); + try { + return this.client.tenDlc.upsertUSBrand(brandId, brandId, updatedOptions); + } catch (e: any) { + span.setStatus({ + status: "error", + error: e, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Upserts a US campaign with the given campaign ID and options. + * + * @param campaingId - The ID of the campaign to upsert. + * @param options - The options for upserting the US campaign. + * @returns The upserted US campaign. + */ + public upsertUSCampaign( + campaingId: string, + options: UpsertUSCampaignOptions = { + brandId: "", + campaignDetails: {}, + messageDetails: {}, + }, + ): Promise { + const { span, updatedOptions } = tracingClient.startSpan( + "TenDlcClient-upsertUSCampaign", + options, + ); + try { + return this.client.tenDlc.upsertUSCampaign(campaingId, campaingId, updatedOptions); + } catch (e: any) { + span.setStatus({ + status: "error", + error: e, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Deletes a US brand by its ID. + * + * @param brandId - The unique identifier of the brand to be deleted. + * @param options - Optional parameters for the delete operation. + * @returns A promise that resolves when the brand is successfully deleted. + */ + public deleteUSBrand(brandId: string, options: DeleteBrandOptionalParams = {}): Promise { + const { span, updatedOptions } = tracingClient.startSpan("TenDlcClient-deleteUSBrand", options); + try { + return this.client.tenDlc.deleteUSBrand(brandId, updatedOptions); + } catch (e: any) { + span.setStatus({ + status: "error", + error: e, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Deletes a US campaign by its campaign ID. + * + * @param campaignId - The unique identifier of the campaign to be deleted. + * @param options - Optional parameters for the delete operation. + * @returns A promise that resolves when the campaign is successfully deleted. + */ + public deleteUSCampaign( + campaignId: string, + options: DeleteCampaignOptionalParams = {}, + ): Promise { + const { span, updatedOptions } = tracingClient.startSpan( + "TenDlcClient-deleteUSCampaign", + options, + ); + try { + return this.client.tenDlc.deleteUSCampaign(campaignId, updatedOptions); + } catch (e: any) { + span.setStatus({ + status: "error", + error: e, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Retrieves a US brand by its brand ID. + * + * @param brandId - The unique identifier of the US brand to retrieve. + * @param options - Optional parameters for the request. + * @returns The USBrand object. + */ + public getUSBrand(brandId: string, options: GetBrandOptionalParams = {}): Promise { + const { span, updatedOptions } = tracingClient.startSpan("TenDlcClient-getUSBrand", options); + try { + return this.client.tenDlc.getUSBrand(brandId, updatedOptions); + } catch (e: any) { + span.setStatus({ + status: "error", + error: e, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Lists US brands with optional parameters. + * + * @param options - Optional parameters for listing US brands. + * @returns An async iterable iterator for US brands. + */ + public listUSBrands(options: GetBrandsOptionalParams = {}): PagedAsyncIterableIterator { + const { span, updatedOptions } = tracingClient.startSpan("TenDlcClient-listUSBrands", options); + try { + return this.client.tenDlc.listUSBrands(updatedOptions); + } catch (e: any) { + span.setStatus({ + status: "error", + error: e, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Retrieves a US campaign by its campaign ID. + * + * @param campaignId - The unique identifier of the US campaign to retrieve. + * @param options - Optional parameters for the request. + * @returns The USCampaign object. + */ + public getUSCampaign( + campaignId: string, + options: GetCampaignOptionalParams = {}, + ): Promise { + const { span, updatedOptions } = tracingClient.startSpan("TenDlcClient-getUSCampaign", options); + try { + return this.client.tenDlc.getUSCampaign(campaignId, updatedOptions); + } catch (e: any) { + span.setStatus({ + status: "error", + error: e, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Lists US campaigns. + * + * @param options - Optional parameters for listing US campaigns. + * @returns An iterator that allows paging through US campaigns. + */ + public listUSCampaigns( + options: ListCampaignsOptionalParams = {}, + ): PagedAsyncIterableIterator { + const { span, updatedOptions } = tracingClient.startSpan( + "TenDlcClient-listUSCampaigns", + options, + ); + try { + return this.client.tenDlc.listUSCampaigns(updatedOptions); + } catch (e: any) { + span.setStatus({ + status: "error", + error: e, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Lists the costs associated with the TenDlc service. + * + * @param options - The options for listing costs. + * @returns An async iterable iterator that allows paging through the costs. + */ + public listCosts(options: ListCostsOptions = {}): PagedAsyncIterableIterator { + const { span, updatedOptions } = tracingClient.startSpan("TenDlcClient-listCosts", options); + try { + return this.client.tenDlc.listCosts(updatedOptions); + } catch (e: any) { + span.setStatus({ + status: "error", + error: e, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Submits a US brand for registration. + * + * @param brandId - The unique identifier of the brand to be submitted. + * @param options - Optional parameters for submitting the brand. + * @returns The submitted US brand. + */ + public submitUSBrand(brandId: string, options: SubmitBrandOptionalParams = {}): Promise { + return tracingClient.withSpan( + "TenDlcClient-submitUSBrand", + options, + (submitOptions: TenDlcSubmitUSBrandOptionalParams | undefined) => { + return this.client.tenDlc.submitUSBrand(brandId, submitOptions); + }, + ); + } + + /** + * Submits a US campaign for approval. + * + * @param campaignId - The unique identifier of the campaign to be submitted. + * @param options - Optional parameters for submitting the campaign. + * @returns The submitted US campaign. + */ + public submitUSCampaign( + campaignId: string, + options: SubmitCampaignOptionalParams = {}, + ): Promise { + return tracingClient.withSpan( + "TenDlcClient-submitUSCampaign", + options, + (submitOptions: TenDlcSubmitUSCampaignOptionalParams | undefined) => { + return this.client.tenDlc.submitUSCampaign(campaignId, submitOptions); + }, + ); + } + + /** + * Cancels a US brand. + * + * @param brandId - The ID of the brand to be canceled. + * @param options - Optional parameters for the cancellation request. + * @returns The response of the cancellation request. + */ + public cancelUSBrand( + brandId: string, + options?: TenDlcCancelUSBrandOptionalParams, + ): Promise { + const { span } = tracingClient.startSpan("TenDLCClient.cancelUSBrand", options); + try { + return this.client.tenDlc.cancelUSBrand(brandId, options); + } catch (e: any) { + span.setStatus({ + status: "error", + error: e, + }); + throw e; + } finally { + span.end(); + } + } + + /** + * Cancels a US campaign with the given campaign ID. + * + * @param campaignId - The ID of the campaign to be canceled. + * @param options - Optional parameters for canceling the campaign. + * @returns The response of the cancel operation. + */ + public cancelUSCampaign( + campaignId: string, + options?: TenDlcCancelUSCampaignOptionalParams, + ): Promise { + const { span } = tracingClient.startSpan("TenDLCClient.cancelUSCampaign", options); + try { + return this.client.tenDlc.cancelUSCampaign(campaignId, options); + } catch (e: any) { + span.setStatus({ + status: "error", + error: e, + }); + throw e; + } finally { + span.end(); + } + } +} diff --git a/sdk/communication/communication-ten-dlc/src/utils/customPipelinePolicies.ts b/sdk/communication/communication-ten-dlc/src/utils/customPipelinePolicies.ts new file mode 100644 index 000000000000..ae9860f9a034 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/utils/customPipelinePolicies.ts @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { FullOperationResponse } from "@azure/core-client"; +import type { + PipelinePolicy, + PipelineRequest, + PipelineResponse, + SendRequest, +} from "@azure/core-rest-pipeline"; + +/** + * Creates a `PipelinePolicy` that converts relative URL values in the `nextLink` property to absolute URLs. + * + * This is necessary because the Core V2 library does not support paging with relative links at time of writing. + * + * @param host - The base URL of the resource. + * @returns the `PipelinePolicy` that addresses the issue. + */ +export function createTenDlcPagingPolicy(host: string): PipelinePolicy { + return { + name: "tenDlcPagingPolicy", + async sendRequest(request: PipelineRequest, next: SendRequest): Promise { + const response: FullOperationResponse = await next(request); + let nextLink: string = response?.parsedBody?.nextLink; + + if (nextLink && !nextLink.startsWith(host)) { + nextLink = host.endsWith("/") ? nextLink.substring(1) : nextLink; + const absolutePath = `${host}${nextLink}`; + response.parsedBody.nextLink = absolutePath; + } + + return response; + }, + }; +} diff --git a/sdk/communication/communication-ten-dlc/src/utils/index.ts b/sdk/communication/communication-ten-dlc/src/utils/index.ts new file mode 100644 index 000000000000..110b45005a1c --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/utils/index.ts @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export * from "./logger"; diff --git a/sdk/communication/communication-ten-dlc/src/utils/logger.ts b/sdk/communication/communication-ten-dlc/src/utils/logger.ts new file mode 100644 index 000000000000..c78cd3cb46ce --- /dev/null +++ b/sdk/communication/communication-ten-dlc/src/utils/logger.ts @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createClientLogger } from "@azure/logger"; + +/** + * The \@azure\/logger configuration for this package. + */ +export const logger = createClientLogger("communication-ten-dlc"); diff --git a/sdk/communication/communication-ten-dlc/swagger/README.md b/sdk/communication/communication-ten-dlc/swagger/README.md new file mode 100644 index 000000000000..cd64745b4014 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/swagger/README.md @@ -0,0 +1,49 @@ +# Azure Communication Services Alpha IDs Module + +> see https://aka.ms/autorest + +## Configuration + +```yaml +package-name: "@azure/communication-ten-dlc" +description: 10 DLC administration client +package-version: "1.0.0" +license-header: MICROSOFT_MIT_NO_VERSION +output-folder: ../src/generated +input-file: ./swagger.json +model-date-time-as-string: false +optional-response-headers: true +payload-flattening-threshold: 10 +add-credentials: false +skip-enum-validation: true +title: 10 DLC Client +use-extension: + "@autorest/typescript": "latest" +tracing-info: + namespace: "Microsoft.Communication" + packagePrefix: "Azure.Communication" + +typescript: + generate-metadata: false + azure-arm: false +``` + +## Customizations + +### Disable extensible enums + +```yaml +directive: + - from: swagger-document + where: $.definitions[*].properties[*]["x-ms-enum"] + transform: > + if ($.modelAsString) { + $.modelAsString = false + } + - from: swagger-document + where: $.definitions[*].properties[*].items["x-ms-enum"] + transform: > + if ($.modelAsString) { + $.modelAsString = false + } +``` diff --git a/sdk/communication/communication-ten-dlc/swagger/swagger.json b/sdk/communication/communication-ten-dlc/swagger/swagger.json new file mode 100644 index 000000000000..e9a1415914f6 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/swagger/swagger.json @@ -0,0 +1,1271 @@ +{ + "swagger": "2.0", + "info": { + "title": "TenDLC Client", + "description": "The TenDLC program enables A2P SMS messaging for Local numbers.", + "version": "2024-05-01-preview" + }, + "paths": { + "/tendlc/countries/US/brands/{brandId}": { + "patch": { + "tags": [ + "10DLC - Brand" + ], + "operationId": "TenDlc_UpsertUSBrand", + "consumes": [ + "application/merge-patch+json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "brandId", + "required": true, + "type": "string", + "format": "uuid" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "schema": { + "$ref": "#/definitions/USBrand" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/USBrand" + } + }, + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/USBrand" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/CommunicationErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or update a 10DLC brand": { + "$ref": "./examples/UpsertTenDlcUSBrand.json" + } + } + }, + "delete": { + "tags": [ + "10DLC - Brand" + ], + "operationId": "TenDlc_DeleteUSBrand", + "parameters": [ + { + "in": "path", + "name": "brandId", + "required": true, + "type": "string", + "format": "uuid" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/CommunicationErrorResponse" + } + } + }, + "x-ms-examples": { + "Delete a 10DLC brand": { + "$ref": "./examples/DeleteTenDlcUSBrand.json" + } + }, + "produces": [ + "application/json" + ] + }, + "get": { + "tags": [ + "10DLC - Brand" + ], + "operationId": "TenDlc_GetUSBrand", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "brandId", + "required": true, + "type": "string", + "format": "uuid" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/USBrand" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/CommunicationErrorResponse" + } + } + }, + "x-ms-examples": { + "Get information about a specific 10DLC brand": { + "$ref": "./examples/GetTenDlcUSBrand.json" + } + } + } + }, + "/tendlc/countries/US/brands/{brandId}:submit": { + "post": { + "tags": [ + "10DLC - Brand" + ], + "operationId": "TenDlc_SubmitUSBrand", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "brandId", + "required": true, + "type": "string", + "format": "uuid" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/USBrand" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/CommunicationErrorResponse" + } + } + }, + "x-ms-examples": { + "Submit a 10DLC brand": { + "$ref": "./examples/SubmitTenDlcUSBrand.json" + } + } + } + }, + "/tendlc/countries/US/brands": { + "get": { + "tags": [ + "10DLC - Brand" + ], + "operationId": "TenDlc_GetUSBrands", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "skip", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "top", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "in": "query", + "name": "filter", + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/USBrands" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/CommunicationErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "brands" + }, + "x-ms-examples": { + "Get information about 10DLC brands for a resource": { + "$ref": "./examples/GetTenDlcUSBrands.json" + } + } + } + }, + "/tendlc/countries/US/brands/{brandId}:cancel": { + "post": { + "tags": [ + "10DLC - Brand" + ], + "operationId": "TenDlc_CancelUSBrand", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "brandId", + "required": true, + "type": "string", + "format": "uuid" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/USBrand" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/CommunicationErrorResponse" + } + } + }, + "x-ms-examples": { + "Cancel 10DLC brand": { + "$ref": "./examples/CancelTenDlcUSBrand.json" + } + } + } + }, + "/tendlc/countries/US/campaigns/{campaignId}": { + "patch": { + "tags": [ + "10DLC - Campaign" + ], + "operationId": "TenDlc_UpsertUSCampaign", + "consumes": [ + "application/merge-patch+json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "campaignId", + "required": true, + "type": "string", + "format": "uuid" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "schema": { + "$ref": "#/definitions/USCampaign" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/USCampaign" + } + }, + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/USCampaign" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/CommunicationErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or update a 10DLC campaign": { + "$ref": "./examples/UpsertTenDlcUSCampaign.json" + } + } + }, + "delete": { + "tags": [ + "10DLC - Campaign" + ], + "operationId": "TenDlc_DeleteUSCampaign", + "parameters": [ + { + "in": "path", + "name": "campaignId", + "required": true, + "type": "string", + "format": "uuid" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/CommunicationErrorResponse" + } + } + }, + "x-ms-examples": { + "Delete a 10DLC campaign": { + "$ref": "./examples/DeleteTenDlcUSCampaign.json" + } + }, + "produces": [ + "application/json" + ] + }, + "get": { + "tags": [ + "10DLC - Campaign" + ], + "operationId": "TenDlc_GetUSCampaign", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "campaignId", + "required": true, + "type": "string", + "format": "uuid" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/USCampaign" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/CommunicationErrorResponse" + } + } + }, + "x-ms-examples": { + "Get information about a specific 10DLC campaign": { + "$ref": "./examples/GetTenDlcUSCampaign.json" + } + } + } + }, + "/tendlc/countries/US/campaigns/{campaignId}:submit": { + "post": { + "tags": [ + "10DLC - Campaign" + ], + "operationId": "TenDlc_SubmitUSCampaign", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "campaignId", + "required": true, + "type": "string", + "format": "uuid" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/USCampaign" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/CommunicationErrorResponse" + } + } + }, + "x-ms-examples": { + "Submit a 10DLC campaign": { + "$ref": "./examples/SubmitTenDlcUSCampaign.json" + } + } + } + }, + "/tendlc/countries/US/campaigns": { + "get": { + "tags": [ + "10DLC - Campaign" + ], + "operationId": "TenDlc_GetUSCampaigns", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "skip", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "top", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "in": "query", + "name": "filter", + "type": "string" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/USCampaigns" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/CommunicationErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "campaigns" + }, + "x-ms-examples": { + "Get information about 10DLC campaigns for a resource": { + "$ref": "./examples/GetTenDlcUSCampaigns.json" + } + } + } + }, + "/tendlc/countries/US/campaigns/{campaignId}:cancel": { + "post": { + "tags": [ + "10DLC - Campaign" + ], + "operationId": "TenDlc_CancelUSCampaign", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "campaignId", + "required": true, + "type": "string", + "format": "uuid" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/USCampaign" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/CommunicationErrorResponse" + } + } + }, + "x-ms-examples": { + "Cancel 10DLC campaign": { + "$ref": "./examples/CancelTenDlcUSCampaign.json" + } + } + } + }, + "/tendlc/costs": { + "get": { + "tags": [ + "10DLC - Costs" + ], + "summary": "Retrieves a collection of eligible 10DLC costs with pagination.", + "description": "This method supports pagination via the \"skip\" and \"top\" query parameters.", + "operationId": "TenDlc_GetCosts", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "skip", + "description": "The number of items to skip in the result set (default: 0).", + "type": "integer", + "format": "int32", + "default": 0 + }, + { + "in": "query", + "name": "top", + "description": "The maximum number of items to return in the result set (default: 100).", + "type": "integer", + "format": "int32", + "default": 100 + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Returns the paginated collection of eligible 10DLC costs.", + "schema": { + "$ref": "#/definitions/TenDlcCosts" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/CommunicationErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "costs" + }, + "x-ms-examples": { + "List 10DLC costs": { + "$ref": "./examples/GetTenDlcCosts.json" + } + } + } + } + }, + "definitions": { + "Address": { + "description": "Represents postal address.", + "type": "object", + "properties": { + "line1": { + "description": "Address line 1", + "type": "string" + }, + "line2": { + "description": "Address line 2", + "type": "string" + }, + "city": { + "description": "The city for the addresses, for example Los Angeles.", + "maxLength": 100, + "type": "string" + }, + "state": { + "description": "The state for the addresses, for example California.", + "maxLength": 20, + "type": "string" + }, + "postalCode": { + "description": "Postal code", + "maxLength": 10, + "type": "string" + }, + "country": { + "description": "Country", + "type": "string" + } + } + }, + "BrandDetails": { + "description": "General information for a 10DLC brand.", + "type": "object", + "properties": { + "name": { + "description": "Gets or sets Name", + "maxLength": 255, + "type": "string" + }, + "companyName": { + "description": "Gets or sets Company Name", + "maxLength": 255, + "type": "string" + }, + "companyVertical": { + "description": "Category of companies motive/use case", + "enum": [ + "Agriculture", + "Communication", + "Construction", + "Education", + "Energy", + "Entertainment", + "Financial", + "Gambling", + "Government", + "Healthcare", + "Hospitality", + "HumanResources", + "Insurance", + "Legal", + "Manufacturing", + "Ngo", + "Political", + "Postal", + "Professional", + "RealEstate", + "Retail", + "Technology", + "Transportation" + ], + "type": "string", + "x-ms-enum": { + "name": "CompanyVertical", + "modelAsString": true + } + }, + "contactInformation": { + "$ref": "#/definitions/ContactInformation" + }, + "address": { + "$ref": "#/definitions/Address" + }, + "entityType": { + "description": "Legal structure or form a company takes", + "enum": [ + "PrivateProfit", + "PublicProfit", + "NonProfit", + "Government" + ], + "type": "string", + "x-ms-enum": { + "name": "EntityType", + "modelAsString": true + } + }, + "stockExchange": { + "description": "Marketplace where stocks, bonds, etc... are bought and sold", + "enum": [ + "Nasdaq", + "Nyse", + "Amex", + "Amx", + "Asx", + "B3", + "Bme", + "Bse", + "Fra", + "Icex", + "Jpx", + "Jse", + "Krx", + "Lon", + "Nse", + "Omx", + "Sehk", + "Sgx", + "Sse", + "Sto", + "Swx", + "Szse", + "Tsx", + "Twse", + "Vse", + "Other" + ], + "type": "string", + "x-ms-enum": { + "name": "StockExchange", + "modelAsString": true + } + }, + "stockSymbol": { + "description": "Stock Exchange", + "maxLength": 10, + "type": "string" + }, + "alternateBusinessIdType": { + "description": "Alternate Business Id Type", + "enum": [ + "Duns", + "Lei", + "Giin" + ], + "type": "string", + "x-ms-enum": { + "name": "AlternateBusinessIdType", + "modelAsString": true + } + }, + "alternateBusinessId": { + "description": "Alternate Business Id", + "maxLength": 50, + "type": "string" + }, + "taxNumber": { + "description": "Business Id that corresponds to your business", + "maxLength": 21, + "type": "string" + }, + "taxNumberIssuingCountry": { + "description": "Tax Issuing Country", + "type": "string" + }, + "url": { + "format": "uri", + "description": "URL", + "maxLength": 100, + "type": "string" + } + } + }, + "CampaignDetails": { + "description": "Information about the campaign.", + "type": "object", + "properties": { + "callToAction": { + "description": "Call to action text. To be provided when InteractiveVoiceResponse is specified as call to action type", + "type": "string" + }, + "description": { + "description": "Describes how and why the number will be used for messaging as part of the program.", + "type": "string" + } + } + }, + "ContactInformation": { + "description": "Represent contact information for the brand.", + "type": "object", + "properties": { + "phone": { + "format": "tel", + "description": "Contact phone number for the authorized user for the customer. Use E164 format. e.g. +14086111111", + "type": "string" + }, + "email": { + "format": "email", + "description": "Contact email address number for the authorized user for the customer", + "maxLength": 100, + "type": "string" + } + } + }, + "MessageDetails": { + "description": "Compiles details describing how the messaging campaign will work, for example whether opt-in and opt-out will be required and how will the messages for those actions look like.", + "type": "object", + "properties": { + "useCase": { + "$ref": "#/definitions/UseCase" + }, + "helpAnswerToUserRequired": { + "description": "Boolean to determine if HelpAnswerToUser is required", + "type": "boolean" + }, + "helpAnswerToUser": { + "description": "Message text for mobile terminated message associated with HELP keyword\r\ne.g 'This is the HELP message test.'.", + "type": "string" + }, + "optOutAnswerToUserRequired": { + "description": "Boolean to determine if optOutAnswerToUser is required", + "type": "boolean" + }, + "optOutAnswerToUser": { + "description": "\"Message text for mobile terminated message associated with STOP keyword\r\ne.g. 'This is the STOP message test.'.", + "type": "string" + }, + "optInMessageToUserRequired": { + "description": "Boolean to determine if optInMessage is required", + "type": "boolean" + }, + "optInMessageToUser": { + "type": "string" + }, + "hasEmbeddedLink": { + "description": "Indicates whether the message has an embedded link.", + "type": "boolean" + }, + "hasEmbeddedPhone": { + "description": "Indicates whether the message has an embedded phone number.", + "type": "boolean" + }, + "termsAndConditionsAccepted": { + "description": "Indicates whether the terms and conditions have been accepted.", + "type": "boolean" + }, + "hasAgeGatedContent": { + "description": "Indicates whether the message contains age-gated content.", + "type": "boolean" + }, + "hasDirectLending": { + "description": "Indicates whether the message involves direct lending.", + "type": "boolean" + } + } + }, + "ReviewNote": { + "description": "Holds a note about a Program Brief that has gone thru stages of review process.", + "type": "object", + "properties": { + "message": { + "description": "Note related to a Brand or Campaign that may imply changes needed from the client.", + "type": "string" + }, + "date": { + "format": "date-time", + "description": "Date and time when the note was added to the Brand or Campaign.", + "type": "string" + } + } + }, + "TenDlcCost": { + "description": "The cost of a 10DLC Brand or Campaign", + "type": "object", + "properties": { + "type": { + "description": "The type of cost.", + "enum": [ + "Brand", + "StandardCampaign" + ], + "type": "string", + "x-ms-enum": { + "name": "TenDlcCostType", + "modelAsString": true + } + }, + "amount": { + "format": "double", + "description": "The cost amount.", + "type": "number" + }, + "currencyCode": { + "description": "The ISO 4217 currency code for the cost amount, e.g. USD.", + "type": "string" + }, + "countryCode": { + "description": "The ISO 3166-2 code of the phone number's country, e.g. US.", + "type": "string" + }, + "billingFrequency": { + "description": "The frequency with which the cost gets billed.", + "enum": [ + "Monthly", + "Once" + ], + "type": "string", + "x-ms-enum": { + "name": "BillingFrequency", + "modelAsString": true + } + } + } + }, + "TenDlcCosts": { + "description": "A wrapper for a list of 10DLC cost entities", + "type": "object", + "properties": { + "costs": { + "description": "List of 10DLC costs.", + "type": "array", + "items": { + "$ref": "#/definitions/TenDlcCost" + } + }, + "nextLink": { + "description": "Represents the URL link to the next page of local 10DLC costs results.", + "type": "string" + } + } + }, + "USBrand": { + "description": "Represents a US 10DLC brand with details and status information.", + "required": [ + "id" + ], + "type": "object", + "properties": { + "id": { + "format": "uuid", + "description": "Unique identifier that corresponds to a brand", + "type": "string" + }, + "statusUpdatedDate": { + "format": "date-time", + "description": "Last date and time when the 10DLC status was updated", + "type": "string" + }, + "status": { + "description": "10 Dlc status e.g. 'submitted', 'approved', etc", + "enum": [ + "Draft", + "Submitted", + "Cancelled", + "PendingCancellation", + "Denied", + "Approved", + "MicrosoftSupportEngaged", + "VettingSubmitted" + ], + "type": "string", + "x-ms-enum": { + "name": "BrandStatus", + "modelAsString": true + } + }, + "costs": { + "description": "Represents the costs tied to the brand", + "type": "array", + "items": { + "$ref": "#/definitions/TenDlcCost" + } + }, + "submissionDate": { + "format": "date-time", + "description": "Date and time when the 10DLC was submitted", + "type": "string" + }, + "reviewNotes": { + "description": "Notes added to the 10DLC Brand after being reviewed to help customer understand\r\nreview results and necessary follow up actions.", + "type": "array", + "items": { + "$ref": "#/definitions/ReviewNote" + } + }, + "brandDetails": { + "$ref": "#/definitions/BrandDetails" + } + } + }, + "USCampaign": { + "description": "Represents a US 10DLC campaign.", + "required": [ + "id" + ], + "type": "object", + "properties": { + "id": { + "format": "uuid", + "description": "Unique identifier that corresponds to a campaign", + "type": "string" + }, + "brandId": { + "format": "uuid", + "description": "Unique identifier that corresponds to a brand", + "type": "string" + }, + "status": { + "description": "10DLC status e.g. 'submitted', 'approved', etc", + "enum": [ + "Draft", + "Submitted", + "Cancelled", + "PendingCancellation", + "Denied", + "Approved", + "MicrosoftSupportEngaged" + ], + "type": "string", + "x-ms-enum": { + "name": "CampaignStatus", + "modelAsString": true + } + }, + "statusUpdatedDate": { + "format": "date-time", + "description": "Last date and time when the 10DLC status was updated", + "type": "string" + }, + "costs": { + "description": "Represents the costs tied to the campaign", + "type": "array", + "items": { + "$ref": "#/definitions/TenDlcCost" + } + }, + "submissionDate": { + "format": "date-time", + "description": "Date and time when the 10DLC was submitted", + "type": "string" + }, + "reviewNotes": { + "description": "Notes added to the 10DLC Campaign after being reviewed to help customer understand\r\nreview results and necessary follow up actions.", + "type": "array", + "items": { + "$ref": "#/definitions/ReviewNote" + } + }, + "phoneNumberCount": { + "format": "int32", + "description": "Count of local phone numbers currently associated to the 10DLC Campaign.", + "type": "integer" + }, + "campaignDetails": { + "$ref": "#/definitions/CampaignDetails" + }, + "messageDetails": { + "$ref": "#/definitions/MessageDetails" + } + } + }, + "UseCase": { + "description": "Compiles information describing the user case for a 10DLC messaging campaign.", + "type": "object", + "properties": { + "contentType": { + "description": "Type of user content", + "enum": [ + "AccountNotification", + "CustomerCare", + "DeliveryNotification", + "FraudAlert", + "HigherEducation", + "LowVolume", + "MachineToMachine", + "Marketing", + "Mixed", + "PollingVoting", + "PublicServiceAnnouncement", + "SecurityAlert", + "TwoFactorAuthentication" + ], + "type": "string", + "x-ms-enum": { + "name": "ContentType", + "modelAsString": true + } + }, + "subContentTypes": { + "description": "Type of user sub-content", + "type": "array", + "items": { + "description": "Enum representing the sub-content types.", + "enum": [ + "TwoFactorAuthentication", + "AccountNotification", + "CustomerCare", + "DeliveryNotification", + "FraudAlert", + "HigherEducation", + "Marketing", + "PollingVoting", + "PublicServiceAnnouncement", + "SecurityAlert" + ], + "type": "string", + "x-ms-enum": { + "name": "SubContentType", + "modelAsString": true + } + } + }, + "sampleMessages": { + "description": "Sample messages that a user might send, as a proof of concept", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "USBrands": { + "description": "A wrapper for a list of USBrands.", + "type": "object", + "properties": { + "brands": { + "description": "List of USBrands", + "type": "array", + "items": { + "$ref": "#/definitions/USBrand" + } + }, + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" + } + } + }, + "USCampaigns": { + "description": "A wrapper for a list of USCampaigns", + "type": "object", + "properties": { + "campaigns": { + "description": "List of USCampaigns", + "type": "array", + "items": { + "$ref": "#/definitions/USCampaign" + } + }, + "nextLink": { + "description": "Represents the URL link to the next page", + "type": "string" + } + } + }, + "CommunicationErrorResponse": { + "description": "The Communication Services error.", + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "description": "The Communication Services error.", + "$ref": "#/definitions/CommunicationError" + } + } + }, + "CommunicationError": { + "description": "The Communication Services error.", + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "string", + "description": "The error code." + }, + "message": { + "type": "string", + "description": "The error message." + }, + "target": { + "type": "string", + "readOnly": true, + "description": "The error target." + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/CommunicationError" + }, + "readOnly": true, + "description": "Further details about specific errors that led to this error." + }, + "innererror": { + "x-ms-client-name": "innerError", + "readOnly": true, + "$ref": "#/definitions/CommunicationError", + "description": "The inner error if any." + } + } + } + }, + "parameters": { + "ApiVersionParameter": { + "in": "query", + "name": "api-version", + "description": "Version of API to invoke", + "required": true, + "type": "string", + "x-ms-parameter-location": "client" + }, + "Endpoint": { + "in": "path", + "name": "endpoint", + "description": "The communication resource, for example https://resourcename.communication.azure.com", + "required": true, + "type": "string", + "x-ms-skip-url-encoding": true, + "x-ms-parameter-location": "client", + "format": "url" + } + }, + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "flow": "implicit", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "user_impersonation": "impersonate your user account" + }, + "description": "Azure Active Directory OAuth2 Flow" + } + }, + "x-ms-parameterized-host": { + "hostTemplate": "{endpoint}", + "useSchemePrefix": false, + "parameters": [ + { + "$ref": "#/parameters/Endpoint" + } + ] + } +} \ No newline at end of file diff --git a/sdk/communication/communication-ten-dlc/test/README.md b/sdk/communication/communication-ten-dlc/test/README.md new file mode 100644 index 000000000000..a237cf921c68 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/test/README.md @@ -0,0 +1,19 @@ +# Testing + +To test this project, make sure to build it by following our [building instructions](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md#building), then follow the [testing instructions](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md#testing). + +You can use existing Azure resources for the live tests, or generate new ones by using our [New-TestResources.ps1](https://github.com/Azure/azure-sdk-for-js/blob/main/eng/common/TestResources/New-TestResources.ps1) script, which will use a [Bicep template](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/communication/test-resources/test-resources.bicep) that already has all of the the necessary configurations. + +The Azure resource that is used by the tests in this project is: + +- An existing Communication Services resource. If you need to create the resource, you can use the [Azure Portal][azure_portal] or [Azure CLI][azure_cli]. + +To run the live tests, you will need to set the below environment variables: + +- `TEST_MODE`: Should have `live` assigned if you want to run live without recording. Assign `record` to run live with recording. +- `COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING`: The primary connection string of the Communication Services resource in your account. + +[azure_sub]: https://azure.microsoft.com/free/ +[azure_portal]: https://portal.azure.com + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcommunication%2Fcommunication-ten-dlc%2FREADME.png) diff --git a/sdk/communication/communication-ten-dlc/test/public/brands.spec.ts b/sdk/communication/communication-ten-dlc/test/public/brands.spec.ts new file mode 100644 index 000000000000..369ce9f4ede9 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/test/public/brands.spec.ts @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { Context } from "mocha"; +import type { TenDlcClient } from "../../src"; +import { assert } from "chai"; +import { createRecordedClient } from "../utils/recordedClient"; +import { CreateUUID } from "../utils/helpers"; +import { type Recorder, isPlaybackMode } from "@azure-tools/test-recorder"; + +describe("TenDlcClient - Brands", function () { + let recorder: Recorder; + let client: TenDlcClient; + let brandId: string; + + const DEFAULT_BRAND_ID = "a551dbcf-30a8-440c-9fb0-6baafbc411e8"; + + beforeEach(async function (this: Context) { + ({ client, recorder } = await createRecordedClient(this)); + if (isPlaybackMode()) { + brandId = DEFAULT_BRAND_ID; + } else { + brandId = CreateUUID(); + } + }); + + afterEach(async function (this: Context) { + if (!this.currentTest?.isPending()) { + await recorder.stop(); + } + }); + + it("successfully inserts brand", async function (this: Context) { + const brandDetails = { + name: "newBrand", + companyName: "Contoso", + }; + + const options = { + brandDetails: brandDetails, + }; + + const brand = await client.upsertUSBrand(brandId, options); + assert.equal(brand.id, brandId); + assert.equal(brand.brandDetails?.name, "newBrand"); + assert.equal(brand.brandDetails?.companyName, "Contoso"); + + await client.deleteUSBrand(brandId); + }).timeout(30000); + + it("successfully updates brand", async function (this: Context) { + const brandDetails = { + name: "newBrand", + companyName: "Contoso", + }; + + const options = { + brandDetails: brandDetails, + }; + + let brand = await client.upsertUSBrand(brandId, options); + assert.equal(brand.id, brandId); + assert.equal(brand.brandDetails?.name, "newBrand"); + assert.equal(brand.brandDetails?.companyName, "Contoso"); + + const newBrandDetails = { + name: "updatedName", + }; + + const newOptions = { + brandDetails: newBrandDetails, + }; + + brand = await client.upsertUSBrand(brandId, newOptions); + assert.equal(brand.id, brandId); + assert.equal(brand.brandDetails?.name, "updatedName"); + assert.equal(brand.brandDetails?.companyName, "Contoso"); + + await client.deleteUSBrand(brandId); + }).timeout(30000); + + it("can list all us brands", async function () { + const brandDetails = { + name: "newBrand", + companyName: "Contoso", + }; + + const options = { + brandDetails: brandDetails, + }; + + client.upsertUSBrand(brandId, options); + + for await (const brand of client.listUSBrands()) { + assert.isNotNull(brand); + } + + await client.deleteUSBrand(brandId); + }).timeout(30000); +}); diff --git a/sdk/communication/communication-ten-dlc/test/public/campaigns.spec.ts b/sdk/communication/communication-ten-dlc/test/public/campaigns.spec.ts new file mode 100644 index 000000000000..464533598f80 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/test/public/campaigns.spec.ts @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { Context } from "mocha"; +import type { TenDlcClient } from "../../src"; +import { assert } from "chai"; +import { createRecordedClient } from "../utils/recordedClient"; +import { type Recorder, isPlaybackMode } from "@azure-tools/test-recorder"; +import { CreateUUID } from "../utils/helpers"; + +describe("TenDlcClient - Campaigns", function () { + let recorder: Recorder; + let client: TenDlcClient; + let id: string; + const DEFAULT_ID = "a551dbcf-30a8-440c-9fb0-6baafbc411e8"; + + const messageDetails = { + useCase: { + sampleMessages: ["sampleMessages"], + }, + }; + + beforeEach(async function (this: Context) { + ({ client, recorder } = await createRecordedClient(this)); + if (isPlaybackMode()) { + id = DEFAULT_ID; + } else { + id = CreateUUID(); + } + }); + + afterEach(async function (this: Context) { + if (!this.currentTest?.isPending()) { + await recorder.stop(); + } + }); + + it("successfully inserts campaign", async function (this: Context) { + const options = { + brandId: id, + campaignDetails: {}, + messageDetails: messageDetails, + }; + + const campaign = await client.upsertUSCampaign(id, options); + assert.equal(campaign.id, id); + assert.equal( + campaign.messageDetails?.useCase?.sampleMessages?.values, + messageDetails.useCase.sampleMessages.values, + ); + + await client.deleteUSCampaign(id); + }).timeout(30000); + + it("successfully updates campaign", async function (this: Context) { + const options = { + brandId: id, + campaignDetails: {}, + messageDetails: messageDetails, + }; + let campaign = await client.upsertUSCampaign(id, options); + assert.equal(campaign.id, id); + assert.equal( + campaign.messageDetails?.useCase?.sampleMessages?.values, + messageDetails.useCase.sampleMessages.values, + ); + + messageDetails.useCase.sampleMessages = ["updatedSampleMessages"]; + const newOptions = { + brandId: id, + campaignDetails: {}, + messageDetails: messageDetails, + }; + + campaign = await client.upsertUSCampaign(id, newOptions); + assert.equal(campaign.id, id); + assert.equal( + campaign.messageDetails?.useCase?.sampleMessages?.values, + messageDetails.useCase.sampleMessages.values, + ); + + await client.deleteUSCampaign(id); + }).timeout(30000); + + it("can list all us campaigns", async function () { + const options = { + brandId: id, + campaignDetails: {}, + messageDetails: {}, + }; + + client.upsertUSCampaign(id, options); + for await (const campaign of client.listUSCampaigns()) { + assert.isNotNull(campaign); + } + + await client.deleteUSCampaign(id); + }).timeout(30000); +}); diff --git a/sdk/communication/communication-ten-dlc/test/public/costs.spec.ts b/sdk/communication/communication-ten-dlc/test/public/costs.spec.ts new file mode 100644 index 000000000000..00c272154b74 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/test/public/costs.spec.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { Context } from "mocha"; +import type { TenDlcClient } from "../../src"; +import { assert } from "chai"; +import { createRecordedClient } from "../utils/recordedClient"; +import type { Recorder } from "@azure-tools/test-recorder"; + +describe("TenDlcClient - Costs", function () { + let recorder: Recorder; + let client: TenDlcClient; + + beforeEach(async function (this: Context) { + ({ client, recorder } = await createRecordedClient(this)); + }); + + afterEach(async function (this: Context) { + if (!this.currentTest?.isPending()) { + await recorder.stop(); + } + }); + + it("can list all costs", async function () { + for await (const cost of client.listCosts()) { + assert.isNotNull(cost); + } + }).timeout(30000); +}); diff --git a/sdk/communication/communication-ten-dlc/test/public/ctor.spec.ts b/sdk/communication/communication-ten-dlc/test/public/ctor.spec.ts new file mode 100644 index 000000000000..8af935577d13 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/test/public/ctor.spec.ts @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AzureKeyCredential } from "@azure/core-auth"; +import type { Context } from "mocha"; +import { TenDlcClient } from "../../src"; +import { assert } from "chai"; +import { createMockToken } from "../utils/recordedClient"; + +describe("TenDlcClient - constructor", function () { + const endpoint = "https://contoso.spool.azure.local"; + const accessKey = "banana"; + + it("successfully instantiates with valid connection string", function () { + const client = new TenDlcClient(`endpoint=${endpoint};accesskey=${accessKey}`); + assert.instanceOf(client, TenDlcClient); + }); + + it("throws with invalid connection string", function () { + assert.throws(() => { + new TenDlcClient(`endpoints=${endpoint};accesskey=${accessKey}`); + }); + }); + + it("successfully instantiates with with endpoint and access key", function () { + const client = new TenDlcClient(endpoint, new AzureKeyCredential(accessKey)); + assert.instanceOf(client, TenDlcClient); + }); + + it("successfully instantiates with with endpoint and managed identity", function (this: Context) { + const client = new TenDlcClient(endpoint, createMockToken()); + assert.instanceOf(client, TenDlcClient); + }); +}); diff --git a/sdk/communication/communication-ten-dlc/test/utils/helpers.ts b/sdk/communication/communication-ten-dlc/test/utils/helpers.ts new file mode 100644 index 000000000000..d4e39b5084c4 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/test/utils/helpers.ts @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export function CreateUUID(): string { + return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { + const r = (Math.random() * 16) | 0; + const v = c === "x" ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); +} diff --git a/sdk/communication/communication-ten-dlc/test/utils/mockHttpClients.ts b/sdk/communication/communication-ten-dlc/test/utils/mockHttpClients.ts new file mode 100644 index 000000000000..88fae2b9f7c3 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/test/utils/mockHttpClients.ts @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { + HttpClient, + HttpHeaders, + PipelineRequest, + PipelineResponse, +} from "@azure/core-rest-pipeline"; + +export const createMockHttpClient = >( + status: number = 200, + parsedBody?: T, + headers?: HttpHeaders, +): HttpClient => { + return { + async sendRequest(request: PipelineRequest): Promise { + return { + status, + request, + headers: headers ?? request.headers, + bodyAsText: JSON.stringify(parsedBody), + }; + }, + }; +}; + +export const configurationHttpClient: HttpClient = createMockHttpClient(200); diff --git a/sdk/communication/communication-ten-dlc/test/utils/msUserAgentPolicy.ts b/sdk/communication/communication-ten-dlc/test/utils/msUserAgentPolicy.ts new file mode 100644 index 000000000000..1de4c36d1974 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/test/utils/msUserAgentPolicy.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { + PipelinePolicy, + PipelineRequest, + PipelineResponse, + SendRequest, +} from "@azure/core-rest-pipeline"; +import { env } from "@azure-tools/test-recorder"; + +export function createMSUserAgentPolicy(): PipelinePolicy { + return { + name: "msUserAgentPolicy", + async sendRequest(request: PipelineRequest, next: SendRequest): Promise { + const useragent = env.AZURE_USERAGENT_OVERRIDE; + + if (useragent) { + request.headers.set("x-ms-useragent", useragent); + } + + return next(request); + }, + }; +} diff --git a/sdk/communication/communication-ten-dlc/test/utils/recordedClient.ts b/sdk/communication/communication-ten-dlc/test/utils/recordedClient.ts new file mode 100644 index 000000000000..915209b3896e --- /dev/null +++ b/sdk/communication/communication-ten-dlc/test/utils/recordedClient.ts @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { Context, Test } from "mocha"; +import * as dotenv from "dotenv"; + +import { + Recorder, + type RecorderStartOptions, + env, + isPlaybackMode, + type SanitizerOptions, +} from "@azure-tools/test-recorder"; +import { TenDlcClient } from "../../src"; +import type { TokenCredential } from "@azure/identity"; +import { isNode } from "@azure-tools/test-utils"; +import { createMSUserAgentPolicy } from "./msUserAgentPolicy"; + +if (isNode) { + dotenv.config(); +} + +export interface RecordedClient { + client: T; + recorder: Recorder; +} + +const envSetupForPlayback: { [k: string]: string } = { + COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING: "endpoint=https://endpoint/;accesskey=banana", + COMMUNICATION_ENDPOINT: "https://endpoint/", + AZURE_CLIENT_ID: "SomeClientId", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "SomeTenantId", + AZURE_PHONE_NUMBER: "+14155550100", + AZURE_USERAGENT_OVERRIDE: "fake-useragent", +}; + +const sanitizerOptions: SanitizerOptions = { + connectionStringSanitizers: [ + { + actualConnString: env.COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING, + fakeConnString: envSetupForPlayback["COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING"], + }, + ], + generalSanitizers: [ + { regex: true, target: `"access_token"\\s?:\\s?"[^"]*"`, value: `"access_token":"sanitized"` }, + { + regex: true, + target: `(https://)([^/'",}]*)`, + value: `$1endpoint`, + }, + { + regex: true, + target: `[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}`, + value: `a551dbcf-30a8-440c-9fb0-6baafbc411e8`, + }, + ], +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback, + sanitizerOptions: sanitizerOptions, + removeCentralSanitizers: [ + "AZSDK3493", // .name in the body is not a secret and is listed below in the beforeEach section + "AZSDK3430", // .id in the body is not a secret and is listed below in the beforeEach section + ], +}; + +export async function createRecorder(context: Test | undefined): Promise { + const recorder = new Recorder(context); + await recorder.start(recorderOptions); + await recorder.setMatcher("CustomDefaultMatcher", { + excludedHeaders: [ + "Accept-Language", // This is env-dependent + "x-ms-content-sha256", // This is dependent on the current datetime + ], + }); + return recorder; +} + +export async function createRecordedClient( + context: Context, +): Promise> { + const recorder = await createRecorder(context.currentTest); + + const client = new TenDlcClient( + env.COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING ?? "", + recorder.configureClientOptions({ + additionalPolicies: [ + { + policy: createMSUserAgentPolicy(), + position: "perCall", + }, + ], + }), + ); + + // casting is a workaround to enable min-max testing + return { client, recorder }; +} + +export function createMockToken(): TokenCredential { + return { + getToken: async (_scopes) => { + return { token: "testToken", expiresOnTimestamp: 11111 }; + }, + }; +} + +export const testPollerOptions = { + pollInterval: isPlaybackMode() ? 0 : undefined, +}; diff --git a/sdk/communication/communication-ten-dlc/tests.yml b/sdk/communication/communication-ten-dlc/tests.yml new file mode 100644 index 000000000000..7f836730a4cd --- /dev/null +++ b/sdk/communication/communication-ten-dlc/tests.yml @@ -0,0 +1,26 @@ +trigger: none + +stages: + - template: /eng/pipelines/templates/stages/archetype-sdk-tests.yml + parameters: + PackageName: "@azure-tools/communication-ten-dlc" + ServiceDirectory: communication + CloudConfig: + Public: + SubscriptionConfigurations: + - $(sub-config-azure-cloud-test-resources) + - $(sub-config-communication-services-cloud-test-resources-common) + - $(sub-config-communication-services-cloud-test-resources-js) + PPE: + SubscriptionConfigurations: + - $(sub-config-communication-ppe-test-resources-common) + - $(sub-config-communication-ppe-test-resources-js) + Int: + SubscriptionConfigurations: + - $(sub-config-communication-int-test-resources-common) + - $(sub-config-communication-int-test-resources-js) + MatrixFilters: + - TestType=^(?!(browser|sample)).* + Clouds: Public,PPE,Int + TestResourceDirectories: + - communication/test-resources/ diff --git a/sdk/communication/communication-ten-dlc/tsconfig.json b/sdk/communication/communication-ten-dlc/tsconfig.json new file mode 100644 index 000000000000..59c943812133 --- /dev/null +++ b/sdk/communication/communication-ten-dlc/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../../tsconfig", + "compilerOptions": { + "outDir": "./dist-esm", + "declarationDir": "./types", + "paths": { + "@azure-tools/communication-ten-dlc": ["./src/index"] + } + }, + "include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"] +}