Giter Club home page Giter Club logo

sdk-java's Introduction

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

sdk-java's People

Contributors

jleber avatar

Watchers

Younes QUOULALI avatar

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.