Skip to content
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

cnam changes done #252

Open
wants to merge 7 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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## [5.31.0](https://github.com/plivo/plivo-dotnet/tree/v5.31.0) (2023-06-27)
**Feature - CNAM**
- Added New Param `cnam` in to the response of the [list all numbers API], [list single number API]
- Added `cnam` parameter to buy number[Buy a Phone Number] to configure CNAM while buying a US number
- Added `callback_url` parameter to buy number[Buy a Phone Number] to configure CNAM callback url while buying a US number
- Added `callback_method` parameter to buy number[Buy a Phone Number] to configure CNAM callback method while buying a US number
- Added `cnam` parameter to update number[Update an account phone number] to configure CNAM while updating a US number
- Added `callback_url` parameter to update number[Update an account phone number] to configure CNAM callback url while updating a US number
- Added `callback_method` parameter to update number[Update an account phone number] to configure CNAM callback method while updating a US number

## [5.30.0](https://github.com/plivo/plivo-dotnet/tree/v5.30.0) (2023-05-02)
**Feature - CNAM Lookup**
- Added New Param `cnam_lookup` in to the response of the [list all numbers API], [list single number API]
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>5.30.0</ReleaseVersion>
<ReleaseVersion>5.31.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>5.30.0</version>
<version>5.31.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>
* 5.31.0 Added New Param 'cnam' in to the response of the [list all numbers API], [list single number API]
* 5.30.0 Added New Param 'cnam_lookup' in to the response of the [list all numbers API], [list single number API]
* 5.29.0 Added New Param 'cnam_lookup_number_config' in GetCall and ListCalls
* 5.28.0 Added new Params 'MonthlyRecordingStorageAmount', 'RecordingStorageRate', 'RecordingStorageDuration' and 'RoundedRecordingDuration' to List Recordings and Get Recording APIs
Expand Down
15 changes: 15 additions & 0 deletions src/Plivo/Resource/NumberUpdateResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Plivo.Resource
{
public class NumberUpdateResponse<T> : UpdateResponse<T>
{
public string NewCnam { get; set; }
public string CnamUpdateStatus { get; set; }

public override string ToString()
{
return base.ToString() +
"NewCnam: " + NewCnam + "\n" +
"CnamUpdateStatus: " + CnamUpdateStatus + "\n";
}
}
}
14 changes: 10 additions & 4 deletions src/Plivo/Resource/PhoneNumber/PhoneNumber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ public override string ToString()
/// <returns>The buy.</returns>
/// <param name="appId">App identifier.</param>
/// <param name="cnamLookup">CnamLookup.</param>
public PhoneNumberBuyResponse Buy(string appId = null, string cnamLookup = null)
/// <param name="cnam">Cnam.</param>
/// <param name="callbackUrl">CallbackUrl.</param>
/// <param name="callbackMethod">CallbackMethod.</param>
public PhoneNumberBuyResponse Buy(string appId = null, string cnamLookup = null, string cnam = null, string callbackUrl = null, string callbackMethod = null)
{
return ((PhoneNumberInterface) Interface).Buy(Id, appId, cnamLookup);
return ((PhoneNumberInterface) Interface).Buy(Id, appId, cnamLookup, cnam, callbackUrl, callbackMethod);
}
/// <summary>
/// Asynchronously buy PhoneNumber and associate it with
Expand All @@ -76,9 +79,12 @@ public PhoneNumberBuyResponse Buy(string appId = null, string cnamLookup = null)
/// <returns>The buy.</returns>
/// <param name="appId">App identifier.</param>
/// <param name="cnamLookup">Cnam Lookup</param>
public async Task<PhoneNumberBuyResponse> BuyAsync(string appId = null, string cnamLookup = null)
/// <param name="cnam">Cnam.</param>
/// <param name="callbackUrl">CallbackUrl.</param>
/// <param name="callbackMethod">CallbackMethod.</param>
public async Task<PhoneNumberBuyResponse> BuyAsync(string appId = null, string cnamLookup = null, string cnam = null, string callbackUrl = null, string callbackMethod = null)
{
return await ((PhoneNumberInterface)Interface).BuyAsync(Id, appId, cnamLookup);
return await ((PhoneNumberInterface)Interface).BuyAsync(Id, appId, cnamLookup, cnam, callbackUrl, callbackMethod);
}
#endregion
}
Expand Down
9 changes: 7 additions & 2 deletions src/Plivo/Resource/PhoneNumber/PhoneNumberBuyResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class PhoneNumberBuyResponse : BaseResponse

public override string ToString()
{
return "StatusCode:" + Status +"\n"+"[Numbers]\n" + string.Join("\n", Numbers)+"\n"+"StatusCode:" + StatusCode + "\n";
return "Status:" + Status +"\n"+"[Numbers]\n" + string.Join("\n", Numbers)+"\n"+"StatusCode:" + StatusCode + "\n";
}

}
Expand All @@ -18,10 +18,15 @@ public class Phone
{
public string Number { get; set; }
public string Status { get; set; }
public string NewCnam { get; set; }
public string CnamUpdateStatus { get; set; }

public override string ToString()
{
return "Number:" + Number + "\n";
if (NewCnam != "") {
return "Number:" + Number + "\n" + "Status:" + Status + "\n" + "NewCnam:" + NewCnam + "\n" +"CnamUpdateStatus:" + CnamUpdateStatus + "\n";
}
return "Number:" + Number + "\n" + "Status:" + Status + "\n";
}

}
Expand Down
18 changes: 12 additions & 6 deletions src/Plivo/Resource/PhoneNumber/PhoneNumberInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,18 @@ public async Task<ListResponse<PhoneNumber>> ListAsync(
/// </summary>
/// <returns>The buy.</returns>
/// <param name="number">Number.</param>
/// <param name="appId">App identifier.</param>
/// <param name="app_id">App identifier.</param>
/// <param name="verificationInfo">Verification information. address_id and identity_id are the keys</param>
/// <param name="cnamLookup">Cnam Lookup</param>
public PhoneNumberBuyResponse Buy(string number, string appId = null, string cnamLookup = null,
/// <param name="cnam">Cnam</param>
/// <param name="callbackUrl">callbackUrl</param>
/// <param name="callbackMethod">callbackMethod</param>
public PhoneNumberBuyResponse Buy(string number, string app_id = null, string cnamLookup = null, string cnam = null, string callbackUrl = null, string callbackMethod = null,
Dictionary<string, string> verificationInfo = null )
{
var mandatoryParams = new List<string> {""};
var data = CreateData(
mandatoryParams, new {appId, verificationInfo, cnamLookup});
mandatoryParams, new {app_id, verificationInfo, cnamLookup, cnam, callbackUrl, callbackMethod});

return ExecuteWithExceptionUnwrap(() =>
{
Expand All @@ -156,15 +159,18 @@ public PhoneNumberBuyResponse Buy(string number, string appId = null, string cna
/// </summary>
/// <returns>The buy.</returns>
/// <param name="number">Number.</param>
/// <param name="appId">App identifier.</param>
/// <param name="app_id">App identifier.</param>
/// <param name="verificationInfo">Verification information. address_id and identity_id are the keys</param>
/// <param name="cnamLookup">Cnam Lookup</param>
public async Task<PhoneNumberBuyResponse> BuyAsync(string number, string appId = null, string cnamLookup = null,
/// <param name="cnam">Cnam</param>
/// <param name="callbackUrl">callbackUrl</param>
/// <param name="callbackMethod">callbackMethod</param>
public async Task<PhoneNumberBuyResponse> BuyAsync(string number, string app_id = null, string cnamLookup = null, string cnam = null, string callbackUrl = null, string callbackMethod = null,
Dictionary<string, string> verificationInfo = null)
{
var mandatoryParams = new List<string> { "" };
var data = CreateData(
mandatoryParams, new { appId, verificationInfo, cnamLookup });
mandatoryParams, new { app_id, verificationInfo, cnamLookup, cnam, callbackUrl, callbackMethod});
var result = await Client.Update<PhoneNumberBuyResponse>(
Uri + number + "/",
data
Expand Down
8 changes: 5 additions & 3 deletions src/Plivo/Resource/RentedNumber/RentedNumber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public class RentedNumber : Resource
public string TollFreeSmsVerification {get; set;}
public string RenewalDate {get; set;}
public string CnamLookup {get; set;}

public string Cnam{get; set;}

public override string ToString()
{
if (string.Compare(Carrier, "Plivo", StringComparison.Ordinal) == 0)
Expand All @@ -50,6 +51,7 @@ public override string ToString()
"City: " + City + "\n" +
"Country: " + Country + "\n" +
"CnamLookup: " + CnamLookup + "\n" +
"Cnam: " + Cnam + "\n" +
"MmsEnabled: " + MmsEnabled + "\n" +
"MmsRate: " + MmsRate + "\n" +
"MonthlyRentalRate: " + MonthlyRentalRate + "\n" +
Expand Down Expand Up @@ -104,7 +106,7 @@ public override string ToString()
/// <param name="appId">App identifier.</param>
/// <param name="subAccount">SubAccount.</param>
/// <param name="alias">Alias.</param>
public UpdateResponse<RentedNumber> Update(
public NumberUpdateResponse<RentedNumber> Update(
string appId = null, string subAccount = null, string alias = null)
{
var updateResponse =
Expand Down Expand Up @@ -132,7 +134,7 @@ public UpdateResponse<RentedNumber> Update(
/// <param name="appId">App identifier.</param>
/// <param name="subAccount">SubAccount.</param>
/// <param name="alias">Alias.</param>
public async Task<UpdateResponse<RentedNumber>> UpdateAsync(
public async Task<NumberUpdateResponse<RentedNumber>> UpdateAsync(
string appId = null, string subAccount = null, string alias = null)
{
var updateResponse = await ((RentedNumberInterface) Interface)
Expand Down
43 changes: 30 additions & 13 deletions src/Plivo/Resource/RentedNumber/RentedNumberInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public async Task<RentedNumber> GetAsync(string number)
/// <param name="renewalDate_Gt">Renewal Date Greater Than</param>
/// <param name="renewalDate_Gte">Renewal Date Greater Than or Equal</param>
/// <param name="cnamLookup">Cnam Lookup configuration</param>
/// <param name="cnam">Cnam configuration</param>
public ListResponse<RentedNumber> List(
string type = null, string numberStartswith = null,
string subaccount = null, string alias = null,
Expand All @@ -82,6 +83,7 @@ public ListResponse<RentedNumber> List(
string renewalDate_Lt = null, string renewalDate_Lte = null,
string renewalDate_Gt = null, string renewalDate_Gte = null,
string cnamLookup = null,
string cnam = null,
uint? limit = null, uint? offset = null)
{
var mandatoryParams = new List<string> {""};
Expand All @@ -103,6 +105,7 @@ public ListResponse<RentedNumber> List(
renewalDate_Gte,
renewalDate_Gt,
cnamLookup,
cnam,
limit,
offset
});
Expand Down Expand Up @@ -187,7 +190,7 @@ public UpdateResponse<RentedNumber> AddNumber(

return ExecuteWithExceptionUnwrap(() =>
{
var result = Task.Run(async () => await Client.Update<UpdateResponse<RentedNumber>>(Uri, data).ConfigureAwait(false)).Result;
var result = Task.Run(async () => await Client.Update<NumberUpdateResponse<RentedNumber>>(Uri, data).ConfigureAwait(false)).Result;
result.Object.StatusCode = result.StatusCode;
return result.Object;
});
Expand All @@ -202,7 +205,7 @@ public UpdateResponse<RentedNumber> AddNumber(
/// <param name="numberType">Number type.</param>
/// <param name="appId">App identifier.</param>
/// <param name="subaccount">Subaccount.</param>
public async Task<UpdateResponse<RentedNumber>> AddNumberAsync(
public async Task<NumberUpdateResponse<RentedNumber>> AddNumberAsync(
List<string> numbers, string carrier, string region,
string numberType = null, string appId = null,
string subaccount = null)
Expand All @@ -220,15 +223,15 @@ public async Task<UpdateResponse<RentedNumber>> AddNumberAsync(
appId,
subaccount
});
var result = await Client.Update<UpdateResponse<RentedNumber>>(Uri, data);
var result = await Client.Update<NumberUpdateResponse<RentedNumber>>(Uri, data);
result.Object.StatusCode = result.StatusCode;
return result.Object;
}
#endregion

#region Update
/// <summary>
/// Update RentedNumber with the specified number, appId, subaccount and alias.
/// Update RentedNumber with the specified number, appId, subaccount, alias, cnamLookup, cnam , callbackUrl and callbackMethod.
/// </summary>
/// <returns>The update.</returns>
/// <param name="number">Number.</param>
Expand All @@ -237,9 +240,13 @@ public async Task<UpdateResponse<RentedNumber>> AddNumberAsync(
/// <param name="alias">Alias.</param>
/// <param name="verificationInfo">Verification Information.</param>
/// <param name="cnamLookup">Cnam Lookup.</param>
public UpdateResponse<RentedNumber> Update(
/// <param name="cnam">Cnam</param>
/// <param name="callbackUrl">callbackUrl</param>
/// <param name="callbackMethod">callbackMethod</param>
public NumberUpdateResponse<RentedNumber> Update(
string number, string appId = null, string subaccount = null,
string alias = null, Dictionary<string, string> verificationInfo = null, string cnamLookup = null)
string alias = null, Dictionary<string, string> verificationInfo = null, string cnamLookup = null,
string cnam = null, string callbackUrl = null, string callbackMethod = null)
{
var mandatoryParams = new List<string> {""};
var data = CreateData(
Expand All @@ -250,13 +257,16 @@ public UpdateResponse<RentedNumber> Update(
subaccount,
alias,
verificationInfo,
cnamLookup
cnamLookup,
cnam,
callbackUrl,
callbackMethod
});
if (appId == "null") data["app_id"] = null;

return ExecuteWithExceptionUnwrap(() =>
{
var result = Task.Run(async () => await Client.Update<UpdateResponse<RentedNumber>>(
var result = Task.Run(async () => await Client.Update<NumberUpdateResponse<RentedNumber>>(
Uri + number + "/",
data
).ConfigureAwait(false)).Result;
Expand All @@ -265,7 +275,7 @@ public UpdateResponse<RentedNumber> Update(
});
}
/// <summary>
/// Asynchronously update RentedNumber with the specified number, appId, subaccount and alias.
/// Asynchronously update RentedNumber with the specified number, appId, subaccount cnamLookup, cnam , callbackUrl and callbackMethod.
/// </summary>
/// <returns>The update.</returns>
/// <param name="number">Number.</param>
Expand All @@ -274,9 +284,13 @@ public UpdateResponse<RentedNumber> Update(
/// <param name="alias">Alias.</param>
/// <param name="verificationInfo">Verification Information.</param>
/// <param name="cnamLookup">Cnam Lookup.</param>
public async Task<UpdateResponse<RentedNumber>> UpdateAsync(
/// <param name="cnam">Cnam</param>
/// <param name="callbackUrl">callbackUrl</param>
/// <param name="callbackMethod">callbackMethod</param>
public async Task<NumberUpdateResponse<RentedNumber>> UpdateAsync(
string number, string appId = null, string subaccount = null,
string alias = null, Dictionary<string, string> verificationInfo = null, string cnamLookup = null)
string alias = null, Dictionary<string, string> verificationInfo = null, string cnamLookup = null,
string cnam = null, string callbackUrl = null, string callbackMethod = null)
{
var mandatoryParams = new List<string> { "" };
var data = CreateData(
Expand All @@ -287,10 +301,13 @@ public async Task<UpdateResponse<RentedNumber>> UpdateAsync(
subaccount,
alias,
verificationInfo,
cnamLookup
cnamLookup,
cnam,
callbackUrl,
callbackMethod
});
if (appId == "null") data["app_id"] = null;
var result = await Client.Update<UpdateResponse<RentedNumber>>(
var result = await Client.Update<NumberUpdateResponse<RentedNumber>>(
Uri + number + "/",
data
);
Expand Down
2 changes: 1 addition & 1 deletion src/Plivo/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Version
/// <summary>
/// DotNet SDK version
/// </summary>
public const string SdkVersion = "5.30.0";
public const string SdkVersion = "5.31.0";
/// <summary>
/// Plivo API version
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion tests/Plivo.Test/Mocks/numberGetResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"tendlc_registration_status": "COMPLETED",
"toll_free_sms_verification": "verified",
"renewal_date": "2023-05-01",
"cnam_lookup": "enabled"
"cnam_lookup": "enabled",
"cnam": "test1"
}
9 changes: 6 additions & 3 deletions tests/Plivo.Test/Mocks/numberListResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"tendlc_registration_status": "COMPLETED",
"toll_free_sms_verification": "verified",
"renewal_date": "2023-05-01",
"cnam_lookup": "enabled"
"cnam_lookup": "enabled",
"cnam": "test1"
},
{
"added_on": "2013-01-01",
Expand All @@ -48,7 +49,8 @@
"tendlc_registration_status": "COMPLETED",
"toll_free_sms_verification": "verified",
"renewal_date": "2023-05-01",
"cnam_lookup": "enabled"
"cnam_lookup": "enabled",
"cnam": "test1"
},
{
"added_on": "2013-03-25",
Expand All @@ -69,7 +71,8 @@
"tendlc_registration_status": "COMPLETED",
"toll_free_sms_verification": "verified",
"renewal_date": "2023-05-01",
"cnam_lookup": "enabled"
"cnam_lookup": "enabled",
"cnam": "test1"
}
]
}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "5.30.0",
"version": "5.31.0",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/heads/v\\d+(?:\\.\\d+)?$"
Expand Down