0.0.15 • Published 7 years ago
spendesk-collect v0.0.15
Spendesk Collect Node
Installation
yarn add spendesk-collectSpendesk Collect Collector
const collector = new SpendeskCollect.Collector(PORT);
collector.startApp();The collector module launches automatically an server instance and exposes what's necessary to develop a collector.
authaction: returns if ship settings are valids or notcollectaction: called to extract invoices from a supplierdescription: redirects to./DESCRIPTION.md, collector descriptionmanifest: redirects to./manifest.jsonassets/*: redirects to./assetsthat contains the list of assets needed like logo (logo.png).
context is inialized for status and collect actions.
module.exports = async (ship, client, captchaSolver) => {
// client is SpendeskCollect.Client instance
// ship is an object that contains information { settings, nextCollectAt, currentSettingsStepTag }
// captchaSolver is a instance of a captcha solver (see below for more information)
}Spendesk Collect Client
const client = new SpendeskCollect.Client("SHIP_TOKEN");This Client API allows to connect with the Spendesk Collect infrastructure. Here the list of methods available:
done(status, metadata): returns to broker the status of the shipstatusis an object:{ label: ok|error, type: auth|collect }metadatais an optional object:{ currentSettingsStepTag }
invoices.create(file, metadata, fileOptions): uploads a new invoicefileneeds a path or a buffermetadatais an object that contains invoice metadata. Requested attributes:identifier,dueAt,amount,currencyfileOptionsis optional iffileis a path otherwise it needs to follow this pattern:{ contentType, filename }
logger: winston logger (error,warn,info,verbose,debug,silly)
Spendesk Collect Captcha Solver
const captchaSolver = new SpendeskCollect.CaptchaSolver("CAPTCHA_SOLVER_TOKEN");List of methods availables:
solveReCaptcha(googlekey, pageurl, proxy, proxytype): method to solve google recaptchagooglekeycorresponds to the captcha key. You can find it in the src of the iframe https://www.google.com/recaptcha/api2/anchor?ar=1&k=GOOGLE_KEY&co=XXX&hl=en&v=VVV&size=normal&cb=YYYpageurlcorresponds to the website url where the captcha is- (optional)
proxyallows you to add a proxy url if wanted - (optional)
proxytype