Socket
Socket
Sign inDemoInstall

pin-api

Package Overview
Dependencies
68
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.3.0

2

dist/index.js

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

"use strict";var _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_request=require("request"),_request2=_interopRequireDefault(_request),_undefsafe=require("undefsafe"),_undefsafe2=_interopRequireDefault(_undefsafe);Object.defineProperty(exports,"__esModule",{value:!0});function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _objectWithoutProperties(a,b){var c={};for(var d in a)0<=b.indexOf(d)||Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var apiVersion="1",liveUrl="https://api.pin.net.au",testUrl="https://test-api.pin.net.au",MODE={POST:"post",GET:"get",PUT:"put",DELETE:"delete"},ENDPOINT={CUSTOMER:"customers",CHARGES:"charges",CARDS:"cards",SUBSCRIPTIONS:"subscriptions",PLANS:"plans"},DELETE=204,PinAPI=function a(b){var c=this;_classCallCheck(this,a),this.setApiUrl=function(a){c.apiUrl=a?liveUrl:testUrl},this.formatResponse=function(){},this.handleAuthentication=function(a){a.auth(c.key,"")},this.handleErrorResponse=function(a,b){console.log(a),b(a)},this.handleSuccessResponse=function(a,b,c){var d=b;(0,_undefsafe2.default)(b,"response")&&(0,_undefsafe2.default)(b,"pagination")===void 0&&(d=b.response),a.statusCode===DELETE&&(d={success:!0}),c(d)},this.makeRequest=function(a){var b=a.token,d=a.body,e=a.endpoint,f=a.mode,g=a.debug,h=c.apiUrl+"/"+apiVersion+"/"+e.primary;return(0,_undefsafe2.default)(b,"primary")&&(h+="/"+b.primary),(0,_undefsafe2.default)(e,"secondary")&&(h+="/"+e.secondary),(0,_undefsafe2.default)(b,"secondary")&&(h+="/"+b.secondary),new Promise(function(a,b){var e=_request2.default[f]({url:h,json:!0,body:d},function(d,e,f){d?c.handleErrorResponse(d,b):g?a({url:h,body:f}):c.handleSuccessResponse(e,f,a)});c.handleAuthentication(e)})},this.createCustomer=function(a){return c.makeRequest({body:a,endpoint:{primary:ENDPOINT.CUSTOMER},mode:MODE.POST})},this.fetchAllCustomers=function(a){return c.makeRequest({body:a,endpoint:{primary:ENDPOINT.CUSTOMER},mode:MODE.GET})},this.fetchCustomer=function(a){return c.makeRequest({token:{primary:a},endpoint:{primary:ENDPOINT.CUSTOMER},mode:MODE.GET})},this.updateCustomer=function(a,b){return c.makeRequest({token:{primary:a},body:b,endpoint:{primary:ENDPOINT.CUSTOMER},mode:MODE.PUT})},this.deleteCustomer=function(a){return c.makeRequest({token:{primary:a},endpoint:{primary:ENDPOINT.CUSTOMER},mode:MODE.DELETE})},this.customerCharges=function(a){return c.makeRequest({token:{primary:a},endpoint:{primary:ENDPOINT.CUSTOMER,secondary:ENDPOINT.CHARGES},mode:MODE.GET})},this.customerCards=function(a){return c.makeRequest({token:{primary:a},endpoint:{primary:ENDPOINT.CUSTOMER,secondary:ENDPOINT.CARDS},mode:MODE.GET})},this.createCustomerCard=function(a,b){return c.makeRequest({body:a,token:{primary:b},endpoint:{primary:ENDPOINT.CUSTOMER,secondary:ENDPOINT.CARDS},mode:MODE.POST})},this.deleteCustomerCard=function(a,b){return c.makeRequest({token:{primary:a,secondary:b},endpoint:{primary:ENDPOINT.CUSTOMER,secondary:ENDPOINT.CARDS},mode:MODE.DELETE})},this.createCharge=function(a){return c.makeRequest({body:a,endpoint:{primary:ENDPOINT.CHARGES},mode:MODE.POST})},this.createCard=function(a){return c.makeRequest({body:a,endpoint:{primary:ENDPOINT.CARDS},mode:MODE.POST})},this.fetchAllPlans=function(a){return c.makeRequest({body:a,endpoint:{primary:ENDPOINT.PLANS},mode:MODE.GET})},this.createSubscription=function(a){var b=a.customerToken,d=a.planToken,e=_objectWithoutProperties(a,["customerToken","planToken"]);return c.makeRequest({body:_extends({customer_token:b,plan_token:d},e),endpoint:{primary:ENDPOINT.SUBSCRIPTIONS},mode:MODE.POST})},this.fetchSubscription=function(a){var b=a.token,d=_objectWithoutProperties(a,["token"]);return c.makeRequest({token:{primary:b},body:d,endpoint:{primary:ENDPOINT.SUBSCRIPTIONS},mode:MODE.GET})},this.key=b.key,this.live=b.live,this.setApiUrl()};exports.default=PinAPI;
"use strict";var _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_request=require("request"),_request2=_interopRequireDefault(_request),_undefsafe=require("undefsafe"),_undefsafe2=_interopRequireDefault(_undefsafe);Object.defineProperty(exports,"__esModule",{value:!0});function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _objectWithoutProperties(a,b){var c={};for(var d in a)0<=b.indexOf(d)||Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var apiVersion="1",liveUrl="https://api.pin.net.au",testUrl="https://test-api.pin.net.au",MODE={POST:"post",GET:"get",PUT:"put",DELETE:"delete"},ENDPOINT={CUSTOMER:"customers",CHARGES:"charges",CARDS:"cards",SUBSCRIPTIONS:"subscriptions",PLANS:"plans"},DELETE=204,PinAPI=function a(b){var c=this;_classCallCheck(this,a),this.setApiUrl=function(a){c.apiUrl=a?liveUrl:testUrl},this.formatResponse=function(){},this.handleAuthentication=function(a){a.auth(c.key,"")},this.handleErrorResponse=function(a,b){console.log(a),b(a)},this.handleSuccessResponse=function(a,b,c){var d=b;(0,_undefsafe2.default)(b,"response")&&(0,_undefsafe2.default)(b,"pagination")===void 0&&(d=b.response),a.statusCode===DELETE&&(d={success:!0}),c(d)},this.makeRequest=function(a){var b=a.token,d=a.body,e=a.endpoint,f=a.mode,g=a.debug,h=c.apiUrl+"/"+apiVersion+"/"+e.primary;return(0,_undefsafe2.default)(b,"primary")&&(h+="/"+b.primary),(0,_undefsafe2.default)(e,"secondary")&&(h+="/"+e.secondary),(0,_undefsafe2.default)(b,"secondary")&&(h+="/"+b.secondary),new Promise(function(a,b){var e=_request2.default[f]({url:h,json:!0,body:d},function(d,e,f){d?c.handleErrorResponse(d,b):g?a({url:h,body:f}):c.handleSuccessResponse(e,f,a)});c.handleAuthentication(e)})},this.createCustomer=function(a){return c.makeRequest({body:a,endpoint:{primary:ENDPOINT.CUSTOMER},mode:MODE.POST})},this.fetchAllCustomers=function(a){return c.makeRequest({body:a,endpoint:{primary:ENDPOINT.CUSTOMER},mode:MODE.GET})},this.fetchCustomer=function(a){return c.makeRequest({token:{primary:a},endpoint:{primary:ENDPOINT.CUSTOMER},mode:MODE.GET})},this.updateCustomer=function(a,b){return c.makeRequest({token:{primary:a},body:b,endpoint:{primary:ENDPOINT.CUSTOMER},mode:MODE.PUT})},this.deleteCustomer=function(a){return c.makeRequest({token:{primary:a},endpoint:{primary:ENDPOINT.CUSTOMER},mode:MODE.DELETE})},this.customerCharges=function(a){return c.makeRequest({token:{primary:a},endpoint:{primary:ENDPOINT.CUSTOMER,secondary:ENDPOINT.CHARGES},mode:MODE.GET})},this.customerCards=function(a){return c.makeRequest({token:{primary:a},endpoint:{primary:ENDPOINT.CUSTOMER,secondary:ENDPOINT.CARDS},mode:MODE.GET})},this.createCustomerCard=function(a,b){return c.makeRequest({body:a,token:{primary:b},endpoint:{primary:ENDPOINT.CUSTOMER,secondary:ENDPOINT.CARDS},mode:MODE.POST})},this.deleteCustomerCard=function(a,b){return c.makeRequest({token:{primary:a,secondary:b},endpoint:{primary:ENDPOINT.CUSTOMER,secondary:ENDPOINT.CARDS},mode:MODE.DELETE})},this.createCharge=function(a){return c.makeRequest({body:a,endpoint:{primary:ENDPOINT.CHARGES},mode:MODE.POST})},this.createCard=function(a){return c.makeRequest({body:a,endpoint:{primary:ENDPOINT.CARDS},mode:MODE.POST})},this.fetchAllPlans=function(a){return c.makeRequest({body:a,endpoint:{primary:ENDPOINT.PLANS},mode:MODE.GET})},this.fetchPlan=function(a){var b=a.token;return c.makeRequest({token:{primary:b},endpoint:{primary:ENDPOINT.PLANS},mode:MODE.GET})},this.createSubscription=function(a){var b=a.customerToken,d=a.planToken,e=_objectWithoutProperties(a,["customerToken","planToken"]);return c.makeRequest({body:_extends({customer_token:b,plan_token:d},e),endpoint:{primary:ENDPOINT.SUBSCRIPTIONS},mode:MODE.POST})},this.fetchSubscription=function(a){var b=a.token;return c.makeRequest({token:{primary:b},endpoint:{primary:ENDPOINT.SUBSCRIPTIONS},mode:MODE.GET})},this.key=b.key,this.live=b.live,this.setApiUrl()};exports.default=PinAPI;

@@ -241,2 +241,15 @@ import request from "request";

fetchPlan = body => {
const { token } = body;
return this.makeRequest({
token: {
primary: token
},
endpoint: {
primary: ENDPOINT.PLANS
},
mode: MODE.GET
});
};
createSubscription = body => {

@@ -258,3 +271,3 @@ const { customerToken, planToken, ...rest } = body;

fetchSubscription = body => {
const { token, ...rest } = body;
const { token } = body;
return this.makeRequest({

@@ -264,3 +277,2 @@ token: {

},
body: rest,
endpoint: {

@@ -267,0 +279,0 @@ primary: ENDPOINT.SUBSCRIPTIONS

{
"name": "pin-api",
"version": "1.2.0",
"version": "1.3.0",
"description": "Pin Payments API wrapper",

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc