@azure/notification-hubs 1.0.0-beta.4 → 1.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -11,7 +11,7 @@ var tslib = require('tslib');
11
11
 
12
12
  // Copyright (c) Microsoft Corporation.
13
13
  // Licensed under the MIT license.
14
- const SDK_VERSION = "1.0.0-beta.4";
14
+ const SDK_VERSION = "1.0.0-beta.5";
15
15
  const JSON_CONTENT_TYPE = "application/json;charset=utf-8";
16
16
  const XML_CONTENT_TYPE = "application/xml";
17
17
  const STREAM_CONTENT_TYPE = "application/octet-stream";
@@ -521,7 +521,7 @@ const tracingClient = coreTracing.createTracingClient({
521
521
  });
522
522
 
523
523
  // Copyright (c) Microsoft Corporation.
524
- const OPERATION_NAME$h = "cancelScheduledNotification";
524
+ const OPERATION_NAME$i = "cancelScheduledNotification";
525
525
  /**
526
526
  * Cancels the scheduled notification with the given notification ID.
527
527
  * NOTE: This is only available in Standard SKU Azure Notification Hubs.
@@ -531,10 +531,10 @@ const OPERATION_NAME$h = "cancelScheduledNotification";
531
531
  * @returns A notification hub response with correlation ID and tracking ID.
532
532
  */
533
533
  function cancelScheduledNotification(context, notificationId, options = {}) {
534
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$h}`, options, async (updatedOptions) => {
534
+ return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$i}`, options, async (updatedOptions) => {
535
535
  const endpoint = context.requestUrl();
536
536
  endpoint.pathname += `/schedulednotifications/${notificationId}`;
537
- const headers = await context.createHeaders(OPERATION_NAME$h);
537
+ const headers = await context.createHeaders(OPERATION_NAME$i);
538
538
  const request = createRequest(endpoint, "DELETE", headers, updatedOptions);
539
539
  const response = await sendRequest(context, request, 200);
540
540
  return parseNotificationSendResponse(response);
@@ -542,7 +542,7 @@ function cancelScheduledNotification(context, notificationId, options = {}) {
542
542
  }
543
543
 
544
544
  // Copyright (c) Microsoft Corporation.
545
- const OPERATION_NAME$g = "createOrUpdateInstallation";
545
+ const OPERATION_NAME$h = "createOrUpdateInstallation";
546
546
  /**
547
547
  * Creates or overwrites an installation to a Notification Hub.
548
548
  * @param context - The Notification Hubs client.
@@ -551,10 +551,10 @@ const OPERATION_NAME$g = "createOrUpdateInstallation";
551
551
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
552
552
  */
553
553
  function createOrUpdateInstallation(context, installation, options = {}) {
554
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$g}`, options, async (updatedOptions) => {
554
+ return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$h}`, options, async (updatedOptions) => {
555
555
  const endpoint = context.requestUrl();
556
556
  endpoint.pathname += `/installations/${installation.installationId}`;
557
- const headers = await context.createHeaders(OPERATION_NAME$g);
557
+ const headers = await context.createHeaders(OPERATION_NAME$h);
558
558
  headers.set("Content-Type", "application/json");
559
559
  const request = createRequest(endpoint, "PUT", headers, updatedOptions);
560
560
  request.body = JSON.stringify(installation);
@@ -590,7 +590,8 @@ const registrationDescriptionParser = {
590
590
  if (!isDefined(xml.feed.entry)) {
591
591
  return results;
592
592
  }
593
- for (const entry of xml.feed.entry) {
593
+ const entries = Array.isArray(xml.feed.entry) ? xml.feed.entry : [xml.feed.entry];
594
+ for (const entry of entries) {
594
595
  delete entry.content["$"];
595
596
  const keyName = Object.keys(entry.content)[0];
596
597
  const methodName = `create${keyName}`;
@@ -936,7 +937,7 @@ async function createOrUpdateRegistrationDescription(context, registration, oper
936
937
  }
937
938
 
938
939
  // Copyright (c) Microsoft Corporation.
939
- const OPERATION_NAME$f = "createOrUpdateRegistration";
940
+ const OPERATION_NAME$g = "createOrUpdateRegistration";
940
941
  /**
941
942
  * Creates or updates a registration.
942
943
  * @param context - The Notification Hubs client.
@@ -945,13 +946,13 @@ const OPERATION_NAME$f = "createOrUpdateRegistration";
945
946
  * @returns The created or updated registration description.
946
947
  */
947
948
  function createOrUpdateRegistration(context, registration, options = {}) {
948
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$f}`, options, async (updatedOptions) => {
949
+ return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$g}`, options, async (updatedOptions) => {
949
950
  return createOrUpdateRegistrationDescription(context, registration, "createOrUpdate", updatedOptions);
950
951
  });
951
952
  }
952
953
 
953
954
  // Copyright (c) Microsoft Corporation.
954
- const OPERATION_NAME$e = "createRegistrationId";
955
+ const OPERATION_NAME$f = "createRegistrationId";
955
956
  /**
956
957
  * Creates a new registration ID.
957
958
  * @param context - The Notification Hubs client.
@@ -959,10 +960,10 @@ const OPERATION_NAME$e = "createRegistrationId";
959
960
  * @returns The newly created registration ID.
960
961
  */
961
962
  function createRegistrationId(context, options = {}) {
962
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$e}`, options, async (updatedOptions) => {
963
+ return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$f}`, options, async (updatedOptions) => {
963
964
  const endpoint = context.requestUrl();
964
965
  endpoint.pathname += "/registrationIDs";
965
- const headers = await context.createHeaders(OPERATION_NAME$e);
966
+ const headers = await context.createHeaders(OPERATION_NAME$f);
966
967
  headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
967
968
  const request = createRequest(endpoint, "POST", headers, updatedOptions);
968
969
  const response = await sendRequest(context, request, 201);
@@ -975,7 +976,7 @@ function createRegistrationId(context, options = {}) {
975
976
  }
976
977
 
977
978
  // Copyright (c) Microsoft Corporation.
978
- const OPERATION_NAME$d = "createRegistration";
979
+ const OPERATION_NAME$e = "createRegistration";
979
980
  /**
980
981
  * Creates a new registration. This method generates a registration ID,
981
982
  * which you can subsequently use to retrieve, update, and delete this registration.
@@ -985,7 +986,7 @@ const OPERATION_NAME$d = "createRegistration";
985
986
  * @returns The newly created registration description.
986
987
  */
987
988
  function createRegistration(context, registration, options = {}) {
988
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$d}`, options, async (updatedOptions) => {
989
+ return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$e}`, options, async (updatedOptions) => {
989
990
  if (registration.registrationId) {
990
991
  throw new coreRestPipeline.RestError("registrationId must not be set during a create operation", {
991
992
  statusCode: 400,
@@ -996,7 +997,7 @@ function createRegistration(context, registration, options = {}) {
996
997
  }
997
998
 
998
999
  // Copyright (c) Microsoft Corporation.
999
- const OPERATION_NAME$c = "deleteInstallation";
1000
+ const OPERATION_NAME$d = "deleteInstallation";
1000
1001
  /**
1001
1002
  * Deletes an installation from a Notification Hub.
1002
1003
  * @param context - The Notification Hubs client.
@@ -1005,16 +1006,38 @@ const OPERATION_NAME$c = "deleteInstallation";
1005
1006
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1006
1007
  */
1007
1008
  function deleteInstallation(context, installationId, options = {}) {
1008
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$c}`, options, async (updatedOptions) => {
1009
+ return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$d}`, options, async (updatedOptions) => {
1009
1010
  const endpoint = context.requestUrl();
1010
1011
  endpoint.pathname += `/installations/${installationId}`;
1011
- const headers = await context.createHeaders(OPERATION_NAME$c);
1012
+ const headers = await context.createHeaders(OPERATION_NAME$d);
1012
1013
  const request = createRequest(endpoint, "DELETE", headers, updatedOptions);
1013
1014
  const response = await sendRequest(context, request, 204);
1014
1015
  return parseNotificationResponse(response);
1015
1016
  });
1016
1017
  }
1017
1018
 
1019
+ // Copyright (c) Microsoft Corporation.
1020
+ const OPERATION_NAME$c = "deleteRegistration";
1021
+ /**
1022
+ * Deletes a registration with the given registration ID.
1023
+ * @param context - The Notification Hubs client.
1024
+ * @param registrationId - The registration ID of the registration to delete.
1025
+ * @param options - The options for delete operations including the ETag
1026
+ * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1027
+ */
1028
+ function deleteRegistration(context, registrationId, options = {}) {
1029
+ return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$c}`, options, async (updatedOptions) => {
1030
+ const endpoint = context.requestUrl();
1031
+ endpoint.pathname += `/registrations/${registrationId}`;
1032
+ const headers = await context.createHeaders(OPERATION_NAME$c);
1033
+ headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
1034
+ headers.set("If-Match", isDefined(options.etag) ? `"${options.etag}"` : "*");
1035
+ const request = createRequest(endpoint, "GET", headers, updatedOptions);
1036
+ const response = await sendRequest(context, request, 200);
1037
+ return parseNotificationResponse(response);
1038
+ });
1039
+ }
1040
+
1018
1041
  // Copyright (c) Microsoft Corporation.
1019
1042
  const OPERATION_NAME$b = "getFeedbackContainerUrl";
1020
1043
  /**
@@ -1094,7 +1117,8 @@ async function parseNotificationHubJobFeed(bodyText) {
1094
1117
  if (!isDefined(xml.feed.entry)) {
1095
1118
  return results;
1096
1119
  }
1097
- for (const item of xml.feed.entry) {
1120
+ const entries = Array.isArray(xml.feed.entry) ? xml.feed.entry : [xml.feed.entry];
1121
+ for (const item of entries) {
1098
1122
  results.push(createNotificationHubJob(item.content.NotificationHubJob));
1099
1123
  }
1100
1124
  return results;
@@ -1742,6 +1766,16 @@ class NotificationHubsServiceClient {
1742
1766
  updateRegistration(registration, options = {}) {
1743
1767
  return updateRegistration(this._client, registration, options);
1744
1768
  }
1769
+ /**
1770
+ * Deletes a registration with the given registration ID.
1771
+ * @param context - The Notification Hubs client.
1772
+ * @param registrationId - The registration ID of the registration to delete.
1773
+ * @param options - The options for delete operations including the ETag
1774
+ * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1775
+ */
1776
+ deleteRegistration(registrationId, options = {}) {
1777
+ return deleteRegistration(this._client, registrationId, options);
1778
+ }
1745
1779
  /**
1746
1780
  * Gets a registration by the given registration ID.
1747
1781
  * @param registrationId - The ID of the registration to get.