Skip to content

Commit

Permalink
Merge pull request #230 from plivo/SMS-4994-update-campaign-sdk
Browse files Browse the repository at this point in the history
Update Campaign DotNet SDK
  • Loading branch information
renoldthomas-plivo authored Jan 5, 2023
2 parents 1731b42 + 7df782b commit 4cbc4f2
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Change Log
## [v5.19.0](https://github.com/plivo/plivo-dotnet/tree/v5.19.0) (2022-12-16)
- Added: Update campaign api endpoints

## [v5.18.0](https://github.com/plivo/plivo-dotnet/tree/v5.18.0) (2022-12-06)
- Added: Delete campaign and brand api endpoints
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.18.0</ReleaseVersion>
<ReleaseVersion>5.19.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.18.0</version>
<version>5.19.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.19.0 Added Update campaign endpoints
* 5.18.0 Added Delete campaign and brand endpoints
* 5.17.0 Added BrandUsecase Api, 10dlc enhancements
* 5.16.0 Adding more attribute on Account PhoneNumber Object
Expand Down
15 changes: 15 additions & 0 deletions src/Plivo/Resource/Campaign/Campaign.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ public override string ToString()
}
}

[JsonObject(MemberSerialization.OptIn)]
public class UpdateCampaign: Resource
{
[JsonProperty("api_id")]
public new string ApiId {get; set;}

[JsonProperty("campaign")]
public CampaignResponse Campaign {get; set;}

public override string ToString()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
}

[JsonObject(MemberSerialization.OptIn)]
public class CreateCampaign: Resource
{
Expand Down
93 changes: 93 additions & 0 deletions src/Plivo/Resource/Campaign/CampaignInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,99 @@ public async Task<CreateCampaign> CreateAsync(string campaign_alias, string bran
}
#endregion

#region Update
/// <summary>
/// Update Campaign with the specified sample, keyword etc.
/// </summary>
/// <returns>The update.</returns>
/// <param name="campaign_id">campaign_id</param>
/// <param name="reseller_id">reseller_id</param>
/// <param name="description">description</param>
/// <param name="sample1">sample1</param>
/// <param name="sample2">sample2</param>
///<param name="message_flow">message_flow<param>
///<param name="help_message">help_message<param>
///<param name="optin_keywords">optin_keywords<param>
///<param name="optin_message">optin_message<param>
///<param name="optout_keywords">optout_keywords<param>
///<param name="optout_message">optout_message<param>
///<param name="help_keywords">help_keywords<param>
public UpdateCampaign Update(string campaign_id,string reseller_id="", string description="", string sample1="",
string sample2="", string message_flow="", string help_message="", string optin_keywords="", string optin_message="",
string optout_keywords="", string optout_message="", string help_keywords="")
{
var mandatoryParams = new List<string>{};
var data = CreateData(
mandatoryParams,
new
{
reseller_id,
description,
sample1,
sample2,
message_flow,
help_message,
optin_keywords,
optin_message,
optout_keywords,
optout_message,
help_keywords,

});
return ExecuteWithExceptionUnwrap(() =>
{
var result = Task.Run(async () => await Client.Update<UpdateCampaign>(Uri + "10dlc/Campaign/"+campaign_id+"/", data).ConfigureAwait(false)).Result;
result.Object.StatusCode = result.StatusCode;
return result.Object;
});
}

/// <summary>
/// Update Campaign with the specified sample, keyword etc.
/// </summary>
/// <returns>The update.</returns>
/// <param name="campaign_id">campaign_id</param>
/// <param name="reseller_id">reseller_id</param>
/// <param name="description">description</param>
/// <param name="sample1">sample1</param>
/// <param name="sample2">sample2</param>
///<param name="message_flow">message_flow<param>
///<param name="help_message">help_message<param>
///<param name="optin_keywords">optin_keywords<param>
///<param name="optin_message">optin_message<param>
///<param name="optout_keywords">optout_keywords<param>
///<param name="optout_message">optout_message<param>
///<param name="help_keywords">help_keywords<param>
public async Task<UpdateCampaign> UpdateAsync(string campaign_id,string reseller_id="", string description="", string sample1="",
string sample2="", string message_flow="", string help_message="", string optin_keywords="", string optin_message="",
string optout_keywords="", string optout_message="", string help_keywords="")
{

var mandatoryParams = new List<string>{};
var data = CreateData(
mandatoryParams,
new
{
reseller_id,
description,
sample1,
sample2,
message_flow,
help_message,
optin_keywords,
optin_message,
optout_keywords,
optout_message,
help_keywords,

});

var result = await Client.Update<UpdateCampaign>(Uri + "10dlc/Campaign/"+campaign_id+"/", data);
result.Object.StatusCode = result.StatusCode;
return result.Object;
}
#endregion

#region GETNumber
/// <summary>
/// Get Campaign with the specified uuid.
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.18.0";
public const string SdkVersion = "5.19.0";
/// <summary>
/// Plivo API version
/// </summary>
Expand Down
38 changes: 38 additions & 0 deletions tests_netcore/Plivo.NetCore.Test/Mocks/campaignUpdateResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"api_id": "71aa47e0-3750-11ec-8e4c-0242ac110002",
"campaign": {
"campaign_id": "CCMZZOS",
"registration_status": "PROCESSING",
"reseller_id": "",
"brand_id": "B4TE2AH",
"usecase": "LOW_VOLUME",
"sub_usecase": "DELIVERY_NOTIFICATION",
"mno_metadata": {
"AT&T": {
"tpm": 75
},
"T-Mobile": {
"brand_tier": "TOP"
},
"US Cellular": {
"tpm": 75
},
"Verizon Wireless": {
"tpm": 75
}
},
"sample1": "Sample 1",
"sample2": "Sample 2",
"description": "Campaign",
"campaign_attributes": {
"embedded_link": false,
"embedded_phone": false,
"age_gated": false,
"direct_lending": false,
"subscriber_optin": false,
"subscriber_optout": false,
"subscriber_help": false,
"affiliate_marketing": false
}
}
}
45 changes: 45 additions & 0 deletions tests_netcore/Plivo.NetCore.Test/Resources/TestCampaign.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,51 @@ public void TestCampaignCreate()
AssertRequest(request);
}


[Fact]
public void TestCampaignUpdate()
{
var id = "CCMZZOS";
var data = new Dictionary<string, object>()
{
{"reseller_id", ""},
{"description", ""},
{"sample1", "sample1"},
{"sample2", ""},
{"message_flow", ""},
{"help_message", ""},
{"optin_keywords", ""},
{"optin_message", ""},
{"optout_keywords", ""},
{"optout_message", ""},
{"help_keywords", ""},

};

var request =
new PlivoRequest(
"POST",
"Account/MAXXXXXXXXXXXXXXXXXX/10dlc/Campaign/" + id + "/",
"",
data);

var response =
System.IO.File.ReadAllText(
SOURCE_DIR + @"../Mocks/campaignUpdateResponse.json"
);
Setup<UpdateCampaign>(
200,
response
);
var resp = Api.Campaign.Update(id, sample1:"sample1");
// Assert.Empty(
// ComparisonUtilities.Compare(
// response,
// Api.Campaign.Update(campaign_id:id, sample1:"sample1")));

AssertRequest(request);
}

[Fact]
public void TestCampaignGet()
{
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "5.18.0",
"version": "5.19.0",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/heads/v\\d+(?:\\.\\d+)?$"
Expand Down

0 comments on commit 4cbc4f2

Please sign in to comment.