-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Molodkovets Bogdan
committed
Jul 19, 2019
0 parents
commit f4da9b0
Showing
56 changed files
with
13,951 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
vendor | ||
.idea/ | ||
|
||
# binary | ||
cdek | ||
|
||
# go test -coverprofile cover.out | ||
cover.out | ||
# go tool cover -html=cover.out -o cover.html | ||
cover.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
run: | ||
# timeout for analysis, e.g. 30s, 5m, default is 1m | ||
deadline: 2m | ||
linters: | ||
enable-all: true | ||
disable: | ||
- scopelint | ||
- dupl | ||
linters-settings: | ||
misspell: | ||
locale: US | ||
issues: | ||
max-same: 0 | ||
max-per-linter: 0 | ||
exclude-use-default: false | ||
exclude: | ||
# gosec: Duplicated errcheck checks | ||
- G104 | ||
# gosec: Variable url | ||
- G107 | ||
# gosec: md5 needed by CDEK | ||
- G501 | ||
# gosec: md5 needed by CDEK | ||
- G401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Contributing | ||
|
||
Feel free to browse the open issues and file new ones, all feedback welcome! | ||
|
||
We follow the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). | ||
|
||
We generally follow the standard [github pull request](https://help.github.com/articles/about-pull-requests/) process | ||
|
||
All changes must be code reviewed. | ||
Expect reviewers to request that you avoid [common go style | ||
mistakes](https://github.com/golang/go/wiki/CodeReviewComments) in your pull requests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 vseinstrumenti.ru | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# GO SDK for CDEK API | ||
[![GoDoc reference](https://godoc.org/github.com/vseinstrumentiru/CDEK?status.svg)](https://godoc.org/github.com/vseinstrumentiru/CDEK) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/vseinstrumentiru/CDEK)](https://goreportcard.com/report/github.com/vseinstrumentiru/CDEK) | ||
[![GitHub release](https://img.shields.io/github/release/vseinstrumentiru/cdek.svg)](https://github.com/vseinstrumentiru/CDEK/releases) | ||
|
||
The Go language implementation of SDK for [integration with CDEK](https://www.cdek.ru/clients/integrator.html) | ||
|
||
---- | ||
Installation | ||
------------ | ||
|
||
To install this package, you need to install Go and setup your Go workspace on | ||
your computer. The simplest way to install the library is to run: | ||
|
||
``` | ||
$ go get github.com/vseinstrumentiru/cdek | ||
``` | ||
With Go module support (Go 1.11+), simply `import "github.com/vseinstrumentiru/cdek"` in | ||
your source code and `go [build|run|test]` will automatically download the | ||
necessary dependencies ([Go modules | ||
ref](https://github.com/golang/go/wiki/Modules)). | ||
|
||
Documentation | ||
------------- | ||
- See [godoc](https://godoc.org/github.com/vseinstrumentiru/CDEK) for package and API | ||
descriptions and examples. | ||
|
||
Example | ||
------------- | ||
You cat get test `clientAccount` and `clientSecurePassword` from [the official CDEK documentation](https://confluence.cdek.ru/pages/viewpage.action?pageId=20264477#DataExchangeProtocol(v1.5)-TestAccount) | ||
``` | ||
clientConf := NewClientConf("https://integration.edu.cdek.ru/") | ||
clientConf.SetAuth(clientAccount, clientSecurePassword) | ||
client := cdek.NewClient(clientConf) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- [ ] расчёт тарифов и обращения к справочникам | ||
- [X] расчёт стоимости доставки по тарифам с приоритетом | ||
- [ ] расчёт стоимости по тарифам без приоритета | ||
- [X] получение списка пунктов выдачи заказов (ПВЗ) с фильтрацией | ||
- [X] получение списка регионов-субъектов РФ | ||
- [X] получение списка городов | ||
- [ ] управление заказами | ||
- [X] формирование новых заказов от ИМ | ||
- [ ] оформление заказов на доставку | ||
- [ ] получение квитанции в PDF | ||
- [ ] получение почтовых этикеток в PDF | ||
- [X] удаление заказов | ||
- [X] изменение заказов | ||
- [ ] получение информации по заказам (отчёт «Информация по заказам») | ||
- [ ] трекинг заказов (отчёт «Статусы заказов») | ||
- [ ] прозвон получателя | ||
- [ ] вызов курьера | ||
- [ ] создание преалерта | ||
- [X] выбор базового URL интерфейса |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package cdek | ||
|
||
//Good Location's dimension | ||
type Good struct { | ||
Weight float64 `json:"weight"` | ||
Length int `json:"length"` | ||
Width int `json:"width"` | ||
Height int `json:"height"` | ||
Volume float64 `json:"volume"` | ||
} | ||
|
||
//ServiceReq List of additional service | ||
type ServiceReq struct { | ||
ID int `json:"id"` | ||
Param int `json:"param,omitempty"` | ||
} | ||
|
||
//ServiceResp List of transmitted additional services | ||
type ServiceResp struct { | ||
ID int `json:"id"` | ||
Title string `json:"title"` | ||
Price float64 `json:"price"` | ||
Rate float64 `json:"rate,omitempty"` | ||
} | ||
|
||
//GetCostReq Cost calculation on tariffs with priority request | ||
type GetCostReq struct { | ||
securableJSON | ||
Version *string `json:"version"` | ||
SenderCityID *int `json:"senderCityId"` | ||
ReceiverCityID *int `json:"receiverCityId"` | ||
TariffID *int `json:"tariffId"` | ||
Goods []*Good `json:"goods"` | ||
Services []*ServiceReq `json:"services,omitempty"` | ||
} | ||
|
||
type getCostResp struct { | ||
ErrorResp []Error `json:"error,omitempty"` | ||
Result GetCostRespResult `json:"result"` | ||
} | ||
|
||
//GetCostRespResult Cost calculation on tariffs with priority result response | ||
type GetCostRespResult struct { | ||
Price float64 `json:"price,string"` | ||
DeliveryPeriodMin int `json:"deliveryPeriodMin"` | ||
DeliveryPeriodMax int `json:"deliveryPeriodMax"` | ||
DeliveryDateMin string `json:"deliveryDateMin"` | ||
DeliveryDateMax string `json:"deliveryDateMax"` | ||
TariffID int `json:"tariffId"` | ||
CashOnDelivery float64 `json:"cashOnDelivery"` | ||
PriceByCurrency float64 `json:"priceByCurrency"` | ||
Currency string `json:"currency"` | ||
PercentVAT int `json:"percentVAT"` | ||
Services []ServiceResp `json:"services"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cdek | ||
|
||
const apiVersion = "1.0" | ||
|
||
//NewGetCostReq create new instance of GetCostReq | ||
func NewGetCostReq(senderCityID int, receiverCityID int, tariffID int) *GetCostReq { | ||
apiVersion := apiVersion | ||
|
||
return &GetCostReq{ | ||
Version: &apiVersion, | ||
SenderCityID: &senderCityID, | ||
ReceiverCityID: &receiverCityID, | ||
TariffID: &tariffID, | ||
} | ||
} | ||
|
||
//AddService add service to request | ||
func (getCostReq *GetCostReq) AddService(service ServiceReq) *GetCostReq { | ||
if getCostReq.Services == nil { | ||
getCostReq.Services = []*ServiceReq{} | ||
} | ||
|
||
getCostReq.Services = append(getCostReq.Services, &service) | ||
|
||
return getCostReq | ||
} | ||
|
||
//AddGood add good to request | ||
func (getCostReq *GetCostReq) AddGood(good Good) *GetCostReq { | ||
if getCostReq.Goods == nil { | ||
getCostReq.Goods = []*Good{} | ||
} | ||
|
||
getCostReq.Goods = append(getCostReq.Goods, &good) | ||
|
||
return getCostReq | ||
} |
Oops, something went wrong.