Skip to content

Commit

Permalink
feat(commerce): feature inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
benhowdle89 committed Dec 11, 2024
1 parent a619b74 commit 46255f3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
13 changes: 13 additions & 0 deletions commerce.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type CommercePlanFeature struct {
UpdatedAt string `json:"updated_at"`
}

type CommercePlanFeatureList PaginatedList[CommercePlanFeature]

type CommerceFeature struct {
APIResource
ID string `json:"id"`
Expand Down Expand Up @@ -102,6 +104,12 @@ type CreatePlanFeatureParams struct {
FeatureID string `json:"feature_id"`
}

type CreateMultiplePlanFeaturesParams struct {
APIParams
PlanID string `json:"plan_id"`
FeatureIDs []string `json:"feature_ids"`
}

type DeletePlanFeatureParams struct {
APIParams
FeatureID string `json:"feature_id"`
Expand All @@ -127,6 +135,11 @@ type CreateFeatureParams struct {
UnitPricing []CommerceFeatureUnitPricing `json:"unit_pricing"`
}

type CreateMultipleFeaturesParams struct {
APIParams
Features []CreateFeatureParams `json:"features"`
}

type UpdateFeatureParams struct {
APIParams
ID string `json:"id"`
Expand Down
6 changes: 3 additions & 3 deletions commerce/features/api.go

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

8 changes: 4 additions & 4 deletions commerce/features/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ func NewClient(config *clerk.ClientConfig) *Client {
}
}

func (c *Client) Create(ctx context.Context, params *clerk.CreateFeatureParams) (*clerk.CommerceFeature, error) {
func (c *Client) Create(ctx context.Context, params *clerk.CreateMultipleFeaturesParams) (*clerk.CommerceFeatureList, error) {
reqPath, err := clerk.JoinPath(rootPath, path)
if err != nil {
return nil, err
}
req := clerk.NewAPIRequest(http.MethodPost, reqPath)
req.SetParams(params)
resource := &clerk.CommerceFeature{}
resource := &clerk.CommerceFeatureList{}
err = c.Backend.Call(ctx, req, resource)
return resource, err
}

func (c *Client) CreatePlanFeature(ctx context.Context, params *clerk.CreatePlanFeatureParams) (*clerk.CommercePlanFeature, error) {
func (c *Client) CreatePlanFeatures(ctx context.Context, params *clerk.CreateMultiplePlanFeaturesParams) (*clerk.CommercePlanFeatureList, error) {
reqPath, err := clerk.JoinPath(rootPath, "plans", params.PlanID, path)
if err != nil {
return nil, err
}
req := clerk.NewAPIRequest(http.MethodPost, reqPath)
req.SetParams(params)
resource := &clerk.CommercePlanFeature{}
resource := &clerk.CommercePlanFeatureList{}
err = c.Backend.Call(ctx, req, resource)
return resource, err
}
Expand Down

0 comments on commit 46255f3

Please sign in to comment.