public void CanCreateChannelForSpecificCalendar() { const string callbackUrl = "https://example.com/callback"; const string calendarId = "cal_U9uuErStTG@EAAAB_IsAsykA2DBTWqQTf-f0kJw"; Http.Stub( HttpPost .Url("https://api.cronofy.com/v1/channels") .RequestHeader("Authorization", "Bearer " + AccessToken) .RequestHeader("Content-Type", "application/json; charset=utf-8") .RequestBodyFormat( "{{\"callback_url\":\"{0}\",\"filters\":{{\"calendar_ids\":[\"{1}\"]}}}}", callbackUrl, calendarId) .ResponseCode(200) .ResponseBodyFormat(@"{{ ""channel"": {{ ""channel_id"": ""chn_54cf7c7cb4ad4c1027000001"", ""callback_url"": ""{0}"", ""filters"": {{ ""calendar_ids"": [""{1}""] }} }} }}", callbackUrl, calendarId) ); var builder = new CreateChannelBuilder() .CallbackUrl(callbackUrl) .CalendarId(calendarId); var channel = Client.CreateChannel(builder); Assert.Equal( new Channel { Id = "chn_54cf7c7cb4ad4c1027000001", CallbackUrl = callbackUrl, Filters = new Channel.ChannelFilters { CalendarIds = new[] { calendarId }, }, }, channel); }
public void CanCreateChannelForOnlyManagedEvents() { const string callbackUrl = "https://example.com/callback"; Http.Stub( HttpPost .Url("https://api.cronofy.com/v1/channels") .RequestHeader("Authorization", "Bearer " + AccessToken) .RequestHeader("Content-Type", "application/json; charset=utf-8") .RequestBodyFormat("{{\"callback_url\":\"{0}\",\"filters\":{{\"only_managed\":true}}}}", callbackUrl) .ResponseCode(200) .ResponseBodyFormat(@"{{ ""channel"": {{ ""channel_id"": ""chn_54cf7c7cb4ad4c1027000001"", ""callback_url"": ""{0}"", ""filters"": {{ ""only_managed"": true }} }} }}", callbackUrl) ); var builder = new CreateChannelBuilder() .CallbackUrl(callbackUrl) .OnlyManaged(true); var channel = Client.CreateChannel(builder); Assert.Equal( new Channel { Id = "chn_54cf7c7cb4ad4c1027000001", CallbackUrl = callbackUrl, Filters = new Channel.ChannelFilters { OnlyManaged = true, }, }, channel); }
public void CanCreateChannelForOnlyManagedEvents() { const string callbackUrl = "https://example.com/callback"; Http.Stub( HttpPost .Url("https://api.cronofy.com/v1/channels") .RequestHeader("Authorization", "Bearer " + AccessToken) .RequestHeader("Content-Type", "application/json; charset=utf-8") .RequestBodyFormat("{{\"callback_url\":\"{0}\",\"filters\":{{\"only_managed\":true}}}}", callbackUrl) .ResponseCode(200) .ResponseBodyFormat(@"{{ ""channel"": {{ ""channel_id"": ""chn_54cf7c7cb4ad4c1027000001"", ""callback_url"": ""{0}"", ""filters"": {{ ""only_managed"": true }} }} }}", callbackUrl) ); var builder = new CreateChannelBuilder() .CallbackUrl(callbackUrl) .OnlyManaged(true); var channel = Client.CreateChannel(builder); Assert.AreEqual( new Channel { Id = "chn_54cf7c7cb4ad4c1027000001", CallbackUrl = callbackUrl, Filters = new Channel.ChannelFilters { OnlyManaged = true, }, }, channel); }
public static Cronofy.Channel CreateChannel(string path, bool onlyManaged, IEnumerable <string> calendarIds) { Cronofy.Channel channel = null; var builtChannel = new CreateChannelBuilder() .CallbackUrl(path) .OnlyManaged(onlyManaged) .CalendarIds(calendarIds) .Build(); try { channel = CronofyAccountRequest <Cronofy.Channel>(() => { return(AccountClient.CreateChannel(builtChannel)); }); LogHelper.Log(String.Format("CreateChannel success - path=`{0}` - onlyManaged=`{1}` - calendarIds=`{2}`", path, onlyManaged, String.Join(",", calendarIds))); } catch (CronofyException) { LogHelper.Log(String.Format("CreateChannel failure - path=`{0}` - onlyManaged=`{1}` - calendarIds=`{2}`", path, onlyManaged, String.Join(",", calendarIds))); throw; } return(channel); }
public void CanCreateChannelForSpecificCalendar() { const string callbackUrl = "https://example.com/callback"; const string calendarId = "cal_U9uuErStTG@EAAAB_IsAsykA2DBTWqQTf-f0kJw"; Http.Stub( HttpPost .Url("https://api.cronofy.com/v1/channels") .RequestHeader("Authorization", "Bearer " + AccessToken) .RequestHeader("Content-Type", "application/json; charset=utf-8") .RequestBodyFormat( "{{\"callback_url\":\"{0}\",\"filters\":{{\"calendar_ids\":[\"{1}\"]}}}}", callbackUrl, calendarId) .ResponseCode(200) .ResponseBodyFormat(@"{{ ""channel"": {{ ""channel_id"": ""chn_54cf7c7cb4ad4c1027000001"", ""callback_url"": ""{0}"", ""filters"": {{ ""calendar_ids"": [""{1}""] }} }} }}", callbackUrl, calendarId) ); var builder = new CreateChannelBuilder() .CallbackUrl(callbackUrl) .CalendarId(calendarId); var channel = Client.CreateChannel(builder); Assert.AreEqual( new Channel { Id = "chn_54cf7c7cb4ad4c1027000001", CallbackUrl = callbackUrl, Filters = new Channel.ChannelFilters { CalendarIds = new[] { calendarId }, }, }, channel); }