-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from seatsio/bver/add-channels-endpoints
Add channels support
- Loading branch information
Showing
5 changed files
with
164 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using SeatsioDotNet.Events; | ||
using Xunit; | ||
|
||
|
||
namespace SeatsioDotNet.Test.Events | ||
{ | ||
public class AssignObjectsToChannelTest : SeatsioClientTest | ||
{ | ||
|
||
[Fact] | ||
public void assignObjectsToChannel() { | ||
var chartKey1 = CreateTestChart(); | ||
var event1 = Client.Events.Create(chartKey1); | ||
var channels = new Dictionary<string, Channel>() | ||
{ | ||
{ "channelKey1", new Channel("channel 1", "#FFFF00", 1) }, | ||
{ "channelKey2", new Channel("channel 2", "#00FFFF", 2) } | ||
}; | ||
Client.Events.UpdateChannels(event1.Key, channels); | ||
|
||
Client.Events.AssignObjectsToChannel(event1.Key, new | ||
{ | ||
channelKey1 = new [] {"A-1", "A-2"}, | ||
channelKey2 = new [] {"A-3"}, | ||
}); | ||
|
||
var retrievedChannels = Client.Events.Retrieve(event1.Key).Channels; | ||
Assert.Equal(new [] {"A-1", "A-2"}, retrievedChannels[0].Objects); | ||
Assert.Equal(new [] {"A-3"}, retrievedChannels[1].Objects); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using SeatsioDotNet.Events; | ||
using Xunit; | ||
|
||
|
||
namespace SeatsioDotNet.Test.Events | ||
{ | ||
public class UpdateChannelsTest : SeatsioClientTest | ||
{ | ||
|
||
[Fact] | ||
public void UpdateChannels() { | ||
var chartKey1 = CreateTestChart(); | ||
var event1 = Client.Events.Create(chartKey1); | ||
|
||
var channels = new Dictionary<string, Channel>() | ||
{ | ||
{ "channelKey1", new Channel("channel 1", "#FFFF00", 1) }, | ||
{ "channelKey2", new Channel("channel 2", "#00FFFF", 2) } | ||
}; | ||
|
||
Client.Events.UpdateChannels(event1.Key, channels); | ||
|
||
var retrievedEvent = Client.Events.Retrieve(event1.Key); | ||
Assert.Equal(2, retrievedEvent.Channels.Count); | ||
|
||
var channel1 = retrievedEvent.Channels[0]; | ||
Assert.Equal("channelKey1", channel1.Key); | ||
Assert.Equal("channel 1", channel1.Name); | ||
Assert.Equal("#FFFF00", channel1.Color); | ||
Assert.Equal(1, channel1.Index); | ||
Assert.Empty(channel1.Objects); | ||
|
||
|
||
var channel2 = retrievedEvent.Channels[1]; | ||
Assert.Equal("channelKey2", channel2.Key); | ||
Assert.Equal("channel 2", channel2.Name); | ||
Assert.Equal("#00FFFF", channel2.Color); | ||
Assert.Equal(2, channel2.Index); | ||
Assert.Empty(channel1.Objects); | ||
} | ||
|
||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using RestSharp.Deserializers; | ||
|
||
namespace SeatsioDotNet.Events | ||
{ | ||
public class Channel | ||
{ | ||
public string Key { get; set; } | ||
public string Name { get; set; } | ||
public string Color { get; set; } | ||
public int Index { get; set; } | ||
public IEnumerable<string> Objects { get; set; } | ||
|
||
public Channel() {} | ||
|
||
public Channel(string name, string color, int index) | ||
{ | ||
Name = name; | ||
Color = color; | ||
Index = index; | ||
} | ||
|
||
public object AsJsonObject() | ||
{ | ||
return new | ||
{ | ||
name = Name, | ||
index = Index, | ||
color = Color | ||
}; | ||
} | ||
|
||
} | ||
} |
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
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