diff --git a/.golangci.yaml b/.golangci.yaml
new file mode 100644
index 0000000..ac9156b
--- /dev/null
+++ b/.golangci.yaml
@@ -0,0 +1,20 @@
+run:
+ # timeout for analysis, e.g. 30s, 5m, default is 1m
+ deadline: 5m
+linters:
+ enable-all: true
+ disable:
+ - scopelint
+linters-settings:
+ misspell:
+ locale: US
+issues:
+ max-same: 0
+ max-per-linter: 0
+ exclude:
+ # gosec: Duplicated errcheck checks
+ - G104
+ # gosec: TLS InsecureSkipVerify may be true
+ - G402
+ # gosec: weak random number generator in app is ok
+ - G404
diff --git a/README.md b/README.md
index b84b540..1e9385b 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ Roadmap
- [ ] getServiceCostInternational
- [ ] Web служба "Создание заказа"
- [X] createOrder
- - [ ] getOrderStatus
+ - [x] getOrderStatus
- [ ] createAddress
- [ ] updateAddress
- [ ] getInvoiceFile
@@ -46,18 +46,13 @@ Roadmap
## Пример использования
```go
-dpdClient := dpdSdk.NewDPDClient(
- dpdSdk.DPDAuth{
- ClientNumber: client number,
- ClientKey: client key ,
- },
- dpdSdk.DPDUrls{
+dpdClient := dpdSdk.NewDPDClient(clinetNumber, clientKey
+ ServiceUrls{
GeographyUrl: "http://wstest.dpd.ru/services/geography2",
- OrderUrl: "http://wstest.dpd.ru/services/order",
+ OrderUrl: "http://wstest.dpd.ru/services/order2",
CalculatorUrl: "http://wstest.dpd.ru/services/calculator2",
- TrackingUrl: "http://wstest.dpd.ru:80/services/tracing",
+ TrackingUrl: "http://wstest.dpd.ru/services/tracing",
},
- "RU",
)
diff --git a/calculateRequestBuilder.go b/calculateRequestBuilder.go
index 62c6732..2999e1e 100644
--- a/calculateRequestBuilder.go
+++ b/calculateRequestBuilder.go
@@ -2,45 +2,38 @@ package dpd
import (
"time"
-
- dpdSoap "github.com/vseinstrumentiru/dpd/soap"
)
-//Request of calculate delivery cost
-type CalculateRequest dpdSoap.ServiceCostRequest
-
-//Address for calculate request
-type CityRequest dpdSoap.CityRequest
-
-//Dpd native, city identifier
-func NewCity(cityId int64) *CityRequest {
+//NewCity creates new pointer to CityRequest
+//use by CalculateRequest
+func NewCity(cityID int64) *CityRequest {
return &CityRequest{
- CityId: &cityId,
+ CityID: &cityID,
}
}
+//SetIndex set zip code of city
func (c *CityRequest) SetIndex(index string) *CityRequest {
c.Index = &index
return c
}
+//SetCityName set city name for city request
func (c *CityRequest) SetCityName(name string) *CityRequest {
c.CityName = &name
return c
}
+//SetRegionCode set region code for city request
func (c *CityRequest) SetRegionCode(code int) *CityRequest {
c.RegionCode = &code
return c
}
-//Set country code according ISO 3166-1 alpha-2 standard
-//
-//https://www.iso.org/obp/ui/#search
-//
+//SetCountryCode the code must comply with ISO 3166-1 alpha-2
//If omitted, default RU
func (c *CityRequest) SetCountryCode(code string) *CityRequest {
c.CountryCode = &code
@@ -48,14 +41,12 @@ func (c *CityRequest) SetCountryCode(code string) *CityRequest {
return c
}
+//NewCalculateRequest creates new pointer to CalculateRequest with required parameters
func NewCalculateRequest(from, to *CityRequest, weight float64, selfPickup, selfDelivery bool) *CalculateRequest {
req := new(CalculateRequest)
- dpdFrom := dpdSoap.CityRequest(*from)
- dpdTo := dpdSoap.CityRequest(*to)
-
- req.Pickup = &dpdFrom
- req.Delivery = &dpdTo
+ req.Pickup = from
+ req.Delivery = to
req.Weight = &weight
req.SelfPickup = &selfPickup
req.SelfDelivery = &selfDelivery
@@ -63,52 +54,51 @@ func NewCalculateRequest(from, to *CityRequest, weight float64, selfPickup, self
return req
}
-//Set pickup address
-func (r *CalculateRequest) OverridePickup(city *CityRequest) *CalculateRequest {
- dpdCityRequest := dpdSoap.CityRequest(*city)
- r.Pickup = &dpdCityRequest
+//OverrideFrom overrides pickup (city-sender) field in CalculateRequest struct
+func (r *CalculateRequest) OverrideFrom(city *CityRequest) *CalculateRequest {
+ r.Pickup = city
return r
}
-//Set delivery address
-func (r *CalculateRequest) OverrideDelivery(city *CityRequest) *CalculateRequest {
- delivery := dpdSoap.CityRequest(*city)
- r.Delivery = &delivery
+//OverrideTo overrides delivery (city-recipient) field in CalculateRequest struct
+func (r *CalculateRequest) OverrideTo(city *CityRequest) *CalculateRequest {
+ r.Delivery = city
return r
}
+//SetWeight set weight of parcel
func (r *CalculateRequest) SetWeight(weight float64) *CalculateRequest {
r.Weight = &weight
return r
}
+//SetVolume set volume of parcel
func (r *CalculateRequest) SetVolume(volume float64) *CalculateRequest {
r.Volume = &volume
return r
}
-//List of services codes.
+//SetServiceCode set service codes - list of comma-separated values
//If set, DPD service will return cost only for given service codes
-//code - list of codes, comma separated
func (r *CalculateRequest) SetServiceCode(code string) *CalculateRequest {
r.ServiceCode = &code
return r
}
-//If not set DPD use current date by default
+//SetPickupDate set date of parcel pickup& If not set DPD use current date by default
func (r *CalculateRequest) SetPickupDate(time time.Time) *CalculateRequest {
- d := dpdSoap.Date(time.Format("2006-01-02"))
+ d := time.Format("2006-01-02")
r.PickupDate = &d
return r
}
-//If specific service is set up for request, call of this function with any parameter
+//SetMaxDays If specific service is set up for request, call of this function with any parameter
//has not affect result of request
func (r *CalculateRequest) SetMaxDays(days int) *CalculateRequest {
r.MaxDays = &days
@@ -116,7 +106,7 @@ func (r *CalculateRequest) SetMaxDays(days int) *CalculateRequest {
return r
}
-//If specific service is set up for request, call of this function with any parameter
+//SetMaxCost If specific service is set up for request, call of this function with any parameter
//has not affect result of request
func (r *CalculateRequest) SetMaxCost(cost float64) *CalculateRequest {
r.MaxCost = &cost
@@ -124,26 +114,21 @@ func (r *CalculateRequest) SetMaxCost(cost float64) *CalculateRequest {
return r
}
+//SetDeclaredValue set cargo declared value
func (r *CalculateRequest) SetDeclaredValue(declaredValue float64) *CalculateRequest {
r.DeclaredValue = &declaredValue
return r
}
-func (r *CalculateRequest) toDpdRequest() *dpdSoap.ServiceCostRequest {
- dpdReq := dpdSoap.ServiceCostRequest(*r)
-
- return &dpdReq
-}
-
-//Set client-side delivery to DPD terminal
+//SetSelfPickup set client-side delivery to DPD terminal
func (r *CalculateRequest) SetSelfPickup(flag bool) *CalculateRequest {
r.SelfPickup = &flag
return r
}
-//Set DPD-side delivery to their terminal and customer-side pickup on DPD terminal (o_O)
+//SetSelfDelivery set DPD-side delivery to their terminal and customer-side pickup on DPD terminal
func (r *CalculateRequest) SetSelfDelivery(flag bool) *CalculateRequest {
r.SelfDelivery = &flag
diff --git a/calculateRequestBuilder_test.go b/calculateRequestBuilder_test.go
index 33ffe68..ebf36c2 100644
--- a/calculateRequestBuilder_test.go
+++ b/calculateRequestBuilder_test.go
@@ -5,13 +5,11 @@ import (
"strconv"
"testing"
"time"
-
- dpdSoap "github.com/vseinstrumentiru/dpd/soap"
)
func TestNewCity(t *testing.T) {
type args struct {
- cityId int64
+ cityID int64
}
var cityID int64 = 234
@@ -24,16 +22,17 @@ func TestNewCity(t *testing.T) {
{
"City " + strconv.Itoa(int(cityID)),
args{
- cityId: cityID,
+ cityID: cityID,
},
&CityRequest{
- CityId: &cityID,
+ CityID: &cityID,
},
},
}
for _, tt := range tests {
+ tt := tt
t.Run(tt.name, func(t *testing.T) {
- if got := NewCity(tt.args.cityId); !reflect.DeepEqual(got, tt.want) {
+ if got := NewCity(tt.args.cityID); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewCity() = %v, want %v", got, tt.want)
}
})
@@ -65,6 +64,7 @@ func TestCityRequest_SetIndex(t *testing.T) {
},
}
for _, tt := range tests {
+ tt := tt
t.Run(tt.name, func(t *testing.T) {
if got := tt.c.SetIndex(tt.args.index); !reflect.DeepEqual(got, tt.want) {
t.Errorf("CityRequest.SetIndex() = %v, want %v", got, tt.want)
@@ -187,9 +187,6 @@ func TestNewCalculateRequest(t *testing.T) {
selfPickup := false
selfDelivery := false
- dpdFrom := dpdSoap.CityRequest(*from)
- dpdTo := dpdSoap.CityRequest(*to)
-
tests := []struct {
name string
args args
@@ -205,8 +202,8 @@ func TestNewCalculateRequest(t *testing.T) {
selfDelivery,
},
&CalculateRequest{
- Pickup: &dpdFrom,
- Delivery: &dpdTo,
+ Pickup: from,
+ Delivery: to,
Weight: &weight,
SelfPickup: &selfPickup,
SelfDelivery: &selfDelivery,
@@ -215,7 +212,13 @@ func TestNewCalculateRequest(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := NewCalculateRequest(tt.args.from, tt.args.to, tt.args.weight, tt.args.selfPickup, tt.args.selfDelivery); !reflect.DeepEqual(got, tt.want) {
+ if got := NewCalculateRequest(
+ tt.args.from,
+ tt.args.to,
+ tt.args.weight,
+ tt.args.selfPickup,
+ tt.args.selfDelivery,
+ ); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewCalculateRequest() = %v, want %v", got, tt.want)
}
})
@@ -228,7 +231,6 @@ func TestCalculateRequest_SetPickup(t *testing.T) {
}
cityRequest := NewCity(123)
- dpdReq := dpdSoap.CityRequest(*cityRequest)
tests := []struct {
name string
@@ -243,15 +245,15 @@ func TestCalculateRequest_SetPickup(t *testing.T) {
cityRequest,
},
&CalculateRequest{
- Pickup: &dpdReq,
+ Pickup: cityRequest,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.OverridePickup(tt.args.city); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("CalculateRequest.OverridePickup() = %v, want %v", got, tt.want)
+ if got := tt.r.OverrideFrom(tt.args.city); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("CalculateRequest.OverrideFrom() = %v, want %v", got, tt.want)
}
})
}
@@ -263,7 +265,6 @@ func TestCalculateRequest_SetDelivery(t *testing.T) {
}
cityRequest := NewCity(123)
- dpdReq := dpdSoap.CityRequest(*cityRequest)
tests := []struct {
name string
@@ -278,15 +279,15 @@ func TestCalculateRequest_SetDelivery(t *testing.T) {
cityRequest,
},
&CalculateRequest{
- Delivery: &dpdReq,
+ Delivery: cityRequest,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.OverrideDelivery(tt.args.city); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("CalculateRequest.OverrideDelivery() = %v, want %v", got, tt.want)
+ if got := tt.r.OverrideTo(tt.args.city); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("CalculateRequest.OverrideTo() = %v, want %v", got, tt.want)
}
})
}
@@ -397,7 +398,7 @@ func TestCalculateRequest_SetPickupDate(t *testing.T) {
}
currentTime := time.Now()
- dpdDate := dpdSoap.Date(currentTime.Format("2006-01-02"))
+ dpdDate := currentTime.Format("2006-01-02")
tests := []struct {
name string
@@ -524,27 +525,6 @@ func TestCalculateRequest_SetDeclaredValue(t *testing.T) {
}
}
-func TestCalculateRequest_toDpdRequest(t *testing.T) {
- tests := []struct {
- name string
- r *CalculateRequest
- want *dpdSoap.ServiceCostRequest
- }{
- {
- "To dpd request",
- &CalculateRequest{},
- &dpdSoap.ServiceCostRequest{},
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.toDpdRequest(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("CalculateRequest.toDpdRequest() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
func TestCalculateRequest_SetSelfPickup(t *testing.T) {
type args struct {
flag bool
diff --git a/calculator2.go b/calculator2.go
new file mode 100644
index 0000000..bb2b967
--- /dev/null
+++ b/calculator2.go
@@ -0,0 +1,54 @@
+package dpd
+
+const calculatorNamespace = "http://dpd.ru/ws/Calculator/2012-03-20"
+
+type operationGetServiceCost2 struct {
+ GetServiceCost2 *getServiceCostRequest `xml:"getServiceCost2,omitempty"`
+}
+
+type getServiceCostRequest struct {
+ Namespace string `xml:"xmlns,attr"`
+ Request *CalculateRequest `xml:"request,omitempty"`
+}
+
+//CalculateRequest GetServiceCost2 request body
+type CalculateRequest struct {
+ Namespace string `xml:"xmlns,attr"`
+ Auth *Auth `xml:"auth,omitempty"`
+ Pickup *CityRequest `xml:"pickup,omitempty"`
+ Delivery *CityRequest `xml:"delivery,omitempty"`
+ SelfPickup *bool `xml:"selfPickup,omitempty"`
+ SelfDelivery *bool `xml:"selfDelivery,omitempty"`
+ Weight *float64 `xml:"weight,omitempty"`
+ Volume *float64 `xml:"volume,omitempty"`
+ ServiceCode *string `xml:"serviceCode,omitempty"`
+ PickupDate *string `xml:"pickupDate,omitempty"`
+ MaxDays *int `xml:"maxDays,omitempty"`
+ MaxCost *float64 `xml:"maxCost,omitempty"`
+ DeclaredValue *float64 `xml:"declaredValue,omitempty"`
+}
+
+//CityRequest Pickup and Delivery part of CalculateRequest
+type CityRequest struct {
+ CityID *int64 `xml:"cityId,omitempty"`
+ Index *string `xml:"index,omitempty"`
+ CityName *string `xml:"cityName,omitempty"`
+ RegionCode *int `xml:"regionCode,omitempty"`
+ CountryCode *string `xml:"countryCode,omitempty"`
+}
+
+type getServiceCostResponse struct {
+ Return []*ServiceCostResponse `xml:"return,omitempty"`
+}
+
+//ServiceCostResponse GetServiceCost2 return body
+type ServiceCostResponse struct {
+ ServiceCode *string `xml:"serviceCode,omitempty"`
+ ServiceName *string `xml:"serviceName,omitempty"`
+ Cost *float64 `xml:"cost,omitempty"`
+ Days *int `xml:"days,omitempty"`
+}
+
+type operationGetServiceCost2Response struct {
+ GetServiceCostResponse *getServiceCostResponse `xml:"getServiceCost2Response,omitempty"`
+}
diff --git a/client.go b/client.go
index 7fb9988..8e2d9d0 100644
--- a/client.go
+++ b/client.go
@@ -2,289 +2,353 @@ package dpd
import (
"github.com/fiorix/wsdl2go/soap"
- dpdSoap "github.com/vseinstrumentiru/dpd/soap"
)
-//Client to call DPD SOAP api methods
-//
-//Names of functions are equals original DPD SOAP methods names
-type DPDClient struct {
- auth DPDAuth
- urls DPDUrls
- services *services
+//Client for DPD soap api
+type Client struct {
+ auth *Auth
+ services *soapClients
}
-//DPD authorization
-type DPDAuth struct {
- ClientNumber int64
- ClientKey string
+//ServiceUrls DPD services urls
+type ServiceUrls struct {
+ CalculatorURL string
+ GeographyURL string
+ OrderURL string
+ TrackingURL string
}
-//URLs of DPD services
-type DPDUrls struct {
- CalculatorUrl string
- GeographyUrl string
- OrderUrl string
- TrackingUrl string
+type soapClients struct {
+ geography *soap.Client
+ order *soap.Client
+ calculator *soap.Client
+ tracking *soap.Client
}
-type services struct {
- geography dpdSoap.DPDGeography2
- order dpdSoap.DPDOrder
- calculator dpdSoap.DPDCalculator
- tracking dpdSoap.ParcelTracing
-}
-
-//Creates new client
-func NewDPDClient(auth DPDAuth, urls DPDUrls) *DPDClient {
- return &DPDClient{
- auth: auth,
- urls: urls,
- services: &services{},
+//NewClient creates new client
+func NewClient(clientNumber int64, clientKey string, urls ServiceUrls) *Client {
+ return &Client{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ geography: &soap.Client{
+ Namespace: geographyNamespace,
+ URL: urls.GeographyURL,
+ },
+ order: &soap.Client{
+ Namespace: orderNamespace,
+ URL: urls.OrderURL,
+ },
+ calculator: &soap.Client{
+ Namespace: calculatorNamespace,
+ URL: urls.CalculatorURL,
+ },
+ tracking: &soap.Client{
+ Namespace: trackingNamespace,
+ URL: urls.TrackingURL,
+ },
+ },
}
}
-const (
- ScehduleSelfDelivery = "SelfDelivery"
-)
-
-func (cl *DPDClient) getGeographyService() dpdSoap.DPDGeography2 {
- if cl.services.geography == nil {
- client := soap.Client{
- Namespace: dpdSoap.GeographyNamespace,
- URL: cl.urls.GeographyUrl,
- }
-
- cl.services.geography = dpdSoap.NewDPDGeography2(&client)
+//GetParcelShops return list of pickup/delivery points with restrictions about weight and dimensions
+func (cl *Client) GetParcelShops(req *ParcelShopRequest) ([]*ParcelShop, error) {
+ req.Auth = cl.auth
+ req.Namespace = ""
+
+ a := struct {
+ operationGetParcelShops `xml:"tns:getParcelShops"`
+ }{
+ operationGetParcelShops{
+ &getParcelShops{
+ req,
+ geographyNamespace,
+ },
+ },
}
- return cl.services.geography
-}
-
-func (cl *DPDClient) getOrderService() dpdSoap.DPDOrder {
- if cl.services.order == nil {
- client := soap.Client{
- Namespace: dpdSoap.OrderNamespace,
- URL: cl.urls.OrderUrl,
- }
+ y := struct {
+ operationGetParcelShopsResponse `xml:"getParcelShopsResponse"`
+ }{}
- cl.services.order = dpdSoap.NewDPDOrder(&client)
+ if err := cl.services.geography.RoundTripWithAction("GetParcelShops", a, &y); err != nil {
+ return nil, err
}
- return cl.services.order
+ return y.operationGetParcelShopsResponse.GetParcelShopsResponse.Return.ParcelShop, nil
}
-func (cl *DPDClient) getCalculatorService() dpdSoap.DPDCalculator {
- if cl.services.calculator == nil {
- client := soap.Client{
- Namespace: dpdSoap.CalculatorNamespace,
- URL: cl.urls.CalculatorUrl,
- }
-
- cl.services.calculator = dpdSoap.NewDPDCalculator(&client)
+//GetTerminalsSelfDelivery2 return terminals list. They don't have any restrictions
+func (cl *Client) GetTerminalsSelfDelivery2() ([]*Terminal, error) {
+ auth := cl.auth
+ auth.Namespace = new(string)
+
+ a := struct {
+ operationGetTerminalsSelfDelivery2 `xml:"tns:getTerminalsSelfDelivery2"`
+ }{
+ operationGetTerminalsSelfDelivery2{
+ &getTerminalsSelfDelivery2Request{
+ Auth: auth,
+ Namespace: geographyNamespace,
+ },
+ },
}
- return cl.services.calculator
-}
-
-func (cl *DPDClient) getTrackingService() dpdSoap.ParcelTracing {
- if cl.services.tracking == nil {
- client := soap.Client{
- Namespace: dpdSoap.TrackingNamespace,
- URL: cl.urls.TrackingUrl,
- }
+ y := struct {
+ operationGetTerminalsSelfDelivery2Response `xml:"getTerminalsSelfDelivery2Response"`
+ }{}
- cl.services.tracking = dpdSoap.NewParcelTracing(&client)
+ if err := cl.services.geography.RoundTripWithAction("getTerminalsSelfDelivery2Request", a, &y); err != nil {
+ return nil, err
}
- return cl.services.tracking
+ return y.Response.Return.Terminal, nil
}
-//Get list of pickup/delivery points with restrictions about weight and dimensions
-func (cl *DPDClient) GetParcelShops(r *ParcelShopRequest) ([]*dpdSoap.ParcelShop, error) {
- req := r.toDPDRequest()
- req.Auth = cl.getAuth()
- req.Ns = ""
+//GetCitiesCashPay countryCode must comply with ISO 3166-1 alpha-2
+func (cl *Client) GetCitiesCashPay(countryCode string) ([]*City, error) {
+ a := struct {
+ operationGetCitiesCashPay `xml:"tns:getCitiesCashPay"`
+ }{
+ operationGetCitiesCashPay{
+ &getCitiesCashPay{
+ Namespace: geographyNamespace,
+ Request: &citiesCashPayRequest{
+ Auth: cl.auth,
+ CountryCode: &countryCode,
+ },
+ },
+ },
+ }
- result, err := cl.getGeographyService().GetParcelShops(&dpdSoap.GetParcelShops{
- Request: req,
- Ns: dpdSoap.GeographyNamespace,
- })
+ y := struct {
+ operationGetCitiesCashPayResponse `xml:"getCitiesCashPayResponse"`
+ }{}
- if err != nil {
+ if err := cl.services.geography.RoundTripWithAction("GetCitiesCashPay", a, &y); err != nil {
return nil, err
}
- return result.Return.ParcelShop, nil
+ return y.GetCitiesCashPayResponse.Return, nil
}
-//Get terminals list. They don't have any restrictions
-func (cl *DPDClient) GetTerminalsSelfDelivery2() ([]*dpdSoap.TerminalSelf, error) {
- auth := cl.getAuth()
- auth.Ns = new(string)
+//GetServiceCost2 return cost of delivery for Russia and Customs Union
+func (cl *Client) GetServiceCost2(req *CalculateRequest) ([]*ServiceCostResponse, error) {
+ req.Auth = cl.auth
+ a := struct {
+ operationGetServiceCost2 `xml:"tns:getServiceCost2"`
+ }{
+ operationGetServiceCost2{
+ &getServiceCostRequest{
+ Namespace: calculatorNamespace,
+ Request: req,
+ },
+ },
+ }
- result, err := cl.getGeographyService().GetTerminalsSelfDelivery2(&dpdSoap.GetTerminalsSelfDelivery2{
- Ns: dpdSoap.GeographyNamespace,
- Auth: auth,
- })
+ y := struct {
+ operationGetServiceCost2Response `xml:"getServiceCost2Response"`
+ }{}
- if err != nil {
+ if err := cl.services.calculator.RoundTripWithAction("GetServiceCost2", a, &y); err != nil {
return nil, err
}
- return result.Return.Terminal, nil
+ return y.GetServiceCostResponse.Return, nil
}
-//Set country code according ISO 3166-1 alpha-2 standard
-//
-//https://www.iso.org/obp/ui/#search
-func (cl *DPDClient) GetCitiesCashPay(countryCode string) ([]*dpdSoap.City, error) {
- result, err := cl.getGeographyService().GetCitiesCashPay(&dpdSoap.GetCitiesCashPay{
- NS: dpdSoap.GeographyNamespace,
- Request: &dpdSoap.DpdCitiesCashPayRequest{
- Auth: cl.getAuth(),
- CountryCode: &countryCode,
+//CreateOrder create a delivery order
+func (cl *Client) CreateOrder(req *CreateOrderRequest) ([]*OrderStatus, error) {
+ req.Auth = cl.auth
+ a := struct {
+ operationCreateOrder `xml:"tns:createOrder"`
+ }{
+ operationCreateOrder{
+ &createOrder{
+ req,
+ },
},
- })
-
- if err != nil {
- return nil, err
}
- return result.Return, nil
-}
-
-//Calculate cost of delivery for Russia and Customs Union
-func (cl *DPDClient) GetServiceCost2(r *CalculateRequest) ([]*dpdSoap.ServiceCost, error) {
- req := r.toDpdRequest()
- req.Auth = cl.getAuth()
-
- result, err := cl.getCalculatorService().GetServiceCost2(&dpdSoap.GetServiceCost2{
- Ns: dpdSoap.CalculatorNamespace,
- Request: req,
- })
+ y := struct {
+ operationCreateOrderResponse `xml:"createOrderResponse"`
+ }{}
- if err != nil {
+ if err := cl.services.order.RoundTripWithAction("CreateOrder", a, &y); err != nil {
return nil, err
}
- return result.Return, nil
+ return y.CreateOrderResponse.Return, nil
}
-func (cl *DPDClient) CreateOrder(r *CreateOrderRequest) ([]*dpdSoap.DpdOrderStatus, error) {
- req := r.toDPDRequest()
- req.Auth = cl.getAuth()
+//AddParcels change order with parcel addition
+func (cl *Client) AddParcels(req *UpdateOrderRequest) (*OrderCorrectionStatus, error) {
+ req.Auth = cl.auth
+
+ a := struct {
+ operationAddParcels `xml:"tns:addParcels"`
+ }{
+ operationAddParcels{
+ &addParcels{
+ req,
+ },
+ },
+ }
- result, err := cl.getOrderService().CreateOrder(&dpdSoap.CreateOrder{
- Orders: req,
- })
+ y := struct {
+ operationAddParcelsResponse `xml:"addParcelsResponse"`
+ }{}
- if err != nil {
+ if err := cl.services.order.RoundTripWithAction("AddParcels", a, &y); err != nil {
return nil, err
}
- return result.Return, nil
+ return y.AddParcelsResponse.Return, nil
}
-//Change order. Add parcels to order
-func (cl *DPDClient) AddParcels(r *UpdateOrderRequest) (*dpdSoap.DpdOrderCorrectionStatus, error) {
- req := r.toDPDRequest()
- r.Auth = cl.getAuth()
+//RemoveParcels change order with parcel deletion
+func (cl *Client) RemoveParcels(req *UpdateOrderRequest) (*OrderCorrectionStatus, error) {
+ req.Auth = cl.auth
+ a := struct {
+ operationRemoveParcels `xml:"tns:removeParcels"`
+ }{
+ operationRemoveParcels{
+ &removeParcels{
+ req,
+ },
+ },
+ }
- result, err := cl.getOrderService().AddParcels(&dpdSoap.AddParcels{
- Parcels: req,
- })
+ y := struct {
+ operationRemoveParcelsResponse `xml:"removeParcelsResponse"`
+ }{}
- if err != nil {
+ if err := cl.services.order.RoundTripWithAction("RemoveParcels", a, &y); err != nil {
return nil, err
}
- return result.Return, nil
+ return y.RemoveParcelsResponse.Return, nil
}
-//Change order. Remove parcels from order
-func (cl *DPDClient) RemoveParcels(r *UpdateOrderRequest) (*dpdSoap.DpdOrderCorrectionStatus, error) {
- req := r.toDPDRequest()
- r.Auth = cl.getAuth()
-
- result, err := cl.getOrderService().RemoveParcels(&dpdSoap.RemoveParcels{
- Parcels: req,
- })
+//CancelOrder cancel a delivery order
+func (cl *Client) CancelOrder(req *CancelOrderRequest) ([]*OrderStatus, error) {
+ req.Auth = cl.auth
+ a := struct {
+ operationCancelOrder `xml:"tns:cancelOrder"`
+ }{
+ operationCancelOrder{
+ &cancelOrder{
+ req,
+ },
+ },
+ }
- if err != nil {
+ y := struct {
+ operationCancelOrderResponse `xml:"cancelOrderResponse"`
+ }{}
+ if err := cl.services.order.RoundTripWithAction("CancelOrder", a, &y); err != nil {
return nil, err
}
- return result.Return, nil
+ return y.CancelOrderResponse.Return, nil
}
-func (cl *DPDClient) CancelOrder(r *CancelOrderRequest) ([]*dpdSoap.DpdOrderStatus, error) {
- req := r.toDPDRequest()
- r.Auth = cl.getAuth()
-
- result, err := cl.getOrderService().CancelOrder(&dpdSoap.CancelOrder{
- Orders: req,
- })
+//GetOrderStatus returns order creation status
+func (cl *Client) GetOrderStatus(req []*InternalOrderNumber) ([]*OrderStatus, error) {
+ a := struct {
+ operationGetOrderStatus `xml:"tns:getOrderStatus"`
+ }{
+ operationGetOrderStatus{
+ &getOrderStatus{
+ &getOrderStatusRequest{
+ Auth: cl.auth,
+ Order: req,
+ },
+ },
+ },
+ }
- if err != nil {
+ y := struct {
+ operationGetOrderStatusResponse `xml:"getOrderStatusResponse"`
+ }{}
+ if err := cl.services.order.RoundTripWithAction("GetOrderStatus", a, &y); err != nil {
return nil, err
}
-
- return result.Return, nil
+ return y.GetOrderStatusResponse.Return, nil
}
-//Return all parcels statuses that changed after last request
-func (cl *DPDClient) GetStatesByClient() (*dpdSoap.StateParcels, error) {
- result, err := cl.getTrackingService().GetStatesByClient(&dpdSoap.GetStatesByClient{
- Request: &dpdSoap.RequestClient{
- Auth: cl.getAuth(),
+//GetStatesByClient returns all statuses of client parcels since previous method call
+func (cl *Client) GetStatesByClient() (*ParcelsStates, error) {
+ a := struct {
+ operationGetStatesByClient `xml:"tns:getStatesByClient"`
+ }{
+ operationGetStatesByClient{
+ &getStatesByClient{
+ &getStatesByClientRequest{
+ Auth: cl.auth,
+ },
+ },
},
- })
+ }
+
+ y := struct {
+ operationGetStatesByClientResponse `xml:"getStatesByClientResponse"`
+ }{}
- if err != nil {
+ if err := cl.services.tracking.RoundTripWithAction("GetStatesByClient", a, &y); err != nil {
return nil, err
}
- return result.Return, err
+ return y.GetStatesByClientResponse.Return, nil
}
-//Get list of states for all parcels for specified order
+//GetStatesByClientOrder returns list of states for all parcels for specified order
//Order identify by client side order number
-func (cl *DPDClient) GetStatesByClientOrder(r *ClientOrderRequest) (*dpdSoap.StateParcels, error) {
- req := r.toDPDRequest()
- req.Auth = cl.getAuth()
+func (cl *Client) GetStatesByClientOrder(req *TrackByClientOrderRequest) (*ParcelsStates, error) {
+ req.Auth = cl.auth
+ a := struct {
+ operationGetStatesByClientOrder `xml:"tns:getStatesByClientOrder"`
+ }{
+ operationGetStatesByClientOrder{
+ &getStatesByClientOrder{
+ req,
+ },
+ },
+ }
- result, err := cl.getTrackingService().GetStatesByClientOrder(&dpdSoap.GetStatesByClientOrder{
- Request: req,
- })
+ y := struct {
+ operationGetStatesByClientOrderResponse `xml:"getStatesByClientOrderResponse"`
+ }{}
- if err != nil {
+ if err := cl.services.tracking.RoundTripWithAction("GetStatesByClientOrder", a, &y); err != nil {
return nil, err
}
- return result.Return, nil
+ return y.GetStatesByClientOrderResponse.Return, nil
}
-//Get states history for specified parcel
+//GetStatesByDPDOrder returns states history for specified parcel
//Parcel identify by client side parcel number
-func (cl *DPDClient) GetStatesByDPDOrder(r *DpdOrderRequest) (*dpdSoap.StateParcels, error) {
- req := r.toDPDRequest()
- req.Auth = cl.getAuth()
-
- result, err := cl.getTrackingService().GetStatesByDPDOrder(&dpdSoap.GetStatesByDPDOrder{
- Request: req,
- })
+func (cl *Client) GetStatesByDPDOrder(req *TrackByDPDOrderRequest) (*ParcelsStates, error) {
+ req.Auth = cl.auth
+ a := struct {
+ operationGetStatesByDPDOrder `xml:"tns:getStatesByDPDOrder"`
+ }{
+ operationGetStatesByDPDOrder{
+ &getStatesByDPDOrder{
+ req,
+ },
+ },
+ }
- if err != nil {
+ y := struct {
+ operationGetStatesByDPDOrderResponse `xml:"getStatesByDPDOrderResponse"`
+ }{}
+ if err := cl.services.tracking.RoundTripWithAction("GetStatesByDPDOrder", a, &y); err != nil {
return nil, err
}
- return result.Return, nil
-}
-
-func (cl *DPDClient) getAuth() *dpdSoap.Auth {
- return &dpdSoap.Auth{
- ClientNumber: &cl.auth.ClientNumber,
- ClientKey: &cl.auth.ClientKey,
- }
+ return y.GetStatesByDPDOrderResponse.Return, nil
}
diff --git a/client_test.go b/client_test.go
index 4c11f75..e3e2e29 100644
--- a/client_test.go
+++ b/client_test.go
@@ -1,36 +1,40 @@
package dpd
import (
+ "fmt"
+ "log"
+ "net/http"
"reflect"
"testing"
+ "time"
"github.com/fiorix/wsdl2go/soap"
- dpdSoap "github.com/vseinstrumentiru/dpd/soap"
)
-func ExampleNewDPDClient() {
- NewDPDClient(
- DPDAuth{
- ClientKey: "key",
- ClientNumber: 1000000,
- },
- DPDUrls{
- CalculatorUrl: "",
- OrderUrl: "",
- GeographyUrl: "",
- TrackingUrl: "",
- },
- )
+func ExampleNewClient() {
+ NewClient(anyNumber, anyKey, ServiceUrls{
+ CalculatorURL: "",
+ OrderURL: "",
+ GeographyURL: "",
+ TrackingURL: "",
+ })
}
-func ExampleDPDClient_GetCitiesCashPay() {
- client := NewDPDClient(DPDAuth{}, DPDUrls{})
+func ExampleClient_GetCitiesCashPay() {
+ client := NewClient(0, "", ServiceUrls{})
+
+ cities, err := client.GetCitiesCashPay("RU")
+ if err != nil {
+ log.Fatalf("Error occurred %s", err.Error())
+ }
- client.GetCitiesCashPay("RU")
+ for _, value := range cities {
+ fmt.Println(*value.CityName)
+ }
}
-func ExampleDPDClient_GetServiceCost2() {
- client := NewDPDClient(DPDAuth{}, DPDUrls{})
+func ExampleClient_GetServiceCost2() {
+ client := NewClient(0, "", ServiceUrls{})
req := NewCalculateRequest(
NewCity(123).SetCityName("Анапа"),
@@ -39,11 +43,18 @@ func ExampleDPDClient_GetServiceCost2() {
false,
false)
- client.GetServiceCost2(req)
+ offers, err := client.GetServiceCost2(req)
+ if err != nil {
+ log.Fatalf("Error occurred %s", err.Error())
+ }
+
+ for _, value := range offers {
+ fmt.Printf("Delivery cost: %b", *value.Cost)
+ }
}
-func ExampleDPDClient_GetParcelShops() {
- client := NewDPDClient(DPDAuth{}, DPDUrls{})
+func ExampleClient_GetParcelShops() {
+ client := NewClient(0, "", ServiceUrls{})
req := NewParcelShopRequest()
@@ -54,193 +65,2106 @@ func ExampleDPDClient_GetParcelShops() {
req.SetCountryCode("RU").
SetCityCode("1243124") //DPD native, city identifier
- client.GetParcelShops(req)
-}
-
-var auth = DPDAuth{
- ClientNumber: 123,
- ClientKey: "client_key",
-}
+ shops, err := client.GetParcelShops(req)
+ if err != nil {
+ log.Fatalf("Error occurred %s", err.Error())
+ }
-var urls = DPDUrls{
- CalculatorUrl: "url",
- GeographyUrl: "url",
- OrderUrl: "url",
- TrackingUrl: "url",
+ for _, value := range shops {
+ fmt.Printf("Shop: %s", *value.Brand)
+ }
}
-func TestNewDPDClient(t *testing.T) {
+func TestNewClient(t *testing.T) {
type args struct {
- auth DPDAuth
- urls DPDUrls
+ clientNumber int64
+ clientKey string
+ urls ServiceUrls
}
+
+ clientNumber := int64(anyNumber)
+ clientKey := anyKey
+
tests := []struct {
name string
args args
- want *DPDClient
+ want *Client
}{
{
- "Client with Auth and Urls",
+ "Client constructor",
args{
- auth,
- urls,
+ clientNumber,
+ clientKey,
+ ServiceUrls{
+ "", "", "", "",
+ },
},
-
- &DPDClient{
- auth,
- urls,
- &services{},
+ &Client{
+ &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ &soapClients{
+ geography: &soap.Client{
+ Namespace: geographyNamespace,
+ URL: "",
+ },
+ calculator: &soap.Client{
+ Namespace: calculatorNamespace,
+ URL: "",
+ },
+ order: &soap.Client{
+ Namespace: orderNamespace,
+ URL: "",
+ },
+ tracking: &soap.Client{
+ Namespace: trackingNamespace,
+ URL: "",
+ },
+ },
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := NewDPDClient(tt.args.auth, tt.args.urls); !reflect.DeepEqual(got, tt.want) {
-
- t.Errorf("NewDPDClient() = %v, want %v", got, tt.want)
+ if got := NewClient(tt.args.clientNumber, tt.args.clientKey, tt.args.urls); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("NewClient() = %v, want %v", got, tt.want)
}
})
}
}
-func TestDPDClient_getGeographyService(t *testing.T) {
- dpdClient := NewDPDClient(auth, urls)
- soapClient := soap.Client{
- Namespace: dpdSoap.GeographyNamespace,
- URL: urls.GeographyUrl,
+func TestClient_CreateOrder(t *testing.T) {
+ type fields struct {
+ auth *Auth
+ services *soapClients
+ }
+ type args struct {
+ req *CreateOrderRequest
+ }
+
+ okServer := makeTestHTTPServer(t, http.StatusOK, getCreateOrderSuccessResponse())
+ defer okServer.Close()
+
+ errServer := makeTestHTTPServer(t, http.StatusInternalServerError, []byte(""))
+ defer errServer.Close()
+
+ clientNumber := int64(anyNumber)
+ clientKey := anyKey
+
+ okFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ order: &soap.Client{
+ Namespace: orderNamespace,
+ URL: okServer.URL,
+ },
+ },
+ }
+
+ errFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ order: &soap.Client{
+ Namespace: orderNamespace,
+ URL: errServer.URL,
+ },
+ },
+ }
+
+ datePickup := time.Now().Format("2006-01-02")
+
+ senderName := "Туда-сюда контора"
+ senderCountry := thisCountry
+ senderRegion := "Московская обл."
+ senderCity := "Котельники"
+ senderStreet := "Ленина"
+ senderStreetAbbr := "ул."
+ senderHouse := "3"
+ senderContactFio := "Туда-Сюда Человек"
+ senderContactPhone := "+790000000000"
+ pickupTimePeriod := "9-18"
+
+ orderNumberInternal := internalOrderNumber
+ serviceCode := "PCL"
+ serviceVariant := "ДД"
+ cargoNumPack := 1
+ cargoWeight := 5.3
+ cargoRegistered := false
+ cargoCategory := "Категория"
+
+ receiverName := "Инокентий"
+ receiverCountryName := thisCountry
+ receiverRegion := "Нижугородская обл."
+ receiverCity := "Арзамас"
+ receiverStreet := "Ленина"
+ receiverStreetAbbr := "ул"
+ receiverHouse := "8"
+ receiverFlat := "5"
+ receiverContactFio := "Инокентий Мутный"
+ receiverContactPhone := "+79888888888"
+
+ orderNum := dpdOrderNumber
+ status := "OK"
+
+ arg := args{&CreateOrderRequest{
+ Header: &Header{
+ DatePickup: &datePickup,
+ SenderAddress: &Address{
+ Name: &senderName,
+ CountryName: &senderCountry,
+ Region: &senderRegion,
+ City: &senderCity,
+ Street: &senderStreet,
+ StreetAbbr: &senderStreetAbbr,
+ House: &senderHouse,
+ ContactFio: &senderContactFio,
+ ContactPhone: &senderContactPhone,
+ },
+ PickupTimePeriod: &pickupTimePeriod,
+ },
+ Order: []*Order{
+ {
+ OrderNumberInternal: &orderNumberInternal,
+ ServiceCode: &serviceCode,
+ ServiceVariant: &serviceVariant,
+ CargoNumPack: &cargoNumPack,
+ CargoWeight: &cargoWeight,
+ CargoRegistered: &cargoRegistered,
+ CargoCategory: &cargoCategory,
+ ReturnAddress: &Address{
+ Name: &receiverName,
+ CountryName: &receiverCountryName,
+ Region: &receiverRegion,
+ City: &receiverCity,
+ Street: &receiverStreet,
+ StreetAbbr: &receiverStreetAbbr,
+ House: &receiverHouse,
+ Flat: &receiverFlat,
+ ContactFio: &receiverContactFio,
+ ContactPhone: &receiverContactPhone,
+ },
+ },
+ },
+ },
}
- want := dpdSoap.NewDPDGeography2(&soapClient)
+ want := []*OrderStatus{
+ {
+ OrderNumberInternal: &orderNumberInternal,
+ OrderNum: &orderNum,
+ Status: &status,
+ },
+ }
tests := []struct {
- name string
- cl *DPDClient
- want dpdSoap.DPDGeography2
+ name string
+ fields fields
+ args args
+ want []*OrderStatus
+ wantErr bool
}{
{
- "Get geography service",
- dpdClient,
+ "Success",
+ okFields,
+ arg,
want,
+ false,
+ },
+ {
+ "Fail",
+ errFields,
+ arg,
+ nil,
+ true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := tt.cl.getGeographyService(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("DPDClient.getGeographyService() = %v, want %v", got, tt.want)
+ cl := &Client{
+ auth: tt.fields.auth,
+ services: tt.fields.services,
+ }
+ got, err := cl.CreateOrder(tt.args.req)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Client.CreateOrder() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Client.CreateOrder() = %v, want %v", got, tt.want)
}
})
}
}
-func TestDPDClient_getOrderService(t *testing.T) {
- dpdClient := NewDPDClient(auth, urls)
- soapClient := soap.Client{
- Namespace: dpdSoap.OrderNamespace,
- URL: urls.OrderUrl,
+func TestClient_AddParcels(t *testing.T) {
+ type fields struct {
+ auth *Auth
+ services *soapClients
+ }
+ type args struct {
+ req *UpdateOrderRequest
+ }
+
+ okServer := makeTestHTTPServer(t, http.StatusOK, getAddParcelsSuccessResponse())
+ defer okServer.Close()
+
+ errServer := makeTestHTTPServer(t, http.StatusInternalServerError, []byte(""))
+ defer errServer.Close()
+
+ clientNumber := int64(anyNumber)
+ clientKey := anyKey
+
+ okFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ order: &soap.Client{
+ Namespace: orderNamespace,
+ URL: okServer.URL,
+ },
+ },
+ }
+
+ errFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ order: &soap.Client{
+ Namespace: orderNamespace,
+ URL: errServer.URL,
+ },
+ },
+ }
+
+ orderNum := dpdOrderNumber
+ orderNumberInternal := internalOrderNumber
+ cargoNumPack := 2
+ cargoWeight := 1.1
+ cargoVolume := 0.05
+ cargoCategory := "category"
+ statusOK := "OK"
+
+ arg := args{
+ &UpdateOrderRequest{
+ Auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ OrderNum: &orderNum,
+ OrderNumberInternal: &orderNumberInternal,
+ CargoNumPack: &cargoNumPack,
+ CargoWeight: &cargoWeight,
+ CargoVolume: &cargoVolume,
+ CargoCategory: &cargoCategory,
+ },
}
- want := dpdSoap.NewDPDOrder(&soapClient)
+ want := &OrderCorrectionStatus{
+ OrderNum: &orderNum,
+ Status: &statusOK,
+ }
tests := []struct {
- name string
- cl *DPDClient
- want dpdSoap.DPDOrder
+ name string
+ fields fields
+ args args
+ want *OrderCorrectionStatus
+ wantErr bool
}{
{
- "Get order service",
- dpdClient,
+ "Success",
+ okFields,
+ arg,
want,
+ false,
+ },
+ {
+ "Fail",
+ errFields,
+ arg,
+ nil,
+ true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := tt.cl.getOrderService(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("DPDClient.getOrderService() = %v, want %v", got, tt.want)
+ cl := &Client{
+ auth: tt.fields.auth,
+ services: tt.fields.services,
+ }
+ got, err := cl.AddParcels(tt.args.req)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Client.AddParcels() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Client.AddParcels() = %v, want %v", got, tt.want)
}
})
}
}
-func TestDPDClient_getCalculatorService(t *testing.T) {
- dpdClient := NewDPDClient(auth, urls)
- soapClient := soap.Client{
- Namespace: dpdSoap.CalculatorNamespace,
- URL: urls.CalculatorUrl,
+func TestClient_RemoveParcels(t *testing.T) {
+ type fields struct {
+ auth *Auth
+ services *soapClients
+ }
+ type args struct {
+ req *UpdateOrderRequest
+ }
+
+ okServer := makeTestHTTPServer(t, http.StatusOK, getRemoveParcelsSuccessResponse())
+ defer okServer.Close()
+
+ errServer := makeTestHTTPServer(t, http.StatusInternalServerError, []byte(""))
+ defer errServer.Close()
+
+ clientNumber := int64(anyNumber)
+ clientKey := anyKey
+
+ okFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ order: &soap.Client{
+ Namespace: orderNamespace,
+ URL: okServer.URL,
+ },
+ },
+ }
+
+ errFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ order: &soap.Client{
+ Namespace: orderNamespace,
+ URL: errServer.URL,
+ },
+ },
+ }
+
+ dpdOrderNum := dpdOrderNumber
+ orderNumberinternal := internalOrderNumber
+ cargoNumPack := 1
+ cargoWeight := 1.1
+ cargoVolume := 0.05
+ cargoCategory := "category"
+ parcelNum := "1"
+ statusOK := "OK"
+
+ arg := args{
+ &UpdateOrderRequest{
+ Auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ OrderNum: &dpdOrderNum,
+ OrderNumberInternal: &orderNumberinternal,
+ CargoNumPack: &cargoNumPack,
+ CargoWeight: &cargoWeight,
+ CargoVolume: &cargoVolume,
+ CargoCategory: &cargoCategory,
+ Parcel: []*Parcel{
+ {
+ Number: &parcelNum,
+ },
+ },
+ },
}
- want := dpdSoap.NewDPDCalculator(&soapClient)
+ want := &OrderCorrectionStatus{
+ OrderNum: &dpdOrderNum,
+ Status: &statusOK,
+ ParcelStatus: []*ParcelStatus{
+ {
+ Number: &parcelNum,
+ Status: &statusOK,
+ },
+ },
+ }
tests := []struct {
- name string
- cl *DPDClient
- want dpdSoap.DPDCalculator
+ name string
+ fields fields
+ args args
+ want *OrderCorrectionStatus
+ wantErr bool
}{
{
- "Get calculator service",
- dpdClient,
+ "Success",
+ okFields,
+ arg,
want,
+ false,
+ },
+ {
+ "Fail",
+ errFields,
+ arg,
+ nil,
+ true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := tt.cl.getCalculatorService(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("DPDClient.getCalculatorService() = %v, want %v", got, tt.want)
+ cl := &Client{
+ auth: tt.fields.auth,
+ services: tt.fields.services,
+ }
+ got, err := cl.RemoveParcels(tt.args.req)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Client.RemoveParcels() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Client.RemoveParcels() = %v, want %v", got, tt.want)
}
})
}
}
-func TestDPDClient_getTrackingService(t *testing.T) {
- dpdClient := NewDPDClient(auth, urls)
- soapClient := soap.Client{
- Namespace: dpdSoap.TrackingNamespace,
- URL: urls.TrackingUrl,
+func TestClient_CancelOrder(t *testing.T) {
+ type fields struct {
+ auth *Auth
+ services *soapClients
+ }
+ type args struct {
+ req *CancelOrderRequest
+ }
+
+ okServer := makeTestHTTPServer(t, http.StatusOK, getCancelOrderSuccessResponse())
+ defer okServer.Close()
+
+ errServer := makeTestHTTPServer(t, http.StatusInternalServerError, []byte(""))
+ defer errServer.Close()
+
+ clientNumber := int64(anyNumber)
+ clientKey := anyKey
+
+ okFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ order: &soap.Client{
+ Namespace: orderNamespace,
+ URL: okServer.URL,
+ },
+ },
+ }
+
+ errFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ order: &soap.Client{
+ Namespace: orderNamespace,
+ URL: errServer.URL,
+ },
+ },
+ }
+
+ orderNum := dpdOrderNumber
+ pickupDate := string("2019-07-15")
+
+ orderNumberInternal := internalOrderNumber
+ status := "Canceled"
+
+ arg := args{
+ &CancelOrderRequest{
+ Cancel: []*OrderToCancel{
+ {
+ OrderNum: &orderNum,
+ PickupDate: &pickupDate,
+ },
+ },
+ },
}
- want := dpdSoap.NewParcelTracing(&soapClient)
+ want :=
+ []*OrderStatus{
+ {
+ OrderNumberInternal: &orderNumberInternal,
+ OrderNum: &orderNum,
+ Status: &status,
+ },
+ }
tests := []struct {
- name string
- cl *DPDClient
- want dpdSoap.ParcelTracing
+ name string
+ fields fields
+ args args
+ want []*OrderStatus
+ wantErr bool
}{
{
- "Get tracking service",
- dpdClient,
+ "Success",
+ okFields,
+ arg,
want,
+ false,
+ },
+ {
+ "Fail",
+ errFields,
+ arg,
+ nil,
+ true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := tt.cl.getTrackingService(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("DPDClient.getTrackingService() = %v, want %v", got, tt.want)
+ cl := &Client{
+ auth: tt.fields.auth,
+ services: tt.fields.services,
+ }
+ got, err := cl.CancelOrder(tt.args.req)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Client.CancelOrder() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Client.CancelOrder() = %v, want %v", got, tt.want)
}
})
}
}
-func TestDPDClient_getAuth(t *testing.T) {
- dpdClient := NewDPDClient(auth, urls)
+func TestClient_GetOrderStatus(t *testing.T) {
+ type fields struct {
+ auth *Auth
+ services *soapClients
+ }
+ type args struct {
+ req []*InternalOrderNumber
+ }
+
+ okServer := makeTestHTTPServer(t, http.StatusOK, getOrderStatusSuccessResponse())
+ defer okServer.Close()
+
+ errServer := makeTestHTTPServer(t, http.StatusInternalServerError, []byte(""))
+ defer errServer.Close()
+
+ clientNumber := int64(anyNumber)
+ clientKey := anyKey
+
+ okFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ order: &soap.Client{
+ Namespace: orderNamespace,
+ URL: okServer.URL,
+ },
+ },
+ }
+
+ errFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ order: &soap.Client{
+ Namespace: orderNamespace,
+ URL: errServer.URL,
+ },
+ },
+ }
+
+ orderNumberInternal := internalOrderNumber
+
+ arg := args{
+ []*InternalOrderNumber{
+ {
+ OrderNumberInternal: &orderNumberInternal,
+ },
+ },
+ }
+
+ orderNum := dpdOrderNumber
+ status := "OrderCancelled"
+
+ want := []*OrderStatus{
+ {
+ OrderNumberInternal: &orderNumberInternal,
+ OrderNum: &orderNum,
+ Status: &status,
+ },
+ }
tests := []struct {
- name string
- cl *DPDClient
- want *dpdSoap.Auth
+ name string
+ fields fields
+ args args
+ want []*OrderStatus
+ wantErr bool
}{
{
- "Get auth",
- dpdClient,
- &dpdSoap.Auth{
- ClientNumber: &auth.ClientNumber,
- ClientKey: &auth.ClientKey,
+ "Success",
+ okFields,
+ arg,
+ want,
+ false,
+ },
+ {
+ "Fail",
+ errFields,
+ arg,
+ nil,
+ true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ cl := &Client{
+ auth: tt.fields.auth,
+ services: tt.fields.services,
+ }
+ got, err := cl.GetOrderStatus(tt.args.req)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Client.GetOrderStatus() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Client.GetOrderStatus() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestClient_GetServiceCost2(t *testing.T) {
+ type fields struct {
+ auth *Auth
+ services *soapClients
+ }
+ type args struct {
+ req *CalculateRequest
+ }
+
+ okServer := makeTestHTTPServer(t, http.StatusOK, getServiceCostSuccessResponse())
+ defer okServer.Close()
+
+ errServer := makeTestHTTPServer(t, http.StatusInternalServerError, []byte(""))
+ defer errServer.Close()
+
+ clientNumber := int64(anyNumber)
+ clientKey := anyKey
+
+ okFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ calculator: &soap.Client{
+ Namespace: calculatorNamespace,
+ URL: okServer.URL,
+ },
+ },
+ }
+
+ errFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ calculator: &soap.Client{
+ Namespace: calculatorNamespace,
+ URL: errServer.URL,
+ },
+ },
+ }
+
+ a, b := true, false
+ weight, volume := 1.1, 0.05
+ cityID := int64(21321421)
+
+ arg := args{
+ &CalculateRequest{
+ Namespace: calculatorNamespace,
+ Pickup: &CityRequest{
+ CityID: &cityID,
},
+ Delivery: &CityRequest{
+ CityID: &cityID,
+ },
+ SelfPickup: &b,
+ SelfDelivery: &a,
+ Weight: &weight,
+ Volume: &volume,
+ },
+ }
+
+ serviceCode1, serviceCode2 := "BZP", "CUR"
+ serviceName1, serviceName2 := "DPD 18:00", "DPD CLASSIC domestic"
+ cost1, cost2 := 7310.71, 6946.2
+ days1, days2 := 13, 9
+
+ want := []*ServiceCostResponse{
+ {
+ ServiceCode: &serviceCode1,
+ ServiceName: &serviceName1,
+ Cost: &cost1,
+ Days: &days1,
+ },
+ {
+ ServiceCode: &serviceCode2,
+ ServiceName: &serviceName2,
+ Cost: &cost2,
+ Days: &days2,
+ },
+ }
+
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ want []*ServiceCostResponse
+ wantErr bool
+ }{
+ {
+ "Success",
+ okFields,
+ arg,
+ want,
+ false,
+ },
+ {
+ "Fail",
+ errFields,
+ arg,
+ nil,
+ true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := tt.cl.getAuth(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("DPDClient.getAuth() = %v, want %v", got, tt.want)
+ cl := &Client{
+ auth: tt.fields.auth,
+ services: tt.fields.services,
+ }
+ got, err := cl.GetServiceCost2(tt.args.req)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Client.GetServiceCost2() error = %v, wantErr %v", err, tt.wantErr)
+ return
}
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Client.GetServiceCost2() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestClient_GetTerminalsSelfDelivery2(t *testing.T) {
+ type fields struct {
+ auth *Auth
+ services *soapClients
+ }
+
+ okServer := makeTestHTTPServer(t, http.StatusOK, getTerminalsSelfDelivery2SuccessResponse())
+ defer okServer.Close()
+
+ errServer := makeTestHTTPServer(t, http.StatusInternalServerError, []byte(""))
+ defer errServer.Close()
+
+ clientNumber := int64(anyNumber)
+ clientKey := anyKey
+
+ okFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ geography: &soap.Client{
+ Namespace: geographyNamespace,
+ URL: okServer.URL,
+ },
+ },
+ }
+
+ errFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ geography: &soap.Client{
+ Namespace: geographyNamespace,
+ URL: errServer.URL,
+ },
+ },
+ }
+
+ terminalCode := "M11"
+ terminalName := "Москва - M11 Илимская"
+
+ cityID := int64(49694102)
+ countryCode := "RU"
+ regionCode := "77"
+ regionName := "Москва"
+ cityCode := "77000000000"
+ cityName := regionName
+ index := "129301"
+ street := "Касаткина"
+ streetAbbr := "улица"
+ houseNo := "11"
+ structure := "3"
+
+ address := GeographyAddress{
+ CityID: &cityID,
+ CountryCode: &countryCode,
+ RegionCode: ®ionCode,
+ RegionName: ®ionName,
+ CityCode: &cityCode,
+ CityName: &cityName,
+ Index: &index,
+ Street: &street,
+ StreetAbbr: &streetAbbr,
+ HouseNo: &houseNo,
+ Structure: &structure,
+ }
+
+ latitude := 55.826581
+ longitude := 37.660667
+
+ geo := GeoCoordinates{
+ Latitude: &latitude,
+ Longitude: &longitude,
+ }
+
+ schedulesOperations := [3]string{
+ "Payment",
+ "PaymentByBankCard",
+ "SelfPickup",
+ }
+
+ weekDays1 := "Пн,Вт,Ср,Чт,Пт"
+ weekDays2 := "Сб,Вс"
+
+ workTime := "10:00 - 21:00"
+
+ schedule := make([]*Schedule, 0)
+
+ for i := 0; i < 3; i++ {
+ operation := schedulesOperations[i]
+
+ schedule = append(schedule, &Schedule{
+ Operation: &operation,
+ Timetable: []*Timetable{
+ {
+ WeekDays: &weekDays1,
+ WorkTime: &workTime,
+ },
+ {
+ WeekDays: &weekDays2,
+ WorkTime: &workTime,
+ },
+ },
})
}
+
+ extraService := "ТРМ"
+ serviceCode := "NDY"
+
+ want := []*Terminal{{
+ TerminalCode: &terminalCode,
+ TerminalName: &terminalName,
+ Address: &address,
+ GeoCoordinates: &geo,
+ Schedule: schedule,
+ ExtraService: []*ExtraServiceParameters{
+ {
+ EsCode: &extraService,
+ },
+ },
+ Services: []*string{&serviceCode},
+ }}
+
+ tests := []struct {
+ name string
+ fields fields
+ want []*Terminal
+ wantErr bool
+ }{
+ {
+ "Success",
+ okFields,
+ want,
+ false,
+ },
+ {
+ "Fail",
+ errFields,
+ nil,
+ true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ cl := &Client{
+ auth: tt.fields.auth,
+ services: tt.fields.services,
+ }
+ got, err := cl.GetTerminalsSelfDelivery2()
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Client.getTerminalsSelfDelivery2Request() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Client.getTerminalsSelfDelivery2Request() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestClient_GetParcelShops(t *testing.T) {
+ type fields struct {
+ auth *Auth
+ services *soapClients
+ }
+ type args struct {
+ req *ParcelShopRequest
+ }
+
+ okServer := makeTestHTTPServer(t, http.StatusOK, getParcelShopsSuccessResponse())
+ defer okServer.Close()
+
+ errServer := makeTestHTTPServer(t, http.StatusInternalServerError, []byte(""))
+ defer errServer.Close()
+
+ clientNumber := int64(anyNumber)
+ clientKey := anyKey
+
+ okFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ geography: &soap.Client{
+ Namespace: geographyNamespace,
+ URL: okServer.URL,
+ },
+ },
+ }
+
+ errFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ geography: &soap.Client{
+ Namespace: geographyNamespace,
+ URL: errServer.URL,
+ },
+ },
+ }
+
+ countryCode := "RU"
+
+ arg := args{
+ &ParcelShopRequest{
+ CountryCode: &countryCode,
+ Namespace: geographyNamespace,
+ },
+ }
+
+ want := []*ParcelShop{
+ getParcelShopResponse(),
+ }
+
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ want []*ParcelShop
+ wantErr bool
+ }{
+ {
+ "Success",
+ okFields,
+ arg,
+ want,
+ false,
+ },
+ {
+ "Fail",
+ errFields,
+ arg,
+ nil,
+ true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ cl := &Client{
+ auth: tt.fields.auth,
+ services: tt.fields.services,
+ }
+ got, err := cl.GetParcelShops(tt.args.req)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Client.GetParcelShops() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Client.GetParcelShops() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestClient_GetCitiesCashPay(t *testing.T) {
+ type fields struct {
+ auth *Auth
+ services *soapClients
+ }
+ type args struct {
+ countryCode string
+ }
+
+ okServer := makeTestHTTPServer(t, http.StatusOK, getCitiesCashPaySuccessResponse())
+ defer okServer.Close()
+
+ errServer := makeTestHTTPServer(t, http.StatusInternalServerError, []byte(""))
+ defer errServer.Close()
+
+ clientNumber := int64(anyNumber)
+ clientKey := anyKey
+
+ okFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ geography: &soap.Client{
+ Namespace: geographyNamespace,
+ URL: okServer.URL,
+ },
+ },
+ }
+
+ errFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ geography: &soap.Client{
+ Namespace: geographyNamespace,
+ URL: errServer.URL,
+ },
+ },
+ }
+
+ countryCode := "RU"
+
+ arg := args{
+ countryCode,
+ }
+
+ cityID1, cityID2 := int64(48951627), int64(48994107)
+ countryName := thisCountry
+ regionCode1, regionCode2 := 42, 66
+ regionName1, regionName2 := "Кемеровская", "Свердловская"
+ cityCode1, cityCode2 := "42000009000", "66000001000"
+ cityName1, cityName2 := "Кемерово", "Екатеринбург"
+ abbrevation := "г"
+ indexMin1, indexMax1, indexMin2, indexMax2 := "650000", "650993", "620000", "624130"
+
+ want := []*City{
+ {
+ CityID: &cityID1,
+ CountryCode: &countryCode,
+ CountryName: &countryName,
+ RegionCode: ®ionCode1,
+ RegionName: ®ionName1,
+ CityCode: &cityCode1,
+ CityName: &cityName1,
+ Abbreviation: &abbrevation,
+ IndexMin: &indexMin1,
+ IndexMax: &indexMax1,
+ },
+ {
+ CityID: &cityID2,
+ CountryCode: &countryCode,
+ CountryName: &countryName,
+ RegionCode: ®ionCode2,
+ RegionName: ®ionName2,
+ CityCode: &cityCode2,
+ CityName: &cityName2,
+ Abbreviation: &abbrevation,
+ IndexMin: &indexMin2,
+ IndexMax: &indexMax2,
+ },
+ }
+
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ want []*City
+ wantErr bool
+ }{
+ {
+ "Success",
+ okFields,
+ arg,
+ want,
+ false,
+ },
+ {
+ "Fail",
+ errFields,
+ arg,
+ nil,
+ true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ cl := &Client{
+ auth: tt.fields.auth,
+ services: tt.fields.services,
+ }
+ got, err := cl.GetCitiesCashPay(tt.args.countryCode)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Client.GetCitiesCashPay() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Client.GetCitiesCashPay() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestClient_GetStatesByClient(t *testing.T) {
+ type fields struct {
+ auth *Auth
+ services *soapClients
+ }
+
+ okServer := makeTestHTTPServer(t, http.StatusOK, getStatesByClientSuccessResponse())
+ defer okServer.Close()
+
+ errServer := makeTestHTTPServer(t, http.StatusInternalServerError, []byte(""))
+ defer errServer.Close()
+
+ clientNumber := int64(anyNumber)
+ clientKey := anyKey
+
+ okFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ tracking: &soap.Client{
+ Namespace: trackingNamespace,
+ URL: okServer.URL,
+ },
+ },
+ }
+
+ errFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ tracking: &soap.Client{
+ Namespace: trackingNamespace,
+ URL: errServer.URL,
+ },
+ },
+ }
+
+ docId := int64(17543659022)
+ docDate := "2019-07-18T15:59:46"
+ clientNumberResp := int64(1001027554)
+ resultComplete := true
+
+ orderNumberDPD := dpdOrderNumber
+ orderNumberInternal := internalOrderNumber
+ parcelNumberDPD := "271227267"
+ pickupDate := "2019-07-18"
+ planDeliveryDate := "2019-07-19"
+ newState := "OnRoad"
+ transitionTime := "2019-07-18T08:52:45"
+ terminalCode := "M16"
+ terminalCity := "Москва"
+
+ want := &ParcelsStates{
+ DocID: &docId,
+ DocDate: &docDate,
+ ClientNumber: &clientNumberResp,
+ ResultComplete: &resultComplete,
+ States: []*ParcelState{
+ {
+ ClientOrderNr: &orderNumberInternal,
+ DpdOrderNr: &orderNumberDPD,
+ DpdParcelNr: &parcelNumberDPD,
+ PickupDate: &pickupDate,
+ PlanDeliveryDate: &planDeliveryDate,
+ NewState: &newState,
+ TransitionTime: &transitionTime,
+ TerminalCode: &terminalCode,
+ TerminalCity: &terminalCity,
+ },
+ },
+ }
+
+ tests := []struct {
+ name string
+ fields fields
+ want *ParcelsStates
+ wantErr bool
+ }{
+ {
+ "Success",
+ okFields,
+ want,
+ false,
+ },
+ {
+ "Fail",
+ errFields,
+ nil,
+ true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ cl := &Client{
+ auth: tt.fields.auth,
+ services: tt.fields.services,
+ }
+ got, err := cl.GetStatesByClient()
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Client.GetStatesByClient() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Client.GetStatesByClient() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestClient_GetStatesByClientOrder(t *testing.T) {
+ type fields struct {
+ auth *Auth
+ services *soapClients
+ }
+ type args struct {
+ req *TrackByClientOrderRequest
+ }
+
+ okServer := makeTestHTTPServer(t, http.StatusOK, getStatesByClientOrderSuccessResponse())
+ defer okServer.Close()
+
+ errServer := makeTestHTTPServer(t, http.StatusInternalServerError, []byte(""))
+ defer errServer.Close()
+
+ clientNumber := int64(anyNumber)
+ clientKey := anyKey
+ orderNumberInternal := internalOrderNumber
+
+ okFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ tracking: &soap.Client{
+ Namespace: trackingNamespace,
+ URL: okServer.URL,
+ },
+ },
+ }
+
+ errFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ tracking: &soap.Client{
+ Namespace: trackingNamespace,
+ URL: errServer.URL,
+ },
+ },
+ }
+
+ arg := args{
+ &TrackByClientOrderRequest{
+ ClientOrderNr: &orderNumberInternal,
+ },
+ }
+
+ docId := int64(17543035562)
+ docDate := "2019-07-18T11:16:46"
+ clientNumberResp := int64(1001027554)
+ resultComplete := true
+
+ orderNumberDPD := dpdOrderNumber
+ parcelNumberDPD := "271227267"
+ pickupDate := "2019-07-18"
+ planDeliveryDate := "2019-07-19"
+ newState := "OnTerminalPickup"
+ transitionTime := "2019-07-18T08:51:21"
+ terminalCode := "M16"
+ terminalCity := "Москва"
+
+ want := &ParcelsStates{
+ DocID: &docId,
+ DocDate: &docDate,
+ ClientNumber: &clientNumberResp,
+ ResultComplete: &resultComplete,
+ States: []*ParcelState{
+ {
+ ClientOrderNr: &orderNumberInternal,
+ DpdOrderNr: &orderNumberDPD,
+ DpdParcelNr: &parcelNumberDPD,
+ PickupDate: &pickupDate,
+ PlanDeliveryDate: &planDeliveryDate,
+ NewState: &newState,
+ TransitionTime: &transitionTime,
+ TerminalCode: &terminalCode,
+ TerminalCity: &terminalCity,
+ },
+ },
+ }
+
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ want *ParcelsStates
+ wantErr bool
+ }{
+ {
+ "Sucess",
+ okFields,
+ arg,
+ want,
+ false,
+ },
+ {
+ "Fail",
+ errFields,
+ args{&TrackByClientOrderRequest{}},
+ nil,
+ true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ cl := &Client{
+ auth: tt.fields.auth,
+ services: tt.fields.services,
+ }
+ got, err := cl.GetStatesByClientOrder(tt.args.req)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Client.GetStatesByClientOrder() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Client.GetStatesByClientOrder() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestClient_GetStatesByDPDOrder(t *testing.T) {
+ type fields struct {
+ auth *Auth
+ services *soapClients
+ }
+ type args struct {
+ req *TrackByDPDOrderRequest
+ }
+
+ okServer := makeTestHTTPServer(t, http.StatusOK, getStatesByDPDOrderSuccessResponse())
+ defer okServer.Close()
+
+ errServer := makeTestHTTPServer(t, http.StatusInternalServerError, []byte(""))
+ defer errServer.Close()
+
+ clientNumber := int64(anyNumber)
+ clientKey := anyKey
+ orderNumberDPD := dpdOrderNumber
+
+ okFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ tracking: &soap.Client{
+ Namespace: trackingNamespace,
+ URL: okServer.URL,
+ },
+ },
+ }
+
+ errFields := fields{
+ auth: &Auth{
+ ClientNumber: &clientNumber,
+ ClientKey: &clientKey,
+ },
+ services: &soapClients{
+ tracking: &soap.Client{
+ Namespace: trackingNamespace,
+ URL: errServer.URL,
+ },
+ },
+ }
+
+ arg := args{
+ &TrackByDPDOrderRequest{
+ DpdOrderNr: &orderNumberDPD,
+ },
+ }
+
+ docId := int64(17543580110)
+ docDate := "2019-07-18T15:24:32"
+ clientNumberResp := int64(1001027554)
+ resultComplete := true
+
+ orderNumberInternal := internalOrderNumber
+ parcelNumberDPD := "271227267"
+ pickupDate := "2019-07-18"
+ planDeliveryDate := "2019-07-19"
+ newState := "Delivered"
+ transitionTime := "2019-07-18T08:58:00"
+ terminalCode := "GOJ"
+ terminalCity := "Нижний Новгород"
+ consignee := "Инокентий Мутный"
+
+ want := &ParcelsStates{
+ DocID: &docId,
+ DocDate: &docDate,
+ ClientNumber: &clientNumberResp,
+ ResultComplete: &resultComplete,
+ States: []*ParcelState{
+ {
+ ClientOrderNr: &orderNumberInternal,
+ DpdOrderNr: &orderNumberDPD,
+ DpdParcelNr: &parcelNumberDPD,
+ PickupDate: &pickupDate,
+ PlanDeliveryDate: &planDeliveryDate,
+ NewState: &newState,
+ TransitionTime: &transitionTime,
+ TerminalCode: &terminalCode,
+ TerminalCity: &terminalCity,
+ Consignee: &consignee,
+ },
+ },
+ }
+
+ tests := []struct {
+ name string
+ fields fields
+ args args
+ want *ParcelsStates
+ wantErr bool
+ }{
+ {
+ "Success",
+ okFields,
+ arg,
+ want,
+ false,
+ },
+ {
+ "Fail",
+ errFields,
+ arg,
+ nil,
+ true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ cl := &Client{
+ auth: tt.fields.auth,
+ services: tt.fields.services,
+ }
+ got, err := cl.GetStatesByDPDOrder(tt.args.req)
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Client.GetStatesByDPDOrder() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Client.GetStatesByDPDOrder() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+/***************************************************************
+********************** Staff *********************
+****************************************************************/
+func getServiceCostSuccessResponse() []byte {
+ return []byte(`
+
+
+
+
+
+ BZP
+ DPD 18:00
+ 7310.71
+ 13
+
+
+ CUR
+ DPD CLASSIC domestic
+ 6946.2
+ 9
+
+
+
+
+`)
+}
+
+func getTerminalsSelfDelivery2SuccessResponse() []byte {
+ return []byte(`
+
+
+
+
+
+
+ M11
+ Москва - M11 Илимская
+
+ 49694102
+ RU
+ 77
+ Москва
+ 77000000000
+ Москва
+ 129301
+ Касаткина
+ улица
+ 11
+ 3
+
+
+ 55.826581
+ 37.660667
+
+
+ Payment
+
+ Пн,Вт,Ср,Чт,Пт
+ 10:00 - 21:00
+
+
+ Сб,Вс
+ 10:00 - 21:00
+
+
+
+ PaymentByBankCard
+
+ Пн,Вт,Ср,Чт,Пт
+ 10:00 - 21:00
+
+
+ Сб,Вс
+ 10:00 - 21:00
+
+
+
+ SelfPickup
+
+ Пн,Вт,Ср,Чт,Пт
+ 10:00 - 21:00
+
+
+ Сб,Вс
+ 10:00 - 21:00
+
+
+
+ ТРМ
+
+
+ NDY
+
+
+
+
+
+
+ `)
+}
+
+func getCitiesCashPaySuccessResponse() []byte {
+ return []byte(`
+
+
+
+
+
+ 48951627
+ RU
+ Россия
+ 42
+ Кемеровская
+ 42000009000
+ Кемерово
+ г
+ 650000
+ 650993
+
+
+ 48994107
+ RU
+ Россия
+ 66
+ Свердловская
+ 66000001000
+ Екатеринбург
+ г
+ 620000
+ 624130
+
+
+
+
+ `)
+}
+
+func getParcelShopsSuccessResponse() []byte {
+ return []byte(`
+
+
+
+
+
+
+ 001G
+ ПВП
+ Open
+
+ 49694167
+ RU
+ 78
+ Санкт-Петербург
+ 78000000000
+ Санкт-Петербург
+ 196135
+ Алтайская
+ ул
+ 16
+ Выход из метро в сторону аэропорта, от Московской пл
+
+ Главпункт
+ Moskovskaya-A16
+
+ 59.849681
+ 30.327345
+
+
+ 70
+ 20
+ 200
+ 200
+ 200
+ 200
+
+
+ Payment
+
+ Пн,Вт,Ср,Чт,Пт,Сб,Вс
+ 10:00 - 21:00
+
+
+
+ PaymentByBankCard
+
+ Пн,Вт,Ср,Чт,Пт,Сб,Вс
+ 10:00 - 21:00
+
+
+
+ SelfDelivery
+
+ Пн,Вт,Ср,Чт,Пт,Сб,Вс
+ 10:00 - 21:00
+
+
+
+ НПП
+
+ sum_npp
+ 100000
+
+
+
+ ОЖД
+
+ reason_delay
+ ПРОС
+
+
+
+ ТРМ
+
+
+ BZP
+
+
+
+
+
+
+ `)
+}
+
+func getParcelShopResponse() *ParcelShop {
+ code := "001G"
+ parcelShopType := "ПВП"
+ state := "Open"
+
+ cityID := int64(49694167)
+ countryCode := "RU"
+ regionCode := "78"
+ regionName := "Санкт-Петербург"
+ cityCode := "78000000000"
+ cityName := regionName
+ index := "196135"
+ street := "Алтайская"
+ streetAbbr := "ул"
+ houseNo := "16"
+ description := `Выход из метро в сторону аэропорта, от Московской пл`
+
+ address := GeographyAddress{
+ CityID: &cityID,
+ CountryCode: &countryCode,
+ RegionCode: ®ionCode,
+ RegionName: ®ionName,
+ CityCode: &cityCode,
+ CityName: &cityName,
+ Index: &index,
+ Street: &street,
+ StreetAbbr: &streetAbbr,
+ HouseNo: &houseNo,
+ Description: &description,
+ }
+
+ brand := "Главпункт"
+ clientDepartmentNum := "Moskovskaya-A16"
+
+ latitude := 59.849681
+ longitude := 30.327345
+
+ geoCoordinates := GeoCoordinates{
+ Latitude: &latitude,
+ Longitude: &longitude,
+ }
+
+ maxShipmentWeight := 70.0
+ maxWeight := 20.0
+ maxLength := 200.0
+ maxWidth := 200.0
+ maxHeight := 200.0
+ dimensionsSum := 200.0
+
+ limits := Limits{
+ MaxShipmentWeight: &maxShipmentWeight,
+ MaxWeight: &maxWeight,
+ MaxLength: &maxLength,
+ MaxWidth: &maxWidth,
+ MaxHeight: &maxHeight,
+ DimensionSum: &dimensionsSum,
+ }
+
+ schedules := make([]*Schedule, 0)
+
+ operations := [3]string{
+ "Payment",
+ "PaymentByBankCard",
+ "SelfDelivery",
+ }
+
+ weekDays := "Пн,Вт,Ср,Чт,Пт,Сб,Вс"
+ workTime := "10:00 - 21:00"
+
+ for i := 0; i < 3; i++ {
+ operation := operations[i]
+ schedules = append(schedules, &Schedule{
+ Operation: &operation,
+ Timetable: []*Timetable{
+ {
+ WeekDays: &weekDays,
+ WorkTime: &workTime,
+ },
+ },
+ })
+ }
+
+ extraServices := make([]*ExtraServiceParameters, 0)
+
+ services := [3]string{
+ "НПП",
+ "ОЖД",
+ "ТРМ",
+ }
+ serviceParamNames := [2]string{
+ "sum_npp",
+ "reason_delay",
+ }
+ serviceParamValue := [2]string{
+ "100000",
+ "ПРОС",
+ }
+
+ for i := 0; i < 3; i++ {
+ name, param := "", ""
+
+ if len(serviceParamNames) > i && len(serviceParamValue) > i {
+ name = serviceParamNames[i]
+ param = serviceParamValue[i]
+ }
+
+ esCode := services[i]
+
+ es := ExtraServiceParameters{
+ EsCode: &esCode,
+ }
+
+ if name != "" && param != "" {
+ es.Params = []*ExtraServiceParameter{
+ {
+ Name: &name,
+ Value: ¶m,
+ },
+ }
+ }
+
+ extraServices = append(extraServices, &es)
+ }
+
+ serviceCode := "BZP"
+
+ return &ParcelShop{
+ Code: &code,
+ ParcelShopType: &parcelShopType,
+ State: &state,
+ Address: &address,
+ Brand: &brand,
+ ClientDepartmentNum: &clientDepartmentNum,
+ GeoCoordinates: &geoCoordinates,
+ Limits: &limits,
+ Schedule: schedules,
+ ExtraService: extraServices,
+ Services: []*string{&serviceCode},
+ }
+}
+
+func getCreateOrderSuccessResponse() []byte {
+ return []byte(`
+
+
+
+
+
+ 1901-200100-42389
+ RU019202656
+ OK
+
+
+
+
+ `)
+}
+
+func getAddParcelsSuccessResponse() []byte {
+ return []byte(`
+
+
+
+
+
+ RU019202656
+ OK
+
+
+
+
+ `)
+}
+
+func getRemoveParcelsSuccessResponse() []byte {
+ return []byte(`
+
+
+
+
+
+ RU019202656
+ OK
+
+ 1
+ OK
+
+
+
+
+
+ `)
+}
+
+func getCancelOrderSuccessResponse() []byte {
+ return []byte(`
+
+
+
+
+
+ 1901-200100-42389
+ RU019202656
+ Canceled
+
+
+
+
+ `)
+}
+
+func getOrderStatusSuccessResponse() []byte {
+ return []byte(`
+
+
+
+
+
+ 1901-200100-42389
+ RU019202656
+ OrderCancelled
+
+
+
+
+ `)
+}
+
+func getStatesByClientOrderSuccessResponse() []byte {
+ return []byte(`
+
+
+
+
+
+ 17543035562
+ 2019-07-18T11:16:46
+ 1001027554
+ true
+
+ 1901-200100-42389
+ RU019202656
+ 271227267
+ 2019-07-18
+ 2019-07-19
+ OnTerminalPickup
+ 2019-07-18T08:51:21
+ M16
+ Москва
+
+
+
+
+
+ `)
+}
+
+func getStatesByDPDOrderSuccessResponse() []byte {
+ return []byte(`
+
+
+
+
+
+ 17543580110
+ 2019-07-18T15:24:32
+ 1001027554
+ true
+
+ 1901-200100-42389
+ RU019202656
+ 271227267
+ 2019-07-18
+ 2019-07-19
+ Delivered
+ 2019-07-18T08:58:00
+ GOJ
+ Нижний Новгород
+ Инокентий Мутный
+
+
+
+
+
+ `)
+}
+
+func getStatesByClientSuccessResponse() []byte {
+ return []byte(`
+
+
+
+
+
+ 17543659022
+ 2019-07-18T15:59:46
+ 1001027554
+ true
+
+ 1901-200100-42389
+ RU019202656
+ 271227267
+ 2019-07-18
+ 2019-07-19
+ OnRoad
+ 2019-07-18T08:52:45
+ M16
+ Москва
+
+
+
+
+
+ `)
}
diff --git a/common.go b/common.go
new file mode 100644
index 0000000..43810f5
--- /dev/null
+++ b/common.go
@@ -0,0 +1,19 @@
+package dpd
+
+//Auth part of all requests. Credentials to DPD SOAP API
+type Auth struct {
+ Namespace *string `xml:"xmlns,attr"`
+ ClientNumber *int64 `xml:"clientNumber,omitempty"`
+ ClientKey *string `xml:"clientKey,omitempty"`
+}
+
+type commonUnitLoad struct {
+ Article *string `xml:"article,omitempty"`
+ Description *string `xml:"descript,omitempty"`
+ DeclaredValue *string `xml:"declared_value,omitempty"`
+ ParcelNum *string `xml:"parcel_num,omitempty"`
+ NppAmount *string `xml:"npp_amount,omitempty"`
+ VatPercent *int `xml:"vat_percent,omitempty"`
+ WithoutVat *bool `xml:"without_vat,omitempty"`
+ Count *int `xml:"count,omitempty"`
+}
diff --git a/common_test.go b/common_test.go
new file mode 100644
index 0000000..9cd1553
--- /dev/null
+++ b/common_test.go
@@ -0,0 +1,35 @@
+package dpd
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "testing"
+)
+
+const (
+ anyString = "any string"
+ anyKey = "any key"
+ anyNumber = 1
+ internalOrderNumber = "1901-200100-42389"
+ dpdOrderNumber = "RU019202656"
+ thisCountry = "Россия"
+)
+
+func makeTestHTTPServer(t *testing.T, status int, body []byte) *httptest.Server {
+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.WriteHeader(status)
+ w.Header().Set("Content-Type", "application/xml")
+
+ if _, err := w.Write(body); err != nil {
+ t.Errorf("Error writing response %s", err.Error())
+ t.FailNow()
+ }
+
+ //if !bytes.Contains(body, []byte("clientNumber")) || !bytes.Contains(body, []byte("clientKey")) {
+ // t.Errorf("Auth tag is necessary")
+ // t.FailNow()
+ //}
+ }))
+
+ return ts
+}
diff --git a/doc.go b/doc.go
index 3b1f9bc..7b0055e 100644
--- a/doc.go
+++ b/doc.go
@@ -1,2 +1,2 @@
-//SDK для интеграции с транспортной компанией DPD
+//Package dpd - SDK для интеграции с транспортной компанией DPD
package dpd
diff --git a/geography2.go b/geography2.go
new file mode 100644
index 0000000..91afc72
--- /dev/null
+++ b/geography2.go
@@ -0,0 +1,178 @@
+package dpd
+
+const geographyNamespace = "http://dpd.ru/ws/geography/2015-05-20"
+
+type operationGetCitiesCashPay struct {
+ GetCitiesCashPay *getCitiesCashPay `xml:"getCitiesCashPay,omitempty"`
+}
+
+type getCitiesCashPay struct {
+ Namespace string `xml:"xmlns,attr"`
+ Request *citiesCashPayRequest `xml:"request,omitempty"`
+}
+
+type citiesCashPayRequest struct {
+ Namespace string `xml:"xmlns,attr"`
+ Auth *Auth `xml:"auth,omitempty"`
+ CountryCode *string `xml:"countryCode,omitempty"`
+}
+
+type operationGetCitiesCashPayResponse struct {
+ GetCitiesCashPayResponse *GetCitiesCashPayResponse `xml:"getCitiesCashPayResponse,omitempty"`
+}
+
+//GetCitiesCashPayResponse list of DPD cities with C.O.D available
+type GetCitiesCashPayResponse struct {
+ Return []*City `xml:"return,omitempty"`
+}
+
+//City with C.O.D available
+type City struct {
+ CityID *int64 `xml:"cityId,omitempty"`
+ CountryCode *string `xml:"countryCode,omitempty"`
+ CountryName *string `xml:"countryName,omitempty"`
+ RegionCode *int `xml:"regionCode,omitempty"`
+ RegionName *string `xml:"regionName,omitempty"`
+ CityCode *string `xml:"cityCode,omitempty"`
+ CityName *string `xml:"cityName,omitempty"`
+ Abbreviation *string `xml:"abbreviation,omitempty"`
+ IndexMin *string `xml:"indexMin,omitempty"`
+ IndexMax *string `xml:"indexMax,omitempty"`
+}
+
+type operationGetParcelShops struct {
+ GetParcelShops *getParcelShops `xml:"getParcelShops,omitempty"`
+}
+
+type getParcelShops struct {
+ Request *ParcelShopRequest `xml:"request,omitempty"`
+ Ns string `xml:"xmlns,attr"`
+}
+
+//ParcelShopRequest GetParcelShops request body
+type ParcelShopRequest struct {
+ Namespace string `xml:"xmlns,attr"`
+ Auth *Auth `xml:"auth,omitempty"`
+ CountryCode *string `xml:"countryCode,omitempty"`
+ RegionCode *string `xml:"regionCode,omitempty"`
+ CityCode *string `xml:"cityCode,omitempty"`
+ CityName *string `xml:"cityName,omitempty"`
+}
+
+type operationGetParcelShopsResponse struct {
+ GetParcelShopsResponse *getParcelShopsResponse `xml:"getParcelShopsResponse,omitempty"`
+}
+
+type getParcelShopsResponse struct {
+ Return *parcelShops `xml:"return,omitempty"`
+}
+
+type parcelShops struct {
+ ParcelShop []*ParcelShop `xml:"parcelShop,omitempty"`
+}
+
+//ParcelShop self delivery point with limits on dimensions and weight
+type ParcelShop struct {
+ Code *string `xml:"code,omitempty"`
+ ParcelShopType *string `xml:"parcelShopType,omitempty"`
+ State *string `xml:"state,omitempty"`
+ Address *GeographyAddress `xml:"address,omitempty"`
+ Brand *string `xml:"brand,omitempty"`
+ ClientDepartmentNum *string `xml:"clientDepartmentNum,omitempty"`
+ GeoCoordinates *GeoCoordinates `xml:"geoCoordinates,omitempty"`
+ Limits *Limits `xml:"limits,omitempty"`
+ Schedule []*Schedule `xml:"schedule,omitempty"`
+ ExtraService []*ExtraServiceParameters `xml:"extraService,omitempty"`
+ Services []*string `xml:"services>serviceCode,omitempty"`
+}
+
+//GeographyAddress of ParcelShop or Terminal
+type GeographyAddress struct {
+ CityID *int64 `xml:"cityId,omitempty"`
+ CountryCode *string `xml:"countryCode,omitempty"`
+ RegionCode *string `xml:"regionCode,omitempty"`
+ RegionName *string `xml:"regionName,omitempty"`
+ CityCode *string `xml:"cityCode,omitempty"`
+ CityName *string `xml:"cityName,omitempty"`
+ Index *string `xml:"index,omitempty"`
+ Street *string `xml:"street,omitempty"`
+ StreetAbbr *string `xml:"streetAbbr,omitempty"`
+ HouseNo *string `xml:"houseNo,omitempty"`
+ Building *string `xml:"building,omitempty"`
+ Structure *string `xml:"structure,omitempty"`
+ Ownership *string `xml:"ownership,omitempty"`
+ Description *string `xml:"descript,omitempty"`
+}
+
+//GeoCoordinates of ParcelShop or Terminal
+type GeoCoordinates struct {
+ Latitude *float64 `xml:"latitude,omitempty"`
+ Longitude *float64 `xml:"longitude,omitempty"`
+}
+
+//Limits of ParcelShop
+type Limits struct {
+ MaxShipmentWeight *float64 `xml:"maxShipmentWeight,omitempty"`
+ MaxWeight *float64 `xml:"maxWeight,omitempty"`
+ MaxLength *float64 `xml:"maxLength,omitempty"`
+ MaxWidth *float64 `xml:"maxWidth,omitempty"`
+ MaxHeight *float64 `xml:"maxHeight,omitempty"`
+ DimensionSum *float64 `xml:"dimensionSum,omitempty"`
+}
+
+//Schedule of ParcelShop or Terminal
+type Schedule struct {
+ Operation *string `xml:"operation,omitempty"`
+ Timetable []*Timetable `xml:"timetable,omitempty"`
+}
+
+//Timetable for operations
+type Timetable struct {
+ WeekDays *string `xml:"weekDays,omitempty"`
+ WorkTime *string `xml:"workTime,omitempty"`
+}
+
+//ExtraServiceParameters for ParcelShop or Terminal
+type ExtraServiceParameters struct {
+ EsCode *string `xml:"esCode,omitempty"`
+ Params []*ExtraServiceParameter `xml:"params,omitempty"`
+}
+
+//ExtraServiceParameter ...
+type ExtraServiceParameter struct {
+ Name *string `xml:"name,omitempty"`
+ Value *string `xml:"value,omitempty"`
+}
+
+type operationGetTerminalsSelfDelivery2 struct {
+ GetTerminalsSelfDelivery2 *getTerminalsSelfDelivery2Request `xml:"getTerminalsSelfDelivery2,omitempty"`
+}
+
+type getTerminalsSelfDelivery2Request struct {
+ Namespace string `xml:"xmlns,attr"`
+ Auth *Auth `xml:"auth,omitempty"`
+}
+
+type operationGetTerminalsSelfDelivery2Response struct {
+ Response *getTerminalsSelfDelivery2Response `xml:"getTerminalsSelfDelivery2Response,omitempty"`
+}
+
+type getTerminalsSelfDelivery2Response struct {
+ Return *Terminals `xml:"return,omitempty"`
+}
+
+//Terminals GetTerminalsSelfDelivery2 response body
+type Terminals struct {
+ Terminal []*Terminal `xml:"terminal,omitempty"`
+}
+
+//Terminal ...
+type Terminal struct {
+ TerminalCode *string `xml:"terminalCode,omitempty"`
+ TerminalName *string `xml:"terminalName,omitempty"`
+ Address *GeographyAddress `xml:"address,omitempty"`
+ GeoCoordinates *GeoCoordinates `xml:"geoCoordinates,omitempty"`
+ Schedule []*Schedule `xml:"schedule,omitempty"`
+ ExtraService []*ExtraServiceParameters `xml:"extraService,omitempty"`
+ Services []*string `xml:"services>serviceCode,omitempty"`
+}
diff --git a/geographyRequestBuilder.go b/geographyRequestBuilder.go
index 8b03d5a..2fcc8d7 100644
--- a/geographyRequestBuilder.go
+++ b/geographyRequestBuilder.go
@@ -1,16 +1,11 @@
package dpd
-import dpdSoap "github.com/vseinstrumentiru/dpd/soap"
-
-//Request list of self delivery points with their restrictions
-type ParcelShopRequest dpdSoap.DpdParcelShopRequest
-
+//NewParcelShopRequest returns pointer to ParcelShopRequest
func NewParcelShopRequest() *ParcelShopRequest {
return new(ParcelShopRequest)
}
-//Set country code according ISO 3166-1 alpha-2 standard
-//https://www.iso.org/obp/ui/#search
+//SetCountryCode the code must comply with ISO 3166-1 alpha-2
//If omitted, default RU
func (r *ParcelShopRequest) SetCountryCode(code string) *ParcelShopRequest {
r.CountryCode = &code
@@ -18,27 +13,23 @@ func (r *ParcelShopRequest) SetCountryCode(code string) *ParcelShopRequest {
return r
}
+//SetRegionCode parameter must comply DPD native region code
func (r *ParcelShopRequest) SetRegionCode(code string) *ParcelShopRequest {
r.RegionCode = &code
return r
}
-//Dpd native, city identifier
+//SetCityCode parameter must comply DPD native city code
func (r *ParcelShopRequest) SetCityCode(code string) *ParcelShopRequest {
r.CityCode = &code
return r
}
+//SetCityName ...
func (r *ParcelShopRequest) SetCityName(name string) *ParcelShopRequest {
r.CityName = &name
return r
}
-
-func (r *ParcelShopRequest) toDPDRequest() *dpdSoap.DpdParcelShopRequest {
- dpdReq := dpdSoap.DpdParcelShopRequest(*r)
-
- return &dpdReq
-}
diff --git a/geographyRequestBuilder_test.go b/geographyRequestBuilder_test.go
index 5d9e935..b0aa530 100644
--- a/geographyRequestBuilder_test.go
+++ b/geographyRequestBuilder_test.go
@@ -3,8 +3,6 @@ package dpd
import (
"reflect"
"testing"
-
- dpdSoap "github.com/vseinstrumentiru/dpd/soap"
)
func TestNewParcelShopRequest(t *testing.T) {
@@ -157,24 +155,3 @@ func TestParcelShopRequest_SetCityName(t *testing.T) {
})
}
}
-
-func TestParcelShopRequest_toDPDRequest(t *testing.T) {
- tests := []struct {
- name string
- r *ParcelShopRequest
- want *dpdSoap.DpdParcelShopRequest
- }{
- {
- "Convert to DPD request",
- &ParcelShopRequest{},
- &dpdSoap.DpdParcelShopRequest{},
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.toDPDRequest(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("ParcelShopRequest.toDPDRequest() = %v, want %v", got, tt.want)
- }
- })
- }
-}
diff --git a/order2.go b/order2.go
new file mode 100644
index 0000000..6d1c37c
--- /dev/null
+++ b/order2.go
@@ -0,0 +1,250 @@
+package dpd
+
+const orderNamespace = "http://dpd.ru/ws/order2Service/2012-04-04"
+
+type operationAddParcels struct {
+ AddParcels *addParcels `xml:"addParcels,omitempty"`
+}
+
+type addParcels struct {
+ Parcels *UpdateOrderRequest `xml:"parcels,omitempty"`
+}
+
+//UpdateOrderRequest AddParcels\RemoveParcels request body
+type UpdateOrderRequest struct {
+ Auth *Auth `xml:"auth,omitempty"`
+ OrderNum *string `xml:"orderNum,omitempty"`
+ OrderNumberInternal *string `xml:"orderNumberInternal,omitempty"`
+ CargoNumPack *int `xml:"cargoNumPack,omitempty"`
+ CargoWeight *float64 `xml:"cargoWeight,omitempty"`
+ CargoVolume *float64 `xml:"cargoVolume,omitempty"`
+ CargoValue *float64 `xml:"cargoValue,omitempty"`
+ CargoCategory *string `xml:"cargoCategory,omitempty"`
+ Parcel []*Parcel `xml:"parcel,omitempty"`
+}
+
+//Parcel to add or remove
+type Parcel struct {
+ Number *string `xml:"number,omitempty"`
+ DpdParcelNumber *int64 `xml:"dpdParcelNumber,omitempty"`
+ NumberForPrint *string `xml:"number_for_print,omitempty"`
+ BoxNeeded *int `xml:"box_needed,omitempty"`
+ Weight *float64 `xml:"weight,omitempty"`
+ Length *float64 `xml:"length,omitempty"`
+ Width *float64 `xml:"width,omitempty"`
+ Height *float64 `xml:"height,omitempty"`
+ InsuranceCost *float64 `xml:"insuranceCost,omitempty"`
+ InsuranceCostVat *float64 `xml:"insuranceCostVat,omitempty"`
+ CodAmount *float64 `xml:"codAmount,omitempty"`
+}
+
+type operationAddParcelsResponse struct {
+ AddParcelsResponse *addParcelsResponse `xml:"addParcelsResponse,omitempty"`
+}
+
+type addParcelsResponse struct {
+ Return *OrderCorrectionStatus `xml:"return,omitempty"`
+}
+
+//OrderCorrectionStatus AddParcels\RemoveParcels response body
+type OrderCorrectionStatus struct {
+ OrderNum *string `xml:"orderNum,omitempty"`
+ Status *string `xml:"status,omitempty"`
+ ErrorMessage *string `xml:"errorMessage,omitempty"`
+ ParcelStatus []*ParcelStatus `xml:"parcelStatus,omitempty"`
+}
+
+//ParcelsStatus correction status
+type ParcelStatus struct {
+ Number *string `xml:"number,omitempty"`
+ Status *string `xml:"status,omitempty"`
+ ErrorMessage *string `xml:"errorMessage,omitempty"`
+}
+
+type operationCancelOrder struct {
+ CancelOrder *cancelOrder `xml:"cancelOrder,omitempty"`
+}
+
+type cancelOrder struct {
+ Orders *CancelOrderRequest `xml:"orders,omitempty"`
+}
+
+//CancelOrderRequest CancelOrder request body
+type CancelOrderRequest struct {
+ Auth *Auth `xml:"auth,omitempty"`
+ Cancel []*OrderToCancel `xml:"cancel,omitempty"`
+}
+
+//OrderToCancel ...
+type OrderToCancel struct {
+ OrderNumberInternal *string `xml:"orderNumberInternal,omitempty"`
+ OrderNum *string `xml:"orderNum,omitempty"`
+ PickupDate *string `xml:"pickupdate,omitempty"`
+}
+
+type operationCancelOrderResponse struct {
+ CancelOrderResponse *cancelOrderResponse `xml:"cancelOrderResponse,omitempty"`
+}
+
+type cancelOrderResponse struct {
+ Return []*OrderStatus `xml:"return,omitempty"`
+}
+
+//OrderStatus CancelOrder response item
+type OrderStatus struct {
+ OrderNumberInternal *string `xml:"orderNumberInternal,omitempty"`
+ OrderNum *string `xml:"orderNum,omitempty"`
+ Status *string `xml:"status,omitempty"`
+ ErrorMessage *string `xml:"errorMessage,omitempty"`
+}
+
+type operationCreateOrder struct {
+ CreateOrder *createOrder `xml:"createOrder,omitempty"`
+}
+
+type createOrder struct {
+ Orders *CreateOrderRequest `xml:"orders,omitempty"`
+}
+
+//CreateOrderRequest CreateOrder request body
+type CreateOrderRequest struct {
+ Auth *Auth `xml:"auth,omitempty"`
+ Header *Header `xml:"header,omitempty"`
+ Order []*Order `xml:"order,omitempty"`
+}
+
+//Order to creation
+type Order struct {
+ OrderNumberInternal *string `xml:"orderNumberInternal,omitempty"`
+ ServiceCode *string `xml:"serviceCode,omitempty"`
+ ServiceVariant *string `xml:"serviceVariant,omitempty"`
+ CargoNumPack *int `xml:"cargoNumPack,omitempty"`
+ CargoWeight *float64 `xml:"cargoWeight,omitempty"`
+ CargoVolume *float64 `xml:"cargoVolume,omitempty"`
+ CargoRegistered *bool `xml:"cargoRegistered,omitempty"`
+ CargoValue *float64 `xml:"cargoValue,omitempty"`
+ CargoCategory *string `xml:"cargoCategory,omitempty"`
+ DeliveryTimePeriod *string `xml:"deliveryTimePeriod,omitempty"`
+ PaymentType *string `xml:"paymentType,omitempty"`
+ ExtraParam []*ExtraParameter `xml:"extraParam,omitempty"`
+ DataInt *DataInternational `xml:"dataInt,omitempty"`
+ ReceiverAddress *Address `xml:"receiverAddress,omitempty"`
+ ReturnAddress *Address `xml:"returnAddress,omitempty"`
+ ExtraService []*ExtraService `xml:"extraService,omitempty"`
+ Parcel []*Parcel `xml:"parcel,omitempty"`
+ UnitLoad []*UnitLoadOrder `xml:"unitLoad,omitempty"`
+}
+
+//UnitLoadOrder array of units in cargo for 54 federal law (54-ФЗ)
+type UnitLoadOrder struct {
+ commonUnitLoad
+ ClientCode *string `xml:"client_code,omitempty"`
+}
+
+//DataInternational data for international delivery orders
+type DataInternational struct {
+ Currency *string `xml:"currency,omitempty"`
+ CurrencyDeclaredValue *string `xml:"currencyDeclaredValue,omitempty"`
+}
+
+//ExtraService list of delivery options
+type ExtraService struct {
+ EsCode *string `xml:"esCode,omitempty"`
+ Param []*ExtraParameter `xml:"param,omitempty"`
+}
+
+//ExtraParameter delivery option
+type ExtraParameter struct {
+ Name *string `xml:"name,omitempty"`
+ Value *string `xml:"value,omitempty"`
+}
+
+//Header common for all types of orders. Contains information about sender
+type Header struct {
+ DatePickup *string `xml:"datePickup,omitempty"`
+ Payer *int64 `xml:"payer,omitempty"`
+ SenderAddress *Address `xml:"senderAddress,omitempty"`
+ PickupTimePeriod *string `xml:"pickupTimePeriod,omitempty"`
+ RegularNum *string `xml:"regularNum,omitempty"`
+}
+
+//Address ...
+type Address struct {
+ Code *string `xml:"code,omitempty"`
+ Name *string `xml:"name,omitempty"`
+ TerminalCode *string `xml:"terminalCode,omitempty"`
+ AddressString *string `xml:"addressString,omitempty"`
+ CountryName *string `xml:"countryName,omitempty"`
+ Index *string `xml:"index,omitempty"`
+ Region *string `xml:"region,omitempty"`
+ City *string `xml:"city,omitempty"`
+ Street *string `xml:"street,omitempty"`
+ StreetAbbr *string `xml:"streetAbbr,omitempty"`
+ House *string `xml:"house,omitempty"`
+ HouseKorpus *string `xml:"houseKorpus,omitempty"`
+ Str *string `xml:"str,omitempty"`
+ Vlad *string `xml:"vlad,omitempty"`
+ ExtraInfo *string `xml:"extraInfo,omitempty"`
+ Office *string `xml:"office,omitempty"`
+ Flat *string `xml:"flat,omitempty"`
+ WorkTimeFrom *string `xml:"workTimeFrom,omitempty"`
+ WorkTimeTo *string `xml:"workTimeTo,omitempty"`
+ DinnerTimeFrom *string `xml:"dinnerTimeFrom,omitempty"`
+ DinnerTimeTo *string `xml:"dinnerTimeTo,omitempty"`
+ ContactFio *string `xml:"contactFio,omitempty"`
+ ContactPhone *string `xml:"contactPhone,omitempty"`
+ ContactEmail *string `xml:"contactEmail,omitempty"`
+ Instructions *string `xml:"instructions,omitempty"`
+ NeedPass *bool `xml:"needPass,omitempty"`
+}
+
+type operationCreateOrderResponse struct {
+ CreateOrderResponse *createOrderResponse `xml:"createOrderResponse,omitempty"`
+}
+
+type createOrderResponse struct {
+ Return []*OrderStatus `xml:"return,omitempty"`
+}
+
+type operationGetOrderStatus struct {
+ GetOrderStatus *getOrderStatus `xml:"getOrderStatus,omitempty"`
+}
+
+type getOrderStatus struct {
+ OrderStatus *getOrderStatusRequest `xml:"orderStatus,omitempty"`
+}
+
+type getOrderStatusRequest struct {
+ Auth *Auth `xml:"auth,omitempty"`
+ Order []*InternalOrderNumber `xml:"order,omitempty"`
+}
+
+//InternalOrderNumber GetOrderStatus request body. Imply client side oder number
+type InternalOrderNumber struct {
+ OrderNumberInternal *string `xml:"orderNumberInternal,omitempty"`
+ DatePickup *string `xml:"datePickup,omitempty"`
+}
+
+type operationGetOrderStatusResponse struct {
+ GetOrderStatusResponse *getOrderStatusResponse `xml:"getOrderStatusResponse,omitempty"`
+}
+
+type getOrderStatusResponse struct {
+ Return []*OrderStatus `xml:"return,omitempty"`
+}
+
+type operationRemoveParcels struct {
+ RemoveParcels *removeParcels `xml:"removeParcels,omitempty"`
+}
+
+type removeParcels struct {
+ Parcels *UpdateOrderRequest `xml:"parcels,omitempty"`
+}
+
+type operationRemoveParcelsResponse struct {
+ RemoveParcelsResponse *removeParcelsResponse `xml:"removeParcelsResponse,omitempty"`
+}
+
+type removeParcelsResponse struct {
+ Return *OrderCorrectionStatus `xml:"return,omitempty"`
+}
diff --git a/orderRequestBuilder.go b/orderRequestBuilder.go
index 56c1c87..e2ffd72 100644
--- a/orderRequestBuilder.go
+++ b/orderRequestBuilder.go
@@ -2,80 +2,69 @@ package dpd
import (
"time"
-
- dpdSoap "github.com/vseinstrumentiru/dpd/soap"
)
-// Запрос на создание заказа
-type CreateOrderRequest dpdSoap.DpdOrdersData
-
-type ExtraParameter dpdSoap.Parameter
-type ExtraService dpdSoap.OrderExtraService
-type UnitLoad dpdSoap.UnitLoad
-
+//NewCreateOrderRequest ...
func NewCreateOrderRequest() *CreateOrderRequest {
- var orders []*dpdSoap.Order
+ var orders []*Order
req := &CreateOrderRequest{
- Header: &dpdSoap.Header{},
+ Header: &Header{},
Order: orders,
}
return req
}
+//SetDatePickup ...
func (r *CreateOrderRequest) SetDatePickup(time time.Time) *CreateOrderRequest {
- d := dpdSoap.Date(time.Format("2006-01-02"))
+ d := time.Format("2006-01-02")
r.Header.DatePickup = &d
return r
}
+//SetPayer ...
func (r *CreateOrderRequest) SetPayer(payer int64) *CreateOrderRequest {
r.Header.Payer = &payer
return r
}
+//SetSender ...
func (r *CreateOrderRequest) SetSender(address Address) *CreateOrderRequest {
- a := dpdSoap.Address(address)
- r.Header.SenderAddress = &a
+ r.Header.SenderAddress = &address
return r
}
+//SetPickupTimePeriod ...
func (r *CreateOrderRequest) SetPickupTimePeriod(period string) *CreateOrderRequest {
r.Header.PickupTimePeriod = &period
return r
}
+//SetRegularNum regular DPD order number. Ask your manager about correct number if you use it
func (r *CreateOrderRequest) SetRegularNum(num string) *CreateOrderRequest {
r.Header.RegularNum = &num
return r
}
+//AddOrder to CreateOrderRequest
func (r *CreateOrderRequest) AddOrder(order *Order) *CreateOrderRequest {
- o := dpdSoap.Order(*order)
- r.Order = append(r.Order, &o)
+ r.Order = append(r.Order, order)
return r
}
-func (r *CreateOrderRequest) toDPDRequest() *dpdSoap.DpdOrdersData {
- dpdRequest := dpdSoap.DpdOrdersData(*r)
-
- return &dpdRequest
-}
-
-type Order dpdSoap.Order
-
+//NewOrder ...
func NewOrder() *Order {
- var parcel []*dpdSoap.Parcel
- var extraService []*dpdSoap.OrderExtraService
- var extraParameter []*dpdSoap.Parameter
- var unitLoad []*dpdSoap.UnitLoad
+ var parcel []*Parcel
+ var extraService []*ExtraService
+ var extraParameter []*ExtraParameter
+ var unitLoad []*UnitLoadOrder
return &Order{
ExtraParam: extraParameter,
@@ -85,54 +74,63 @@ func NewOrder() *Order {
}
}
+//SetInternalOrderNumber imply client side order number
func (o *Order) SetInternalOrderNumber(number string) *Order {
o.OrderNumberInternal = &number
return o
}
+//SetServiceCode code of DPD service
func (o *Order) SetServiceCode(code string) *Order {
o.ServiceCode = &code
return o
}
+//SetServiceVariant delivery variant& Four variants are available(ДД, ДТ, ТД, ТТ)
func (o *Order) SetServiceVariant(variant string) *Order {
o.ServiceVariant = &variant
return o
}
-func (o *Order) SetCargoNumPack(num int) *Order {
+//SetCargoCount ...
+func (o *Order) SetCargoCount(num int) *Order {
o.CargoNumPack = &num
return o
}
+//SetCargoWeight ...
func (o *Order) SetCargoWeight(weight float64) *Order {
o.CargoWeight = &weight
return o
}
+//SetCargoVolume ...
func (o *Order) SetCargoVolume(volume float64) *Order {
o.CargoVolume = &volume
return o
}
-func (o *Order) SetCargoRegistered(flag bool) *Order {
+//SetValuableCargo ...
+func (o *Order) SetValuableCargo(flag bool) *Order {
o.CargoRegistered = &flag
return o
}
+//SetCargoValue ...
func (o *Order) SetCargoValue(value float64) *Order {
o.CargoValue = &value
return o
}
+//SerCargoCategory ...
func (o *Order) SerCargoCategory(category string) *Order {
o.CargoCategory = &category
@@ -152,49 +150,41 @@ func (o *Order) SetPaymentType(pType string) *Order {
}
func (o *Order) SetReceiverAddress(address *Address) *Order {
- a := dpdSoap.Address(*address)
- o.ReceiverAddress = &a
+ o.ReceiverAddress = address
return o
}
func (o *Order) SetReturnAddress(address *Address) *Order {
- a := dpdSoap.Address(*address)
- o.ReturnAddress = &a
+ o.ReturnAddress = address
return o
}
func (o *Order) AddExtraParameter(parameter *ExtraParameter) *Order {
- p := dpdSoap.Parameter(*parameter)
- o.ExtraParam = append(o.ExtraParam, &p)
+ o.ExtraParam = append(o.ExtraParam, parameter)
return o
}
func (o *Order) AddExtraService(service *ExtraService) *Order {
- s := dpdSoap.OrderExtraService(*service)
- o.ExtraService = append(o.ExtraService, &s)
+ o.ExtraService = append(o.ExtraService, service)
return o
}
func (o *Order) AddParcel(parcel *Parcel) *Order {
- p := dpdSoap.Parcel(*parcel)
- o.Parcel = append(o.Parcel, &p)
+ o.Parcel = append(o.Parcel, parcel)
return o
}
-func (o *Order) AddUnitLoad(load *UnitLoad) *Order {
- u := dpdSoap.UnitLoad(*load)
- o.UnitLoad = append(o.UnitLoad, &u)
+func (o *Order) AddUnitLoad(load *UnitLoadOrder) *Order {
+ o.UnitLoad = append(o.UnitLoad, load)
return o
}
-type Address dpdSoap.Address
-
func NewAddress() *Address {
return new(Address)
}
@@ -355,8 +345,6 @@ func (a *Address) SetNeedPass(flag bool) *Address {
return a
}
-type Parcel dpdSoap.Parcel
-
func NewParcel() *Parcel {
return new(Parcel)
}
@@ -421,10 +409,8 @@ func (p *Parcel) SetCodAmount(amount float64) *Parcel {
return p
}
-type UpdateOrderRequest dpdSoap.DpdOrderCorrection
-
func NewUpdateOrderRequest() *UpdateOrderRequest {
- var parcels []*dpdSoap.Parcel
+ var parcels []*Parcel
req := new(UpdateOrderRequest)
req.Parcel = parcels
@@ -475,47 +461,36 @@ func (r *UpdateOrderRequest) SetCargoCategory(category string) *UpdateOrderReque
}
func (r *UpdateOrderRequest) AddParcel(parcel *Parcel) *UpdateOrderRequest {
- p := dpdSoap.Parcel(*parcel)
- r.Parcel = append(r.Parcel, &p)
+ r.Parcel = append(r.Parcel, parcel)
return r
}
-func (r *UpdateOrderRequest) toDPDRequest() *dpdSoap.DpdOrderCorrection {
- dpdReq := dpdSoap.DpdOrderCorrection(*r)
-
- return &dpdReq
-}
-
-type Order2Cancel dpdSoap.OrderCancel
-
-func NewOrder2Cancel() *Order2Cancel {
- return new(Order2Cancel)
+func NewOrderToCancel() *OrderToCancel {
+ return new(OrderToCancel)
}
-func (o *Order2Cancel) SetInternalOrderNumber(number string) *Order2Cancel {
+func (o *OrderToCancel) SetInternalOrderNumber(number string) *OrderToCancel {
o.OrderNumberInternal = &number
return o
}
-func (o *Order2Cancel) SetDPDOrderNumber(number string) *Order2Cancel {
+func (o *OrderToCancel) SetDPDOrderNumber(number string) *OrderToCancel {
o.OrderNum = &number
return o
}
-func (o *Order2Cancel) SetPickupDate(time time.Time) *Order2Cancel {
- d := dpdSoap.Date(time.Format("2006-01-02"))
- o.Pickupdate = &d
+func (o *OrderToCancel) SetPickupDate(time time.Time) *OrderToCancel {
+ d := time.Format("2006-01-02")
+ o.PickupDate = &d
return o
}
-type CancelOrderRequest dpdSoap.DpdOrderCancellation
-
func NewCancelOrderRequest() *CancelOrderRequest {
- var orders []*dpdSoap.OrderCancel
+ var orders []*OrderToCancel
req := new(CancelOrderRequest)
req.Cancel = orders
@@ -523,15 +498,8 @@ func NewCancelOrderRequest() *CancelOrderRequest {
return req
}
-func (r *CancelOrderRequest) AddOrder(order *Order2Cancel) *CancelOrderRequest {
- o := dpdSoap.OrderCancel(*order)
- r.Cancel = append(r.Cancel, &o)
+func (r *CancelOrderRequest) AddOrder(order *OrderToCancel) *CancelOrderRequest {
+ r.Cancel = append(r.Cancel, order)
return r
}
-
-func (r *CancelOrderRequest) toDPDRequest() *dpdSoap.DpdOrderCancellation {
- dpdReq := dpdSoap.DpdOrderCancellation(*r)
-
- return &dpdReq
-}
diff --git a/orderRequestBuilder_test.go b/orderRequestBuilder_test.go
index 730ee50..30d5965 100644
--- a/orderRequestBuilder_test.go
+++ b/orderRequestBuilder_test.go
@@ -4,15 +4,13 @@ import (
"reflect"
"testing"
"time"
-
- dpdSoap "github.com/vseinstrumentiru/dpd/soap"
)
func createEmptyOrderRequest() *CreateOrderRequest {
- var orders []*dpdSoap.Order
+ var orders []*Order
return &CreateOrderRequest{
- Header: &dpdSoap.Header{},
+ Header: &Header{},
Order: orders,
}
}
@@ -42,7 +40,7 @@ func TestCreateOrderRequest_SetDatePickup(t *testing.T) {
}
date := time.Now()
- dpdDate := dpdSoap.Date(date.Format("2006-01-02"))
+ dpdDate := date.Format("2006-01-02")
want := createEmptyOrderRequest()
want.Header.DatePickup = &dpdDate
@@ -111,10 +109,9 @@ func TestCreateOrderRequest_SetSender(t *testing.T) {
}
address := NewAddress()
- dpdAddress := dpdSoap.Address(*address)
want := createEmptyOrderRequest()
- want.Header.SenderAddress = &dpdAddress
+ want.Header.SenderAddress = address
tests := []struct {
name string
@@ -179,7 +176,7 @@ func TestCreateOrderRequest_SetRegularNum(t *testing.T) {
num string
}
- num := "any string"
+ num := anyString
want := createEmptyOrderRequest()
want.Header.RegularNum = &num
@@ -216,7 +213,7 @@ func TestCreateOrderRequest_AddOrder(t *testing.T) {
order := new(Order)
want := createEmptyOrderRequest()
- want.Order = append(want.Order, &dpdSoap.Order{})
+ want.Order = append(want.Order, &Order{})
tests := []struct {
name string
@@ -242,37 +239,11 @@ func TestCreateOrderRequest_AddOrder(t *testing.T) {
}
}
-func TestCreateOrderRequest_toDPDRequest(t *testing.T) {
- var orders []*dpdSoap.Order
-
- tests := []struct {
- name string
- r *CreateOrderRequest
- want *dpdSoap.DpdOrdersData
- }{
- {
- "converter",
- NewCreateOrderRequest(),
- &dpdSoap.DpdOrdersData{
- Header: &dpdSoap.Header{},
- Order: orders,
- },
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.toDPDRequest(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("CreateOrderRequest.toDPDRequest() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
func createEmptyOrder() *Order {
- var parcel []*dpdSoap.Parcel
- var extraService []*dpdSoap.OrderExtraService
- var extraParameter []*dpdSoap.Parameter
- var unitLoad []*dpdSoap.UnitLoad
+ var parcel []*Parcel
+ var extraService []*ExtraService
+ var extraParameter []*ExtraParameter
+ var unitLoad []*UnitLoadOrder
return &Order{
ExtraParam: extraParameter,
@@ -306,7 +277,7 @@ func TestOrder_SetInternalOrderNumber(t *testing.T) {
number string
}
- number := "any string"
+ number := anyString
want := createEmptyOrder()
want.OrderNumberInternal = &number
@@ -340,7 +311,7 @@ func TestOrder_SetServiceCode(t *testing.T) {
code string
}
- code := "any string"
+ code := anyString
want := createEmptyOrder()
want.ServiceCode = &code
@@ -374,7 +345,7 @@ func TestOrder_SetServiceVariant(t *testing.T) {
variant string
}
- var variant = "any string"
+ var variant = anyString
want := createEmptyOrder()
want.ServiceVariant = &variant
@@ -430,8 +401,8 @@ func TestOrder_SetCargoNumPack(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := tt.o.SetCargoNumPack(tt.args.num); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("Order.SetCargoNumPack() = %v, want %v", got, tt.want)
+ if got := tt.o.SetCargoCount(tt.args.num); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Order.SetCargoCount() = %v, want %v", got, tt.want)
}
})
}
@@ -532,8 +503,8 @@ func TestOrder_SetCargoRegistered(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := tt.o.SetCargoRegistered(tt.args.flag); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("Order.SetCargoRegistered() = %v, want %v", got, tt.want)
+ if got := tt.o.SetValuableCargo(tt.args.flag); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Order.SetValuableCargo() = %v, want %v", got, tt.want)
}
})
}
@@ -578,7 +549,7 @@ func TestOrder_SerCargoCategory(t *testing.T) {
category string
}
- category := "any string"
+ category := anyString
want := createEmptyOrder()
want.CargoCategory = &category
@@ -612,7 +583,7 @@ func TestOrder_SetDeliveryTimePeriod(t *testing.T) {
period string
}
- period := "any string"
+ period := anyString
want := createEmptyOrder()
want.DeliveryTimePeriod = &period
@@ -646,7 +617,7 @@ func TestOrder_SetPaymentType(t *testing.T) {
pType string
}
- var pType = "any string"
+ pType := anyString
want := createEmptyOrder()
want.PaymentType = &pType
@@ -683,7 +654,7 @@ func TestOrder_SetReceiverAddress(t *testing.T) {
address := new(Address)
want := createEmptyOrder()
- want.ReceiverAddress = &dpdSoap.Address{}
+ want.ReceiverAddress = &Address{}
tests := []struct {
name string
@@ -717,7 +688,7 @@ func TestOrder_SetReturnAddress(t *testing.T) {
address := new(Address)
want := createEmptyOrder()
- want.ReturnAddress = &dpdSoap.Address{}
+ want.ReturnAddress = &Address{}
tests := []struct {
name string
@@ -751,7 +722,7 @@ func TestOrder_AddExtraParameter(t *testing.T) {
parameter := new(ExtraParameter)
want := createEmptyOrder()
- want.ExtraParam = append(want.ExtraParam, &dpdSoap.Parameter{})
+ want.ExtraParam = append(want.ExtraParam, &ExtraParameter{})
tests := []struct {
name string
@@ -785,7 +756,7 @@ func TestOrder_AddExtraService(t *testing.T) {
service := new(ExtraService)
want := createEmptyOrder()
- want.ExtraService = append(want.ExtraService, &dpdSoap.OrderExtraService{})
+ want.ExtraService = append(want.ExtraService, &ExtraService{})
tests := []struct {
name string
@@ -819,7 +790,7 @@ func TestOrder_AddParcel(t *testing.T) {
parcel := new(Parcel)
want := createEmptyOrder()
- want.Parcel = append(want.Parcel, &dpdSoap.Parcel{})
+ want.Parcel = append(want.Parcel, &Parcel{})
tests := []struct {
name string
@@ -847,13 +818,13 @@ func TestOrder_AddParcel(t *testing.T) {
func TestOrder_AddUnitLoad(t *testing.T) {
type args struct {
- load *UnitLoad
+ load *UnitLoadOrder
}
- unit := new(UnitLoad)
+ unit := new(UnitLoadOrder)
want := createEmptyOrder()
- want.UnitLoad = append(want.UnitLoad, &dpdSoap.UnitLoad{})
+ want.UnitLoad = append(want.UnitLoad, &UnitLoadOrder{})
tests := []struct {
name string
@@ -903,7 +874,7 @@ func TestAddress_SetCode(t *testing.T) {
code string
}
- code := "any string"
+ code := anyString
tests := []struct {
name string
@@ -936,7 +907,7 @@ func TestAddress_SetName(t *testing.T) {
name string
}
- name := "any string"
+ name := anyString
tests := []struct {
name string
@@ -969,7 +940,7 @@ func TestAddress_SetTerminalCode(t *testing.T) {
code string
}
- terminalCode := "any string"
+ terminalCode := anyString
tests := []struct {
name string
@@ -1002,7 +973,7 @@ func TestAddress_SetAddressString(t *testing.T) {
address string
}
- address := "any string"
+ address := anyString
tests := []struct {
name string
@@ -1035,7 +1006,7 @@ func TestAddress_SetCountryName(t *testing.T) {
name string
}
- name := "any string"
+ name := anyString
tests := []struct {
name string
@@ -1068,7 +1039,7 @@ func TestAddress_SetZip(t *testing.T) {
zip string
}
- zip := "any string"
+ zip := anyString
tests := []struct {
name string
@@ -1101,7 +1072,7 @@ func TestAddress_SetRegion(t *testing.T) {
region string
}
- region := "Any string"
+ region := anyString
tests := []struct {
name string
@@ -1134,7 +1105,7 @@ func TestAddress_SetCity(t *testing.T) {
city string
}
- city := "any string"
+ city := anyString
tests := []struct {
name string
@@ -1167,7 +1138,7 @@ func TestAddress_SetStreet(t *testing.T) {
street string
}
- street := "any string"
+ street := anyString
tests := []struct {
name string
@@ -1200,7 +1171,7 @@ func TestAddress_SetStreetAbbr(t *testing.T) {
abbr string
}
- abbr := "any string"
+ abbr := anyString
tests := []struct {
name string
@@ -1233,7 +1204,7 @@ func TestAddress_SetHouse(t *testing.T) {
house string
}
- house := "any string"
+ house := anyString
tests := []struct {
name string
@@ -1266,7 +1237,7 @@ func TestAddress_SetHousing(t *testing.T) {
housing string
}
- housing := "any string"
+ housing := anyString
tests := []struct {
name string
@@ -1299,7 +1270,7 @@ func TestAddress_SetBuilding(t *testing.T) {
building string
}
- building := "any string"
+ building := anyString
tests := []struct {
name string
@@ -1332,7 +1303,7 @@ func TestAddress_SetPossession(t *testing.T) {
possession string
}
- possession := "any string"
+ possession := anyString
tests := []struct {
name string
@@ -1365,7 +1336,7 @@ func TestAddress_SetExtraInfo(t *testing.T) {
info string
}
- info := "any string"
+ info := anyString
tests := []struct {
name string
@@ -1398,7 +1369,7 @@ func TestAddress_SetOffice(t *testing.T) {
office string
}
- office := "any string"
+ office := anyString
tests := []struct {
name string
@@ -1431,7 +1402,7 @@ func TestAddress_SetFlat(t *testing.T) {
flat string
}
- flat := "any string"
+ flat := anyString
tests := []struct {
name string
@@ -1596,7 +1567,7 @@ func TestAddress_SetContactFullName(t *testing.T) {
fullName string
}
- fullName := "any string"
+ fullName := anyString
tests := []struct {
name string
@@ -1629,7 +1600,7 @@ func TestAddress_SetContactPhone(t *testing.T) {
phone string
}
- phone := "any string"
+ phone := anyString
tests := []struct {
name string
@@ -1662,7 +1633,7 @@ func TestAddress_SetContactEmail(t *testing.T) {
email string
}
- email := "any string"
+ email := anyString
tests := []struct {
name string
@@ -1695,7 +1666,7 @@ func TestAddress_SetInstructions(t *testing.T) {
instructions string
}
- instructions := "any string"
+ instructions := anyString
tests := []struct {
name string
@@ -1780,7 +1751,7 @@ func TestParcel_SetNumber(t *testing.T) {
number string
}
- number := "any string"
+ number := anyString
tests := []struct {
name string
@@ -1846,7 +1817,7 @@ func TestParcel_SetNumberForPrint(t *testing.T) {
number string
}
- number := "any string"
+ number := anyString
tests := []struct {
name string
@@ -2129,7 +2100,7 @@ func TestUpdateOrderRequest_SetDPDOrderNumber(t *testing.T) {
number string
}
- number := "any string"
+ number := anyString
tests := []struct {
name string
@@ -2162,7 +2133,7 @@ func TestUpdateOrderRequest_SetInternalOrderNumber(t *testing.T) {
number string
}
- number := "any string"
+ number := anyString
tests := []struct {
name string
@@ -2327,7 +2298,7 @@ func TestUpdateOrderRequest_SetCargoCategory(t *testing.T) {
category string
}
- category := "any string"
+ category := anyString
tests := []struct {
name string
@@ -2361,9 +2332,9 @@ func TestUpdateOrderRequest_AddParcel(t *testing.T) {
}
parcel := NewParcel()
- parcels := make([]*dpdSoap.Parcel, 0)
+ parcels := make([]*Parcel, 0)
- parcels = append(parcels, &dpdSoap.Parcel{})
+ parcels = append(parcels, &Parcel{})
tests := []struct {
name string
@@ -2391,41 +2362,20 @@ func TestUpdateOrderRequest_AddParcel(t *testing.T) {
}
}
-func TestUpdateOrderRequest_toDPDRequest(t *testing.T) {
- tests := []struct {
- name string
- r *UpdateOrderRequest
- want *dpdSoap.DpdOrderCorrection
- }{
- {
- "Convert to DPD request",
- NewUpdateOrderRequest(),
- &dpdSoap.DpdOrderCorrection{},
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.toDPDRequest(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("UpdateOrderRequest.toDPDRequest() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
func TestNewOrder2Cancel(t *testing.T) {
tests := []struct {
name string
- want *Order2Cancel
+ want *OrderToCancel
}{
{
"Constructor",
- &Order2Cancel{},
+ &OrderToCancel{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := NewOrder2Cancel(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("NewOrder2Cancel() = %v, want %v", got, tt.want)
+ if got := NewOrderToCancel(); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("NewOrderToCancel() = %v, want %v", got, tt.want)
}
})
}
@@ -2436,21 +2386,21 @@ func TestOrder2Cancel_SetInternalOrderNumber(t *testing.T) {
number string
}
- number := "any string"
+ number := anyString
tests := []struct {
name string
- o *Order2Cancel
+ o *OrderToCancel
args args
- want *Order2Cancel
+ want *OrderToCancel
}{
{
"Set internal order number",
- NewOrder2Cancel(),
+ NewOrderToCancel(),
args{
number,
},
- &Order2Cancel{
+ &OrderToCancel{
OrderNumberInternal: &number,
},
},
@@ -2458,7 +2408,7 @@ func TestOrder2Cancel_SetInternalOrderNumber(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.o.SetInternalOrderNumber(tt.args.number); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("Order2Cancel.SetInternalOrderNumber() = %v, want %v", got, tt.want)
+ t.Errorf("OrderToCancel.SetInternalOrderNumber() = %v, want %v", got, tt.want)
}
})
}
@@ -2469,21 +2419,21 @@ func TestOrder2Cancel_SetDPDOrderNumber(t *testing.T) {
number string
}
- number := "any string"
+ number := anyString
tests := []struct {
name string
- o *Order2Cancel
+ o *OrderToCancel
args args
- want *Order2Cancel
+ want *OrderToCancel
}{
{
"Set DPD order number",
- NewOrder2Cancel(),
+ NewOrderToCancel(),
args{
number,
},
- &Order2Cancel{
+ &OrderToCancel{
OrderNum: &number,
},
},
@@ -2491,7 +2441,7 @@ func TestOrder2Cancel_SetDPDOrderNumber(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.o.SetDPDOrderNumber(tt.args.number); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("Order2Cancel.SetDPDOrderNumber() = %v, want %v", got, tt.want)
+ t.Errorf("OrderToCancel.SetDPDOrderNumber() = %v, want %v", got, tt.want)
}
})
}
@@ -2503,36 +2453,36 @@ func TestOrder2Cancel_SetPickupDate(t *testing.T) {
}
now := time.Now()
- dpdDate := dpdSoap.Date(now.Format("2006-01-02"))
+ dpdDate := now.Format("2006-01-02")
tests := []struct {
name string
- o *Order2Cancel
+ o *OrderToCancel
args args
- want *Order2Cancel
+ want *OrderToCancel
}{
{
"Set pikcup date",
- NewOrder2Cancel(),
+ NewOrderToCancel(),
args{
now,
},
- &Order2Cancel{
- Pickupdate: &dpdDate,
+ &OrderToCancel{
+ PickupDate: &dpdDate,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.o.SetPickupDate(tt.args.time); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("Order2Cancel.SetPickupDate() = %v, want %v", got, tt.want)
+ t.Errorf("OrderToCancel.SetPickupDate() = %v, want %v", got, tt.want)
}
})
}
}
func TestNewCancelOrderRequest(t *testing.T) {
- var orders []*dpdSoap.OrderCancel
+ var orders []*OrderToCancel
tests := []struct {
name string
@@ -2556,12 +2506,12 @@ func TestNewCancelOrderRequest(t *testing.T) {
func TestCancelOrderRequest_AddOrder(t *testing.T) {
type args struct {
- order *Order2Cancel
+ order *OrderToCancel
}
- var orders []*dpdSoap.OrderCancel
+ var orders []*OrderToCancel
- orders = append(orders, &dpdSoap.OrderCancel{})
+ orders = append(orders, &OrderToCancel{})
tests := []struct {
name string
@@ -2573,7 +2523,7 @@ func TestCancelOrderRequest_AddOrder(t *testing.T) {
"Add order",
NewCancelOrderRequest(),
args{
- &Order2Cancel{},
+ &OrderToCancel{},
},
&CancelOrderRequest{
Cancel: orders,
@@ -2588,24 +2538,3 @@ func TestCancelOrderRequest_AddOrder(t *testing.T) {
})
}
}
-
-func TestCancelOrderRequest_toDPDRequest(t *testing.T) {
- tests := []struct {
- name string
- r *CancelOrderRequest
- want *dpdSoap.DpdOrderCancellation
- }{
- {
- "Converter",
- NewCancelOrderRequest(),
- &dpdSoap.DpdOrderCancellation{},
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.toDPDRequest(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("CancelOrderRequest.toDPDRequest() = %v, want %v", got, tt.want)
- }
- })
- }
-}
diff --git a/soap/calculator.go b/soap/calculator.go
deleted file mode 100644
index 07b65de..0000000
--- a/soap/calculator.go
+++ /dev/null
@@ -1,311 +0,0 @@
-package soap
-
-import "github.com/fiorix/wsdl2go/soap"
-
-const CalculatorNamespace = "http://dpd.ru/ws/calculator/2012-03-20"
-
-type dPDCalculator struct {
- cli *soap.Client
-}
-
-func NewDPDCalculator(cli *soap.Client) DPDCalculator {
- return &dPDCalculator{cli}
-}
-
-type DPDCalculator interface {
- GetServiceCost(GetServiceCost *GetServiceCost) (*GetServiceCostResponse, error)
- GetServiceCost2(GetServiceCost2 *GetServiceCost2) (*GetServiceCost2Response, error)
- GetServiceCostByParcels(GetServiceCostByParcels *GetServiceCostByParcels) (*GetServiceCostByParcelsResponse, error)
- GetServiceCostByParcels2(GetServiceCostByParcels2 *GetServiceCostByParcels2) (*GetServiceCostByParcels2Response, error)
- GetServiceCostInternational(GetServiceCostInternational *GetServiceCostInternational) (*GetServiceCostInternationalResponse, error)
-}
-
-func (p *dPDCalculator) GetServiceCost(GetServiceCost *GetServiceCost) (*GetServiceCostResponse, error) {
- α := struct {
- OperationGetServiceCost `xml:"tns:getServiceCost"`
- }{
- OperationGetServiceCost{
- GetServiceCost,
- },
- }
-
- γ := struct {
- OperationGetServiceCostResponse `xml:"getServiceCostResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetServiceCost", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetServiceCostResponse, nil
-}
-
-func (p *dPDCalculator) GetServiceCost2(GetServiceCost2 *GetServiceCost2) (*GetServiceCost2Response, error) {
- α := struct {
- OperationGetServiceCost2 `xml:"tns:getServiceCost2"`
- }{
- OperationGetServiceCost2{
- GetServiceCost2,
- },
- }
-
- γ := struct {
- OperationGetServiceCost2Response `xml:"getServiceCost2Response"`
- }{}
- if err := p.cli.RoundTripWithAction("GetServiceCost2", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetServiceCost2Response, nil
-}
-
-func (p *dPDCalculator) GetServiceCostByParcels(GetServiceCostByParcels *GetServiceCostByParcels) (*GetServiceCostByParcelsResponse, error) {
- α := struct {
- OperationGetServiceCostByParcels `xml:"tns:getServiceCostByParcels"`
- }{
- OperationGetServiceCostByParcels{
- GetServiceCostByParcels,
- },
- }
-
- γ := struct {
- OperationGetServiceCostByParcelsResponse `xml:"getServiceCostByParcelsResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetServiceCostByParcels", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetServiceCostByParcelsResponse, nil
-}
-
-func (p *dPDCalculator) GetServiceCostByParcels2(GetServiceCostByParcels2 *GetServiceCostByParcels2) (*GetServiceCostByParcels2Response, error) {
- α := struct {
- OperationGetServiceCostByParcels2 `xml:"tns:getServiceCostByParcels2"`
- }{
- OperationGetServiceCostByParcels2{
- GetServiceCostByParcels2,
- },
- }
-
- γ := struct {
- OperationGetServiceCostByParcels2Response `xml:"getServiceCostByParcels2Response"`
- }{}
- if err := p.cli.RoundTripWithAction("GetServiceCostByParcels2", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetServiceCostByParcels2Response, nil
-}
-
-func (p *dPDCalculator) GetServiceCostInternational(GetServiceCostInternational *GetServiceCostInternational) (*GetServiceCostInternationalResponse, error) {
- α := struct {
- OperationGetServiceCostInternational `xml:"tns:getServiceCostInternational"`
- }{
- OperationGetServiceCostInternational{
- GetServiceCostInternational,
- },
- }
-
- γ := struct {
- OperationGetServiceCostInternationalResponse `xml:"getServiceCostInternationalResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetServiceCostInternational", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetServiceCostInternationalResponse, nil
-}
-
-type ServiceCostFault struct {
- Code *string `xml:"code,omitempty"`
- DeliveryDups []*CalculatorCity `xml:"deliveryDups,omitempty"`
- Message *string `xml:"message,omitempty"`
- PickupDups []*CalculatorCity `xml:"pickupDups,omitempty"`
-}
-
-type ServiceCostFault2 struct {
- Code *string `xml:"code,omitempty"`
- DeliveryDups []*CityIndex `xml:"deliveryDups,omitempty"`
- Message *string `xml:"message,omitempty"`
- PickupDups []*CityIndex `xml:"pickupDups,omitempty"`
-}
-
-type CalculatorCity struct {
- CityId *int64 `xml:"cityId,omitempty"`
- CountryCode *string `xml:"countryCode,omitempty"`
- CountryName *string `xml:"countryName,omitempty"`
- RegionCode *int `xml:"regionCode,omitempty"`
- RegionName *string `xml:"regionName,omitempty"`
- CityName *string `xml:"cityName,omitempty"`
-}
-
-type CityIndex struct {
- CityId *int64 `xml:"cityId,omitempty"`
- CountryCode *string `xml:"countryCode,omitempty"`
- CountryName *string `xml:"countryName,omitempty"`
- RegionCode *int `xml:"regionCode,omitempty"`
- RegionName *string `xml:"regionName,omitempty"`
- CityCode *string `xml:"cityCode,omitempty"`
- CityName *string `xml:"cityName,omitempty"`
- Abbreviation *string `xml:"abbreviation,omitempty"`
- IndexMin *string `xml:"indexMin,omitempty"`
- IndexMax *string `xml:"indexMax,omitempty"`
-}
-
-type CityInternationalRequest struct {
- CountryName *string `xml:"countryName,omitempty"`
- CityName *string `xml:"cityName,omitempty"`
- CityId *int64 `xml:"cityId,omitempty"`
-}
-
-type CityRequest struct {
- CityId *int64 `xml:"cityId,omitempty"`
- Index *string `xml:"index,omitempty"`
- CityName *string `xml:"cityName,omitempty"`
- RegionCode *int `xml:"regionCode,omitempty"`
- CountryCode *string `xml:"countryCode,omitempty"`
-}
-
-type GetServiceCost struct {
- Request *ServiceCostRequest `xml:"request,omitempty"`
-}
-
-type GetServiceCost2 struct {
- Ns string `xml:"xmlns,attr"`
- Request *ServiceCostRequest `xml:"request,omitempty"`
-}
-
-type GetServiceCost2Response struct {
- Return []*ServiceCost `xml:"return,omitempty"`
-}
-
-type GetServiceCostByParcels struct {
- Request *ServiceCostParcelsRequest `xml:"request,omitempty"`
-}
-
-type GetServiceCostByParcels2 struct {
- Request *ServiceCostParcelsRequest `xml:"request,omitempty"`
-}
-
-type GetServiceCostByParcels2Response struct {
- Return []*ServiceCost `xml:"return,omitempty"`
-}
-
-type GetServiceCostByParcelsResponse struct {
- Return []*ServiceCost `xml:"return,omitempty"`
-}
-
-type GetServiceCostInternational struct {
- Request *ServiceCostInternationalRequest `xml:"request,omitempty"`
-}
-
-type GetServiceCostInternationalResponse struct {
- Return []*ServiceCostInternational `xml:"return,omitempty"`
-}
-
-type GetServiceCostResponse struct {
- Return []*ServiceCost `xml:"return,omitempty"`
-}
-
-type ParcelRequest struct {
- Weight *float64 `xml:"weight,omitempty"`
- Length *float64 `xml:"length,omitempty"`
- Width *float64 `xml:"width,omitempty"`
- Height *float64 `xml:"height,omitempty"`
- Quantity *int `xml:"quantity,omitempty"`
-}
-
-type ServiceCost struct {
- ServiceCode *string `xml:"serviceCode,omitempty"`
- ServiceName *string `xml:"serviceName,omitempty"`
- Cost *float64 `xml:"cost,omitempty"`
- Days *int `xml:"days,omitempty"`
-}
-
-type ServiceCostInternational struct {
- ServiceCode *string `xml:"serviceCode,omitempty"`
- ServiceName *string `xml:"serviceName,omitempty"`
- Days *string `xml:"days,omitempty"`
- Cost *float64 `xml:"cost,omitempty"`
- CostPin *float64 `xml:"costPin,omitempty"`
- Weight *float64 `xml:"weight,omitempty"`
- Volume *float64 `xml:"Volume,omitempty"`
-}
-
-type ServiceCostInternationalRequest struct {
- Auth *Auth `xml:"auth,omitempty"`
- Pickup *CityInternationalRequest `xml:"pickup,omitempty"`
- Delivery *CityInternationalRequest `xml:"delivery,omitempty"`
- SelfPickup *bool `xml:"SelfPickup,omitempty"`
- SelfDelivery *bool `xml:"SelfDelivery,omitempty"`
- Weight *float64 `xml:"weight,omitempty"`
- Length *int64 `xml:"length,omitempty"`
- Width *int64 `xml:"width,omitempty"`
- Height *int64 `xml:"height,omitempty"`
- DeclaredValue *float64 `xml:"declaredValue,omitempty"`
- Insurance *bool `xml:"insurance,omitempty"`
-}
-
-type ServiceCostParcelsRequest struct {
- Auth *Auth `xml:"auth,omitempty"`
- Pickup *CityRequest `xml:"pickup,omitempty"`
- Delivery *CityRequest `xml:"delivery,omitempty"`
- SelfPickup *bool `xml:"SelfPickup,omitempty"`
- SelfDelivery *bool `xml:"SelfDelivery,omitempty"`
- ServiceCode *string `xml:"serviceCode,omitempty"`
- PickupDate *Date `xml:"pickupDate,omitempty"`
- MaxDays *int `xml:"MaxDays,omitempty"`
- MaxCost *float64 `xml:"MaxCost,omitempty"`
- DeclaredValue *float64 `xml:"declaredValue,omitempty"`
- Parcel []*ParcelRequest `xml:"parcel,omitempty"`
-}
-
-type ServiceCostRequest struct {
- Ns string `xml:"xmlns,attr"`
- Auth *Auth `xml:"auth,omitempty"`
- Pickup *CityRequest `xml:"pickup,omitempty"`
- Delivery *CityRequest `xml:"delivery,omitempty"`
- SelfPickup *bool `xml:"selfPickup,omitempty"`
- SelfDelivery *bool `xml:"selfDelivery,omitempty"`
- Weight *float64 `xml:"weight,omitempty"`
- Volume *float64 `xml:"volume,omitempty"`
- ServiceCode *string `xml:"serviceCode,omitempty"`
- PickupDate *Date `xml:"pickupDate,omitempty"`
- MaxDays *int `xml:"maxDays,omitempty"`
- MaxCost *float64 `xml:"maxCost,omitempty"`
- DeclaredValue *float64 `xml:"declaredValue,omitempty"`
-}
-
-type OperationGetServiceCost struct {
- GetServiceCost *GetServiceCost `xml:"getServiceCost,omitempty"`
-}
-
-type OperationGetServiceCostResponse struct {
- GetServiceCostResponse *GetServiceCostResponse `xml:"getServiceCostResponse,omitempty"`
-}
-
-type OperationGetServiceCost2 struct {
- GetServiceCost2 *GetServiceCost2 `xml:"getServiceCost2,omitempty"`
-}
-
-type OperationGetServiceCost2Response struct {
- GetServiceCost2Response *GetServiceCost2Response `xml:"getServiceCost2Response,omitempty"`
-}
-
-type OperationGetServiceCostByParcels struct {
- GetServiceCostByParcels *GetServiceCostByParcels `xml:"getServiceCostByParcels,omitempty"`
-}
-
-type OperationGetServiceCostByParcelsResponse struct {
- GetServiceCostByParcelsResponse *GetServiceCostByParcelsResponse `xml:"getServiceCostByParcelsResponse,omitempty"`
-}
-
-type OperationGetServiceCostByParcels2 struct {
- GetServiceCostByParcels2 *GetServiceCostByParcels2 `xml:"getServiceCostByParcels2,omitempty"`
-}
-
-type OperationGetServiceCostByParcels2Response struct {
- GetServiceCostByParcels2Response *GetServiceCostByParcels2Response `xml:"getServiceCostByParcels2Response,omitempty"`
-}
-
-type OperationGetServiceCostInternational struct {
- GetServiceCostInternational *GetServiceCostInternational `xml:"getServiceCostInternational,omitempty"`
-}
-
-type OperationGetServiceCostInternationalResponse struct {
- GetServiceCostInternationalResponse *GetServiceCostInternationalResponse `xml:"getServiceCostInternationalResponse,omitempty"`
-}
diff --git a/soap/commonModels.go b/soap/commonModels.go
deleted file mode 100644
index 6b97ee8..0000000
--- a/soap/commonModels.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package soap
-
-type Date string
-
-type DateTime string
-
-type Auth struct {
- Ns *string `xml:"xmlns,attr"`
- ClientNumber *int64 `xml:"clientNumber,omitempty"`
- ClientKey *string `xml:"clientKey,omitempty"`
-}
-
-type WSFault struct {
- Code *string `xml:"code,omitempty"`
- Message *string `xml:"message,omitempty"`
-}
diff --git a/soap/doc.go b/soap/doc.go
deleted file mode 100644
index c113dc7..0000000
--- a/soap/doc.go
+++ /dev/null
@@ -1,4 +0,0 @@
-// Автоматически сгенерированный код для работы с wsdl
-//
-// Спасибо проекту wsdl2go (https://github.com/fiorix/wsdl2go/)
-package soap
diff --git a/soap/event-tracking.go b/soap/event-tracking.go
deleted file mode 100644
index e631791..0000000
--- a/soap/event-tracking.go
+++ /dev/null
@@ -1,195 +0,0 @@
-package soap
-
-import (
- "github.com/fiorix/wsdl2go/soap"
-)
-
-const EventTrackingNamespace = "http://dpd.ru/ws/event-tracking/2016-02-15"
-
-func NewDPDEventTracking(cli *soap.Client) DPDEventTracking {
- return &dPDEventTracking{cli}
-}
-
-type DPDEventTracking interface {
- Confirm(Confirm *Confirm) (*ConfirmResponse, error)
- GetEvents(GetEvents *GetEvents) (*GetEventsResponse, error)
- GetTrakingOrderLink(GetTrakingOrderLink *GetTrakingOrderLink) (*GetTrakingOrderLinkResponse, error)
-}
-
-type Confirm struct {
- Request *RequestConfirm `xml:"request,omitempty"`
-}
-
-type ConfirmResponse struct {
- Return *string `xml:"return,omitempty"`
-}
-
-type EventTackingResponse struct {
- DocId *int64 `xml:"docId,omitempty"`
- DocDate *DateTime `xml:"docDate,omitempty"`
- ClientNumber *int64 `xml:"clientNumber,omitempty"`
- ResultComplete *bool `xml:"resultComplete,omitempty"`
- Event []*EventType `xml:"event,omitempty"`
-}
-
-type EventTrackingRequest struct {
- Auth *Auth `xml:"auth,omitempty"`
- DateFrom *DateTime `xml:"dateFrom,omitempty"`
- DateTo *DateTime `xml:"dateTo,omitempty"`
- MaxRowCount *int `xml:"maxRowCount,omitempty"`
-}
-
-type EventTrackingUnitLoad struct {
- Article *string `xml:"article,omitempty"`
- Descript *string `xml:"descript,omitempty"`
- Declared_value *string `xml:"declared_value,omitempty"`
- Parcel_num *string `xml:"parcel_num,omitempty"`
- Npp_amount *string `xml:"npp_amount,omitempty"`
- Vat_percent *int `xml:"vat_percent,omitempty"`
- Without_vat *bool `xml:"without_vat,omitempty"`
- Count *int `xml:"count,omitempty"`
- State_name *string `xml:"state_name,omitempty"`
-}
-
-type EventType struct {
- ClientOrderNr *string `xml:"clientOrderNr,omitempty"`
- ClientCodeInternal *string `xml:"clientCodeInternal,omitempty"`
- ClientParcelNr *string `xml:"clientParcelNr,omitempty"`
- DpdOrderNr *string `xml:"dpdOrderNr,omitempty"`
- DpdParcelNr *string `xml:"dpdParcelNr,omitempty"`
- EventNumber *string `xml:"eventNumber,omitempty"`
- EventCode *string `xml:"eventCode,omitempty"`
- EventName *string `xml:"eventName,omitempty"`
- ReasonCode *string `xml:"reasonCode,omitempty"`
- ReasonName *string `xml:"reasonName,omitempty"`
- EventDate *string `xml:"eventDate,omitempty"`
- Parameter []*ParameterType `xml:"parameter,omitempty"`
-}
-
-type ExtTrackingLinkRequest struct {
- Auth *Auth `xml:"auth,omitempty"`
- Order *TrackingOrder `xml:"order,omitempty"`
-}
-
-type ExtTrackingLinkResponse struct {
- Link *string `xml:"link,omitempty"`
- Status *string `xml:"status,omitempty"`
-}
-
-type GetEvents struct {
- Request *EventTrackingRequest `xml:"request,omitempty"`
-}
-
-type GetEventsResponse struct {
- Return *EventTackingResponse `xml:"return,omitempty"`
-}
-
-type GetTrakingOrderLink struct {
- TrackingOrder *ExtTrackingLinkRequest `xml:"trackingOrder,omitempty"`
-}
-
-type GetTrakingOrderLinkResponse struct {
- Return *ExtTrackingLinkResponse `xml:"return,omitempty"`
-}
-
-type TrackingOrder struct {
- OrderNumberDPD *string `xml:"orderNumberDPD,omitempty"`
- OrderNumberInternal *string `xml:"orderNumberInternal,omitempty"`
- OrderNumberInternalAdditional *string `xml:"orderNumberInternalAdditional,omitempty"`
-}
-
-type ParameterType struct {
- ParamName *string `xml:"paramName,omitempty"`
- ValueString *string `xml:"valueString,omitempty"`
- ValueDecimal *float64 `xml:"valueDecimal,omitempty"`
- ValueDateTime *DateTime `xml:"valueDateTime,omitempty"`
- Value []*EventTrackingUnitLoad `xml:"value,omitempty"`
- Type string `xml:"type,attr,omitempty"`
-}
-
-type RequestConfirm struct {
- Auth *Auth `xml:"auth,omitempty"`
- DocId *int64 `xml:"docId,omitempty"`
-}
-
-type OperationConfirm struct {
- Confirm *Confirm `xml:"confirm,omitempty"`
-}
-
-type OperationConfirmResponse struct {
- ConfirmResponse *ConfirmResponse `xml:"confirmResponse,omitempty"`
-}
-
-type OperationGetEvents struct {
- GetEvents *GetEvents `xml:"getEvents,omitempty"`
-}
-
-type OperationGetEventsResponse struct {
- GetEventsResponse *GetEventsResponse `xml:"getEventsResponse,omitempty"`
-}
-
-type OperationGetTrakingOrderLink struct {
- GetTrakingOrderLink *GetTrakingOrderLink `xml:"getTrakingOrderLink,omitempty"`
-}
-
-type OperationGetTrakingOrderLinkResponse struct {
- GetTrakingOrderLinkResponse *GetTrakingOrderLinkResponse `xml:"getTrakingOrderLinkResponse,omitempty"`
-}
-
-type dPDEventTracking struct {
- cli *soap.Client
-}
-
-func (p *dPDEventTracking) Confirm(Confirm *Confirm) (*ConfirmResponse, error) {
- α := struct {
- OperationConfirm `xml:"tns:confirm"`
- }{
- OperationConfirm{
- Confirm,
- },
- }
-
- γ := struct {
- OperationConfirmResponse `xml:"confirmResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("Confirm", α, &γ); err != nil {
- return nil, err
- }
- return γ.ConfirmResponse, nil
-}
-
-func (p *dPDEventTracking) GetEvents(GetEvents *GetEvents) (*GetEventsResponse, error) {
- α := struct {
- OperationGetEvents `xml:"tns:getEvents"`
- }{
- OperationGetEvents{
- GetEvents,
- },
- }
-
- γ := struct {
- OperationGetEventsResponse `xml:"getEventsResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetEvents", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetEventsResponse, nil
-}
-
-func (p *dPDEventTracking) GetTrakingOrderLink(GetTrakingOrderLink *GetTrakingOrderLink) (*GetTrakingOrderLinkResponse, error) {
- α := struct {
- OperationGetTrakingOrderLink `xml:"tns:getTrakingOrderLink"`
- }{
- OperationGetTrakingOrderLink{
- GetTrakingOrderLink,
- },
- }
-
- γ := struct {
- OperationGetTrakingOrderLinkResponse `xml:"getTrakingOrderLinkResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetTrakingOrderLink", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetTrakingOrderLinkResponse, nil
-}
diff --git a/soap/geography.go b/soap/geography.go
deleted file mode 100644
index 58134c0..0000000
--- a/soap/geography.go
+++ /dev/null
@@ -1,361 +0,0 @@
-package soap
-
-import "github.com/fiorix/wsdl2go/soap"
-
-const GeographyNamespace = "http://dpd.ru/ws/geography/2015-05-20"
-
-func NewDPDGeography2(cli *soap.Client) DPDGeography2 {
- return &dPDGeography2{cli}
-}
-
-type DPDGeography2 interface {
- GetCitiesCashPay(GetCitiesCashPay *GetCitiesCashPay) (*GetCitiesCashPayResponse, error)
- GetParcelShops(GetParcelShops *GetParcelShops) (*GetParcelShopsResponse, error)
- GetPossibleExtraService(GetPossibleExtraService *GetPossibleExtraService) (*GetPossibleExtraServiceResponse, error)
- GetStoragePeriod(GetStoragePeriod *GetStoragePeriod) (*GetStoragePeriodResponse, error)
- GetTerminalsSelfDelivery2(GetTerminalsSelfDelivery2 *GetTerminalsSelfDelivery2) (*GetTerminalsSelfDelivery2Response, error)
-}
-
-func (p *dPDGeography2) GetCitiesCashPay(GetCitiesCashPay *GetCitiesCashPay) (*GetCitiesCashPayResponse, error) {
- α := struct {
- OperationGetCitiesCashPay `xml:"tns:getCitiesCashPay"`
- }{
- OperationGetCitiesCashPay{
- GetCitiesCashPay,
- },
- }
-
- γ := struct {
- OperationGetCitiesCashPayResponse `xml:"getCitiesCashPayResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetCitiesCashPay", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetCitiesCashPayResponse, nil
-}
-
-func (p *dPDGeography2) GetParcelShops(GetParcelShops *GetParcelShops) (*GetParcelShopsResponse, error) {
- α := struct {
- OperationGetParcelShops `xml:"tns:getParcelShops"`
- }{
- OperationGetParcelShops{
- GetParcelShops,
- },
- }
-
- γ := struct {
- OperationGetParcelShopsResponse `xml:"getParcelShopsResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetParcelShops", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetParcelShopsResponse, nil
-}
-
-func (p *dPDGeography2) GetPossibleExtraService(GetPossibleExtraService *GetPossibleExtraService) (*GetPossibleExtraServiceResponse, error) {
- α := struct {
- OperationGetPossibleExtraService `xml:"tns:getPossibleExtraService"`
- }{
- OperationGetPossibleExtraService{
- GetPossibleExtraService,
- },
- }
-
- γ := struct {
- OperationGetPossibleExtraServiceResponse `xml:"getPossibleExtraServiceResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetPossibleExtraService", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetPossibleExtraServiceResponse, nil
-}
-
-func (p *dPDGeography2) GetStoragePeriod(GetStoragePeriod *GetStoragePeriod) (*GetStoragePeriodResponse, error) {
- α := struct {
- OperationGetStoragePeriod `xml:"tns:getStoragePeriod"`
- }{
- OperationGetStoragePeriod{
- GetStoragePeriod,
- },
- }
-
- γ := struct {
- OperationGetStoragePeriodResponse `xml:"getStoragePeriodResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetStoragePeriod", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetStoragePeriodResponse, nil
-}
-
-func (p *dPDGeography2) GetTerminalsSelfDelivery2(GetTerminalsSelfDelivery2 *GetTerminalsSelfDelivery2) (*GetTerminalsSelfDelivery2Response, error) {
- α := struct {
- OperationGetTerminalsSelfDelivery2 `xml:"tns:getTerminalsSelfDelivery2"`
- }{
- OperationGetTerminalsSelfDelivery2{
- GetTerminalsSelfDelivery2,
- },
- }
-
- γ := struct {
- OperationGetTerminalsSelfDelivery2Response `xml:"getTerminalsSelfDelivery2Response"`
- }{}
- if err := p.cli.RoundTripWithAction("GetTerminalsSelfDelivery2", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetTerminalsSelfDelivery2Response, nil
-}
-
-type GeographyAddress struct {
- CityId *int64 `xml:"cityId,omitempty"`
- CountryCode *string `xml:"countryCode,omitempty"`
- RegionCode *string `xml:"regionCode,omitempty"`
- RegionName *string `xml:"regionName,omitempty"`
- CityCode *string `xml:"cityCode,omitempty"`
- CityName *string `xml:"cityName,omitempty"`
- Index *string `xml:"index,omitempty"`
- Street *string `xml:"street,omitempty"`
- StreetAbbr *string `xml:"streetAbbr,omitempty"`
- HouseNo *string `xml:"houseNo,omitempty"`
- Building *string `xml:"building,omitempty"`
- Structure *string `xml:"structure,omitempty"`
- Ownership *string `xml:"ownership,omitempty"`
- Descript *string `xml:"descript,omitempty"`
-}
-
-type City struct {
- CityId *int64 `xml:"cityId,omitempty"`
- CountryCode *string `xml:"countryCode,omitempty"`
- CountryName *string `xml:"countryName,omitempty"`
- RegionCode *int `xml:"regionCode,omitempty"`
- RegionName *string `xml:"regionName,omitempty"`
- CityCode *string `xml:"cityCode,omitempty"`
- CityName *string `xml:"cityName,omitempty"`
- Abbreviation *string `xml:"abbreviation,omitempty"`
- IndexMin *string `xml:"indexMin,omitempty"`
- IndexMax *string `xml:"indexMax,omitempty"`
-}
-
-type DpdCitiesCashPayRequest struct {
- NS string `xml:"xmlns,attr"`
- Auth *Auth `xml:"auth,omitempty"`
- CountryCode *string `xml:"countryCode,omitempty"`
-}
-
-type DpdParcelShopRequest struct {
- Ns string `xml:"xmlns,attr"`
- Auth *Auth `xml:"auth,omitempty"`
- CountryCode *string `xml:"countryCode,omitempty"`
- RegionCode *string `xml:"regionCode,omitempty"`
- CityCode *string `xml:"cityCode,omitempty"`
- CityName *string `xml:"cityName,omitempty"`
-}
-
-type DpdParcelShops struct {
- ParcelShop []*ParcelShop `xml:"parcelShop,omitempty"`
-}
-
-type DpdPossibleESOption struct {
- Option []*string `xml:"option,omitempty"`
-}
-
-type DpdPossibleESPickupDelivery struct {
- CityId *float64 `xml:"cityId,omitempty"`
- TerminalCode *string `xml:"terminalCode,omitempty"`
- Index *float64 `xml:"index,omitempty"`
- CityName *string `xml:"cityName,omitempty"`
- RegionCode *string `xml:"regionCode,omitempty"`
- CountryCode *string `xml:"countryCode,omitempty"`
-}
-
-type DpdPossibleESRequest struct {
- Auth *Auth `xml:"auth,omitempty"`
- Pickup *DpdPossibleESPickupDelivery `xml:"pickup,omitempty"`
- Delivery *DpdPossibleESPickupDelivery `xml:"delivery,omitempty"`
- SelfPickup *bool `xml:"SelfPickup,omitempty"`
- SelfDelivery *bool `xml:"SelfDelivery,omitempty"`
- ServiceCode *string `xml:"serviceCode,omitempty"`
- PickupDate *Date `xml:"pickupDate,omitempty"`
- Options *DpdPossibleESOption `xml:"options,omitempty"`
-}
-
-type DpdPossibleESResult struct {
- ResultCode *string `xml:"resultCode,omitempty"`
- ResultMessage *string `xml:"resultMessage,omitempty"`
- ExtraService []*PossibleExtraService `xml:"extraService,omitempty"`
-}
-
-type DpdTerminals struct {
- Terminal []*TerminalStoragePeriods `xml:"terminal,omitempty"`
-}
-
-type ExtraService struct {
- EsCode *string `xml:"esCode,omitempty"`
- Params []*ExtraServiceParam `xml:"params,omitempty"`
-}
-
-type ExtraServiceParam struct {
- Name *string `xml:"name,omitempty"`
- Value *string `xml:"value,omitempty"`
-}
-
-type GeoCoordinates struct {
- Latitude *float64 `xml:"latitude,omitempty"`
- Longitude *float64 `xml:"longitude,omitempty"`
-}
-
-type GetCitiesCashPay struct {
- NS string `xml:"xmlns,attr"`
- Request *DpdCitiesCashPayRequest `xml:"request,omitempty"`
-}
-
-type GetCitiesCashPayResponse struct {
- Return []*City `xml:"return,omitempty"`
-}
-
-type GetParcelShops struct {
- Request *DpdParcelShopRequest `xml:"request,omitempty"`
- Ns string `xml:"xmlns,attr"`
-}
-
-type GetParcelShopsResponse struct {
- Return *DpdParcelShops `xml:"return,omitempty"`
-}
-
-type GetPossibleExtraService struct {
- Request *DpdPossibleESRequest `xml:"request,omitempty"`
-}
-
-type GetPossibleExtraServiceResponse struct {
- Return *DpdPossibleESResult `xml:"return,omitempty"`
-}
-
-type GetStoragePeriod struct {
- Request *StoragePeriodRequest `xml:"request,omitempty"`
-}
-
-type GetStoragePeriodResponse struct {
- Return *DpdTerminals `xml:"return,omitempty"`
-}
-
-type GetTerminalsSelfDelivery2 struct {
- Ns string `xml:"xmlns,attr"`
- Auth *Auth `xml:"auth,omitempty"`
-}
-
-type GetTerminalsSelfDelivery2Response struct {
- Return *SelfTerminals `xml:"return,omitempty"`
-}
-
-type Limits struct {
- MaxShipmentWeight *float64 `xml:"maxShipmentWeight,omitempty"`
- MaxWeight *float64 `xml:"maxWeight,omitempty"`
- MaxLength *float64 `xml:"maxLength,omitempty"`
- MaxWidth *float64 `xml:"maxWidth,omitempty"`
- MaxHeight *float64 `xml:"maxHeight,omitempty"`
- DimensionSum *float64 `xml:"dimensionSum,omitempty"`
-}
-
-type ParcelShop struct {
- Code *string `xml:"code,omitempty"`
- ParcelShopType *string `xml:"parcelShopType,omitempty"`
- State *string `xml:"state,omitempty"`
- Address *GeographyAddress `xml:"address,omitempty"`
- Brand *string `xml:"brand,omitempty"`
- ClientDepartmentNum *string `xml:"clientDepartmentNum,omitempty"`
- GeoCoordinates *GeoCoordinates `xml:"geoCoordinates,omitempty"`
- Limits *Limits `xml:"limits,omitempty"`
- Schedule []*Schedule `xml:"schedule,omitempty"`
- ExtraService []*ExtraService `xml:"extraService,omitempty"`
- Services []*string `xml:"services>serviceCode,omitempty"`
-}
-
-type PossibleExtraService struct {
- Code *string `xml:"code,omitempty"`
- Name *string `xml:"name,omitempty"`
- IsPaid *bool `xml:"isPaid,omitempty"`
-}
-
-type Schedule struct {
- Operation *string `xml:"operation,omitempty"`
- Timetable []*Timetable `xml:"timetable,omitempty"`
-}
-
-type SelfTerminals struct {
- Terminal []*TerminalSelf `xml:"terminal,omitempty"`
-}
-
-type StoragePeriod struct {
- ServiceCode *string `xml:"serviceCode,omitempty"`
- Days *int `xml:"days,omitempty"`
-}
-
-type StoragePeriodRequest struct {
- Auth *Auth `xml:"auth,omitempty"`
- TerminalCode *string `xml:"terminalCode,omitempty"`
- ServiceCode *string `xml:"serviceCode,omitempty"`
-}
-
-type TerminalSelf struct {
- TerminalCode *string `xml:"terminalCode,omitempty"`
- TerminalName *string `xml:"terminalName,omitempty"`
- Address *GeographyAddress `xml:"address,omitempty"`
- GeoCoordinates *GeoCoordinates `xml:"geoCoordinates,omitempty"`
- Schedule []*Schedule `xml:"schedule,omitempty"`
- ExtraService []*ExtraService `xml:"extraService,omitempty"`
- Services []*string `xml:"services>serviceCode,omitempty"`
-}
-
-type TerminalStoragePeriods struct {
- TerminalCode *string `xml:"terminalCode,omitempty"`
- Services []*StoragePeriod `xml:"services,omitempty"`
-}
-
-type Timetable struct {
- WeekDays *string `xml:"weekDays,omitempty"`
- WorkTime *string `xml:"workTime,omitempty"`
-}
-
-type OperationGetCitiesCashPay struct {
- GetCitiesCashPay *GetCitiesCashPay `xml:"getCitiesCashPay,omitempty"`
-}
-
-type OperationGetCitiesCashPayResponse struct {
- GetCitiesCashPayResponse *GetCitiesCashPayResponse `xml:"getCitiesCashPayResponse,omitempty"`
-}
-
-type OperationGetParcelShops struct {
- GetParcelShops *GetParcelShops `xml:"getParcelShops,omitempty"`
-}
-
-type OperationGetParcelShopsResponse struct {
- GetParcelShopsResponse *GetParcelShopsResponse `xml:"getParcelShopsResponse,omitempty"`
-}
-
-type OperationGetPossibleExtraService struct {
- GetPossibleExtraService *GetPossibleExtraService `xml:"getPossibleExtraService,omitempty"`
-}
-
-type OperationGetPossibleExtraServiceResponse struct {
- GetPossibleExtraServiceResponse *GetPossibleExtraServiceResponse `xml:"getPossibleExtraServiceResponse,omitempty"`
-}
-
-type OperationGetStoragePeriod struct {
- GetStoragePeriod *GetStoragePeriod `xml:"getStoragePeriod,omitempty"`
-}
-
-type OperationGetStoragePeriodResponse struct {
- GetStoragePeriodResponse *GetStoragePeriodResponse `xml:"getStoragePeriodResponse,omitempty"`
-}
-
-type OperationGetTerminalsSelfDelivery2 struct {
- GetTerminalsSelfDelivery2 *GetTerminalsSelfDelivery2 `xml:"getTerminalsSelfDelivery2,omitempty"`
-}
-
-type OperationGetTerminalsSelfDelivery2Response struct {
- GetTerminalsSelfDelivery2Response *GetTerminalsSelfDelivery2Response `xml:"getTerminalsSelfDelivery2Response,omitempty"`
-}
-
-type dPDGeography2 struct {
- cli *soap.Client
-}
diff --git a/soap/order.go b/soap/order.go
deleted file mode 100644
index 173c49a..0000000
--- a/soap/order.go
+++ /dev/null
@@ -1,892 +0,0 @@
-package soap
-
-import "github.com/fiorix/wsdl2go/soap"
-
-const OrderNamespace = "http://dpd.ru/ws/order2/2012-04-04"
-
-func NewDPDOrder(cli *soap.Client) DPDOrder {
- return &dPDOrder{cli}
-}
-
-type DPDOrder interface {
- AddAirwayBill(AddAirwayBill *AddAirwayBill) (*AddAirwayBillResponse, error)
- AddParcels(AddParcels *AddParcels) (*AddParcelsResponse, error)
- CancelOrder(CancelOrder *CancelOrder) (*CancelOrderResponse, error)
- ChangeDeliveryDate(ChangeDeliveryDate *ChangeDeliveryDate) (*ChangeDeliveryDateResponse, error)
- ChangeUnitLoad(ChangeUnitLoad *ChangeUnitLoad) (*ChangeUnitLoadResponse, error)
- CreateAddress(CreateAddress *CreateAddress) (*CreateAddressResponse, error)
- CreateOrder(CreateOrder *CreateOrder) (*CreateOrderResponse, error)
- CreateOrderAsync(CreateOrderAsync *CreateOrderAsync) (*CreateOrderAsyncResponse, error)
- CreateOrderResult(CreateOrderResult *CreateOrderResult) (*CreateOrderResultResponse, error)
- GetInvoiceFile(GetInvoiceFile *GetInvoiceFile) (*GetInvoiceFileResponse, error)
- GetOrderSMS(GetOrderSMS *GetOrderSMS) (*GetOrderSMSResponse, error)
- GetOrderStatus(GetOrderStatus *GetOrderStatus) (*GetOrderStatusResponse, error)
- GetRegisterFile(GetRegisterFile *GetRegisterFile) (*GetRegisterFileResponse, error)
- OrderReDirect(OrderReDirect *OrderReDirect) (*OrderReDirectResponse, error)
- RemoveParcels(RemoveParcels *RemoveParcels) (*RemoveParcelsResponse, error)
- UpdateAddress(UpdateAddress *UpdateAddress) (*UpdateAddressResponse, error)
-}
-
-func (p *dPDOrder) AddAirwayBill(AddAirwayBill *AddAirwayBill) (*AddAirwayBillResponse, error) {
- α := struct {
- OperationAddAirwayBill `xml:"tns:addAirwayBill"`
- }{
- OperationAddAirwayBill{
- AddAirwayBill,
- },
- }
-
- γ := struct {
- OperationAddAirwayBillResponse `xml:"addAirwayBillResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("AddAirwayBill", α, &γ); err != nil {
- return nil, err
- }
- return γ.AddAirwayBillResponse, nil
-}
-
-func (p *dPDOrder) AddParcels(AddParcels *AddParcels) (*AddParcelsResponse, error) {
- α := struct {
- OperationAddParcels `xml:"tns:addParcels"`
- }{
- OperationAddParcels{
- AddParcels,
- },
- }
-
- γ := struct {
- OperationAddParcelsResponse `xml:"addParcelsResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("AddParcels", α, &γ); err != nil {
- return nil, err
- }
- return γ.AddParcelsResponse, nil
-}
-
-func (p *dPDOrder) CancelOrder(CancelOrder *CancelOrder) (*CancelOrderResponse, error) {
- α := struct {
- OperationCancelOrder `xml:"tns:cancelOrder"`
- }{
- OperationCancelOrder{
- CancelOrder,
- },
- }
-
- γ := struct {
- OperationCancelOrderResponse `xml:"cancelOrderResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("CancelOrder", α, &γ); err != nil {
- return nil, err
- }
- return γ.CancelOrderResponse, nil
-}
-
-func (p *dPDOrder) ChangeDeliveryDate(ChangeDeliveryDate *ChangeDeliveryDate) (*ChangeDeliveryDateResponse, error) {
- α := struct {
- OperationChangeDeliveryDate `xml:"tns:changeDeliveryDate"`
- }{
- OperationChangeDeliveryDate{
- ChangeDeliveryDate,
- },
- }
-
- γ := struct {
- OperationChangeDeliveryDateResponse `xml:"changeDeliveryDateResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("ChangeDeliveryDate", α, &γ); err != nil {
- return nil, err
- }
- return γ.ChangeDeliveryDateResponse, nil
-}
-
-func (p *dPDOrder) ChangeUnitLoad(ChangeUnitLoad *ChangeUnitLoad) (*ChangeUnitLoadResponse, error) {
- α := struct {
- OperationChangeUnitLoad `xml:"tns:changeUnitLoad"`
- }{
- OperationChangeUnitLoad{
- ChangeUnitLoad,
- },
- }
-
- γ := struct {
- OperationChangeUnitLoadResponse `xml:"changeUnitLoadResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("ChangeUnitLoad", α, &γ); err != nil {
- return nil, err
- }
- return γ.ChangeUnitLoadResponse, nil
-}
-
-func (p *dPDOrder) CreateAddress(CreateAddress *CreateAddress) (*CreateAddressResponse, error) {
- α := struct {
- OperationCreateAddress `xml:"tns:createAddress"`
- }{
- OperationCreateAddress{
- CreateAddress,
- },
- }
-
- γ := struct {
- OperationCreateAddressResponse `xml:"createAddressResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("CreateAddress", α, &γ); err != nil {
- return nil, err
- }
- return γ.CreateAddressResponse, nil
-}
-
-func (p *dPDOrder) CreateOrder(CreateOrder *CreateOrder) (*CreateOrderResponse, error) {
- α := struct {
- OperationCreateOrder `xml:"tns:createOrder"`
- }{
- OperationCreateOrder{
- CreateOrder,
- },
- }
-
- γ := struct {
- OperationCreateOrderResponse `xml:"createOrderResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("CreateOrder", α, &γ); err != nil {
- return nil, err
- }
- return γ.CreateOrderResponse, nil
-}
-
-func (p *dPDOrder) CreateOrderAsync(CreateOrderAsync *CreateOrderAsync) (*CreateOrderAsyncResponse, error) {
- α := struct {
- OperationCreateOrderAsync `xml:"tns:createOrderAsync"`
- }{
- OperationCreateOrderAsync{
- CreateOrderAsync,
- },
- }
-
- γ := struct {
- OperationCreateOrderAsyncResponse `xml:"createOrderAsyncResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("CreateOrderAsync", α, &γ); err != nil {
- return nil, err
- }
- return γ.CreateOrderAsyncResponse, nil
-}
-
-func (p *dPDOrder) CreateOrderResult(CreateOrderResult *CreateOrderResult) (*CreateOrderResultResponse, error) {
- α := struct {
- OperationCreateOrderResult `xml:"tns:createOrderResult"`
- }{
- OperationCreateOrderResult{
- CreateOrderResult,
- },
- }
-
- γ := struct {
- OperationCreateOrderResultResponse `xml:"createOrderResultResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("CreateOrderResult", α, &γ); err != nil {
- return nil, err
- }
- return γ.CreateOrderResultResponse, nil
-}
-
-func (p *dPDOrder) GetInvoiceFile(GetInvoiceFile *GetInvoiceFile) (*GetInvoiceFileResponse, error) {
- α := struct {
- OperationGetInvoiceFile `xml:"tns:getInvoiceFile"`
- }{
- OperationGetInvoiceFile{
- GetInvoiceFile,
- },
- }
-
- γ := struct {
- OperationGetInvoiceFileResponse `xml:"getInvoiceFileResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetInvoiceFile", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetInvoiceFileResponse, nil
-}
-
-func (p *dPDOrder) GetOrderSMS(GetOrderSMS *GetOrderSMS) (*GetOrderSMSResponse, error) {
- α := struct {
- OperationGetOrderSMS `xml:"tns:getOrderSMS"`
- }{
- OperationGetOrderSMS{
- GetOrderSMS,
- },
- }
-
- γ := struct {
- OperationGetOrderSMSResponse `xml:"getOrderSMSResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetOrderSMS", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetOrderSMSResponse, nil
-}
-
-func (p *dPDOrder) GetOrderStatus(GetOrderStatus *GetOrderStatus) (*GetOrderStatusResponse, error) {
- α := struct {
- OperationGetOrderStatus `xml:"tns:getOrderStatus"`
- }{
- OperationGetOrderStatus{
- GetOrderStatus,
- },
- }
-
- γ := struct {
- OperationGetOrderStatusResponse `xml:"getOrderStatusResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetOrderStatus", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetOrderStatusResponse, nil
-}
-
-func (p *dPDOrder) GetRegisterFile(GetRegisterFile *GetRegisterFile) (*GetRegisterFileResponse, error) {
- α := struct {
- OperationGetRegisterFile `xml:"tns:getRegisterFile"`
- }{
- OperationGetRegisterFile{
- GetRegisterFile,
- },
- }
-
- γ := struct {
- OperationGetRegisterFileResponse `xml:"getRegisterFileResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetRegisterFile", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetRegisterFileResponse, nil
-}
-
-func (p *dPDOrder) OrderReDirect(OrderReDirect *OrderReDirect) (*OrderReDirectResponse, error) {
- α := struct {
- OperationOrderReDirect `xml:"tns:orderReDirect"`
- }{
- OperationOrderReDirect{
- OrderReDirect,
- },
- }
-
- γ := struct {
- OperationOrderReDirectResponse `xml:"orderReDirectResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("OrderReDirect", α, &γ); err != nil {
- return nil, err
- }
- return γ.OrderReDirectResponse, nil
-}
-
-func (p *dPDOrder) RemoveParcels(RemoveParcels *RemoveParcels) (*RemoveParcelsResponse, error) {
- α := struct {
- OperationRemoveParcels `xml:"tns:removeParcels"`
- }{
- OperationRemoveParcels{
- RemoveParcels,
- },
- }
-
- γ := struct {
- OperationRemoveParcelsResponse `xml:"removeParcelsResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("RemoveParcels", α, &γ); err != nil {
- return nil, err
- }
- return γ.RemoveParcelsResponse, nil
-}
-
-func (p *dPDOrder) UpdateAddress(UpdateAddress *UpdateAddress) (*UpdateAddressResponse, error) {
- α := struct {
- OperationUpdateAddress `xml:"tns:updateAddress"`
- }{
- OperationUpdateAddress{
- UpdateAddress,
- },
- }
-
- γ := struct {
- OperationUpdateAddressResponse `xml:"updateAddressResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("UpdateAddress", α, &γ); err != nil {
- return nil, err
- }
- return γ.UpdateAddressResponse, nil
-}
-
-type AddAirwayBill struct {
- Request *DpdAirwayBillInput `xml:"request,omitempty"`
-}
-
-type AddAirwayBillResponse struct {
- Return *DpdAirwayBillOutput `xml:"return,omitempty"`
-}
-
-type AddParcels struct {
- Parcels *DpdOrderCorrection `xml:"parcels,omitempty"`
-}
-
-type AddParcelsResponse struct {
- Return *DpdOrderCorrectionStatus `xml:"return,omitempty"`
-}
-
-type Address struct {
- Code *string `xml:"code,omitempty"`
- Name *string `xml:"name,omitempty"`
- TerminalCode *string `xml:"terminalCode,omitempty"`
- AddressString *string `xml:"addressString,omitempty"`
- CountryName *string `xml:"countryName,omitempty"`
- Index *string `xml:"index,omitempty"`
- Region *string `xml:"region,omitempty"`
- City *string `xml:"city,omitempty"`
- Street *string `xml:"street,omitempty"`
- StreetAbbr *string `xml:"streetAbbr,omitempty"`
- House *string `xml:"house,omitempty"`
- HouseKorpus *string `xml:"houseKorpus,omitempty"`
- Str *string `xml:"str,omitempty"`
- Vlad *string `xml:"vlad,omitempty"`
- ExtraInfo *string `xml:"extraInfo,omitempty"`
- Office *string `xml:"office,omitempty"`
- Flat *string `xml:"flat,omitempty"`
- WorkTimeFrom *string `xml:"workTimeFrom,omitempty"`
- WorkTimeTo *string `xml:"workTimeTo,omitempty"`
- DinnerTimeFrom *string `xml:"dinnerTimeFrom,omitempty"`
- DinnerTimeTo *string `xml:"dinnerTimeTo,omitempty"`
- ContactFio *string `xml:"contactFio,omitempty"`
- ContactPhone *string `xml:"contactPhone,omitempty"`
- ContactEmail *string `xml:"contactEmail,omitempty"`
- Instructions *string `xml:"instructions,omitempty"`
- NeedPass *bool `xml:"needPass,omitempty"`
-}
-
-type AsyncRequest struct {
- Auth *Auth `xml:"auth,omitempty"`
- TaskId *int64 `xml:"taskId,omitempty"`
-}
-
-type AsyncResponse struct {
- TaskId *int64 `xml:"taskId,omitempty"`
- TaskDate *DateTime `xml:"taskDate,omitempty"`
-}
-
-type CancelOrder struct {
- Orders *DpdOrderCancellation `xml:"orders,omitempty"`
-}
-
-type CancelOrderResponse struct {
- Return []*DpdOrderStatus `xml:"return,omitempty"`
-}
-
-type ChangeDeliveryDate struct {
- Request *DpdChangeDeliveryDate `xml:"request,omitempty"`
-}
-
-type ChangeDeliveryDateResponse struct {
- Return []*DpdOrderStatus `xml:"return,omitempty"`
-}
-
-type ChangeUnitLoad struct {
- Request *DpdUnitLoadChange `xml:"request,omitempty"`
-}
-
-type ChangeUnitLoadResponse struct {
- Return []*DpdOrderStatus `xml:"return,omitempty"`
-}
-
-type ClientAddress struct {
- Code *string `xml:"code,omitempty"`
- Name *string `xml:"name,omitempty"`
- AddressString *string `xml:"addressString,omitempty"`
- CountryName *string `xml:"countryName,omitempty"`
- Index *string `xml:"index,omitempty"`
- Region *string `xml:"region,omitempty"`
- City *string `xml:"city,omitempty"`
- Street *string `xml:"street,omitempty"`
- StreetAbbr *string `xml:"streetAbbr,omitempty"`
- House *string `xml:"house,omitempty"`
- HouseKorpus *string `xml:"houseKorpus,omitempty"`
- Str *string `xml:"str,omitempty"`
- Vlad *string `xml:"vlad,omitempty"`
- ExtraInfo *string `xml:"extraInfo,omitempty"`
- Office *string `xml:"office,omitempty"`
- Flat *string `xml:"flat,omitempty"`
- WorkTimeFrom *string `xml:"workTimeFrom,omitempty"`
- WorkTimeTo *string `xml:"workTimeTo,omitempty"`
- DinnerTimeFrom *string `xml:"dinnerTimeFrom,omitempty"`
- DinnerTimeTo *string `xml:"dinnerTimeTo,omitempty"`
- ContactFio *string `xml:"contactFio,omitempty"`
- ContactPhone *string `xml:"contactPhone,omitempty"`
- ContactEmail *string `xml:"contactEmail,omitempty"`
- Instructions *string `xml:"instructions,omitempty"`
- NeedPass *bool `xml:"needPass,omitempty"`
-}
-
-type CreateAddress struct {
- Address *DpdClientAddress `xml:"address,omitempty"`
-}
-
-type CreateAddressResponse struct {
- Return *DpdClientAddressStatus `xml:"return,omitempty"`
-}
-
-type CreateOrder struct {
- Orders *DpdOrdersData `xml:"orders,omitempty"`
-}
-
-type CreateOrderAsync struct {
- Orders *DpdOrdersData `xml:"orders,omitempty"`
-}
-
-type CreateOrderAsyncResponse struct {
- Return *AsyncResponse `xml:"return,omitempty"`
-}
-
-type CreateOrderResponse struct {
- Return []*DpdOrderStatus `xml:"return,omitempty"`
-}
-
-type CreateOrderResult struct {
- Orders *AsyncRequest `xml:"orders,omitempty"`
-}
-
-type CreateOrderResultResponse struct {
- Return []*DpdOrderStatus `xml:"return,omitempty"`
-}
-
-type DataInternational struct {
- Currency *string `xml:"currency,omitempty"`
- CurrencyDeclaredValue *string `xml:"currencyDeclaredValue,omitempty"`
-}
-
-type DpdAirwayBillInput struct {
- Auth *Auth `xml:"auth,omitempty"`
- Order []*OrderAirbillInput `xml:"order,omitempty"`
-}
-
-type DpdAirwayBillOutput struct {
- Order []*OrderAirbillOutput `xml:"order,omitempty"`
-}
-
-type DpdChangeDeliveryDate struct {
- Auth *Auth `xml:"auth,omitempty"`
- Order []*OrderDeliveryDate `xml:"order,omitempty"`
-}
-
-type DpdClientAddress struct {
- Auth *Auth `xml:"auth,omitempty"`
- ClientAddress *ClientAddress `xml:"clientAddress,omitempty"`
-}
-
-type DpdClientAddressStatus struct {
- Code *string `xml:"code,omitempty"`
- Status *string `xml:"status,omitempty"`
- ErrorMessage *string `xml:"errorMessage,omitempty"`
-}
-
-type DpdGetInvoiceFile struct {
- Auth *Auth `xml:"auth,omitempty"`
- OrderNum *string `xml:"orderNum,omitempty"`
- ParcelCount *int `xml:"parcelCount,omitempty"`
- CargoValue *float64 `xml:"cargoValue,omitempty"`
-}
-
-type DpdGetOrderStatus struct {
- Auth *Auth `xml:"auth,omitempty"`
- Order []*InternalOrderNumber `xml:"order,omitempty"`
-}
-
-type DpdGetRegisterFile struct {
- Auth *Auth `xml:"auth,omitempty"`
- DatePickup *Date `xml:"datePickup,omitempty"`
- RegularNum *string `xml:"regularNum,omitempty"`
- CityPickupId *int64 `xml:"cityPickupId,omitempty"`
- AddressCode *string `xml:"addressCode,omitempty"`
-}
-
-type DpdInvoiceFile struct {
- File *[]byte `xml:"file,omitempty"`
-}
-
-type DpdOrderCancellation struct {
- Auth *Auth `xml:"auth,omitempty"`
- Cancel []*OrderCancel `xml:"cancel,omitempty"`
-}
-
-type DpdOrderCorrection struct {
- Auth *Auth `xml:"auth,omitempty"`
- OrderNum *string `xml:"orderNum,omitempty"`
- OrderNumberInternal *string `xml:"orderNumberInternal,omitempty"`
- CargoNumPack *int `xml:"cargoNumPack,omitempty"`
- CargoWeight *float64 `xml:"cargoWeight,omitempty"`
- CargoVolume *float64 `xml:"cargoVolume,omitempty"`
- CargoValue *float64 `xml:"cargoValue,omitempty"`
- CargoCategory *string `xml:"cargoCategory,omitempty"`
- Parcel []*Parcel `xml:"parcel,omitempty"`
-}
-
-type DpdOrderCorrectionStatus struct {
- OrderNum *string `xml:"orderNum,omitempty"`
- Status *string `xml:"status,omitempty"`
- ErrorMessage *string `xml:"errorMessage,omitempty"`
- ParcelStatus []*ParcelStatus `xml:"parcelStatus,omitempty"`
-}
-
-type DpdOrderResult struct {
- OrderNum *string `xml:"orderNum,omitempty"`
- StatusCode *string `xml:"statusCode,omitempty"`
-}
-
-type DpdOrderSmsRequest struct {
- Auth *Auth `xml:"auth,omitempty"`
- Order []*OrderNum `xml:"order,omitempty"`
-}
-
-type DpdOrderSmsResult struct {
- Order []*DpdOrderSmsStatus `xml:"order,omitempty"`
-}
-
-type DpdOrderSmsStatus struct {
- OrderNum *string `xml:"orderNum,omitempty"`
- Status *string `xml:"status,omitempty"`
- ErrorMessage *string `xml:"errorMessage,omitempty"`
-}
-
-type DpdOrderStatus struct {
- OrderNumberInternal *string `xml:"orderNumberInternal,omitempty"`
- OrderNum *string `xml:"orderNum,omitempty"`
- Status *string `xml:"status,omitempty"`
- ErrorMessage *string `xml:"errorMessage,omitempty"`
-}
-
-type DpdOrdersData struct {
- Auth *Auth `xml:"auth,omitempty"`
- Header *Header `xml:"header,omitempty"`
- Order []*Order `xml:"order,omitempty"`
-}
-
-type DpdOrdersReDirect struct {
- Auth *Auth `xml:"auth,omitempty"`
- Order []*ReDirectOrder `xml:"order,omitempty"`
-}
-
-type DpdRegisterFile struct {
- File []*[]byte `xml:"file,omitempty"`
-}
-
-type DpdUnitLoadChange struct {
- Auth *Auth `xml:"auth,omitempty"`
- Order []*OrderUnitLoad `xml:"order,omitempty"`
-}
-
-type OrderExtraService struct {
- EsCode *string `xml:"esCode,omitempty"`
- Param []*Parameter `xml:"param,omitempty"`
-}
-
-type GetInvoiceFile struct {
- Request *DpdGetInvoiceFile `xml:"request,omitempty"`
-}
-
-type GetInvoiceFileResponse struct {
- Return *DpdInvoiceFile `xml:"return,omitempty"`
-}
-
-type GetOrderSMS struct {
- Request *DpdOrderSmsRequest `xml:"request,omitempty"`
-}
-
-type GetOrderSMSResponse struct {
- Return *DpdOrderSmsResult `xml:"return,omitempty"`
-}
-
-type GetOrderStatus struct {
- OrderStatus *DpdGetOrderStatus `xml:"orderStatus,omitempty"`
-}
-
-type GetOrderStatusResponse struct {
- Return []*DpdOrderStatus `xml:"return,omitempty"`
-}
-
-type GetRegisterFile struct {
- Request *DpdGetRegisterFile `xml:"request,omitempty"`
-}
-
-type GetRegisterFileResponse struct {
- Return *DpdRegisterFile `xml:"return,omitempty"`
-}
-
-type Header struct {
- DatePickup *Date `xml:"datePickup,omitempty"`
- Payer *int64 `xml:"payer,omitempty"`
- SenderAddress *Address `xml:"senderAddress,omitempty"`
- PickupTimePeriod *string `xml:"pickupTimePeriod,omitempty"`
- RegularNum *string `xml:"regularNum,omitempty"`
-}
-
-type InternalOrderNumber struct {
- OrderNumberInternal *string `xml:"orderNumberInternal,omitempty"`
- DatePickup *Date `xml:"datePickup,omitempty"`
-}
-
-type Order struct {
- OrderNumberInternal *string `xml:"orderNumberInternal,omitempty"`
- ServiceCode *string `xml:"serviceCode,omitempty"`
- ServiceVariant *string `xml:"serviceVariant,omitempty"`
- CargoNumPack *int `xml:"cargoNumPack,omitempty"`
- CargoWeight *float64 `xml:"cargoWeight,omitempty"`
- CargoVolume *float64 `xml:"cargoVolume,omitempty"`
- CargoRegistered *bool `xml:"cargoRegistered,omitempty"`
- CargoValue *float64 `xml:"cargoValue,omitempty"`
- CargoCategory *string `xml:"cargoCategory,omitempty"`
- DeliveryTimePeriod *string `xml:"deliveryTimePeriod,omitempty"`
- PaymentType *string `xml:"paymentType,omitempty"`
- ExtraParam []*Parameter `xml:"extraParam,omitempty"`
- DataInt *DataInternational `xml:"dataInt,omitempty"`
- ReceiverAddress *Address `xml:"receiverAddress,omitempty"`
- ReturnAddress *Address `xml:"returnAddress,omitempty"`
- ExtraService []*OrderExtraService `xml:"extraService,omitempty"`
- Parcel []*Parcel `xml:"parcel,omitempty"`
- UnitLoad []*UnitLoad `xml:"unitLoad,omitempty"`
-}
-
-type OrderAirbillInput struct {
- OrderNumberDPD *string `xml:"orderNumberDPD,omitempty"`
- OrderNumberInternal *string `xml:"orderNumberInternal,omitempty"`
- Param []*ParamAirbill `xml:"param,omitempty"`
-}
-
-type OrderAirbillOutput struct {
- OrderNumberDPD *string `xml:"orderNumberDPD,omitempty"`
- Result *string `xml:"result,omitempty"`
- ErrorCode *string `xml:"errorCode,omitempty"`
- ErrorMessage *string `xml:"errorMessage,omitempty"`
-}
-
-type OrderCancel struct {
- OrderNumberInternal *string `xml:"orderNumberInternal,omitempty"`
- OrderNum *string `xml:"orderNum,omitempty"`
- Pickupdate *Date `xml:"pickupdate,omitempty"`
-}
-
-type OrderDeliveryDate struct {
- OrderNum *string `xml:"orderNum,omitempty"`
- NewDeliveryDate *Date `xml:"newDeliveryDate,omitempty"`
-}
-
-type OrderNum struct {
- OrderNum *string `xml:"orderNum,omitempty"`
-}
-
-type OrderReDirect struct {
- Orders *DpdOrdersReDirect `xml:"orders,omitempty"`
-}
-
-type OrderReDirectResponse struct {
- Return []*DpdOrderResult `xml:"return,omitempty"`
-}
-
-type OrderUnitLoad struct {
- OrderNum *string `xml:"orderNum,omitempty"`
- DatePickup *Date `xml:"datePickup,omitempty"`
- DeliveryAmount *float64 `xml:"deliveryAmount,omitempty"`
- GoodsReturnAmount *float64 `xml:"goodsReturnAmount,omitempty"`
- UnitLoad []*UnitLoad `xml:"unitLoad,omitempty"`
-}
-
-type ParamAirbill struct {
- ParamName *string `xml:"paramName,omitempty"`
- ParamValue *string `xml:"paramValue,omitempty"`
-}
-
-type Parameter struct {
- Name *string `xml:"name,omitempty"`
- Value *string `xml:"value,omitempty"`
-}
-
-type Parcel struct {
- Number *string `xml:"number,omitempty"`
- DpdParcelNumber *int64 `xml:"dpdParcelNumber,omitempty"`
- NumberForPrint *string `xml:"number_for_print,omitempty"`
- BoxNeeded *int `xml:"box_needed,omitempty"`
- Weight *float64 `xml:"weight,omitempty"`
- Length *float64 `xml:"length,omitempty"`
- Width *float64 `xml:"width,omitempty"`
- Height *float64 `xml:"height,omitempty"`
- InsuranceCost *float64 `xml:"insuranceCost,omitempty"`
- InsuranceCostVat *float64 `xml:"insuranceCostVat,omitempty"`
- CodAmount *float64 `xml:"codAmount,omitempty"`
-}
-
-type ParcelStatus struct {
- Number *string `xml:"number,omitempty"`
- Status *string `xml:"status,omitempty"`
- ErrorMessage *string `xml:"errorMessage,omitempty"`
-}
-
-type ReDirectOrder struct {
- OrderNum *string `xml:"orderNum,omitempty"`
- DatePickup *Date `xml:"datePickup,omitempty"`
- ReDirectionType *string `xml:"reDirectionType,omitempty"`
- PointCode *string `xml:"pointCode,omitempty"`
-}
-
-type RemoveParcels struct {
- Parcels *DpdOrderCorrection `xml:"parcels,omitempty"`
-}
-
-type RemoveParcelsResponse struct {
- Return *DpdOrderCorrectionStatus `xml:"return,omitempty"`
-}
-
-type UnitLoad struct {
- Article *string `xml:"article,omitempty"`
- Descript *string `xml:"descript,omitempty"`
- ClientCode *string `xml:"client_code,omitempty"`
- DeclaredValue *string `xml:"declared_value,omitempty"`
- ParcelNum *string `xml:"parcel_num,omitempty"`
- NppAmount *string `xml:"npp_amount,omitempty"`
- VatPercent *int `xml:"vat_percent,omitempty"`
- WithoutVat *bool `xml:"without_vat,omitempty"`
- Count *int `xml:"count,omitempty"`
-}
-
-type UpdateAddress struct {
- Address *DpdClientAddress `xml:"address,omitempty"`
-}
-
-type UpdateAddressResponse struct {
- Return *DpdClientAddressStatus `xml:"return,omitempty"`
-}
-
-type OperationAddAirwayBill struct {
- AddAirwayBill *AddAirwayBill `xml:"addAirwayBill,omitempty"`
-}
-
-type OperationAddAirwayBillResponse struct {
- AddAirwayBillResponse *AddAirwayBillResponse `xml:"addAirwayBillResponse,omitempty"`
-}
-
-type OperationAddParcels struct {
- AddParcels *AddParcels `xml:"addParcels,omitempty"`
-}
-
-type OperationAddParcelsResponse struct {
- AddParcelsResponse *AddParcelsResponse `xml:"addParcelsResponse,omitempty"`
-}
-
-type OperationCancelOrder struct {
- CancelOrder *CancelOrder `xml:"cancelOrder,omitempty"`
-}
-
-type OperationCancelOrderResponse struct {
- CancelOrderResponse *CancelOrderResponse `xml:"cancelOrderResponse,omitempty"`
-}
-
-type OperationChangeDeliveryDate struct {
- ChangeDeliveryDate *ChangeDeliveryDate `xml:"changeDeliveryDate,omitempty"`
-}
-
-type OperationChangeDeliveryDateResponse struct {
- ChangeDeliveryDateResponse *ChangeDeliveryDateResponse `xml:"changeDeliveryDateResponse,omitempty"`
-}
-
-type OperationChangeUnitLoad struct {
- ChangeUnitLoad *ChangeUnitLoad `xml:"changeUnitLoad,omitempty"`
-}
-
-type OperationChangeUnitLoadResponse struct {
- ChangeUnitLoadResponse *ChangeUnitLoadResponse `xml:"changeUnitLoadResponse,omitempty"`
-}
-
-type OperationCreateAddress struct {
- CreateAddress *CreateAddress `xml:"createAddress,omitempty"`
-}
-
-type OperationCreateAddressResponse struct {
- CreateAddressResponse *CreateAddressResponse `xml:"createAddressResponse,omitempty"`
-}
-
-type OperationCreateOrder struct {
- CreateOrder *CreateOrder `xml:"createOrder,omitempty"`
-}
-
-type OperationCreateOrderResponse struct {
- CreateOrderResponse *CreateOrderResponse `xml:"createOrderResponse,omitempty"`
-}
-
-type OperationCreateOrderAsync struct {
- CreateOrderAsync *CreateOrderAsync `xml:"createOrderAsync,omitempty"`
-}
-
-type OperationCreateOrderAsyncResponse struct {
- CreateOrderAsyncResponse *CreateOrderAsyncResponse `xml:"createOrderAsyncResponse,omitempty"`
-}
-
-type OperationCreateOrderResult struct {
- CreateOrderResult *CreateOrderResult `xml:"createOrderResult,omitempty"`
-}
-
-type OperationCreateOrderResultResponse struct {
- CreateOrderResultResponse *CreateOrderResultResponse `xml:"createOrderResultResponse,omitempty"`
-}
-
-type OperationGetInvoiceFile struct {
- GetInvoiceFile *GetInvoiceFile `xml:"getInvoiceFile,omitempty"`
-}
-
-type OperationGetInvoiceFileResponse struct {
- GetInvoiceFileResponse *GetInvoiceFileResponse `xml:"getInvoiceFileResponse,omitempty"`
-}
-
-type OperationGetOrderSMS struct {
- GetOrderSMS *GetOrderSMS `xml:"getOrderSMS,omitempty"`
-}
-
-type OperationGetOrderSMSResponse struct {
- GetOrderSMSResponse *GetOrderSMSResponse `xml:"getOrderSMSResponse,omitempty"`
-}
-
-type OperationGetOrderStatus struct {
- GetOrderStatus *GetOrderStatus `xml:"getOrderStatus,omitempty"`
-}
-
-type OperationGetOrderStatusResponse struct {
- GetOrderStatusResponse *GetOrderStatusResponse `xml:"getOrderStatusResponse,omitempty"`
-}
-
-type OperationGetRegisterFile struct {
- GetRegisterFile *GetRegisterFile `xml:"getRegisterFile,omitempty"`
-}
-
-type OperationGetRegisterFileResponse struct {
- GetRegisterFileResponse *GetRegisterFileResponse `xml:"getRegisterFileResponse,omitempty"`
-}
-
-type OperationOrderReDirect struct {
- OrderReDirect *OrderReDirect `xml:"orderReDirect,omitempty"`
-}
-
-type OperationOrderReDirectResponse struct {
- OrderReDirectResponse *OrderReDirectResponse `xml:"orderReDirectResponse,omitempty"`
-}
-
-type OperationRemoveParcels struct {
- RemoveParcels *RemoveParcels `xml:"removeParcels,omitempty"`
-}
-
-type OperationRemoveParcelsResponse struct {
- RemoveParcelsResponse *RemoveParcelsResponse `xml:"removeParcelsResponse,omitempty"`
-}
-
-type OperationUpdateAddress struct {
- UpdateAddress *UpdateAddress `xml:"updateAddress,omitempty"`
-}
-
-type OperationUpdateAddressResponse struct {
- UpdateAddressResponse *UpdateAddressResponse `xml:"updateAddressResponse,omitempty"`
-}
-
-type dPDOrder struct {
- cli *soap.Client
-}
diff --git a/soap/tracking.go b/soap/tracking.go
deleted file mode 100644
index 2c28397..0000000
--- a/soap/tracking.go
+++ /dev/null
@@ -1,223 +0,0 @@
-package soap
-
-import "github.com/fiorix/wsdl2go/soap"
-
-const TrackingNamespace = "http://dpd.ru/ws/tracing/2011-11-18"
-
-type parcelTracing struct {
- cli *soap.Client
-}
-
-func NewParcelTracing(cli *soap.Client) ParcelTracing {
- return &parcelTracing{cli}
-}
-
-type ParcelTracing interface {
- GetStatesByClient(GetStatesByClient *GetStatesByClient) (*GetStatesByClientResponse, error)
- GetStatesByClientOrder(GetStatesByClientOrder *GetStatesByClientOrder) (*GetStatesByClientOrderResponse, error)
- GetStatesByClientParcel(GetStatesByClientParcel *GetStatesByClientParcel) (*GetStatesByClientParcelResponse, error)
- GetStatesByDPDOrder(GetStatesByDPDOrder *GetStatesByDPDOrder) (*GetStatesByDPDOrderResponse, error)
-}
-
-func (p *parcelTracing) Confirm(Confirm *Confirm) (*ConfirmResponse, error) {
- α := struct {
- OperationConfirm `xml:"tns:confirm"`
- }{
- OperationConfirm{
- Confirm,
- },
- }
-
- γ := struct {
- OperationConfirmResponse `xml:"confirmResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("Confirm", α, &γ); err != nil {
- return nil, err
- }
- return γ.ConfirmResponse, nil
-}
-
-func (p *parcelTracing) GetStatesByClient(GetStatesByClient *GetStatesByClient) (*GetStatesByClientResponse, error) {
- α := struct {
- OperationGetStatesByClient `xml:"tns:getStatesByClient"`
- }{
- OperationGetStatesByClient{
- GetStatesByClient,
- },
- }
-
- γ := struct {
- OperationGetStatesByClientResponse `xml:"getStatesByClientResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetStatesByClient", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetStatesByClientResponse, nil
-}
-
-func (p *parcelTracing) GetStatesByClientOrder(GetStatesByClientOrder *GetStatesByClientOrder) (*GetStatesByClientOrderResponse, error) {
- α := struct {
- OperationGetStatesByClientOrder `xml:"tns:getStatesByClientOrder"`
- }{
- OperationGetStatesByClientOrder{
- GetStatesByClientOrder,
- },
- }
-
- γ := struct {
- OperationGetStatesByClientOrderResponse `xml:"getStatesByClientOrderResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetStatesByClientOrder", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetStatesByClientOrderResponse, nil
-}
-
-func (p *parcelTracing) GetStatesByClientParcel(GetStatesByClientParcel *GetStatesByClientParcel) (*GetStatesByClientParcelResponse, error) {
- α := struct {
- OperationGetStatesByClientParcel `xml:"tns:getStatesByClientParcel"`
- }{
- OperationGetStatesByClientParcel{
- GetStatesByClientParcel,
- },
- }
-
- γ := struct {
- OperationGetStatesByClientParcelResponse `xml:"getStatesByClientParcelResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetStatesByClientParcel", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetStatesByClientParcelResponse, nil
-}
-
-func (p *parcelTracing) GetStatesByDPDOrder(GetStatesByDPDOrder *GetStatesByDPDOrder) (*GetStatesByDPDOrderResponse, error) {
- α := struct {
- OperationGetStatesByDPDOrder `xml:"tns:getStatesByDPDOrder"`
- }{
- OperationGetStatesByDPDOrder{
- GetStatesByDPDOrder,
- },
- }
-
- γ := struct {
- OperationGetStatesByDPDOrderResponse `xml:"getStatesByDPDOrderResponse"`
- }{}
- if err := p.cli.RoundTripWithAction("GetStatesByDPDOrder", α, &γ); err != nil {
- return nil, err
- }
- return γ.GetStatesByDPDOrderResponse, nil
-}
-
-type GetStatesByClient struct {
- Request *RequestClient `xml:"request,omitempty"`
-}
-
-type GetStatesByClientOrder struct {
- Request *RequestClientOrder `xml:"request,omitempty"`
-}
-
-type GetStatesByClientOrderResponse struct {
- Return *StateParcels `xml:"return,omitempty"`
-}
-
-type GetStatesByClientParcel struct {
- Request *RequestClientParcel `xml:"request,omitempty"`
-}
-
-type GetStatesByClientParcelResponse struct {
- Return *StateParcels `xml:"return,omitempty"`
-}
-
-type GetStatesByClientResponse struct {
- Return *StateParcels `xml:"return,omitempty"`
-}
-
-type GetStatesByDPDOrder struct {
- Request *RequestDpdOrder `xml:"request,omitempty"`
-}
-
-type GetStatesByDPDOrderResponse struct {
- Return *StateParcels `xml:"return,omitempty"`
-}
-
-type RequestClient struct {
- Auth *Auth `xml:"auth,omitempty"`
-}
-
-type RequestClientOrder struct {
- Auth *Auth `xml:"auth,omitempty"`
- ClientOrderNr *string `xml:"clientOrderNr,omitempty"`
- PickupDate *Date `xml:"pickupDate,omitempty"`
-}
-
-type RequestClientParcel struct {
- Auth *Auth `xml:"auth,omitempty"`
- ClientParcelNr *string `xml:"clientParcelNr,omitempty"`
- PickupDate *Date `xml:"pickupDate,omitempty"`
-}
-
-type RequestDpdOrder struct {
- Auth *Auth `xml:"auth,omitempty"`
- DpdOrderNr *string `xml:"dpdOrderNr,omitempty"`
- PickupYear *int `xml:"pickupYear,omitempty"`
-}
-
-type StateParcel struct {
- ClientOrderNr *string `xml:"clientOrderNr,omitempty"`
- ClientParcelNr *string `xml:"clientParcelNr,omitempty"`
- DpdOrderNr *string `xml:"dpdOrderNr,omitempty"`
- DpdParcelNr *string `xml:"dpdParcelNr,omitempty"`
- PickupDate *Date `xml:"pickupDate,omitempty"`
- DpdOrderReNr *string `xml:"dpdOrderReNr,omitempty"`
- DpdParcelReNr *string `xml:"dpdParcelReNr,omitempty"`
- IsReturn *bool `xml:"isReturn,omitempty"`
- PlanDeliveryDate *Date `xml:"planDeliveryDate,omitempty"`
- NewState *string `xml:"newState,omitempty"`
- TransitionTime *DateTime `xml:"transitionTime,omitempty"`
- TerminalCode *string `xml:"terminalCode,omitempty"`
- TerminalCity *string `xml:"terminalCity,omitempty"`
- IncidentCode *string `xml:"incidentCode,omitempty"`
- IncidentName *string `xml:"incidentName,omitempty"`
- Consignee *string `xml:"consignee,omitempty"`
-}
-
-type StateParcels struct {
- DocId *int64 `xml:"docId,omitempty"`
- DocDate *DateTime `xml:"docDate,omitempty"`
- ClientNumber *int64 `xml:"clientNumber,omitempty"`
- ResultComplete *bool `xml:"resultComplete,omitempty"`
- States []*StateParcel `xml:"states,omitempty"`
-}
-
-type OperationGetStatesByClient struct {
- GetStatesByClient *GetStatesByClient `xml:"getStatesByClient,omitempty"`
-}
-
-type OperationGetStatesByClientResponse struct {
- GetStatesByClientResponse *GetStatesByClientResponse `xml:"getStatesByClientResponse,omitempty"`
-}
-
-type OperationGetStatesByClientOrder struct {
- GetStatesByClientOrder *GetStatesByClientOrder `xml:"getStatesByClientOrder,omitempty"`
-}
-
-type OperationGetStatesByClientOrderResponse struct {
- GetStatesByClientOrderResponse *GetStatesByClientOrderResponse `xml:"getStatesByClientOrderResponse,omitempty"`
-}
-
-type OperationGetStatesByClientParcel struct {
- GetStatesByClientParcel *GetStatesByClientParcel `xml:"getStatesByClientParcel,omitempty"`
-}
-
-type OperationGetStatesByClientParcelResponse struct {
- GetStatesByClientParcelResponse *GetStatesByClientParcelResponse `xml:"getStatesByClientParcelResponse,omitempty"`
-}
-
-type OperationGetStatesByDPDOrder struct {
- GetStatesByDPDOrder *GetStatesByDPDOrder `xml:"getStatesByDPDOrder,omitempty"`
-}
-
-type OperationGetStatesByDPDOrderResponse struct {
- GetStatesByDPDOrderResponse *GetStatesByDPDOrderResponse `xml:"getStatesByDPDOrderResponse,omitempty"`
-}
diff --git a/tracking.go b/tracking.go
new file mode 100644
index 0000000..701b42d
--- /dev/null
+++ b/tracking.go
@@ -0,0 +1,96 @@
+package dpd
+
+const trackingNamespace = "http://dpd.ru/ws/tracing/2011-11-18"
+
+type operationGetStatesByClient struct {
+ GetStatesByClient *getStatesByClient `xml:"getStatesByClient,omitempty"`
+}
+
+type getStatesByClient struct {
+ Request *getStatesByClientRequest `xml:"request,omitempty"`
+}
+
+type getStatesByClientRequest struct {
+ Auth *Auth `xml:"auth,omitempty"`
+}
+
+type operationGetStatesByClientResponse struct {
+ GetStatesByClientResponse *getStatesByClientResponse `xml:"getStatesByClientResponse,omitempty"`
+}
+
+type getStatesByClientResponse struct {
+ Return *ParcelsStates `xml:"return,omitempty"`
+}
+
+type ParcelsStates struct {
+ DocID *int64 `xml:"docId,omitempty"`
+ DocDate *string `xml:"docDate,omitempty"`
+ ClientNumber *int64 `xml:"clientNumber,omitempty"`
+ ResultComplete *bool `xml:"resultComplete,omitempty"`
+ States []*ParcelState `xml:"states,omitempty"`
+}
+
+type ParcelState struct {
+ ClientOrderNr *string `xml:"clientOrderNr,omitempty"`
+ ClientParcelNr *string `xml:"clientParcelNr,omitempty"`
+ DpdOrderNr *string `xml:"dpdOrderNr,omitempty"`
+ DpdParcelNr *string `xml:"dpdParcelNr,omitempty"`
+ PickupDate *string `xml:"pickupDate,omitempty"`
+ DpdOrderReNr *string `xml:"dpdOrderReNr,omitempty"`
+ DpdParcelReNr *string `xml:"dpdParcelReNr,omitempty"`
+ IsReturn *bool `xml:"isReturn,omitempty"`
+ PlanDeliveryDate *string `xml:"planDeliveryDate,omitempty"`
+ NewState *string `xml:"newState,omitempty"`
+ TransitionTime *string `xml:"transitionTime,omitempty"`
+ TerminalCode *string `xml:"terminalCode,omitempty"`
+ TerminalCity *string `xml:"terminalCity,omitempty"`
+ IncidentCode *string `xml:"incidentCode,omitempty"`
+ IncidentName *string `xml:"incidentName,omitempty"`
+ Consignee *string `xml:"consignee,omitempty"`
+}
+
+type operationGetStatesByClientOrder struct {
+ GetStatesByClientOrder *getStatesByClientOrder `xml:"getStatesByClientOrder,omitempty"`
+}
+
+type getStatesByClientOrder struct {
+ Request *TrackByClientOrderRequest `xml:"request,omitempty"`
+}
+
+//TrackByClientOrderRequest GetStatesByClientOrder request body
+type TrackByClientOrderRequest struct {
+ Auth *Auth `xml:"auth,omitempty"`
+ ClientOrderNr *string `xml:"clientOrderNr,omitempty"`
+ PickupDate *string `xml:"pickupDate,omitempty"`
+}
+
+type operationGetStatesByClientOrderResponse struct {
+ GetStatesByClientOrderResponse *getStatesByClientOrderResponse `xml:"getStatesByClientOrderResponse,omitempty"`
+}
+
+type getStatesByClientOrderResponse struct {
+ Return *ParcelsStates `xml:"return,omitempty"`
+}
+
+type operationGetStatesByDPDOrder struct {
+ GetStatesByDPDOrder *getStatesByDPDOrder `xml:"getStatesByDPDOrder,omitempty"`
+}
+
+type getStatesByDPDOrder struct {
+ Request *TrackByDPDOrderRequest `xml:"request,omitempty"`
+}
+
+//TrackByDPDOrderRequest GetStatesByDPDOrder request body
+type TrackByDPDOrderRequest struct {
+ Auth *Auth `xml:"auth,omitempty"`
+ DpdOrderNr *string `xml:"dpdOrderNr,omitempty"`
+ PickupYear *int `xml:"pickupYear,omitempty"`
+}
+
+type operationGetStatesByDPDOrderResponse struct {
+ GetStatesByDPDOrderResponse *getStatesByDPDOrderResponse `xml:"getStatesByDPDOrderResponse,omitempty"`
+}
+
+type getStatesByDPDOrderResponse struct {
+ Return *ParcelsStates `xml:"return,omitempty"`
+}
diff --git a/trackingRequestBuilder.go b/trackingRequestBuilder.go
index 5c71f2e..816084a 100644
--- a/trackingRequestBuilder.go
+++ b/trackingRequestBuilder.go
@@ -2,118 +2,37 @@ package dpd
import (
"time"
-
- dpdSoap "github.com/vseinstrumentiru/dpd/soap"
)
-//Запрос на трекинг по номеру заказа клиента
-type ClientOrderRequest dpdSoap.RequestClientOrder
-
-func NewClientOrderRequest() *ClientOrderRequest {
- return new(ClientOrderRequest)
+func NewClientOrderRequest() *TrackByClientOrderRequest {
+ return new(TrackByClientOrderRequest)
}
-func (r *ClientOrderRequest) SetClientOrderNumber(number string) *ClientOrderRequest {
+func (r *TrackByClientOrderRequest) SetClientOrderNumber(number string) *TrackByClientOrderRequest {
r.ClientOrderNr = &number
return r
}
-func (r *ClientOrderRequest) SetPickupDate(time time.Time) *ClientOrderRequest {
- d := dpdSoap.Date(time.Format("2006-01-02"))
- r.PickupDate = &d
-
- return r
-}
-
-func (r *ClientOrderRequest) toDPDRequest() *dpdSoap.RequestClientOrder {
- dpdReq := dpdSoap.RequestClientOrder(*r)
-
- return &dpdReq
-}
-
-//Запрос на трекинг по посылке. Посылка идентифицируется по номеру посылки в информационной системе клиента.
-type ClientParcelRequest dpdSoap.RequestClientParcel
-
-func NewClientParcelRequest() *ClientParcelRequest {
- return new(ClientParcelRequest)
-}
-
-func (r *ClientParcelRequest) SetClientParcelNumber(number string) *ClientParcelRequest {
- r.ClientParcelNr = &number
-
- return r
-}
-
-func (r *ClientParcelRequest) SetPickupDate(time time.Time) *ClientParcelRequest {
- d := dpdSoap.Date(time.Format("2006-01-02"))
+func (r *TrackByClientOrderRequest) SetPickupDate(time time.Time) *TrackByClientOrderRequest {
+ d := time.Format("2006-01-02")
r.PickupDate = &d
return r
}
-//Запрос на трекинг по номеру заказа DPD
-type DpdOrderRequest dpdSoap.RequestDpdOrder
-
-func NewDpdOrderRequest() *DpdOrderRequest {
- return new(DpdOrderRequest)
+func NewDpdOrderRequest() *TrackByDPDOrderRequest {
+ return new(TrackByDPDOrderRequest)
}
-func (r *DpdOrderRequest) SetDPDOrderNumber(number string) *DpdOrderRequest {
+func (r *TrackByDPDOrderRequest) SetDPDOrderNumber(number string) *TrackByDPDOrderRequest {
r.DpdOrderNr = &number
return r
}
-func (r *DpdOrderRequest) SetPickupYear(year int) *DpdOrderRequest {
+func (r *TrackByDPDOrderRequest) SetPickupYear(year int) *TrackByDPDOrderRequest {
r.PickupYear = &year
return r
}
-
-func (r *DpdOrderRequest) toDPDRequest() *dpdSoap.RequestDpdOrder {
- dpdReq := dpdSoap.RequestDpdOrder(*r)
-
- return &dpdReq
-}
-
-// Запрос на подтверждение эвентов получених от GetEvents
-type ConfirmRequest dpdSoap.RequestConfirm
-
-func NewConfirmRequest() *ConfirmRequest {
- return new(ConfirmRequest)
-}
-
-func (r *ConfirmRequest) SetDocId(docId int64) *ConfirmRequest {
- r.DocId = &docId
-
- return r
-}
-
-type DpdTrackingEventRequest dpdSoap.EventTrackingRequest
-
-func (r *DpdTrackingEventRequest) SetDateFrom(from time.Time) *DpdTrackingEventRequest {
- d := dpdSoap.DateTime(from.Format("2006-01-02 15:04:05"))
- r.DateFrom = &d
-
- return r
-}
-
-func (r *DpdTrackingEventRequest) SetDateTo(to time.Time) *DpdTrackingEventRequest {
- d := dpdSoap.DateTime(to.Format("2006-01-02 15:04:05"))
- r.DateTo = &d
-
- return r
-}
-
-func (r *DpdTrackingEventRequest) SetMaxRowCount(count int) *DpdTrackingEventRequest {
- r.MaxRowCount = &count
-
- return r
-}
-
-func (r *DpdTrackingEventRequest) toDPDRequest() *dpdSoap.EventTrackingRequest {
- dpdReq := dpdSoap.EventTrackingRequest(*r)
-
- return &dpdReq
-}
diff --git a/trackingRequestBuilder_test.go b/trackingRequestBuilder_test.go
index 33a0f55..c374350 100644
--- a/trackingRequestBuilder_test.go
+++ b/trackingRequestBuilder_test.go
@@ -5,18 +5,16 @@ import (
"strconv"
"testing"
"time"
-
- dpdSoap "github.com/vseinstrumentiru/dpd/soap"
)
func TestNewClientOrderRequest(t *testing.T) {
tests := []struct {
name string
- want *ClientOrderRequest
+ want *TrackByClientOrderRequest
}{
{
"Constructor",
- &ClientOrderRequest{},
+ &TrackByClientOrderRequest{},
},
}
for _, tt := range tests {
@@ -32,21 +30,21 @@ func TestClientOrderRequest_SetClientOrderNumber(t *testing.T) {
type args struct {
number string
}
- orderNumber := "any string"
+ orderNumber := anyString
tests := []struct {
name string
- r *ClientOrderRequest
+ r *TrackByClientOrderRequest
args args
- want *ClientOrderRequest
+ want *TrackByClientOrderRequest
}{
{
"Set order number",
- &ClientOrderRequest{},
+ &TrackByClientOrderRequest{},
args{
orderNumber,
},
- &ClientOrderRequest{
+ &TrackByClientOrderRequest{
ClientOrderNr: &orderNumber,
},
},
@@ -54,7 +52,7 @@ func TestClientOrderRequest_SetClientOrderNumber(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.r.SetClientOrderNumber(tt.args.number); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("ClientOrderRequest.SetClientOrderNumber() = %v, want %v", got, tt.want)
+ t.Errorf("TrackByClientOrderRequest.SetClientOrderNumber() = %v, want %v", got, tt.want)
}
})
}
@@ -66,21 +64,21 @@ func TestClientOrderRequest_SetPickupDate(t *testing.T) {
}
now := time.Now()
- dpdDate := dpdSoap.Date(now.Format("2006-01-02"))
+ dpdDate := now.Format("2006-01-02")
tests := []struct {
name string
- r *ClientOrderRequest
+ r *TrackByClientOrderRequest
args args
- want *ClientOrderRequest
+ want *TrackByClientOrderRequest
}{
{
"Set pickup date",
- &ClientOrderRequest{},
+ &TrackByClientOrderRequest{},
args{
now,
},
- &ClientOrderRequest{
+ &TrackByClientOrderRequest{
PickupDate: &dpdDate,
},
},
@@ -88,114 +86,7 @@ func TestClientOrderRequest_SetPickupDate(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.r.SetPickupDate(tt.args.time); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("ClientOrderRequest.SetPickupDate() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestClientOrderRequest_toDPDRequest(t *testing.T) {
- tests := []struct {
- name string
- r *ClientOrderRequest
- want *dpdSoap.RequestClientOrder
- }{
- {
- "Converter",
- &ClientOrderRequest{},
- &dpdSoap.RequestClientOrder{},
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.toDPDRequest(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("ClientOrderRequest.toDPDRequest() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestNewClientParcelRequest(t *testing.T) {
- tests := []struct {
- name string
- want *ClientParcelRequest
- }{
- {
- "Constructor",
- &ClientParcelRequest{},
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := NewClientParcelRequest(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("NewClientParcelRequest() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestClientParcelRequest_SetClientParcelNumber(t *testing.T) {
- type args struct {
- number string
- }
-
- number := "any string"
-
- tests := []struct {
- name string
- r *ClientParcelRequest
- args args
- want *ClientParcelRequest
- }{
- {
- "Set client parcel number",
- &ClientParcelRequest{},
- args{
- number,
- },
- &ClientParcelRequest{
- ClientParcelNr: &number,
- },
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.SetClientParcelNumber(tt.args.number); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("ClientParcelRequest.SetClientParcelNumber() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestClientParcelRequest_SetPickupDate(t *testing.T) {
- type args struct {
- time time.Time
- }
-
- now := time.Now()
- dpdDate := dpdSoap.Date(now.Format("2006-01-02"))
-
- tests := []struct {
- name string
- r *ClientParcelRequest
- args args
- want *ClientParcelRequest
- }{
- {
- "Set pickup date",
- &ClientParcelRequest{},
- args{
- now,
- },
- &ClientParcelRequest{
- PickupDate: &dpdDate,
- },
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.SetPickupDate(tt.args.time); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("ClientParcelRequest.SetPickupDate() = %v, want %v", got, tt.want)
+ t.Errorf("TrackByClientOrderRequest.SetPickupDate() = %v, want %v", got, tt.want)
}
})
}
@@ -204,11 +95,11 @@ func TestClientParcelRequest_SetPickupDate(t *testing.T) {
func TestNewDpdOrderRequest(t *testing.T) {
tests := []struct {
name string
- want *DpdOrderRequest
+ want *TrackByDPDOrderRequest
}{
{
"Constructor",
- &DpdOrderRequest{},
+ &TrackByDPDOrderRequest{},
},
}
for _, tt := range tests {
@@ -225,21 +116,21 @@ func TestDpdOrderRequest_SetDPDOrderNumber(t *testing.T) {
number string
}
- number := "any string"
+ number := anyString
tests := []struct {
name string
- r *DpdOrderRequest
+ r *TrackByDPDOrderRequest
args args
- want *DpdOrderRequest
+ want *TrackByDPDOrderRequest
}{
{
"DPD order number",
- &DpdOrderRequest{},
+ &TrackByDPDOrderRequest{},
args{
number,
},
- &DpdOrderRequest{
+ &TrackByDPDOrderRequest{
DpdOrderNr: &number,
},
},
@@ -247,7 +138,7 @@ func TestDpdOrderRequest_SetDPDOrderNumber(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.r.SetDPDOrderNumber(tt.args.number); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("DpdOrderRequest.SetDPDOrderNumber() = %v, want %v", got, tt.want)
+ t.Errorf("TrackByDPDOrderRequest.SetDPDOrderNumber() = %v, want %v", got, tt.want)
}
})
}
@@ -261,23 +152,23 @@ func TestDpdOrderRequest_SetPickupYear(t *testing.T) {
year, err := strconv.Atoi(time.Now().Format("2006"))
if err != nil {
- t.Errorf("DpdOrderRequest.SetPickupYear(), err %s", err.Error())
+ t.Errorf("TrackByDPDOrderRequest.SetPickupYear(), err %s", err.Error())
t.SkipNow()
}
tests := []struct {
name string
- r *DpdOrderRequest
+ r *TrackByDPDOrderRequest
args args
- want *DpdOrderRequest
+ want *TrackByDPDOrderRequest
}{
{
"Set pickup year",
- &DpdOrderRequest{},
+ &TrackByDPDOrderRequest{},
args{
year,
},
- &DpdOrderRequest{
+ &TrackByDPDOrderRequest{
PickupYear: &year,
},
},
@@ -285,202 +176,7 @@ func TestDpdOrderRequest_SetPickupYear(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.r.SetPickupYear(tt.args.year); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("DpdOrderRequest.SetPickupYear() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestDpdOrderRequest_toDPDRequest(t *testing.T) {
- tests := []struct {
- name string
- r *DpdOrderRequest
- want *dpdSoap.RequestDpdOrder
- }{
- {
- "Converter",
- &DpdOrderRequest{},
- &dpdSoap.RequestDpdOrder{},
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.toDPDRequest(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("DpdOrderRequest.toDPDRequest() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestNewConfirmRequest(t *testing.T) {
- tests := []struct {
- name string
- want *ConfirmRequest
- }{
- {
- "Constructor",
- &ConfirmRequest{},
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := NewConfirmRequest(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("NewConfirmRequest() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestConfirmRequest_SetDocId(t *testing.T) {
- type args struct {
- docId int64
- }
-
- var docID int64 = 12341241242
-
- tests := []struct {
- name string
- r *ConfirmRequest
- args args
- want *ConfirmRequest
- }{
- {
- "Set doc id",
- &ConfirmRequest{},
- args{
- docID,
- },
- &ConfirmRequest{
- DocId: &docID,
- },
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.SetDocId(tt.args.docId); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("ConfirmRequest.SetDocId() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestDpdTrackingEventRequest_SetDateFrom(t *testing.T) {
- type args struct {
- from time.Time
- }
-
- from := time.Now()
- dpdDateTime := dpdSoap.DateTime(from.Format("2006-01-02 15:04:05"))
-
- tests := []struct {
- name string
- r *DpdTrackingEventRequest
- args args
- want *DpdTrackingEventRequest
- }{
- {
- "Set date from",
- &DpdTrackingEventRequest{},
- args{
- from,
- },
- &DpdTrackingEventRequest{
- DateFrom: &dpdDateTime,
- },
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.SetDateFrom(tt.args.from); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("DpdTrackingEventRequest.SetDateFrom() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestDpdTrackingEventRequest_SetDateTo(t *testing.T) {
- type args struct {
- to time.Time
- }
-
- to := time.Now()
- dpdDateTime := dpdSoap.DateTime(to.Format("2006-01-02 15:04:05"))
-
- tests := []struct {
- name string
- r *DpdTrackingEventRequest
- args args
- want *DpdTrackingEventRequest
- }{
- {
- "Set date to",
- &DpdTrackingEventRequest{},
- args{
- to,
- },
- &DpdTrackingEventRequest{
- DateTo: &dpdDateTime,
- },
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.SetDateTo(tt.args.to); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("DpdTrackingEventRequest.SetDateTo() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestDpdTrackingEventRequest_SetMaxRowCount(t *testing.T) {
- type args struct {
- count int
- }
-
- count := 2
-
- tests := []struct {
- name string
- r *DpdTrackingEventRequest
- args args
- want *DpdTrackingEventRequest
- }{
- {
- "Max row count",
- &DpdTrackingEventRequest{},
- args{
- count,
- },
- &DpdTrackingEventRequest{
- MaxRowCount: &count,
- },
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.SetMaxRowCount(tt.args.count); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("DpdTrackingEventRequest.SetMaxRowCount() = %v, want %v", got, tt.want)
- }
- })
- }
-}
-
-func TestDpdTrackingEventRequest_toDPDRequest(t *testing.T) {
- tests := []struct {
- name string
- r *DpdTrackingEventRequest
- want *dpdSoap.EventTrackingRequest
- }{
- {
- "Converter",
- &DpdTrackingEventRequest{},
- &dpdSoap.EventTrackingRequest{},
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := tt.r.toDPDRequest(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("DpdTrackingEventRequest.toDPDRequest() = %v, want %v", got, tt.want)
+ t.Errorf("TrackByDPDOrderRequest.SetPickupYear() = %v, want %v", got, tt.want)
}
})
}