Giter Club home page Giter Club logo

cambio's Introduction

This package has been DEPRECATED in favor of the trm-api package which uses the official Tasa Representativa del Mercado API instead of the SOAP web service.

Cambio 💵

install size npm version Build Status codecov Greenkeeper badge

Consulta la Tasa Representativa del Mercado en el servicio web de la Superintendencia Financiera de Colombia.

📦 Sin dependencias

📦 Extra liviano

Cambio

Instalación

npm install @trmapi/cambio

Uso

Requerir la función cambio:

const cambio = require('@trmapi/cambio')

La función cambio recibe los argumentos date y options, y devuelve una promesa.

Argumentos

Argumento Descripción
[date] String - fecha que se desea consultar en formato YYYY-MM-DD. Si se omite, se devolverá la información de la TRM para la fecha actual.
[options] Objeto - opciones que se desean para la respuesta.

Opciones

Opción Descripción
mode String - El tipo de respuesta que se desea. Puede ser slim mostrando una respuesta resumida; full mostrando la respuesta completa; raw mostrando el xml original. Por defecto el valor que se usa es slim.
status Boolean - Si se muestra o no el código del estado de la respuesta. Por defecto es true.

Respuesta

En caso de que el código del estado de la respuesta del servicio web de la SFC sea 200 OK y se usen las opciones por defecto, se devuelve una promesa que resuelve con un objecto como el siguiente:

{
  status: 200,
  trm: {
    validityFrom: "2013-01-01T00:00:00-05:00",
    validityTo: "2013-01-02T00:00:00-05:00",
    value: 1768.23,
    message: "No se ha encontrado el valor para la TCRM en la fecha dada: Fri Oct 10 00:00:00 COT 2008. Se retorna el valor de la fecha superior mas cercana",
  }
}

El campo message no está disponible en todas las respuestas y sólo se mostrará en aquellas en donde sea proporcionado por el servicio web de la SFC.

Si se usa la opcion mode: full se obtienen todos los campos de la respuesta:

{
  status: 200,
  trm: {
    id: 1701,
    unit: "COP",
    validityFrom: "2013-01-01T00:00:00-05:00",
    validityTo: "2013-01-02T00:00:00-05:00",
    value: 1768.23,
    message: "No se ha encontrado el valor para la TCRM en la fecha dada: Fri Oct 10 00:00:00 COT 2008. Se retorna el valor de la fecha superior mas cercana",
    success: true
  }
}

Si se usa la opcion mode: raw se obtiene el xml original de la respuesta:

{
  status: 200,
  trm: '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:queryTCRMResponse xmlns:ns2="http://action.trm.services.generic.action.superfinanciera.nexura.sc.com.co/"><return><id>1701</id><unit>COP</unit><validityFrom>2013-01-01T00:00:00-05:00</validityFrom><validityTo>2013-01-02T00:00:00-05:00</validityTo><value>1768.23</value><message>No se ha encontrado el valor para la TCRM en la fecha dada: Tue Jan 01 00:00:00 COT 2008. Se retorna el valor de la fecha superior mas cercana</message><success>true</success></return></ns2:queryTCRMResponse></soap:Body></soap:Envelope>'
}

En caso de que se encuentre otro código de respuesta por parte del servicio web la respuesta será como la siguiente:

{
  status: 500,
  trm: {
    faultcode: "soap:Client",
    faultstring: "Unmarshalling Error: "
  }
}

En este caso, mode: slim y mode: full devolverán la misma información.

Ejemplos

Para obtener la información de la TRM para el 6 de enero de 2018:

cambio('2018-01-06')
  .then(data => console.log(data))
  .catch(err => console.log(err))
{
  status: 200,
  trm: {
    validityFrom: "2018-01-06T00:00:00-05:00",
    validityTo: "2018-01-09T00:00:00-05:00",
    value: 2898.32
  }
}

Si sólo se desea obtener la información de la TRM sin el código del estado de la respuesta:

cambio('2018-01-06', { status: false })
  .then(data => console.log(data))
  .catch(err => console.log(err))
{
  validityFrom: "2018-01-06T00:00:00-05:00",
  validityTo: "2018-01-09T00:00:00-05:00",
  value: 2898.32
}

Si sólo se desea obtener el xml devuelto por el servicio web se pueden combinar las opciones status: false y mode: raw:

cambio("2018-01-06", { mode: "raw", status: false })
  .then(data => console.log(data))
  .catch(err => console.log(err))
);
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:queryTCRMResponse xmlns:ns2="http://action.trm.services.generic.action.superfinanciera.nexura.sc.com.co/"><return><id>620351</id><unit>COP</unit><validityFrom>2018-01-06T00:00:00-05:00</validityFrom><validityTo>2018-01-09T00:00:00-05:00</validityTo><value>2898.32</value><success>true</success></return></ns2:queryTCRMResponse></soap:Body></soap:Envelope>

Para obtener la información de la TRM que aplica para la fecha actual:

cambio()
  .then(data => console.log(data))
  .catch(err => console.log(err))
{
  status: 200,
  trm: {
    validityFrom: "2018-11-16T00:00:00-05:00",
    validityTo: "2018-11-16T00:00:00-05:00",
    value: 3198.29
  }
}

El argumento fecha de la función no es verificado sino que es pasado directamente como argumento en la solicitud SOAP que se hace al servicio web de la SFC, esto quiere decir que se puede pasar un argumento inválido y la función devolverá la respuesta del servicio web a dicho argumento:

cambio('31-10-2018')
  .then(data => console.log(data))
  .catch(err => console.log(err))
{
  status: 500,
  trm: {
    faultcode: "soap:Client",
    faultstring: "Unmarshalling Error: 31-10-2018"
  }
}

Así mismo, se puede pasar una fecha mayor a la actual en cuyo caso se devolverá la información de la trm para la fecha más reciente disponible:

cambio('9999-10-10')
  .then(data => console.log(data))
  .catch(err => console.log(err))
{
  status: 200,
  trm: {
    validityFrom: "2018-11-16T00:00:00-05:00",
    validityTo: "2018-11-16T00:00:00-05:00",
    value: 3198.29
  }
}

El servicio web de la SFC proporciona información de la TRM a partir de 2013-01-01, por lo que si se solicita una fecha menor a esta fecha se devolverá el valor correspondiente a dicha fecha:

cambio('1978-10-10')
  .then(data => console.log(data))
  .catch(err => console.log(err))
{
  status: 200,
  trm: {
    validityFrom: "2013-01-01T00:00:00-05:00",
    validityTo: "2013-01-02T00:00:00-05:00",
    value: 1768.23,
    message: "No se ha encontrado el valor para la TCRM en la fecha dada: Tue Oct 10 00:00:00 COT 1978. Se retorna el valor de la fecha superior mas cercana"
  }
}

Licencia

MIT

💗Bandera de Colombia

cambio's People

Contributors

dependabot[bot] avatar greenkeeper[bot] avatar mauriciorobayo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

fossabot

cambio's Issues

An in-range update of eslint-plugin-import is breaking the build 🚨

The devDependency eslint-plugin-import was updated from 2.18.0 to 2.18.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Commits

The new version differs by 14 commits.

  • b51aa2f Bump to v2.18.1
  • 32704da fix: Improve parse perf when using @typescript-eslint/parser
  • 3b21de6 [Tests] extract common "get parser" logic into test helpers
  • f4e3f1b prefer-default-export: don't warn on TypeAlias & TSTypeAliasDeclaration
  • 1caa402 [Fix] no-unused-modules: Exclude package "main"/"bin"/"browser" entry points
  • 22d5440 [fix] export: false positive for typescript overloads
  • 5abd5ed [Tests] temporarily disable these failing tests in eslint < 4
  • 752dcd5 [Tests] add missing --no-save to time travel script
  • d3a3fa5 [Refactor] no-extraneous-dependencies: remove the last bit of lodash
  • 8a38fd4 [Refactor] no-extraneous-dependencies: use Array.isArray instead of lodash
  • c5078ad [Refactor] importType: remove use of cond
  • 118afd4 no-deprecated: don't run tests for typescript-eslint-parser against ESLint <4
  • 6512110 fix tests for node 4 + fixed lint issues
  • bb9ba24 no-deprecated TS tests (#1315)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of husky is breaking the build 🚨

The devDependency husky was updated from 3.0.0 to 3.0.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

husky is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for v3.0.1
  • Improve error message if git command fails
Commits

The new version differs by 6 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint is breaking the build 🚨

The devDependency eslint was updated from 6.0.1 to 6.1.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for v6.1.0
  • 8f86cca Upgrade: eslint-scope@^5.0.0 (#12011) (Kevin Partington)
  • d08683e Fix: glob processing (fixes #11940) (#11986) (Toru Nagashima)
  • bfcf8b2 Fix: dot-location errors with parenthesized objects (fixes #11868) (#11933) (Milos Djermanovic)
  • 79e8d09 Fix: add parens for sequence expr in arrow-body-style (fixes #11917) (#11918) (Pig Fang)
  • 105c098 Docs: update docs for object-curly-spacing (fixes #11634) (#12009) (Chiawen Chen)
  • c90a12c Chore: update release script for new website repo (#12006) (Kai Cataldo)
  • e2c08a9 Sponsors: Sync README with website (ESLint Jenkins)
  • b974fcb Update: Check computed property keys in no-extra-parens (#11952) (Milos Djermanovic)
  • 222d27c Update: Add for-in and for-of checks for props in no-param-reassign (#11941) (Milos Djermanovic)
  • e4c450f Fix: no-extra-parens autofix with in in a for-loop init (fixes #11706) (#11848) (Milos Djermanovic)
  • 2dafe2d Fix: prefer-const produces invalid autofix (fixes #11699) (#11827) (Milos Djermanovic)
  • cb475fd Fix: Cache file error handling on read-only file system. (fixes #11945) (#11946) (Cuki)
  • 89412c3 Docs: Fixed a typo (fixes #11999) (#12000) (Eddie Olson)
  • 6669f78 Fix: --init with Vue.js failed (fixes #11970) (#11985) (Toru Nagashima)
  • 93633c2 Upgrade: Upgrade lodash dependency (fixes #11992) (#11994) (Cyd La Luz)
  • 776dae7 Docs: fix wrong Node.js version in getting started (#11993) (Toru Nagashima)
  • 4448261 Docs: some typos and optimization points (#11960) (Jason Lee)
  • 2a10856 Chore: Add temporary test files to .gitignore (#11978) (Milos Djermanovic)
  • d83b233 Chore: update path for release bundles (#11977) (Kai Cataldo)
  • 1fb3620 Fix: creating of enabledGlobals object without prototype (fixes #11929) (#11935) (finico)
  • c2f2db9 Docs: Replace global true and false with writable and readonly in rules (#11956) (Milos Djermanovic)
  • 19335b8 Fix: actual messageId and expected messageId are switched in rule tester (#11928) (Milos Djermanovic)
  • 8b216e0 Docs: Fix incorrect example comments for unicode-bom rule (fixes #11937) (#11938) (Brandon Yeager)
  • cc3885b Chore: add v8-compile-cache to speed up instantiation time (#11921) (薛定谔的猫)
  • d8f2688 Upgrade: deps (#11904) (薛定谔的猫)
  • e5f1ccc Docs: add 'stricter rule config validating' in migrating docs (#11905) (薛定谔的猫)
Commits

The new version differs by 28 commits.

  • 02d7542 6.1.0
  • 5997f7a Build: changelog update for 6.1.0
  • 8f86cca Upgrade: eslint-scope@^5.0.0 (#12011)
  • d08683e Fix: glob processing (fixes #11940) (#11986)
  • bfcf8b2 Fix: dot-location errors with parenthesized objects (fixes #11868) (#11933)
  • 79e8d09 Fix: add parens for sequence expr in arrow-body-style (fixes #11917) (#11918)
  • 105c098 Docs: update docs for object-curly-spacing (fixes #11634) (#12009)
  • c90a12c Chore: update release script for new website repo (#12006)
  • e2c08a9 Sponsors: Sync README with website
  • b974fcb Update: Check computed property keys in no-extra-parens (#11952)
  • 222d27c Update: Add for-in and for-of checks for props in no-param-reassign (#11941)
  • e4c450f Fix: no-extra-parens autofix with in in a for-loop init (fixes #11706) (#11848)
  • 2dafe2d Fix: prefer-const produces invalid autofix (fixes #11699) (#11827)
  • cb475fd Fix: Cache file error handling on read-only file system. (fixes #11945) (#11946)
  • 89412c3 Docs: Fixed a typo (fixes #11999) (#12000)

There are 28 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of lint-staged is breaking the build 🚨

The devDependency lint-staged was updated from 10.0.3 to 10.0.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

lint-staged is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for v10.0.4

10.0.4 (2020-01-29)

Bug Fixes

Commits

The new version differs by 2 commits.

  • 9c08e8e fix: use verbose renderer when TERM=dumb (#782)
  • 7fac11f docs: Add better docs on running multiple commands

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of husky is breaking the build 🚨

The devDependency husky was updated from 4.2.0 to 4.2.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

husky is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for v4.2.1
  • Fix: support spaces in path to husky.local.sh #658
Commits

The new version differs by 3 commits.

  • d1f182b 4.2.1
  • fa3a7d7 support spaces in path to husky.local.sh (#658)
  • 9891528 Update README.md and mention husky.config.js file

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of lint-staged is breaking the build 🚨

The devDependency lint-staged was updated from 9.2.0 to 9.2.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

lint-staged is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for v9.2.1

9.2.1 (2019-07-25)

Bug Fixes

Commits

The new version differs by 13 commits.

  • e879b6a fix: pin [email protected] to support node 8
  • ee774e3 fix: pin [email protected] to support node 8
  • eb07cd5 chore: use jsonlint --in-place
  • 6126b72 fix: remove empty spaces from warning
  • 0ce85b2 chore: upgrade devDependencies and simplify eslint config
  • 34ab803 chore: upgrade production depedencies
  • 127cd95 refactor: set SIGINT listener in bin instead of runAll
  • 0342ebf test: update snapshots
  • 7a9df2f refactor: change 'linters' to 'tasks'
  • 7432469 test: add integration test for runAll
  • 8ba95d5 refactor: allow runAll and generateTasks to receive cwd
  • cf8a005 docs: add information about ignoring files
  • da0bbc7 docs: add --relative to README

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of commitlint is breaking the build 🚨

There have been updates to the commitlint monorepo:

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the commitlint group definition.

commitlint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Commits

The new version differs by 39 commits.

  • c17420d v8.1.0
  • ca19d70 chore: update dependency lodash to v4.17.14 (#724)
  • 5757ef2 build(deps): bump lodash.template from 4.4.0 to 4.5.0 (#721)
  • 5b5f855 build(deps): bump lodash.merge from 4.6.0 to 4.6.2 (#722)
  • 4cb979d build(deps): bump lodash from 4.17.11 to 4.17.13 (#723)
  • a89c1ba chore: add devcontainer setup
  • 9aa5709 chore: pin dependencies (#714)
  • c9ef5e2 chore: centralize typescript and jest setups (#710)
  • c9dcf1a chore: pin dependencies (#708)
  • 6a6a8b0 refactor: rewrite top level to typescript (#679)
  • 0fedbc0 chore: update dependency @types/jest to v24.0.15 (#694)
  • 0b9c7ed chore: update dependency typescript to v3.5.2 (#695)
  • 4efb34b chore: update dependency globby to v10 (#705)
  • 804af8b chore: update dependency lint-staged to v8.2.1 (#696)
  • 9075844 fix: add explicit dependency on chalk (#687)

There are 39 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-plugin-import is breaking the build 🚨

The devDependency eslint-plugin-import was updated from 2.18.1 to 2.18.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Commits

The new version differs by 4 commits.

  • 1a90a20 Bump to v2.18.2
  • b3e5311 bump utils to v2.4.1
  • 984fa3b Remove duplicate no-duplicates changelog entry
  • 582236b [bugfix] Skip warning on type interfaces

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

ReferenceError: URL is not defined

La clase cambio no está disponible de manera global en node v8.10, sólo está disponible de manera global a partir de node v10.0.0 (https://nodejs.org/api/url.html):

Version Changes
v10.0.0 The class is now available on the global object.
v7.0.0, v6.13.0 Added in: v7.0.0, v6.13.0

Si no se requiere la clase se produce el siguiente error (https://travis-ci.com/trmapi/trmapi/builds/94481971):

ReferenceError: URL is not defined
  1 | const debug = require("debug")("getTrmDataByDate");
> 2 | const cambio = require("@trmapi/cambio");
    |                ^
  3 | const {
  4 |   formatDate,
  5 |   dateIsInRange,
  at Object.<anonymous> (node_modules/@trmapi/cambio/src/request.js:8:19)
  at Object.<anonymous> (node_modules/@trmapi/cambio/src/index.js:1:44)
  at Object.require (src/endpoints/date.js:2:16)

Se debe requerir la clase para poder usarla en node v8.10: const { URL } = require("url");

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.