Skip to content

Commit

Permalink
Prepare initial v1.0.0 release (#13)
Browse files Browse the repository at this point in the history
* Prepare v1.0.0 release
Additional fixes

* Bump Delivery dependency
  • Loading branch information
XDex authored Apr 27, 2021
1 parent 15ce5e6 commit cfc2276
Show file tree
Hide file tree
Showing 19 changed files with 402 additions and 21 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ On Windows, we recommend installing [the latest Visual Studio 2019](https://www.

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).

### Super Simple to Use

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.

### Sample Apps

There's a couple of sample apps showing sample sync/async Target SDK usage under [SampleApp project](SampleApp).
To switch between sync and async sample apps, just modify `StartupObject` property in [SampleApp project file](SampleApp/SampleApp.csproj) accordingly.

### Build

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.
Expand All @@ -58,16 +67,9 @@ Each project can also be built individually directly through the CLI or your edi

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

### Using nugets built locally in your project

```bash
# Add Adobe.Target.Client nuget package
dotnet add package Adobe.Target.Client -s <RepoRoot>/Artefacts
```

### Contributing

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

### Licensing

Expand Down
37 changes: 34 additions & 3 deletions SampleApp/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,23 @@ public App(ITargetClient targetClient, ILogger<App> logger)
public async Task RunAsync(string[] args)
{
Console.WriteLine("Async app");
this.logger.LogInformation("Starting ...");

// Initialize the SDK

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

this.targetClient.Initialize(targetClientConfig);

// sample server-side GetOffers call

var deliveryRequest = new TargetDeliveryRequest.Builder()
.SetDecisioningMethod(DecisioningMethod.ServerSide)
.SetThirdPartyId("testThirdPartyId")
.SetContext(new Context(ChannelType.Web))
.SetExecute(new ExecuteRequest(null, new List<MboxRequest>
Expand All @@ -54,7 +62,10 @@ public async Task RunAsync(string[] args)

App.PrintCookies(this.logger, response);

// sample SendNotifications call

var notificationRequest = new TargetDeliveryRequest.Builder()
.SetDecisioningMethod(DecisioningMethod.ServerSide)
.SetSessionId(response.Request.SessionId)
.SetTntId(response.Response?.Id?.TntId)
.SetThirdPartyId("testThirdPartyId")
Expand All @@ -68,8 +79,6 @@ public async Task RunAsync(string[] args)

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

this.logger.LogInformation("Done");

await Task.CompletedTask;
}

Expand All @@ -78,5 +87,27 @@ internal static void PrintCookies(ILogger logger, TargetDeliveryResponse respons
logger.LogInformation("Mbox cookie: " + response.GetCookies()[TargetConstants.MboxCookieName].Value);
logger.LogInformation("Cluster cookie: " + response.GetCookies()[TargetConstants.ClusterCookieName].Value);
}

private void DecisioningReady()
{
Console.WriteLine("OnDeviceDecisioningReady");
_ = this.GetOnDeviceOffersAsync();
}

private async Task GetOnDeviceOffersAsync()
{
// sample on-device GetOffers call

var deliveryRequest = new TargetDeliveryRequest.Builder()
.SetContext(new Context(ChannelType.Web, geo: new Geo("193.105.140.131")))
.SetExecute(new ExecuteRequest(new RequestDetails(), new List<MboxRequest>
{
new(index:1, name: "a1-mobile-tstsree")
}))
.Build();

var response = await targetClient.GetOffersAsync(deliveryRequest);
App.PrintCookies(this.logger, response);
}
}
}
43 changes: 41 additions & 2 deletions SampleApp/ProgramSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace SampleApp
internal class ProgramSync
{
private static TargetClient targetClient;
private static ILogger<ProgramSync> logger;
public static void Main(string[] args)
{
Console.WriteLine("Sync app");
Expand All @@ -20,7 +21,9 @@ public static void Main(string[] args)
builder.AddSimpleConsole(options => options.TimestampFormat = "hh:mm:ss ");
builder.SetMinimumLevel(LogLevel.Debug);
});
var logger = loggerFactory.CreateLogger<ProgramSync>();
logger = loggerFactory.CreateLogger<ProgramSync>();

// Initialize the SDK

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

// sample server-side GetOffers call

var deliveryRequest = new TargetDeliveryRequest.Builder()
.SetDecisioningMethod(DecisioningMethod.ServerSide)
.SetThirdPartyId("testThirdPartyId")
.SetContext(new Context(ChannelType.Web))
.SetExecute(new ExecuteRequest(null, new List<MboxRequest>
{
new MboxRequest(index:1, name: "a1-serverside-ab")
}))
.Build();

var response = targetClient.GetOffers(deliveryRequest);

App.PrintCookies(logger, response);

// sample SendNotifications call

var notificationRequest = new TargetDeliveryRequest.Builder()
.SetDecisioningMethod(DecisioningMethod.ServerSide)
.SetSessionId(response.Request.SessionId)
.SetTntId(response.Response?.Id?.TntId)
.SetThirdPartyId("testThirdPartyId")
.SetContext(new Context(ChannelType.Web))
.SetNotifications(new List<Notification>()
{
{ new(id:"notificationId1", type: MetricType.Display, timestamp: DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
tokens: new List<string>())}
})
.Build();

var notificationResponse = targetClient.SendNotifications(notificationRequest);
App.PrintCookies(logger, notificationResponse);

Thread.Sleep(3000);
}

private static void DecisioningReady()
{
Console.WriteLine("OnDeviceDecisioningReady");

// sample on-device GetOffers call

var deliveryRequest = new TargetDeliveryRequest.Builder()
.SetThirdPartyId("testThirdPartyId")
.SetContext(new Context(ChannelType.Web, geo: new Geo("193.105.140.131")))
.SetExecute(new ExecuteRequest(new RequestDetails(), new List<MboxRequest>
{
Expand All @@ -48,6 +86,7 @@ private static void DecisioningReady()
.Build();

var response = targetClient.GetOffers(deliveryRequest);
App.PrintCookies(logger, response);
}
}
}
4 changes: 2 additions & 2 deletions Source/Adobe.Target.Client/Adobe.Target.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

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

<ItemGroup Label="Project References">
<PackageReference Include="Adobe.ExperienceCloud.Ecid" Version="1.0.0" />
<PackageReference Include="Adobe.Target.Delivery" Version="0.0.0-preview.0.14" />
<PackageReference Include="Adobe.Target.Delivery" Version="1.0.0" />
<PackageReference Include="JsonLogic.Net" Version="1.1.9" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
Expand Down
1 change: 1 addition & 0 deletions Source/Adobe.Target.Client/OnDevice/ClusterLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private void FetchLocation(ITargetService targetService)
private async Task FetchLocationAsync(ITargetService targetService)
{
var request = new TargetDeliveryRequest.Builder()
.SetDecisioningMethod(DecisioningMethod.ServerSide)
.SetContext(new Context(ChannelType.Web))
.Build();

Expand Down
2 changes: 1 addition & 1 deletion Source/Adobe.Target.Client/TargetClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public static TargetClient Create(TargetClientConfig clientConfig)
public void Initialize(TargetClientConfig clientConfig)
{
Logger = clientConfig.Logger;
VisitorProvider.Initialize(clientConfig.OrganizationId);
this.targetService = new TargetService(clientConfig);
this.localService = new OnDeviceDecisioningService(clientConfig, this.targetService);
this.defaultDecisioningMethod = clientConfig.DecisioningMethod;
this.defaultPropertyToken = clientConfig.DefaultPropertyToken;
VisitorProvider.Initialize(clientConfig.OrganizationId);
Logger?.LogDebug("Initialized Target Client: " + clientConfig.OrganizationId);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Adobe.Target.Client/Util/TargetConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static class TargetConstants
/// <summary>
/// SDK Version
/// </summary>
public const string SdkVersion = "0.0.1";
public const string SdkVersion = "1.0.0";

/// <summary>
/// Mbox cookie name
Expand Down
2 changes: 1 addition & 1 deletion Source/Adobe.Target.Delivery/Adobe.Target.Delivery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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

Expand Down
18 changes: 17 additions & 1 deletion Source/Adobe.Target.Delivery/Model/DeliveryRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ protected DeliveryRequest() { }
/// <param name="telemetry">telemetry.</param>
/// <param name="notifications">Notifications for the displayed content, clicked selectors, and/or visited views or mboxes..</param>
/// <param name="qaMode">qaMode.</param>
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))
/// <param name="preview">preview.</param>
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))
{
// to ensure "context" is required (not null)
this.Context = context ?? throw new ArgumentNullException("context is a required property for DeliveryRequest and cannot be null");
Expand All @@ -71,6 +72,7 @@ protected DeliveryRequest() { }
this.Telemetry = telemetry;
this.Notifications = notifications;
this.QaMode = qaMode;
this.Preview = preview;
}

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

/// <summary>
/// Gets or Sets Preview
/// </summary>
[DataMember(Name = "preview", EmitDefaultValue = false)]
public Preview Preview { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
Expand All @@ -176,6 +184,7 @@ public override string ToString()
sb.Append(" Telemetry: ").Append(Telemetry).Append("\n");
sb.Append(" Notifications: ").Append(Notifications).Append("\n");
sb.Append(" QaMode: ").Append(QaMode).Append("\n");
sb.Append(" Preview: ").Append(Preview).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
Expand Down Expand Up @@ -274,6 +283,11 @@ public bool Equals(DeliveryRequest input)
this.QaMode == input.QaMode ||
(this.QaMode != null &&
this.QaMode.Equals(input.QaMode))
) &&
(
this.Preview == input.Preview ||
(this.Preview != null &&
this.Preview.Equals(input.Preview))
);
}

Expand Down Expand Up @@ -311,6 +325,8 @@ public override int GetHashCode()
hashCode = hashCode * 59 + this.Notifications.GetHashCode();
if (this.QaMode != null)
hashCode = hashCode * 59 + this.QaMode.GetHashCode();
if (this.Preview != null)
hashCode = hashCode * 59 + this.Preview.GetHashCode();
return hashCode;
}
}
Expand Down
18 changes: 17 additions & 1 deletion Source/Adobe.Target.Delivery/Model/DeliveryResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public partial class DeliveryResponse : IEquatable<DeliveryResponse>, IValidatab
/// <param name="edgeHost">Cluster host name that served the response. Ideally, all subsequent requests should be made to that host..</param>
/// <param name="execute">execute.</param>
/// <param name="prefetch">prefetch.</param>
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))
/// <param name="notifications">notifications.</param>
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))
{
this.Status = status;
this.RequestId = requestId;
Expand All @@ -53,6 +54,7 @@ public partial class DeliveryResponse : IEquatable<DeliveryResponse>, IValidatab
this.EdgeHost = edgeHost;
this.Execute = execute;
this.Prefetch = prefetch;
this.Notifications = notifications;
}

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

/// <summary>
/// Gets or Sets Notifications
/// </summary>
[DataMember(Name = "notifications", EmitDefaultValue = false)]
public NotificationResponse Notifications { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
Expand All @@ -115,6 +123,7 @@ public override string ToString()
sb.Append(" EdgeHost: ").Append(EdgeHost).Append("\n");
sb.Append(" Execute: ").Append(Execute).Append("\n");
sb.Append(" Prefetch: ").Append(Prefetch).Append("\n");
sb.Append(" Notifications: ").Append(Notifications).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
Expand Down Expand Up @@ -182,6 +191,11 @@ public bool Equals(DeliveryResponse input)
this.Prefetch == input.Prefetch ||
(this.Prefetch != null &&
this.Prefetch.Equals(input.Prefetch))
) &&
(
this.Notifications == input.Notifications ||
(this.Notifications != null &&
this.Notifications.Equals(input.Notifications))
);
}

Expand All @@ -207,6 +221,8 @@ public override int GetHashCode()
hashCode = hashCode * 59 + this.Execute.GetHashCode();
if (this.Prefetch != null)
hashCode = hashCode * 59 + this.Prefetch.GetHashCode();
if (this.Notifications != null)
hashCode = hashCode * 59 + this.Notifications.GetHashCode();
return hashCode;
}
}
Expand Down
Loading

0 comments on commit cfc2276

Please sign in to comment.