-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPZGet.cs
More file actions
36 lines (32 loc) · 964 Bytes
/
PZGet.cs
File metadata and controls
36 lines (32 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using OldMusicBox.ePUAP.Client.Model.Common;
using OldMusicBox.ePUAP.Client;
using System.Security.Cryptography.X509Certificates;
using OldMusicBox.ePUAP.Client.Model.GetSignedDocument;
using Newtonsoft.Json;
namespace PZBridge
{
internal class PZGet
{
public static void Execute(X509Certificate2 cert, string[] args)
{
if (args.Length < 2)
{
Program.SendFault("get: not enough arguments\nsyntax: get <env> <url>");
return;
}
if (args[0] == "stub") {
PZGetStub.Execute(args);
return;
}
TpSigning5Client client = new(args[0] == "prod" ? TpSigning5Client.PRODUCTION_URI : TpSigning5Client.INTEGRATION_URI, cert);
FaultModel faultModel;
GetSignedDocument5Response response = client.GetSignedDocument(args[1], out faultModel);
if(faultModel != null)
{
Program.SendFault(faultModel);
return;
}
Console.Write("{\"ok\": true, \"data\": " + JsonConvert.SerializeObject(response) + "}");
}
}
}