-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathsmart_rate.go
96 lines (83 loc) · 7.37 KB
/
smart_rate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package easypost
import (
"context"
"net/http"
)
// TimeInTransitDetailsForDeliveryDate contains the time-in-transit details and estimated delivery date for a specific DeliveryDateForZipPairEstimate.
type TimeInTransitDetailsForDeliveryDate struct {
PlannedShipDate *DateTime `json:"planned_ship_date,omitempty" url:"planned_ship_date,omitempty"`
EasyPostEstimatedDeliveryDate *DateTime `json:"easypost_estimated_delivery_date,omitempty" url:"easypost_estimated_delivery_date,omitempty"`
DaysInTransit *TimeInTransit `json:"days_in_transit,omitempty" url:"days_in_transit,omitempty"`
}
// DeliveryDateForZipPairEstimate is a single zip-pair-based delivery date estimate for a carrier-service level combination.
type DeliveryDateForZipPairEstimate struct {
Carrier string `json:"carrier,omitempty" url:"carrier,omitempty"`
Service string `json:"service,omitempty" url:"service,omitempty"`
EasyPostTimeInTransitData *TimeInTransitDetailsForDeliveryDate `json:"easypost_time_in_transit_data,omitempty" url:"easypost_time_in_transit_data,omitempty"`
}
// EstimateDeliveryDateForZipPairResult is the result of the EstimateDeliveryDateForZipPair method, containing the estimated delivery date of each carrier-service level combination and additional metadata.
type EstimateDeliveryDateForZipPairResult struct {
CarriersWithoutEstimates []string `json:"carriers_without_tint_estimates,omitempty" url:"carriers_without_tint_estimates,omitempty"`
FromZip string `json:"from_zip,omitempty" url:"from_zip,omitempty"`
ToZip string `json:"to_zip,omitempty" url:"to_zip,omitempty"`
SaturdayDelivery bool `json:"saturday_delivery,omitempty" url:"saturday_delivery,omitempty"`
PlannedShipDate *DateTime `json:"planned_ship_date,omitempty" url:"planned_ship_date,omitempty"`
Results []*DeliveryDateForZipPairEstimate `json:"results,omitempty" url:"results,omitempty"`
}
// EstimateDeliveryDateForZipPairParams are used in the EstimateDeliveryDateForZipPair method.
type EstimateDeliveryDateForZipPairParams struct {
FromZip string `json:"from_zip,omitempty" url:"from_zip,omitempty"`
ToZip string `json:"to_zip,omitempty" url:"to_zip,omitempty"`
Carriers []string `json:"carriers,omitempty" url:"carriers,omitempty"`
PlannedShipDate string `json:"planned_ship_date,omitempty" url:"planned_ship_date,omitempty"`
SaturdayDelivery bool `json:"saturday_delivery,omitempty" url:"saturday_delivery,omitempty"`
}
// TimeInTransitDetailsForShipDate contains the time-in-transit details and estimated delivery date for a specific ShipDateForZipPairRecommendation or RecommendShipDateForShipmentResult.
type TimeInTransitDetailsForShipDate struct {
DesiredDeliveryDate *DateTime `json:"desired_delivery_date,omitempty" url:"desired_delivery_date,omitempty"`
EasyPostRecommendedShipDate *DateTime `json:"ship_on_date,omitempty" url:"ship_on_date,omitempty"`
DeliveryDateConfidence float64 `json:"delivery_date_confidence,omitempty" url:"delivery_date_confidence,omitempty"`
EstimatedTransitDays int `json:"estimated_transit_days,omitempty" url:"estimated_transit_days,omitempty"`
DaysInTransit *TimeInTransit `json:"days_in_transit,omitempty" url:"days_in_transit,omitempty"`
}
// ShipDateForZipPairRecommendation is a single zip-pair-based ship date recommendation for a carrier-service level combination.
type ShipDateForZipPairRecommendation struct {
Carrier string `json:"carrier,omitempty" url:"carrier,omitempty"`
Service string `json:"service,omitempty" url:"service,omitempty"`
EasyPostTimeInTransitData *TimeInTransitDetailsForShipDate `json:"easypost_time_in_transit_data,omitempty" url:"easypost_time_in_transit_data,omitempty"`
}
// RecommendShipDateForZipPairResult is the result of the RecommendShipDateForZipPair method, containing the recommended ship date of each carrier-service level combination and additional metadata.
type RecommendShipDateForZipPairResult struct {
CarriersWithoutEstimates []string `json:"carriers_without_tint_estimates,omitempty" url:"carriers_without_tint_estimates,omitempty"`
FromZip string `json:"from_zip,omitempty" url:"from_zip,omitempty"`
ToZip string `json:"to_zip,omitempty" url:"to_zip,omitempty"`
SaturdayDelivery bool `json:"saturday_delivery,omitempty" url:"saturday_delivery,omitempty"`
DesiredDeliveryDate *DateTime `json:"desired_delivery_date,omitempty" url:"desired_delivery_date,omitempty"`
Results []*ShipDateForZipPairRecommendation `json:"results,omitempty" url:"results,omitempty"`
}
// RecommendShipDateForZipPairParams are used in the RecommendShipDateForZipPair method.
type RecommendShipDateForZipPairParams struct {
FromZip string `json:"from_zip,omitempty" url:"from_zip,omitempty"`
ToZip string `json:"to_zip,omitempty" url:"to_zip,omitempty"`
Carriers []string `json:"carriers,omitempty" url:"carriers,omitempty"`
DesiredDeliveryDate string `json:"desired_delivery_date,omitempty" url:"desired_delivery_date,omitempty"`
SaturdayDelivery bool `json:"saturday_delivery,omitempty" url:"saturday_delivery,omitempty"`
}
// EstimateDeliveryDateForZipPair retrieves the estimated delivery date of each carrier-service level combination via the Smart Deliver By API, based on a specific ship date and origin-destination postal code pair.
func (c *Client) EstimateDeliveryDateForZipPair(params *EstimateDeliveryDateForZipPairParams) (out *EstimateDeliveryDateForZipPairResult, err error) {
return c.EstimateDeliveryDateForZipPairWithContext(context.Background(), params)
}
// EstimateDeliveryDateForZipPairWithContext performs the same operation as EstimateDeliveryDateForZipPair, but allows specifying a context that can interrupt the request.
func (c *Client) EstimateDeliveryDateForZipPairWithContext(ctx context.Context, params *EstimateDeliveryDateForZipPairParams) (out *EstimateDeliveryDateForZipPairResult, err error) {
err = c.do(ctx, http.MethodPost, "smartrate/deliver_by", params, &out)
return
}
// RecommendShipDateForZipPair retrieves the recommended ship date of each carrier-service level combination via the Smart Deliver On API, based on a specific desired delivery date and origin-destination postal code pair.
func (c *Client) RecommendShipDateForZipPair(params *RecommendShipDateForZipPairParams) (out *RecommendShipDateForZipPairResult, err error) {
return c.RecommendShipDateForZipPairWithContext(context.Background(), params)
}
// RecommendShipDateForZipPairWithContext performs the same operation as RecommendShipDateForZipPair, but allows specifying a context that can interrupt the request.
func (c *Client) RecommendShipDateForZipPairWithContext(ctx context.Context, params *RecommendShipDateForZipPairParams) (out *RecommendShipDateForZipPairResult, err error) {
err = c.do(ctx, http.MethodPost, "smartrate/deliver_on", params, &out)
return
}