-
-
Save JIntrocaso/77ba0cb8fa369bbea3cf39d968a48dfc to your computer and use it in GitHub Desktop.
Add Contact To Campaign
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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