All Projects → rbardini → Sro

rbardini / Sro

Licence: mit
Friendly Correios SRO API wrapper and command-line utility

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Sro

Umbraco Nexu
Umbraco package that let's you track internal links in Umbraco
Stars: ✭ 18 (+157.14%)
Mutual labels:  package, tracking
Ip Biter
IP-Biter: The Hacker-friendly E-Mail (but not only) Tracking Framework
Stars: ✭ 166 (+2271.43%)
Mutual labels:  tracking, mail
py17track
📦 A simple API to track package info from 17track.com
Stars: ✭ 20 (+185.71%)
Mutual labels:  tracking, package
Parse Auditor
Audit module for Parse Platform
Stars: ✭ 19 (+171.43%)
Mutual labels:  tracking
Mixpanel Android
Official Mixpanel Android SDK
Stars: ✭ 907 (+12857.14%)
Mutual labels:  tracking
Atom Korean Spell Daum
Daum 맞춤법 검사기로 텍스트를 보내 손쉽게 교정 가능한 Atom package
Stars: ✭ 24 (+242.86%)
Mutual labels:  package
Clojure Empregos Brasil
Vagas e empresas que ativamente contratam pessoas desenvolvedoras Clojure no Brasil
Stars: ✭ 27 (+285.71%)
Mutual labels:  brazil
Pydnsbl
Async dnsbl spam lists checker based on asyncio/aiodns.
Stars: ✭ 18 (+157.14%)
Mutual labels:  mail
Warc
Golang WARC (Web ARChive) Library
Stars: ✭ 25 (+257.14%)
Mutual labels:  package
Snm
🤏 Smol Node Manager written in Rust
Stars: ✭ 24 (+242.86%)
Mutual labels:  package
Empresas Que Usam React No Brasil
Repositório que mostra empresas e projetos que utilizam React no Brasil
Stars: ✭ 923 (+13085.71%)
Mutual labels:  brazil
Media Tracker
Self-hosted open source media-tracker for tv shows and movies. (React, Redux)
Stars: ✭ 21 (+200%)
Mutual labels:  tracking
Doc Hunt
Keep your documentation up to date by tracking changes in your source code
Stars: ✭ 24 (+242.86%)
Mutual labels:  tracking
Compinstall
Delphi utility app to auto-install component packages into IDE
Stars: ✭ 19 (+171.43%)
Mutual labels:  package
Norfair
Lightweight Python library for adding real-time 2D object tracking to any detector.
Stars: ✭ 933 (+13228.57%)
Mutual labels:  tracking
Tidymv
Tidy Model Visualisation for Generalised Additive Models
Stars: ✭ 25 (+257.14%)
Mutual labels:  package
Pagarme Laravel
Pagar.me SDK for Laravel applications.
Stars: ✭ 23 (+228.57%)
Mutual labels:  package
Libra Sdk Go
Go SDK for the Libra cryptocurrency
Stars: ✭ 23 (+228.57%)
Mutual labels:  package
Laravel Aws Sns
Laravel package for the AWS SNS Events
Stars: ✭ 24 (+242.86%)
Mutual labels:  package
Cs.2click
🔊 A Better Audio Router for a Modular System.
Stars: ✭ 7 (+0%)
Mutual labels:  package

SRO

npm package version Build status Code coverage Dependency status JavaScript Standard Style

Friendly Correios SRO API wrapper and command-line utility.

Installation

$ npm install sro

Usage

import sro from 'sro'

sro.track('SS123456789BR', (err, items, failures) => {
  if (err) throw err

  items.forEach(item => {
    var status = item.status()
    if (status != null) console.log(status.get('descricao'))
  })

  failures.forEach(failure => {
    console.log(failure.error)
  })
})

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

$ sro SS123456789BR

Run $ sro --help for more information.

Features

  • Validates tracking numbers and their check digits
  • Makes multiple API requests in batch if possible
  • Strips empty or whitespace-only fields
  • Creates proper Date objects from item events
  • Handles crazy server responses, like unclosed XML tags
  • Provides command-line utility with human-readable output

Documentation

Methods

track(numbers [, options], callback)

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.
  • callback(err, items, failures) (Function) - Callback function called once all tracking numbers have been processed, or when an error occurs. items is an array of Item objects. failures is an array of objects containing the tracking numbers that did not pass validation.

validate(number [, options], callback)

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
  • callback(err, passes, failures) (Function) - Callback function called once all numbers have been processed, or when an error occurs. passes is an array of objects containing the tracking numbers that passed validation. failures is an array of objects containing the tracking numbers that did not pass validation.

Return True if all tracking numbers are valid, false otherwise.

Models

SRO models are heavily inspired by Backbone.Model and provide conversions, validations, computed properties, and data access control. All models have the following base methods:

  • set(name, attr) - Sets an attribute on the model.
  • unset(name) - Removes an attribute from the model.
  • get(name) - Gets the current value of an attribute from the model.
  • has(name) - Returns true if the attribute is set to a non-null or non-undefined value.
  • forEach(iteratee) - Iterates over the attributes, yielding each in turn to an iteratee function.
  • compact() - Removes all attributes with empty or whitespace-only values.
  • toJSON() - Returns a shallow copy of the model's attributes for JSON stringification.

Item

Represents a postal item, holding all the tracking data retrieved from the API for a given tracking number.

  • number() - Returns the tracking number.
  • serviceCode() - Returns the two-digit postal service code.
  • service() - Returns the postal service description.
  • countryCode() - Returns the two-digit ISO 3166-1 alpha 2 country code.
  • countryName() - Returns the country name.
  • country() - Returns the country data from country-data.
  • events() - Returns an array with all Event objects, ordered by most recent.
  • status() - Returns the most recent Event object.
  • found() - Returns true if there is any Event object.

Event

Represents the status of an item at an specific point in time.

  • date() - Return a Date object derived from the data and hora attributes.

TODO

  • Add last event-only tracking option
  • Add validation-only CLI option
  • Support custom user credentials
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].