Intelipost Java SDK

Java SDK to deal with Intelipost API - V1

License

License

Categories

Categories

Java Languages
GroupId

GroupId

br.com.intelipost
ArtifactId

ArtifactId

sdk-java
Last Version

Last Version

0.0.8
Release Date

Release Date

Type

Type

jar
Description

Description

Intelipost Java SDK
Java SDK to deal with Intelipost API - V1
Project URL

Project URL

https://github.com/intelipost/sdk-java
Source Code Management

Source Code Management

https://github.com/intelipost/sdk-java/tree/master

Download sdk-java

How to add to project

<!-- https://jarcasting.com/artifacts/br.com.intelipost/sdk-java/ -->
<dependency>
    <groupId>br.com.intelipost</groupId>
    <artifactId>sdk-java</artifactId>
    <version>0.0.8</version>
</dependency>
// https://jarcasting.com/artifacts/br.com.intelipost/sdk-java/
implementation 'br.com.intelipost:sdk-java:0.0.8'
// https://jarcasting.com/artifacts/br.com.intelipost/sdk-java/
implementation ("br.com.intelipost:sdk-java:0.0.8")
'br.com.intelipost:sdk-java:jar:0.0.8'
<dependency org="br.com.intelipost" name="sdk-java" rev="0.0.8">
  <artifact name="sdk-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='br.com.intelipost', module='sdk-java', version='0.0.8')
)
libraryDependencies += "br.com.intelipost" % "sdk-java" % "0.0.8"
[br.com.intelipost/sdk-java "0.0.8"]

Dependencies

compile (9)

Group / Artifact Type Version
org.apache.httpcomponents : fluent-hc jar 4.5.2
org.apache.commons : commons-lang3 jar 3.7
com.fasterxml.jackson.core : jackson-annotations jar 2.9.0.pr1
com.fasterxml.jackson.core : jackson-databind jar 2.9.0.pr1
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar 2.9.0.pr1
org.projectlombok : lombok jar 1.16.14
org.springframework.data : spring-data-rest-webmvc jar 2.6.0.RELEASE
org.slf4j : slf4j-simple jar 1.7.25
org.slf4j : slf4j-api jar 1.7.25

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-all jar RELEASE
org.hamcrest : hamcrest-library jar RELEASE

Project Modules

There are no modules declared in this project.

Build Status

SDK JAVA - Intelipost API V1

Overview

SDK para auxiliar no consumo de alguns endpoints existentes na API V1, conforme documentação.

Usage

Para utilizar o SDK é necessário:

  1. Incluir o jar no classpath ou incluir a dependencia no arquivo pom.xml do Maven.
<dependency>
   <groupId>br.com.intelipost</groupId>
   <artifactId>sdk-java</artifactId>
   <version>RELEASE</version>
</dependency>
  1. Instanciar a classe IntelipostClient com sua API_KEY.
  IntelipostClient intelipostClient = new IntelipostClient("SUA_API_KEY");

Endpoints Disponíveis

  • CEP ( GET - /cep_location/address_complete/{cep} ), exemplo:
  IntelipostClient intelipostClient = new IntelipostClient("SUA_API_KEY");
  ZipCodeResponse zipCodeInfo = intelipostClient.getZipCodeInfo("00000000");
  • Cotação ( POST - /quote_by_product ), exemplo:
  IntelipostClient intelipostClient = new IntelipostClient("SUA_API_KEY");
  
  QuoteProductRequest productRequest;
  productRequest= QuoteProductDSL.newProduct()
                                  .sku("MCK")
                                  .description("Mockito")
                                  .weight(66.0D)
                                  .height(10.0D)
                                  .length(3.0D)
                                  .width(11.0D)
                                  .quantity(1)
                                  .unitPrice(100.0D)
                                .serialize();

  QuoteRequest quote;
  quote = QuoteDSL.newQuote()
                    .originZipCode("4401160")
                    .destinationZipCode("7011010")
                  .withProducts()
                    .addItem(productRequest)
                  .serialize();

  QuoteResponse quoteResponse = intelipostClient.doShippingQuote(quote);
  
  • Consulta Cotação ( GET - /quote/{id} ), exemplo:

      Long idQuote = 122L;
      IntelipostClient intelipostClient = new IntelipostClient("SUA_API_KEY");
      QuoteResponse quote = intelipostClient.getShippingQuote(idQuote);
  • Pedido de Envio ( POST - /shipment_order ), exemplo:

      IntelipostClient intelipostClient = new IntelipostClient("SUA_API_KEY");
      
      ShipmentOrderVolumeInvoiceRequest orderVolumeInvoice;
      ShipmentOrderVolumeRequest orderVolume;
      ShipmentOrderCustomerResquest orderCustomer;
      ShipmentOrderRequest shipmentOrder;
      
      List<ShipmentOrderVolumeRequest> orderVolumes = new ArrayList<>(1);
    
      orderVolumeInvoice = ShipmentOrderVolumeInvoiceDSL.newVolumeInvoice()
                .cfop("61258")
                .key("13245613963285523155248613218512318651321135")
                .series(1)
                .number(3335131L)
                .date(ZonedDateTime.parse("2017-05-03T11:26:06.674Z"))
                .productTotal(110D)
                .total(160D)
              .serialize();
    
      orderVolume = ShipmentOrderVolumeDSL.newOrderVolume()
                .height(16D)
                .length(10D)
                .width(10D)
                .weight(170D)
                .quantity(1)
                .trackingCode("TRACKING123") //OPCIONAL
                .volumeNumber(1)
                .withInvoice(orderVolumeInvoice)
              .serialize();
    
      orderVolumes.add(orderVolume);
    
      orderCustomer = ShipmentOrderCustomerDSL.newCustomer()
                .email("[email protected]")
                .firstName("teste")
                .lastName("teste")
                .phone("11 55555555555")
                .federalTaxPayerId("19100000000")
                .withShippingInfo()
                .address("Rua teste")
                .additionalInfo("add")
                .neighborhood("mock")
                .number("152")
                .country("BR")
                .state("Amazonas")
                .city("Manaus")
                .zipCode("05433020")
              .serialize();
    
      shipmentOrder = ShipmentOrderDSL.newShipmentOrder()
                  .idQuote(123L)
                  .idDeliveryMethod(2)
                  .orderNumber("123")
                  .shippingCost(50D)
                  .shippedDate(OffsetDateTime.now())
                .withCustomer(orderCustomer)
                .withVolumes(orderVolumes)
              .serialize();
    
      ShipmentOrderResponse shipmentOrderResponse = intelipostClient.doShipmentOrder(shipmentOrder);
  • Consultar Pedido de Envio ( GET - /shipment_order/{pedido_de_envio} ), exemplo:

      IntelipostClient intelipostClient = new IntelipostClient("SUA_API_KEY");
      ShipmentOrderResponse shipmentOrder = intelipostClient.getShipmentOrder("1234-123");
  • Gerar Tracking Code ( GET - /tracking_code/{delivery_method_id}/{quantity} ), exemplo:

      IntelipostClient intelipostClient = new IntelipostClient("SUA_API_KEY");
      TrackingCodeRequest trackingCodeRequest = new TrackingCodeRequest(1, "5");
      TrackingCodeResponse trackingCodeResponse = intelipostClient.getTrackingCode(trackingCodeRequest);
  • Atualizar dados de rastreamento ( POST - /shipment_order/set_tracking_data ), exemplo:

      String newTrackingCode = "NEW_TRACKING_CODE";
      IntelipostClient intelipostClient = new IntelipostClient("SUA_API_KEY");
    
      ShipmentOrderResponse shipmentOrder = intelipostClient.getShipmentOrder("1234");
    
      shipmentOrder.getOrderVolumes().forEach(vol -> {
          TrackingDataRequest data = TrackingDataDSL.newTrackingDataDSL()
                      .orderNumber(shipmentOrder.getOrderNumber())
                    .withVolumes()
                      .volumeTrackingCode(vol.getVolumeNumber(), newTrackingCode)
                  .serialize();
    
          intelipostClient.updateTrackingData(data);
      });
  • Impressão das Etiquetas ( GET - /shipment_order/get_label/{pedido_envio}/{numero_volume} ), exemplo:

      IntelipostClient intelipostClient = new IntelipostClient("SUA_API_KEY");
      
      ShipmentOrderResponse shipmentOrder = intelipostClient.getShipmentOrder("3123");
      Integer volumeNumber = shipmentOrder.getOrderVolumes().stream().findFirst().get().getVolumeNumber();
      
      LabelResponse label = intelipostClient.getLabel(shipmentOrder.getOrderNumber(), volumeNumber);
  • Disparar Pré Lista de Postagem por Volume ( POST - /pre_shipment_list/send_volumes ), exemplo:

      IntelipostClient intelipostClient = new IntelipostClient("SUA_API_KEY");
      
      ShipmentOrderResponse shipmentOrder = intelipostClient.getShipmentOrder("3123");
      
      List<Long> shipmentOrderVolumesId = shipmentOrder.getOrderVolumes()
              .stream()
              .map(ShipmentOrderVolumeResponse::getVolumeId)
              .collect(toList());
    
      PlpRequest plp = PlpDSL.newPlp()
              .logisticProvider(1)
              .shipmentOrderVolumesId(shipmentOrderVolumesId)
              .serialize();
    
      intelipostClient.sendPlp(plp);

Stack

br.com.intelipost

Intelipost

E-Commerce Logistics Gateway

Versions

Version
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1