Giter VIP home page Giter VIP logo

gocorreios's Introduction

gocorreios

Go Correios

Integration with Correios Web Services ✉️

Made with Golang 🚀

GitHub language count Made by Lgdev07 License Stargazers

Features   |    How to Use   |    How to contribute   

✅ Features

🚀 How to Use

Tracking

package main

import (
	"fmt"
	"log"

	"github.com/Lgdev07/gocorreios"
)

func main() {
	result, err := gocorreios.Tracking([]string{"OK816158697BR"})
	if err != nil {
        fmt.Println("[ERRO]:", err.Error())
        return
	}
	fmt.Println(string(result))
}

Expected result:

[
    {
        "number": "OK816158697BR",
        "category": "SEDEX",
        "last_date": "05/10/2020 - 09:09",
        "last_type": "BDE",
        "last_status": 23,
        "last_description": "Objeto entregue ao remetente",
        "last_detail": "",
        "last_origin": "CDD CARIACICA - RUA SAO FRANCISCO, 53, SAO FRANCISCO - VIANA/ES",
        "last_destination": "",
        "error": "",
        "history": [
            {
                "date": "05/10/2020 - 06:37",
                "type": "OEC",
                "status": 9,
                "description": "Objeto saiu para entrega ao remetente",
                "detail": "",
                "origin": "CDD CARIACICA - RUA SAO FRANCISCO, 53, SAO FRANCISCO - VIANA/ES",
                "destination": ""
            },
            {
                "date": "01/10/2020 - 22:07",
                "type": "DO",
                "status": 1,
                "description": "Objeto em trânsito - por favor aguarde",
                "detail": "",
                "origin": "CTE BENFICA - RUA LEOPOLDO BULHOES, 530, BENFICA - RIO DE JANEIRO/RJ",
                "destination": "CDD CARIACICA - RUA SAO FRANCISCO, 53, SAO FRANCISCO - VIANA/ES"
            },
            {
                "date": "30/09/2020 - 11:03",
                "type": "RO",
                "status": 1,
                "description": "Objeto em trânsito - por favor aguarde",
                "detail": "",
                "origin": "CEE CAMPOS DOS GOYTACAZES - RUA ROCHA LEAO, 120, PARQUE CAJU - CAMPOS DOS GOYTACAZES/RJ",
                "destination": "CTE BENFICA - RUA LEOPOLDO BULHOES, 530, BENFICA - RIO DE JANEIRO/RJ"
            },
            {
                "date": "30/09/2020 - 11:02",
                "type": "FC",
                "status": 3,
                "description": "Objeto mal encaminhado",
                "detail": "Encaminhamento a ser corrigido",
                "origin": "CEE CAMPOS DOS GOYTACAZES - RUA ROCHA LEAO, 120, PARQUE CAJU - CAMPOS DOS GOYTACAZES/RJ",
                "destination": ""
            },
            {
                "date": "29/09/2020 - 18:06",
                "type": "DO",
                "status": 1,
                "description": "Objeto em trânsito - por favor aguarde",
                "detail": "",
                "origin": "CTE BENFICA - RUA LEOPOLDO BULHOES, 530, BENFICA - RIO DE JANEIRO/RJ",
                "destination": "CEE CAMPOS DOS GOYTACAZES - RUA ROCHA LEAO, 120, PARQUE CAJU - CAMPOS DOS GOYTACAZES/RJ"
            },
            {
                "date": "28/09/2020 - 21:03",
                "type": "DO",
                "status": 1,
                "description": "Objeto em trânsito - por favor aguarde",
                "detail": "",
                "origin": "CTE SAUDE - RUA DO BOQUEIRAO, 320, SAUDE - SAO PAULO/SP",
                "destination": "CTE BENFICA - RUA LEOPOLDO BULHOES, 530, BENFICA - RIO DE JANEIRO/RJ"
            },
            {
                "date": "28/09/2020 - 14:53",
                "type": "RO",
                "status": 1,
                "description": "Objeto em trânsito - por favor aguarde",
                "detail": "",
                "origin": "CDD PIRAPORINHA - RUA ANTONIO DIAS ADORNO, 236/240, VILA NOGUEIRA - Diadema/SP",
                "destination": "CTE SAUDE - RUA DO BOQUEIRAO, 320, SAUDE - SAO PAULO/SP"
            },
            {
                "date": "26/09/2020 - 09:56",
                "type": "BDI",
                "status": 26,
                "description": "Destinatário não retirou objeto no prazo",
                "detail": "Objeto será devolvido ao remetente",
                "origin": "CDD PIRAPORINHA - RUA ANTONIO DIAS ADORNO, 236/240, VILA NOGUEIRA - Diadema/SP",
                "destination": ""
            },
            {
                "date": "18/09/2020 - 09:42",
                "type": "LDI",
                "status": 1,
                "description": "Objeto aguardando retirada no endereço indicado",
                "detail": "Para retirá-lo, é preciso informar o código do objeto e apresentar documentação que comprove ser o destinatário ou pessoa por ele oficialmente autorizada.",
                "origin": "CDD PIRAPORINHA - RUA ANTONIO DIAS ADORNO, 236/240, VILA NOGUEIRA - Diadema/SP",
                "destination": ""
            },
            {
                "date": "16/09/2020 - 20:57",
                "type": "DO",
                "status": 1,
                "description": "Objeto em trânsito - por favor aguarde",
                "detail": "",
                "origin": "CTE SAUDE - RUA DO BOQUEIRAO, 320, SAUDE - SAO PAULO/SP",
                "destination": "CDD PIRAPORINHA - RUA ANTONIO DIAS ADORNO, 236/240, VILA NOGUEIRA - Diadema/SP"
            },
            {
                "date": "16/09/2020 - 15:11",
                "type": "DO",
                "status": 1,
                "description": "Objeto em trânsito - por favor aguarde",
                "detail": "",
                "origin": "CTE JAGUARE - RUA MERGENTHALER, 568, VILA LEOPOLDINA - SAO PAULO/SP",
                "destination": "CTE SAUDE - RUA DO BOQUEIRAO, 320, SAUDE - SAO PAULO/SP"
            },
            {
                "date": "16/09/2020 - 01:53",
                "type": "RO",
                "status": 1,
                "description": "Objeto em trânsito - por favor aguarde",
                "detail": "",
                "origin": "AGF XV DE NOVEMBRO - AVENIDA QUINZE DE NOVEMBRO, 1668, CENTRO - ITAPECERICA DA SERRA/SP",
                "destination": "CTE JAGUARE - RUA MERGENTHALER, 568, VILA LEOPOLDINA - SAO PAULO/SP"
            },
            {
                "date": "16/09/2020 - 01:36",
                "type": "PO",
                "status": 1,
                "description": "Objeto postado",
                "detail": "",
                "origin": "AGF XV DE NOVEMBRO - AVENIDA QUINZE DE NOVEMBRO, 1668, CENTRO - ITAPECERICA DA SERRA/SP",
                "destination": ""
            }
        ]
    }
]

CEP

package main

import (
	"fmt"

	"github.com/Lgdev07/gocorreios"
)

func main() {
	res, err := gocorreios.Cep("04029000")
	if err != nil {
		fmt.Println("[ERRO]:", err.Error())
		return
	}

	fmt.Println(string(res))
}

Expected result:

{
    "cep": "04029-000",
    "uf": "SP",
    "localidade": "São Paulo",
    "logradouro": "Avenida Ibirapuera",
    "bairro": "Indianópolis",
    "complemento": "até 1731 - lado ímpar"
}

Fare

package main

import (
	"fmt"

	"github.com/Lgdev07/gocorreios"
	"github.com/Lgdev07/gocorreios/fare"
)

func main() {
	params := fare.Interface{
		Service:        "SEDEX", // Avaliable Services: SEDEX, PAC
		CepOrigin:      "60010100",
		CepDestination: "04029000",
		Weight:         30,
		Length:         20,
		Height:         20,
		Width:          20,
	}

	result, err := gocorreios.Fare(params)
	if err != nil {
		fmt.Println("[ERRO]:", err.Error())
		return
	}
	fmt.Println(string(result))
}

Expected result:

{
    "service": "SEDEX",
    "price": "22,50",
    "days_for_delivery": "9",
    "deliver_home": "S",
    "deliver_saturday": "S",
    "obs": "O CEP de destino está sujeito a condições especiais de entrega  pela  ECT e será realizada com o acréscimo de até 7 (sete) dias úteis ao prazo regular."
}

🤔 How to contribute

  • Fork this repository;
  • Create a branch with your feature: git checkout -b my-feature;
  • Commit your changes: git commit -m 'feat: My new feature';
  • Push to your branch: git push origin my-feature.

After the merge of your pull request is done, you can delete your branch.


gocorreios's People

Contributors

alisonosouza avatar lgdev07 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

alisonosouza

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.