This commit is contained in:
@@ -13,6 +13,10 @@ namespace AyaNovaQBI
|
||||
internal class util
|
||||
{
|
||||
#region API stuff
|
||||
public static Guid QBI_INTEGRATION_ID
|
||||
{
|
||||
get { return new Guid("{82CD3609-4601-4C1A-9633-7836F92D2D06}"); }
|
||||
}
|
||||
public const string TEST_ROUTE = "notify/hello";
|
||||
public const string API_BASE_ROUTE = "api/v8/";
|
||||
private const int MAX_TRIES = 3;//max times to retry an api call before giving up
|
||||
@@ -33,6 +37,8 @@ namespace AyaNovaQBI
|
||||
|
||||
internal static AyaNovaLicense ALicense { get; set; } = null;
|
||||
|
||||
internal static Integration QBIntegration { get; set; } = null;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -539,8 +545,44 @@ namespace AyaNovaQBI
|
||||
{
|
||||
//Check for integration object at server, if not there then create one if have sufficient rights
|
||||
//check if inactive
|
||||
await Task.CompletedTask;
|
||||
return true;
|
||||
ApiResponse r = null;
|
||||
try
|
||||
{
|
||||
r = await GetAsync($"integration/exists/{QBI_INTEGRATION_ID}");
|
||||
|
||||
if (r.ObjectResponse["data"].Value<bool>() == false)
|
||||
{
|
||||
//doesn't exist, need to create it now
|
||||
QBIntegration = new Integration();
|
||||
QBIntegration.IntegrationAppId = QBI_INTEGRATION_ID;
|
||||
QBIntegration.Active = true;
|
||||
QBIntegration.Name = "QBI - QuickBooks Desktop integration";
|
||||
r = await PostAsync("integration", Newtonsoft.Json.JsonConvert.SerializeObject(QBIntegration));
|
||||
var id = IdFromResponse(r);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Exists, fetch it and we're done here
|
||||
r = await GetAsync($"integration/{QBI_INTEGRATION_ID}");
|
||||
QBIntegration = r.ObjectResponse["data"].ToObject<Integration>();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}catch(Exception ex)
|
||||
{
|
||||
initErrors.AppendLine("Error fetching QBI Integration object");
|
||||
initErrors.AppendLine(ex.Message);
|
||||
initErrors.AppendLine(r.CompactResponse);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user