Comparing version 1.6.5 to 1.6.6
@@ -1,2 +0,1 @@ | ||
import { AnyResponse } from "./services/shared.types"; | ||
export * from "./services/detector"; | ||
@@ -7,23 +6,2 @@ export * from "./services/p2p"; | ||
export * from "./services/personal.types"; | ||
/** | ||
* Форматирует дату в понятную для QIWI строку: | ||
* | ||
* `ГГГГ-ММ-ДДTЧЧ:ММ:СС+\-ЧЧ:ММ` | ||
* | ||
* @param {Date | number | string} date Аргумент для конструктора | ||
* @return {string} | ||
*/ | ||
export declare function formatDate(date: Date | number | string): string; | ||
/** | ||
* Разбирает строку запроса, в том формате, который передаёт QIWI | ||
* @param {string} querystring Строка запроса | ||
* @return {*} | ||
*/ | ||
export declare function parseQS(querystring: string): AnyResponse; | ||
/** | ||
* Создаёт строку запроса, в формате, который понимает QIWI | ||
* | ||
* @param {AnyResponse} object Объект для преобразования | ||
* @return {string} | ||
*/ | ||
export declare function createQS(object: AnyResponse): string; | ||
export * from "./services/shared"; |
@@ -12,8 +12,3 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createQS = exports.parseQS = exports.formatDate = void 0; | ||
const query_string_1 = __importDefault(require("query-string")); | ||
__exportStar(require("./services/detector"), exports); | ||
@@ -24,50 +19,2 @@ __exportStar(require("./services/p2p"), exports); | ||
__exportStar(require("./services/personal.types"), exports); | ||
/** | ||
* Форматирует часть даты | ||
* @param {number} x | ||
* @return {string} | ||
*/ | ||
const fd = (x) => x.toString().padStart(2, "0"); | ||
/** | ||
* Форматирует дату в понятную для QIWI строку: | ||
* | ||
* `ГГГГ-ММ-ДДTЧЧ:ММ:СС+\-ЧЧ:ММ` | ||
* | ||
* @param {Date | number | string} date Аргумент для конструктора | ||
* @return {string} | ||
*/ | ||
function formatDate(date) { | ||
const d = new Date(date); | ||
const tz = d.getTimezoneOffset(); | ||
const sign = tz > 0 ? "-" : "+"; | ||
const base = d.toISOString().split(".")[0]; | ||
return base + sign + fd(Math.trunc(Math.abs(tz) / 60)) + ":" + fd(tz % 60); | ||
} | ||
exports.formatDate = formatDate; | ||
/** | ||
* Разбирает строку запроса, в том формате, который передаёт QIWI | ||
* @param {string} querystring Строка запроса | ||
* @return {*} | ||
*/ | ||
function parseQS(querystring) { | ||
return query_string_1.default.parse(querystring, { | ||
arrayFormat: "index", | ||
parseBooleans: true, | ||
parseNumbers: true | ||
}); | ||
} | ||
exports.parseQS = parseQS; | ||
/** | ||
* Создаёт строку запроса, в формате, который понимает QIWI | ||
* | ||
* @param {AnyResponse} object Объект для преобразования | ||
* @return {string} | ||
*/ | ||
function createQS(object) { | ||
return query_string_1.default.stringify(object, { | ||
arrayFormat: "index", | ||
skipNull: true, | ||
skipEmptyString: false | ||
}); | ||
} | ||
exports.createQS = createQS; | ||
__exportStar(require("./services/shared"), exports); |
@@ -17,3 +17,3 @@ "use strict"; | ||
const uuid_1 = require("uuid"); | ||
const __1 = require(".."); | ||
const shared_1 = require("./shared"); | ||
const error_1 = require("../error"); | ||
@@ -154,3 +154,3 @@ const http_1 = require("../http"); | ||
date.setTime(time); | ||
return __1.formatDate(date); | ||
return shared_1.formatDate(date); | ||
} | ||
@@ -189,3 +189,3 @@ /** | ||
}; | ||
return `https://oplata.qiwi.com/create?${__1.createQS(options)}`; | ||
return `https://oplata.qiwi.com/create?${shared_1.createQS(options)}`; | ||
} | ||
@@ -192,0 +192,0 @@ } |
@@ -35,3 +35,3 @@ "use strict"; | ||
const sweet_decorators_1 = require("sweet-decorators"); | ||
const __1 = require(".."); | ||
const shared_1 = require("./shared"); | ||
const error_1 = require("../error"); | ||
@@ -64,3 +64,3 @@ const http_1 = require("../http"); | ||
if (error instanceof http_1.HttpError) { | ||
return new PersonalApiError(error.message, JSON.parse(error.body)); | ||
return new PersonalApiError(error.message, error.body ? JSON.parse(error.body) : undefined); | ||
} | ||
@@ -118,3 +118,3 @@ return error; | ||
async getLimits(wallet, limits) { | ||
const query = __1.createQS({ types: limits }); | ||
const query = shared_1.createQS({ types: limits }); | ||
return await this.get(`qw-limits/v1/persons/${wallet}/actual-limits?${query}`); | ||
@@ -135,3 +135,3 @@ } | ||
async getPaymentHistory(wallet, parameters) { | ||
const query = __1.createQS(parameters); | ||
const query = shared_1.createQS(parameters); | ||
return await this.get(`payment-history/v2/persons/${wallet}/payments?${query}`); | ||
@@ -145,3 +145,3 @@ } | ||
async getPaymentHistoryTotal(wallet, parameters) { | ||
const query = __1.createQS(parameters); | ||
const query = shared_1.createQS(parameters); | ||
return await this.get(`payment-history/v2/persons/${wallet}/payments/total?${query}`); | ||
@@ -257,3 +257,3 @@ } | ||
data.blocked = options.blocked; | ||
const query = __1.createQS(data); | ||
const query = shared_1.createQS(data); | ||
return `https://qiwi.com/payment/form/${provider}?${query}`; | ||
@@ -260,0 +260,0 @@ } |
{ | ||
"name": "qiwi-sdk", | ||
"version": "1.6.5", | ||
"version": "1.6.6", | ||
"description": "Typed, Promise based, QIWI API (P2P & Personal) client", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
159880
27
2348