Git Product home page Git Product logo

sro's Introduction

SRO

npm package version Build status Code coverage Dependencies status

๐Ÿ“ฆ๐Ÿ” Friendly Correios SRO API wrapper and command-line utility.

  • Validate tracking numbers and their check digits
  • Batch API requests whenever possible
  • Strip empty or whitespace-only fields
  • Create proper ISO date strings from events
  • Handle crazy server responses, like unclosed XML tags
  • Provide command-line utility with human-readable output

Installation

npm install sro

Usage

import { track } from 'sro'
const [items, failures] = await track('TE123456789BR')

If installed globally using the npm -g flag, SRO can also be invoked from the command-line:

$ sro
Usage: sro [options] <numbers...>

Options:
  -V, --version          output the version number
  -o, --output <format>  specify the output format (table|json|pretty) [table] (default: "table")
  -c, --check            check tracking number check digit (default: false)
  -h, --help             display help for command

API

track(numbers, options?): Promise<[items, failures]>

Tracks a collection of tracking numbers.

Arguments

  • numbers (String|Array) - Tracking number or array of tracking numbers to be tracked.
  • options (Object) - Optional tracking options:
    • checkDigit (Boolean) - Whether to validate the tracking number check digit
    • onProgress(progress, item) (Function) - Callback function called for each number once its data has been retrieved. progress is a float number between 0 and 1. item is the item object. Invalid tracking numbers are filtered before any requests are made, so they will not be passed here.

Return

[items, failures] (Array)

  • items (Array) - Item objects.
  • failures (Array) - Objects containing the tracking numbers that did not pass validation.

validate(number, options?): [passes, failures]

Validates a collection of tracking numbers.

Arguments

  • numbers (String|Array) - Tracking number or array of tracking numbers to be validated
  • options (Object) - Optional tracking options:
    • checkDigit (Boolean) - Whether to validate the tracking number check digit

Return

[passes, failures] (Array)

  • passes (Array) - Objects containing the tracking numbers that passed validation.
  • failures (Array) - Objects containing the tracking numbers that did not pass validation.

sro's People

Contributors

rbardini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sro's Issues

Cors

Access to fetch at 'http://webservice.correios.com.br/service/rastro' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
consulta:1 Uncaught (in promise) TypeError: Failed to fetch

Este erro ocorre ao fazer a consulta, e uns warnings de um tal de colors, mas, este erro seria no meu ambiente ou seria alterado no plugin?

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.