dollar-quotation
Seja avisado quando a cotação do dólar para sua moeda local estiver abaixo de determinado valor
Last updated 4 years ago by haskellcamargo .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dollar-quotation 
SYNC missed versions from official npm registry.

Rung ─ Dollar quotation extension

This is a demo extension to Rung showing how to be alerted when dollar in a specific currency be lower or equal to a specified value.

Full source

const { create, run } = require('rung-sdk');
const { OneOf, Money } = require('rung-sdk/dist/types');
const Bluebird = require('bluebird');
const agent = require('superagent');
const promisifyAgent = require('superagent-promise');
const { path } = require('ramda');

const request = promisifyAgent(agent, Bluebird);

function main(context, done) {
    const { currency, value } = context.params;

    return request.get('http://api.fixer.io/latest?base=USD')
        .then(path(['body', 'rates', currency]))
        .then(dollar => dollar <= value
            ? `Dollar is lower or equal to ${value}`
            : null)
        .then(done)
        .catch(() => done());
}

const params = {
    currency: {
        description: 'Currency to check dollar quotation',
        type: OneOf(['BRL', 'EUR']),
        default: 'BRL'
    },
    value: {
        description: 'When lower or equal to this, we\'ll tell you',
        type: Money,
        default: 3.0
    }
};

const app = create(main, { params });
app.run();

module.exports = app;

When you clone this repo and install the packages, you can do node index.js to start the Query Wizard via CLI. We integrate with a third-party API called fixer.io.

You'll get this screen and the result:

If you get a valid value as output, an alert would be generated. Otherwise, nothing would happen.

Current Tags

  • 1.0.0                                ...           latest (4 years ago)

1 Versions

  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 3
Dependencies (5)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |