Skip to content

Commit

Permalink
Remove carbon_offset from parameter (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchen293 authored Dec 1, 2023
1 parent d24726e commit 2fe3489
Show file tree
Hide file tree
Showing 145 changed files with 3,452 additions and 5,648 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Next major release

- Removes the undocumented `CreateAndBuy` function from the Batch service. The proper usage is to create a batch first and buy it separately
- Removed `CarbonOffset` parameter from `createShipmentRequest`, `buyShipmentRequest`, and `buyShipmentRequest` structs as EasyPost now offers Carbon Neutral shipments by default for free

## v3.2.0 (2023-10-11)

Expand Down
9 changes: 0 additions & 9 deletions carbon_offset.go

This file was deleted.

41 changes: 20 additions & 21 deletions rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,26 @@ import (

// A Rate contains information on shipping cost and delivery time.
type Rate struct {
ID string `json:"id,omitempty"`
Object string `json:"object,omitempty"`
Mode string `json:"mode,omitempty"`
CreatedAt *DateTime `json:"created_at,omitempty"`
UpdatedAt *DateTime `json:"updated_at,omitempty"`
Service string `json:"service,omitempty"`
Carrier string `json:"carrier,omitempty"`
CarrierAccountID string `json:"carrier_account_id,omitempty"`
ShipmentID string `json:"shipment_id,omitempty"`
Rate string `json:"rate,omitempty"`
Currency string `json:"currency,omitempty"`
RetailRate string `json:"retail_rate,omitempty"`
RetailCurrency string `json:"retail_currency,omitempty"`
ListRate string `json:"list_rate,omitempty"`
ListCurrency string `json:"list_currency,omitempty"`
DeliveryDays int `json:"delivery_days,omitempty"`
DeliveryDate *DateTime `json:"delivery_date,omitempty"`
DeliveryDateGuaranteed bool `json:"delivery_date_guaranteed,omitempty"`
EstDeliveryDays int `json:"est_delivery_days,omitempty"`
BillingType string `json:"billing_type,omitempty"`
CarbonOffset *CarbonOffset `json:"carbon_offset,omitempty"`
ID string `json:"id,omitempty"`
Object string `json:"object,omitempty"`
Mode string `json:"mode,omitempty"`
CreatedAt *DateTime `json:"created_at,omitempty"`
UpdatedAt *DateTime `json:"updated_at,omitempty"`
Service string `json:"service,omitempty"`
Carrier string `json:"carrier,omitempty"`
CarrierAccountID string `json:"carrier_account_id,omitempty"`
ShipmentID string `json:"shipment_id,omitempty"`
Rate string `json:"rate,omitempty"`
Currency string `json:"currency,omitempty"`
RetailRate string `json:"retail_rate,omitempty"`
RetailCurrency string `json:"retail_currency,omitempty"`
ListRate string `json:"list_rate,omitempty"`
ListCurrency string `json:"list_currency,omitempty"`
DeliveryDays int `json:"delivery_days,omitempty"`
DeliveryDate *DateTime `json:"delivery_date,omitempty"`
DeliveryDateGuaranteed bool `json:"delivery_date_guaranteed,omitempty"`
EstDeliveryDays int `json:"est_delivery_days,omitempty"`
BillingType string `json:"billing_type,omitempty"`
}

// A SmartRate contains information on shipping cost and delivery time in addition to time-in-transit details.
Expand Down
62 changes: 2 additions & 60 deletions shipment.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,11 @@ type ListShipmentsResult struct {
type buyShipmentRequest struct {
Rate *Rate `json:"rate,omitempty"`
Insurance string `json:"insurance,omitempty"`
CarbonOffset bool `json:"carbon_offset,omitempty"`
EndShipperID string `json:"end_shipper_id,omitempty"`
}

type createShipmentRequest struct {
Shipment *Shipment `json:"shipment,omitempty"`
CarbonOffset bool `json:"carbon_offset,omitempty"`
}

type getShipmentRatesRequest struct {
CarbonOffset bool `json:"carbon_offset,omitempty"`
Shipment *Shipment `json:"shipment,omitempty"`
}

type getShipmentRatesResponse struct {
Expand Down Expand Up @@ -165,11 +159,6 @@ func (c *Client) CreateShipment(in *Shipment) (out *Shipment, err error) {
return c.CreateShipmentWithContext(context.Background(), in)
}

// CreateShipmentWithCarbonOffset performs the same operation as CreateShipment, but includes a carbon offset.
func (c *Client) CreateShipmentWithCarbonOffset(in *Shipment) (out *Shipment, err error) {
return c.CreateShipmentWithCarbonOffsetWithContext(context.Background(), in)
}

// CreateShipmentWithContext performs the same operation as CreateShipment, but
// allows specifying a context that can interrupt the request.
func (c *Client) CreateShipmentWithContext(ctx context.Context, in *Shipment) (out *Shipment, err error) {
Expand All @@ -178,14 +167,6 @@ func (c *Client) CreateShipmentWithContext(ctx context.Context, in *Shipment) (o
return
}

// CreateShipmentWithCarbonOffsetWithContext performs the same operation as CreateShipmentWithCarbonOffset, but
// allows specifying a context that can interrupt the request.
func (c *Client) CreateShipmentWithCarbonOffsetWithContext(ctx context.Context, in *Shipment) (out *Shipment, err error) {
req := &createShipmentRequest{Shipment: in, CarbonOffset: true}
err = c.post(ctx, "shipments", &req, &out)
return
}

// ListShipments provides a paginated result of Shipment objects.
func (c *Client) ListShipments(opts *ListShipmentsOptions) (out *ListShipmentsResult, err error) {
return c.ListShipmentsWithContext(context.Background(), opts)
Expand Down Expand Up @@ -273,18 +254,6 @@ func (c *Client) BuyShipmentWithContext(ctx context.Context, shipmentID string,
return c.buyShipment(ctx, shipmentID, req)
}

// BuyShipmentWithCarbonOffset performs the same operation as BuyShipment, but includes a carbon offset.
func (c *Client) BuyShipmentWithCarbonOffset(shipmentID string, rate *Rate, insurance string) (out *Shipment, err error) {
return c.BuyShipmentWithCarbonOffsetWithContext(context.Background(), shipmentID, rate, insurance)
}

// BuyShipmentWithCarbonOffsetWithContext performs the same operation as BuyShipmentWithCarbonOffset, but allows
// specifying a context that can interrupt the request.
func (c *Client) BuyShipmentWithCarbonOffsetWithContext(ctx context.Context, shipmentID string, rate *Rate, insurance string) (out *Shipment, err error) {
req := &buyShipmentRequest{Rate: rate, Insurance: insurance, CarbonOffset: true}
return c.buyShipment(ctx, shipmentID, req)
}

// BuyShipmentWithEndShipper performs the same operation as BuyShipment, but includes an EndShipper ID.
func (c *Client) BuyShipmentWithEndShipper(shipmentID string, rate *Rate, insurance string, endShipperID string) (out *Shipment, err error) {
return c.BuyShipmentWithEndShipperWithContext(context.Background(), shipmentID, rate, insurance, endShipperID)
Expand All @@ -297,18 +266,6 @@ func (c *Client) BuyShipmentWithEndShipperWithContext(ctx context.Context, shipm
return c.buyShipment(ctx, shipmentID, req)
}

// BuyShipmentWithCarbonOffsetAndEndShipper performs the same operation as BuyShipment, but includes a carbon offset and an EndShipper ID.
func (c *Client) BuyShipmentWithCarbonOffsetAndEndShipper(shipmentID string, rate *Rate, insurance string, endShipperID string) (out *Shipment, err error) {
return c.BuyShipmentWithCarbonOffsetAndEndShipperWithContext(context.Background(), shipmentID, rate, insurance, endShipperID)
}

// BuyShipmentWithCarbonOffsetAndEndShipperWithContext performs the same operation as BuyShipmentWithCarbonOffsetAndEndShipper, but allows
// specifying a context that can interrupt the request.
func (c *Client) BuyShipmentWithCarbonOffsetAndEndShipperWithContext(ctx context.Context, shipmentID string, rate *Rate, insurance string, endShipperID string) (out *Shipment, err error) {
req := &buyShipmentRequest{Rate: rate, Insurance: insurance, CarbonOffset: true, EndShipperID: endShipperID}
return c.buyShipment(ctx, shipmentID, req)
}

// GetShipmentLabel enables retrieving the label for a shipment in a different
// format. The PostageLabel field in the returned Shipment object will reflect
// the new format.
Expand Down Expand Up @@ -375,23 +332,8 @@ func (c *Client) RerateShipment(shipmentID string) (out []*Rate, err error) {
// RerateShipmentWithContext performs the same operation as RerateShipment,
// but allows specifying a context that can interrupt the request.
func (c *Client) RerateShipmentWithContext(ctx context.Context, shipmentID string) (out []*Rate, err error) {
req := &getShipmentRatesRequest{CarbonOffset: false}
res := &getShipmentRatesResponse{Rates: &out}
err = c.post(ctx, "shipments/"+shipmentID+"/rerate", &req, &res)
return
}

// RerateShipmentWithCarbonOffset performs the same operation as RerateShipment, but includes a carbon offset.
func (c *Client) RerateShipmentWithCarbonOffset(shipmentID string) (out []*Rate, err error) {
return c.RerateShipmentWithCarbonOffsetWithContext(context.Background(), shipmentID)
}

// RerateShipmentWithCarbonOffsetWithContext performs the same operation as RerateShipmentWithCarbonOffset, but allows
// specifying a context that can interrupt the request.
func (c *Client) RerateShipmentWithCarbonOffsetWithContext(ctx context.Context, shipmentID string) (out []*Rate, err error) {
req := &getShipmentRatesRequest{CarbonOffset: true}
res := &getShipmentRatesResponse{Rates: &out}
err = c.post(ctx, "shipments/"+shipmentID+"/rerate", &req, &res)
err = c.post(ctx, "shipments/"+shipmentID+"/rerate", nil, &res)
return
}

Expand Down
37 changes: 17 additions & 20 deletions tests/cassettes/TestAddressAll.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 9 additions & 14 deletions tests/cassettes/TestAddressCreate.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 9 additions & 13 deletions tests/cassettes/TestAddressCreateAndVerify.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2fe3489

Please sign in to comment.