Code Monkey home page Code Monkey logo

dhl-express-js's Introduction

DHL Express - MyDHL API js client

  • v2.4.0
  • Division: DHL Express

This is TypeScript/JavaScript client that utilizes axios.

Exampel usage:

import type {
  SupermodelIoLogisticsExpressAddressCreateShipmentRequest,
  SupermodelIoLogisticsExpressContact,
  SupermodelIoLogisticsExpressCreateShipmentRequest,
  SupermodelIoLogisticsExpressCreateShipmentResponse,
} from '@myorb/dhl-express';
import {
  ShipmentApi,
  SupermodelIoLogisticsExpressCreateShipmentRequestContentIncotermEnum,
  SupermodelIoLogisticsExpressCreateShipmentRequestContentUnitOfMeasurementEnum,
} from '@myorb/dhl-express';

export class DHLService {
  static async createShipping(req: SomeInput): Promise<SupermodelIoLogisticsExpressCreateShipmentResponse> {
    const config = {
      basePath?: string;
      username?: string;
      password?: string;
      apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
      accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
    };
    const dhlApi = new ShipmentApi(config);
    const body: SupermodelIoLogisticsExpressCreateShipmentRequest = {
      plannedShippingDateAndTime: '',
      pickup: {
        isRequested: true,
      },
      productCode: '',
      accounts: [],
      customerDetails: {
        shipperDetails: {
          postalAddress: {
            postalCode: '8888',
            cityName: 'Berlin',
            countryCode: 'DE',
            provinceCode: '',
            addressLine1: 'Alexander Platz 1',
            addressLine2: '',
            addressLine3: '',
            provinceName: '',
            countryName: 'Germany',
          },
          contactInformation: {
            phone: '0123456789',
            companyName: 'MyOrb',
            fullName: 'MyOrb',
          },
        },
        receiverDetails: {
          postalAddress: {
            postalCode: '8888',
            cityName: 'Munchen',
            countryCode: 'DE',
            provinceCode: '',
            addressLine1: 'Marienplatz 1',
            addressLine2: '',
            addressLine3: '',
            provinceName: '',
            countryName: 'Germany',
          },
          contactInformation: {
            phone: '0123456789',
            companyName: 'MyOrb',
            fullName: 'MyOrb',
          },
        },
      },
      content: {
        isCustomsDeclarable: false,
        description: 'DOCUMENTS',
        packages: [
          {
            weight: 0.3,
            dimensions: {
              length: 32,
              width: 23.8,
              height: 1,
            },
          },
        ],
        incoterm: SupermodelIoLogisticsExpressCreateShipmentRequestContentIncotermEnum.DAP,
        unitOfMeasurement: SupermodelIoLogisticsExpressCreateShipmentRequestContentUnitOfMeasurementEnum.Metric,
      },
    };
    const shipment = await dhlApi.expApiShipments(body);
    return shipment.data;
  }
}

Configuration

Name Type Default Description
basePath str https://express.api.dhl.com/mydhlapi/ The base URL that is going to be used for DHL API connections.
username str None The DHL API username to be used for authentication
password str None The DHL API password to be used for authentication
apiKey str None Can be used for authentication
accessToken str None Can be used for authentication

License

DHL API for Javascript is currently licensed under the Apache License, Version 2.0.

dhl-express-js's People

Contributors

myorb avatar

Stargazers

 avatar

Watchers

 avatar  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.