Class: SmartInvoice

SmartInvoice(instanceConfig, userIdentity) → {object}

Main SmartInvoice class representing interface to Smart Invoice API endpoint. See below example how to use it:

   // ES6 project
   import SmartInvoice from 'smartinvoice-sdk';

   // or below
   var SmartInvoice = require("smartinvoice-sdk").default

   var identity = SmartInvoice.createIdentity();
   var host = "https://api.difacturo.com"
   var invitationCode = "getitfromus"
   var config = { host: host, invitationCode: invitationCode}
   var smartinvoice = new SmartInvoice(config, identity);

Constructor

new SmartInvoice(instanceConfig, userIdentity) → {object}

Parameters:
Name Type Description
instanceConfig Object Json object with configuration for new instance
userIdentity Identity Sovrin identity object generate with createIdentity()
License:
  • MIT
Source:
Returns:
SmartInvoice - The top level SmartInvoice object
Type
object

Members

host

Set/Get host for SmartInvoice API Host is used only for calls which does not required JWT For authenticated calls the host is taken by interceptor from JWT
Source:

jwt

Set/Get Json Web Token which is used to authenticate against endpoint from host variable
Source:

Methods

(static) createIdentity() → {Object}

Generate new DID base identity It include public and private key. Currently supported only Sovrin but in the feature this would be extended to other DID Methods. Currently supported confguration: { host, // host of the api endpoint to which you want to connect invitationCode //invitation code required to connect to pilot network }
Source:
Returns:
object including public and private key for the identity.
Type
Object

(async) decryptTransactionPayload(senderDID, encryptedPayload) → {Object}

Decrypt payload from transaction
Parameters:
Name Type Description
senderDID String Sender DID
encryptedPayload String encrypted payload from transaction
Source:
Returns:
decrypted payload
Type
Object

fetchDocuments(startTimestamp, endTimestamp)

Allow to fetch document for the user within given time frame.
Parameters:
Name Type Description
startTimestamp Timestamp Miliseconds since 1900, from when we should get documents
endTimestamp Timestamp Miliseconds since 1900, until when we should look for documents
Source:

(async) forwardDocument(receiverDID, dri, payload)

Forward existing document on the network to given receiver
Parameters:
Name Type Description
receiverDID String Decentralize identifier of the receiver
dri String Decentralize Resource Identifier of the forwarding file
payload Object Additional information which should be attached to the document
Source:

(async) login() → {Promise}

Login user and get JWT token for next calls
Source:
Returns:
axios promise and if success Json Web Token (JWT)
Type
Promise

(async) sendTo(receiverDID, file, payload)

Send document via SmartInvoice platform to the receiver
Parameters:
Name Type Description
receiverDID String Decentralize identifier of the receiver
file File Document which should be sent
payload Object Additional information which should be attached to the document
Source: