Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ jobs:
- uses: extractions/setup-just@v4
- uses: actions/setup-go@v7
with:
# TODO: The version of golangci-lint we use is not compatible with Go 1.26+, migrate to new version
go-version: '1.25'
go-version: '1.27'
- name: Lint project
run: just install lint
build:
Expand Down
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# CHANGELOG

## v6.0.0
## Next Release

See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-5x-to-60) for more details.

- BREAKING: Renames exported identifiers to use Go initialisms (e.g. `Id` to `ID`, `Url` to `URL`); JSON and URL tags are unchanged
- Types: `ExternalApiError`, `UnknownHttpError`
- Functions: `RetrieveEasypostStripeApiKey(WithContext)`, `BetaCreateBankAccountClientSecretWithReturlUrl` to `BetaCreateBankAccountClientSecretWithReturnURL` (fixes the `Returl` typo), `BetaCreateBankAccountClientSecretWithReturnUrlWithContext`
- Variables: `ApiDidNotReturnErrorDetails`, `ApiErrorDetailsParsingError`, `JsonDeserializationErrorMessage`, `JsonNoDataErrorMessage`, `JsonSerializationErrorMessage`, `NoUserFoundForId`
- Struct fields: `BetaPaymentRefund.PaymentLogId`, `Claim.InsuranceId`, `Claim.ShipmentId`, `CustomerPortalAccountLinkParameters.UserId/RefreshUrl/ReturnUrl`, `EmbeddablesSession.SessionId`, `EmbeddablesSessionParameters.UserId`, `MandateData.IpAddress`, `MockRequestMatchRule.UrlRegexPattern`, `RequestHookEvent.Id/Url`, `ResponseHookEvent.HttpStatus/Id/Url`, `TaxIdentifier.TaxId/TaxIdType`
- Upgrades golangci-lint to v2
- Changes `ShipmentOptions.Machinable` from `bool` to `*bool` so an explicit `false` is sent; callers use `easypost.BoolPtr(...)`. Previously `false` was dropped and USPS rated the parcel as machinable (closes #297, thanks @pcbeingused333)
- Fixes `BetaRefundByAmount` and `BetaRefundByPaymentLog` failing to decode a successful response
- Fixes `BetaAddPaymentMethod` failing to decode a successful response
- Fixes `AddReferralCustomerBankAccountFromStripe` sending `mandata_data` instead of `mandate_data`

## v5.13.0 (2026-11-09)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ mockRequests := []easypost.MockRequest{
MatchRule: easypost.MockRequestMatchRule{
// HTTP method and regex pattern for the URL must both pass for the request to match
Method: "POST",
UrlRegexPattern: "v2\\/bank_accounts\\/\\S*\\/charges$",
URLRegexPattern: "v2\\/bank_accounts\\/\\S*\\/charges$",
},
ResponseInfo: easypost.MockRequestResponseInfo{
// HTTP status code and body to return when this request is matched
Expand Down
56 changes: 56 additions & 0 deletions UPGRADE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,67 @@

Use the following guide to assist in the upgrade process of the `easypost-go` library between major versions.

- [Upgrading from 5.x to 6.0](#upgrading-from-5x-to-60)
- [Upgrading from 4.x to 5.0](#upgrading-from-4x-to-50)
- [Upgrading from 3.x to 4.0](#upgrading-from-3x-to-40)
- [Upgrading from 2.x to 3.0](#upgrading-from-2x-to-30)
- [Upgrading from 1.x to 2.0](#upgrading-from-1x-to-20)

## Upgrading from 5.x to 6.0

### 6.0 High Impact Changes

- [Renamed Identifiers](#60-renamed-identifiers)

## 6.0 Renamed Identifiers

*Likelihood of Impact: **High***

Exported identifiers now use Go initialisms (e.g. `Id` to `ID`, `Url` to `URL`). JSON and URL tags are unchanged.

`RequestHookEvent`, `ResponseHookEvent` and `MockRequestMatchRule` have no JSON tags, so if you serialize them yourself their keys change too (e.g. `Id` to `ID`, `Url` to `URL`, `HttpStatus` to `HTTPStatus`).

The following types were renamed:

- `ExternalApiError` to `ExternalAPIError`
- `UnknownHttpError` to `UnknownHTTPError`

The following functions were renamed:

- `RetrieveEasypostStripeApiKey` to `RetrieveEasypostStripeAPIKey`
- `RetrieveEasypostStripeApiKeyWithContext` to `RetrieveEasypostStripeAPIKeyWithContext`
- `BetaCreateBankAccountClientSecretWithReturlUrl` to `BetaCreateBankAccountClientSecretWithReturnURL` (also fixes the `Returl` typo)
- `BetaCreateBankAccountClientSecretWithReturnUrlWithContext` to `BetaCreateBankAccountClientSecretWithReturnURLWithContext`

The following variables were renamed:

- `ApiDidNotReturnErrorDetails` to `APIDidNotReturnErrorDetails`
- `ApiErrorDetailsParsingError` to `APIErrorDetailsParsingError`
- `JsonDeserializationErrorMessage` to `JSONDeserializationErrorMessage`
- `JsonNoDataErrorMessage` to `JSONNoDataErrorMessage`
- `JsonSerializationErrorMessage` to `JSONSerializationErrorMessage`
- `NoUserFoundForId` to `NoUserFoundForID`

The following struct fields were renamed:

- `BetaPaymentRefund.PaymentLogId` to `BetaPaymentRefund.PaymentLogID`
- `Claim.InsuranceId` to `Claim.InsuranceID`
- `Claim.ShipmentId` to `Claim.ShipmentID`
- `CustomerPortalAccountLinkParameters.UserId` to `CustomerPortalAccountLinkParameters.UserID`
- `CustomerPortalAccountLinkParameters.RefreshUrl` to `CustomerPortalAccountLinkParameters.RefreshURL`
- `CustomerPortalAccountLinkParameters.ReturnUrl` to `CustomerPortalAccountLinkParameters.ReturnURL`
- `EmbeddablesSession.SessionId` to `EmbeddablesSession.SessionID`
- `EmbeddablesSessionParameters.UserId` to `EmbeddablesSessionParameters.UserID`
- `MandateData.IpAddress` to `MandateData.IPAddress`
- `MockRequestMatchRule.UrlRegexPattern` to `MockRequestMatchRule.URLRegexPattern`
- `RequestHookEvent.Id` to `RequestHookEvent.ID`
- `RequestHookEvent.Url` to `RequestHookEvent.URL`
- `ResponseHookEvent.HttpStatus` to `ResponseHookEvent.HTTPStatus`
- `ResponseHookEvent.Id` to `ResponseHookEvent.ID`
- `ResponseHookEvent.Url` to `ResponseHookEvent.URL`
- `TaxIdentifier.TaxId` to `TaxIdentifier.TaxID`
- `TaxIdentifier.TaxIdType` to `TaxIdentifier.TaxIDType`

## Upgrading from 4.x to 5.0

### 5.0 High Impact Changes
Expand Down
4 changes: 2 additions & 2 deletions address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ func (c *ClientTests) TestAddressGetNextPage() {
assert.True(len(nextPage.Addresses) <= c.fixture.pageSize())

lastIDOfFirstPage := firstPage.Addresses[len(firstPage.Addresses)-1].ID
firstIdOfSecondPage := nextPage.Addresses[0].ID
firstIDOfSecondPage := nextPage.Addresses[0].ID

assert.NotEqual(lastIDOfFirstPage, firstIdOfSecondPage)
assert.NotEqual(lastIDOfFirstPage, firstIDOfSecondPage)
}
}()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (c *Client) GetAPIKeysForUserWithContext(ctx context.Context, userID string
}
}

return nil, newFilteringError(NoUserFoundForId)
return nil, newFilteringError(NoUserFoundForID)
}

// CreateAPIKey creates an API key for a child or referral customer user.
Expand Down
4 changes: 2 additions & 2 deletions api_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ func (c *ClientTests) TestApiKeysRetrieveChildUser() {
client := c.ProdClient()
assert, require := c.Assert(), c.Require()

fakeChildUserId := "user_123456789"
fakeChildUserID := "user_123456789"

apiKeys, err := client.GetAPIKeysForUser(fakeChildUserId)
apiKeys, err := client.GetAPIKeysForUser(fakeChildUserID)
require.Error(err)

assert.Nil(apiKeys)
Expand Down
14 changes: 7 additions & 7 deletions billing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ func GetBillingMockRequests() []MockRequest {
{
MatchRule: MockRequestMatchRule{
Method: "POST",
UrlRegexPattern: "v2\\/bank_accounts\\/\\S*\\/charges$",
URLRegexPattern: "v2\\/bank_accounts\\/\\S*\\/charges$",
},
ResponseInfo: MockRequestResponseInfo{
StatusCode: 200,
Expand All @@ -15,7 +15,7 @@ func GetBillingMockRequests() []MockRequest {
{
MatchRule: MockRequestMatchRule{
Method: "POST",
UrlRegexPattern: "v2\\/credit_cards\\/\\S*\\/charges$",
URLRegexPattern: "v2\\/credit_cards\\/\\S*\\/charges$",
},
ResponseInfo: MockRequestResponseInfo{
StatusCode: 200,
Expand All @@ -25,7 +25,7 @@ func GetBillingMockRequests() []MockRequest {
{
MatchRule: MockRequestMatchRule{
Method: "DELETE",
UrlRegexPattern: "v2\\/bank_accounts\\/\\S*$",
URLRegexPattern: "v2\\/bank_accounts\\/\\S*$",
},
ResponseInfo: MockRequestResponseInfo{
StatusCode: 200,
Expand All @@ -35,7 +35,7 @@ func GetBillingMockRequests() []MockRequest {
{
MatchRule: MockRequestMatchRule{
Method: "DELETE",
UrlRegexPattern: "v2\\/credit_cards\\/\\S*$",
URLRegexPattern: "v2\\/credit_cards\\/\\S*$",
},
ResponseInfo: MockRequestResponseInfo{
StatusCode: 200,
Expand All @@ -45,7 +45,7 @@ func GetBillingMockRequests() []MockRequest {
{
MatchRule: MockRequestMatchRule{
Method: "GET",
UrlRegexPattern: "v2\\/payment_methods$",
URLRegexPattern: "v2\\/payment_methods$",
},
ResponseInfo: MockRequestResponseInfo{
StatusCode: 200,
Expand Down Expand Up @@ -93,7 +93,7 @@ func (c *ClientTests) TestGetPaymentMethodInfoByObjectType() {
{
MatchRule: MockRequestMatchRule{
Method: "GET",
UrlRegexPattern: "v2\\/payment_methods$",
URLRegexPattern: "v2\\/payment_methods$",
},
ResponseInfo: MockRequestResponseInfo{
StatusCode: 200,
Expand All @@ -103,7 +103,7 @@ func (c *ClientTests) TestGetPaymentMethodInfoByObjectType() {
{
MatchRule: MockRequestMatchRule{
Method: "DELETE",
UrlRegexPattern: "v2\\/credit_cards\\/pm_123$",
URLRegexPattern: "v2\\/credit_cards\\/pm_123$",
},
ResponseInfo: MockRequestResponseInfo{
StatusCode: 200,
Expand Down
34 changes: 17 additions & 17 deletions bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func contains(elements []string, target string) bool {
return false
}

// applyCensorsToJsonList applies the censors to a JSON list.
func (c *ClientTests) applyCensorsToJsonList(list []interface{}, elementsToCensor map[string]interface{}) []interface{} {
// applyCensorsToJSONList applies the censors to a JSON list.
func (c *ClientTests) applyCensorsToJSONList(list []interface{}, elementsToCensor map[string]interface{}) []interface{} {
if len(list) == 0 {
// short circuit and return the list if it is empty
return list
Expand All @@ -64,14 +64,14 @@ func (c *ClientTests) applyCensorsToJsonList(list []interface{}, elementsToCenso
continue
}

// nolint:gosimple
// nolint:staticcheck
switch value.(type) {
case map[string]interface{}:
// value is a dictionary
list[index] = c.applyCensorsToJsonDictionary(value.(map[string]interface{}), elementsToCensor)
list[index] = c.applyCensorsToJSONDictionary(value.(map[string]interface{}), elementsToCensor)
case []map[string]interface{}:
// value is a list of dictionaries
list[index] = c.applyCensorsToJsonList(value.([]interface{}), elementsToCensor)
list[index] = c.applyCensorsToJSONList(value.([]interface{}), elementsToCensor)
default:
// value is a single value or a normal list, nothing to censor
}
Expand All @@ -80,8 +80,8 @@ func (c *ClientTests) applyCensorsToJsonList(list []interface{}, elementsToCenso
return list
}

// applyCensorsToJsonDictionary applies the censors to a JSON dictionary.
func (c *ClientTests) applyCensorsToJsonDictionary(dictionary map[string]interface{}, elementsToCensor map[string]interface{}) map[string]interface{} {
// applyCensorsToJSONDictionary applies the censors to a JSON dictionary.
func (c *ClientTests) applyCensorsToJSONDictionary(dictionary map[string]interface{}, elementsToCensor map[string]interface{}) map[string]interface{} {
if len(dictionary) == 0 {
// short circuit and return the dictionary if it is empty
return dictionary
Expand All @@ -104,14 +104,14 @@ func (c *ClientTests) applyCensorsToJsonDictionary(dictionary map[string]interfa
dictionary[key] = elementsToCensor[key]
} else {
// element doesn't need to be censored
// nolint:gosimple
// nolint:staticcheck
switch value.(type) {
case map[string]interface{}:
// value is a dictionary
dictionary[key] = c.applyCensorsToJsonDictionary(value.(map[string]interface{}), elementsToCensor)
dictionary[key] = c.applyCensorsToJSONDictionary(value.(map[string]interface{}), elementsToCensor)
case []interface{}:
// value is a list
dictionary[key] = c.applyCensorsToJsonList(value.([]interface{}), elementsToCensor)
dictionary[key] = c.applyCensorsToJSONList(value.([]interface{}), elementsToCensor)
default:
// value is a single value, nothing to censor
}
Expand All @@ -121,8 +121,8 @@ func (c *ClientTests) applyCensorsToJsonDictionary(dictionary map[string]interfa
return dictionary
}

// censorJsonData censors data in cassette files before they persist to disk
func (c *ClientTests) censorJsonData(data string, elementsToCensor map[string]interface{}) string {
// censorJSONData censors data in cassette files before they persist to disk
func (c *ClientTests) censorJSONData(data string, elementsToCensor map[string]interface{}) string {
var jsonMap map[string]interface{}
mapErr := json.Unmarshal([]byte(data), &jsonMap)
if mapErr != nil {
Expand All @@ -137,13 +137,13 @@ func (c *ClientTests) censorJsonData(data string, elementsToCensor map[string]in
}

// data is a JSON list
censoredList := c.applyCensorsToJsonList(jsonList, elementsToCensor)
censoredList := c.applyCensorsToJSONList(jsonList, elementsToCensor)
censoredListBytes, _ := json.Marshal(censoredList)
return string(censoredListBytes)
}

// data is a JSON dictionary
censoredDictionary := c.applyCensorsToJsonDictionary(jsonMap, elementsToCensor)
censoredDictionary := c.applyCensorsToJSONDictionary(jsonMap, elementsToCensor)
censoredDictionaryBytes, _ := json.Marshal(censoredDictionary)
return string(censoredDictionaryBytes)
}
Expand Down Expand Up @@ -189,7 +189,7 @@ func (c *ClientTests) SetupTest() {
return true
}
// run the request body through the same censors before comparing to the recording
bStringCensored := c.censorJsonData(bString, responseBodyElementsToCensor)
bStringCensored := c.censorJSONData(bString, responseBodyElementsToCensor)
return cassette.DefaultMatcher(r, i) && (bStringCensored == i.Body)
})

Expand All @@ -208,12 +208,12 @@ func (c *ClientTests) SetupTest() {

// Censor request data
var requestBody = i.Request.Body
var censoredRequestBody = c.censorJsonData(requestBody, responseBodyElementsToCensor)
var censoredRequestBody = c.censorJSONData(requestBody, responseBodyElementsToCensor)
i.Request.Body = censoredRequestBody

// Censor response data
var responseBody = i.Response.Body
var censoredResponseBody = c.censorJsonData(responseBody, responseBodyElementsToCensor)
var censoredResponseBody = c.censorJSONData(responseBody, responseBodyElementsToCensor)
i.Response.Body = censoredResponseBody

return nil
Expand Down
Loading
Loading