Skip to content

Commit

Permalink
Update generated code for v982
Browse files Browse the repository at this point in the history
  • Loading branch information
stripe-openapi[bot] committed Apr 23, 2024
1 parent d56a355 commit b331dd6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v981
v982
4 changes: 2 additions & 2 deletions entitlements_activeentitlement.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func (p *EntitlementsActiveEntitlementParams) AddExpand(f string) {
// An active entitlement describes access to a feature for a customer.
type EntitlementsActiveEntitlement struct {
APIResource
// The feature that the customer is entitled to.
Feature string `json:"feature"`
// The [Feature](https://stripe.com/docs/api/entitlements/feature) that the customer is entitled to.
Feature *EntitlementsFeature `json:"feature"`
// Unique identifier for the object.
ID string `json:"id"`
// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
Expand Down
21 changes: 21 additions & 0 deletions entitlements_feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package stripe

import "encoding/json"

// Retrieve a list of features
type EntitlementsFeatureListParams struct {
ListParams `form:"*"`
Expand Down Expand Up @@ -73,3 +75,22 @@ type EntitlementsFeatureList struct {
ListMeta
Data []*EntitlementsFeature `json:"data"`
}

// UnmarshalJSON handles deserialization of an EntitlementsFeature.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (e *EntitlementsFeature) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
e.ID = id
return nil
}

type entitlementsFeature EntitlementsFeature
var v entitlementsFeature
if err := json.Unmarshal(data, &v); err != nil {
return err
}

*e = EntitlementsFeature(v)
return nil
}

0 comments on commit b331dd6

Please sign in to comment.