Skip to content

Commit

Permalink
Fix Packages type
Browse files Browse the repository at this point in the history
  • Loading branch information
radulucut committed Nov 16, 2023
1 parent 72be3e0 commit 7fa71a0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 27 deletions.
40 changes: 24 additions & 16 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,20 +712,24 @@ func newOrder() Order {
},
ValidationStrategy: ValidationStrategyTypeMinimal,
},
Packages: []Package{
{
Weight: 1.0,
Width: 1.0,
Height: 1.0,
Length: 1.0,
Packages: Packages{
Type: PackageTypePackage,
Content: "Content",
List: []Package{
{
Weight: 1.0,
Width: 1.0,
Height: 1.0,
Length: 1.0,
},
},
},
ServiceSelectStrategy: ServiceSelectStrategy{
SelectionType: ServiceTypeDirectId,
ServiceIds: []int64{1},
},
ExtraOptions: []map[string]interface{}{
{
ExtraOptions: []interface{}{
map[string]interface{}{
"id": ExtraOptionIdOpenAtDelivery,
},
},
Expand All @@ -740,20 +744,24 @@ func newOrderWithAddressId() Order {
Recipient: Recipient{
AddressId: 2,
},
Packages: []Package{
{
Weight: 1.0,
Width: 1.0,
Height: 1.0,
Length: 1.0,
Packages: Packages{
Type: PackageTypePackage,
Content: "Content",
List: []Package{
{
Weight: 1.0,
Width: 1.0,
Height: 1.0,
Length: 1.0,
},
},
},
ServiceSelectStrategy: ServiceSelectStrategy{
SelectionType: ServiceTypeDirectId,
ServiceIds: []int64{1},
},
ExtraOptions: []map[string]interface{}{
{
ExtraOptions: []interface{}{
map[string]interface{}{
"id": ExtraOptionIdOpenAtDelivery,
},
},
Expand Down
26 changes: 15 additions & 11 deletions order.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ const (
)

type Package struct {
Type PackageType `json:"type"`
Content string `json:"content"`
Weight float64 `json:"weight"`
Width float64 `json:"width"`
Height float64 `json:"height"`
Length float64 `json:"length"`
Weight float64 `json:"weight"`
Width float64 `json:"width"`
Height float64 `json:"height"`
Length float64 `json:"length"`
}

type ServiceType string
Expand All @@ -54,12 +52,18 @@ type ServiceSelectStrategy struct {
Grades []ServiceGrade `json:"grades,omitempty"`
}

type Packages struct {
Type PackageType `json:"type"`
Content string `json:"content"`
List []Package `json:"list"`
}

type Order struct {
Sender Sender `json:"sender"`
Recipient Recipient `json:"recipient"`
Packages []Package `json:"packages"`
ServiceSelectStrategy ServiceSelectStrategy `json:"serviceSelectStrategy"`
ExtraOptions []map[string]interface{} `json:"extraOptions,omitempty"`
Sender Sender `json:"sender"`
Recipient Recipient `json:"recipient"`
Packages Packages `json:"packages"`
ServiceSelectStrategy ServiceSelectStrategy `json:"serviceSelectStrategy"`
ExtraOptions []interface{} `json:"extraOptions,omitempty"`
}

type ServicePrice struct {
Expand Down

0 comments on commit 7fa71a0

Please sign in to comment.