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
Awards
Array of Award
Awards that the Customer submitted has
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
EarnedOrderId
long
Maps to the Id of the Order on which this Award was earned
EligibleLocationId
Guid
Location Id at which this Award is eligible, empty Guid if eligible at all locations
EmployeeId
int
Maps to the Id of the Employee who granted this Award
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
RedemptionEmployeeId
int
Maps to the Id of the Employee who accepted redemption of this Award
RedemptionLocationId
Guid
Location Id at which this Award was redeemed
RewardRedemptionOptions
RewardRedemption Options
Returns one of the following:
  • None
  • Required
  • Multiple
  • Undefined
RedemptionOrderId
long
Maps to the Id of the Order on which this Award was redeemed
Redemptions
Array of Redemption
Time at which this Award was redeemed
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
EmployeeId
int
Maps to the Id of the Employee who accepted redemption of this Award
Id
int
Unique Id of this Redemption
LocationId
Guid
Location Id at which this Award was redeemed
OrderId
long
Maps to the Id of the Order on which this Award was redeemed
Time
DateTime
Time at which this Award was redeemed
Value
decimal
Value of this Redemption

                    
                        
                        
                        
                        
GetAwards Sample Code
using 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 Code
using 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); } } } }
GetAwards Sample Code
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.brinksoftware.com/webservices/loyalty/20140330"> <soapenv:Header/> <soapenv:Body> <ns:GetAwards> <ns:request> <ns:CustomerId>00000000-0000-0000-0000-000000000000</ns:CustomerId> </ns:request> </ns:GetAwards> </soapenv:Body> </soapenv:Envelope>
GetAwards Sample Code
from zeep import Client from zeep.transports import Transport import requests import uuid accessToken = 'AccessToken' locationToken = 'LocationToken' #Include tokens in HTTP Web Request Headers session = requests.Session() session.headers.update({'AccessToken': accessToken, 'LocationToken': locationToken}) transport = Transport(session=session) #Connect to Loyalty service client client = Client(wsdl='{YOUR_WSDL_URL_GOES_HERE}', transport=transport) service = client.create_service( '{http://www.brinksoftware.com/webservices/loyalty/20140330}BasicHttpBinding_ILoyaltyWebService', 'https://{YourStack}.brinkpos.net/loyalty.svc' ) reqType = client.get_type('ns1:GetAwardsRequest') customer = uuid.UUID('{00000000-0000-0000-0000-000000000000}') req = reqType(CustomerId=customer) try: #Make GetAwards call res = service.GetAwards(req) #If call is successful if res.ResultCode == 0: if res.Awards != None: #Loop through collection of Award objects returned for award in res.Awards.Award: print('Id: ' + str(award.Id)) print('RewardId: ' + str(award.RewardId)) print('RewardName: ' + str(award.RewardName)) print('Value: ' + str(award.Value)) print('DiscountRemaining: ' + str(award.DiscountRemaining)) print('EarnedOrderId: ' + str(award.EarnedOrderId)) print('EligibleLocationId: ' + str(award.EligibleLocationId)) print('EmployeeId: ' + str(award.EmployeeId)) print('ExpirationDate: ' + str(award.ExpirationDate)) print('PlanId: ' + str(award.PlanId)) print('Redeemed: ' + str(award.Redeemed)) print('RedeemedValue: ' + str(award.RedeemedValue)) print('RedemptionEmployeeId: ' + str(award.RedemptionEmployeeId)) print('RedemptionLocationId: ' + str(award.RedemptionLocationId)) print('RedemptionOptions: ' + str(award.RedemptionOptions)) print('RedemptionOrderId: ' + str(award.RedemptionOrderId)) print('RedemptionTime: ' + str(award.RedemptionTime)) if award.Redemptions != None: print('Redemptions:') #Loop through collection of Redemption objects returned for each Award for redemption in award.Redemptions.Redemption: print('\tId: ' + str(redemption.Id)) print('\tOrderId: ' + str(redemption.OrderId)) print('\tValue: ' + str(redemption.Value)) print('\tLocationId: ' + str(redemption.LocationId)) print('\tEmployeeId: ' + str(redemption.EmployeeId)) print('\tTime: ' + str(redemption.Time)) print('\t------------') else: print('Redemptions: None') print('RewardLocationId: ' + str(award.RewardLocationId)) print('RewardText: ' + str(award.RewardText)) print('RewardTime: ' + str(award.RewardTime)) print('ValidFromDate: ' + str(award.ValidFromDate)) print('ValidTerminalTypes: ' + str(award.ValidTerminalTypes)) print('---------------------------') else: print('No Awards') print('---------------------------') print('End') else: print('Error Code: ' + str(res.ResultCode)) print('Message: ' + str(res.Message)) except Exception as e: print(e)