@paddle/paddle-node-sdk
Version:
A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.
52 lines (51 loc) • 2.7 kB
JavaScript
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 { Notification, NotificationCollection, NotificationLogCollection, ReplayNotification, } from '../../entities/index.js';
const NotificationPaths = {
list: '/notifications',
get: '/notifications/{notification_id}',
getLogs: '/notifications/{notification_id}/logs',
replay: '/notifications/{notification_id}/replay',
};
export * from './operations/index.js';
export class NotificationsResource extends BaseResource {
list(queryParams) {
const queryParameters = new QueryParameters(queryParams);
return new NotificationCollection(this.client, NotificationPaths.list + queryParameters.toQueryString());
}
get(notificationId) {
return __awaiter(this, void 0, void 0, function* () {
const urlWithPathParams = new PathParameters(NotificationPaths.get, {
notification_id: notificationId,
}).deriveUrl();
const response = yield this.client.get(urlWithPathParams);
const data = this.handleResponse(response);
return new Notification(data);
});
}
replay(notificationId) {
return __awaiter(this, void 0, void 0, function* () {
const urlWithPathParams = new PathParameters(NotificationPaths.replay, {
notification_id: notificationId,
}).deriveUrl();
const response = yield this.client.post(urlWithPathParams, undefined);
const data = this.handleResponse(response);
return new ReplayNotification(data);
});
}
getLogs(notificationId, queryParams) {
const queryParameters = new QueryParameters(queryParams);
const urlWithPathParams = new PathParameters(NotificationPaths.getLogs, {
notification_id: notificationId,
}).deriveUrl();
return new NotificationLogCollection(this.client, urlWithPathParams + queryParameters.toQueryString());
}
}