Skip to content

Instantly share code, notes, and snippets.

@JIntrocaso
Last active September 21, 2020 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JIntrocaso/77ba0cb8fa369bbea3cf39d968a48dfc to your computer and use it in GitHub Desktop.
Save JIntrocaso/77ba0cb8fa369bbea3cf39d968a48dfc to your computer and use it in GitHub Desktop.
Add Contact To Campaign
public addContactToCampaign(contactResponse: any): Observable<any> {
return this.getCampaignData()
.pipe(
flatMap(response => {
this.campaign = response;
let contactsList = this.campaign.signup_list ? this.campaign.signup_list.map(l => l._id).join() + ',' + contactResponse.object._id : contactResponse.object._id;
let objects = this.campaign.signup_list ? this.campaign.signup_list.push(contactResponse) : contactResponse;
let postBody = {
slug: this.campaign.slug,
metafields: [
{
type: 'objects',
key: 'signup_list',
title: 'Signup List',
value: contactsList
}
],
write_key: config.writeKey
};
return this.http.patch(`${this.cosmicUrl}${this.bucketSlug}/edit-object-metafields`, postBody);
})
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment