gochimp3 icon indicating copy to clipboard operation
gochimp3 copied to clipboard

make CampaignCreationSegmentOptions fields omitempty

Open njason opened this issue 1 year ago • 1 comments

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 avatar Sep 07 '24 20:09 njason

@zeekay @bradleyfalk @tw1nk @Rishub21

Can someone please review?

njason avatar Oct 30 '24 03:10 njason

Looks good, thanks for your contribution!

zeekay avatar Nov 27 '24 05:11 zeekay