import "github.com/vseinstrumentiru/CDEK"
calculator-models.go calculator-req-builder.go calculator-service.go city-filter.go city-models.go city-service.go client.go delete-order-models.go delete-order-req-builder.go delete-order-service.go error-response.go pvzlist-filter.go pvzlist-models.go pvzlist-service.go region-filter.go region-models.go region-service.go register-order-models.go register-order-req-builder.go register-order-service.go secure.go status-report-models.go status-report-req-builder.go status-report-service.go test-helper.go update-order-models.go update-order-req-builder.go update-order-service.go
const ( //TypePvz только склады СДЭК TypePvz string = "PVZ" //TypePostomat постоматы партнёра TypePostomat string = "POSTOMAT" //TypeAll все ПВЗ не зависимо от их типа TypeAll string = "ALL" )
type AddService struct { ServiceCode *int `xml:"ServiceCode,attr"` Count *int `xml:"Count,attr,omitempty"` }
AddService Additional services
func NewAddService(serviceCode int) *AddService
NewAddService Additional services builder serviceCode: Type of additional service
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 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
NewAddress Address of pickup builder
SetFlat Flat/office
SetPhone Sender's phone
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.
Alert CDEK Alert model
AlertResponse CDEK Alerts model
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 struct { CallGood *CallGood `xml:"CallGood"` CallFail *CallFail `xml:"CallFail"` CallDelay *CallDelay `xml:"CallDelay"` }
Call History of notification calls to the receiver
type CallCourier struct { Call *CourierCallReq `xml:"Call"` }
CallCourier Call courier
func NewCallCourier(call CourierCallReq) *CallCourier
NewCallCourier Call courier builder call: Waiting for a courier
type CallDelay struct { Delay []*CallDelayItem `xml:"Delay"` }
CallDelay History of call reschedules
type CallDelayItem struct { Date *string `xml:"Date,attr"` DateNext *string `xml:"DateNext,attr"` }
CallDelayItem Call reschedule
type CallFail struct { Fail []*CallFailItem `xml:"Fail"` }
CallFail History of failed calls
type CallFailItem struct { Date *string `xml:"Date,attr"` ReasonCode *int `xml:"ReasonCode,attr"` ReasonDescription *string `xml:"ReasonDescription,attr"` }
CallFailItem Failed call
type CallGood struct { Good []*CallGoodItem `xml:"Good"` }
CallGood History of successful calls
type CallGoodItem struct { Date *string `xml:"Date,attr"` DateDeliv *string `xml:"DateDeliv,attr"` }
CallGoodItem Successful call
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(dateFirst time.Time) *ChangePeriod
NewChangePeriod ChangePeriod builder dateFirst: start date of requested period
func (changePeriod *ChangePeriod) SetDateLast(date time.Time) *ChangePeriod
SetDateLast End date of requested period
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
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 struct {
// contains filtered or unexported fields
}
CityFilterBuilder builder for filer for "List of Cities" request
func (filterBuilder *CityFilterBuilder) AddFilter(filter CityFilter, value string) *CityFilterBuilder
AddFilter add filter to set of filters for "List of Cities" request
func (filterBuilder *CityFilterBuilder) Filter() map[CityFilter]string
Filter returns complete CityFilter for "List of Cities" request
type Client struct {
// contains filtered or unexported fields
}
Client SDK Client configuration
func (c Client) CalculateDelivery(req GetCostReq) (*GetCostRespResult, error)
CalculateDelivery Cost calculation on tariffs with priority.
Code:
client := NewClient("https://integration.edu.cdek.ru/") client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq") result, err := client.CalculateDelivery(*NewGetCostReq(61208, 2108, 10)) _, _ = result, err
func (c Client) DeleteOrder(req DeleteOrderReq) (*DeleteOrderResp, error)
DeleteOrder The method is designed to cancel/delete an order at the client's initiative.
Code:
client := NewClient("https://integration.edu.cdek.ru/") client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq") result, err := client.DeleteOrder(*NewDeleteOrderReq( "number-soOEl0", 1, *NewDeleteOrder().SetNumber("number-soOEl0"), )) _, _ = result, err
func (c Client) GetCities(filter map[CityFilter]string) (*GetCitiesResp, error)
GetCities This method is used to load detailed information on cities.
Code:
client := NewClient("https://integration.edu.cdek.ru/") client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq") result, err := client.GetCities(map[CityFilter]string{ CityFilterPage: "3", }) _, _ = result, err
GetPvzList The method is used to load the list of active pickup points, from which the client can pick up its order.
Code:
client := NewClient("https://integration.edu.cdek.ru/") client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq") result, err := client.GetPvzList(map[PvzListFilter]string{ PvzListFilterCityID: "44", }) _, _ = result, err
func (c Client) GetRegions(filter map[RegionFilter]string) (*GetRegionsResp, error)
GetRegions This method is used to load detailed information on regions.
Code:
client := NewClient("https://integration.edu.cdek.ru/") client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq") result, err := client.GetRegions(map[RegionFilter]string{ RegionFilterPage: "3", }) _, _ = result, err
func (c Client) GetStatusReport(statusReportReq StatusReport) (*StatusReportResp, error)
GetStatusReport This method is used to generate an order status report, including order change history.
func (c Client) RegisterOrder(req RegisterOrderReq) (*RegisterOrderResp, error)
RegisterOrder This method is used to register orders to be delivered to clients.
Code:
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"), ), ) result, err := client.RegisterOrder(*NewDeliveryRequest("soOEl", 1, exampleOrder)) _, _ = result, err
func (c *Client) SetAuth(account, secure string) ServiceProvider
SetAuth set auth data
func (c *Client) SetCalculatorURL(calculatorURL string) ServiceProvider
SetCalculatorURL url for delivery calculation
func (c Client) UpdateOrder(req UpdateOrderReq) (*UpdateOrderResp, error)
UpdateOrder This method is used to change a created order.
Code:
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), ), ) result, err := client.UpdateOrder(*NewUpdateOrderReq("soOEl", 1, *exampleOrderToUpdate)) _, _ = result, err
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( 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 (call *CourierCallReq) SetComment(comment string) *CourierCallReq
SetComment Comment for courier
func (call *CourierCallReq) SetLunchBeg(lunchBeg string) *CourierCallReq
SetLunchBeg Start time of a lunch break, if it is within a time range [TimeBeg; TimeEnd]
func (call *CourierCallReq) SetLunchEnd(lunchEnd string) *CourierCallReq
SetLunchEnd End time of a lunch break, if it is within a time range [TimeBeg; TimeEnd]
func (call *CourierCallReq) SetSendCityCode(sendCityCode int) *CourierCallReq
SetSendCityCode Sender's city code from the CDEK base
func (call *CourierCallReq) SetSendCityName(sendCityName string) *CourierCallReq
SetSendCityName Name of sender's city
func (call *CourierCallReq) SetSendCityPostCode(sendCityPostCode string) *CourierCallReq
SetSendCityPostCode Postal code of the sender's city
func (call *CourierCallReq) SetSendCountryCode(sendCountryCode string) *CourierCallReq
SetSendCountryCode Sender's country code to identify a country by postal code
CourierCallResp Call courier
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 struct { Number *string `xml:"Number,attr"` DispatchNumber *int `xml:"DispatchNumber,attr"` }
DeleteOrder order model for deleting request
func NewDeleteOrder() *DeleteOrder
NewDeleteOrder DeleteOrder constructor
func (o *DeleteOrder) SetDispatchNumber(dispatchNumber int) *DeleteOrder
SetDispatchNumber CDEK order number
func (o *DeleteOrder) SetNumber(number string) *DeleteOrder
SetNumber Client's shipment number. Order identifier in the IS of the CDEK client.
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(number string, orderCount int, order DeleteOrder) *DeleteOrderReq
NewDeleteOrderReq DeleteOrderReq constructor
DeleteOrderResp response structure of deleting order from CDEK
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(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 (d *DeliveryRecipientCostAdv) SetVATRate(vatRate string) *DeliveryRecipientCostAdv
SetVATRate VAT rate included in the additional charge for delivery. If the value is unknown, then default value “No VAT” is applied
func (d *DeliveryRecipientCostAdv) SetVATSum(vatSum float64) *DeliveryRecipientCostAdv
SetVATSum VAT sum included in the additional charge for delivery
type Error struct { ErrorCode *string `xml:"ErrorCode,attr,omitempty" json:"code"` Msg *string `xml:"Msg,attr,omitempty" json:"text"` }
Error error values in responses
IsErroneous check if struct has error
GetCitiesResp response struct for CDEK cities getter
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(senderCityID int, receiverCityID int, tariffID int) *GetCostReq
NewGetCostReq create new instance of GetCostReq
func (getCostReq *GetCostReq) AddGood(good Good) *GetCostReq
AddGood add good to request
func (getCostReq *GetCostReq) AddService(service ServiceReq) *GetCostReq
AddService add service to request
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
GetRegionsResp List of Regions response
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 struct { WareKey *string `xml:"WareKey,attr"` Amount *int `xml:"Amount,attr"` DelivAmount *int `xml:"DelivAmount,attr"` }
Item Items
OfficeImage All photos of the office (except for a photo showing how to get to it)
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(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 *OrderPackage) AddItem(item OrderPackageItem) *OrderPackage
AddItem Add OrderPackageItem to OrderPackageItems list
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 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( 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 (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 (item *OrderPackageItem) SetPaymentVATRate(paymentVATRate string) *OrderPackageItem
SetPaymentVATRate VAT rate included in the value of the goods
func (item *OrderPackageItem) SetPaymentVATSum(paymentVATSum float64) *OrderPackageItem
SetPaymentVATSum VAT amount included in the value (payment) of the goods.
func (item *OrderPackageItem) SetWeightBrutto(weightBrutto int) *OrderPackageItem
SetWeightBrutto Gross weight (for one unit of goods, in grams). Only for international orders.
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)
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 *OrderReq) AddPackage(pack OrderPackage) *OrderReq
AddPackage Package (all packages are sent with different Package tags)
func (orderReq *OrderReq) SetAddService(addService AddService) *OrderReq
SetAddService Additional services
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)
SetComment Comments (special notes on the order)
SetDateInvoice Invoice date. Only for international orders.
SetDeliveryRecipientCost Extra delivery charge collected by the online store from the receiver (in the specified currency)
func (orderReq *OrderReq) SetDeliveryRecipientCostAdv(deliveryRecipientCostAdv DeliveryRecipientCostAdv) *OrderReq
SetDeliveryRecipientCostAdv Additional charge for delivery (E-shop charges the receiver), depending on the order’s sum
SetDeliveryRecipientVATRate VAT rate included in the extra delivery charge
SetDeliveryRecipientVATSum VAT amount included in the extra delivery charge
SetItemsCurrency Code of declared value currency (all items in the order). Currency of settlements with the CDEK Client under contract.
SetPassport Details of the receiver’s passport. Used to print waybills. Only for international orders.
SetRecCityCode Receiver's city code from the CDEK base
SetRecCityName Name of receiver's city
SetRecCityPostCode Postal code of the receiver's city
SetRecCountryCode Receiver's country code to identify a country by postal code. Default value: RU
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
SetRecipientEmail Receiver's email for sending order status notifications and contacting in case of failed calls
SetRecipientINN TIN of the receiver. Only for international orders.
SetSchedule Schedule for delivery/pickup
SetSeller Requisites of the real seller
SetSendCityCode Sender's city code from the CDEK base
SetSendCityName Name of sender's city
SetSendCityPostCode Postal code of the sender's city
SetSendCountryCode Sender's country code to identify a country by postal code. Default value: RU
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.
SetShipperAddress Shipper’s address. Used to print waybills. Only for international orders
SetShipperName Shipper. Used to print waybills. Only for international orders.
type OrderResp struct { Error DispatchNumber *int `xml:"DispatchNumber,attr"` Number *string `xml:"Number,attr"` }
OrderResp Order
GetError returns error supplemented with order data
type Package struct { Number *string `xml:"Number,attr"` BarCode *string `xml:"BarCode,attr"` Item []*Item `xml:"Item"` }
Package Package
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.
NewPassport Passport builder
SetDateBirth The receiver’s birthdate
SetIssueDate Date of issue of the receiver’s passport.
SetIssuedBy Issuing authority of the receiver’s passport.
SetNumber Number of the receiver’s passport.
SetSeries Series of the receiver’s passport.
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
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 struct {
// contains filtered or unexported fields
}
PvzListFilterBuilder builder for pvzList filter
func (filterBuilder *PvzListFilterBuilder) AddFilter(filter PvzListFilter, value string) *PvzListFilterBuilder
AddFilter adds filter for pvzList filter
func (filterBuilder PvzListFilterBuilder) Filter() map[PvzListFilter]string
Filter returns complete filter
type Reason struct { Date string `xml:"Date,attr"` Code int `xml:"Code,attr"` Description string `xml:"Description,attr"` }
Reason Current additional status
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
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 struct {
// contains filtered or unexported fields
}
RegionFilterBuilder builder for filer for "List of Regions" request
func (filterBuilder *RegionFilterBuilder) AddFilter(filter RegionFilter, value string) *RegionFilterBuilder
AddFilter add filter to set of filters for "List of Regions" request
func (filterBuilder *RegionFilterBuilder) Filter() map[RegionFilter]string
Filter compile RegionFilterBuilder for "List of Regions" request
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(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 *RegisterOrderReq) SetCallCourier(callCourier CallCourier) *RegisterOrderReq
SetCallCourier Call courier
func (registerOrderReq *RegisterOrderReq) SetCurrency(currency string) *RegisterOrderReq
SetCurrency Currency identifier for prices, RUB is a default parameter. Only for international orders
type RegisterOrderResp struct { Order []*OrderResp `xml:"Order,omitempty"` Call []*CourierCallResp `xml:"Call,omitempty"` }
RegisterOrderResp Order registration response structure
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 struct { Attempt []*ScheduleAttempt `xml:"Attempt"` }
Schedule Schedule for delivery/pickup
NewSchedule Schedule for delivery/pickup builder
func (schedule *Schedule) AddAttempt(attempt ScheduleAttempt) *Schedule
AddAttempt add Time of delivery
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(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 *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 *ScheduleAttempt) SetComment(comment string) *ScheduleAttempt
SetComment Comment
func (scheduleAttempt *ScheduleAttempt) SetTimeBeg(timeBeg string) *ScheduleAttempt
SetTimeBeg Start of a delivery time range (receiver's time)
func (scheduleAttempt *ScheduleAttempt) SetTimeEnd(timeEnd string) *ScheduleAttempt
SetTimeEnd End of a delivery time range (receiver's time)
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
NewSeller Requisites of the real seller builder
SetAddress Real seller’s address. Used to print invoices to display the address of the true seller or trade name. Only for international orders.
SetINN ITN (Individual Taxpayer Number) of the real seller
SetName Real seller
SetOwnershipForm Code of type ownership
SetPhone Telephone of the real seller
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.
NewSender Sender builder
AddPhone Sender's phone
SetAddress Address of pickup builder
SetCompany Name of sender's company
SetName Sender's contact person
type ServiceAccessСonfigurator interface { SetAuth(account, secure string) ServiceProvider SetCalculatorURL(calculatorURL string) ServiceProvider }
ServiceAccessСonfigurator allows to configure client for the service
type ServiceProvider interface { ServiceAccessСonfigurator CalculateDelivery(req GetCostReq) (*GetCostRespResult, error) GetCities(filter map[CityFilter]string) (*GetCitiesResp, error) GetPvzList(filter map[PvzListFilter]string) ([]*Pvz, error) GetRegions(filter map[RegionFilter]string) (*GetRegionsResp, error) RegisterOrder(req RegisterOrderReq) (*RegisterOrderResp, error) UpdateOrder(req UpdateOrderReq) (*UpdateOrderResp, error) DeleteOrder(req DeleteOrderReq) (*DeleteOrderResp, error) GetStatusReport(statusReportReq StatusReport) (*StatusReportResp, error) }
ServiceProvider provides CDEK API functionality
func NewClient(apiURL string) ServiceProvider
NewClient Client constructor with defaults
Code:
client := NewClient("https://integration.edu.cdek.ru/") client.SetAuth("z9GRRu7FxmO53CQ9cFfI6qiy32wpfTkd", "w24JTCv4MnAcuRTx0oHjHLDtyt3I6IBq")
ServiceReq List of additional service
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 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 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 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() *StatusReport
NewStatusReportReq Order Status Report builder
func (req *StatusReport) AddOrder(order StatusReportOrderReq) *StatusReport
AddOrder Add Shipment (order)
func (req *StatusReport) SetChangePeriod(changePeriod ChangePeriod) *StatusReport
SetChangePeriod The period during which the order status has changed.
func (req *StatusReport) SetShowHistory(showHistory int) *StatusReport
SetShowHistory The attribute indicating that the order history must be loaded (1 – yes, 0 – no)
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 (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 struct { DateFirst *string `xml:"DateFirst,attr"` DateLast *string `xml:"DateLast,attr"` }
StatusReportContentForResp The period during which the order status has changed.
type StatusReportOrderReq struct { DispatchNumber *int `xml:"DispatchNumber,attr"` Number *string `xml:"Number,attr"` Date *string `xml:"Date,attr"` }
StatusReportOrderReq Shipment (order)
func NewStatusReportByCDEKIdentifierReq(dispatchNumber int) *StatusReportOrderReq
NewStatusReportByCDEKNumberReq StatusReportOrderReq builder by CDEK order number
func NewStatusReportByClientIdentifierReq(number string, date time.Time) *StatusReportOrderReq
NewStatusReportByClientNumberReq StatusReportOrderReq builder by client order number
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 struct { Error StatusReport *StatusReportContentForResp `xml:"StatusReport"` Order []*StatusReportOrderResp `xml:"Order"` ReturnOrder []*ReturnOrder `xml:"ReturnOrder,omitempty"` }
StatusReportResp Order Status Report response
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() *UpdateOrder
NewUpdateOrder UpdateOrder builder
func (updateOrder *UpdateOrder) SetAddress(address Address) *UpdateOrder
SetAddress Delivery address.
func (updateOrder *UpdateOrder) SetDateInvoice(dateInvoice string) *UpdateOrder
SetDateInvoice Invoice date. Only for international orders.
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 *UpdateOrder) SetDeliveryRecipientCostAdv(v DeliveryRecipientCostAdv) *UpdateOrder
SetDeliveryRecipientCostAdv Additional charge for delivery
func (updateOrder *UpdateOrder) SetDeliveryRecipientVATRate(deliveryRecipientVATRate string) *UpdateOrder
SetDeliveryRecipientVATRate VAT rate included in the extra delivery charge
func (updateOrder *UpdateOrder) SetDeliveryRecipientVATSum(deliveryRecipientVATSum float64) *UpdateOrder
SetDeliveryRecipientVATSum VAT amount included in the extra. delivery charge
func (updateOrder *UpdateOrder) SetDispatchNumber(dispatchNumber int) *UpdateOrder
SetDispatchNumber CDEK order number
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 *UpdateOrder) SetPackage(pack OrderPackage) *UpdateOrder
SetPackage Package
func (updateOrder *UpdateOrder) SetPassport(passport Passport) *UpdateOrder
SetPassport Details of the receiver’s passport.
func (updateOrder *UpdateOrder) SetPhone(phone string) *UpdateOrder
SetPhone Receiver's phone
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 *UpdateOrder) SetRecipientINN(recipientINN string) *UpdateOrder
SetRecipientINN TIN of the receiver. Only for international orders.
func (updateOrder *UpdateOrder) SetRecipientName(recipientName string) *UpdateOrder
SetRecipientName Receiver (full name). At least 3 characters.
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(number string, orderCount int, order UpdateOrder) *UpdateOrderReq
NewUpdateOrderReq UpdateOrderReq builder
UpdateOrderResp Order Change response
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)
WorkTimeY Opening hours for every day
Package cdek imports 14 packages (graph). Updated 2020-08-07. Refresh now. Tools for package owners.