Skip to content

Instantly share code, notes, and snippets.

@JIntrocaso
Last active Sep 21, 2020
Embed
What would you like to do?
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