public void FixtureSetup() { SubscriptionServiceMock = MockRepository.GenerateStub <ISubscriptionServicePortTypeClient>(); Client = new SoapSubscriptionClient(SubscriptionServiceMock); SubscriptionId = 1; SubscriptionFilter = new CfSubscriptionSubscriptionFilter(1, 5, "fromNumber", "toNumber", true); Subscription = new CfSubscription(SubscriptionId, true, "endPoint", CfNotificationFormat.Soap, CfSubscriptionTriggerEvent.CampaignStarted, SubscriptionFilter); SubscriptionRequest = new CfSubscriptionRequest("requestId", Subscription); var notificationFormat = EnumeratedMapper.ToSoapEnumerated <NotificationFormat>(Subscription.NotificationFormat.ToString()); var triggerEvent = EnumeratedMapper.ToSoapEnumerated <SubscriptionTriggerEvent>(Subscription.TriggerEvent.ToString()); SubscriptionServiceMock.Stub(b => b.CreateSubscription( Arg <SubscriptionRequest> .Matches(x => x.RequestId == SubscriptionRequest.RequestId && x.Subscription.id == Subscription.Id && x.Subscription.Enabled == Subscription.Enabled && x.Subscription.Endpoint == Subscription.Endpoint && x.Subscription.NotificationFormat == notificationFormat && x.Subscription.TriggerEvent == triggerEvent && x.Subscription.SubscriptionFilter.BroadcastId == SubscriptionFilter.BroadcastId && x.Subscription.SubscriptionFilter.BatchId == SubscriptionFilter.BatchId && x.Subscription.SubscriptionFilter.FromNumber == SubscriptionFilter.FromNumber && x.Subscription.SubscriptionFilter.ToNumber == SubscriptionFilter.ToNumber && x.Subscription.SubscriptionFilter.Inbound == SubscriptionFilter.Inbound))) .Return(SubscriptionId); }
public void FixtureSetup() { HttpClientMock = MockRepository.GenerateMock <IHttpClient>(); Client = new RestSubscriptionClient(HttpClientMock); SubscriptionId = 1; SubscriptionFilter = new CfSubscriptionSubscriptionFilter(1, 5, "fromNumber", "toNumber", true); Subscription = new CfSubscription(SubscriptionId, true, "endPoint", CfNotificationFormat.Soap, CfSubscriptionTriggerEvent.CampaignStarted, SubscriptionFilter); SubscriptionRequest = new CfSubscriptionRequest("requestId", Subscription); var notificationFormat = EnumeratedMapper.ToSoapEnumerated <NotificationFormat>(Subscription.NotificationFormat.ToString()); var triggerEvent = EnumeratedMapper.ToSoapEnumerated <SubscriptionTriggerEvent>(Subscription.TriggerEvent.ToString()); HttpClientMock .Stub(j => j.Send(Arg <string> .Is.Equal(String.Format("/subscription/{0}", SubscriptionId)), Arg <HttpMethod> .Is.Equal(HttpMethod.Put), Arg <SubscriptionRequest> .Matches(x => x.RequestId == SubscriptionRequest.RequestId && x.Subscription.id == Subscription.Id && x.Subscription.Enabled == Subscription.Enabled && x.Subscription.Endpoint == Subscription.Endpoint && x.Subscription.NotificationFormat == notificationFormat && x.Subscription.TriggerEvent == triggerEvent && x.Subscription.SubscriptionFilter.BroadcastId == SubscriptionFilter.BroadcastId && x.Subscription.SubscriptionFilter.BatchId == SubscriptionFilter.BatchId && x.Subscription.SubscriptionFilter.FromNumber == SubscriptionFilter.FromNumber && x.Subscription.SubscriptionFilter.ToNumber == SubscriptionFilter.ToNumber && x.Subscription.SubscriptionFilter.Inbound == SubscriptionFilter.Inbound))) .Return(string.Empty); }
public void FixtureSetup() { HttpClientMock = MockRepository.GenerateMock <IHttpClient>(); Client = new RestSubscriptionClient(HttpClientMock); SubscriptionId = 14561; SubscriptionFilter = new CfSubscriptionSubscriptionFilter(1, 5, "fromNumber", "toNumber", true); Subscription = new CfSubscription(SubscriptionId, true, "endPoint", CfNotificationFormat.Soap, CfSubscriptionTriggerEvent.CampaignStarted, SubscriptionFilter); SubscriptionRequest = new CfSubscriptionRequest("requestId", Subscription); var notificationFormat = EnumeratedMapper.ToSoapEnumerated <NotificationFormat>(Subscription.NotificationFormat.ToString()); var triggerEvent = EnumeratedMapper.ToSoapEnumerated <SubscriptionTriggerEvent>(Subscription.TriggerEvent.ToString()); var response = string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<r:ResourceReference xmlns=\"http://api.callfire.com/data\" xmlns:r=\"http://api.callfire.com/resource\">" + "<r:Id>{0}</r:Id>" + "<r:Location>https://www.callfire.com/api/1.1/rest/subscription/{0}</r:Location>" + "</r:ResourceReference>", SubscriptionId); HttpClientMock .Stub(j => j.Send(Arg <string> .Is.Equal("/subscription"), Arg <HttpMethod> .Is.Equal(HttpMethod.Post), Arg <SubscriptionRequest> .Matches(x => x.RequestId == SubscriptionRequest.RequestId && x.Subscription.id == Subscription.Id && x.Subscription.Enabled == Subscription.Enabled && x.Subscription.Endpoint == Subscription.Endpoint && x.Subscription.NotificationFormat == notificationFormat && x.Subscription.TriggerEvent == triggerEvent && x.Subscription.SubscriptionFilter.BroadcastId == SubscriptionFilter.BroadcastId && x.Subscription.SubscriptionFilter.BatchId == SubscriptionFilter.BatchId && x.Subscription.SubscriptionFilter.FromNumber == SubscriptionFilter.FromNumber && x.Subscription.SubscriptionFilter.ToNumber == SubscriptionFilter.ToNumber && x.Subscription.SubscriptionFilter.Inbound == SubscriptionFilter.Inbound))) .Return(response); }
public long CreateSubscription(CfSubscriptionRequest cfCreateSubscription) { var subscriptionRequest = new SubscriptionRequest(cfCreateSubscription.RequestId, SubscriptionMapper.ToSoapSubscription(cfCreateSubscription.Subscription)); var resource = BaseRequest <ResourceReference>(HttpMethod.Post, subscriptionRequest, new CallfireRestRoute <Subscription>()); return(resource.Id); }
public void Test_UpdateSubscriptionEmpty() { var subscriptionRequest = new CfSubscriptionRequest { Subscription = new CfSubscription() }; AssertClientException <WebException, FaultException>(() => Client.UpdateSubscription(subscriptionRequest)); }
public void UpdateSubscription(CfSubscriptionRequest cfUpdateSubscription) { var subscription = cfUpdateSubscription.Subscription; if (subscription == null) { return; } var subscriptionRequest = new SubscriptionRequest(cfUpdateSubscription.RequestId, SubscriptionMapper.ToSoapSubscription(subscription)); BaseRequest <string>(HttpMethod.Put, subscriptionRequest, new CallfireRestRoute <Subscription>(subscription.Id)); }
public void Test_CreateSubscriptionEndpointID() { var subscriptionRequest = new CfSubscriptionRequest { Subscription = new CfSubscription { Endpoint = "*****@*****.**", TriggerEvent = CfSubscriptionTriggerEvent.CampaignStarted } }; var id = Client.CreateSubscription(subscriptionRequest); Assert.IsNotNull(id); }
public void Test_DeleteSubscriptionComplete() { var subscriptionRequest = new CfSubscriptionRequest { Subscription = new CfSubscription { Endpoint = "*****@*****.**", TriggerEvent = CfSubscriptionTriggerEvent.OutboundTextFinished, NotificationFormat = CfNotificationFormat.Email, Enabled = true, } }; var id = Client.CreateSubscription(subscriptionRequest); Client.DeleteSubscription(id); }
public void Test_UpdateSubscriptionFalse() { var subscriptionRequest = new CfSubscriptionRequest { Subscription = new CfSubscription { Endpoint = "*****@*****.**", TriggerEvent = CfSubscriptionTriggerEvent.OutboundTextFinished, NotificationFormat = CfNotificationFormat.Email, Enabled = true, SubscriptionFilter = new CfSubscriptionSubscriptionFilter { FromNumber = VerifyShortCode, Inbound = true, BroadcastId = 1903388001, ToNumber = VerifyFromNumber } } }; var id = Client.CreateSubscription(subscriptionRequest); var updateSubscriptionRequest = new CfSubscriptionRequest { Subscription = new CfSubscription { Id = id, Enabled = false, NotificationFormat = CfNotificationFormat.Soap, TriggerEvent = CfSubscriptionTriggerEvent.CampaignStarted, SubscriptionFilter = new CfSubscriptionSubscriptionFilter { FromNumber = VerifyFromNumber, Inbound = false } } }; Client.UpdateSubscription(updateSubscriptionRequest); var subscription = Client.GetSubscription(id); Assert.AreEqual(false, subscription.Enabled); Assert.AreEqual(CfNotificationFormat.Soap, subscription.NotificationFormat); Assert.AreEqual(CfSubscriptionTriggerEvent.CampaignStarted, subscription.TriggerEvent); Assert.AreEqual(VerifyFromNumber, subscription.SubscriptionFilter.FromNumber); }
public void FixtureSetup() { Client = new RestSubscriptionClient(MockClient.User(), MockClient.Password()); var subscriptionFilter = new CfSubscriptionSubscriptionFilter(1, 5, "fromNumber", "toNumber", true); CfSubscription = new CfSubscription(1, true, "endPoint", CfNotificationFormat.Soap, CfSubscriptionTriggerEvent.CampaignStarted, subscriptionFilter); CfSubscriptionRequest = new CfSubscriptionRequest("", CfSubscription); QuerySubscription = new CfQuery(); var subscription = new CfSubscription(140553001, true, "endPoint", CfNotificationFormat.Soap, CfSubscriptionTriggerEvent.CampaignStopped, subscriptionFilter); CfUpdateSubscription = new CfSubscriptionRequest("", subscription); }
public void Test_CreateSubscriptionCompleteFalse() { var subscriptionRequest = new CfSubscriptionRequest { Subscription = new CfSubscription { Endpoint = "*****@*****.**", TriggerEvent = CfSubscriptionTriggerEvent.OutboundTextFinished, NotificationFormat = CfNotificationFormat.Email, Enabled = false, SubscriptionFilter = new CfSubscriptionSubscriptionFilter { FromNumber = VerifyShortCode, Inbound = false, BroadcastId = 1903388001, ToNumber = VerifyFromNumber } } }; var id = Client.CreateSubscription(subscriptionRequest); Assert.IsNotNull(id); }
public void UpdateSubscription(CfSubscriptionRequest cfUpdateSubscription) { var subscription = SubscriptionMapper.ToSoapSubscription(cfUpdateSubscription.Subscription); SubscriptionService.UpdateSubscription(new SubscriptionRequest(cfUpdateSubscription.RequestId, subscription)); }
public long CreateSubscription(CfSubscriptionRequest cfCreateSubscription) { return(SubscriptionService.CreateSubscription(new SubscriptionRequest(cfCreateSubscription.RequestId, SubscriptionMapper.ToSoapSubscription(cfCreateSubscription.Subscription)))); }