Loyalty.svc
Sending a Request to Loyalty.svc
All calls to Loyalty.svc require the AccessToken and the LocationToken in the HTTP Web Request Headers of the request. The parameters for the request body of each call are outlined in the sections below.
Loyalty.svc Endpoint
Endpoint
https://{{server}}.brinkpos.net/Loyalty.svc
HTTP Web Request Headers
Header Name
Header Value
AccessToken
{{AccessToken}}
LocationToken
{{LocationToken}}
This call is to retrieve an array of Award objects for the location.
GetAwards Request
Data Name
Data Type
Data Description
CustomerId
Guid
Specify the Customer Id who you would like to get awards for
GetAwards 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
Global Type
All the Types available in Loyalty.svc will be displayed below.
Award Type
Data Name
Data Type
Data Description
DiscountRemaining
decimal
Amount of discount remaining on this Award
EligibleLocationId
Guid
Location Id at which this Award is eligible, empty Guid if eligible at all locations
ExpirationDate
DateTime
Expiration date of this Award (the time component will always return as 00:00:00)
Id
int
Unique Id of this Award
PlanId
int
Plan Id of this Award
Redeemed
bool
True if this Award has been redeemed, False if not
RedeemedValue
decimal
Value redeemed on this Award
RedemptionLocationId
Guid
Location Id at which this Award was redeemed
RewardRedemptionOptions
RewardRedemption Options
Returns one of the following:
- None
- Required
- Multiple
- Undefined
RedemptionTime
DateTime
Redemptions for this Award
RewardId
int
Reward Id of this Award
RewardLocationId
Guid
Location Id at which this Award was rewarded
RewardName
string
Name of this Award
RewardText
string
Text associated with this Award
RewardTime
DateTime
Time at which this Award was rewarded
ValidFromDate
DateTime
Date from which this Award is valid (the time component will always return as 00:00:00)
ValidTerminalTypes
ValidTerminalType
Returns one or more of the following:
- None
- Register
- CustomerPortal
- CustomerPortalMobile
- WebService
- MobileApp
Value
decimal
Value of this Award
Redemption Type
Data Name
Data Type
Data Description
Id
int
Unique Id of this Redemption
LocationId
Guid
Location Id at which this Award was redeemed
Time
DateTime
Time at which this Award was redeemed
Value
decimal
Value of this Redemption
GetAwards 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 Loyalty_GetAwards.LoyaltyServiceReference; namespace Loyalty_GetAwards { class Program { static void Main(string[] args) { //Connect to Loyalty service client var client = new LoyaltyWebServiceClient(); //Set security protocol to TLS 1.2 System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; using (var scope = new OperationContextScope(client.InnerChannel)) { //Include tokens in HTTP Web Request Headers var headers = WebOperationContext.Current.OutgoingRequest.Headers; headers["AccessToken"] = @"AccessToken"; headers["LocationToken"] = @"LocationToken"; Guid customerId = Guid.Empty; //Include CustomerId parameter in request body var request = new GetAwardsRequest() { CustomerId = customerId, }; //Make GetAwards call var response = client.GetAwards(request); //If call is successful if (response.ResultCode == 0) { if (response.Awards.Length > 0) { //Loop through collection of Award objects returned foreach (var award in response.Awards) { Console.WriteLine("Id: " + award.Id); Console.WriteLine("RewardId: " + award.RewardId); Console.WriteLine("RewardName: " + award.RewardName); Console.WriteLine("Value: " + award.Value); Console.WriteLine("DiscountRemaining: " + award.DiscountRemaining); Console.WriteLine("EarnedOrderId: " + award.EarnedOrderId); Console.WriteLine("EligibleLocationId: " + award.EligibleLocationId); Console.WriteLine("EmployeeId: " + award.EmployeeId); Console.WriteLine("ExpirationDate: " + award.ExpirationDate); Console.WriteLine("PlanId: " + award.PlanId); Console.WriteLine("Redeemed: " + award.Redeemed); Console.WriteLine("RedeemedValue: " + award.RedeemedValue); Console.WriteLine("RedemptionEmployeeId: " + award.RedemptionEmployeeId); Console.WriteLine("RedemptionLocationId: " + award.RedemptionLocationId); Console.WriteLine("RedemptionOptions: " + award.RedemptionOptions); Console.WriteLine("RedemptionOrderId: " + award.RedemptionOrderId); Console.WriteLine("RedemptionTime: " + award.RedemptionTime); Console.WriteLine("Redemptions:"); if (award.Redemptions != null) { //Loop through collection of Redemption objects returned for each Award foreach (var redemption in award.Redemptions) { Console.WriteLine("\tId: " + redemption.Id); Console.WriteLine("\tOrderId: " + redemption.OrderId); Console.WriteLine("\tValue: " + redemption.Value); Console.WriteLine("\tLocationId: " + redemption.LocationId); Console.WriteLine("\tEmployeeId: " + redemption.EmployeeId); Console.WriteLine("\tTime: " + redemption.Time); Console.WriteLine("\t------------"); } } Console.WriteLine("RewardLocationId: " + award.RewardLocationId); Console.WriteLine("RewardText: " + award.RewardText); Console.WriteLine("RewardTime: " + award.RewardTime); Console.WriteLine("ValidFromDate: " + award.ValidFromDate); Console.WriteLine("ValidTerminalTypes: " + award.ValidTerminalTypes); Console.WriteLine("---------------------------"); } } else { Console.WriteLine("No Awards"); Console.WriteLine("---------------------------"); } Console.WriteLine("End"); Console.ReadKey(); } else { Console.WriteLine("Error Code: " + response.ResultCode); Console.WriteLine("Message: " + response.Message); Console.ReadKey(); } } } } }
GetAwards Sample Codeusing Microsoft.Extensions.DependencyInjection; using ServiceReference7; using System.ServiceModel; using System.ServiceModel.Channels; namespace Loyalty_GetAwards { class Program { public static ServiceCollection services = new ServiceCollection(); public static void AddLoyaltyServiceClient() { services.AddTransient<ILoyaltyWebService>((provider) => { BasicHttpBinding binding = new BasicHttpBinding(); binding.MaxReceivedMessageSize = 2147483647; EndpointAddress endpointAddress = new EndpointAddress("{YOUR_WSDL_URL_GOES_HERE}"); ChannelFactory<ILoyaltyWebService> factory = new ChannelFactory<ILoyaltyWebService>(binding, endpointAddress); return factory.CreateChannel(); }); } static void Main(string[] args) { AddLoyaltyServiceClient(); ILoyaltyWebService client = services.BuildServiceProvider().GetRequiredService<ILoyaltyWebService>(); try { 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 = Guid.Empty; //Include CustomerId parameter in request body var request = new GetAwardsRequest() { CustomerId = customerId, }; //Make GetAwards call var response = client.GetAwardsAsync(request); //If call is successful if (response.Result.ResultCode == 0) { if (response.Result.Awards.Length > 0) { //Loop through collection of Award objects returned foreach (var award in response.Result.Awards) { Console.WriteLine("Id: " + award.Id); Console.WriteLine("RewardId: " + award.RewardId); Console.WriteLine("RewardName: " + award.RewardName); Console.WriteLine("Value: " + award.Value); Console.WriteLine("DiscountRemaining: " + award.DiscountRemaining); Console.WriteLine("EarnedOrderId: " + award.EarnedOrderId); Console.WriteLine("EligibleLocationId: " + award.EligibleLocationId); Console.WriteLine("EmployeeId: " + award.EmployeeId); Console.WriteLine("ExpirationDate: " + award.ExpirationDate); Console.WriteLine("PlanId: " + award.PlanId); Console.WriteLine("Redeemed: " + award.Redeemed); Console.WriteLine("RedeemedValue: " + award.RedeemedValue); Console.WriteLine("RedemptionEmployeeId: " + award.RedemptionEmployeeId); Console.WriteLine("RedemptionLocationId: " + award.RedemptionLocationId); Console.WriteLine("RedemptionOptions: " + award.RedemptionOptions); Console.WriteLine("RedemptionOrderId: " + award.RedemptionOrderId); Console.WriteLine("RedemptionTime: " + award.RedemptionTime); Console.WriteLine("Redemptions:"); if (award.Redemptions != null) { //Loop through collection of Redemption objects returned for each Award foreach (var redemption in award.Redemptions) { Console.WriteLine("\tId: " + redemption.Id); Console.WriteLine("\tOrderId: " + redemption.OrderId); Console.WriteLine("\tValue: " + redemption.Value); Console.WriteLine("\tLocationId: " + redemption.LocationId); Console.WriteLine("\tEmployeeId: " + redemption.EmployeeId); Console.WriteLine("\tTime: " + redemption.Time); Console.WriteLine("\t------------"); } } Console.WriteLine("RewardLocationId: " + award.RewardLocationId); Console.WriteLine("RewardText: " + award.RewardText); Console.WriteLine("RewardTime: " + award.RewardTime); Console.WriteLine("ValidFromDate: " + award.ValidFromDate); Console.WriteLine("ValidTerminalTypes: " + award.ValidTerminalTypes); Console.WriteLine("---------------------------"); } } else { Console.WriteLine("No Awards"); Console.WriteLine("---------------------------"); } Console.WriteLine("End"); Console.ReadKey(); } else { Console.WriteLine("Error Code: " + response.Result.ResultCode); Console.WriteLine("Message: " + response.Result.Message); } } } catch (Exception ex) { Console.WriteLine("Error calling GetAwards operation: " + ex.Message); } } } }