Skip to content

Replace Dictionary.Add with Item property so that parameters may be o… #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Telesign.Example/PhoneId/Addons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ static void Main(string[] args)

string phoneNumber = "phone_number";

Dictionary<string, object> contact = new Dictionary<string, object>();
contact.Add("contact", new Dictionary<string, object>());
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("addons", contact);
Dictionary<string, object> parameters = new Dictionary<string, object>()
{
{ "addons", new List<string>() { "contact" } },
};

try
{
PhoneIdClient phoneIdClient = new PhoneIdClient(customerId, apiKey);
Expand Down
8 changes: 4 additions & 4 deletions Telesign.Test/RestClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void TestRestClientPost()
{
string testResource = "/test/resource";
Dictionary<string, string> testParams = new Dictionary<string, string>();
testParams.Add("test", "123_\u03ff_test");
testParams["test"] = "123_\u03ff_test";

RestClient client = new RestClient(this.customerId,
this.apiKey,
Expand Down Expand Up @@ -217,7 +217,7 @@ public void TestRestClientGet()
{
string testResource = "/test/resource";
Dictionary<string, string> testParams = new Dictionary<string, string>();
testParams.Add("test", "123_\u03ff_test");
testParams["test"] = "123_\u03ff_test";

RestClient client = new RestClient(this.customerId,
this.apiKey,
Expand Down Expand Up @@ -247,7 +247,7 @@ public void TestRestClientPut()
{
string testResource = "/test/resource";
Dictionary<string, string> testParams = new Dictionary<string, string>();
testParams.Add("test", "123_\u03ff_test");
testParams["test"] = "123_\u03ff_test";

RestClient client = new RestClient(this.customerId,
this.apiKey,
Expand Down Expand Up @@ -277,7 +277,7 @@ public void TestRestClientDelete()
{
string testResource = "/test/resource";
Dictionary<string, string> testParams = new Dictionary<string, string>();
testParams.Add("test", "123_\u03ff_test");
testParams["test"] = "123_\u03ff_test";

RestClient client = new RestClient(this.customerId,
this.apiKey,
Expand Down
6 changes: 3 additions & 3 deletions Telesign/MessagingClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public TelesignResponse Message(string phoneNumber, string message, string messa
if (null == parameters)
parameters = new Dictionary<string, string>();

parameters.Add("phone_number", phoneNumber);
parameters.Add("message", message);
parameters.Add("message_type", messageType);
parameters["phone_number"] = phoneNumber;
parameters["message"] = message;
parameters["message_type"] = messageType;

return Post(MESSAGING_RESOURCE, parameters);
}
Expand Down
2 changes: 1 addition & 1 deletion Telesign/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Telesign")]
[assembly: AssemblyProduct("Telesign")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
12 changes: 6 additions & 6 deletions Telesign/RestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ public static Dictionary<string, string> GenerateTelesignHeaders(string customer

Dictionary<string, string> headers = new Dictionary<string, string>();

headers.Add("Authorization", authorization);
headers.Add("Date", dateRfc2616);
headers.Add("Content-Type", contentType);
headers.Add("x-ts-auth-method", authMethod);
headers.Add("x-ts-nonce", nonce);
headers["Authorization"] = authorization;
headers["Date"] = dateRfc2616;
headers["Content-Type"] = contentType;
headers["x-ts-auth-method"] = authMethod;
headers["x-ts-nonce"] = nonce;

if (userAgent != null)
{
headers.Add("User-Agent", userAgent);
headers["User-Agent"] = userAgent;
}

return headers;
Expand Down
4 changes: 2 additions & 2 deletions Telesign/ScoreClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public TelesignResponse Score(string phoneNumber, string accountLifecycleEvent,
{
if (null == scoreParams)
scoreParams = new Dictionary<string, string>();
scoreParams.Add("phone_number", phoneNumber);
scoreParams.Add("account_lifecycle_event", accountLifecycleEvent);
scoreParams["phone_number"] = phoneNumber;
scoreParams["account_lifecycle_event"] = accountLifecycleEvent;

string resource = string.Format(SCORE_RESOURCE, phoneNumber);

Expand Down
3 changes: 3 additions & 0 deletions Telesign/Telesign.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<Version>2.2.2</Version>
<Authors>TeleSign</Authors>
<Company>TeleSign</Company>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
8 changes: 4 additions & 4 deletions Telesign/VoiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public TelesignResponse Call(string phoneNumber, string message, string messageT
if (null == callParams)
callParams = new Dictionary<string, string>();

callParams.Add("phone_number", phoneNumber);
callParams.Add("message", message);
callParams.Add("message_type", messageType);
callParams["phone_number"] = phoneNumber;
callParams["message"] = message;
callParams["message_type"] = messageType;

return Post(VOICE_RESOURCE, callParams);
}
Expand All @@ -68,7 +68,7 @@ public TelesignResponse Status(string referenceId, Dictionary<string, string> st
{
if (null == statusParams)
statusParams = new Dictionary<string, string>();
statusParams.Add("reference_id", referenceId);
statusParams["reference_id"] = referenceId;

string resource = string.Format(VOICE_STATUS_RESOURCE, referenceId);

Expand Down