Asynchronous Requests
Description#
One benefit of server-side integration is that one can leverage the huge bandwidth and computing resources available on the server-side by using parallelism. Target .NET SDK supports asynchronous requests, making it easy to integrate Target into an app's existing async workflow.
Supported Methods#
.NET
Copied to your clipboard1Task<TargetDeliveryResponse> GetOffersAsync(TargetDeliveryRequest request);2Task<TargetDeliveryResponse> SendNotificationsAsync(TargetDeliveryRequest request);3Task<TargetAttributes> GetAttributesAsync(TargetDeliveryRequest request, params string[] mboxes);
Example#
A sample async SDK API usage could appear as follows:
.NET
Copied to your clipboard1var deliveryRequest = new TargetDeliveryRequest.Builder()2 .SetExecute(new ExecuteRequest(mboxes: new List<MboxRequest> { new MboxRequest(index: 1, name: "a1-serverside-ab") }))3 .Build();45var response = await this.targetClient.GetOffersAsync(deliveryRequest);67var notificationRequest = new TargetDeliveryRequest.Builder()8 .SetSessionId(response.Request.SessionId)9 .SetTntId(response.Response?.Id?.TntId)10 .SetNotifications(new List<Notification>11 {12 new (id: "1", type: MetricType.Display, timestamp: DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),13 mbox: new NotificationMbox("product1", "J+W1Fq18hxliDDJonTPfV0S+mzxapAO3d14M43EsM9f12A6QaqL+E3XKkRFlmq9U"),14 tokens: new List<string> { "t0FRvoWosOqHmYL5G18QCZNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==" })15 })16 .Build();1718var notificationResponse = await this.targetClient.SendNotificationsAsync(notificationRequest);
This example assumes you have initialized the SDK.