Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.

Commit 0632de5

Browse files
dailycodingf2prateek
authored andcommitted
Add destination specific options (#80)
* Enable destination specific options * Add test cases for destination specific option * Add missing test function Identify for Net35
1 parent 60234c5 commit 0632de5

File tree

7 files changed

+103
-2
lines changed

7 files changed

+103
-2
lines changed

Analytics/Model/Options.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,25 @@ public Options SetIntegration (string integration, bool enabled)
7373
return this;
7474
}
7575

76+
/// <summary>
77+
/// Enable destination specific options for integration.
78+
/// For example, to send tags in https://segment.com/docs/destinations/vero/#tags, use following
79+
/// new Options()
80+
/// .Integration("Vero", new Model.Dict() {
81+
/// "tags", new Model.Dict() {
82+
/// { "id", "235FAG" },
83+
/// { "action", "add" },
84+
/// { "values", new string[] {"warriors", "giants", "niners"} }
85+
/// }
86+
/// });
87+
/// </summary>
88+
/// <param name="integration">The integration name.</param>
89+
/// <param name="value">Dict value</param>
90+
public Options SetIntegration (string integration, Dict value)
91+
{
92+
this.Integrations.Add (integration, value);
93+
return this;
94+
}
95+
7696
}
7797
}

Test.Net35/ActionTests.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using NUnit.Framework;
33
using System.Collections.Generic;
44
using System.Threading.Tasks;
@@ -24,6 +24,27 @@ public void IdentifyTestNet35()
2424
FlushAndCheck(1);
2525
}
2626

27+
[Test()]
28+
public void IdentifyWithCustomOptionsTestNet35()
29+
{
30+
var traits = new Model.Traits() {
31+
{ "email", "[email protected]" }
32+
};
33+
var options = new Model.Options()
34+
.SetIntegration("Vero", new Model.Dict() {
35+
{
36+
"tags", new Model.Dict() {
37+
{ "id", "235FAG" },
38+
{ "action", "add" },
39+
{ "values", new string[] {"warriors", "giants", "niners"} }
40+
}
41+
}
42+
});
43+
44+
Actions.Identify(Analytics.Client, traits, options);
45+
FlushAndCheck(1);
46+
}
47+
2748
[Test()]
2849
public void TrackTestNet35()
2950
{

Test.Net35/Actions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ public static void Identify(Client client)
4949
Analytics.Client.Flush();
5050
}
5151

52+
public static void Identify(Client client, Traits traits, Options options)
53+
{
54+
client.Identify("user", traits, options);
55+
Analytics.Client.Flush();
56+
}
57+
5258
public static void Group(Client client)
5359
{
5460
client.Group("user", "group", Traits(), Options());

Test.Net45/ActionTests.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using NUnit.Framework;
33
using System.Collections.Generic;
44
using System.Threading.Tasks;
@@ -24,6 +24,27 @@ public void IdentifyTestNet45()
2424
FlushAndCheck(1);
2525
}
2626

27+
[Test()]
28+
public void IdentifyWithCustomOptionsTestNet45()
29+
{
30+
var traits = new Model.Traits() {
31+
{ "email", "[email protected]" }
32+
};
33+
var options = new Model.Options()
34+
.SetIntegration("Vero", new Model.Dict() {
35+
{
36+
"tags", new Model.Dict() {
37+
{ "id", "235FAG" },
38+
{ "action", "add" },
39+
{ "values", new string[] {"warriors", "giants", "niners"} }
40+
}
41+
}
42+
});
43+
44+
Actions.Identify(Analytics.Client, traits, options);
45+
FlushAndCheck(1);
46+
}
47+
2748
[Test()]
2849
public void TrackTestNet45()
2950
{

Test.Net45/Actions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ public static void Identify(Client client)
4949
Analytics.Client.Flush();
5050
}
5151

52+
public static void Identify(Client client, Traits traits, Options options)
53+
{
54+
client.Identify("user", traits, options);
55+
Analytics.Client.Flush();
56+
}
57+
5258
public static void Group(Client client)
5359
{
5460
client.Group("user", "group", Traits(), Options());

Test/ActionTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,27 @@ public void IdentifyTest()
2424
FlushAndCheck(1);
2525
}
2626

27+
[Test()]
28+
public void IdentifyWithCustomOptionsTest()
29+
{
30+
var traits = new Model.Traits() {
31+
{ "email", "[email protected]" }
32+
};
33+
var options = new Model.Options()
34+
.SetIntegration("Vero", new Model.Dict() {
35+
{
36+
"tags", new Model.Dict() {
37+
{ "id", "235FAG" },
38+
{ "action", "add" },
39+
{ "values", new string[] {"warriors", "giants", "niners"} }
40+
}
41+
}
42+
});
43+
44+
Actions.Identify(Analytics.Client, traits, options);
45+
FlushAndCheck(1);
46+
}
47+
2748
[Test()]
2849
public void TrackTest()
2950
{

Test/Actions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ public static void Identify(Client client)
4949
Analytics.Client.Flush();
5050
}
5151

52+
public static void Identify(Client client, Traits traits, Options options)
53+
{
54+
client.Identify("user", traits, options);
55+
Analytics.Client.Flush();
56+
}
57+
5258
public static void Group(Client client)
5359
{
5460
client.Group("user", "group", Traits(), Options());

0 commit comments

Comments
 (0)