paypal-rest-api
Advanced tools
Comparing version 0.0.45 to 0.0.46
@@ -56,4 +56,7 @@ "use strict"; | ||
if (!this.model.id) { | ||
throw new Error("Model does not have an id. Call create first"); | ||
throw new Error("Model id is invalid"); | ||
} | ||
if (this.model.status !== "DRAFT") { | ||
throw new Error("Invalid Status"); | ||
} | ||
const response = yield this.api.send(this.model.id, options); | ||
@@ -67,4 +70,8 @@ yield this.get(); | ||
if (!this.model.id) { | ||
throw new Error("Model does not have an id. Call create first"); | ||
throw new Error("Model id is invalid"); | ||
} | ||
const validStatuses = ["SENT"]; | ||
if (validStatuses.indexOf(this.model.status) === -1) { | ||
throw new Error("Invalid Status"); | ||
} | ||
const response = yield this.api.remind(this.model.id, options); | ||
@@ -77,4 +84,8 @@ return this; | ||
if (!this.model.id) { | ||
throw new Error("Model does not have an id. Call create first"); | ||
throw new Error("Model id is invalid"); | ||
} | ||
const validStatuses = ["SENT"]; | ||
if (validStatuses.indexOf(this.model.status) === -1) { | ||
throw new Error("Invalid Status"); | ||
} | ||
const response = yield this.api.cancel(this.model.id, options); | ||
@@ -87,2 +98,6 @@ return this; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const validStatuses = ["DRAFT", "UNPAID", "SENT"]; | ||
if (validStatuses.indexOf(this.model.status) === -1) { | ||
throw new Error("Invalid Status"); | ||
} | ||
return _super("update").call(this, this.model, options); | ||
@@ -94,4 +109,7 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.model.id) { | ||
throw new Error("Model id is invalid"); | ||
} | ||
if (this.model.status !== "DRAFT") { | ||
throw new Error(`Only draft invoices can be deleted`); | ||
throw new Error(`Invalid status`); | ||
} | ||
@@ -104,4 +122,8 @@ return _super("delete").call(this, options); | ||
if (!this.model.id) { | ||
throw new Error("Model does not have an id. Call create first"); | ||
throw new Error("Model id is invalid"); | ||
} | ||
const validStatuses = ["UNPAID", "SENT"]; | ||
if (validStatuses.indexOf(this.model.status) === -1) { | ||
throw new Error("Invalid Status"); | ||
} | ||
options.body = payment; | ||
@@ -115,4 +137,8 @@ const response = yield this.api.recordPayment(this.model.id, options); | ||
if (!this.model.id) { | ||
throw new Error("Model does not have an id. Call create first"); | ||
throw new Error("Model id is invalid"); | ||
} | ||
const validStatuses = ["UNPAID", "SENT"]; | ||
if (validStatuses.indexOf(this.model.status) === -1) { | ||
throw new Error("Invalid Status"); | ||
} | ||
options.body = refund; | ||
@@ -126,3 +152,3 @@ const response = yield this.api.recordRefund(this.model.id, options); | ||
if (!this.model.id) { | ||
throw new Error("Model does not have an id. Call create first"); | ||
throw new Error("Model id is invalid"); | ||
} | ||
@@ -129,0 +155,0 @@ options.qs = opts; |
{ | ||
"name": "paypal-rest-api", | ||
"version": "0.0.45", | ||
"version": "0.0.46", | ||
"description": "A typescript module for integrating with PayPal REST APIs.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
137141
2861