Skip to content

Some request fields are not omitted #45

@gordon2

Description

@gordon2

Description of the Bug

When you run request /estimates/update_subscription_for_items with remove discount param you end up with an error.

This happens because two of the request fields are missing 'omitempty' param in the struct UpdateSubscriptionForItemsDiscountParams

	ApplyOn       enum.ApplyOn       `json:"apply_on"`
	DurationType  enum.DurationType  `json:"duration_type"`

Steps to reproduce

run this code

chargebee.Configure("", "")

subID := "subscription-id"
discountID := "id-of-existing-discount"

_, err := estimate.UpdateSubscriptionForItems(&estimateModels.UpdateSubscriptionForItemsRequestParams{
	Subscription: &estimateModels.UpdateSubscriptionForItemsSubscriptionParams{
		Id: subID,
	},
	Discounts: []*estimateModels.UpdateSubscriptionForItemsDiscountParams{
		{
			Id:            discountID,
			OperationType: enum.OperationTypeRemove,
		},
	},
}).Request()

if err != nil {
	fmt.Println(err)
}

get the following response
{"http_status_code":400,"message":"discounts[apply_on][0] : should not be sent when operation type is REMOVE","param":"discounts[apply_on][1]","api_error_code":"invalid_request","type":"invalid_request","error_code":"param_should_not_be_sent","_":{}}

Expected Behavior

response should return 200 with estimates data

Code Snippets (if applicable)

Operating System

macOS

Language version

Go 1.24

Library version

v3.29.0

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions