Skip to content

Commit

Permalink
Merge pull request #72 from plivo/trackable_message_option
Browse files Browse the repository at this point in the history
optional trackable field added
  • Loading branch information
Abhishek-plivo authored Oct 1, 2018
2 parents e5eb852 + 627477f commit 23ae79f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
51 changes: 46 additions & 5 deletions src/Plivo/Resource/Message/MessageInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ public MessageInterface(HttpClient client) : base(client)
/// <param name="url">URL.</param>
/// <param name="method">Method.</param>
/// <param name="log">Log.</param>
/// <param name="trackable">trackable.</param>
/// <param name="powerpackUUID">powerpackUUID</param>
public MessageCreateResponse Create(
string src, List<string> dst, string text, string type = null,
string url = null, string method = null, bool? log = null)
List<string> dst, string text, string src = null, string type = null,
string url = null, string method = null, bool? log = null, bool? trackable = null, string powerpack_uuid = null)
{

string _dst = string.Join("<", dst);
var data = (dynamic)null;
var mandatoryParams = new List<string> {""};
var data = CreateData(
if (src != null && powerpack_uuid == null){
data = CreateData(
mandatoryParams,
new
{
Expand All @@ -48,11 +53,47 @@ public MessageCreateResponse Create(
type,
url,
method,
log
log,
trackable
});
} else if (powerpack_uuid != null && src == null){
data = CreateData(
mandatoryParams,
new
{
powerpack_uuid,
_dst,
text,
type,
url,
method,
log,
trackable
});


} else if ( src != null && powerpack_uuid != null){
return getResponseValidation ("Both powerpack_uuid and src cannot be specified. Specify either powerpack_uuid or src in request params to send a message.") ;
} else if (src == null && powerpack_uuid == null){
return getResponseValidation("Specify either powerpack_uuid or src in request params to send a message.");
}
return Client.Update<MessageCreateResponse>(Uri, data).Object;
}

/// <summary>
/// validation for src and powerpack id and return the repsonse.
/// </summary>
/// <returns>The get.</returns>
/// <param name="errormessagetext">errormessagetext</param>
private MessageCreateResponse getResponseValidation(string errorMessageText){

MessageCreateResponse notValidResponse = new MessageCreateResponse();
notValidResponse.ApiId = null;
notValidResponse.Message = errorMessageText;
notValidResponse.MessageUuid = new List<string>();
return notValidResponse;
}

/// <summary>
/// Get Message with the specified messageUuid.
/// </summary>
Expand Down Expand Up @@ -123,4 +164,4 @@ public ListResponse<Message> List(
return resources;
}
}
}
}
4 changes: 2 additions & 2 deletions tests/Plivo.Test/Resources/TestMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public void TestMessageCreate()
Assert.IsEmpty(
ComparisonUtilities.Compare(
response,
Api.Message.Create("+919999999999", new List<string>() {"+919898989898", "+919090909090"},
"textext")));
Api.Message.Create( new List<string>() {"+919898989898", "+919090909090"},
"textext", "+919999999999")));
AssertRequest(request);
}

Expand Down
4 changes: 2 additions & 2 deletions tests_netcore/Plivo.NetCore.Test/Resources/TestMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public void TestMessageCreate()
Assert.Empty(
ComparisonUtilities.Compare(
response,
Api.Message.Create("+919999999999", new List<string>() {"+919898989898", "+919090909090"},
"textext")));
Api.Message.Create(src:"+919999999999", dst:new List<string>() {"+919898989898", "+919090909090"},
text:"textext")));
AssertRequest(request);
}

Expand Down

0 comments on commit 23ae79f

Please sign in to comment.