コード例 #1
0
        /// <summary>
        /// Limited to campaigns containing emails and segments
        /// </summary>
        public Campaign CreateCampaign(int emailId, int segmentId)
        {
            CampaignEmail campaignEmail = _elementHelper.GetCampaignEmail(emailId, -101);
            CampaignSegment campaignSegment = _elementHelper.GetCampaignSegment(segmentId, -100, -101);

            Campaign campaign = new Campaign
                                    {
                                        name = "sample campaign",
                                        campaignType = "sample",
                                        type = "Campaign",
                                        startAt = ConvertToUnixEpoch(DateTime.Now),
                                        endAt = ConvertToUnixEpoch(DateTime.Today.AddDays(1)),
                                        elements = new List<CampaignElement>
                                                       {
                                                           campaignSegment,
                                                           campaignEmail
                                                       }
                                    };

            RestRequest request = new RestRequest(Method.POST)
                                      {
                                          Resource = "/assets/campaign",
                                          RequestFormat = DataFormat.Json
                                      };
            request.AddBody(campaign);

            IRestResponse<Campaign> response = _client.Execute<Campaign>(request);

            return response.Data;
        }
コード例 #2
0
        /// <summary>
        /// Limited to campaigns containing emails and segments
        /// </summary>
        public Campaign UpdateCampaign(Campaign campaign)
        {
            RestRequest request = new RestRequest(Method.PUT)
            {
                Resource = string.Format("/assets/campaign/{0}", campaign.id),
                RequestFormat = DataFormat.Json
            };
            request.AddBody(campaign);

            IRestResponse<Campaign> response = _client.Execute<Campaign>(request);

            return response.Data;
        }