UNPKG

@paddle/paddle-node-sdk

Version:

A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.

68 lines (67 loc) 3.47 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { BaseResource, PathParameters, QueryParameters } from '../../internal/base/index.js'; import { NotificationSettings } from '../../entities/index.js'; const NotificationSettingsPaths = { list: '/notification-settings', create: '/notification-settings', get: '/notification-settings/{notification_setting_id}', update: '/notification-settings/{notification_setting_id}', delete: '/notification-settings/{notification_setting_id}', }; export * from './operations/index.js'; export class NotificationSettingsResource extends BaseResource { list(queryParams) { return __awaiter(this, void 0, void 0, function* () { const queryParameters = new QueryParameters(queryParams); const response = yield this.client.get(NotificationSettingsPaths.list + queryParameters.toQueryString()); const data = this.handleResponse(response); return data.map((notificationSetting) => new NotificationSettings(notificationSetting)); }); } create(createNotificationSettings) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.client.post(NotificationSettingsPaths.create, createNotificationSettings); const data = this.handleResponse(response); return new NotificationSettings(data); }); } get(notificationId) { return __awaiter(this, void 0, void 0, function* () { const urlWithPathParams = new PathParameters(NotificationSettingsPaths.get, { notification_setting_id: notificationId, }).deriveUrl(); const response = yield this.client.get(urlWithPathParams); const data = this.handleResponse(response); return new NotificationSettings(data); }); } update(notificationId, updateNotificationSettings) { return __awaiter(this, void 0, void 0, function* () { const urlWithPathParams = new PathParameters(NotificationSettingsPaths.update, { notification_setting_id: notificationId, }).deriveUrl(); const response = yield this.client.patch(urlWithPathParams, updateNotificationSettings); const data = this.handleResponse(response); return new NotificationSettings(data); }); } delete(notificationId) { return __awaiter(this, void 0, void 0, function* () { const urlWithPathParams = new PathParameters(NotificationSettingsPaths.update, { notification_setting_id: notificationId, }).deriveUrl(); const response = yield this.client.delete(urlWithPathParams); if (response) { this.handleResponse(response); } }); } }