项目作者: Lgdev07

项目描述 :
Golang go Integration with Correios Services
高级语言: Go
项目地址: git://github.com/Lgdev07/gocorreios.git
创建时间: 2020-10-15T01:49:36Z
项目社区:https://github.com/Lgdev07/gocorreios

开源协议:

下载



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

  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "github.com/Lgdev07/gocorreios"
  6. )
  7. func main() {
  8. result, err := gocorreios.Tracking([]string{"OK816158697BR"})
  9. if err != nil {
  10. fmt.Println("[ERRO]:", err.Error())
  11. return
  12. }
  13. fmt.Println(string(result))
  14. }

Expected result:

  1. [
  2. {
  3. "number": "OK816158697BR",
  4. "category": "SEDEX",
  5. "last_date": "05/10/2020 - 09:09",
  6. "last_type": "BDE",
  7. "last_status": 23,
  8. "last_description": "Objeto entregue ao remetente",
  9. "last_detail": "",
  10. "last_origin": "CDD CARIACICA - RUA SAO FRANCISCO, 53, SAO FRANCISCO - VIANA/ES",
  11. "last_destination": "",
  12. "error": "",
  13. "history": [
  14. {
  15. "date": "05/10/2020 - 06:37",
  16. "type": "OEC",
  17. "status": 9,
  18. "description": "Objeto saiu para entrega ao remetente",
  19. "detail": "",
  20. "origin": "CDD CARIACICA - RUA SAO FRANCISCO, 53, SAO FRANCISCO - VIANA/ES",
  21. "destination": ""
  22. },
  23. {
  24. "date": "01/10/2020 - 22:07",
  25. "type": "DO",
  26. "status": 1,
  27. "description": "Objeto em trânsito - por favor aguarde",
  28. "detail": "",
  29. "origin": "CTE BENFICA - RUA LEOPOLDO BULHOES, 530, BENFICA - RIO DE JANEIRO/RJ",
  30. "destination": "CDD CARIACICA - RUA SAO FRANCISCO, 53, SAO FRANCISCO - VIANA/ES"
  31. },
  32. {
  33. "date": "30/09/2020 - 11:03",
  34. "type": "RO",
  35. "status": 1,
  36. "description": "Objeto em trânsito - por favor aguarde",
  37. "detail": "",
  38. "origin": "CEE CAMPOS DOS GOYTACAZES - RUA ROCHA LEAO, 120, PARQUE CAJU - CAMPOS DOS GOYTACAZES/RJ",
  39. "destination": "CTE BENFICA - RUA LEOPOLDO BULHOES, 530, BENFICA - RIO DE JANEIRO/RJ"
  40. },
  41. {
  42. "date": "30/09/2020 - 11:02",
  43. "type": "FC",
  44. "status": 3,
  45. "description": "Objeto mal encaminhado",
  46. "detail": "Encaminhamento a ser corrigido",
  47. "origin": "CEE CAMPOS DOS GOYTACAZES - RUA ROCHA LEAO, 120, PARQUE CAJU - CAMPOS DOS GOYTACAZES/RJ",
  48. "destination": ""
  49. },
  50. {
  51. "date": "29/09/2020 - 18:06",
  52. "type": "DO",
  53. "status": 1,
  54. "description": "Objeto em trânsito - por favor aguarde",
  55. "detail": "",
  56. "origin": "CTE BENFICA - RUA LEOPOLDO BULHOES, 530, BENFICA - RIO DE JANEIRO/RJ",
  57. "destination": "CEE CAMPOS DOS GOYTACAZES - RUA ROCHA LEAO, 120, PARQUE CAJU - CAMPOS DOS GOYTACAZES/RJ"
  58. },
  59. {
  60. "date": "28/09/2020 - 21:03",
  61. "type": "DO",
  62. "status": 1,
  63. "description": "Objeto em trânsito - por favor aguarde",
  64. "detail": "",
  65. "origin": "CTE SAUDE - RUA DO BOQUEIRAO, 320, SAUDE - SAO PAULO/SP",
  66. "destination": "CTE BENFICA - RUA LEOPOLDO BULHOES, 530, BENFICA - RIO DE JANEIRO/RJ"
  67. },
  68. {
  69. "date": "28/09/2020 - 14:53",
  70. "type": "RO",
  71. "status": 1,
  72. "description": "Objeto em trânsito - por favor aguarde",
  73. "detail": "",
  74. "origin": "CDD PIRAPORINHA - RUA ANTONIO DIAS ADORNO, 236/240, VILA NOGUEIRA - Diadema/SP",
  75. "destination": "CTE SAUDE - RUA DO BOQUEIRAO, 320, SAUDE - SAO PAULO/SP"
  76. },
  77. {
  78. "date": "26/09/2020 - 09:56",
  79. "type": "BDI",
  80. "status": 26,
  81. "description": "Destinatário não retirou objeto no prazo",
  82. "detail": "Objeto será devolvido ao remetente",
  83. "origin": "CDD PIRAPORINHA - RUA ANTONIO DIAS ADORNO, 236/240, VILA NOGUEIRA - Diadema/SP",
  84. "destination": ""
  85. },
  86. {
  87. "date": "18/09/2020 - 09:42",
  88. "type": "LDI",
  89. "status": 1,
  90. "description": "Objeto aguardando retirada no endereço indicado",
  91. "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.",
  92. "origin": "CDD PIRAPORINHA - RUA ANTONIO DIAS ADORNO, 236/240, VILA NOGUEIRA - Diadema/SP",
  93. "destination": ""
  94. },
  95. {
  96. "date": "16/09/2020 - 20:57",
  97. "type": "DO",
  98. "status": 1,
  99. "description": "Objeto em trânsito - por favor aguarde",
  100. "detail": "",
  101. "origin": "CTE SAUDE - RUA DO BOQUEIRAO, 320, SAUDE - SAO PAULO/SP",
  102. "destination": "CDD PIRAPORINHA - RUA ANTONIO DIAS ADORNO, 236/240, VILA NOGUEIRA - Diadema/SP"
  103. },
  104. {
  105. "date": "16/09/2020 - 15:11",
  106. "type": "DO",
  107. "status": 1,
  108. "description": "Objeto em trânsito - por favor aguarde",
  109. "detail": "",
  110. "origin": "CTE JAGUARE - RUA MERGENTHALER, 568, VILA LEOPOLDINA - SAO PAULO/SP",
  111. "destination": "CTE SAUDE - RUA DO BOQUEIRAO, 320, SAUDE - SAO PAULO/SP"
  112. },
  113. {
  114. "date": "16/09/2020 - 01:53",
  115. "type": "RO",
  116. "status": 1,
  117. "description": "Objeto em trânsito - por favor aguarde",
  118. "detail": "",
  119. "origin": "AGF XV DE NOVEMBRO - AVENIDA QUINZE DE NOVEMBRO, 1668, CENTRO - ITAPECERICA DA SERRA/SP",
  120. "destination": "CTE JAGUARE - RUA MERGENTHALER, 568, VILA LEOPOLDINA - SAO PAULO/SP"
  121. },
  122. {
  123. "date": "16/09/2020 - 01:36",
  124. "type": "PO",
  125. "status": 1,
  126. "description": "Objeto postado",
  127. "detail": "",
  128. "origin": "AGF XV DE NOVEMBRO - AVENIDA QUINZE DE NOVEMBRO, 1668, CENTRO - ITAPECERICA DA SERRA/SP",
  129. "destination": ""
  130. }
  131. ]
  132. }
  133. ]

CEP

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/Lgdev07/gocorreios"
  5. )
  6. func main() {
  7. res, err := gocorreios.Cep("04029000")
  8. if err != nil {
  9. fmt.Println("[ERRO]:", err.Error())
  10. return
  11. }
  12. fmt.Println(string(res))
  13. }

Expected result:

  1. {
  2. "cep": "04029-000",
  3. "uf": "SP",
  4. "localidade": "São Paulo",
  5. "logradouro": "Avenida Ibirapuera",
  6. "bairro": "Indianópolis",
  7. "complemento": "até 1731 - lado ímpar"
  8. }

Fare

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/Lgdev07/gocorreios"
  5. "github.com/Lgdev07/gocorreios/fare"
  6. )
  7. func main() {
  8. params := fare.Interface{
  9. Service: "SEDEX", // Avaliable Services: SEDEX, PAC
  10. CepOrigin: "60010100",
  11. CepDestination: "04029000",
  12. Weight: 30,
  13. Length: 20,
  14. Height: 20,
  15. Width: 20,
  16. }
  17. result, err := gocorreios.Fare(params)
  18. if err != nil {
  19. fmt.Println("[ERRO]:", err.Error())
  20. return
  21. }
  22. fmt.Println(string(result))
  23. }

Expected result:

  1. {
  2. "service": "SEDEX",
  3. "price": "22,50",
  4. "days_for_delivery": "9",
  5. "deliver_home": "S",
  6. "deliver_saturday": "S",
  7. "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."
  8. }

🤔 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.