Giter VIP home page Giter VIP logo

cdek-api-library's Introduction

CDEK API library

Content

  1. Description
  2. Realisation
  3. Installation
  4. Usage

Description

This is a Golang library for working with the CDEK API. It allows you to easily create an order, validate an address, check the order status, calculate shipping prices based on package size and delivery addresses.

Realisation

  • Bearer Auth
  • Clean Architecture

Installation

To install the library, use the following command:

go get github.com/fshmit/CDEK-API-library

Usage

To use the library, first import it into your Go project:

import "github.com/fshmit/CDEK-API-library"

Next, create a new client with your CDEK account credentials:

client, err := cdek_api_lib.NewClient(username, password, testMode, apiAddress)
if err != nil {
// Handle error
}

The testMode parameter specifies whether to use CDEK's test API or the live API. The apiAddress parameter is the URL of the CDEK API.

You can then use the client to calculate shipping prices:

prices, err := client.Calculate(fromAddress, toAddress, packageSize)
if err != nil {
// Handle error
}

for _, price := range prices {
// Process price information
}

The fromAddress and toAddress parameters should be the delivery addresses in string format. The packageSize parameter should be a CDEK_API_lib.Size struct that specifies the dimensions and weight of the package.

To validate the address you can use the same client. Method will switch API address just for validation and return original API url back:

res, uniformAddr, err := client.ValidateAddress(addrFrom)

To create the order you can use the same client. Method will change API url for itself:

orderId, err := client.CreateOrder(addrFrom, addrTo, size, tariffCode)

To check the order status you can use the same client. You will also need the uuid of the order(which you get from CreateOrder):

status, err := client.GetStatus(orderId)

cdek-api-library's People

Contributors

fshmidt avatar

Watchers

 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.