Skip to content

Commit

Permalink
Merge pull request #106 from plivo/AddStatuscode_response
Browse files Browse the repository at this point in the history
Add statuscode response
  • Loading branch information
nixonsam authored Jul 18, 2019
2 parents 053107b + d7914d7 commit 7ac5e28
Show file tree
Hide file tree
Showing 270 changed files with 1,339 additions and 1,014 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# Change Log

## [v4.4.2](https://github.com/plivo/plivo-dotnet/tree/v4.4.2) (2019-07-18)
- Add Status Code in API responses.

## [v4.4.1](https://github.com/plivo/plivo-dotnet/tree/v4.4.1) (2019-06-12)
- Add AggregateException Flattening

Expand Down
Empty file modified src/Plivo/Authentication/BasicAuth.cs
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions src/Plivo/Client/HttpClient.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public async Task<PlivoResponse<T>> Fetch<T>(string uri, Dictionary<string, obje
where T : new()
{
return await _client.SendRequest<T>("GET", uri, data ?? new Dictionary<string, object>());

}

/// <summary>
Expand Down
Empty file modified src/Plivo/Client/IHttpClient.cs
100644 → 100755
Empty file.
Empty file modified src/Plivo/Client/SystemHttpClient.cs
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/Plivo/Exception/PlivoAuthenticationException.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Plivo.Exception
{
public class PlivoAuthenticationException : PlivoRestException
{
public PlivoAuthenticationException(string message) : base(message)
public PlivoAuthenticationException(string message, uint statusCode = 401) : base(message, statusCode)
{
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Plivo/Exception/PlivoNotFoundException.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ namespace Plivo.Exception
{
public class PlivoNotFoundException : PlivoRestException
{
public PlivoNotFoundException(string message) : base(message)
public PlivoNotFoundException(string message, uint statusCode = 404) : base(message, statusCode)
{

}
}
}
2 changes: 1 addition & 1 deletion src/Plivo/Exception/PlivoRequestException.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Plivo.Exception
{
public class PlivoRequestException : PlivoRestException
{
public PlivoRequestException(string message) : base(message)
public PlivoRequestException(string message, uint statusCode = 405) : base(message, statusCode)
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Plivo/Exception/PlivoResponseException.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class PlivoResponseException : PlivoRestException
/// Initializes a new instance of the <see cref="T:plivo.Exception.PlivoResponseException"/> class.
/// </summary>
/// <param name="message">Message.</param>
public PlivoResponseException(string message) : base(message)
public PlivoResponseException(string message, uint statusCode=0) : base(message, statusCode)
{
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Plivo/Exception/PlivoRestException.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
{
public class PlivoRestException : System.Exception
{
public PlivoRestException(string message) : base(message)
public uint StatusCode { get; set; }

public PlivoRestException(string message, uint statusCode) : base(message)
{
this.StatusCode = statusCode;
}
}
}
2 changes: 1 addition & 1 deletion src/Plivo/Exception/PlivoServerException.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Plivo.Exception
{
public class PlivoServerException : PlivoRestException
{
public PlivoServerException(string message) : base(message)
public PlivoServerException(string message, uint statusCode = 500) : base(message, statusCode)
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Plivo/Exception/PlivoValidationException.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Plivo.Exception
{
public class PlivoValidationException : PlivoRestException
{
public PlivoValidationException(string message) : base(message)
public PlivoValidationException(string message, uint statusCode = 400) : base(message, statusCode)
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Plivo/Exception/PlivoXMLException.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Plivo.Exception
{
public class PlivoXMLException : PlivoRestException
{
public PlivoXMLException(string message) : base(message)
public PlivoXMLException(string message, uint statusCode = 400) : base(message, statusCode)
{
}
}
Expand Down
Empty file modified src/Plivo/Http/PlivoRequest.cs
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion src/Plivo/Http/PlivoResponse.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public PlivoResponse(uint statusCode, List<string> headers, string content, T ob
Object = obj;
PlivoRequest = request;


HandleResponse();
}

Expand Down Expand Up @@ -95,7 +96,7 @@ private void ThrowException(string message)
case 500:
throw new PlivoServerException(message);
default:
throw new PlivoRestException(message);
throw new PlivoRestException(message, StatusCode);
}
}

Expand Down
Empty file modified src/Plivo/PhloApi.cs
100644 → 100755
Empty file.
73 changes: 37 additions & 36 deletions src/Plivo/Plivo.csproj
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard1.3</TargetFrameworks>
<ReleaseVersion>4.4.1</ReleaseVersion>
<Version></Version>
<Authors>Plivo SDKs Team</Authors>
<Owners>Plivo Inc.</Owners>
<Summary>A .NET SDK to make voice calls &amp; send SMS using Plivo and to generate Plivo XML</Summary>
<Title>Plivo</Title>
<Description>A .NET SDK to make voice calls &amp; send SMS using Plivo and to generate Plivo XML</Description>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>NETCORE;NETSTANDARD;NETSTANDARD2_0</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3'">
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<DefineConstants>NETSTANDARD1_3</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<NoStdLib>false</NoStdLib>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<NoStdLib>false</NoStdLib>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
<PackageReference Include="NuGet.Build.Packaging" Version="0.1.276" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resource\Address\" />
<Folder Include="Resource\Identity\" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard1.3</TargetFrameworks>
<ReleaseVersion>4.4.2</ReleaseVersion>
<Version />
<Authors>Plivo SDKs Team</Authors>
<Owners>Plivo Inc.</Owners>
<Summary>A .NET SDK to make voice calls &amp; send SMS using Plivo and to generate Plivo XML</Summary>
<Title>Plivo</Title>
<Description>A .NET SDK to make voice calls &amp; send SMS using Plivo and to generate Plivo XML</Description>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>NETCORE;NETSTANDARD;NETSTANDARD2_0</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3'">
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<DefineConstants>NETSTANDARD1_3</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<NoStdLib>false</NoStdLib>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<NoStdLib>false</NoStdLib>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
<PackageReference Include="NuGet.Build.Packaging" Version="0.1.276" />

</ItemGroup>
<ItemGroup>
<Folder Include="Resource\Address\" />
<Folder Include="Resource\Identity\" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions src/Plivo/Plivo.nuspec
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<projectUrl>http://github.com/plivo/plivo-dotnet</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>
* 4.4.2 Add Status Code in API responses
* 4.4.1 Add AggregateException Flattening
* 4.4.0 Add PHLO support and Multi-party call triggers
* 4.3.0-beta1 Add PHLO support and Multi-party call triggers in beta release
Expand Down
Empty file modified src/Plivo/PlivoApi.cs
100644 → 100755
Empty file.
13 changes: 10 additions & 3 deletions src/Plivo/Resource/Account/Account.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Plivo.Resource.Account
/// <summary>
/// Account.
/// </summary>

public class Account : Resource
{
/// <summary>
Expand Down Expand Up @@ -81,6 +82,7 @@ public class Account : Resource
/// <value>The timezone.</value>
public string Timezone { get; set; }



// public Account(string accountType, string address, string authId, bool autoRecharge, string billingMode,
// string cashCredits, string city, string name, string resourceUri, string state, string timezone)
Expand All @@ -106,12 +108,15 @@ public class Account : Resource
/// <param name="name">Name.</param>
/// <param name="city">City.</param>
/// <param name="address">Address.</param>
public UpdateResponse<Account> Update(string name = null, string city = null, string address = null)
/// <param state="state">State.</param>

public UpdateResponse<Account> Update(string name = null, string city = null, string address = null, string state=null)
{
var updateResponse = ((AccountInterface) Interface).Update(name, city, address);
var updateResponse = ((AccountInterface) Interface).Update(name, city, address, state);
if (name != null) Name = name;
if (city != null) City = city;
if (address != null) Address = address;
if (state != null) State = state;
return updateResponse;
}
/// <summary>
Expand All @@ -121,12 +126,14 @@ public UpdateResponse<Account> Update(string name = null, string city = null, st
/// <param name="name">Name.</param>
/// <param name="city">City.</param>
/// <param name="address">Address.</param>
public async Task<UpdateResponse<Account>> UpdateAsync(string name = null, string city = null, string address = null)
/// <param name="state">State.</param>
public async Task<UpdateResponse<Account>> UpdateAsync(string name = null, string city = null, string address = null, string state = null)
{
var updateResponse = await ((AccountInterface)Interface).UpdateAsync(name, city, address);
if (name != null) Name = name;
if (city != null) City = city;
if (address != null) Address = address;
if (state != null) State = state;
return updateResponse;
}
#endregion
Expand Down
46 changes: 25 additions & 21 deletions src/Plivo/Resource/Account/AccountInterface.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Account Get()
{
var account = Task.Run(async () => await GetResource<Account>("").ConfigureAwait(false)).Result;
account.Interface = this;
return account;
return account;
});
}
/// <summary>
Expand All @@ -44,40 +44,44 @@ public async Task<Account> GetAsync()
account.Interface = this;
return account;
}
#endregion
#endregion

#region Update
/// <summary>
/// Update the specified name, city and address.
/// </summary>
/// <returns>The update.</returns>
/// <param name="name">Name.</param>
/// <param name="city">City.</param>
/// <param name="address">Address.</param>
public UpdateResponse<Account> Update(string name = null, string city = null, string address = null)
#region Update
/// <summary>
/// Update the specified name, city, address and state.
/// </summary>
/// <returns>The update.</returns>
/// <param name="name">Name.</param>
/// <param name="city">City.</param>
/// <param name="address">Address.</param>
/// <param name="state">State.</param>
public UpdateResponse<Account> Update(string name = null, string city = null, string address = null, string state = null)
{
var mandatoryParams = new List<string> { "name" };
var data = CreateData(mandatoryParams, new { name, city, address });
var data = CreateData(mandatoryParams, new { name, city, address, state });

return ExecuteWithExceptionUnwrap(() =>
{
var result = Task.Run(async () => await Client.Update<UpdateResponse<Account>>(Uri, data).ConfigureAwait(false)).Result;
result.Object.StatusCode = result.StatusCode;
return result.Object;
});
}
/// <summary>
/// Asynchronously update the specified name, city and address.
/// </summary>
/// <returns>The update.</returns>
/// <param name="name">Name.</param>
/// <param name="city">City.</param>
/// <param name="address">Address.</param>
public async Task<UpdateResponse<Account>> UpdateAsync(string name = null, string city = null, string address = null)
/// <summary>
/// Asynchronously update the specified name, city, address and state.
/// </summary>
/// <returns>The update.</returns>
/// <param name="name">Name.</param>
/// <param name="city">City.</param>
/// <param name="address">Address.</param>
/// <param name="state">State.</param>
public async Task<UpdateResponse<Account>> UpdateAsync(string name = null, string city = null, string address = null,string state = null)
{
var mandatoryParams = new List<string> { "name" };
var data = CreateData(
mandatoryParams, new { name, city, address });
mandatoryParams, new { name, city, address, state });
var result = await Client.Update<UpdateResponse<Account>>(Uri, data);
result.Object.StatusCode = result.StatusCode;
return result.Object;
}
#endregion
Expand Down
25 changes: 25 additions & 0 deletions src/Plivo/Resource/Address/Address.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,31 @@ public class Address : Resource
/// <value>Document Details</value>
public AddressDocumentDetail DocumentDetails { get; set; }

public override string ToString()
{
return "StreetCode: " + StreetCode + "\n" +
"MunicipalCode: " + MunicipalCode + "\n" +
"ValidationStatus: " + ValidationStatus + "\n" +
"Subaccount: " + Subaccount + "\n" +
"VerificationStatus: " + VerificationStatus + "\n" +
"Url: " + Url + "\n" +
"AddressProofType: " + AddressProofType + "\n" +
"AddressProofNumber: " + AddressProofNumber + "\n" +
"FiscalIdentificationCode: " + FiscalIdentificationCode + "\n" +
"PostalCode: " + PostalCode + "\n" +
"Region: " + Region + "\n" +
"City: " + City + "\n" +
"AddressLine2: " + AddressLine2 + "\n" +
"AddressLine1: " + AddressLine1 + "\n" +
"LastName: " + LastName + "\n" +
"FirstName: " + FirstName + "\n" +
"Salutation: " + Salutation + "\n" +
"Alias: " + Alias + "\n" +
"Account: " + Account + "\n" +
"CountryIso: " + CountryIso + "\n" +
"Id: " + Id + "\n" ;
}

public Address()
{
}
Expand Down
Empty file modified src/Plivo/Resource/Address/AddressCreateResponse.cs
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/Plivo/Resource/Address/AddressDeleteResponse.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class AddressDeleteResponse : DeleteResponse<Address>
/// <summary>
/// Gets or sets the status code.
/// </summary>
public uint StatusCode { get; set; }
//public uint StatusCode { get; set; }
}
}
13 changes: 13 additions & 0 deletions src/Plivo/Resource/Address/AddressDocumentDetail.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,18 @@ public class AddressDocumentDetail
/// </summary>
/// <value>Postal Code</value>
public string PostalCode { get; set; }

public override string ToString()
{
return "Salutation: " + Salutation + "\n" +
"FirstName: " + FirstName + "\n" +
"LastName: " + LastName + "\n" +
"AddressLine1: " + AddressLine1 + "\n" +
"AddressLine2: " + AddressLine2 + "\n" +
"City: " + City + "\n" +
"Region: " + Region + "\n" +
"PostalCode: " + PostalCode + "\n";

}
}
}
Empty file modified src/Plivo/Resource/Address/AddressGetResponse.cs
100644 → 100755
Empty file.
Loading

0 comments on commit 7ac5e28

Please sign in to comment.