Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ubivar

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ubivar - npm Package Compare versions

Comparing version 0.1.3-beta16 to 0.1.3-beta17

25

lib/index.js

@@ -5,10 +5,23 @@ /* Ubivar API client factory

*/
module.exports = function(token, version){
module.exports = function(token, version, resources){
var _ = require("lodash")
, Ubivar = require("./Ubivar")
, Resource = require("./Resource")
, ubivar = new Ubivar(token, version)
_.each(ubivar.get("resources"), function(resourceName){
ubivar[resourceName] = new Resource(ubivar, resourceName)
var Ubivar = require("./Ubivar")
resources = resources || [
"accounts"
, "transactions"
, "routing"
, "orders"
, "login"
, "logout"
, "items"
, "labels"
, "me"
]
var ubivar = new Ubivar(token, version, resources)
_.each(resources, function(resource){
ubivar.extend(resource)
})

@@ -15,0 +28,0 @@

var path = require("path")
, fs = require("fs")
, _ = require("lodash")
, RESOURCES = [
"accounts"
, "transactions"
, "routing"
, "orders"
, "login"
, "logout"
, "items"
, "labels"
, "uptime"
, "ci"
, "geoip"
, "fx"
, "bins"
, "me"
]
, Resource = require("../Resource")

@@ -26,3 +11,3 @@ /*

*/
function Ubivar(token, version){
function Ubivar(token, version, resources){
var http = require("http")

@@ -40,3 +25,3 @@ , pathPackage = "../../package.json"

, "timeout" : theTimeout
, "resources" : RESOURCES
, "resources" : resources
, "revokedCerts" : theRevokedCerts

@@ -76,4 +61,12 @@ , "headers" : {

/*
* Extend function to add resources to 'this' running instance
* @resource [String] name of the resource to add
*/
Ubivar.prototype.extend = function(resource){
this[resource] = new Resource(this, resource)
}
/*
* Export the wrapper factory of Ubivar
*/
module.exports = Ubivar
{
"name": "ubivar",
"version": "0.1.3-beta16",
"version": "0.1.3-beta17",
"description": "API wrapper to Ubivar",

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

@@ -8,3 +8,3 @@ # Ubivar node.js bindings

Ubivar routes e-commerce transactions given their risk. By default the three
routing outcomes are rejection, manual verification and acceptance. And the two
`routing` outcomes are rejection, manual verification and acceptance. And the two
elementary resources are the `transactions` and the `labels`. `Transactions`

@@ -16,3 +16,3 @@ are online sales pushed to your payment gateway and `labels` define the *a

hooks to send and receive resources to the API. For each `transaction` that
Ubivar receives, it calculates a routing. Later, as you review manually some of
Ubivar receives, it calculates a `routing`. Later, as you review manually some of
the `transactions` or as you receive fraud notifications, you `label`

@@ -23,12 +23,14 @@ those `transactions` as `fraud`.

### A. Install and initialize
Install the nodejs binding of `ubivar` from npm.
`npm install ubivar`
Initialize the binding with your API access token:
```js
var Ubivar = require("ubivar")
, ubivar = new Ubivar("YOUR_API_ACCESS_TOKEN", "latest")
, ubivar = new Ubivar("YOUR_API_ACCESS_TOKEN")
```
### B. Send transactions
### A. Send transactions
```js

@@ -38,2 +40,5 @@ ubivar.transactions.create({

, "user_email" : "test_phahr3Eit3@gmail-123.com" // your client email
, "gender" : "M" // your client's gender
, "first_name" : "John" // your client's first name
, "last_name" : "Doe" // your client's last name
, "type" : "sale" // the transaction type

@@ -43,18 +48,20 @@ , "status" : "success" // the transaction status

, "tx_id" : "client_tx_id_123" // the transaction id
, "tx_timestamp": "2015-04-13 13:36:41" // the timestamp of this transaction
, "amount" : "43210" // the amount in cents
, "payment_method":{
"bin" :"123456" // the BIN of the card
, "brand" :"Mastercard" // the brand of the card
, "funding" :"credit" // the type of card
, "country" :"US" // the card country code
, "name" :"M Man" // the card holder's name
, "cvc_check" :"pass" // the cvc check result
"bin" : "123456" // the BIN of the card
, "brand" : "Mastercard" // the brand of the card
, "funding" : "credit" // the type of card
, "country" : "US" // the card country code
, "name" : "M John Doe" // the card holder's name
, "cvc_check" : "pass" // the cvc check result
},"billing_address":{
"line1" :"123 Market Street" // the billing address
, "line2" :"4th Floor"
, "city" :"San Francisco"
, "state" :"California"
, "zip" :"94102"
, "country" :"US"
}
"line1" : "123 Market Street" // the billing address
, "line2" : "4th Floor"
, "city" : "San Francisco"
, "state" : "California"
, "zip" : "94102"
, "country" : "US"
},"ip_address" : "1.2.3.4" // your client ip address
, "user_agent" : "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" // your client's user agent
}, function(err, res){

@@ -70,5 +77,6 @@

### C. Retrieve routing and label
### B. Retrieve routing
```js
ubivar.labels.retrieve(txId, function(err, res){
ubivar.routing.retrieve(txId, function(err, res){

@@ -79,6 +87,19 @@ if(err) return err

status = res.data[0].status
// the status of the transaction
// the routing, e.g. {pending, green, orange, red}
})
```
### C. Label as fraud
```js
ubivar.labels.retrieve(txId, {"status": "is_fraud"}, function(err, res){
if(err) return err
// something unexpected occurred
status = res.data[0].status
// the label of the transaction
})
```
## Resources, actions, and arguments

@@ -88,19 +109,14 @@ Every resource is accessed via your `ubivar` instance and accepts an optional

(rows), the actions (columns) and the arguments (cells). The full documentation
is available at
[https://ubivar.com/docs/nodejs](https://ubivar.com/docs/nodejs).
is available at [https://ubivar.com/docs/nodejs](https://ubivar.com/docs/nodejs).
| Resource | C | R | U | D | List | Summary | Test | Status |
| ------------- |:-:|:-:|:-:|:-:|:----:|:-------:|:----:|:------:|
| Me | |<a href="https://ubivar.com/docs/nodejs#retrieve_your_information">_</a> |<a href="https://ubivar.com/docs/nodejs#retrieve_your_information">`{}`</a>| | | | [spec](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Me/spec.js)| ![](https://status.ubivar.com/ubivar-node/resources/me.svg) |
| Accounts |<a href="https://ubivar.com/docs/nodejs#create_an_account">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_an_account">id</a> |<a href="https://ubivar.com/docs/nodejs#update_an_account">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#delete_an_account">id</a>|<a href="https://ubivar.com/docs/nodejs#list_accounts">`{}`</a>| | [spec](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Accounts/spec.js)| ![](https://status.ubivar.com/ubivar-node/resources/accounts.svg)|
| Transactions |<a href="https://ubivar.com/docs/nodejs#create_a_transaction">`{}`</a>| <a href="https://ubivar.com/docs/nodejs#retrieve_a_transaction">id</a> |<a href="https://ubivar.com/docs/nodejs#update_a_transaction">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#delete_a_transaction">id</a>|<a href="https://ubivar.com/docs/nodejs#list_transactions">`{}`</a>| | [spec](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Transactions/spec.js)| ![](https://status.ubivar.com/ubivar-node/resources/transactions.svg)|
| Login |<a href="https://ubivar.com/docs/nodejs#create_login_event">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_login_event">id</a> | |<a href="https://ubivar.com/docs/nodejs#delete_login_event">id</a>|<a href="https://ubivar.com/docs/nodejs#list_login_events">`{}`</a>| | [spec](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Login/spec.js)| ![](https://status.ubivar.com/ubivar-node/resources/login.svg)|
| Logout |<a href="https://ubivar.com/docs/nodejs#create_logout_event">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_logout_event">id</a> | |<a href="https://ubivar.com/docs/nodejs#delete_logout_event">id</a>|<a href="https://ubivar.com/docs/nodejs#list_logout_events">`{}`</a>| | [spec](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Logout/spec.js)| ![](https://status.ubivar.com/ubivar-node/resources/logout.svg)|
| Items |<a href="https://ubivar.com/docs/nodejs#create_item">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_item">id</a> |<a href="https://ubivar.com/docs/nodejs#update_item">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#delete_item">id</a>|<a href="https://ubivar.com/docs/nodejs#list_items">`{}`</a>| | [spec](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Items/spec.js)| ![](https://status.ubivar.com/ubivar-node/resources/items.svg)|
| Labels |<a href="https://ubivar.com/docs/nodejs#create_label">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_label">id</a> |<a href="https://ubivar.com/docs/nodejs#update_label">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#delete_label">id</a>|<a href="https://ubivar.com/docs/nodejs#list_labels">`{}`</a>| | [spec](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Labels/spec.js)| ![](https://status.ubivar.com/ubivar-node/resources/labels.svg)|
| Fx | | | | |<a href="https://ubivar.com/docs/nodejs#list_fx">`{}`</a>| | [spec](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Fx/spec.js)| ![](https://status.ubivar.com/ubivar-node/resources/fx.svg)|
| Bins | | | | |<a href="https://ubivar.com/docs/nodejs#list_bin">`{}`</a>| | [spec](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Bins/spec.js)| ![](https://status.ubivar.com/ubivar-node/resources/bins.svg)|
| Uptime | | | | |<a href="https://ubivar.com/docs/nodejs#list_uptime">`{}`</a>| <a href="https://ubivar.com/docs/nodejs#summary_uptime">`{}`</a>|[spec](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Uptime/spec.js)| ![](https://status.ubivar.com/ubivar-node/resources/uptime.svg)|
| CI | | | | |<a href="https://ubivar.com/docs/nodejs#list_ci">`{}`</a>| <a href="https://ubivar.com/docs/nodejs#summary_ci">`{}`</a>|[spec](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Ci/spec.js)| ![](https://status.ubivar.com/ubivar-node/resources/ci.svg)|
| Geoip | | | | |<a href="https://ubivar.com/docs/nodejs#list_geoip">`{}`</a>| |[spec](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Geoip/spec.js)| ![](https://status.ubivar.com/ubivar-node/resources/geoip.svg)|
| Resource | C | R | U | D | L | Summary | Test Specs |
| ------------- |:-:|:-:|:-:|:-:|:----:|:-------:|:----------:|
| Accounts |<a href="https://ubivar.com/docs/nodejs#create_an_account">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_an_account">id</a> |<a href="https://ubivar.com/docs/nodejs#update_an_account">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#delete_an_account">id</a>|<a href="https://ubivar.com/docs/nodejs#list_accounts">`{}`</a>| | [![](https://status.ubivar.com/ubivar-node/resources/accounts.svg)](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Accounts/spec.js)|
| Items |<a href="https://ubivar.com/docs/nodejs#create_item">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_item">id</a> |<a href="https://ubivar.com/docs/nodejs#update_item">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#delete_item">id</a>|<a href="https://ubivar.com/docs/nodejs#list_items">`{}`</a>| | [![](https://status.ubivar.com/ubivar-node/resources/items.svg)](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Items/spec.js)|
| Labels |<a href="https://ubivar.com/docs/nodejs#create_label">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_label">id</a> |<a href="https://ubivar.com/docs/nodejs#update_label">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#delete_label">id</a>|<a href="https://ubivar.com/docs/nodejs#list_labels">`{}`</a>| | [![](https://status.ubivar.com/ubivar-node/resources/labels.svg)](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Labels/spec.js) |
| Login |<a href="https://ubivar.com/docs/nodejs#create_login_event">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_login_event">id</a> | |<a href="https://ubivar.com/docs/nodejs#delete_login_event">id</a>|<a href="https://ubivar.com/docs/nodejs#list_login_events">`{}`</a>| | [![](https://status.ubivar.com/ubivar-node/resources/login.svg)](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Login/spec.js)|
| Logout |<a href="https://ubivar.com/docs/nodejs#create_logout_event">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_logout_event">id</a> | |<a href="https://ubivar.com/docs/nodejs#delete_logout_event">id</a>|<a href="https://ubivar.com/docs/nodejs#list_logout_events">`{}`</a>| | [![](https://status.ubivar.com/ubivar-node/resources/logout.svg)](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Logout/spec.js)|
| Me | |<a href="https://ubivar.com/docs/nodejs#retrieve_your_information">_</a> |<a href="https://ubivar.com/docs/nodejs#retrieve_your_information">`{}`</a>| | | | [![](https://status.ubivar.com/ubivar-node/resources/me.svg)](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Me/spec.js) |
| Routing | | <a href="https://ubivar.com/docs/nodejs#retrieve_a_routing">id</a> |<a href="https://ubivar.com/docs/nodejs#update_a_routing">`{}`</a>| |<a href="https://ubivar.com/docs/nodejs#list_routing">`{}`</a>| | [![](https://status.ubivar.com/ubivar-node/resources/routing.svg)](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Routing/spec.js)|
| Transactions |<a href="https://ubivar.com/docs/nodejs#create_a_transaction">`{}`</a>| <a href="https://ubivar.com/docs/nodejs#retrieve_a_transaction">id</a> |<a href="https://ubivar.com/docs/nodejs#update_a_transaction">`{}`</a>|<a href="https://ubivar.com/docs/nodejs#delete_a_transaction">id</a>|<a href="https://ubivar.com/docs/nodejs#list_transactions">`{}`</a>| | [![](https://status.ubivar.com/ubivar-node/resources/transactions.svg)](https://github.com/ubivar/ubivar-node/blob/master/test/Resources/Transactions/spec.js)|

@@ -111,2 +127,3 @@ + *C*: Create

+ *D*: Delete
+ *L*: List
+ `{}`: JSON with query parameters

@@ -128,9 +145,22 @@

+ `ubivar.set("auth", "your-api-token")`
+ `ubivar.set("timeout", 20000) // in ms`, node's default is `120000ms`
## Issues and feature requests
Extend `this` `ubivar` instance with a new resource whose accessibility is
controlled by access rights.
```js
var Ubivar = require("ubivar")
, ubivar = new Ubivar("YOUR_API_ACCESS_TOKEN")
+ [Report issues and feature requests](https://github.com/ubivar/ubivar-node/issues)
ubivar.extend("geoip") // extend with
```
Change API access token dynamically:
```js
ubivar.set("auth", "your-api-token")
```
Define timeout of the binding:
```js
ubivar.set("timeout", 20000) // in ms`, node's default is `120000ms`
```
## Development

@@ -147,4 +177,6 @@

### [Issues and feature requests](https://github.com/ubivar/ubivar-node/issues)
## Author
Originally inspired from [stripe-node](https://github.com/stripe/stripe-node). Developed by [Fabrice Colas](https://fabricecolas.me) ([fabrice.colas@gmail.com](mailto:fabrice.colas@gmail.com)). Maintained by Ubivar.
Originally inspired from [stripe-node](https://github.com/stripe/stripe-node). Developed and maintained by [Fabrice Colas](https://fabricecolas.me) ([fabrice.colas@gmail.com](mailto:fabrice.colas@gmail.com)) for [Ubivar](https://ubivar.com).

@@ -32,14 +32,21 @@ "use strict"

it("Should return routing greater than (gt) a given timestamp", function(done){
ubivar.routing.list({
"insert_timestamp":{"gte":"2015-04-19 19:28:45.263772"
, "lte":"2015-04-19 19:28:45.374523"}
}, function(err, res){
ubivar.transactions.list({"limit":2, "order":"id"}, function(err, res){
if(err){
console.log(err, res)
return done(err)
} else if(res.data.length !== 2){
return done(new Error("Did not return the right number of results" ))
}
}
done()
var tx_id_min = res.data[0].id
, tx_id_max = res.data[1].id
ubivar.routing.list({"id":{"gte":tx_id_min, "lte":tx_id_max}}, function(err, res){
if(err){
console.log(err, res)
return done(err)
} else if(res.data.length !== 2){
return done(new Error("Did not return the right number of results" ))
}
done()
})
})

@@ -46,0 +53,0 @@ })

Sorry, the diff of this file is not supported yet

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