@nizam-os/merchant-sdk 2.7.3 → 3.0.0
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/Client.d.ts +9 -0
- package/dist/Client.js +24 -12
- package/dist/api/resources/devices/client/Client.d.ts +71 -0
- package/dist/api/resources/devices/client/Client.js +238 -0
- package/dist/api/resources/devices/client/index.d.ts +1 -0
- package/dist/api/resources/devices/client/index.js +17 -0
- package/dist/api/resources/devices/client/requests/DeregisterDeviceRequest.d.ts +9 -0
- package/dist/api/resources/devices/client/requests/DeregisterDeviceRequest.js +3 -0
- package/dist/api/resources/devices/client/requests/RegisterDevice.d.ts +22 -0
- package/dist/api/resources/devices/client/requests/RegisterDevice.js +13 -0
- package/dist/api/resources/devices/client/requests/index.d.ts +2 -0
- package/dist/api/resources/devices/client/requests/index.js +5 -0
- package/dist/api/resources/devices/exports.d.ts +2 -0
- package/dist/api/resources/devices/exports.js +21 -0
- package/dist/api/resources/devices/index.d.ts +1 -0
- package/dist/api/resources/devices/index.js +17 -0
- package/dist/api/resources/index.d.ts +6 -0
- package/dist/api/resources/index.js +7 -1
- package/dist/api/resources/notificationPreferences/client/Client.d.ts +49 -0
- package/dist/api/resources/notificationPreferences/client/Client.js +175 -0
- package/dist/api/resources/notificationPreferences/client/index.d.ts +1 -0
- package/dist/api/resources/notificationPreferences/client/index.js +17 -0
- package/dist/api/resources/notificationPreferences/client/requests/UpdateNotificationPreferences.d.ts +11 -0
- package/dist/api/resources/notificationPreferences/client/requests/UpdateNotificationPreferences.js +3 -0
- package/dist/api/resources/notificationPreferences/client/requests/index.d.ts +1 -0
- package/dist/api/resources/notificationPreferences/client/requests/index.js +2 -0
- package/dist/api/resources/notificationPreferences/exports.d.ts +2 -0
- package/dist/api/resources/notificationPreferences/exports.js +21 -0
- package/dist/api/resources/notificationPreferences/index.d.ts +1 -0
- package/dist/api/resources/notificationPreferences/index.js +17 -0
- package/dist/api/resources/notifications/client/Client.d.ts +179 -0
- package/dist/api/resources/notifications/client/Client.js +623 -0
- package/dist/api/resources/notifications/client/index.d.ts +1 -0
- package/dist/api/resources/notifications/client/index.js +17 -0
- package/dist/api/resources/notifications/client/requests/ArchiveNotificationRequest.d.ts +9 -0
- package/dist/api/resources/notifications/client/requests/ArchiveNotificationRequest.js +3 -0
- package/dist/api/resources/notifications/client/requests/ListNotificationsRequest.d.ts +30 -0
- package/dist/api/resources/notifications/client/requests/ListNotificationsRequest.js +3 -0
- package/dist/api/resources/notifications/client/requests/MarkNotificationReadRequest.d.ts +9 -0
- package/dist/api/resources/notifications/client/requests/MarkNotificationReadRequest.js +3 -0
- package/dist/api/resources/notifications/client/requests/MarkNotificationUnreadRequest.d.ts +9 -0
- package/dist/api/resources/notifications/client/requests/MarkNotificationUnreadRequest.js +3 -0
- package/dist/api/resources/notifications/client/requests/UnarchiveNotificationRequest.d.ts +9 -0
- package/dist/api/resources/notifications/client/requests/UnarchiveNotificationRequest.js +3 -0
- package/dist/api/resources/notifications/client/requests/index.d.ts +5 -0
- package/dist/api/resources/notifications/client/requests/index.js +2 -0
- package/dist/api/resources/notifications/exports.d.ts +2 -0
- package/dist/api/resources/notifications/exports.js +21 -0
- package/dist/api/resources/notifications/index.d.ts +1 -0
- package/dist/api/resources/notifications/index.js +17 -0
- package/dist/api/types/ActiveOrganization.d.ts +2 -2
- package/dist/api/types/ActiveOrganization.js +1 -1
- package/dist/api/types/ActivityResource.d.ts +2 -2
- package/dist/api/types/ActivityResource.js +1 -1
- package/dist/api/types/Asset.d.ts +2 -2
- package/dist/api/types/Asset.js +1 -1
- package/dist/api/types/AssetListItem.d.ts +2 -2
- package/dist/api/types/AssetListItem.js +1 -1
- package/dist/api/types/Assignment.d.ts +2 -2
- package/dist/api/types/Assignment.js +1 -1
- package/dist/api/types/BusinessCategory.d.ts +2 -2
- package/dist/api/types/BusinessCategory.js +1 -1
- package/dist/api/types/Country.d.ts +2 -2
- package/dist/api/types/Country.js +1 -1
- package/dist/api/types/Currency.d.ts +2 -2
- package/dist/api/types/Currency.js +1 -1
- package/dist/api/types/Device.d.ts +24 -0
- package/dist/api/types/Device.js +11 -0
- package/dist/api/types/Devices.d.ts +17 -0
- package/dist/api/types/Devices.js +11 -0
- package/dist/api/types/Invite.d.ts +2 -2
- package/dist/api/types/Invite.js +1 -1
- package/dist/api/types/Language.d.ts +2 -2
- package/dist/api/types/Language.js +1 -1
- package/dist/api/types/ListResponseActivityResource.d.ts +3 -3
- package/dist/api/types/ListResponseActivityResource.js +1 -1
- package/dist/api/types/ListResponseAssetListItem.d.ts +3 -3
- package/dist/api/types/ListResponseAssetListItem.js +1 -1
- package/dist/api/types/ListResponseBusinessCategory.d.ts +3 -3
- package/dist/api/types/ListResponseBusinessCategory.js +1 -1
- package/dist/api/types/ListResponseCountry.d.ts +3 -3
- package/dist/api/types/ListResponseCountry.js +1 -1
- package/dist/api/types/ListResponseCurrency.d.ts +3 -3
- package/dist/api/types/ListResponseCurrency.js +1 -1
- package/dist/api/types/ListResponseFile.d.ts +3 -3
- package/dist/api/types/ListResponseFile.js +1 -1
- package/dist/api/types/ListResponseHeatmapCell.d.ts +3 -3
- package/dist/api/types/ListResponseHeatmapCell.js +1 -1
- package/dist/api/types/ListResponseJob.d.ts +3 -3
- package/dist/api/types/ListResponseJob.js +1 -1
- package/dist/api/types/ListResponseLanguage.d.ts +3 -3
- package/dist/api/types/ListResponseLanguage.js +1 -1
- package/dist/api/types/ListResponseMembership.d.ts +3 -3
- package/dist/api/types/ListResponseMembership.js +1 -1
- package/dist/api/types/ListResponseNotification.d.ts +27 -0
- package/dist/api/types/ListResponseNotification.js +11 -0
- package/dist/api/types/ListResponseNotificationDeadLetter.d.ts +27 -0
- package/dist/api/types/ListResponseNotificationDeadLetter.js +11 -0
- package/dist/api/types/ListResponseOperatorPosition.d.ts +3 -3
- package/dist/api/types/ListResponseOperatorPosition.js +1 -1
- package/dist/api/types/ListResponseOrganization.d.ts +3 -3
- package/dist/api/types/ListResponseOrganization.js +1 -1
- package/dist/api/types/ListResponsePosition.d.ts +3 -3
- package/dist/api/types/ListResponsePosition.js +1 -1
- package/dist/api/types/ListResponseTimezone.d.ts +3 -3
- package/dist/api/types/ListResponseTimezone.js +1 -1
- package/dist/api/types/ListResponseUserResource.d.ts +3 -3
- package/dist/api/types/ListResponseUserResource.js +1 -1
- package/dist/api/types/Membership.d.ts +2 -2
- package/dist/api/types/Membership.js +1 -1
- package/dist/api/types/Notification.d.ts +52 -0
- package/dist/api/types/Notification.js +27 -0
- package/dist/api/types/NotificationCategoryCount.d.ts +23 -0
- package/dist/api/types/NotificationCategoryCount.js +16 -0
- package/dist/api/types/NotificationCounts.d.ts +23 -0
- package/dist/api/types/NotificationCounts.js +11 -0
- package/dist/api/types/NotificationDeadLetter.d.ts +36 -0
- package/dist/api/types/NotificationDeadLetter.js +11 -0
- package/dist/api/types/NotificationPreference.d.ts +13 -0
- package/dist/api/types/NotificationPreference.js +3 -0
- package/dist/api/types/NotificationPreferenceItem.d.ts +13 -0
- package/dist/api/types/NotificationPreferenceItem.js +3 -0
- package/dist/api/types/NotificationPreferences.d.ts +17 -0
- package/dist/api/types/NotificationPreferences.js +11 -0
- package/dist/api/types/NotificationUnreadCount.d.ts +16 -0
- package/dist/api/types/NotificationUnreadCount.js +11 -0
- package/dist/api/types/NotificationsArchived.d.ts +16 -0
- package/dist/api/types/NotificationsArchived.js +11 -0
- package/dist/api/types/NotificationsMarkedRead.d.ts +16 -0
- package/dist/api/types/NotificationsMarkedRead.js +11 -0
- package/dist/api/types/Operator.d.ts +2 -2
- package/dist/api/types/Operator.js +1 -1
- package/dist/api/types/Organization.d.ts +2 -2
- package/dist/api/types/Organization.js +1 -1
- package/dist/api/types/QuietHours.d.ts +11 -0
- package/dist/api/types/QuietHours.js +3 -0
- package/dist/api/types/RealtimeTicket.d.ts +2 -2
- package/dist/api/types/RealtimeTicket.js +1 -1
- package/dist/api/types/ReconcileResponse.d.ts +2 -2
- package/dist/api/types/ReconcileResponse.js +1 -1
- package/dist/api/types/Timezone.d.ts +2 -2
- package/dist/api/types/Timezone.js +1 -1
- package/dist/api/types/User.d.ts +2 -2
- package/dist/api/types/User.js +1 -1
- package/dist/api/types/UserResource.d.ts +2 -2
- package/dist/api/types/UserResource.js +1 -1
- package/dist/api/types/index.d.ts +15 -0
- package/dist/api/types/index.js +15 -0
- package/package.json +1 -1
|
@@ -0,0 +1,623 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.NotificationsClient = void 0;
|
|
38
|
+
const BaseClient_js_1 = require("../../../../BaseClient.js");
|
|
39
|
+
const headers_js_1 = require("../../../../core/headers.js");
|
|
40
|
+
const core = __importStar(require("../../../../core/index.js"));
|
|
41
|
+
const environments = __importStar(require("../../../../environments.js"));
|
|
42
|
+
const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
|
|
43
|
+
const errors = __importStar(require("../../../../errors/index.js"));
|
|
44
|
+
const NizamMerchant = __importStar(require("../../../index.js"));
|
|
45
|
+
/**
|
|
46
|
+
* The authenticated user's notification inbox.
|
|
47
|
+
*/
|
|
48
|
+
class NotificationsClient {
|
|
49
|
+
constructor(options) {
|
|
50
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The caller's own notifications ordered by `created_at` descending (pass `sort=created_at` for ascending). `status` selects the segment — `all` (default; the active inbox, non-archived), `unread`, `read`, or `archived`. `category` and `kind` accept comma-separated values and AND on top of the segment; `q` matches the notification title/body. `since=` (RFC 3339) returns only items at/after the instant for incremental catch-up after a reconnect. Pagination is bidirectional (`starting_after` / `ending_before`); cursors are bound to the sort direction that minted them.
|
|
54
|
+
*
|
|
55
|
+
* @param {NizamMerchant.ListNotificationsRequest} request
|
|
56
|
+
* @param {NotificationsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
57
|
+
*
|
|
58
|
+
* @throws {@link NizamMerchant.BadRequestError}
|
|
59
|
+
* @throws {@link NizamMerchant.UnauthorizedError}
|
|
60
|
+
* @throws {@link NizamMerchant.ForbiddenError}
|
|
61
|
+
* @throws {@link NizamMerchant.TooManyRequestsError}
|
|
62
|
+
* @throws {@link NizamMerchant.InternalServerError}
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* await client.notifications.listNotifications({
|
|
66
|
+
* status: "<string>",
|
|
67
|
+
* q: "<string>",
|
|
68
|
+
* since: "2026-05-20T14:00:00Z",
|
|
69
|
+
* starting_after: "Y3Vyc29yX25leHRfMDFKNVE=",
|
|
70
|
+
* ending_before: "Y3Vyc29yX25leHRfMDFKNVE="
|
|
71
|
+
* })
|
|
72
|
+
*/
|
|
73
|
+
listNotifications(request = {}, requestOptions) {
|
|
74
|
+
return core.HttpResponsePromise.fromPromise(this.__listNotifications(request, requestOptions));
|
|
75
|
+
}
|
|
76
|
+
async __listNotifications(request = {}, requestOptions) {
|
|
77
|
+
const { status, category, kind, q, since, sort, limit, starting_after: startingAfter, ending_before: endingBefore, } = request;
|
|
78
|
+
const _queryParams = {
|
|
79
|
+
status,
|
|
80
|
+
category,
|
|
81
|
+
kind,
|
|
82
|
+
q,
|
|
83
|
+
since: since != null ? since : undefined,
|
|
84
|
+
sort,
|
|
85
|
+
limit,
|
|
86
|
+
starting_after: startingAfter,
|
|
87
|
+
ending_before: endingBefore,
|
|
88
|
+
};
|
|
89
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
90
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
91
|
+
const _response = await core.fetcher({
|
|
92
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
93
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
94
|
+
environments.NizamMerchantEnvironment.Production, "v1/notifications"),
|
|
95
|
+
method: "GET",
|
|
96
|
+
headers: _headers,
|
|
97
|
+
queryString: core.url
|
|
98
|
+
.queryBuilder()
|
|
99
|
+
.addMany(_queryParams)
|
|
100
|
+
.mergeAdditional(requestOptions?.queryParams)
|
|
101
|
+
.build(),
|
|
102
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
103
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
104
|
+
abortSignal: requestOptions?.abortSignal,
|
|
105
|
+
fetchFn: this._options?.fetch,
|
|
106
|
+
logging: this._options.logging,
|
|
107
|
+
});
|
|
108
|
+
if (_response.ok) {
|
|
109
|
+
return {
|
|
110
|
+
data: _response.body,
|
|
111
|
+
rawResponse: _response.rawResponse,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (_response.error.reason === "status-code") {
|
|
115
|
+
switch (_response.error.statusCode) {
|
|
116
|
+
case 400:
|
|
117
|
+
throw new NizamMerchant.BadRequestError(_response.error.body, _response.rawResponse);
|
|
118
|
+
case 401:
|
|
119
|
+
throw new NizamMerchant.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
120
|
+
case 403:
|
|
121
|
+
throw new NizamMerchant.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
122
|
+
case 429:
|
|
123
|
+
throw new NizamMerchant.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
124
|
+
case 500:
|
|
125
|
+
throw new NizamMerchant.InternalServerError(_response.error.body, _response.rawResponse);
|
|
126
|
+
default:
|
|
127
|
+
throw new errors.NizamMerchantError({
|
|
128
|
+
statusCode: _response.error.statusCode,
|
|
129
|
+
body: _response.error.body,
|
|
130
|
+
rawResponse: _response.rawResponse,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v1/notifications");
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Archives every active notification of the caller in one operation. Returns the number archived (zero when the active inbox was already empty).
|
|
138
|
+
*
|
|
139
|
+
* @param {NotificationsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
140
|
+
*
|
|
141
|
+
* @throws {@link NizamMerchant.BadRequestError}
|
|
142
|
+
* @throws {@link NizamMerchant.UnauthorizedError}
|
|
143
|
+
* @throws {@link NizamMerchant.ForbiddenError}
|
|
144
|
+
* @throws {@link NizamMerchant.TooManyRequestsError}
|
|
145
|
+
* @throws {@link NizamMerchant.InternalServerError}
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* await client.notifications.archiveAllNotifications()
|
|
149
|
+
*/
|
|
150
|
+
archiveAllNotifications(requestOptions) {
|
|
151
|
+
return core.HttpResponsePromise.fromPromise(this.__archiveAllNotifications(requestOptions));
|
|
152
|
+
}
|
|
153
|
+
async __archiveAllNotifications(requestOptions) {
|
|
154
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
155
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
156
|
+
const _response = await core.fetcher({
|
|
157
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
158
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
159
|
+
environments.NizamMerchantEnvironment.Production, "v1/notifications/archive_all"),
|
|
160
|
+
method: "POST",
|
|
161
|
+
headers: _headers,
|
|
162
|
+
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
163
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
164
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
165
|
+
abortSignal: requestOptions?.abortSignal,
|
|
166
|
+
fetchFn: this._options?.fetch,
|
|
167
|
+
logging: this._options.logging,
|
|
168
|
+
});
|
|
169
|
+
if (_response.ok) {
|
|
170
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
171
|
+
}
|
|
172
|
+
if (_response.error.reason === "status-code") {
|
|
173
|
+
switch (_response.error.statusCode) {
|
|
174
|
+
case 400:
|
|
175
|
+
throw new NizamMerchant.BadRequestError(_response.error.body, _response.rawResponse);
|
|
176
|
+
case 401:
|
|
177
|
+
throw new NizamMerchant.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
178
|
+
case 403:
|
|
179
|
+
throw new NizamMerchant.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
180
|
+
case 429:
|
|
181
|
+
throw new NizamMerchant.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
182
|
+
case 500:
|
|
183
|
+
throw new NizamMerchant.InternalServerError(_response.error.body, _response.rawResponse);
|
|
184
|
+
default:
|
|
185
|
+
throw new errors.NizamMerchantError({
|
|
186
|
+
statusCode: _response.error.statusCode,
|
|
187
|
+
body: _response.error.body,
|
|
188
|
+
rawResponse: _response.rawResponse,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/v1/notifications/archive_all");
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The segment-badge roll-up for the active organization: total + unread (active, non-archived), archived, and per-category active total/unread. Computed server-side in one pass so segment badges stay accurate across cursor pages (never inferred from the loaded page). Excludes dismissed (soft-deleted) notifications.
|
|
196
|
+
*
|
|
197
|
+
* @param {NotificationsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
198
|
+
*
|
|
199
|
+
* @throws {@link NizamMerchant.BadRequestError}
|
|
200
|
+
* @throws {@link NizamMerchant.UnauthorizedError}
|
|
201
|
+
* @throws {@link NizamMerchant.ForbiddenError}
|
|
202
|
+
* @throws {@link NizamMerchant.TooManyRequestsError}
|
|
203
|
+
* @throws {@link NizamMerchant.InternalServerError}
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* await client.notifications.getNotificationCounts()
|
|
207
|
+
*/
|
|
208
|
+
getNotificationCounts(requestOptions) {
|
|
209
|
+
return core.HttpResponsePromise.fromPromise(this.__getNotificationCounts(requestOptions));
|
|
210
|
+
}
|
|
211
|
+
async __getNotificationCounts(requestOptions) {
|
|
212
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
213
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
214
|
+
const _response = await core.fetcher({
|
|
215
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
216
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
217
|
+
environments.NizamMerchantEnvironment.Production, "v1/notifications/counts"),
|
|
218
|
+
method: "GET",
|
|
219
|
+
headers: _headers,
|
|
220
|
+
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
221
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
222
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
223
|
+
abortSignal: requestOptions?.abortSignal,
|
|
224
|
+
fetchFn: this._options?.fetch,
|
|
225
|
+
logging: this._options.logging,
|
|
226
|
+
});
|
|
227
|
+
if (_response.ok) {
|
|
228
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
229
|
+
}
|
|
230
|
+
if (_response.error.reason === "status-code") {
|
|
231
|
+
switch (_response.error.statusCode) {
|
|
232
|
+
case 400:
|
|
233
|
+
throw new NizamMerchant.BadRequestError(_response.error.body, _response.rawResponse);
|
|
234
|
+
case 401:
|
|
235
|
+
throw new NizamMerchant.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
236
|
+
case 403:
|
|
237
|
+
throw new NizamMerchant.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
238
|
+
case 429:
|
|
239
|
+
throw new NizamMerchant.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
240
|
+
case 500:
|
|
241
|
+
throw new NizamMerchant.InternalServerError(_response.error.body, _response.rawResponse);
|
|
242
|
+
default:
|
|
243
|
+
throw new errors.NizamMerchantError({
|
|
244
|
+
statusCode: _response.error.statusCode,
|
|
245
|
+
body: _response.error.body,
|
|
246
|
+
rawResponse: _response.rawResponse,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v1/notifications/counts");
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Flips every unread notification of the caller to read in one operation. Returns the number of notifications that were flipped (zero when the inbox was already clear).
|
|
254
|
+
*
|
|
255
|
+
* @param {NotificationsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
256
|
+
*
|
|
257
|
+
* @throws {@link NizamMerchant.BadRequestError}
|
|
258
|
+
* @throws {@link NizamMerchant.UnauthorizedError}
|
|
259
|
+
* @throws {@link NizamMerchant.ForbiddenError}
|
|
260
|
+
* @throws {@link NizamMerchant.TooManyRequestsError}
|
|
261
|
+
* @throws {@link NizamMerchant.InternalServerError}
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* await client.notifications.markAllNotificationsRead()
|
|
265
|
+
*/
|
|
266
|
+
markAllNotificationsRead(requestOptions) {
|
|
267
|
+
return core.HttpResponsePromise.fromPromise(this.__markAllNotificationsRead(requestOptions));
|
|
268
|
+
}
|
|
269
|
+
async __markAllNotificationsRead(requestOptions) {
|
|
270
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
271
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
272
|
+
const _response = await core.fetcher({
|
|
273
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
274
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
275
|
+
environments.NizamMerchantEnvironment.Production, "v1/notifications/read_all"),
|
|
276
|
+
method: "POST",
|
|
277
|
+
headers: _headers,
|
|
278
|
+
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
279
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
280
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
281
|
+
abortSignal: requestOptions?.abortSignal,
|
|
282
|
+
fetchFn: this._options?.fetch,
|
|
283
|
+
logging: this._options.logging,
|
|
284
|
+
});
|
|
285
|
+
if (_response.ok) {
|
|
286
|
+
return {
|
|
287
|
+
data: _response.body,
|
|
288
|
+
rawResponse: _response.rawResponse,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
if (_response.error.reason === "status-code") {
|
|
292
|
+
switch (_response.error.statusCode) {
|
|
293
|
+
case 400:
|
|
294
|
+
throw new NizamMerchant.BadRequestError(_response.error.body, _response.rawResponse);
|
|
295
|
+
case 401:
|
|
296
|
+
throw new NizamMerchant.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
297
|
+
case 403:
|
|
298
|
+
throw new NizamMerchant.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
299
|
+
case 429:
|
|
300
|
+
throw new NizamMerchant.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
301
|
+
case 500:
|
|
302
|
+
throw new NizamMerchant.InternalServerError(_response.error.body, _response.rawResponse);
|
|
303
|
+
default:
|
|
304
|
+
throw new errors.NizamMerchantError({
|
|
305
|
+
statusCode: _response.error.statusCode,
|
|
306
|
+
body: _response.error.body,
|
|
307
|
+
rawResponse: _response.rawResponse,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/v1/notifications/read_all");
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* The unread badge count for the active organization. Counts active (non-archived) unread notifications; excludes dismissed (soft-deleted) and archived ones.
|
|
315
|
+
*
|
|
316
|
+
* @param {NotificationsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
317
|
+
*
|
|
318
|
+
* @throws {@link NizamMerchant.BadRequestError}
|
|
319
|
+
* @throws {@link NizamMerchant.UnauthorizedError}
|
|
320
|
+
* @throws {@link NizamMerchant.ForbiddenError}
|
|
321
|
+
* @throws {@link NizamMerchant.TooManyRequestsError}
|
|
322
|
+
* @throws {@link NizamMerchant.InternalServerError}
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* await client.notifications.getUnreadNotificationCount()
|
|
326
|
+
*/
|
|
327
|
+
getUnreadNotificationCount(requestOptions) {
|
|
328
|
+
return core.HttpResponsePromise.fromPromise(this.__getUnreadNotificationCount(requestOptions));
|
|
329
|
+
}
|
|
330
|
+
async __getUnreadNotificationCount(requestOptions) {
|
|
331
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
332
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
333
|
+
const _response = await core.fetcher({
|
|
334
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
335
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
336
|
+
environments.NizamMerchantEnvironment.Production, "v1/notifications/unread_count"),
|
|
337
|
+
method: "GET",
|
|
338
|
+
headers: _headers,
|
|
339
|
+
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
340
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
341
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
342
|
+
abortSignal: requestOptions?.abortSignal,
|
|
343
|
+
fetchFn: this._options?.fetch,
|
|
344
|
+
logging: this._options.logging,
|
|
345
|
+
});
|
|
346
|
+
if (_response.ok) {
|
|
347
|
+
return {
|
|
348
|
+
data: _response.body,
|
|
349
|
+
rawResponse: _response.rawResponse,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
if (_response.error.reason === "status-code") {
|
|
353
|
+
switch (_response.error.statusCode) {
|
|
354
|
+
case 400:
|
|
355
|
+
throw new NizamMerchant.BadRequestError(_response.error.body, _response.rawResponse);
|
|
356
|
+
case 401:
|
|
357
|
+
throw new NizamMerchant.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
358
|
+
case 403:
|
|
359
|
+
throw new NizamMerchant.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
360
|
+
case 429:
|
|
361
|
+
throw new NizamMerchant.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
362
|
+
case 500:
|
|
363
|
+
throw new NizamMerchant.InternalServerError(_response.error.body, _response.rawResponse);
|
|
364
|
+
default:
|
|
365
|
+
throw new errors.NizamMerchantError({
|
|
366
|
+
statusCode: _response.error.statusCode,
|
|
367
|
+
body: _response.error.body,
|
|
368
|
+
rawResponse: _response.rawResponse,
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v1/notifications/unread_count");
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Moves a single notification to the archive ("Done") — reversible, not a delete: it leaves the active inbox but stays listable under `status=archived`. Idempotent. 404 if the notification is not the caller's.
|
|
376
|
+
*
|
|
377
|
+
* @param {NizamMerchant.ArchiveNotificationRequest} request
|
|
378
|
+
* @param {NotificationsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
379
|
+
*
|
|
380
|
+
* @throws {@link NizamMerchant.UnauthorizedError}
|
|
381
|
+
* @throws {@link NizamMerchant.ForbiddenError}
|
|
382
|
+
* @throws {@link NizamMerchant.NotFoundError}
|
|
383
|
+
* @throws {@link NizamMerchant.TooManyRequestsError}
|
|
384
|
+
* @throws {@link NizamMerchant.InternalServerError}
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* await client.notifications.archiveNotification({
|
|
388
|
+
* id: "00000000-0000-0000-0000-000000000000"
|
|
389
|
+
* })
|
|
390
|
+
*/
|
|
391
|
+
archiveNotification(request, requestOptions) {
|
|
392
|
+
return core.HttpResponsePromise.fromPromise(this.__archiveNotification(request, requestOptions));
|
|
393
|
+
}
|
|
394
|
+
async __archiveNotification(request, requestOptions) {
|
|
395
|
+
const { id } = request;
|
|
396
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
397
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
398
|
+
const _response = await core.fetcher({
|
|
399
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
400
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
401
|
+
environments.NizamMerchantEnvironment.Production, `v1/notifications/${core.url.encodePathParam(id)}/archive`),
|
|
402
|
+
method: "POST",
|
|
403
|
+
headers: _headers,
|
|
404
|
+
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
405
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
406
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
407
|
+
abortSignal: requestOptions?.abortSignal,
|
|
408
|
+
fetchFn: this._options?.fetch,
|
|
409
|
+
logging: this._options.logging,
|
|
410
|
+
});
|
|
411
|
+
if (_response.ok) {
|
|
412
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
413
|
+
}
|
|
414
|
+
if (_response.error.reason === "status-code") {
|
|
415
|
+
switch (_response.error.statusCode) {
|
|
416
|
+
case 401:
|
|
417
|
+
throw new NizamMerchant.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
418
|
+
case 403:
|
|
419
|
+
throw new NizamMerchant.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
420
|
+
case 404:
|
|
421
|
+
throw new NizamMerchant.NotFoundError(_response.error.body, _response.rawResponse);
|
|
422
|
+
case 429:
|
|
423
|
+
throw new NizamMerchant.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
424
|
+
case 500:
|
|
425
|
+
throw new NizamMerchant.InternalServerError(_response.error.body, _response.rawResponse);
|
|
426
|
+
default:
|
|
427
|
+
throw new errors.NizamMerchantError({
|
|
428
|
+
statusCode: _response.error.statusCode,
|
|
429
|
+
body: _response.error.body,
|
|
430
|
+
rawResponse: _response.rawResponse,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/v1/notifications/{id}/archive");
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Flips a single notification to read. Idempotent — a second call is a no-op that preserves the original read timestamp. 404 if the notification is not the caller's.
|
|
438
|
+
*
|
|
439
|
+
* @param {NizamMerchant.MarkNotificationReadRequest} request
|
|
440
|
+
* @param {NotificationsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
441
|
+
*
|
|
442
|
+
* @throws {@link NizamMerchant.UnauthorizedError}
|
|
443
|
+
* @throws {@link NizamMerchant.ForbiddenError}
|
|
444
|
+
* @throws {@link NizamMerchant.NotFoundError}
|
|
445
|
+
* @throws {@link NizamMerchant.TooManyRequestsError}
|
|
446
|
+
* @throws {@link NizamMerchant.InternalServerError}
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* await client.notifications.markNotificationRead({
|
|
450
|
+
* id: "00000000-0000-0000-0000-000000000000"
|
|
451
|
+
* })
|
|
452
|
+
*/
|
|
453
|
+
markNotificationRead(request, requestOptions) {
|
|
454
|
+
return core.HttpResponsePromise.fromPromise(this.__markNotificationRead(request, requestOptions));
|
|
455
|
+
}
|
|
456
|
+
async __markNotificationRead(request, requestOptions) {
|
|
457
|
+
const { id } = request;
|
|
458
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
459
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
460
|
+
const _response = await core.fetcher({
|
|
461
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
462
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
463
|
+
environments.NizamMerchantEnvironment.Production, `v1/notifications/${core.url.encodePathParam(id)}/read`),
|
|
464
|
+
method: "POST",
|
|
465
|
+
headers: _headers,
|
|
466
|
+
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
467
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
468
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
469
|
+
abortSignal: requestOptions?.abortSignal,
|
|
470
|
+
fetchFn: this._options?.fetch,
|
|
471
|
+
logging: this._options.logging,
|
|
472
|
+
});
|
|
473
|
+
if (_response.ok) {
|
|
474
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
475
|
+
}
|
|
476
|
+
if (_response.error.reason === "status-code") {
|
|
477
|
+
switch (_response.error.statusCode) {
|
|
478
|
+
case 401:
|
|
479
|
+
throw new NizamMerchant.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
480
|
+
case 403:
|
|
481
|
+
throw new NizamMerchant.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
482
|
+
case 404:
|
|
483
|
+
throw new NizamMerchant.NotFoundError(_response.error.body, _response.rawResponse);
|
|
484
|
+
case 429:
|
|
485
|
+
throw new NizamMerchant.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
486
|
+
case 500:
|
|
487
|
+
throw new NizamMerchant.InternalServerError(_response.error.body, _response.rawResponse);
|
|
488
|
+
default:
|
|
489
|
+
throw new errors.NizamMerchantError({
|
|
490
|
+
statusCode: _response.error.statusCode,
|
|
491
|
+
body: _response.error.body,
|
|
492
|
+
rawResponse: _response.rawResponse,
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/v1/notifications/{id}/read");
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Restores an archived notification to the active inbox — the inverse of archive. Idempotent. 404 if the notification is not the caller's.
|
|
500
|
+
*
|
|
501
|
+
* @param {NizamMerchant.UnarchiveNotificationRequest} request
|
|
502
|
+
* @param {NotificationsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
503
|
+
*
|
|
504
|
+
* @throws {@link NizamMerchant.UnauthorizedError}
|
|
505
|
+
* @throws {@link NizamMerchant.ForbiddenError}
|
|
506
|
+
* @throws {@link NizamMerchant.NotFoundError}
|
|
507
|
+
* @throws {@link NizamMerchant.TooManyRequestsError}
|
|
508
|
+
* @throws {@link NizamMerchant.InternalServerError}
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* await client.notifications.unarchiveNotification({
|
|
512
|
+
* id: "00000000-0000-0000-0000-000000000000"
|
|
513
|
+
* })
|
|
514
|
+
*/
|
|
515
|
+
unarchiveNotification(request, requestOptions) {
|
|
516
|
+
return core.HttpResponsePromise.fromPromise(this.__unarchiveNotification(request, requestOptions));
|
|
517
|
+
}
|
|
518
|
+
async __unarchiveNotification(request, requestOptions) {
|
|
519
|
+
const { id } = request;
|
|
520
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
521
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
522
|
+
const _response = await core.fetcher({
|
|
523
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
524
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
525
|
+
environments.NizamMerchantEnvironment.Production, `v1/notifications/${core.url.encodePathParam(id)}/unarchive`),
|
|
526
|
+
method: "POST",
|
|
527
|
+
headers: _headers,
|
|
528
|
+
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
529
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
530
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
531
|
+
abortSignal: requestOptions?.abortSignal,
|
|
532
|
+
fetchFn: this._options?.fetch,
|
|
533
|
+
logging: this._options.logging,
|
|
534
|
+
});
|
|
535
|
+
if (_response.ok) {
|
|
536
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
537
|
+
}
|
|
538
|
+
if (_response.error.reason === "status-code") {
|
|
539
|
+
switch (_response.error.statusCode) {
|
|
540
|
+
case 401:
|
|
541
|
+
throw new NizamMerchant.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
542
|
+
case 403:
|
|
543
|
+
throw new NizamMerchant.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
544
|
+
case 404:
|
|
545
|
+
throw new NizamMerchant.NotFoundError(_response.error.body, _response.rawResponse);
|
|
546
|
+
case 429:
|
|
547
|
+
throw new NizamMerchant.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
548
|
+
case 500:
|
|
549
|
+
throw new NizamMerchant.InternalServerError(_response.error.body, _response.rawResponse);
|
|
550
|
+
default:
|
|
551
|
+
throw new errors.NizamMerchantError({
|
|
552
|
+
statusCode: _response.error.statusCode,
|
|
553
|
+
body: _response.error.body,
|
|
554
|
+
rawResponse: _response.rawResponse,
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/v1/notifications/{id}/unarchive");
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Flips a single notification back to unread — the inverse of mark-read. Idempotent. 404 if the notification is not the caller's.
|
|
562
|
+
*
|
|
563
|
+
* @param {NizamMerchant.MarkNotificationUnreadRequest} request
|
|
564
|
+
* @param {NotificationsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
565
|
+
*
|
|
566
|
+
* @throws {@link NizamMerchant.UnauthorizedError}
|
|
567
|
+
* @throws {@link NizamMerchant.ForbiddenError}
|
|
568
|
+
* @throws {@link NizamMerchant.NotFoundError}
|
|
569
|
+
* @throws {@link NizamMerchant.TooManyRequestsError}
|
|
570
|
+
* @throws {@link NizamMerchant.InternalServerError}
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* await client.notifications.markNotificationUnread({
|
|
574
|
+
* id: "00000000-0000-0000-0000-000000000000"
|
|
575
|
+
* })
|
|
576
|
+
*/
|
|
577
|
+
markNotificationUnread(request, requestOptions) {
|
|
578
|
+
return core.HttpResponsePromise.fromPromise(this.__markNotificationUnread(request, requestOptions));
|
|
579
|
+
}
|
|
580
|
+
async __markNotificationUnread(request, requestOptions) {
|
|
581
|
+
const { id } = request;
|
|
582
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
583
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
584
|
+
const _response = await core.fetcher({
|
|
585
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
586
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
587
|
+
environments.NizamMerchantEnvironment.Production, `v1/notifications/${core.url.encodePathParam(id)}/unread`),
|
|
588
|
+
method: "POST",
|
|
589
|
+
headers: _headers,
|
|
590
|
+
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
591
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
592
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
593
|
+
abortSignal: requestOptions?.abortSignal,
|
|
594
|
+
fetchFn: this._options?.fetch,
|
|
595
|
+
logging: this._options.logging,
|
|
596
|
+
});
|
|
597
|
+
if (_response.ok) {
|
|
598
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
599
|
+
}
|
|
600
|
+
if (_response.error.reason === "status-code") {
|
|
601
|
+
switch (_response.error.statusCode) {
|
|
602
|
+
case 401:
|
|
603
|
+
throw new NizamMerchant.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
604
|
+
case 403:
|
|
605
|
+
throw new NizamMerchant.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
606
|
+
case 404:
|
|
607
|
+
throw new NizamMerchant.NotFoundError(_response.error.body, _response.rawResponse);
|
|
608
|
+
case 429:
|
|
609
|
+
throw new NizamMerchant.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
610
|
+
case 500:
|
|
611
|
+
throw new NizamMerchant.InternalServerError(_response.error.body, _response.rawResponse);
|
|
612
|
+
default:
|
|
613
|
+
throw new errors.NizamMerchantError({
|
|
614
|
+
statusCode: _response.error.statusCode,
|
|
615
|
+
body: _response.error.body,
|
|
616
|
+
rawResponse: _response.rawResponse,
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/v1/notifications/{id}/unread");
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
exports.NotificationsClient = NotificationsClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./requests/index.js"), exports);
|