0.0.2 • Published 3 months ago

gsl-correios-plugin v0.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 months ago

Plugin de Correios Plugin Vendure

Este é um plugin para o framework de e-commerce Vendure Para integração com os Correios, Ele lida com cálculos relacionados a envio de produtos, como cálculo de cubagem e peso, consulta de serviços disponíveis, cálculo de prazo de entrega, entre outros. O motivo de usá-lo seria facilitar a integração do seu sistema com os serviços dos Correios, permitindo que você automatize tarefas relacionadas ao envio de produtos, como calcular o preço do frete, o prazo de entrega, e outras informações úteis em seus projetos Gseller.

Após configurar o seu projeto Vendure, você pode usar este plugin via npm install:

npm install correios-plugin

e inclua-o no arquivo vendure-config conforme abaixo:

import { CorreiosPlugin } from "correios-plugin";
...
export const config: VendureConfig = {
  ...
  plugins: [
    ...,
	CorreiosPlugin
  ]
}

Os tipos, entradas atualizadas após a instalação do plugin são:

Shop Api Main Type

   type CubicInfoNotRegisteredError {
    errorCode: String!
    message: String!
  }

  type ErrorCorreios {
    endNote: String
    error: String
    errorMessage: String
  }

  type SearchByCepResponse {
    ZipCode: String!
    Street: String!
    Neighborhood: String
    Locality: String!
    State: String!
  }

  type ServicesCodeResponse {
    code: String
    description: String
    segmentCode: String
    segmentDescription: String
  }

  type DeliveryTimeResponse {
    codeService: Float
    deliveryTime: Int
    maxDate: String
    homeDelivery: Boolean
    SaturdayDelivery: Boolean
  }

  type PriceTimeResponse {
    coProduto: String
    pcBase: String
    pcBaseGeral: String
    peVariation: String
    pcReference: String
    vlTaxableBase: String
    inCubicWeight: Boolean
    psCharged: String
    peAdValorem: String
    vlAutomaticInsurance: String
    qtAdditional: String
    pcRange: String
    pcRangeVariation: String
    pcProduct: String
    pcFinal: String
  }

  type ConsultPriceAndTimeResponseBase {
    deliveryTime: DeliveryTimeResponse
    deliveryPrice: PriceTimeResponse
  }

Shop Api Schema Inputs

  input PriceTimeResponseInput {
    "Product or service code"
    serviceCode: String

    "Post destination zip code."
    destinationZipCode: String

    "Products variant ids."
    ProductVariantInput: [ProductIds]
  }

  input ProductIds {
    productVariantId: ID!
    quantity: String
  }

  input DeliveryTimeInput {
    "Service code that will be used to calculate the price."
    serviceCode: String!

    "Destination zip code."
    destinationZipCode: String!

    "Date that will be used to calculate the price. DD-MM-YYYY"
    eventDate: String
  }

  input GetDeliveryTimeForProductVariantIdsInput {
    productVariantIds: [ID!]!
  }

  input SearchByCepInput {
    cep: String!
  }

  input FetchPriceTimeInput {
    productVariantId: ID!
    sCepOrigin: String!
    sCepDestination: String!
    # nWeight: String!
    # nFormatCode: String!
    # nLength: String
    # nHeight: String
    # nWidth: String
    nServiceCode: String
    nDiameter: String
    nCompanyCode: String
    sPassword: String
    sOwnHandCode: String
    nDeclaredValue: String
    sReceiptNoticeCode: String
    nCalculateIndication: String
  }

Shop Api Schema Unions

  union CorreiosResponse = CubicInfoNotRegisteredError | PriceTimeResponse
  union ConsultPriceAndTimeResponse = CubicInfoNotRegisteredError | ConsultPriceAndTimeResponseBase

Shop Query

  extend type Query {
    "Consult the postal code information."
    searchByCep(input: SearchByCepInput!): SearchByCepResponse!

    "Consult all services available in the Correios API in contract in use."
    consultServicesCodeList: [ServicesCodeResponse]!

    "Consult the delivery time of the order based on the postal code."
    deliveryTime(input: DeliveryTimeInput!): DeliveryTimeResponse!

    "Consult the delivery values of orders based on the postal api."
    consultPrice(input: PriceTimeResponseInput!): CorreiosResponse!

    "Consult the delivery time and price of orders based on the postal api."
    consultPriceAndTime(
      input: PriceTimeResponseInput!
    ): ConsultPriceAndTimeResponse!
  }