Skip to content

Commit cfc2276

Browse files
authored
Prepare initial v1.0.0 release (#13)
* Prepare v1.0.0 release Additional fixes * Bump Delivery dependency
1 parent 15ce5e6 commit cfc2276

19 files changed

+402
-21
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ On Windows, we recommend installing [the latest Visual Studio 2019](https://www.
3838

3939
To get started with Target Node.js SDK, just add it as a dependency by [installing from NuGet](https://www.nuget.org/packages/Adobe.Target.Client).
4040

41+
### Super Simple to Use
42+
43+
Please take a look at [our documentation](https://adobetarget-sdks.gitbook.io/docs/sdk-reference-guides/dotnet-sdk) to learn how to use the .NET SDK.
44+
45+
### Sample Apps
46+
47+
There's a couple of sample apps showing sample sync/async Target SDK usage under [SampleApp project](SampleApp).
48+
To switch between sync and async sample apps, just modify `StartupObject` property in [SampleApp project file](SampleApp/SampleApp.csproj) accordingly.
49+
4150
### Build
4251

4352
To build everything and generate NuGet packages, run [dotnet Cake](https://cakebuild.net/) CLI commands. Binaries and NuGet packages will be dropped in an *Artefacts* directory at the repo root.
@@ -58,16 +67,9 @@ Each project can also be built individually directly through the CLI or your edi
5867

5968
We publish NuGet packages to [nuget.org](https://www.nuget.org/packages/Adobe.Target.Client) for each release.
6069

61-
### Using nugets built locally in your project
62-
63-
```bash
64-
# Add Adobe.Target.Client nuget package
65-
dotnet add package Adobe.Target.Client -s <RepoRoot>/Artefacts
66-
```
67-
6870
### Contributing
6971

70-
Contributions are welcomed! Read the [Contributing Guide](./.github/CONTRIBUTING.md) for more information.
72+
Contributions are welcome! Read the [Contributing Guide](./.github/CONTRIBUTING.md) for more information.
7173

7274
### Licensing
7375

SampleApp/App.cs

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,23 @@ public App(ITargetClient targetClient, ILogger<App> logger)
3333
public async Task RunAsync(string[] args)
3434
{
3535
Console.WriteLine("Async app");
36-
this.logger.LogInformation("Starting ...");
36+
37+
// Initialize the SDK
3738

3839
var targetClientConfig = new TargetClientConfig.Builder("adobetargetmobile", "B8A054D958807F770A495DD6@AdobeOrg")
3940
.SetLogger(this.logger)
41+
.SetDecisioningMethod(DecisioningMethod.OnDevice)
42+
.SetOnDeviceDecisioningReady(this.DecisioningReady)
43+
.SetArtifactDownloadSucceeded(artifact => Console.WriteLine("ArtifactDownloadSucceeded: " + artifact))
44+
.SetArtifactDownloadFailed(exception => Console.WriteLine("ArtifactDownloadFailed " + exception.Message))
4045
.Build();
4146

4247
this.targetClient.Initialize(targetClientConfig);
4348

49+
// sample server-side GetOffers call
50+
4451
var deliveryRequest = new TargetDeliveryRequest.Builder()
52+
.SetDecisioningMethod(DecisioningMethod.ServerSide)
4553
.SetThirdPartyId("testThirdPartyId")
4654
.SetContext(new Context(ChannelType.Web))
4755
.SetExecute(new ExecuteRequest(null, new List<MboxRequest>
@@ -54,7 +62,10 @@ public async Task RunAsync(string[] args)
5462

5563
App.PrintCookies(this.logger, response);
5664

65+
// sample SendNotifications call
66+
5767
var notificationRequest = new TargetDeliveryRequest.Builder()
68+
.SetDecisioningMethod(DecisioningMethod.ServerSide)
5869
.SetSessionId(response.Request.SessionId)
5970
.SetTntId(response.Response?.Id?.TntId)
6071
.SetThirdPartyId("testThirdPartyId")
@@ -68,8 +79,6 @@ public async Task RunAsync(string[] args)
6879

6980
App.PrintCookies(this.logger, await this.targetClient.SendNotificationsAsync(notificationRequest));
7081

71-
this.logger.LogInformation("Done");
72-
7382
await Task.CompletedTask;
7483
}
7584

@@ -78,5 +87,27 @@ internal static void PrintCookies(ILogger logger, TargetDeliveryResponse respons
7887
logger.LogInformation("Mbox cookie: " + response.GetCookies()[TargetConstants.MboxCookieName].Value);
7988
logger.LogInformation("Cluster cookie: " + response.GetCookies()[TargetConstants.ClusterCookieName].Value);
8089
}
90+
91+
private void DecisioningReady()
92+
{
93+
Console.WriteLine("OnDeviceDecisioningReady");
94+
_ = this.GetOnDeviceOffersAsync();
95+
}
96+
97+
private async Task GetOnDeviceOffersAsync()
98+
{
99+
// sample on-device GetOffers call
100+
101+
var deliveryRequest = new TargetDeliveryRequest.Builder()
102+
.SetContext(new Context(ChannelType.Web, geo: new Geo("193.105.140.131")))
103+
.SetExecute(new ExecuteRequest(new RequestDetails(), new List<MboxRequest>
104+
{
105+
new(index:1, name: "a1-mobile-tstsree")
106+
}))
107+
.Build();
108+
109+
var response = await targetClient.GetOffersAsync(deliveryRequest);
110+
App.PrintCookies(this.logger, response);
111+
}
81112
}
82113
}

SampleApp/ProgramSync.cs

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace SampleApp
1111
internal class ProgramSync
1212
{
1313
private static TargetClient targetClient;
14+
private static ILogger<ProgramSync> logger;
1415
public static void Main(string[] args)
1516
{
1617
Console.WriteLine("Sync app");
@@ -20,7 +21,9 @@ public static void Main(string[] args)
2021
builder.AddSimpleConsole(options => options.TimestampFormat = "hh:mm:ss ");
2122
builder.SetMinimumLevel(LogLevel.Debug);
2223
});
23-
var logger = loggerFactory.CreateLogger<ProgramSync>();
24+
logger = loggerFactory.CreateLogger<ProgramSync>();
25+
26+
// Initialize the SDK
2427

2528
var targetClientConfig = new TargetClientConfig.Builder("adobetargetmobile", "B8A054D958807F770A495DD6@AdobeOrg")
2629
.SetLogger(logger)
@@ -31,15 +34,50 @@ public static void Main(string[] args)
3134
.Build();
3235
targetClient = TargetClient.Create(targetClientConfig);
3336

37+
// sample server-side GetOffers call
38+
39+
var deliveryRequest = new TargetDeliveryRequest.Builder()
40+
.SetDecisioningMethod(DecisioningMethod.ServerSide)
41+
.SetThirdPartyId("testThirdPartyId")
42+
.SetContext(new Context(ChannelType.Web))
43+
.SetExecute(new ExecuteRequest(null, new List<MboxRequest>
44+
{
45+
new MboxRequest(index:1, name: "a1-serverside-ab")
46+
}))
47+
.Build();
48+
49+
var response = targetClient.GetOffers(deliveryRequest);
50+
51+
App.PrintCookies(logger, response);
52+
53+
// sample SendNotifications call
54+
55+
var notificationRequest = new TargetDeliveryRequest.Builder()
56+
.SetDecisioningMethod(DecisioningMethod.ServerSide)
57+
.SetSessionId(response.Request.SessionId)
58+
.SetTntId(response.Response?.Id?.TntId)
59+
.SetThirdPartyId("testThirdPartyId")
60+
.SetContext(new Context(ChannelType.Web))
61+
.SetNotifications(new List<Notification>()
62+
{
63+
{ new(id:"notificationId1", type: MetricType.Display, timestamp: DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
64+
tokens: new List<string>())}
65+
})
66+
.Build();
67+
68+
var notificationResponse = targetClient.SendNotifications(notificationRequest);
69+
App.PrintCookies(logger, notificationResponse);
70+
3471
Thread.Sleep(3000);
3572
}
3673

3774
private static void DecisioningReady()
3875
{
3976
Console.WriteLine("OnDeviceDecisioningReady");
4077

78+
// sample on-device GetOffers call
79+
4180
var deliveryRequest = new TargetDeliveryRequest.Builder()
42-
.SetThirdPartyId("testThirdPartyId")
4381
.SetContext(new Context(ChannelType.Web, geo: new Geo("193.105.140.131")))
4482
.SetExecute(new ExecuteRequest(new RequestDetails(), new List<MboxRequest>
4583
{
@@ -48,6 +86,7 @@ private static void DecisioningReady()
4886
.Build();
4987

5088
var response = targetClient.GetOffers(deliveryRequest);
89+
App.PrintCookies(logger, response);
5190
}
5291
}
5392
}

Source/Adobe.Target.Client/Adobe.Target.Client.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
<PropertyGroup Label="Package">
88
<Product>Adobe.Target.Client</Product>
9-
<Description>Target .NET SDK</Description>
9+
<Description>Adobe Target .NET SDK - https://adobetarget-sdks.gitbook.io/docs/sdk-reference-guides/dotnet-sdk</Description>
1010
<PackageTags>adobe;target;target-sdk;target-client</PackageTags>
1111
</PropertyGroup>
1212

1313
<ItemGroup Label="Project References">
1414
<PackageReference Include="Adobe.ExperienceCloud.Ecid" Version="1.0.0" />
15-
<PackageReference Include="Adobe.Target.Delivery" Version="0.0.0-preview.0.14" />
15+
<PackageReference Include="Adobe.Target.Delivery" Version="1.0.0" />
1616
<PackageReference Include="JsonLogic.Net" Version="1.1.9" />
1717
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
1818
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />

Source/Adobe.Target.Client/OnDevice/ClusterLocator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ private void FetchLocation(ITargetService targetService)
4646
private async Task FetchLocationAsync(ITargetService targetService)
4747
{
4848
var request = new TargetDeliveryRequest.Builder()
49+
.SetDecisioningMethod(DecisioningMethod.ServerSide)
4950
.SetContext(new Context(ChannelType.Web))
5051
.Build();
5152

Source/Adobe.Target.Client/TargetClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ public static TargetClient Create(TargetClientConfig clientConfig)
4747
public void Initialize(TargetClientConfig clientConfig)
4848
{
4949
Logger = clientConfig.Logger;
50+
VisitorProvider.Initialize(clientConfig.OrganizationId);
5051
this.targetService = new TargetService(clientConfig);
5152
this.localService = new OnDeviceDecisioningService(clientConfig, this.targetService);
5253
this.defaultDecisioningMethod = clientConfig.DecisioningMethod;
5354
this.defaultPropertyToken = clientConfig.DefaultPropertyToken;
54-
VisitorProvider.Initialize(clientConfig.OrganizationId);
5555
Logger?.LogDebug("Initialized Target Client: " + clientConfig.OrganizationId);
5656
}
5757

Source/Adobe.Target.Client/Util/TargetConstants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static class TargetConstants
1818
/// <summary>
1919
/// SDK Version
2020
/// </summary>
21-
public const string SdkVersion = "0.0.1";
21+
public const string SdkVersion = "1.0.0";
2222

2323
/// <summary>
2424
/// Mbox cookie name

Source/Adobe.Target.Delivery/Adobe.Target.Delivery.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<PropertyGroup Label="Package">
88
<Product>Adobe.Target.Delivery</Product>
9-
<Description>Target .NET Delivery API</Description>
9+
<Description>Target .NET Delivery API - https://developers.adobetarget.com/api/delivery-api/</Description>
1010
<PackageTags>adobe;target;target-delivery;target-delivery-api</PackageTags>
1111
</PropertyGroup>
1212

Source/Adobe.Target.Delivery/Model/DeliveryRequest.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ protected DeliveryRequest() { }
5555
/// <param name="telemetry">telemetry.</param>
5656
/// <param name="notifications">Notifications for the displayed content, clicked selectors, and/or visited views or mboxes..</param>
5757
/// <param name="qaMode">qaMode.</param>
58-
public DeliveryRequest(string requestId = default(string), string impressionId = default(string), VisitorId id = default(VisitorId), long environmentId = default(long), Property property = default(Property), Trace trace = default(Trace), Context context = default(Context), ExperienceCloud experienceCloud = default(ExperienceCloud), ExecuteRequest execute = default(ExecuteRequest), PrefetchRequest prefetch = default(PrefetchRequest), Telemetry telemetry = default(Telemetry), List<Notification> notifications = default(List<Notification>), QAMode qaMode = default(QAMode))
58+
/// <param name="preview">preview.</param>
59+
public DeliveryRequest(string requestId = default(string), string impressionId = default(string), VisitorId id = default(VisitorId), long environmentId = default(long), Property property = default(Property), Trace trace = default(Trace), Context context = default(Context), ExperienceCloud experienceCloud = default(ExperienceCloud), ExecuteRequest execute = default(ExecuteRequest), PrefetchRequest prefetch = default(PrefetchRequest), Telemetry telemetry = default(Telemetry), List<Notification> notifications = default(List<Notification>), QAMode qaMode = default(QAMode), Preview preview = default(Preview))
5960
{
6061
// to ensure "context" is required (not null)
6162
this.Context = context ?? throw new ArgumentNullException("context is a required property for DeliveryRequest and cannot be null");
@@ -71,6 +72,7 @@ protected DeliveryRequest() { }
7172
this.Telemetry = telemetry;
7273
this.Notifications = notifications;
7374
this.QaMode = qaMode;
75+
this.Preview = preview;
7476
}
7577

7678
/// <summary>
@@ -155,6 +157,12 @@ protected DeliveryRequest() { }
155157
[DataMember(Name = "qaMode", EmitDefaultValue = false)]
156158
public QAMode QaMode { get; set; }
157159

160+
/// <summary>
161+
/// Gets or Sets Preview
162+
/// </summary>
163+
[DataMember(Name = "preview", EmitDefaultValue = false)]
164+
public Preview Preview { get; set; }
165+
158166
/// <summary>
159167
/// Returns the string presentation of the object
160168
/// </summary>
@@ -176,6 +184,7 @@ public override string ToString()
176184
sb.Append(" Telemetry: ").Append(Telemetry).Append("\n");
177185
sb.Append(" Notifications: ").Append(Notifications).Append("\n");
178186
sb.Append(" QaMode: ").Append(QaMode).Append("\n");
187+
sb.Append(" Preview: ").Append(Preview).Append("\n");
179188
sb.Append("}\n");
180189
return sb.ToString();
181190
}
@@ -274,6 +283,11 @@ public bool Equals(DeliveryRequest input)
274283
this.QaMode == input.QaMode ||
275284
(this.QaMode != null &&
276285
this.QaMode.Equals(input.QaMode))
286+
) &&
287+
(
288+
this.Preview == input.Preview ||
289+
(this.Preview != null &&
290+
this.Preview.Equals(input.Preview))
277291
);
278292
}
279293

@@ -311,6 +325,8 @@ public override int GetHashCode()
311325
hashCode = hashCode * 59 + this.Notifications.GetHashCode();
312326
if (this.QaMode != null)
313327
hashCode = hashCode * 59 + this.QaMode.GetHashCode();
328+
if (this.Preview != null)
329+
hashCode = hashCode * 59 + this.Preview.GetHashCode();
314330
return hashCode;
315331
}
316332
}

Source/Adobe.Target.Delivery/Model/DeliveryResponse.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public partial class DeliveryResponse : IEquatable<DeliveryResponse>, IValidatab
4444
/// <param name="edgeHost">Cluster host name that served the response. Ideally, all subsequent requests should be made to that host..</param>
4545
/// <param name="execute">execute.</param>
4646
/// <param name="prefetch">prefetch.</param>
47-
public DeliveryResponse(int status = default(int), string requestId = default(string), VisitorId id = default(VisitorId), string _client = default(string), string edgeHost = default(string), ExecuteResponse execute = default(ExecuteResponse), PrefetchResponse prefetch = default(PrefetchResponse))
47+
/// <param name="notifications">notifications.</param>
48+
public DeliveryResponse(int status = default(int), string requestId = default(string), VisitorId id = default(VisitorId), string _client = default(string), string edgeHost = default(string), ExecuteResponse execute = default(ExecuteResponse), PrefetchResponse prefetch = default(PrefetchResponse), NotificationResponse notifications = default(NotificationResponse))
4849
{
4950
this.Status = status;
5051
this.RequestId = requestId;
@@ -53,6 +54,7 @@ public partial class DeliveryResponse : IEquatable<DeliveryResponse>, IValidatab
5354
this.EdgeHost = edgeHost;
5455
this.Execute = execute;
5556
this.Prefetch = prefetch;
57+
this.Notifications = notifications;
5658
}
5759

5860
/// <summary>
@@ -100,6 +102,12 @@ public partial class DeliveryResponse : IEquatable<DeliveryResponse>, IValidatab
100102
[DataMember(Name = "prefetch", EmitDefaultValue = false)]
101103
public PrefetchResponse Prefetch { get; set; }
102104

105+
/// <summary>
106+
/// Gets or Sets Notifications
107+
/// </summary>
108+
[DataMember(Name = "notifications", EmitDefaultValue = false)]
109+
public NotificationResponse Notifications { get; set; }
110+
103111
/// <summary>
104112
/// Returns the string presentation of the object
105113
/// </summary>
@@ -115,6 +123,7 @@ public override string ToString()
115123
sb.Append(" EdgeHost: ").Append(EdgeHost).Append("\n");
116124
sb.Append(" Execute: ").Append(Execute).Append("\n");
117125
sb.Append(" Prefetch: ").Append(Prefetch).Append("\n");
126+
sb.Append(" Notifications: ").Append(Notifications).Append("\n");
118127
sb.Append("}\n");
119128
return sb.ToString();
120129
}
@@ -182,6 +191,11 @@ public bool Equals(DeliveryResponse input)
182191
this.Prefetch == input.Prefetch ||
183192
(this.Prefetch != null &&
184193
this.Prefetch.Equals(input.Prefetch))
194+
) &&
195+
(
196+
this.Notifications == input.Notifications ||
197+
(this.Notifications != null &&
198+
this.Notifications.Equals(input.Notifications))
185199
);
186200
}
187201

@@ -207,6 +221,8 @@ public override int GetHashCode()
207221
hashCode = hashCode * 59 + this.Execute.GetHashCode();
208222
if (this.Prefetch != null)
209223
hashCode = hashCode * 59 + this.Prefetch.GetHashCode();
224+
if (this.Notifications != null)
225+
hashCode = hashCode * 59 + this.Notifications.GetHashCode();
210226
return hashCode;
211227
}
212228
}

0 commit comments

Comments
 (0)