cdek

package module
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2022 License: MIT Imports: 15 Imported by: 0

README

GO SDK for CDEK API

GoDoc reference Build Status Coverage Status Go Report Card GitHub release CII Best Practices

The Go language implementation of SDK for integration with CDEK


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

Documentation

  • See godoc for package and API descriptions and examples.

Example

You cat get test clientAccount and clientSecurePassword from the official CDEK documentation

import "github.com/vseinstrumentiru/cdek"
...

client := cdek.NewClient("https://integration.edu.cdek.ru/").
    SetAuth(clientAccount, clientSecurePassword)

cities, err := client.GetCities(map[cdek.CityFilter]string{
    cdek.CityFilterPage: "1",
})

Documentation

Index

Examples

Constants

View Source
const (
	//TypePvz только склады СДЭК
	TypePvz string = "PVZ"

	//TypePostomat постоматы партнёра
	TypePostomat string = "POSTOMAT"

	//TypeAll все ПВЗ не зависимо от их типа
	TypeAll string = "ALL"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddService

type AddService struct {
	ServiceCode *int `xml:"ServiceCode,attr"`
	Count       *int `xml:"Count,attr,omitempty"`
}

AddService Additional services

func NewAddService

func NewAddService(serviceCode int) *AddService

NewAddService Additional services builder serviceCode: Type of additional service

func (*AddService) SetCount

func (addService *AddService) SetCount(count int) *AddService

SetCount Number of packages. It is used and is mandatory only for the additional service "Package 1".

type Address

type Address struct {
	Street  *string `xml:"Street,attr"`
	House   *string `xml:"House,attr"`
	Flat    *string `xml:"Flat,attr,omitempty"`
	Phone   *string `xml:"Phone,attr,omitempty"`
	PvzCode *string `xml:"PvzCode,attr,omitempty"`
}

Address Address of pickup

func NewAddress

func NewAddress(street string, house string) *Address

NewAddress Address of pickup builder

func (*Address) SetFlat

func (address *Address) SetFlat(flat string) *Address

SetFlat Flat/office

func (*Address) SetPhone

func (address *Address) SetPhone(phone string) *Address

SetPhone Sender's phone

func (*Address) SetPvzCode

func (address *Address) SetPvzCode(pvzCode string) *Address

SetPvzCode Pickup code. The attribute is required only for orders with the delivery mode “to warehouse”, provided that no additional service “Delivery in the receiver's city” is ordered. If the specified pickup point is closed at the time of order creation, the order will be accepted for the nearest functioning pickup point. The receiver will be notified about change of the pickup point via SMS. If all pickup points in the city that can provide the selected service are closed, order registration will be impossible. The relevant error message will be sent.

type Alert

type Alert struct {
	Type      string
	Msg       string
	ErrorCode string
}

Alert CDEK Alert model

func (*Alert) Error

func (a *Alert) Error() string

type AlertResponse

type AlertResponse struct {
	Alerts []*Alert
}

AlertResponse CDEK Alerts model

type Attempt

type Attempt struct {
	ID                  *int    `xml:"ID,attr"`
	ScheduleCode        *int    `xml:"ScheduleCode,attr"`
	ScheduleDescription *string `xml:"ScheduleDescription,attr"`
}

Attempt Delivery time taken from the delivery schedule

type Call

type Call struct {
	CallGood  *CallGood  `xml:"CallGood"`
	CallFail  *CallFail  `xml:"CallFail"`
	CallDelay *CallDelay `xml:"CallDelay"`
}

Call History of notification calls to the receiver

type CallCourier

type CallCourier struct {
	Call *CourierCallReq `xml:"Call"`
}

CallCourier Call courier

func NewCallCourier

func NewCallCourier(call CourierCallReq) *CallCourier

NewCallCourier Call courier builder call: Waiting for a courier

type CallDelay

type CallDelay struct {
	Delay []*CallDelayItem `xml:"Delay"`
}

CallDelay History of call reschedules

type CallDelayItem

type CallDelayItem struct {
	Date     *string `xml:"Date,attr"`
	DateNext *string `xml:"DateNext,attr"`
}

CallDelayItem Call reschedule

type CallFail

type CallFail struct {
	Fail []*CallFailItem `xml:"Fail"`
}

CallFail History of failed calls

type CallFailItem

type CallFailItem struct {
	Date              *string `xml:"Date,attr"`
	ReasonCode        *int    `xml:"ReasonCode,attr"`
	ReasonDescription *string `xml:"ReasonDescription,attr"`
}

CallFailItem Failed call

type CallGood

type CallGood struct {
	Good []*CallGoodItem `xml:"Good"`
}

CallGood History of successful calls

type CallGoodItem

type CallGoodItem struct {
	Date      *string `xml:"Date,attr"`
	DateDeliv *string `xml:"DateDeliv,attr"`
}

CallGoodItem Successful call

type ChangePeriod

type ChangePeriod struct {
	DateFirst *string `xml:"DateFirst,attr"`
	DateLast  *string `xml:"DateLast,attr"`
}

ChangePeriod The period during which the order status has changed.

func NewChangePeriod

func NewChangePeriod(dateFirst time.Time) *ChangePeriod

NewChangePeriod ChangePeriod builder dateFirst: start date of requested period

func (*ChangePeriod) SetDateLast

func (changePeriod *ChangePeriod) SetDateLast(date time.Time) *ChangePeriod

SetDateLast End date of requested period

type City

type City struct {
	CityUUID       *string  `json:"cityUuid"`
	CityName       *string  `json:"cityName"`
	CityCode       *string  `json:"cityCode"`
	Region         *string  `json:"region"`
	RegionCodeExt  *int     `json:"regionCodeExt,string"`
	RegionCode     *int     `json:"regionCode,string"`
	SubRegion      *string  `json:"subRegion"`
	Country        *string  `json:"country"`
	CountryCode    *string  `json:"countryCode"`
	Latitude       *float64 `json:"latitude"`
	Longitude      *float64 `json:"longitude"`
	Kladr          *string  `json:"kladr"`
	FiasGUID       *string  `json:"fiasGuid"`
	RegionFiasGUID *string  `json:"regionFiasGuid"`
	PaymentLimit   *float64 `json:"paymentLimit"`
}

City CDEK city model

type CityFilter

type CityFilter string

CityFilter filter key for "List of Cities" request

const (
	//CityFilterRegionCodeExt Код региона
	CityFilterRegionCodeExt CityFilter = "regionCodeExt"

	//CityFilterRegionCode Код региона в ИС СДЭК
	CityFilterRegionCode CityFilter = "regionCode"

	//CityFilterRegionFiasGUID Код региона из ФИАС
	CityFilterRegionFiasGUID CityFilter = "regionFiasGuid"

	//CityFilterPage Номер страницы выборки результата.По умолчанию 0
	CityFilterPage CityFilter = "page"

	//CityFilterSize Ограничение выборки результата.По умолчанию 1000
	CityFilterSize CityFilter = "size"

	//CityFilterCountryCode Код страны в формате ISO 3166-1 alpha-2
	CityFilterCountryCode CityFilter = "countryCode"

	//CityFilterCityName Название города
	CityFilterCityName CityFilter = "cityName"

	//CityFilterPostcode Почтовый индекс
	CityFilterPostcode CityFilter = "postcode"
)

type CityFilterBuilder

type CityFilterBuilder struct {
	// contains filtered or unexported fields
}

CityFilterBuilder builder for filer for "List of Cities" request

func (*CityFilterBuilder) AddFilter

func (filterBuilder *CityFilterBuilder) AddFilter(filter CityFilter, value string) *CityFilterBuilder

AddFilter add filter to set of filters for "List of Cities" request

func (*CityFilterBuilder) Filter

func (filterBuilder *CityFilterBuilder) Filter() map[CityFilter]string

Filter returns complete CityFilter for "List of Cities" request

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client SDK Client configuration

func (Client) CalculateDelivery

func (c Client) CalculateDelivery(ctx context.Context, req GetCostReq) (*GetCostRespResult, error)

CalculateDelivery Cost calculation on tariffs with priority.

Example
client := NewClient("https://integration.edu.cdek.ru/")
client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq")

ctx := context.TODO()
result, err := client.CalculateDelivery(ctx, *NewGetCostReq(61208, 2108, 10))

_, _ = result, err
Output:

func (Client) DeleteOrder

func (c Client) DeleteOrder(ctx context.Context, req DeleteOrderReq) (*DeleteOrderResp, error)

DeleteOrder The method is designed to cancel/delete an order at the client's initiative.

Example
client := NewClient("https://integration.edu.cdek.ru/")
client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq")

ctx := context.TODO()
result, err := client.DeleteOrder(ctx, *NewDeleteOrderReq(
	"number-soOEl0",
	1,
	*NewDeleteOrder().SetNumber("number-soOEl0"),
))

_, _ = result, err
Output:

func (Client) GetCities

func (c Client) GetCities(ctx context.Context, filter map[CityFilter]string) (*GetCitiesResp, error)

GetCities This method is used to load detailed information on cities.

Example
client := NewClient("https://integration.edu.cdek.ru/")
client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq")

ctx := context.TODO()
result, err := client.GetCities(ctx, map[CityFilter]string{
	CityFilterPage: "3",
})

_, _ = result, err
Output:

func (Client) GetPvzList

func (c Client) GetPvzList(ctx context.Context, filter map[PvzListFilter]string) ([]*Pvz, error)

GetPvzList The method is used to load the list of active pickup points, from which the client can pick up its order.

Example
client := NewClient("https://integration.edu.cdek.ru/")
client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq")

ctx := context.TODO()
result, err := client.GetPvzList(ctx, map[PvzListFilter]string{
	PvzListFilterCityID: "44",
})

_, _ = result, err
Output:

func (Client) GetRegions

func (c Client) GetRegions(ctx context.Context, filter map[RegionFilter]string) (*GetRegionsResp, error)

GetRegions This method is used to load detailed information on regions.

Example
client := NewClient("https://integration.edu.cdek.ru/")
client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq")

ctx := context.TODO()
result, err := client.GetRegions(ctx, map[RegionFilter]string{
	RegionFilterPage: "3",
})

_, _ = result, err
Output:

func (Client) GetStatusReport

func (c Client) GetStatusReport(ctx context.Context, statusReportReq StatusReport) (*StatusReportResp, error)

GetStatusReport This method is used to generate an order status report, including order change history.

func (Client) RegisterOrder

func (c Client) RegisterOrder(ctx context.Context, req RegisterOrderReq) (*RegisterOrderResp, error)

RegisterOrder This method is used to register orders to be delivered to clients.

Example
client := NewClient("https://integration.edu.cdek.ru/")
client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq")

exampleOrder := NewOrderReq("number-soOEl0", "name-soOEl0", "+79138739944", 139).
	SetSendCityCode(44).
	SetRecCityCode(44).
	SetComment("comment-soOEl0").
	SetDeliveryRecipientCost(0).
	SetDeliveryRecipientVATRate("VATX").
	SetDeliveryRecipientVATSum(0).
	SetRecipientEmail("no-reply@cdek.ru").
	SetAddress(*NewAddress("street-soOEl0", "house-soOEl0").
		SetFlat("flat-soOEl0"),
	).
	SetSender(*NewSender().
		SetCompany("company-soOEl0").
		SetName("Отправителев").
		SetAddress(*NewAddress("street-soOEl0", "house-soOEl0").
			SetFlat("flat-soOEl0"),
		).
		AddPhone("+79138739946").
		AddPhone("+79138739945"),
	).
	SetSeller(*NewSeller().
		SetAddress("street_soOEl0 1").
		SetName("seller-soOEl0").
		SetINN("111111111111").
		SetPhone("+79138739947").
		SetOwnershipForm(249),
	).
	AddPackage(*NewOrderPackage("soOEl00", "barcode-soOEl00", 100).
		SetSize(2, 3, 4).
		AddItem(*NewOrderPackageItem(2, "warekey-soOEl000", 8, 10, 1, "comment-soOEl000").
			SetPaymentVATRate("VATX").
			SetPaymentVATSum(0),
		),
	).
	SetDeliveryRecipientCostAdv(*NewDeliveryRecipientCostAdv(2000, 150).
		SetVATRate("vat10").
		SetVATSum(13.64),
	).
	SetAddService(*NewAddService(30)).
	SetSchedule(*NewSchedule().
		AddAttempt(*NewScheduleAttempt("soOEl00", time.Date(2019, 7, 19, 12, 0, 0, 0, time.UTC)).
			SetAddress(*NewAddress("street-prozvon_adr", "house-prozvon_adr").
				SetFlat("flat-prozvon_adr"),
			).
			SetTimeBeg("11:00:00").
			SetTimeEnd("13:00:00"),
		),
	)

ctx := context.TODO()
result, err := client.RegisterOrder(ctx, *NewDeliveryRequest("soOEl", 1, exampleOrder))

_, _ = result, err
Output:

func (*Client) SetAuth

func (c *Client) SetAuth(account, secure string) ServiceProvider

SetAuth set auth data

func (*Client) SetCalculatorURL

func (c *Client) SetCalculatorURL(calculatorURL string) ServiceProvider

SetCalculatorURL url for delivery calculation

func (Client) UpdateOrder

func (c Client) UpdateOrder(ctx context.Context, req UpdateOrderReq) (*UpdateOrderResp, error)

UpdateOrder This method is used to change a created order.

Example
client := NewClient("https://integration.edu.cdek.ru/")
client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq")

exampleOrderToUpdate := NewUpdateOrder().
	SetDeliveryRecipientCost(10.02).
	SetDeliveryRecipientVATRate("VATX").
	SetDeliveryRecipientVATSum(0.0).
	SetNumber("number-s785558445").
	SetPackage(*NewOrderPackage("soOEl00", "barcode-soOEl00", 100).
		SetSize(2, 3, 4).
		AddItem(*NewOrderPackageItem(2, "warekey-soOEl000", 8, 10, 1, "comment-soOEl000").
			SetPaymentVATRate("VATX").
			SetPaymentVATSum(0),
		),
	)

ctx := context.TODO()
result, err := client.UpdateOrder(ctx, *NewUpdateOrderReq("soOEl", 1, *exampleOrderToUpdate))

_, _ = result, err
Output:

type CourierCallReq

type CourierCallReq struct {
	Date             *string  `xml:"Date,attr"`
	TimeBeg          *string  `xml:"TimeBeg,attr"`
	TimeEnd          *string  `xml:"TimeEnd,attr"`
	LunchBeg         *string  `xml:"LunchBeg,attr"`
	LunchEnd         *string  `xml:"LunchEnd,attr"`
	SendCityCode     *int     `xml:"SendCityCode,attr"`
	SendCityPostCode *string  `xml:"SendCityPostCode,attr"`
	SendCountryCode  *string  `xml:"SendCountryCode,attr"`
	SendCityName     *string  `xml:"SendCityName,attr"`
	SendPhone        *string  `xml:"SendPhone,attr"`
	SenderName       *string  `xml:"SenderName,attr"`
	Comment          *string  `xml:"Comment,attr"`
	SendAddress      *Address `xml:"SendAddress"`
}

CourierCallReq Waiting for a courier

func NewCourierCall

func NewCourierCall(
	date time.Time,
	timeBeg string,
	timeEnd string,
	sendPhone string,
	senderName string,
	sendAddress Address,
) *CourierCallReq

NewCourierCall NewCourierCall builder date: Date of courier waiting timeBeg: Start time of courier waiting timeEnd: End time of courier waiting sendPhone: Sender's contact phone senderName: Sender (full name) sendAddress: Sender's address

func (*CourierCallReq) SetComment

func (call *CourierCallReq) SetComment(comment string) *CourierCallReq

SetComment Comment for courier

func (*CourierCallReq) SetLunchBeg

func (call *CourierCallReq) SetLunchBeg(lunchBeg string) *CourierCallReq

SetLunchBeg Start time of a lunch break, if it is within a time range [TimeBeg; TimeEnd]

func (*CourierCallReq) SetLunchEnd

func (call *CourierCallReq) SetLunchEnd(lunchEnd string) *CourierCallReq

SetLunchEnd End time of a lunch break, if it is within a time range [TimeBeg; TimeEnd]

func (*CourierCallReq) SetSendCityCode

func (call *CourierCallReq) SetSendCityCode(sendCityCode int) *CourierCallReq

SetSendCityCode Sender's city code from the CDEK base

func (*CourierCallReq) SetSendCityName

func (call *CourierCallReq) SetSendCityName(sendCityName string) *CourierCallReq

SetSendCityName Name of sender's city

func (*CourierCallReq) SetSendCityPostCode

func (call *CourierCallReq) SetSendCityPostCode(sendCityPostCode string) *CourierCallReq

SetSendCityPostCode Postal code of the sender's city

func (*CourierCallReq) SetSendCountryCode

func (call *CourierCallReq) SetSendCountryCode(sendCountryCode string) *CourierCallReq

SetSendCountryCode Sender's country code to identify a country by postal code

type CourierCallResp

type CourierCallResp struct {
	Error
	Number *string `xml:"Number,attr"`
}

CourierCallResp Call courier

type DelayReason

type DelayReason struct {
	Date        string  `xml:"Date,attr"`
	Code        int     `xml:"Code,attr"`
	Description string  `xml:"Description,attr"`
	State       []State `xml:"State"`
}

DelayReason Current delay reason

type DeleteOrder

type DeleteOrder struct {
	Number         *string `xml:"Number,attr"`
	DispatchNumber *int    `xml:"DispatchNumber,attr"`
}

DeleteOrder order model for deleting request

func NewDeleteOrder

func NewDeleteOrder() *DeleteOrder

NewDeleteOrder DeleteOrder constructor

func (*DeleteOrder) SetDispatchNumber

func (o *DeleteOrder) SetDispatchNumber(dispatchNumber int) *DeleteOrder

SetDispatchNumber CDEK order number

func (*DeleteOrder) SetNumber

func (o *DeleteOrder) SetNumber(number string) *DeleteOrder

SetNumber Client's shipment number. Order identifier in the IS of the CDEK client.

type DeleteOrderReq

type DeleteOrderReq struct {
	XMLName    xml.Name     `xml:"DeleteRequest"`
	Number     *string      `xml:"Number,attr"`
	OrderCount *int         `xml:"OrderCount,attr"`
	Order      *DeleteOrder `xml:"Order"`
	// contains filtered or unexported fields
}

DeleteOrderReq request structure for deleting order from CDEK

func NewDeleteOrderReq

func NewDeleteOrderReq(number string, orderCount int, order DeleteOrder) *DeleteOrderReq

NewDeleteOrderReq DeleteOrderReq constructor

type DeleteOrderResp

type DeleteOrderResp struct {
	Order []*OrderResp `xml:"Order"`
}

DeleteOrderResp response structure of deleting order from CDEK

type DeliveryRecipientCostAdv

type DeliveryRecipientCostAdv struct {
	Threshold *int     `xml:"Threshold,attr"`
	Sum       *float64 `xml:"Sum,attr"`
	VATRate   *string  `xml:"VATRate,attr,omitempty"`
	VATSum    *float64 `xml:"VATSum,attr,omitempty"`
}

DeliveryRecipientCostAdv Additional charge for delivery (E-shop charges the receiver), depending on the order’s sum

func NewDeliveryRecipientCostAdv

func NewDeliveryRecipientCostAdv(threshold int, sum float64) *DeliveryRecipientCostAdv

NewDeliveryRecipientCostAdv DeliveryRecipientCostAdv builder threshold: Goods price threshold (valid by condition less than or equal to), in even monetary units sum: Additional charge for delivery with total amount that falls within the interval

func (*DeliveryRecipientCostAdv) SetVATRate

SetVATRate VAT rate included in the additional charge for delivery. If the value is unknown, then default value “No VAT” is applied

func (*DeliveryRecipientCostAdv) SetVATSum

SetVATSum VAT sum included in the additional charge for delivery

type Error

type Error struct {
	ErrorCode *string `xml:"ErrorCode,attr,omitempty" json:"code"`
	Msg       *string `xml:"Msg,attr,omitempty" json:"text"`
}

Error error values in responses

func (Error) Error

func (e Error) Error() string

func (*Error) IsErroneous

func (e *Error) IsErroneous() bool

IsErroneous check if struct has error

type GetCitiesResp

type GetCitiesResp []*City

GetCitiesResp response struct for CDEK cities getter

type GetCostReq

type GetCostReq struct {
	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"`
	// contains filtered or unexported fields
}

GetCostReq Cost calculation on tariffs with priority request

func NewGetCostReq

func NewGetCostReq(senderCityID int, receiverCityID int, tariffID int) *GetCostReq

NewGetCostReq create new instance of GetCostReq

func (*GetCostReq) AddGood

func (getCostReq *GetCostReq) AddGood(good Good) *GetCostReq

AddGood add good to request

func (*GetCostReq) AddService

func (getCostReq *GetCostReq) AddService(service ServiceReq) *GetCostReq

AddService add service to request

type GetCostRespResult

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"`
}

GetCostRespResult Cost calculation on tariffs with priority result response

type GetRegionsResp

type GetRegionsResp []Region

GetRegionsResp List of Regions response

type Good

type Good struct {
	Weight float64 `json:"weight"`
	Length int     `json:"length"`
	Width  int     `json:"width"`
	Height int     `json:"height"`
	Volume float64 `json:"volume"`
}

Good Location's dimension

type Item

type Item struct {
	WareKey     *string `xml:"WareKey,attr"`
	Amount      *int    `xml:"Amount,attr"`
	DelivAmount *int    `xml:"DelivAmount,attr"`
}

Item Items

type OfficeImage

type OfficeImage struct {
	URL *string `xml:"url,attr"`
}

OfficeImage All photos of the office (except for a photo showing how to get to it)

type OrderPackage

type OrderPackage struct {
	Number  *string             `xml:"Number,attr"`
	BarCode *string             `xml:"BarCode,attr"`
	Weight  *int                `xml:"Weight,attr"`
	SizeA   *int                `xml:"SizeA,attr,omitempty"`
	SizeB   *int                `xml:"SizeB,attr,omitempty"`
	SizeC   *int                `xml:"SizeC,attr,omitempty"`
	Item    []*OrderPackageItem `xml:"Item"`
}

OrderPackage Package (all packages are sent with different Package tags)

func NewOrderPackage

func NewOrderPackage(number string, barCode string, weight int) *OrderPackage

NewOrderPackage OrderPackage builder number: Package number (ordinal package number or order number can be used), unique for this order. Order identifier in the Client's IS. barCode: Package barcode, package identifier (if any); otherwise, transmit a value of the package number: Packege.Number). The parameter is used to handle the cargo at CDEK warehouses), unique for this order. Package identifier in the Client's IS. weight: Total weight (in grams)

func (*OrderPackage) AddItem

func (orderPackage *OrderPackage) AddItem(item OrderPackageItem) *OrderPackage

AddItem Add OrderPackageItem to OrderPackageItems list

func (*OrderPackage) SetSize

func (orderPackage *OrderPackage) SetSize(length int, width int, height int) *OrderPackage

SetSize Package dimensions length: Length (in centimeters) width: Width (in centimeters) height: Height (in centimeters)

type OrderPackageItem

type OrderPackageItem struct {
	Amount         *int     `xml:"Amount,attr"`
	WareKey        *string  `xml:"WareKey,attr"`
	Cost           *float64 `xml:"Cost,attr"`
	Payment        *float64 `xml:"Payment,attr"`
	PaymentVATRate *string  `xml:"PaymentVATRate,attr,omitempty"`
	PaymentVATSum  *float64 `xml:"PaymentVATSum,attr,omitempty"`
	Weight         *int     `xml:"Weight,attr"`
	Comment        *string  `xml:"Comment,attr"`
	WeightBrutto   *int     `xml:"WeightBrutto,attr,omitempty"`
	CommentEx      *string  `xml:"CommentEx,attr,omitempty"`
	Link           *string  `xml:"Link,attr,omitempty"`
}

OrderPackageItem Items (goods)

func NewOrderPackageItem

func NewOrderPackageItem(
	amount int,
	wareKey string,
	cost float64,
	payment float64,
	weight int,
	comment string,
) *OrderPackageItem

NewOrderPackageItem OrderPackageItem builder amount: Quantity of goods of the same type (pcs). The maximum number is 999. wareKey: Identifier/item number of the goods (Unique for this Package). cost: Declared value of the goods (per item in the specified currency, value >=0). This value is used to calculate the amount of insurance. payment: Cash on delivery (per item in the specified currency, value >=0) — cash on delivery; in case of prepayment, value = 0. weight: Weight (per item, in grams) comment: Name of the goods (may contain description of the goods: size, color)

func (*OrderPackageItem) SetCommentEx

func (item *OrderPackageItem) SetCommentEx(commentEx string) *OrderPackageItem

SetCommentEx Name of the goods, in English (also can contain description of the goods, such as size and color). Only for international orders.

func (item *OrderPackageItem) SetLink(link string) *OrderPackageItem

SetLink Link to the e-shop’s website with the goods’ description. Only for international orders.

func (*OrderPackageItem) SetPaymentVATRate

func (item *OrderPackageItem) SetPaymentVATRate(paymentVATRate string) *OrderPackageItem

SetPaymentVATRate VAT rate included in the value of the goods

func (*OrderPackageItem) SetPaymentVATSum

func (item *OrderPackageItem) SetPaymentVATSum(paymentVATSum float64) *OrderPackageItem

SetPaymentVATSum VAT amount included in the value (payment) of the goods.

func (*OrderPackageItem) SetWeightBrutto

func (item *OrderPackageItem) SetWeightBrutto(weightBrutto int) *OrderPackageItem

SetWeightBrutto Gross weight (for one unit of goods, in grams). Only for international orders.

type OrderReq

type OrderReq struct {
	Number                   *string                   `xml:"Number,attr"`
	SendCityCode             *int                      `xml:"SendCityCode,attr"`
	RecCityCode              *int                      `xml:"RecCityCode,attr"`
	SendCityPostCode         *int                      `xml:"SendCityPostCode,attr"`
	RecCityPostCode          *int                      `xml:"RecCityPostCode,attr"`
	SendCountryCode          *int                      `xml:"SendCountryCode,attr,omitempty"`
	RecCountryCode           *int                      `xml:"RecCountryCode,attr,omitempty"`
	SendCityName             *string                   `xml:"SendCityName,attr,omitempty"`
	RecCityName              *string                   `xml:"RecCityName,attr,omitempty"`
	RecipientINN             *string                   `xml:"RecipientINN,attr,omitempty"`
	DateInvoice              *string                   `xml:"DateInvoice,attr,omitempty"`
	ShipperName              *string                   `xml:"ShipperName,attr,omitempty"`
	ShipperAddress           *string                   `xml:"ShipperAddress,attr,omitempty"`
	Passport                 *Passport                 `xml:"Passport,omitempty"`
	Sender                   *Sender                   `xml:"Sender,omitempty"`
	RecipientName            *string                   `xml:"RecipientName,attr"`
	RecipientEmail           *string                   `xml:"RecipientEmail,attr,omitempty"`
	Phone                    *string                   `xml:"Phone,attr"`
	TariffTypeCode           *int                      `xml:"TariffTypeCode,attr"`
	DeliveryRecipientCost    *float64                  `xml:"DeliveryRecipientCost,attr,omitempty"`
	DeliveryRecipientVATRate *string                   `xml:"DeliveryRecipientVATRate,attr,omitempty"`
	DeliveryRecipientVATSum  *float64                  `xml:"DeliveryRecipientVATSum,attr,omitempty"`
	RecipientCurrency        *string                   `xml:"RecipientCurrency,attr,omitempty"`
	ItemsCurrency            *string                   `xml:"ItemsCurrency,attr,omitempty"`
	Seller                   *Seller                   `xml:"Seller,omitempty"`
	Comment                  *string                   `xml:"Comment,attr,omitempty"`
	Address                  *Address                  `xml:"Address,omitempty"`
	Package                  []*OrderPackage           `xml:"Package,omitempty"`
	DeliveryRecipientCostAdv *DeliveryRecipientCostAdv `xml:"DeliveryRecipientCostAdv,omitempty"`
	AddService               *AddService               `xml:"AddService,omitempty"`
	Schedule                 *Schedule                 `xml:"Schedule,omitempty"`
}

OrderReq Shipment (order)

func NewOrderReq

func NewOrderReq(number string, recipientName string, phone string, tariffTypeCode int) *OrderReq

NewOrderReq Shipment (order) builder number: Client shipment number (unique for orders of a particular Client). Order identifier in the Client's IS recipientName: Receiver (full name). At least 3 characters. phone: Receiver's phone tariffTypeCode: Code of tariff type

func (*OrderReq) AddPackage

func (orderReq *OrderReq) AddPackage(pack OrderPackage) *OrderReq

AddPackage Package (all packages are sent with different Package tags)

func (*OrderReq) SetAddService

func (orderReq *OrderReq) SetAddService(addService AddService) *OrderReq

SetAddService Additional services

func (*OrderReq) SetAddress

func (orderReq *OrderReq) SetAddress(address Address) *OrderReq

SetAddress Depending on a delivery mode, it is necessary to specify either Street, House, Flat attributes (delivery to the receiver's address) or PvzCode (pickup)

func (*OrderReq) SetComment

func (orderReq *OrderReq) SetComment(comment string) *OrderReq

SetComment Comments (special notes on the order)

func (*OrderReq) SetDateInvoice

func (orderReq *OrderReq) SetDateInvoice(dateInvoice time.Time) *OrderReq

SetDateInvoice Invoice date. Only for international orders.

func (*OrderReq) SetDeliveryRecipientCost

func (orderReq *OrderReq) SetDeliveryRecipientCost(deliveryRecipientCost float64) *OrderReq

SetDeliveryRecipientCost Extra delivery charge collected by the online store from the receiver (in the specified currency)

func (*OrderReq) SetDeliveryRecipientCostAdv

func (orderReq *OrderReq) SetDeliveryRecipientCostAdv(deliveryRecipientCostAdv DeliveryRecipientCostAdv) *OrderReq

SetDeliveryRecipientCostAdv Additional charge for delivery (E-shop charges the receiver), depending on the order’s sum

func (*OrderReq) SetDeliveryRecipientVATRate

func (orderReq *OrderReq) SetDeliveryRecipientVATRate(deliveryRecipientVATRate string) *OrderReq

SetDeliveryRecipientVATRate VAT rate included in the extra delivery charge

func (*OrderReq) SetDeliveryRecipientVATSum

func (orderReq *OrderReq) SetDeliveryRecipientVATSum(deliveryRecipientVATSum float64) *OrderReq

SetDeliveryRecipientVATSum VAT amount included in the extra delivery charge

func (*OrderReq) SetItemsCurrency

func (orderReq *OrderReq) SetItemsCurrency(itemsCurrency string) *OrderReq

SetItemsCurrency Code of declared value currency (all items in the order). Currency of settlements with the CDEK Client under contract.

func (*OrderReq) SetPassport

func (orderReq *OrderReq) SetPassport(passport Passport) *OrderReq

SetPassport Details of the receiver’s passport. Used to print waybills. Only for international orders.

func (*OrderReq) SetRecCityCode

func (orderReq *OrderReq) SetRecCityCode(recCityCode int) *OrderReq

SetRecCityCode Receiver's city code from the CDEK base

func (*OrderReq) SetRecCityName

func (orderReq *OrderReq) SetRecCityName(recCityName string) *OrderReq

SetRecCityName Name of receiver's city

func (*OrderReq) SetRecCityPostCode

func (orderReq *OrderReq) SetRecCityPostCode(recCityPostCode int) *OrderReq

SetRecCityPostCode Postal code of the receiver's city

func (*OrderReq) SetRecCountryCode

func (orderReq *OrderReq) SetRecCountryCode(recCountryCode int) *OrderReq

SetRecCountryCode Receiver's country code to identify a country by postal code. Default value: RU

func (*OrderReq) SetRecipientCurrency

func (orderReq *OrderReq) SetRecipientCurrency(recipientCurrency string) *OrderReq

SetRecipientCurrency Code of cash-on-delivery currency: extra delivery charge and payment for the goods to be collected from the receiver. The currency is considered to be a currency of the receiver's country

func (*OrderReq) SetRecipientEmail

func (orderReq *OrderReq) SetRecipientEmail(recipientEmail string) *OrderReq

SetRecipientEmail Receiver's email for sending order status notifications and contacting in case of failed calls

func (*OrderReq) SetRecipientINN

func (orderReq *OrderReq) SetRecipientINN(recipientINN string) *OrderReq

SetRecipientINN TIN of the receiver. Only for international orders.

func (*OrderReq) SetSchedule

func (orderReq *OrderReq) SetSchedule(schedule Schedule) *OrderReq

SetSchedule Schedule for delivery/pickup

func (*OrderReq) SetSeller

func (orderReq *OrderReq) SetSeller(seller Seller) *OrderReq

SetSeller Requisites of the real seller

func (*OrderReq) SetSendCityCode

func (orderReq *OrderReq) SetSendCityCode(sendCityCode int) *OrderReq

SetSendCityCode Sender's city code from the CDEK base

func (*OrderReq) SetSendCityName

func (orderReq *OrderReq) SetSendCityName(sendCityName string) *OrderReq

SetSendCityName Name of sender's city

func (*OrderReq) SetSendCityPostCode

func (orderReq *OrderReq) SetSendCityPostCode(sendCityPostCode int) *OrderReq

SetSendCityPostCode Postal code of the sender's city

func (*OrderReq) SetSendCountryCode

func (orderReq *OrderReq) SetSendCountryCode(sendCountryCode int) *OrderReq

SetSendCountryCode Sender's country code to identify a country by postal code. Default value: RU

func (*OrderReq) SetSender

func (orderReq *OrderReq) SetSender(sender Sender) *OrderReq

SetSender Sender. Must be defined if it is different from the online store Client. If the online store is a sender, the Sender tag is not available.

func (*OrderReq) SetShipperAddress

func (orderReq *OrderReq) SetShipperAddress(shipperAddress string) *OrderReq

SetShipperAddress Shipper’s address. Used to print waybills. Only for international orders

func (*OrderReq) SetShipperName

func (orderReq *OrderReq) SetShipperName(shipperName string) *OrderReq

SetShipperName Shipper. Used to print waybills. Only for international orders.

type OrderResp

type OrderResp struct {
	Error
	DispatchNumber *int    `xml:"DispatchNumber,attr"`
	Number         *string `xml:"Number,attr"`
}

OrderResp Order

func (*OrderResp) GetError

func (o *OrderResp) GetError() error

GetError returns error supplemented with order data

type Package

type Package struct {
	Number  *string `xml:"Number,attr"`
	BarCode *string `xml:"BarCode,attr"`
	Item    []*Item `xml:"Item"`
}

Package Package

type Passport

type Passport struct {
	Series    *string `xml:"Series,attr"`
	Number    *string `xml:"Number,attr"`
	IssueDate *string `xml:"IssueDate,attr"`
	IssuedBy  *string `xml:"IssuedBy,attr"`
	DateBirth *string `xml:"DateBirth,attr"`
}

Passport Details of the receiver’s passport. Used to print waybills. Only for international orders.

func NewPassport

func NewPassport() *Passport

NewPassport Passport builder

func (*Passport) SetDateBirth

func (passport *Passport) SetDateBirth(dateBirth time.Time) *Passport

SetDateBirth The receiver’s birthdate

func (*Passport) SetIssueDate

func (passport *Passport) SetIssueDate(issueDate time.Time) *Passport

SetIssueDate Date of issue of the receiver’s passport.

func (*Passport) SetIssuedBy

func (passport *Passport) SetIssuedBy(issuedBy string) *Passport

SetIssuedBy Issuing authority of the receiver’s passport.

func (*Passport) SetNumber

func (passport *Passport) SetNumber(number string) *Passport

SetNumber Number of the receiver’s passport.

func (*Passport) SetSeries

func (passport *Passport) SetSeries(series string) *Passport

SetSeries Series of the receiver’s passport.

type Pvz

type Pvz struct {
	Code           *string        `xml:"Code,attr"`
	PostalCode     *string        `xml:"PostalCode,attr"`
	Name           *string        `xml:"Name,attr"`
	CountryCode    *string        `xml:"CountryCode,attr"`
	CountryCodeIso *string        `xml:"countryCodeIso,attr"`
	CountryName    *string        `xml:"CountryName,attr"`
	RegionCode     *string        `xml:"RegionCode,attr"`
	RegionName     *string        `xml:"RegionName,attr"`
	CityCode       *int           `xml:"CityCode,attr"`
	City           *string        `xml:"City,attr"`
	WorkTime       *string        `xml:"WorkTime,attr"`
	Address        *string        `xml:"Address,attr"`
	FullAddress    *string        `xml:"FullAddress,attr"`
	AddressComment *string        `xml:"AddressComment,attr"`
	Phone          *string        `xml:"Phone,attr"`
	Email          *string        `xml:"Email,attr"`
	QqID           *string        `xml:"qqId,attr"`
	Note           *string        `xml:"Note,attr"`
	CoordX         *float64       `xml:"coordX,attr"`
	CoordY         *float64       `xml:"coordY,attr"`
	Type           *string        `xml:"Type,attr"`
	OwnerCode      *string        `xml:"ownerCode,attr"`
	IsDressingRoom *bool          `xml:"IsDressingRoom,attr"`
	HaveCashless   *bool          `xml:"HaveCashless,attr"`
	AllowedCod     *bool          `xml:"AllowedCod,attr"`
	NearestStation *string        `xml:"NearestStation,attr"`
	MetroStation   *string        `xml:"MetroStation,attr"`
	Site           *string        `xml:"Site,attr"`
	OfficeImage    []*OfficeImage `xml:"OfficeImage"`
	WorkTimeY      []*WorkTimeY   `xml:"WorkTimeY"`
	WeightLimit    *WeightLimit   `xml:"WeightLimit"`
}

Pvz List of Pickup Points

type PvzListFilter

type PvzListFilter string

PvzListFilter key for filtering pvzList

const (
	//PvzListFilterCityPostCode Почтовый индекс города, для которого необходим список ПВЗ
	PvzListFilterCityPostCode PvzListFilter = "citypostcode"

	//PvzListFilterCityID Код города по базе СДЭК
	PvzListFilterCityID PvzListFilter = "cityid"

	//PvzListFilterType Тип пункта выдачи, по умолчанию «PVZ».
	PvzListFilterType PvzListFilter = "type"

	//PvzListFilterCountryID Код страны по базе СДЭК
	PvzListFilterCountryID PvzListFilter = "countryid"

	//PvzListFilterCountryIso Код страны в формате ISO_3166-1_alpha-2
	PvzListFilterCountryIso PvzListFilter = "countryiso"

	//PvzListFilterRegionID Код региона по базе СДЭК
	PvzListFilterRegionID PvzListFilter = "regionid"

	//PvzListFilterHaveCashless Наличие терминала оплаты («1», «true» - есть; «0», «false» - нет.)
	PvzListFilterHaveCashless PvzListFilter = "havecashless"

	//PvzListFilterAllowedCod Разрешен наложенный платеж («1», «true» - да; «0», «false» - нет.)
	PvzListFilterAllowedCod PvzListFilter = "allowedcod"

	//PvzListFilterIsDressingRoom Наличие примерочной («1», «true» - есть; «0», «false» - нет.)
	PvzListFilterIsDressingRoom PvzListFilter = "isdressingroom"

	//PvzListFilterWeightMax Максимальный вес, который может принять ПВЗ
	PvzListFilterWeightMax PvzListFilter = "weightmax"

	//PvzListFilterLang Локализация ПВЗ. По-умолчанию "rus"
	PvzListFilterLang PvzListFilter = "lang"

	//PvzListFilterTakeOnly Является ли ПВЗ только пунктом выдачи («1», «true» - да; «0», «false» - нет.)
	PvzListFilterTakeOnly PvzListFilter = "takeonly"
)

type PvzListFilterBuilder

type PvzListFilterBuilder struct {
	// contains filtered or unexported fields
}

PvzListFilterBuilder builder for pvzList filter

func (*PvzListFilterBuilder) AddFilter

func (filterBuilder *PvzListFilterBuilder) AddFilter(filter PvzListFilter, value string) *PvzListFilterBuilder

AddFilter adds filter for pvzList filter

func (PvzListFilterBuilder) Filter

func (filterBuilder PvzListFilterBuilder) Filter() map[PvzListFilter]string

Filter returns complete filter

type Reason

type Reason struct {
	Date        string `xml:"Date,attr"`
	Code        int    `xml:"Code,attr"`
	Description string `xml:"Description,attr"`
}

Reason Current additional status

type Region

type Region struct {
	RegionUUID     *string `json:"regionUuid"`
	RegionName     *string `json:"regionName"`
	Prefix         *string `json:"prefix,omitempty"`
	RegionCodeExt  *int    `json:"regionCodeExt,string,omitempty"`
	RegionCode     *int    `json:"regionCode,string,omitempty"`
	RegionFiasGUID *string `json:"regionFiasGuid,omitempty"`
	CountryName    *string `json:"countryName"`
	CountryCode    *string `json:"countryCode,omitempty"`
	CountryCodeExt *int    `json:"countryCodeExt,omitempty,string"`
}

Region Region response

type RegionFilter

type RegionFilter string

RegionFilter filter key for "List of Regions" request

const (
	//RegionFilterRegionCodeExt  Region code
	RegionFilterRegionCodeExt RegionFilter = "regionCodeExt"

	//RegionFilterRegionCode Region code in the CDEK IS
	RegionFilterRegionCode RegionFilter = "regionCode"

	//RegionFilterRegionFiasGUID Region code according to the Federal Information Address System
	RegionFilterRegionFiasGUID RegionFilter = "regionFiasGuid"

	//RegionFilterCountryCode Country code in the CDEK IS
	RegionFilterCountryCode RegionFilter = "countryCode"

	//RegionFilterCountryCodeExt Code according to the Russian Classifier of Countries of the World
	RegionFilterCountryCodeExt RegionFilter = "countryCodeExt"

	//RegionFilterPage Number of the results page. Default value: 0
	RegionFilterPage RegionFilter = "page"

	//RegionFilterSize Limitation on the number of results displayed. Default value: 1,000
	RegionFilterSize RegionFilter = "size"
)

type RegionFilterBuilder

type RegionFilterBuilder struct {
	// contains filtered or unexported fields
}

RegionFilterBuilder builder for filer for "List of Regions" request

func (*RegionFilterBuilder) AddFilter

func (filterBuilder *RegionFilterBuilder) AddFilter(filter RegionFilter, value string) *RegionFilterBuilder

AddFilter add filter to set of filters for "List of Regions" request

func (*RegionFilterBuilder) Filter

func (filterBuilder *RegionFilterBuilder) Filter() map[RegionFilter]string

Filter compile RegionFilterBuilder for "List of Regions" request

type RegisterOrderReq

type RegisterOrderReq struct {
	XMLName     xml.Name     `xml:"DeliveryRequest"`
	Number      *string      `xml:"Number,attr"`
	OrderCount  *int         `xml:"OrderCount,attr"`
	Currency    *string      `xml:"Currency,attr,omitempty"`
	Order       *OrderReq    `xml:"Order"`
	CallCourier *CallCourier `xml:"CallCourier"`
	// contains filtered or unexported fields
}

RegisterOrderReq Order registration request

func NewDeliveryRequest

func NewDeliveryRequest(number string, orderCount int, order *OrderReq) *RegisterOrderReq

NewDeliveryRequest Order registration request builder number: ID number of the acceptance certificate/waybill, accompanying document attached upon the transfer of the cargo to CDEK, generated in the online store's system. Identifier of the list of cargoes in the IS of the CDEK Client. By default, you can use 1. orderCount: The total number of orders in a document, default value: 1. order: Shipment (order)

func (*RegisterOrderReq) SetCallCourier

func (registerOrderReq *RegisterOrderReq) SetCallCourier(callCourier CallCourier) *RegisterOrderReq

SetCallCourier Call courier

func (*RegisterOrderReq) SetCurrency

func (registerOrderReq *RegisterOrderReq) SetCurrency(currency string) *RegisterOrderReq

SetCurrency Currency identifier for prices, RUB is a default parameter. Only for international orders

type RegisterOrderResp

type RegisterOrderResp struct {
	Order []*OrderResp       `xml:"Order,omitempty"`
	Call  []*CourierCallResp `xml:"Call,omitempty"`
}

RegisterOrderResp Order registration response structure

type ReturnOrder

type ReturnOrder struct {
	ActNumber      *string      `xml:"ActNumber,attr"`
	Number         *string      `xml:"Number,attr"`
	DispatchNumber *int         `xml:"DispatchNumber,attr"`
	DeliveryDate   *string      `xml:"DeliveryDate,attr"`
	RecipientName  *string      `xml:"RecipientName,attr"`
	Status         *Status      `xml:"Status"`
	Reason         *Reason      `xml:"Reason"`
	DelayReason    *DelayReason `xml:"DelayReason"`
}

ReturnOrder Return shipment

type Schedule

type Schedule struct {
	Attempt []*ScheduleAttempt `xml:"Attempt"`
}

Schedule Schedule for delivery/pickup

func NewSchedule

func NewSchedule() *Schedule

NewSchedule Schedule for delivery/pickup builder

func (*Schedule) AddAttempt

func (schedule *Schedule) AddAttempt(attempt ScheduleAttempt) *Schedule

AddAttempt add Time of delivery

type ScheduleAttempt

type ScheduleAttempt struct {
	ID      *string  `xml:"ID,attr"`
	Date    *string  `xml:"Date,attr"`
	Comment *string  `xml:"Comment,attr"`
	TimeBeg *string  `xml:"TimeBeg,attr"`
	TimeEnd *string  `xml:"TimeEnd,attr"`
	Address *Address `xml:"Address"`
}

ScheduleAttempt Time of delivery (one time interval not less than 3 hours is permitted for one day)

func NewScheduleAttempt

func NewScheduleAttempt(id string, date time.Time) *ScheduleAttempt

NewScheduleAttempt Time of delivery builder id: ID number of a schedule from the online store's database. You may use 1 as a default value date: Date of delivery as agreed by the receiver

func (*ScheduleAttempt) SetAddress

func (scheduleAttempt *ScheduleAttempt) SetAddress(address Address) *ScheduleAttempt

SetAddress New delivery address (if change is required). Depending on a delivery mode, Street or House attributes should be specified. Flat – delivery to the receiver's address, or PvzCode – pickup

func (*ScheduleAttempt) SetComment

func (scheduleAttempt *ScheduleAttempt) SetComment(comment string) *ScheduleAttempt

SetComment Comment

func (*ScheduleAttempt) SetTimeBeg

func (scheduleAttempt *ScheduleAttempt) SetTimeBeg(timeBeg string) *ScheduleAttempt

SetTimeBeg Start of a delivery time range (receiver's time)

func (*ScheduleAttempt) SetTimeEnd

func (scheduleAttempt *ScheduleAttempt) SetTimeEnd(timeEnd string) *ScheduleAttempt

SetTimeEnd End of a delivery time range (receiver's time)

type Seller

type Seller struct {
	Address       *string `xml:"Address,attr,omitempty"`
	Name          *string `xml:"Name,attr,omitempty"`
	INN           *string `xml:"INN,attr,omitempty"`
	Phone         *string `xml:"Phone,attr,omitempty"`
	OwnershipForm *int    `xml:"OwnershipForm,attr,omitempty"`
}

Seller Requisites of the real seller

func NewSeller

func NewSeller() *Seller

NewSeller Requisites of the real seller builder

func (*Seller) SetAddress

func (seller *Seller) SetAddress(address string) *Seller

SetAddress Real seller’s address. Used to print invoices to display the address of the true seller or trade name. Only for international orders.

func (*Seller) SetINN

func (seller *Seller) SetINN(inn string) *Seller

SetINN ITN (Individual Taxpayer Number) of the real seller

func (*Seller) SetName

func (seller *Seller) SetName(name string) *Seller

SetName Real seller

func (*Seller) SetOwnershipForm

func (seller *Seller) SetOwnershipForm(ownershipForm int) *Seller

SetOwnershipForm Code of type ownership

func (*Seller) SetPhone

func (seller *Seller) SetPhone(phone string) *Seller

SetPhone Telephone of the real seller

type Sender

type Sender struct {
	Company *string   `xml:"Company,attr"`
	Name    *string   `xml:"Name,attr"`
	Address *Address  `xml:"Address,omitempty"`
	Phone   []*string `xml:"Phone,omitempty"`
}

Sender Sender. Must be defined if it is different from the online store Client. If the online store is a sender, the Sender tag is not available.

func NewSender

func NewSender() *Sender

NewSender Sender builder

func (*Sender) AddPhone

func (sender *Sender) AddPhone(phone string) *Sender

AddPhone Sender's phone

func (*Sender) SetAddress

func (sender *Sender) SetAddress(address Address) *Sender

SetAddress Address of pickup builder

func (*Sender) SetCompany

func (sender *Sender) SetCompany(company string) *Sender

SetCompany Name of sender's company

func (*Sender) SetName

func (sender *Sender) SetName(name string) *Sender

SetName Sender's contact person

type ServiceAccessСonfigurator added in v0.0.3

type ServiceAccessСonfigurator interface {
	SetAuth(account, secure string) ServiceProvider
	SetCalculatorURL(calculatorURL string) ServiceProvider
}

ServiceAccessСonfigurator allows to configure client for the service

type ServiceProvider added in v0.0.3

type ServiceProvider interface {
	ServiceAccessСonfigurator

	CalculateDelivery(ctx context.Context, req GetCostReq) (*GetCostRespResult, error)
	GetCities(ctx context.Context, filter map[CityFilter]string) (*GetCitiesResp, error)
	GetPvzList(ctx context.Context, filter map[PvzListFilter]string) ([]*Pvz, error)
	GetRegions(ctx context.Context, filter map[RegionFilter]string) (*GetRegionsResp, error)
	RegisterOrder(ctx context.Context, req RegisterOrderReq) (*RegisterOrderResp, error)
	UpdateOrder(ctx context.Context, req UpdateOrderReq) (*UpdateOrderResp, error)
	DeleteOrder(ctx context.Context, req DeleteOrderReq) (*DeleteOrderResp, error)
	GetStatusReport(ctx context.Context, statusReportReq StatusReport) (*StatusReportResp, error)
}

ServiceProvider provides CDEK API functionality

func NewClient

func NewClient(apiURL string) ServiceProvider

NewClient Client constructor with defaults

Example
client := NewClient("https://integration.edu.cdek.ru/")
client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq")
Output:

type ServiceReq

type ServiceReq struct {
	ID    int `json:"id"`
	Param int `json:"param,omitempty"`
}

ServiceReq List of additional service

type ServiceResp

type ServiceResp struct {
	ID    int     `json:"id"`
	Title string  `json:"title"`
	Price float64 `json:"price"`
	Rate  float64 `json:"rate,omitempty"`
}

ServiceResp List of transmitted additional services

type State

type State struct {
	Date        *string `xml:"Date,attr"`
	Code        *int    `xml:"Code,attr"`
	Description *string `xml:"Description,attr"`
	CityCode    *int    `xml:"CityCode,attr,omitempty"`
	CityName    *string `xml:"CityName,attr,omitempty"`
}

State Status change history

type Status

type Status struct {
	Date        *string  `xml:"Date,attr"`
	Code        *int     `xml:"Code,attr"`
	Description *string  `xml:"Description,attr"`
	CityCode    *int     `xml:"CityCode,attr"`
	CityName    *string  `xml:"CityName,attr"`
	State       []*State `xml:"State"`
}

Status Current order status

type StatusReport

type StatusReport struct {
	ShowHistory            *int                    `xml:"ShowHistory,attr"`
	ShowReturnOrder        *bool                   `xml:"ShowReturnOrder,attr"`
	ShowReturnOrderHistory *bool                   `xml:"ShowReturnOrderHistory,attr"`
	ChangePeriod           *ChangePeriod           `xml:"ChangePeriod"`
	Order                  []*StatusReportOrderReq `xml:"Order"`
	// contains filtered or unexported fields
}

StatusReport Order Status Report request

func NewStatusReportReq

func NewStatusReportReq() *StatusReport

NewStatusReportReq Order Status Report builder

func (*StatusReport) AddOrder

func (req *StatusReport) AddOrder(order StatusReportOrderReq) *StatusReport

AddOrder Add Shipment (order)

func (*StatusReport) SetChangePeriod

func (req *StatusReport) SetChangePeriod(changePeriod ChangePeriod) *StatusReport

SetChangePeriod The period during which the order status has changed.

func (*StatusReport) SetShowHistory

func (req *StatusReport) SetShowHistory(showHistory int) *StatusReport

SetShowHistory The attribute indicating that the order history must be loaded (1 – yes, 0 – no)

func (*StatusReport) SetShowReturnOrder

func (req *StatusReport) SetShowReturnOrder(showReturnOrder bool) *StatusReport

SetShowReturnOrder The attribute indicating that the list of return orders must be loaded (1 – yes, 0 – no)

func (*StatusReport) SetShowReturnOrderHistory

func (req *StatusReport) SetShowReturnOrderHistory(showReturnOrderHistory bool) *StatusReport

SetShowReturnOrderHistory The attribute indicating that the history of return orders must be loaded (1 – yes, 0 – no)

type StatusReportContentForResp

type StatusReportContentForResp struct {
	DateFirst *string `xml:"DateFirst,attr"`
	DateLast  *string `xml:"DateLast,attr"`
}

StatusReportContentForResp The period during which the order status has changed.

type StatusReportOrderReq

type StatusReportOrderReq struct {
	DispatchNumber *int    `xml:"DispatchNumber,attr"`
	Number         *string `xml:"Number,attr"`
	Date           *string `xml:"Date,attr"`
}

StatusReportOrderReq Shipment (order)

func NewStatusReportByCDEKIdentifierReq added in v0.0.5

func NewStatusReportByCDEKIdentifierReq(dispatchNumber int) *StatusReportOrderReq

NewStatusReportByCDEKNumberReq StatusReportOrderReq builder by CDEK order number

func NewStatusReportByClientIdentifierReq added in v0.0.5

func NewStatusReportByClientIdentifierReq(number string, date time.Time) *StatusReportOrderReq

NewStatusReportByClientNumberReq StatusReportOrderReq builder by client order number

type StatusReportOrderResp

type StatusReportOrderResp struct {
	ActNumber            *string     `xml:"ActNumber,attr"`
	Number               *string     `xml:"Number,attr"`
	DispatchNumber       *int        `xml:"DispatchNumber,attr"`
	DeliveryDate         string      `xml:"DeliveryDate,attr"`
	RecipientName        string      `xml:"RecipientName,attr"`
	ReturnDispatchNumber *int        `xml:"ReturnDispatchNumber,attr"`
	Status               *Status     `xml:"Status"`
	Reason               Reason      `xml:"Reason"`
	DelayReason          DelayReason `xml:"DelayReason"`
	Package              *Package    `xml:"Package"`
	Attempt              *Attempt    `xml:"Attempt"`
	Call                 *Call       `xml:"Call"`
}

StatusReportOrderResp Shipment (order)

type StatusReportResp

type StatusReportResp struct {
	Error
	StatusReport *StatusReportContentForResp `xml:"StatusReport"`
	Order        []*StatusReportOrderResp    `xml:"Order"`
	ReturnOrder  []*ReturnOrder              `xml:"ReturnOrder,omitempty"`
}

StatusReportResp Order Status Report response

type UpdateOrder

type UpdateOrder struct {
	Number                   *string                   `xml:"Number,attr"`
	DispatchNumber           *int                      `xml:"DispatchNumber,attr"`
	DeliveryRecipientCost    *float64                  `xml:"DeliveryRecipientCost,attr"`
	DeliveryRecipientVATRate *string                   `xml:"DeliveryRecipientVATRate,attr"`
	DeliveryRecipientVATSum  *float64                  `xml:"DeliveryRecipientVATSum,attr"`
	RecipientName            *string                   `xml:"RecipientName,attr"`
	RecipientEmail           *string                   `xml:"RecipientEmail,attr"`
	Phone                    *string                   `xml:"Phone,attr"`
	RecipientINN             *string                   `xml:"RecipientINN,attr"`
	DateInvoice              *string                   `xml:"DateInvoice,attr"`
	Passport                 *Passport                 `xml:"Passport"`
	Address                  *Address                  `xml:"Address"`
	DeliveryRecipientCostAdv *DeliveryRecipientCostAdv `xml:"DeliveryRecipientCostAdv"`
	Package                  *OrderPackage             `xml:"Package"`
}

UpdateOrder Order Change request

func NewUpdateOrder

func NewUpdateOrder() *UpdateOrder

NewUpdateOrder UpdateOrder builder

func (*UpdateOrder) SetAddress

func (updateOrder *UpdateOrder) SetAddress(address Address) *UpdateOrder

SetAddress Delivery address.

func (*UpdateOrder) SetDateInvoice

func (updateOrder *UpdateOrder) SetDateInvoice(dateInvoice string) *UpdateOrder

SetDateInvoice Invoice date. Only for international orders.

func (*UpdateOrder) SetDeliveryRecipientCost

func (updateOrder *UpdateOrder) SetDeliveryRecipientCost(deliveryRecipientCost float64) *UpdateOrder

SetDeliveryRecipientCost Additional delivery charge collected by the online store from the receiver (in the specified currency)

func (*UpdateOrder) SetDeliveryRecipientCostAdv

func (updateOrder *UpdateOrder) SetDeliveryRecipientCostAdv(v DeliveryRecipientCostAdv) *UpdateOrder

SetDeliveryRecipientCostAdv Additional charge for delivery

func (*UpdateOrder) SetDeliveryRecipientVATRate

func (updateOrder *UpdateOrder) SetDeliveryRecipientVATRate(deliveryRecipientVATRate string) *UpdateOrder

SetDeliveryRecipientVATRate VAT rate included in the extra delivery charge

func (*UpdateOrder) SetDeliveryRecipientVATSum

func (updateOrder *UpdateOrder) SetDeliveryRecipientVATSum(deliveryRecipientVATSum float64) *UpdateOrder

SetDeliveryRecipientVATSum VAT amount included in the extra. delivery charge

func (*UpdateOrder) SetDispatchNumber

func (updateOrder *UpdateOrder) SetDispatchNumber(dispatchNumber int) *UpdateOrder

SetDispatchNumber CDEK order number

func (*UpdateOrder) SetNumber

func (updateOrder *UpdateOrder) SetNumber(number string) *UpdateOrder

SetNumber Client shipment number (unique for orders of a particular Client). Order identifier in the Client's IS.

func (*UpdateOrder) SetPackage

func (updateOrder *UpdateOrder) SetPackage(pack OrderPackage) *UpdateOrder

SetPackage Package

func (*UpdateOrder) SetPassport

func (updateOrder *UpdateOrder) SetPassport(passport Passport) *UpdateOrder

SetPassport Details of the receiver’s passport.

func (*UpdateOrder) SetPhone

func (updateOrder *UpdateOrder) SetPhone(phone string) *UpdateOrder

SetPhone Receiver's phone

func (*UpdateOrder) SetRecipientEmail added in v0.0.4

func (updateOrder *UpdateOrder) SetRecipientEmail(recipientEmail string) *UpdateOrder

SetRecipientEmail Receiver's email for sending order status notifications and contacting in case of failed calls

func (*UpdateOrder) SetRecipientINN

func (updateOrder *UpdateOrder) SetRecipientINN(recipientINN string) *UpdateOrder

SetRecipientINN TIN of the receiver. Only for international orders.

func (*UpdateOrder) SetRecipientName

func (updateOrder *UpdateOrder) SetRecipientName(recipientName string) *UpdateOrder

SetRecipientName Receiver (full name). At least 3 characters.

type UpdateOrderReq

type UpdateOrderReq struct {
	XMLName    xml.Name     `xml:"UpdateRequest"`
	Number     *string      `xml:"Number,attr"`
	OrderCount *int         `xml:"OrderCount,attr"`
	Order      *UpdateOrder `xml:"Order"`
	// contains filtered or unexported fields
}

UpdateOrderReq Order Change request structure

func NewUpdateOrderReq

func NewUpdateOrderReq(number string, orderCount int, order UpdateOrder) *UpdateOrderReq

NewUpdateOrderReq UpdateOrderReq builder

type UpdateOrderResp

type UpdateOrderResp struct {
	Order []*OrderResp `xml:"Order"`
}

UpdateOrderResp Order Change response

type WeightLimit

type WeightLimit struct {
	WeightMin *float64 `xml:"WeightMin,attr"`
	WeightMax *float64 `xml:"WeightMax,attr"`
}

WeightLimit Weight limits for a pickup point (the tag is used only if limits are set)

type WorkTimeY

type WorkTimeY struct {
	Day     *int    `xml:"day,attr"`
	Periods *string `xml:"periods,attr"`
}

WorkTimeY Opening hours for every day

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL