Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ codeunit 6941 "EA Http Client"
CanaryAllowlistEndpointTok: Label '/api/v1.0/canary/allowlist', Locked = true;
ProdBaseUrlSecretNameTok: Label 'EABaseUrl', Locked = true;
CanaryBaseUrlSecretNameTok: Label 'EABaseUrlCanary', Locked = true;
ExpenseAgentSetupMissingTxt: Label 'Expense Agent setup is missing. The service request was not sent.', Locked = true;

[NonDebuggable]
procedure SubmitExpenseWithAttachments(ConversationId: Text; Context: Text; OnBehalfUser: Text; var TempAttachment: Record "EA Email Attachment" temporary): Boolean
Expand Down Expand Up @@ -431,14 +432,24 @@ codeunit 6941 "EA Http Client"
local procedure GetExpenseAgentBaseUrl(var BaseUrl: SecretText): Boolean
var
ExpenseAgentSetup: Record "Expense Agent Setup";
begin
Clear(BaseUrl);
if not ExpenseAgentSetup.Get() then begin
FeatureTelemetry.LogError('0000VGO', ExpenseAgentSetup.GetFeatureName(), 'Resolve service endpoint', ExpenseAgentSetupMissingTxt);
exit(false);
end;

exit(GetExpenseAgentBaseUrl(ExpenseAgentSetup."Use Canary Endpoint", BaseUrl));
end;

local procedure GetExpenseAgentBaseUrl(UseCanaryEndpoint: Boolean; var BaseUrl: SecretText): Boolean
var
AzureKeyVault: Codeunit "Azure Key Vault";
SecretName: Text;
begin
SecretName := ProdBaseUrlSecretNameTok;
if ExpenseAgentSetup.Get() then
if ExpenseAgentSetup."Use Canary Endpoint" then
SecretName := CanaryBaseUrlSecretNameTok;
exit(AzureKeyVault.GetAzureKeyVaultSecret(SecretName, BaseUrl));
if UseCanaryEndpoint then
exit(AzureKeyVault.GetAzureKeyVaultSecret(CanaryBaseUrlSecretNameTok, BaseUrl));

exit(GetProductionBaseUrl(BaseUrl));
end;

local procedure GetProductionBaseUrl(var BaseUrl: SecretText): Boolean
Expand All @@ -449,19 +460,19 @@ codeunit 6941 "EA Http Client"
end;

[NonDebuggable]
procedure RegisterErpConfiguration(): Boolean
procedure RegisterErpConfiguration(UseCanaryEndpoint: Boolean): Boolean
begin
exit(SendErpConfigRequest('POST', ErpRegistrationFailedErr));
exit(SendErpConfigRequest('POST', ErpRegistrationFailedErr, UseCanaryEndpoint));
end;

[NonDebuggable]
procedure UnregisterErpConfiguration(): Boolean
procedure UnregisterErpConfiguration(UseCanaryEndpoint: Boolean): Boolean
begin
exit(SendErpConfigRequest('DELETE', ErpUnregistrationFailedErr));
exit(SendErpConfigRequest('DELETE', ErpUnregistrationFailedErr, UseCanaryEndpoint));
end;

[NonDebuggable]
local procedure SendErpConfigRequest(HttpMethod: Text; FailureError: Text): Boolean
local procedure SendErpConfigRequest(HttpMethod: Text; FailureError: Text; UseCanaryEndpoint: Boolean): Boolean
var
ExpenseAgentSetup: Record "Expense Agent Setup";
Client: HttpClient;
Expand All @@ -473,7 +484,7 @@ codeunit 6941 "EA Http Client"
Url: Text;
BaseUrl: SecretText;
begin
if not GetExpenseAgentBaseUrl(BaseUrl) then begin
if not GetExpenseAgentBaseUrl(UseCanaryEndpoint, BaseUrl) then begin
Message(FailureError);
exit(false);
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ pageextension 6995 "EA Agent Card" extends "Agent Card"

var
ExpenseAgentNotificationId: Guid;
ExpenseAgentInfoMsg: Label 'Additional options are available in the Setup page.';
OpenSetupLbl: Label 'Open Expense Agent Setup';
ExpenseAgentInfoMsg: Label 'Use Expense Management Setup to configure general expense and accounting settings. Use Configure to set up the agent.';
OpenSetupLbl: Label 'Open Expense Management Setup';
}
Loading
Loading