diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 4db457fa8d..735a5bbc23 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v981 \ No newline at end of file +v982 \ No newline at end of file diff --git a/entitlements_activeentitlement.go b/entitlements_activeentitlement.go index 6d33d78353..43cad64601 100644 --- a/entitlements_activeentitlement.go +++ b/entitlements_activeentitlement.go @@ -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. diff --git a/entitlements_feature.go b/entitlements_feature.go index 8466ecf96e..277cd601aa 100644 --- a/entitlements_feature.go +++ b/entitlements_feature.go @@ -6,6 +6,8 @@ package stripe +import "encoding/json" + // Retrieve a list of features type EntitlementsFeatureListParams struct { ListParams `form:"*"` @@ -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 +}