Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make CampaignCreationSegmentOptions fields omitempty #65

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

njason
Copy link
Contributor

@njason njason commented Sep 7, 2024

recipients.segment_opts in MailChimp API docs is optional, hence I have modified the CampaignCreationSegmentOptions struct accordingly.

I did not like the solution in #53 and #60 which makes SegmentOptions a pointer because it is breaking change. However that is the only way to use the omitempty tag on a struct field.

My solution is to instead place omitempty on all the fields within the struct. When the CampaignCreationRecipients is JSON marshalled and SegmentOptions is not provided, it will generate "segment_opts": {} which behaves the same at it being omitted in the MailChimp API. This solution also does not break existing usage.

@njason
Copy link
Contributor Author

njason commented Oct 30, 2024

@zeekay @bradleyfalk @tw1nk @Rishub21

Can someone please review?

@zeekay zeekay merged commit 6051f77 into hanzoai:master Nov 27, 2024
@zeekay
Copy link
Member

zeekay commented Nov 27, 2024

Looks good, thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants