Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

me_api

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

me_api

  • 1.1.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

MeApi

Wrapper de integração com a API v2 do Melhor Envio para cotação de frete.

Documentação API Melhor Envio

Funcionalidades:

  • Autenticação: authorization e refresh_token
  • Cotação de frete

Instalação

Adicionar me_api no Gemfile:

gem 'me_api'

ou

bundle add me_api

Instalar a gem:

bin/rails generate me_api:install

Uso

Exemplo

Autorização
api_client = MeApi::Client.new.authorize(client_id: "123456", client_secret: "abcde", code: "a1b2c3d4e5", redirect_url: "https://redirect-url.com")
# retorna JSON da resposta
puts api_client["access_token"] # string -> "abcde12345"
puts api_client["refresh_token"] # string -> "asdfghjk123456"
puts api_client["expires_in"] # integer -> 216000
Refresh Token
api_client = MeApi::Client.new.refresh_token(client_id: "123456", client_secret: "abcde", refresh_token: "asdfghjk123456")
# retorna JSON da resposta
puts api_client["access_token"] # string -> "abcde12345"
puts api_client["refresh_token"] # string -> "qwertyu098765"
puts api_client["expires_in"] # string -> 21600
Cotação de Frete
rates = MeApi::Client.new("access_token").rates(from: "01002010", to: "99990971", weight_kg: 10, contents_value_brl: 100.00, height_cm: 15, width_cm: 30, length_cm: 30)

#retorna um array de Objetos <MeApi::Client::Rate>
puts rates[0] # <data MeApi::Client::Rate from="01002010", to="99990971", price=87.3, delivery_range={"min"=>16, "max"=>17}, service_name="PAC", carrier_name="Correios", carrier_logo_url="https://www.melhorenvio.com.br/images/shipping-companies/correios.png">

puts rates[0].price # 87.3

FAQs

Package last updated on 28 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc