Ver Fonte

Added LicenseSummary endpoint and Ping endpoint

Kenric Nugteren há 1 ano atrás
pai
commit
d2db0bf831
1 ficheiros alterados com 66 adições e 1 exclusões
  1. 66 1
      prs.licensing/Engine/LicensingEngine.cs

+ 66 - 1
prs.licensing/Engine/LicensingEngine.cs

@@ -26,13 +26,78 @@ public class LicensingHandler : Handler<LicensingHandlerProperties>
     {
     }
 
+    private IResponseBuilder LicenseSummary(IRequest request)
+    {
+        var summary = new LicenseSummary {
+            LicenseFees = new() {
+                { typeof(CoreLicense).EntityName(),                 7.99 },
+                { typeof(DigitalFormsLicense).EntityName(),         3.99 },
+                { typeof(SchedulingControlLicense).EntityName(),    1.99 },
+                { typeof(TimeManagementLicense).EntityName(),       2.99 },
+                { typeof(AccountsPayableLicense).EntityName(),      1.99 },
+                { typeof(GPSTrackerLicense).EntityName(),           2.99 },
+                { typeof(LogisticsLicense).EntityName(),            4.99 },
+                { typeof(ScheduleEngineLicense).EntityName(),       2.99 },
+                { typeof(QuotesManagementLicense).EntityName(),     4.99 },
+                { typeof(LeaveManagementLicense).EntityName(),      2.99 },
+                { typeof(TaskManagementLicense).EntityName(),       1.99 },
+                { typeof(WarehouseLicense).EntityName(),            5.99 },
+                { typeof(ProjectManagementLicense).EntityName(),    4.99 },
+                { typeof(ManufacturingLicense).EntityName(),        4.99 },
+                { typeof(ProductManagementLicense).EntityName(),    2.99 },
+                { typeof(EquipmentLicense).EntityName(),            2.99 },
+                { typeof(HumanResourcesLicense).EntityName(),       2.99 },
+                { typeof(AccountsReceivableLicense).EntityName(),   1.99 }
+            },
+            TimeDiscounts = new() {
+                { 1,    0.00 },
+                { 3,    5.00 },
+                { 6,    5.00 },
+                { 12,   10.00 }
+            },
+            UserDiscounts = new() {
+                { 1,    00.31 },
+                { 6,    08.63 },
+                { 11,   16.94 },
+                { 21,   25.25 },
+                { 51,   33.57 }
+            }
+        };
+        return request.Respond().Status(ResponseStatus.OK).Content(Serialization.Serialize(summary));
+    }
+
+    private IResponseBuilder RenewLicense(IRequest request)
+    {
+        return request.Respond().Status(ResponseStatus.NotFound);
+    }
+    private IResponseBuilder Ping(IRequest request)
+    {
+        return request.Respond().Status(ResponseStatus.OK);
+    }
+
     private IResponseBuilder HandleGET(IRequest request)
     {
-        return request.Respond().Content("Hello, World!").Status(ResponseStatus.OK);
+        var endpoint = request.Target.Current?.Value.ToLower() ?? "";
+
+        if(endpoint == nameof(LicenseSummary).ToLower())
+        {
+            return LicenseSummary(request);
+        }
+        else if(endpoint == nameof(Ping).ToLower())
+        {
+            return Ping(request);
+        }
+        return request.Respond().Status(ResponseStatus.NotFound);
     }
 
     private IResponseBuilder HandlePOST(IRequest request)
     {
+        var endpoint = string.Join('/', request.Target.GetRemaining());
+        if(endpoint == nameof(RenewLicense).ToLower())
+        {
+            return RenewLicense(request);
+        }
+
         return request.Respond().Status(ResponseStatus.NotFound);
     }