Program.cs
/// <summary>
/// Square 9 API Quickstart Sample:
/// 
/// When processing volumes of work in the context of a service worker, it is considered best practice to
/// reuse a longlived token, rather than to request and dispose of a license token for each request. In
/// simple terms this can reduce each transaction from 3 calls to one, and greatly reduce load on the SQL
/// database by preventing additional queries necessitated by the create license process.
/// 
/// Example API Consumer Service Workflow:
/// 1. Ensure we have a token:
///     (a) Load our stored license token (if we have one).
///     (b) If we do not have one, request a new one and save it for future use.
/// 2. Do any work that needs to be completed.
/// 3. If we are unable to complete work because our license is expired:
///     (a) Remove invalid stored token.
///     (b) Restart the flow, if we have not failed too many times already.
/// </summary>
/// <param name="args"></param>
Square 9 API Quickstart Sample.

When processing volumes of work in the context of a service worker, it is considered best practice to
reuse a longlived token, rather than to request and dispose of a license token for each request. In
simple terms this can reduce each transaction from 3 calls to one, and greatly reduce load on the SQL
database by preventing additional queries necessitated by the create license process.

Example API Consumer Service Workflow:
1. Ensure we have a token:
(a) Load our stored license token (if we have one).
(b) If we do not have one, request a new one and save it for future use.
2. Do any work that needs to be completed.
3. If we are unable to complete work because our license is expired:
(a) Remove invalid stored token.
(b) Restart the flow, if we have not failed too many times already.
Square 9 API Quickstart Sample . When processing volumes of work in the context of a service worker it is considered best practice to reuse a longlived token rather than to request and dispose of a license token for each request . In simple terms this can reduce each transaction from 3 calls to one and greatly reduce load on the SQL database by preventing additional queries necessitated by the create license process . Example API Consumer Service Workflow : 1 . Ensure we have a token : ( a ) Load our stored license token ( if we have one ) . ( b ) If we do not have one request a new one and save it for future use . 2 . Do any work that needs to be completed . 3 . If we are unable to complete work because our license is expired : ( a ) Remove invalid stored token . ( b ) Restart the flow if we have not failed too many times already .
static async Task Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
                .AddJsonFile("appsettings.json")
                .Build();
            var apiConfig = config.GetSection("Square9ApiConfig").Get<ApiConfig>();
            await GetTokenAndDoWork(apiConfig);
        }
static async Task Main ( string [ ] args ) { var config = new ConfigurationBuilder ( ) . SetBasePath ( AppDomain . CurrentDomain . BaseDirectory ) . AddJsonFile ( " " ) . Build ( ) ; var apiConfig = config . GetSection ( " " ) . Get < ApiConfig > ( ) ; await GetTokenAndDoWork ( apiConfig ) ; }
Square 9 API Quickstart Sample:
Square 9 API Quickstart Sample :
// Load our configuration options. // Ensure we have a token and attempt to complete our "work".
args
string[]
None