Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Latest commit

 

History

History
98 lines (73 loc) · 5.42 KB

README.md

File metadata and controls

98 lines (73 loc) · 5.42 KB

Gem Version Build Status Code Climate Test Coverage

intelipost

Gem for the Intelipost API

Usage:

Address Complete (CEP)

# GET /cep_address/complete
require 'intelipost'

client = Intelipost::Client.new api_key: <your api key>
address = client.cep.address_complete.get '05307000'
# => #<Hashie::Mash content=#<Hashie::Mash bairro="Vila Ribeiro de Barros" city="São Paulo" ibge="3550308" neighborhood="Vila Ribeiro de Barros" state="São Paulo" state_short="SP" street="R Maj Paladino"> messages=[] status="OK" time="0.6 ms">
address.content.street
# => "R Maj Paladino"

Quote (Cotação)

# POST /quote
require 'intelipost'

client = Intelipost::Client.new api_key: <your api key>
quote = client.quote.create({hash_of: :intelipost, args: :values})
# => #<Hashie::Mash content=#<Hashie::Mash additional_information=#<Hashie::Mash client_type="gold" delivery_method_ids=[4, 3, 2] extra_cost_absolute=0.0 extra_cost_percentage=0.0 free_shipping=false lead_time_business_days=0 sales_channel="hotsite" tax_id=nil> client_id=1783 created=1433872646799 created_iso="2015-06-09T14:57:26.799-03:00" delivery_options=[#<Hashie::Mash delivery_estimate_business_days=1 delivery_method_id=4 delivery_method_name="Total Express" delivery_method_type="EXPRESS" delivery_note=nil description="Total Express" final_shipping_cost=5.05 logistic_provider_name="Total" provider_shipping_cost=5.05>, #<Hashie::Mash delivery_estimate_business_days=1 delivery_method_id=3 delivery_method_name="Correios eSedex" delivery_method_type="EXPRESS" delivery_note=nil description="Correios eSedex" final_shipping_cost=7.83 logistic_provider_name="Correios" provider_shipping_cost=7.83>, #<Hashie::Mash delivery_estimate_business_days=1 delivery_method_id=2 delivery_method_name="Correios Sedex" delivery_method_type="EXPRESS" delivery_note=nil description="Correios Sedex" final_shipping_cost=13.83 logistic_provider_name="Correios" provider_shipping_cost=13.83>] destination_zip_code="06396-200" id=4347667 origin_zip_code="04037-003" platform=nil volumes=[#<Hashie::Mash cost_of_goods=100.0 description=nil height=10.0 length=10.0 volume_type="BOX" weight=0.1 width=10.0>]> messages=[] status="OK" time="34.0 ms">
quote.content.id
# => 4347667

Quote By Product (Cotação por produto)

# POST /quote
require 'intelipost'

client = Intelipost::Client.new api_key: <your api key>
quote = client.quote_by_product.create({hash_of: :intelipost, args: :values})
# => #<Hashie::Mash content=#<Hashie::Mash additional_information=#<Hashie::Mash client_type="gold" delivery_method_ids=[4, 3, 2] extra_cost_absolute=0.0 extra_cost_percentage=0.0 free_shipping=false lead_time_business_days=0 sales_channel="hotsite" tax_id=nil> client_id=1783 created=1433872646799 created_iso="2015-06-09T14:57:26.799-03:00" delivery_options=[#<Hashie::Mash delivery_estimate_business_days=1 delivery_method_id=4 delivery_method_name="Total Express" delivery_method_type="EXPRESS" delivery_note=nil description="Total Express" final_shipping_cost=5.05 logistic_provider_name="Total" provider_shipping_cost=5.05>, #<Hashie::Mash delivery_estimate_business_days=1 delivery_method_id=3 delivery_method_name="Correios eSedex" delivery_method_type="EXPRESS" delivery_note=nil description="Correios eSedex" final_shipping_cost=7.83 logistic_provider_name="Correios" provider_shipping_cost=7.83>, #<Hashie::Mash delivery_estimate_business_days=1 delivery_method_id=2 delivery_method_name="Correios Sedex" delivery_method_type="EXPRESS" delivery_note=nil description="Correios Sedex" final_shipping_cost=13.83 logistic_provider_name="Correios" provider_shipping_cost=13.83>] destination_zip_code="06396-200" id=4347667 origin_zip_code="04037-003" platform=nil products=[#<Hashie::Mash weight=5 cost_of_goods=100 width=10.0 height=10.0 length="BOX" quantity=1 sku_id=2323232 product_category=Calçados>]> messages=[] status="OK" time="34.0 ms">
quote.content.id
# => 4347667
# GET /quote/{id}
require 'intelipost'
client = Intelipost::Client.new api_key: <your api key>
quote = client.quote.get(124560)

Shipment Order (Pedido de Envio)

# POST /shipment_order
require 'intelipost'

client = Intelipost::Client.new api_key: <your api key>
client.shipment_order.create({hash_of: :intelipost, args: :values})
# POST /shipment_order/set_invoice
require 'intelipost'

client = Intelipost::Client.new api_key: <your api key>
client.shipment_order.set_invoice.update({hash_of: :intelipost, args: :values})
# POST /shipment_order/set_tracking_data
require 'intelipost'

client = Intelipost::Client.new api_key: <your api key>
client.shipment_order.set_tracking_data.update({hash_of: :intelipost, args: :values})
# GET /shipment_order/read_status/{order_number}
require 'intelipost'

client = Intelipost::Client.new api_key: <your api key>
client.shipment_order.read_status.get(124560)

Development:

For testing, create a .env file with the following content:

INTELIPOST_API_KEY=<YOUR API KEY>