@ogcio/building-blocks-sdk 0.2.98 → 0.2.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +14 -0
- package/dist/client/clients/journey/index.d.ts +36 -9
- package/dist/client/clients/journey/index.d.ts.map +1 -1
- package/dist/client/clients/journey/schema.d.ts +31 -8
- package/dist/client/clients/journey/schema.d.ts.map +1 -1
- package/dist/client/clients/messaging-public-api/citizen/index.d.ts +602 -0
- package/dist/client/clients/messaging-public-api/citizen/index.d.ts.map +1 -0
- package/dist/client/clients/messaging-public-api/citizen/index.js +34 -0
- package/dist/client/clients/messaging-public-api/citizen/index.js.map +1 -0
- package/dist/client/clients/messaging-public-api/index.d.ts +18 -0
- package/dist/client/clients/messaging-public-api/index.d.ts.map +1 -0
- package/dist/client/clients/messaging-public-api/index.js +15 -0
- package/dist/client/clients/messaging-public-api/index.js.map +1 -0
- package/dist/client/clients/messaging-public-api/organisation/index.d.ts +621 -0
- package/dist/client/clients/messaging-public-api/organisation/index.d.ts.map +1 -0
- package/dist/client/clients/messaging-public-api/organisation/index.js +49 -0
- package/dist/client/clients/messaging-public-api/organisation/index.js.map +1 -0
- package/dist/client/clients/messaging-public-api/schema.d.ts +2464 -0
- package/dist/client/clients/messaging-public-api/schema.d.ts.map +1 -0
- package/dist/client/clients/messaging-public-api/schema.js +2 -0
- package/dist/client/clients/messaging-public-api/schema.js.map +1 -0
- package/dist/clients-configurations/clients-configuration.json +17 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +9 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client/clients/journey/open-api-definition.json +221 -33
- package/src/client/clients/journey/schema.ts +31 -8
- package/src/client/clients/messaging-public-api/citizen/index.ts +57 -0
- package/src/client/clients/messaging-public-api/index.ts +35 -0
- package/src/client/clients/messaging-public-api/open-api-definition.json +4539 -0
- package/src/client/clients/messaging-public-api/organisation/index.ts +79 -0
- package/src/client/clients/messaging-public-api/schema.ts +2463 -0
- package/src/clients-configurations/clients-configuration.json +17 -1
- package/src/index.ts +7 -0
- package/src/types/index.ts +9 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type createClient from "openapi-fetch";
|
|
2
|
+
import type { Logger } from "../../../../types/index.js";
|
|
3
|
+
import {
|
|
4
|
+
formatError,
|
|
5
|
+
formatResponse,
|
|
6
|
+
throwIfEmpty,
|
|
7
|
+
} from "../../../utils/client-utils.js";
|
|
8
|
+
import type { paths } from "../schema.js";
|
|
9
|
+
|
|
10
|
+
type SendMessageBody =
|
|
11
|
+
paths["/api/v1/organisations/messages/"]["post"]["requestBody"]["content"]["multipart/form-data"];
|
|
12
|
+
|
|
13
|
+
export class MessagingPublicApiOrganisation {
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly client: ReturnType<typeof createClient<paths>>,
|
|
16
|
+
private readonly serviceName: string,
|
|
17
|
+
private readonly logger: Logger | undefined,
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
async send(
|
|
21
|
+
message: Omit<SendMessageBody, "attachments">,
|
|
22
|
+
attachments?: File[],
|
|
23
|
+
) {
|
|
24
|
+
return this.client
|
|
25
|
+
.POST("/api/v1/organisations/messages/", {
|
|
26
|
+
body: { ...message, attachments },
|
|
27
|
+
bodySerializer: (body: unknown) => {
|
|
28
|
+
const parsed = (body ?? {}) as Record<string, unknown>;
|
|
29
|
+
const formData = new FormData();
|
|
30
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
31
|
+
if (key === "attachments" || value === undefined) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
formData.set(
|
|
35
|
+
key,
|
|
36
|
+
typeof value === "object" ? JSON.stringify(value) : String(value),
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
for (const attachment of attachments ?? []) {
|
|
40
|
+
formData.append("attachments", attachment);
|
|
41
|
+
}
|
|
42
|
+
return formData;
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
.then(
|
|
46
|
+
(response) => formatResponse(response, this.serviceName, this.logger),
|
|
47
|
+
(reason) => formatError(reason, this.serviceName, this.logger),
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async getMessageEvents(
|
|
52
|
+
messageId: paths["/api/v1/organisations/messages/{messageId}/events"]["get"]["parameters"]["path"]["messageId"],
|
|
53
|
+
) {
|
|
54
|
+
throwIfEmpty(messageId);
|
|
55
|
+
return this.client
|
|
56
|
+
.GET("/api/v1/organisations/messages/{messageId}/events", {
|
|
57
|
+
params: { path: { messageId } },
|
|
58
|
+
})
|
|
59
|
+
.then(
|
|
60
|
+
(response) => formatResponse(response, this.serviceName, this.logger),
|
|
61
|
+
(reason) => formatError(reason, this.serviceName, this.logger),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async getLatestEvents(
|
|
66
|
+
filter: paths["/api/v1/organisations/messages/events"]["post"]["requestBody"]["content"]["application/json"],
|
|
67
|
+
query?: paths["/api/v1/organisations/messages/events"]["post"]["parameters"]["query"],
|
|
68
|
+
) {
|
|
69
|
+
return this.client
|
|
70
|
+
.POST("/api/v1/organisations/messages/events", {
|
|
71
|
+
params: { query },
|
|
72
|
+
body: filter,
|
|
73
|
+
})
|
|
74
|
+
.then(
|
|
75
|
+
(response) => formatResponse(response, this.serviceName, this.logger),
|
|
76
|
+
(reason) => formatError(reason, this.serviceName, this.logger),
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|