Socket
Socket
Sign inDemoInstall

pagarme

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pagarme - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

dist/base.d.ts

51

dist/pagarme.d.ts

@@ -0,1 +1,5 @@

import { LazyPlanCollection, LazyPlanObject } from "./plan.ts";
import { LazyCardCollection, LazyCardObject } from "./card.ts";
import { LazyTransactionCollection } from "./transaction.ts";
export declare const PAGE_SIZE: number;
export default class PagarMe {

@@ -5,5 +9,7 @@ api_key: string;

constructor(api_key: string, encryption_key: string);
cards: CardCollection;
card(id: string): Endpoint<Card>;
transactions: TransactionCollection;
cards: LazyCardCollection;
plans: LazyPlanCollection;
card(id: string): LazyCardObject;
plan(id: number): LazyPlanObject;
transactions: LazyTransactionCollection;
cardHash(card: CardData): Promise<string>;

@@ -17,40 +23,1 @@ }

}
export declare class CardCollection {
private pagarme;
constructor(pagarme: PagarMe);
insert(cardHash: string): Endpoint<Card>;
}
export interface Card {
id: string;
date_created: string;
date_updated: string;
brand: string;
holder_name: string;
first_digits: string;
last_digits: string;
country: string;
fingerprint: string;
customer?: Customer;
valid: boolean;
}
export interface Customer {
}
export declare class TransactionCollection {
private pagarme;
constructor(pagarme: PagarMe);
cardHashKey(): Endpoint<CardHashKey>;
}
export interface CardHashKey {
date_created: string;
id: number;
ip: string;
public_key: string;
}
export declare class Endpoint<T> {
private path;
private params;
private method;
constructor(path: string, params: any, method?: string);
private do();
then<U>(onFulfilled: (value: T) => U, onRejected?: (reason: any) => U): Promise<U>;
}

@@ -10,6 +10,9 @@ "use strict";

};
const rest_1 = require("rest");
const querystring_1 = require("querystring");
const crypto_1 = require("crypto");
const constants_1 = require("constants");
const plan_ts_1 = require("./plan.ts");
const card_ts_1 = require("./card.ts");
const transaction_ts_1 = require("./transaction.ts");
exports.PAGE_SIZE = 30;
class PagarMe {

@@ -21,9 +24,15 @@ constructor(api_key, encryption_key) {

get cards() {
return new CardCollection(this);
return new card_ts_1.LazyCardCollection(this);
}
get plans() {
return new plan_ts_1.LazyPlanCollection(this);
}
card(id) {
return new Endpoint(`cards/${id}`, { api_key: this.api_key });
return new card_ts_1.LazyCardObject(`cards/${id}`, { api_key: this.api_key });
}
plan(id) {
return new plan_ts_1.LazyPlanObject(`plans/${id}`, { api_key: this.api_key });
}
get transactions() {
return new TransactionCollection(this);
return new transaction_ts_1.LazyTransactionCollection(this);
}

@@ -41,59 +50,2 @@ cardHash(card) {

exports.default = PagarMe;
class CardCollection {
constructor(pagarme) {
this.pagarme = pagarme;
}
insert(cardHash) {
return new Endpoint(`cards`, { api_key: this.pagarme.api_key, card_hash: cardHash }, "POST");
}
}
exports.CardCollection = CardCollection;
class TransactionCollection {
constructor(pagarme) {
this.pagarme = pagarme;
}
cardHashKey() {
return new Endpoint(`transactions/card_hash_key`, { encryption_key: this.pagarme.encryption_key });
}
}
exports.TransactionCollection = TransactionCollection;
class Endpoint {
constructor(path, params, method = "GET") {
this.path = path;
this.params = params;
this.method = method;
}
do() {
return __awaiter(this, void 0, void 0, function* () {
const request = {
method: this.method,
path: `https://api.pagar.me/1/${this.path}`,
params: this.params
};
const result = JSON.parse((yield rest_1.default(request)).entity);
if (result.errors) {
const err = result.errors[0];
throw new Error(`PagarMe: ${err.type}: ${err.message}`);
}
return result;
});
}
then(onFulfilled, onRejected) {
return __awaiter(this, void 0, Promise, function* () {
try {
const result = yield this.do();
return yield onFulfilled(result);
}
catch (err) {
if (typeof onRejected === "function") {
return yield onRejected(err);
}
else {
throw err;
}
}
});
}
}
exports.Endpoint = Endpoint;
//# sourceMappingURL=pagarme.js.map
{
"name": "pagarme",
"version": "1.0.5",
"version": "1.0.6",
"description": "A simple nodejs wrapper for the Pagar.me API",

@@ -5,0 +5,0 @@ "main": "dist/pagarme.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc