Loyalty2.svc
Calls
- AddManualAdjustment - Adding a Manual Adjustment to a Customer's plan.
- GetActivity - What Activity is associated with this Customer?
- GetAdjustmentDetails - What are the Adjustment Details at this Location?
- GetAwardRedemptions - What are the Award Redemptions of this Customer?
- RedeemAwards - Redeem one or more awards.
Sending a Request to Loyalty2.svc
All calls to the Loyalty2.svc require an Authorization header in the HTTP Web Request Headers of the request. The parameters for the request body of each call are outlined in the sections below.
Loyalty2.svc Endpoint
Endpoint
https://{{server}}.brinkpos.net/Loyalty2.svc
HTTP Web Request Headers
Header Name
Header Value
Authorization
Token {{AccessToken}}
For example, if your AccessToken is 'ABC123', then the value of your Authorization header would be Token ABC123.
This call is to push an Adjustment for a customer.
AddManualAdjustment Request
Data Name
Data Type
Data Description
CustomerId
Guid
Specify the Id of the Customer for this adjustment
GroupToken
string
Specify the Token of the Group to add this adjustment
PlanId
int
Specify the Id of the Plan
ReasonId
int
Specify the Id of the adjustment reason
Value
decimal
Specify the amount of the adjustment
AddManualAdjustment Response
Data Name
Data Type
Data Description
Message
string
Returns a Brink Error message if the request did not go through. Otherwise, this field will be null.
ResultCode
int
Returns one of the following:
- 0 = Request went through successfully
- 1 = Request returned an unknown error
- 2 = Request was not valid
- 3 = Server is currently unavailable and unable to receive the request
- 4 = Access Denied
- 101 = Invalid customer Id (submitted CustomerId is empty or does not exist)
- 102 = Loyalty adjustment reason Id does not exist (submitted adjustment reason Id does not exist)
- 103 = Invalid loyalty plan Id (submitted loyalty plan Id does not exist)
- 104 = No locations are defined for the group (submitted group token did not have any locations defined)
ResultCodes specific to AddManualAdjustment:
This call is to retrieve an array of ActivityDetail objects for the location.
GetActivity Request
Data Name
Data Type
Data Description
CustomerId
Guid?
Specify the Customer Id of the Customer you would like to retrieve activity for. This is a required field if StartTime is null, but otherwise can be left null.
GroupToken
string
Specify the token of the group you would like to retrieve activity for
RecordOffset
uint
(Optional) Specify the number of the first record to return in the series.
E.g. A maximum of 1,000 records are returned at a time. This field should be '1' for the first page of data and '1,001' for the second page.
E.g. A maximum of 1,000 records are returned at a time. This field should be '1' for the first page of data and '1,001' for the second page.
StartTime
DateTimeOffset?
Specify the start date and time from which to retrieve activity for. This is a required field if CustomerId is null, but otherwise can be left null.
GetActivity Response
Data Name
Data Type
Data Description
Activity
Array of ActivityDetail
Activity details for a specific Customer or Group within a period of time
Message
string
Returns a Brink Error message if the request did not go through. Otherwise, this field will be null.
ResultCode
int
Returns one of the following:
- 0 = Request went through successfully
- 1 = Request returned an unknown error
- 2 = Request was not valid
- 3 = Server is currently unavailable and unable to receive the request
- 4 = Access Denied
This call is to retrieve an array of AdjustmentDetail objects for the location.
GetAdjustmentDetails Request
Data Name
Data Type
Data Description
GroupToken
string
Specify the token of the group you would like to retrieve activity for
IncludeBulkAdjustments
bool
(Optional) Specify True if you would like details for bulk adjustments to be included, False if not. Default is False if not specified.
RecordOffset
uint
(Optional) Specify the number of the first record to return in the series.
E.g. A maximum of 1,000 records are returned at a time. This field should be '1' for the first page of data and '1,001' for the second page.
E.g. A maximum of 1,000 records are returned at a time. This field should be '1' for the first page of data and '1,001' for the second page.
StartTime
DateTimeOffset
Specify the start date and time from which to retrieve activity for
GetAdjustmentDetails Response
Data Name
Data Type
Data Description
Message
string
Returns a Brink Error message if the request did not go through. Otherwise, this field will be null.
ResultCode
int
Returns one of the following:
- 0 = Request went through successfully
- 1 = Request returned an unknown error
- 2 = Request was not valid
- 3 = Server is currently unavailable and unable to receive the request
- 4 = Access Denied
This call is to retrieve an array of AwardRedemption objects for the location.
GetAwardRedemptions Request
Data Name
Data Type
Data Description
CustomerId
Guid?
Specify the Customer Id of the Customer you would like to retrieve activity for. This is a required field if StartTime is null, but otherwise can be left null.
GroupToken
string
Specify the token of the group you would like to retrieve activity for
RecordOffset
uint
Specify the number of the first record to return in the series.
E.g. A maximum of 1,000 records are returned at a time. This field should be 1 for the first page of data and 1,001 for the second page.
E.g. A maximum of 1,000 records are returned at a time. This field should be 1 for the first page of data and 1,001 for the second page.
StartTime
DateTimeOffset?
Specify the start date and time to retrieve activity for. This is a required field if CustomerId is null, but otherwise can be left null.
GetAwardRedemptions Response
Data Name
Data Type
Data Description
Message
string
Returns a Brink Error message if the request did not go through. Otherwise, this field will be null.
Redemptions
Array of AwardRedemption
Award redemptions for a specific Customer or Group within a period of time
ResultCode
int
Returns one of the following:
- 0 = Request went through successfully
- 1 = Request returned an unknown error
- 2 = Request was not valid
- 3 = Server is currently unavailable and unable to receive the request
- 4 = Access Denied
This call is to redeem one or more Awards.
RedeemAwards Request
Data Name
Data Type
Data Description
AllowPartialSuccess
bool
Specify True to allow for valid Award Ids to be processed even if invalid or already redeemed Award Ids have been passed in, or False if you would like only complete failure or complete success. Default is False if not specified.
AwardIds
List<int>
Specify one or more Award Ids to mark as redeemed
GroupToken
string
Specify the Token of the Group to add data for
RedeemAwards Response
Data Name
Data Type
Data Description
AlreadyRedeemedAwardIds
List<int>
Requested Award Ids that have already been marked as redeemed out of those submitted
InvalidAwardIds
List<int>
Requested Award Ids that are invalid out of those submitted
Message
string
Returns a Brink Error message if the request did not go through. Otherwise, this field will be null.
ResultCode
int
Returns one of the following:
- 0 = Request went through successfully
- 1 = Request returned an unknown error
- 2 = Request was not valid
- 3 = Server is currently unavailable and unable to receive the request
- 4 = Access Denied
SuccessfulAwardIds
List<int>
Requested Award Ids that have been successfully marked as redeemed out of those submitted
Global Type
All the Types available in Loyalty2.svc will be displayed below.
ActivityDetail Type
Data Name
Data Type
Data Description
CustomerId
Guid
Id of the customer for this ActivityDetail
LocationId
Guid
Id of the location for this ActivityDetail
PlanId
int
Id of the plan for this ActivityDetail
Time
DateTimeOffset
Time of activity for this ActivityDetail in the location's local time
Type
byte
Returns one of the following:
- 0 = NewCard (a new card was issued)
- 1 = GrantValue (value was added to a card)
- 2 = RedeemValue (value was redeemed from a card)
- 3 = ManualAdjustment (a manual adjustment was added)
Value
decimal
Amount for this ActivityDetail
AdjustmentDetail Type
Data Name
Data Type
Data Description
ActivityType
int
Returns one of the following:
- 0 = NewCard (a new card was issued)
- 1 = GrantValue (value was added to a card)
- 2 = RedeemValue (value was redeemed from a card)
- 3 = ManualAdjustment (a manual adjustment was added)
CustomerId
Guid
Id of the customer for this AdjustmentDetail
IsBulkAdjustment
bool
True if adjustment was part of a bulk operation, False if not
Notes
string
Special instructions or notes for this AdjustmentDetail
PlanId
int
Id of the plan for this AdjustmentDetail
ReasonId
int
Id for the adjustment reason for this AdjustmentDetail
RewardId
int?
Id for the reward for this AdjustmentDetail, if applicable
RewardValue
decimal?
Amount of the reward for this AdjustmentDetail, if applicable
Time
DateTimeOffset
Time of this AdjustmentDetail using the location's local time
Value
decimal
Amount of the adjustment
AwardRedemption Type
Data Name
Data Type
Data Description
AwardId
int
Id of the award for this AwardRedemption
Id
int
Id of the redemption for this AwardRedemption
LocationId
Guid
Id of the location for this AwardRedemption
Time
DateTimeOffset
Time of adjustment for this AwardRedemption in the location's local time
Value
decimal
Amount for this AwardRedemption
AddManualAdjustment Sample Codeusing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ServiceModel; using System.ServiceModel.Web; using Loyalty2_AddManualAdjustment.Loyalty2ServiceReference; namespace Loyalty2_AddManualAdjustment { class Program { static void Main(string[] args) { //Connect to Loyalty2 service client var client = new LoyaltyWebService2Client(); //Set security protocol to TLS 1.2 System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; using (var scope = new OperationContextScope(client.InnerChannel)) { //Include token in HTTP Web Request Header var headers = WebOperationContext.Current.OutgoingRequest.Headers; headers["Authorization"] = @"Token {{AccessToken}}"; Guid customerId = Empty.Guid; String groupToken = @"GroupToken"; int planId = 123; int reasonId = 123; decimal value = 123M; //Include all parameters in request body var request = new AddManualAdjustmentRequest() { CustomerId = customerId, GroupToken = groupToken, PlanId = planId, ReasonId = reasonId, Value = value, }; //Make AddManualAdjustment call var response = client.AddManualAdjustment(request); if (response.ResultCode == 0) { Console.WriteLine("Success!"); Console.WriteLine("---------------------------"); Console.WriteLine("End"); Console.ReadKey(); } else { Console.WriteLine("Error Code: " + response.ResultCode); Console.WriteLine("Message: " + response.Message); Console.ReadKey(); } } } } }
AddManualAdjustment Sample Codeusing Microsoft.Extensions.DependencyInjection; using ServiceReference8; using System.ServiceModel; using System.ServiceModel.Channels; namespace Loyalty2_AddManualAdjustment { class Program { public static ServiceCollection services = new ServiceCollection(); public static void AddLoyaltyServiceClient() { services.AddTransient<ILoyaltyWebService2>((provider) => { BasicHttpBinding binding = new BasicHttpBinding(); binding.MaxReceivedMessageSize = 2147483647; EndpointAddress endpointAddress = new EndpointAddress("{YOUR_WSDL_URL_GOES_HERE}"); ChannelFactory<ILoyaltyWebService2> factory = new ChannelFactory<ILoyaltyWebService2>(binding, endpointAddress); return factory.CreateChannel(); }); } static void Main(string[] args) { AddLoyaltyServiceClient(); ILoyaltyWebService2 client = services.BuildServiceProvider().GetRequiredService<ILoyaltyWebService2>(); try { int count = 1; using (OperationContextScope scope = new OperationContextScope((IContextChannel)client)) { OperationContext context = OperationContext.Current; HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty(); httpRequestProperty.Headers["AccessToken"] = 'AccessToken'; httpRequestProperty.Headers["LocationToken"] = 'LocationToken'; context.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty; Guid customerId = new Guid("fd405d23-ce88-4385-98a9-f496014439b9"); String groupToken = "b05c3b2d265c4b04826606d2f63fbd96"; int planId = 4005247; int reasonId = 1; decimal value = 20; //Include all parameters in request body var request = new AddManualAdjustmentRequest() { CustomerId = customerId, GroupToken = groupToken, PlanId = planId, ReasonId = reasonId, Value = value, }; //Make AddManualAdjustment call var response = client.AddManualAdjustmentAsync(request); Console.WriteLine("AddManualAdjustment"); Console.WriteLine("-------------------"); if (response.Result.ResultCode == 0) { Console.WriteLine("Success!"); Console.WriteLine("---------------------------"); Console.WriteLine("End"); Console.ReadKey(); } else { Console.WriteLine("Error Code: " + response.Result.ResultCode); Console.WriteLine("Message: " + response.Result.Message); Console.ReadKey(); } } } catch (Exception ex) { Console.WriteLine("Error calling AddManualAdjustment operation: " + ex.Message); } } } }
GetActivity Sample Codeusing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ServiceModel; using System.ServiceModel.Web; using Loyalty2_GetActivity.Loyalty2ServiceReference; namespace Loyalty2_GetActivity { class Program { static void Main(string[] args) { //Connect to Loyalty2 service client var client = new LoyaltyWebService2Client(); //Set security protocol to TLS 1.2 System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; using (var scope = new OperationContextScope(client.InnerChannel)) { //Include token in HTTP Web Request Header var headers = WebOperationContext.Current.OutgoingRequest.Headers; headers["Authorization"] = @"Token {{AccessToken}}"; String groupToken = @"GroupToken"; DateTimeOffset startTime = new DateTimeOffset(2001, 01, 01, 0, 0, 0, new TimeSpan(0)); uint recordOffset = 1; Guid customerId = new Guid(); //Include GroupToken and StartTime parameters (RecordOffset and CustomerId optional) in request body var request = new GetActivityRequest() { GroupToken = groupToken, StartTime = startTime, RecordOffset = recordOffset, CustomerId = customerId, }; //Make GetActivity call var response = client.GetActivity(request); //If call is successful if (response.ResultCode == 0) { if (response.Activity.Length > 0) { //Loop through collection of ActivityDetail objects returned foreach (var detail in response.Activity) { Console.WriteLine("CustomerId: " + detail.CustomerId); Console.WriteLine("LocationId: " + detail.LocationId); Console.WriteLine("OrderId: " + detail.OrderId); Console.WriteLine("PlanId: " + detail.PlanId); Console.WriteLine("Time: " + detail.Time); Console.WriteLine("Type: " + detail.Type); Console.WriteLine("Value: " + detail.Value); Console.WriteLine("---------------------------"); } } else { Console.WriteLine("No Activity Details"); Console.WriteLine("---------------------------"); } Console.WriteLine("End"); Console.ReadKey(); } else { Console.WriteLine("Error Code: " + response.ResultCode); Console.WriteLine("Message: " + response.Message); Console.ReadKey(); } } } } }
GetActivity Sample Codeusing Microsoft.Extensions.DependencyInjection; using ServiceReference8; using System.ServiceModel; using System.ServiceModel.Channels; namespace Loyalty2_GetActivity { class Program { public static ServiceCollection services = new ServiceCollection(); public static void AddLoyaltyServiceClient() { services.AddTransient<ILoyaltyWebService2>((provider) => { BasicHttpBinding binding = new BasicHttpBinding(); binding.MaxReceivedMessageSize = 2147483647; EndpointAddress endpointAddress = new EndpointAddress("{YOUR_WSDL_URL_GOES_HERE}"); ChannelFactory<ILoyaltyWebService2> factory = new ChannelFactory<ILoyaltyWebService2>(binding, endpointAddress); return factory.CreateChannel(); }); } static void Main(string[] args) { AddLoyaltyServiceClient(); ILoyaltyWebService2 client = services.BuildServiceProvider().GetRequiredService<ILoyaltyWebService2>(); try { int count = 1; using (OperationContextScope scope = new OperationContextScope((IContextChannel)client)) { OperationContext context = OperationContext.Current; HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty(); httpRequestProperty.Headers["AccessToken"] = 'AccessToken'; httpRequestProperty.Headers["LocationToken"] = 'LocationToken'; context.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty; String groupToken = "b05c3b2d265c4b04826606d2f63fbd96"; DateTimeOffset startTime = new DateTimeOffset(2022, 02, 09, 0, 0, 0, new TimeSpan(0)); uint recordOffset = 0; Guid customerId = new Guid("fd405d23-ce88-4385-98a9-f496014439b9"); //Include GroupToken and StartTime parameters (RecordOffset and CustomerId optional) in request body var request = new GetActivityRequest() { GroupToken = groupToken, StartTime = startTime, RecordOffset = recordOffset, CustomerId = customerId, }; //Make GetActivity call var response = client.GetActivityAsync(request); Console.WriteLine("GetActivity"); Console.WriteLine("------------"); //If call is successful if (response.Result.ResultCode == 0) { Console.WriteLine(response.Result.ResultCode); if (response.Result.Activity.Length > 0) { //Loop through collection of ActivityDetail objects returned foreach (var detail in response.Result.Activity) { Console.WriteLine("CustomerId: " + detail.CustomerId); Console.WriteLine("LocationId: " + detail.LocationId); Console.WriteLine("OrderId: " + detail.OrderId); Console.WriteLine("PlanId: " + detail.PlanId); Console.WriteLine("Time: " + detail.Time); Console.WriteLine("Type: " + detail.Type); Console.WriteLine("Value: " + detail.Value); Console.WriteLine("---------------------------"); } } else { Console.WriteLine("No Activity Details"); Console.WriteLine("---------------------------"); } Console.WriteLine("End"); Console.ReadKey(); } } } catch (Exception ex) { Console.WriteLine("Error calling GetActivity operation: " + ex.Message); } } } }
GetAdjustmentDetails Sample Codeusing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ServiceModel; using System.ServiceModel.Web; using Loyalty2_GetAdjustmentDetails.Loyalty2ServiceReference; namespace Loyalty2_GetAdjustmentDetails { class Program { static void Main(string[] args) { //Connect to Loyalty2 service client var client = new LoyaltyWebService2Client(); //Set security protocol to TLS 1.2 System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; using (var scope = new OperationContextScope(client.InnerChannel)) { //Include token in HTTP Web Request Header var headers = WebOperationContext.Current.OutgoingRequest.Headers; headers["Authorization"] = @"Token {{AccessToken}}"; String groupToken = @"GroupToken"; DateTimeOffset startTime = new DateTimeOffset(2001, 01, 01, 0, 0, 0, new TimeSpan(0)); uint recordOffset = 1; bool includeBulkAdjustments = true; //Include GroupToken and StartTime parameters (RecordOffset and IncludeBulkAdjustments optional) in request body var request = new GetAdjustmentDetailsRequest() { GroupToken = groupToken, StartTime = startTime, RecordOffset = recordOffset, IncludeBulkAdjustments = includeBulkAdjustments, }; //Make GetAdjustmentDetails call var response = client.GetAdjustmentDetails(request); //If call is successful if (response.ResultCode == 0) { if (response.Adjustments.Length > 0) { //Loop through collection of AdjustmentDetail objects returned foreach (var detail in response.Adjustments) { Console.WriteLine("Activity Type: " + detail.ActivityType); Console.WriteLine("CustomerId: " + detail.CustomerId); Console.WriteLine("IsBulkAdjustment: " + detail.IsBulkAdjustment); Console.WriteLine("Notes: " + detail.Notes); Console.WriteLine("PlanId: " + detail.PlanId); Console.WriteLine("ReasonId: " + detail.ReasonId); Console.WriteLine("RewardId: " + detail.RewardId); Console.WriteLine("RewardValue: " + detail.RewardValue); Console.WriteLine("Time: " + detail.Time); Console.WriteLine("Value: " + detail.Value); Console.WriteLine("---------------------------"); } } else { Console.WriteLine("No Adjustment Details"); Console.WriteLine("---------------------------"); } Console.WriteLine("End"); Console.ReadKey(); } else { Console.WriteLine("Error Code: " + response.ResultCode); Console.WriteLine("Message: " + response.Message); Console.ReadKey(); } } } } }
GetAdjustmentDetails Sample Codeusing Microsoft.Extensions.DependencyInjection; using ServiceReference8; using System.ServiceModel; using System.ServiceModel.Channels; namespace Loyalty2_GetAdjustmentDetails { class Program { public static ServiceCollection services = new ServiceCollection(); public static void AddLoyaltyServiceClient() { services.AddTransient<ILoyaltyWebService2>((provider) => { BasicHttpBinding binding = new BasicHttpBinding(); binding.MaxReceivedMessageSize = 2147483647; EndpointAddress endpointAddress = new EndpointAddress("{YOUR_WSDL_URL_GOES_HERE}"); ChannelFactory<ILoyaltyWebService2> factory = new ChannelFactory<ILoyaltyWebService2>(binding, endpointAddress); return factory.CreateChannel(); }); } static void Main(string[] args) { AddLoyaltyServiceClient(); ILoyaltyWebService2 client = services.BuildServiceProvider().GetRequiredService<ILoyaltyWebService2>(); try { int count = 1; using (OperationContextScope scope = new OperationContextScope((IContextChannel)client)) { OperationContext context = OperationContext.Current; HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty(); httpRequestProperty.Headers["AccessToken"] = 'AccessToken'; httpRequestProperty.Headers["LocationToken"] = 'LocationToken'; context.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty; String groupToken = "b05c3b2d265c4b04826606d2f63fbd96"; DateTimeOffset startTime = new DateTimeOffset(2024, 04, 12, 0, 0, 0, new TimeSpan(0)); uint recordOffset = 0; bool includeBulkAdjustments = true; //Include GroupToken and StartTime parameters (RecordOffset and IncludeBulkAdjustments optional) in request body var request = new GetAdjustmentDetailsRequest() { GroupToken = groupToken, StartTime = startTime, RecordOffset = recordOffset, IncludeBulkAdjustments = includeBulkAdjustments, }; //Make GetAdjustmentDetails call var response = client.GetAdjustmentDetailsAsync(request); Console.WriteLine("GetAdjustmentDetails"); Console.WriteLine("--------------------"); //If call is successful if (response.Result.ResultCode == 0) { Console.WriteLine(response.Result.ResultCode); if (response.Result.Adjustments.Length > 0) { //Loop through collection of AdjustmentDetail objects returned foreach (var detail in response.Result.Adjustments) { Console.WriteLine("Activity Type: " + detail.ActivityType); Console.WriteLine("CustomerId: " + detail.CustomerId); Console.WriteLine("IsBulkAdjustment: " + detail.IsBulkAdjustment); Console.WriteLine("Notes: " + detail.Notes); Console.WriteLine("PlanId: " + detail.PlanId); Console.WriteLine("ReasonId: " + detail.ReasonId); Console.WriteLine("RewardId: " + detail.RewardId); Console.WriteLine("RewardValue: " + detail.RewardValue); Console.WriteLine("Time: " + detail.Time); Console.WriteLine("Value: " + detail.Value); Console.WriteLine("---------------------------"); } } else { Console.WriteLine("No Adjustment Details"); Console.WriteLine("---------------------------"); } Console.WriteLine("End"); Console.ReadKey(); } } } catch (Exception ex) { Console.WriteLine("Error calling GetAdjustmentDetails operation: " + ex.Message); } } } }
GetAwardRedemptions Sample Codeusing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ServiceModel; using System.ServiceModel.Web; using Loyalty2_GetAwardRedemptions.Loyalty2ServiceReference; namespace Loyalty2_GetAwardRedemptions { class Program { static void Main(string[] args) { //Connect to Loyalty2 service client var client = new LoyaltyWebService2Client(); //Set security protocol to TLS 1.2 System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; using (var scope = new OperationContextScope(client.InnerChannel)) { //Include token in HTTP Web Request Header var headers = WebOperationContext.Current.OutgoingRequest.Headers; headers["Authorization"] = @"Token {{AccessToken}}"; String groupToken = @"GroupToken"; DateTimeOffset startTime = new DateTimeOffset(2001, 01, 01, 0, 0, 0, new TimeSpan(0)); uint recordOffset = 1; Guid customerId = new Guid(); //Include GroupToken and StartTime parameters (RecordOffset and CustomerId optional) in request body var request = new GetAwardRedemptionsRequest() { GroupToken = groupToken, StartTime = startTime, RecordOffset = recordOffset, CustomerId = customerId, }; //Make GetAwardRedemptions call var response = client.GetAwardRedemptions(request); //If call is successful if (response.ResultCode == 0) { if (response.Redemptions != null) { //Loop through collection of AwardRedemption objects returned foreach (var redemption in response.Redemptions) { Console.WriteLine("Id: " + redemption.Id); Console.WriteLine("AwardId: " + redemption.AwardId); Console.WriteLine("LocationId: " + redemption.LocationId); Console.WriteLine("OrderId: " + redemption.OrderId); Console.WriteLine("Time: " + redemption.Time); Console.WriteLine("Value: " + redemption.Value); Console.WriteLine("---------------------------"); } } else { Console.WriteLine("No Award Redemptions"); Console.WriteLine("---------------------------"); } Console.WriteLine("End"); Console.ReadKey(); } else { Console.WriteLine("Error Code: " + response.ResultCode); Console.WriteLine("Message: " + response.Message); Console.ReadKey(); } } } } }
GetAwardRedemptions Sample Codeusing Microsoft.Extensions.DependencyInjection; using ServiceReference8; using System.ServiceModel; using System.ServiceModel.Channels; namespace Loyalty2_GetAwardRedemptions { class Program { public static ServiceCollection services = new ServiceCollection(); public static void AddLoyaltyServiceClient() { services.AddTransient<ILoyaltyWebService2>((provider) => { BasicHttpBinding binding = new BasicHttpBinding(); binding.MaxReceivedMessageSize = 2147483647; EndpointAddress endpointAddress = new EndpointAddress("{YOUR_WSDL_URL_GOES_HERE}"); ChannelFactory<ILoyaltyWebService2> factory = new ChannelFactory<ILoyaltyWebService2>(binding, endpointAddress); return factory.CreateChannel(); }); } static void Main(string[] args) { AddLoyaltyServiceClient(); ILoyaltyWebService2 client = services.BuildServiceProvider().GetRequiredService<ILoyaltyWebService2>(); try { int count = 1; using (OperationContextScope scope = new OperationContextScope((IContextChannel)client)) { OperationContext context = OperationContext.Current; HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty(); httpRequestProperty.Headers["AccessToken"] = 'AccessToken'; httpRequestProperty.Headers["LocationToken"] = 'LocationToken'; context.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty; String groupToken = "b05c3b2d265c4b04826606d2f63fbd96"; DateTimeOffset startTime = new DateTimeOffset(2024, 04, 12, 0, 0, 0, new TimeSpan(0)); uint recordOffset = 0; Guid customerId = new Guid(); //Include GroupToken and StartTime parameters (RecordOffset and CustomerId optional) in request body var request = new GetAwardRedemptionsRequest() { GroupToken = groupToken, StartTime = startTime, RecordOffset = recordOffset, CustomerId = customerId, }; //Make GetAwardRedemptions call var response = client.GetAwardRedemptionsAsync(request); Console.WriteLine("GetAwardRedemptions"); Console.WriteLine("---------------------"); //If call is successful if (response.Result.ResultCode == 0) { Console.WriteLine(response.Result.ResultCode); if (response.Result.Redemptions != null) { //Loop through collection of AwardRedemption objects returned foreach (var redemption in response.Result.Redemptions) { Console.WriteLine("Id: " + redemption.Id); Console.WriteLine("AwardId: " + redemption.AwardId); Console.WriteLine("LocationId: " + redemption.LocationId); Console.WriteLine("OrderId: " + redemption.OrderId); Console.WriteLine("Time: " + redemption.Time); Console.WriteLine("Value: " + redemption.Value); Console.WriteLine("---------------------------"); } } else { Console.WriteLine("No Award Redemptions"); Console.WriteLine("---------------------------"); } Console.WriteLine("End"); Console.ReadKey(); } } } catch (Exception ex) { Console.WriteLine("Error calling GetAwardRedemptions operation: " + ex.Message); } } } }
RedeemAwards Sample Codeusing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ServiceModel; using System.ServiceModel.Web; using Loyalty2_RedeemAwards.Loyalty2ServiceReference; namespace Loyalty2_RedeemAwards { class Program { static void Main(string[] args) { //Connect to Loyalty2 service client var client = new LoyaltyWebService2Client(); //Set security protocol to TLS 1.2 System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; using (var scope = new OperationContextScope(client.InnerChannel)) { //Include token in HTTP Web Request Header var headers = WebOperationContext.Current.OutgoingRequest.Headers; headers["Authorization"] = @"Token {{AccessToken}}"; String groupToken = @"GroupToken"; int[] awardIds = new int[]{ 1, 2, 3}; bool allowPartialSuccess = true; //Include GroupToken and AwardIds parameters (AllowPartialSuccess optional) in request body var request = new RedeemAwardsRequest() { GroupToken = groupToken, AwardIds = awardIds, AllowPartialSuccess = allowPartialSuccess, }; //Make RedeemAwards call var response = client.RedeemAwards(request); //If call is only partially successful or unsuccessful if (response.ResultCode != 0) { Console.WriteLine("Error Code: " + response.ResultCode); Console.WriteLine("Message: " + response.Message); Console.WriteLine("---------------------------"); } else { Console.WriteLine("Success!"); Console.WriteLine("---------------------------"); } //List status of the awards if (response.AlreadyRedeemedAwardIds.Length > 0) { Console.WriteLine("AlreadyRedeemedAwardIds:"); foreach (var id in response.AlreadyRedeemedAwardIds) { Console.WriteLine("\t" + id); } } else { Console.WriteLine("No Already Redeemed Awards"); } Console.WriteLine("---------------------------"); if (response.InvalidAwardIds.Length > 0) { Console.WriteLine("InvalidAwardIds:"); foreach (var id in response.InvalidAwardIds) { Console.WriteLine("\t" + id); } } else { Console.WriteLine("No Invalid Awards"); } Console.WriteLine("---------------------------"); if (response.SuccessfulAwardIds.Length > 0) { Console.WriteLine("SuccessfulAwardIds:"); foreach (var id in response.SuccessfulAwardIds) { Console.WriteLine("\t" + id); } } else { Console.WriteLine("No Successful Awards"); } Console.WriteLine("---------------------------"); Console.WriteLine("End"); Console.ReadKey(); } } } }
RedeemAwards Sample Codeusing Microsoft.Extensions.DependencyInjection; using ServiceReference8; using System.ServiceModel; using System.ServiceModel.Channels; namespace Loyalty2_RedeemAwards { class Program { public static ServiceCollection services = new ServiceCollection(); public static void AddLoyaltyServiceClient() { services.AddTransient<ILoyaltyWebService2>((provider) => { BasicHttpBinding binding = new BasicHttpBinding(); binding.MaxReceivedMessageSize = 2147483647; EndpointAddress endpointAddress = new EndpointAddress("{YOUR_WSDL_URL_GOES_HERE}"); ChannelFactory<ILoyaltyWebService2> factory = new ChannelFactory<ILoyaltyWebService2>(binding, endpointAddress); return factory.CreateChannel(); }); } static void Main(string[] args) { AddLoyaltyServiceClient(); ILoyaltyWebService2 client = services.BuildServiceProvider().GetRequiredService<ILoyaltyWebService2>(); try { int count = 1; using (OperationContextScope scope = new OperationContextScope((IContextChannel)client)) { OperationContext context = OperationContext.Current; HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty(); httpRequestProperty.Headers["AccessToken"] = 'AccessToken'; httpRequestProperty.Headers["LocationToken"] = 'LocationToken'; context.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty; String groupToken = "b05c3b2d265c4b04826606d2f63fbd96"; int[] awardIds = new int[] { 1, 2, 3 }; bool allowPartialSuccess = true; var request = new RedeemAwardsRequest() { GroupToken = groupToken, AwardIds = awardIds, AllowPartialSuccess = allowPartialSuccess, }; //Make RedeemAwards call var response = client.RedeemAwardsAsync(request); Console.WriteLine("RedeemAwards"); Console.WriteLine("-------------"); //If call is only partially successful or unsuccessful if (response.Result.ResultCode != 0) { Console.WriteLine("Error Code: " + response.Result.ResultCode); Console.WriteLine("Message: " + response.Result.Message); Console.WriteLine("---------------------------"); } else { Console.WriteLine("Success!"); Console.WriteLine("---------------------------"); } //List status of the awards if (response.Result.AlreadyRedeemedAwardIds.Length > 0) { Console.WriteLine("AlreadyRedeemedAwardIds:"); foreach (var id in response.Result.AlreadyRedeemedAwardIds) { Console.WriteLine("\t" + id); } } else { Console.WriteLine("No Already Redeemed Awards"); } Console.WriteLine("---------------------------"); if (response.Result.InvalidAwardIds.Length > 0) { Console.WriteLine("InvalidAwardIds:"); foreach (var id in response.Result.InvalidAwardIds) { Console.WriteLine("\t" + id); } } else { Console.WriteLine("No Invalid Awards"); } Console.WriteLine("---------------------------"); if (response.Result.SuccessfulAwardIds.Length > 0) { Console.WriteLine("SuccessfulAwardIds:"); foreach (var id in response.Result.SuccessfulAwardIds) { Console.WriteLine("\t" + id); } } else { Console.WriteLine("No Successful Awards"); } Console.WriteLine("---------------------------"); Console.WriteLine("End"); Console.ReadKey(); } } catch (Exception ex) { Console.WriteLine("Error calling RedeemAwards operation: " + ex.Message); } } } }