Skip to content

Commit

Permalink
Merge pull request #144 from plivo/mms-powerpack
Browse files Browse the repository at this point in the history
mms powerpack
  • Loading branch information
nixonsam authored Sep 7, 2020
2 parents 0ba40b4 + 859cdd9 commit 4456eea
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 55 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.11.0](https://github.com/plivo/plivo-dotnet/tree/v4.11.0) (2020-09-07)
- Add Powerpack for MMS

## [v4.10.2](https://github.com/plivo/plivo-dotnet/tree/v4.10.2) (2020-08-19)
- Internal changes in PHLO for MultiPartyCall component.

Expand Down
2 changes: 1 addition & 1 deletion src/Plivo/Plivo.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard1.3</TargetFrameworks>
<ReleaseVersion>4.10.2</ReleaseVersion>
<ReleaseVersion>4.11.0</ReleaseVersion>
<Version />
<Authors>Plivo SDKs Team</Authors>
<Owners>Plivo Inc.</Owners>
Expand Down
3 changes: 2 additions & 1 deletion src/Plivo/Plivo.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
<summary>A .NET SDK to make voice calls and send SMS using Plivo and to generate Plivo XML</summary>
<description>A .NET SDK to make voice calls and send SMS using Plivo and to generate Plivo XML</description>
<id>Plivo</id>
<version>4.10.2</version>
<version>4.11.0</version>
<title>Plivo</title>
<authors>Plivo SDKs Team</authors>
<owners>Plivo, Inc.</owners>
<licenseUrl>https://github.com/plivo/plivo-dotnet/blob/master/LICENSE.txt</licenseUrl>
<projectUrl>http://github.com/plivo/plivo-dotnet</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>
* 4.11.0 Add Powerpack for MMS
* 4.10.2 Internal changes in PHLO for MultiPartyCall component.
* 4.10.1 Added exception handling for non json error responses and statuscode 401.
* 4.10.0 Add retries to multiple regions for voice requests.
Expand Down
23 changes: 15 additions & 8 deletions src/Plivo/Resource/Powerpack/Numbers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,25 @@ public Numbers () {
/// <value>The Type</value>
public string Type { get; set; }

/// <summary>
/// Gets or sets Service.
/// </summary>
/// <value>The Service</value>
public string Service { get; set; }

public Numbers Get (string memberId) {
var member = new Numbers ();
return member;
}
public ListResponse<Numbers> List (string starts_with = null, string country_iso2 = null,
string type = null, uint? limit = null, uint? offset = null) {
return PowerpackI.List_Numbers (numberpooluuid, starts_with, country_iso2, type, limit, offset);
string type = null, uint? limit = null, uint? offset = null, string service = null) {
return PowerpackI.List_Numbers (numberpooluuid, starts_with, country_iso2, type, limit, offset, service);
}
public async Task<ListResponse<Numbers>> ListAsync (
string starts_with = null, string country_iso2 = null,
string type = null, uint? limit = null, uint? offset = null) {
string type = null, uint? limit = null, uint? offset = null, string service = null) {
return await PowerpackI
.List_NumbersAsync (numberpooluuid, starts_with, country_iso2, type, limit, offset);
.List_NumbersAsync (numberpooluuid, starts_with, country_iso2, type, limit, offset, service);

}

Expand Down Expand Up @@ -115,30 +121,31 @@ public async Task<Numbers> FindAsync (
.Find_NumberAsync (numberpooluuid, number);
}

public Numbers Buy_Add_Number (string number = null, string type = null, string country_iso2 = null, string region = null, string pattern = null) {
public Numbers Buy_Add_Number (string number = null, string type = null, string country_iso2 = null, string region = null, string pattern = null, string service = null) {
if (number == null) {
var countryIso = country_iso2;
var numbers = PhoneNumberI.List (countryIso, type, pattern, region);
number = numbers.Objects[0].Number;
}
return PowerpackI
.Add_Number (numberpooluuid, number, true);
.Add_Number (numberpooluuid, number, service, true);
}
public async Task<Numbers> Buy_Add_NumberAsync (string number = null, string type = null, string country_iso2 = null, string region = null, string pattern = null) {
public async Task<Numbers> Buy_Add_NumberAsync (string number = null, string type = null, string country_iso2 = null, string region = null, string pattern = null, string service = null) {
if (number == null) {
var countryIso = country_iso2;
var numbers = PhoneNumberI.List (countryIso, type, pattern, region);
number = numbers.Objects[0].Number;
}
return await PowerpackI
.Add_NumberAsync (numberpooluuid, number, true);
.Add_NumberAsync (numberpooluuid, number, service, true);
}

public override string ToString () {
return "\n" +
"Type: " + Type + "\n" +
"NumberPoolUUID: " + NumberPoolUuid + "\n" +
"Number: " + Number + "\n" +
"Service: " + Service + "\n" +
"CountryISO2: " + CountryIso2 + "\n" +
"AddedOn: " + AddedOn + "\n" +
"AccountPhoneNumberResource: " + AccountPhoneNumberResource + "\n";
Expand Down
40 changes: 20 additions & 20 deletions src/Plivo/Resource/Powerpack/Powerpack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,37 +84,37 @@ public async Task<UpdateResponse<Powerpack>> UpdateAsync (string name = null, st
.UpdateAsync (Id, name, application_type, application_id, sticky_sender, local_connect);
}
public ListResponse<Numbers> List_Numbers (string starts_with = null, string country_iso2 = null,
string type = null, uint? limit = null, uint? offset = null) {
string type = null, string service = null, uint? limit = null, uint? offset = null) {
return ((PowerpackInterface) Interface)
.List_Numbers (number_pool_id, starts_with, country_iso2, type, limit, offset);
.List_Numbers (number_pool_id, starts_with, country_iso2, type, limit, offset, service);
}
public async Task<ListResponse<Numbers>> List_NumbersAsync (
string starts_with = null, string country_iso2 = null,
string type = null, uint? limit = null, uint? offset = null) {
string type = null, string service = null, uint? limit = null, uint? offset = null) {
return await ((PowerpackInterface) Interface)
.List_NumbersAsync (number_pool_id, starts_with, country_iso2, type, limit, offset);
.List_NumbersAsync (number_pool_id, starts_with, country_iso2, type, limit, offset, service);

}

public uint Count_Numbers (string starts_with = null, string country_iso2 = null,
string type = null, uint? limit = null, uint? offset = null) {
string type = null, string service = null, uint? limit = null, uint? offset = null) {
return ((PowerpackInterface) Interface)
.Count_Number (number_pool_id, starts_with, country_iso2, type, limit, offset);
.Count_Number (number_pool_id, starts_with, country_iso2, type, limit, offset, service);
}
public async Task<uint> Count_NumbersAsync (
string starts_with = null, string country_iso2 = null,
string type = null, uint? limit = null, uint? offset = null) {
string type = null, string service = null, uint? limit = null, uint? offset = null) {
return await ((PowerpackInterface) Interface)
.Count_NumbersAsync (number_pool_id, starts_with, country_iso2, type, limit, offset);
.Count_NumbersAsync (number_pool_id, starts_with, country_iso2, type, limit, offset, service);

}
public Numbers Add_Number (string number) {
public Numbers Add_Number (string number, string service = null) {
return ((PowerpackInterface) Interface)
.Add_Number (number_pool_id, number);
.Add_Number (number_pool_id, number, service);
}
public async Task<Numbers> Add_NumberAsync (string number) {
public async Task<Numbers> Add_NumberAsync (string number, string service = null) {
return await ((PowerpackInterface) Interface)
.Add_NumberAsync (number_pool_id, number);
.Add_NumberAsync (number_pool_id, number, service);
}

public Tollfree Add_Tollfree (string tollfree) {
Expand Down Expand Up @@ -146,14 +146,14 @@ public async Task<DeleteResponse<Tollfree>> Remove_TollfreeAsync (
.Remove_TollfreeAsync (number_pool_id, tollfree, unrent);
}

public Numbers Find_Number (string number) {
public Numbers Find_Number (string number, string service = null) {
return ((PowerpackInterface) Interface)
.Find_Number (number_pool_id, number);
.Find_Number (number_pool_id, number, service);
}
public async Task<Numbers> Find_NumberAsync (
string number) {
string number, string service = null) {
return await ((PowerpackInterface) Interface)
.Find_NumberAsync (number_pool_id, number);
.Find_NumberAsync (number_pool_id, number, service);
}
public ListResponse<Shortcode> List_Shortcode (uint? limit = null, uint? offset = null) {
return ((PowerpackInterface) Interface)
Expand Down Expand Up @@ -203,23 +203,23 @@ public async Task<Tollfree> Find_TollfreeAsync (
.Find_TollfreeAsync (tollfree, number_pool_id);
}

public Numbers Buy_Add_Number (string number = null, string type = null, string country_iso2 = null, string region = null, string pattern = null) {
public Numbers Buy_Add_Number (string number = null, string type = null, string country_iso2 = null, string region = null, string pattern = null, string service = null) {
if (number == null) {
var countryIso = country_iso2;
var numbers = PhoneNumberI.List (countryIso, type, pattern, region);
number = numbers.Objects[0].Number;
}
return ((PowerpackInterface) Interface)
.Add_Number (number_pool_id, number, true);
.Add_Number (number_pool_id, number, service, true);
}
public async Task<Numbers> Buy_Add_NumberAsync (string number = null, string type = null, string country_iso2 = null, string region = null, string pattern = null) {
public async Task<Numbers> Buy_Add_NumberAsync (string number = null, string type = null, string country_iso2 = null, string region = null, string pattern = null, string service = null) {
if (number == null) {
var countryIso = country_iso2;
var numbers = PhoneNumberI.List (countryIso, type, pattern, region);
number = numbers.Objects[0].Number;
}
return await ((PowerpackInterface) Interface)
.Add_NumberAsync (number_pool_id, number, true);
.Add_NumberAsync (number_pool_id, number, service, true);
}

public override string ToString () {
Expand Down
58 changes: 40 additions & 18 deletions src/Plivo/Resource/Powerpack/PowerpackInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public UpdateResponse<Powerpack> Update(string uuid, string name=null, string ap

return ExecuteWithExceptionUnwrap(() =>
{
var result = Task.Run(async () => await Client.Update<UpdateResponse<Powerpack>>(Uri +"Powerpack/"+uuid, data).ConfigureAwait(false)).Result;
var result = Task.Run(async () => await Client.Update<UpdateResponse<Powerpack>>(Uri +"Powerpack/"+uuid+"/", data).ConfigureAwait(false)).Result;
result.Object.StatusCode = result.StatusCode;
return result.Object;
});
Expand All @@ -260,7 +260,7 @@ public async Task<UpdateResponse<Powerpack>> UpdateAsync(string uuid, string nam
application_id,
sticky_sender,
local_connect });
var result = await Client.Update<UpdateResponse<Powerpack>>(Uri +"Powerpack/"+uuid, data);
var result = await Client.Update<UpdateResponse<Powerpack>>(Uri +"Powerpack/"+uuid+"/", data);
result.Object.StatusCode = result.StatusCode;
return result.Object;
}
Expand All @@ -277,7 +277,7 @@ public async Task<UpdateResponse<Powerpack>> UpdateAsync(string uuid, string nam
/// <param uuid="uuid">UUID</param>
/// <param name="offset">Offset.</param>
public ListResponse<Numbers> List_Numbers(string uuid, string starts_with =null, string country_iso2 =null,
string type=null, uint? limit = null, uint? offset = null)
string type=null, uint? limit = null, uint? offset = null, string service = null)
{
var mandatoryParams = new List<string> {""};
var data = CreateData(
Expand All @@ -288,7 +288,8 @@ public ListResponse<Numbers> List_Numbers(string uuid, string starts_with =null,
country_iso2,
type,
limit,
offset
offset,
service
});

return ExecuteWithExceptionUnwrap(() =>
Expand All @@ -315,7 +316,7 @@ public ListResponse<Numbers> List_Numbers(string uuid, string starts_with =null,
/// <param name="offset">Offset.</param>
public async Task<ListResponse<Numbers>> List_NumbersAsync(
string uuid, string starts_with =null, string country_iso2 =null,
string type=null, uint? limit = null, uint? offset = null)
string type=null, uint? limit = null, uint? offset = null, string service = null)
{
var mandatoryParams = new List<string> { "" };
var data = CreateData(
Expand All @@ -326,7 +327,8 @@ public async Task<ListResponse<Numbers>> List_NumbersAsync(
country_iso2,
type,
limit,
offset
offset,
service
});
var resources = await ListResources<ListResponse<Numbers>>("NumberPool/"+uuid+"/Number", data);
resources.Objects.ForEach(
Expand All @@ -352,7 +354,7 @@ public string Hello(){
/// <param uuid="uuid">UUID</param>
/// <param name="offset">Offset.</param>
public uint Count_Number(string uuid, string starts_with =null, string country_iso2 =null,
string type=null, uint? limit = null, uint? offset = null)
string type=null, uint? limit = null, uint? offset = null, string service = null)
{
var mandatoryParams = new List<string> {""};
var data = CreateData(
Expand All @@ -363,7 +365,8 @@ public uint Count_Number(string uuid, string starts_with =null, string country_
country_iso2,
type,
limit,
offset
offset,
service
});

// return ExecuteWithExceptionUnwrap(() =>
Expand All @@ -390,7 +393,7 @@ public uint Count_Number(string uuid, string starts_with =null, string country_
/// <param name="offset">Offset.</param>
public async Task<uint> Count_NumbersAsync(
string uuid, string starts_with =null, string country_iso2 =null,
string type=null, uint? limit = null, uint? offset = null)
string type=null, uint? limit = null, uint? offset = null, string service = null)
{
var mandatoryParams = new List<string> { "" };
var data = CreateData(
Expand All @@ -401,7 +404,8 @@ public async Task<uint> Count_NumbersAsync(
country_iso2,
type,
limit,
offset
offset,
service
});
var resources = await ListResources<ListResponse<Numbers>>("NumberPool/"+uuid+"/Number", data);
resources.Objects.ForEach(
Expand All @@ -421,14 +425,15 @@ public async Task<uint> Count_NumbersAsync(
/// <param name="uuid">UUID.</param>
/// <param name="number">Number.</param>

public Numbers Add_Number( string uuid, string number, bool rent=false )
public Numbers Add_Number( string uuid, string number, string service = null, bool rent=false)
{
var mandatoryParams = new List<string>{""};
var data= CreateData(
mandatoryParams,
new
{
rent
rent,
service
});


Expand All @@ -448,14 +453,15 @@ public Numbers Add_Number( string uuid, string number, bool rent=false )
/// <param name="uuid">UUID.</param>
/// <param name="number">Number.</param>
public async Task<Numbers> Add_NumberAsync(
string uuid, string number, bool rent=false)
string uuid, string number, string service = null, bool rent=false)
{
var mandatoryParams = new List<string>{""};
var data = CreateData(
mandatoryParams,
new
{
rent
rent,
service
});

var result = await Client.Update<Numbers>(Uri + "NumberPool/"+uuid+"/Number/"+number+"/", data);
Expand Down Expand Up @@ -604,19 +610,35 @@ public async Task<DeleteResponse<Tollfree>> Remove_TollfreeAsync(
/// <returns>The Number resource.</returns>
/// <param name="uuid">UUID.</param>
/// <param name="number">Number.</param>
public Numbers Find_Number(string uuid,string number)
/// <param name="service">Service.</param>
public Numbers Find_Number(string uuid,string number, string service = null)
{
var mandatoryParams = new List<string>{""};
var data= CreateData(
mandatoryParams,
new
{
service
});

return ExecuteWithExceptionUnwrap(() =>
{
var numberpoolResponse = Task.Run(async () => await GetResource<Numbers>("NumberPool/"+uuid+"/Number/"+number).ConfigureAwait(false)).Result;
var numberpoolResponse = Task.Run(async () => await GetResource<Numbers>("NumberPool/"+uuid+"/Number/"+number, data).ConfigureAwait(false)).Result;
numberpoolResponse.Interface = this;
return numberpoolResponse;
});
}
public async Task<Numbers> Find_NumberAsync(string uuid,
string number)
string number, string service = null)
{
var numberpoolresp = await GetResource<Numbers>("NumberPool/"+uuid+"/Number/"+number);
var mandatoryParams = new List<string>{""};
var data= CreateData(
mandatoryParams,
new
{
service
});
var numberpoolresp = await GetResource<Numbers>("NumberPool/"+uuid+"/Number/"+number, data);
numberpoolresp.Interface = this;
return numberpoolresp;

Expand Down
Loading

0 comments on commit 4456eea

Please sign in to comment.