pingen2-sdk-js 0.1.2 → 0.2.0

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.
Files changed (224) hide show
  1. package/dist/index.d.mts +814 -0
  2. package/dist/index.d.ts +814 -12
  3. package/dist/index.js +1190 -59
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +1106 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +16 -3
  8. package/dist/client.d.ts +0 -30
  9. package/dist/client.d.ts.map +0 -1
  10. package/dist/client.js +0 -72
  11. package/dist/client.js.map +0 -1
  12. package/dist/common/enums/address-position.d.ts +0 -5
  13. package/dist/common/enums/address-position.d.ts.map +0 -1
  14. package/dist/common/enums/address-position.js +0 -9
  15. package/dist/common/enums/address-position.js.map +0 -1
  16. package/dist/common/enums/delivery-product.d.ts +0 -8
  17. package/dist/common/enums/delivery-product.d.ts.map +0 -1
  18. package/dist/common/enums/delivery-product.js +0 -12
  19. package/dist/common/enums/delivery-product.js.map +0 -1
  20. package/dist/common/enums/index.d.ts +0 -6
  21. package/dist/common/enums/index.d.ts.map +0 -1
  22. package/dist/common/enums/index.js +0 -14
  23. package/dist/common/enums/index.js.map +0 -1
  24. package/dist/common/enums/paper-type.d.ts +0 -7
  25. package/dist/common/enums/paper-type.d.ts.map +0 -1
  26. package/dist/common/enums/paper-type.js +0 -11
  27. package/dist/common/enums/paper-type.js.map +0 -1
  28. package/dist/common/enums/print-mode.d.ts +0 -5
  29. package/dist/common/enums/print-mode.d.ts.map +0 -1
  30. package/dist/common/enums/print-mode.js +0 -9
  31. package/dist/common/enums/print-mode.js.map +0 -1
  32. package/dist/common/enums/print-spectrum.d.ts +0 -5
  33. package/dist/common/enums/print-spectrum.d.ts.map +0 -1
  34. package/dist/common/enums/print-spectrum.js +0 -9
  35. package/dist/common/enums/print-spectrum.js.map +0 -1
  36. package/dist/common/index.d.ts +0 -8
  37. package/dist/common/index.d.ts.map +0 -1
  38. package/dist/common/index.js +0 -24
  39. package/dist/common/index.js.map +0 -1
  40. package/dist/common/json-api.d.ts +0 -37
  41. package/dist/common/json-api.d.ts.map +0 -1
  42. package/dist/common/json-api.js +0 -3
  43. package/dist/common/json-api.js.map +0 -1
  44. package/dist/common/preset.d.ts +0 -13
  45. package/dist/common/preset.d.ts.map +0 -1
  46. package/dist/common/preset.js +0 -20
  47. package/dist/common/preset.js.map +0 -1
  48. package/dist/common/relationships.d.ts +0 -20
  49. package/dist/common/relationships.d.ts.map +0 -1
  50. package/dist/common/relationships.js +0 -3
  51. package/dist/common/relationships.js.map +0 -1
  52. package/dist/common/response.d.ts +0 -12
  53. package/dist/common/response.d.ts.map +0 -1
  54. package/dist/common/response.js +0 -77
  55. package/dist/common/response.js.map +0 -1
  56. package/dist/common/typed-response.d.ts +0 -29
  57. package/dist/common/typed-response.d.ts.map +0 -1
  58. package/dist/common/typed-response.js +0 -3
  59. package/dist/common/typed-response.js.map +0 -1
  60. package/dist/common/webhook-event.d.ts +0 -34
  61. package/dist/common/webhook-event.d.ts.map +0 -1
  62. package/dist/common/webhook-event.js +0 -3
  63. package/dist/common/webhook-event.js.map +0 -1
  64. package/dist/constants.d.ts +0 -10
  65. package/dist/constants.d.ts.map +0 -1
  66. package/dist/constants.js +0 -16
  67. package/dist/constants.js.map +0 -1
  68. package/dist/errors.d.ts +0 -50
  69. package/dist/errors.d.ts.map +0 -1
  70. package/dist/errors.js +0 -115
  71. package/dist/errors.js.map +0 -1
  72. package/dist/index.d.ts.map +0 -1
  73. package/dist/oauth.d.ts +0 -17
  74. package/dist/oauth.d.ts.map +0 -1
  75. package/dist/oauth.js +0 -68
  76. package/dist/oauth.js.map +0 -1
  77. package/dist/requestor.d.ts +0 -28
  78. package/dist/requestor.d.ts.map +0 -1
  79. package/dist/requestor.js +0 -163
  80. package/dist/requestor.js.map +0 -1
  81. package/dist/resources/base.d.ts +0 -19
  82. package/dist/resources/base.d.ts.map +0 -1
  83. package/dist/resources/base.js +0 -40
  84. package/dist/resources/base.js.map +0 -1
  85. package/dist/resources/batches/batches.d.ts +0 -15
  86. package/dist/resources/batches/batches.d.ts.map +0 -1
  87. package/dist/resources/batches/batches.js +0 -68
  88. package/dist/resources/batches/batches.js.map +0 -1
  89. package/dist/resources/batches/enums.d.ts +0 -39
  90. package/dist/resources/batches/enums.d.ts.map +0 -1
  91. package/dist/resources/batches/enums.js +0 -44
  92. package/dist/resources/batches/enums.js.map +0 -1
  93. package/dist/resources/batches/response.d.ts +0 -27
  94. package/dist/resources/batches/response.d.ts.map +0 -1
  95. package/dist/resources/batches/response.js +0 -3
  96. package/dist/resources/batches/response.js.map +0 -1
  97. package/dist/resources/batches/types.d.ts +0 -41
  98. package/dist/resources/batches/types.d.ts.map +0 -1
  99. package/dist/resources/batches/types.js +0 -3
  100. package/dist/resources/batches/types.js.map +0 -1
  101. package/dist/resources/ebills/ebills.d.ts +0 -13
  102. package/dist/resources/ebills/ebills.d.ts.map +0 -1
  103. package/dist/resources/ebills/ebills.js +0 -38
  104. package/dist/resources/ebills/ebills.js.map +0 -1
  105. package/dist/resources/ebills/response.d.ts +0 -27
  106. package/dist/resources/ebills/response.d.ts.map +0 -1
  107. package/dist/resources/ebills/response.js +0 -3
  108. package/dist/resources/ebills/response.js.map +0 -1
  109. package/dist/resources/ebills/types.d.ts +0 -23
  110. package/dist/resources/ebills/types.d.ts.map +0 -1
  111. package/dist/resources/ebills/types.js +0 -3
  112. package/dist/resources/ebills/types.js.map +0 -1
  113. package/dist/resources/emails/emails.d.ts +0 -13
  114. package/dist/resources/emails/emails.d.ts.map +0 -1
  115. package/dist/resources/emails/emails.js +0 -38
  116. package/dist/resources/emails/emails.js.map +0 -1
  117. package/dist/resources/emails/response.d.ts +0 -24
  118. package/dist/resources/emails/response.d.ts.map +0 -1
  119. package/dist/resources/emails/response.js +0 -3
  120. package/dist/resources/emails/response.js.map +0 -1
  121. package/dist/resources/emails/types.d.ts +0 -26
  122. package/dist/resources/emails/types.d.ts.map +0 -1
  123. package/dist/resources/emails/types.js +0 -3
  124. package/dist/resources/emails/types.js.map +0 -1
  125. package/dist/resources/events/batch-events.d.ts +0 -6
  126. package/dist/resources/events/batch-events.d.ts.map +0 -1
  127. package/dist/resources/events/batch-events.js +0 -11
  128. package/dist/resources/events/batch-events.js.map +0 -1
  129. package/dist/resources/events/ebill-events.d.ts +0 -6
  130. package/dist/resources/events/ebill-events.d.ts.map +0 -1
  131. package/dist/resources/events/ebill-events.js +0 -11
  132. package/dist/resources/events/ebill-events.js.map +0 -1
  133. package/dist/resources/events/email-events.d.ts +0 -6
  134. package/dist/resources/events/email-events.d.ts.map +0 -1
  135. package/dist/resources/events/email-events.js +0 -11
  136. package/dist/resources/events/email-events.js.map +0 -1
  137. package/dist/resources/events/letter-events.d.ts +0 -11
  138. package/dist/resources/events/letter-events.d.ts.map +0 -1
  139. package/dist/resources/events/letter-events.js +0 -26
  140. package/dist/resources/events/letter-events.js.map +0 -1
  141. package/dist/resources/events/response.d.ts +0 -20
  142. package/dist/resources/events/response.d.ts.map +0 -1
  143. package/dist/resources/events/response.js +0 -3
  144. package/dist/resources/events/response.js.map +0 -1
  145. package/dist/resources/file-upload.d.ts +0 -17
  146. package/dist/resources/file-upload.d.ts.map +0 -1
  147. package/dist/resources/file-upload.js +0 -24
  148. package/dist/resources/file-upload.js.map +0 -1
  149. package/dist/resources/index.d.ts +0 -30
  150. package/dist/resources/index.d.ts.map +0 -1
  151. package/dist/resources/index.js +0 -58
  152. package/dist/resources/index.js.map +0 -1
  153. package/dist/resources/letters/letters.d.ts +0 -18
  154. package/dist/resources/letters/letters.d.ts.map +0 -1
  155. package/dist/resources/letters/letters.js +0 -88
  156. package/dist/resources/letters/letters.js.map +0 -1
  157. package/dist/resources/letters/response.d.ts +0 -35
  158. package/dist/resources/letters/response.d.ts.map +0 -1
  159. package/dist/resources/letters/response.js +0 -3
  160. package/dist/resources/letters/response.js.map +0 -1
  161. package/dist/resources/letters/types.d.ts +0 -61
  162. package/dist/resources/letters/types.d.ts.map +0 -1
  163. package/dist/resources/letters/types.js +0 -3
  164. package/dist/resources/letters/types.js.map +0 -1
  165. package/dist/resources/organisations/organisations.d.ts +0 -7
  166. package/dist/resources/organisations/organisations.d.ts.map +0 -1
  167. package/dist/resources/organisations/organisations.js +0 -14
  168. package/dist/resources/organisations/organisations.js.map +0 -1
  169. package/dist/resources/organisations/response.d.ts +0 -24
  170. package/dist/resources/organisations/response.d.ts.map +0 -1
  171. package/dist/resources/organisations/response.js +0 -3
  172. package/dist/resources/organisations/response.js.map +0 -1
  173. package/dist/resources/users/response.d.ts +0 -21
  174. package/dist/resources/users/response.d.ts.map +0 -1
  175. package/dist/resources/users/response.js +0 -3
  176. package/dist/resources/users/response.js.map +0 -1
  177. package/dist/resources/users/user-associations.d.ts +0 -6
  178. package/dist/resources/users/user-associations.d.ts.map +0 -1
  179. package/dist/resources/users/user-associations.js +0 -11
  180. package/dist/resources/users/user-associations.js.map +0 -1
  181. package/dist/resources/users/users.d.ts +0 -6
  182. package/dist/resources/users/users.d.ts.map +0 -1
  183. package/dist/resources/users/users.js +0 -11
  184. package/dist/resources/users/users.js.map +0 -1
  185. package/dist/resources/webhooks/enums.d.ts +0 -8
  186. package/dist/resources/webhooks/enums.d.ts.map +0 -1
  187. package/dist/resources/webhooks/enums.js +0 -12
  188. package/dist/resources/webhooks/enums.js.map +0 -1
  189. package/dist/resources/webhooks/response.d.ts +0 -8
  190. package/dist/resources/webhooks/response.d.ts.map +0 -1
  191. package/dist/resources/webhooks/response.js +0 -3
  192. package/dist/resources/webhooks/response.js.map +0 -1
  193. package/dist/resources/webhooks/types.d.ts +0 -7
  194. package/dist/resources/webhooks/types.d.ts.map +0 -1
  195. package/dist/resources/webhooks/types.js +0 -3
  196. package/dist/resources/webhooks/types.js.map +0 -1
  197. package/dist/resources/webhooks/webhooks.d.ts +0 -10
  198. package/dist/resources/webhooks/webhooks.d.ts.map +0 -1
  199. package/dist/resources/webhooks/webhooks.js +0 -24
  200. package/dist/resources/webhooks/webhooks.js.map +0 -1
  201. package/dist/utils/headers.d.ts +0 -2
  202. package/dist/utils/headers.d.ts.map +0 -1
  203. package/dist/utils/headers.js +0 -13
  204. package/dist/utils/headers.js.map +0 -1
  205. package/dist/utils/idempotency.d.ts +0 -2
  206. package/dist/utils/idempotency.d.ts.map +0 -1
  207. package/dist/utils/idempotency.js +0 -8
  208. package/dist/utils/idempotency.js.map +0 -1
  209. package/dist/utils/object.d.ts +0 -2
  210. package/dist/utils/object.d.ts.map +0 -1
  211. package/dist/utils/object.js +0 -17
  212. package/dist/utils/object.js.map +0 -1
  213. package/dist/utils/payload.d.ts +0 -8
  214. package/dist/utils/payload.d.ts.map +0 -1
  215. package/dist/utils/payload.js +0 -20
  216. package/dist/utils/payload.js.map +0 -1
  217. package/dist/utils/retry.d.ts +0 -6
  218. package/dist/utils/retry.d.ts.map +0 -1
  219. package/dist/utils/retry.js +0 -45
  220. package/dist/utils/retry.js.map +0 -1
  221. package/dist/webhook.d.ts +0 -7
  222. package/dist/webhook.d.ts.map +0 -1
  223. package/dist/webhook.js +0 -25
  224. package/dist/webhook.js.map +0 -1
@@ -0,0 +1,814 @@
1
+ interface ResourceObject {
2
+ id: string;
3
+ type: string;
4
+ attributes: Record<string, unknown>;
5
+ relationships?: Record<string, unknown>;
6
+ links?: ItemLinks;
7
+ meta?: Record<string, unknown>;
8
+ }
9
+ interface JsonApiResource {
10
+ data: ResourceObject;
11
+ included?: Record<string, unknown>[];
12
+ }
13
+ interface JsonApiCollection {
14
+ data: ResourceObject[];
15
+ links?: CollectionLinks;
16
+ meta?: CollectionMeta;
17
+ included?: Record<string, unknown>[];
18
+ }
19
+ interface CollectionLinks {
20
+ first?: string;
21
+ last?: string;
22
+ prev?: string | null;
23
+ next?: string | null;
24
+ self?: string;
25
+ }
26
+ interface CollectionMeta {
27
+ current_page?: number;
28
+ last_page?: number;
29
+ per_page?: number;
30
+ from?: number;
31
+ to?: number;
32
+ total?: number;
33
+ }
34
+ interface ItemLinks {
35
+ self?: string;
36
+ }
37
+
38
+ interface ApiResource<A> {
39
+ id: string;
40
+ resourceType: string;
41
+ attributes: A;
42
+ relationships?: Record<string, unknown>;
43
+ links?: ItemLinks;
44
+ meta?: Record<string, unknown>;
45
+ included: Record<string, unknown>[];
46
+ statusCode: number;
47
+ headers: Record<string, string>;
48
+ }
49
+ interface ApiCollectionItem<A> {
50
+ id: string;
51
+ resourceType: string;
52
+ attributes: A;
53
+ relationships?: Record<string, unknown>;
54
+ links?: ItemLinks;
55
+ meta?: Record<string, unknown>;
56
+ }
57
+ interface ApiCollection<A> {
58
+ data: ApiCollectionItem<A>[];
59
+ links?: CollectionLinks;
60
+ meta?: CollectionMeta;
61
+ included: Record<string, unknown>[];
62
+ statusCode: number;
63
+ headers: Record<string, string>;
64
+ }
65
+
66
+ declare class PingenResponse {
67
+ readonly body: string;
68
+ readonly statusCode: number;
69
+ readonly headers: Record<string, string>;
70
+ readonly data: unknown;
71
+ constructor(body: string, statusCode: number, headers: Record<string, string>);
72
+ get requestId(): string | null;
73
+ toResource<A>(): ApiResource<A>;
74
+ toCollection<A>(): ApiCollection<A>;
75
+ }
76
+
77
+ interface ApiRequestorOptions {
78
+ useStaging?: boolean;
79
+ maxAttempts?: number;
80
+ timeoutMs?: number;
81
+ uploadTimeoutMs?: number;
82
+ on401?: () => Promise<string | undefined>;
83
+ }
84
+ declare class ApiRequestor {
85
+ private accessToken;
86
+ private readonly apiBase;
87
+ private readonly maxAttempts;
88
+ private readonly timeoutMs;
89
+ private readonly uploadTimeoutMs;
90
+ private readonly on401?;
91
+ constructor(accessToken: string | null, options?: ApiRequestorOptions);
92
+ setAccessToken(accessToken: string): void;
93
+ get(path: string, params?: Record<string, string>, extraHeaders?: Record<string, string>): Promise<PingenResponse>;
94
+ post(path: string, payload: string, extraHeaders?: Record<string, string>): Promise<PingenResponse>;
95
+ patch(path: string, payload?: string, extraHeaders?: Record<string, string>): Promise<PingenResponse>;
96
+ delete(path: string): Promise<PingenResponse>;
97
+ put(url: string, filePath: string): Promise<void>;
98
+ stream(path: string): Promise<string>;
99
+ private buildUrl;
100
+ private defaultHeaders;
101
+ private execute;
102
+ }
103
+
104
+ interface FileUploadAttributes {
105
+ url?: string;
106
+ url_signature?: string;
107
+ expires_at?: string;
108
+ }
109
+ interface SignedUpload {
110
+ url: string;
111
+ signature: string;
112
+ }
113
+ declare class FileUpload {
114
+ private readonly requestor;
115
+ constructor(requestor: ApiRequestor);
116
+ requestFileUpload(): Promise<SignedUpload>;
117
+ putFile(filePath: string, fileUrl: string): Promise<void>;
118
+ }
119
+
120
+ declare abstract class BaseResource {
121
+ protected readonly requestor: ApiRequestor;
122
+ constructor(requestor: ApiRequestor);
123
+ }
124
+ declare abstract class OrgResource {
125
+ protected readonly orgId: string;
126
+ protected readonly requestor: ApiRequestor;
127
+ constructor(orgId: string, requestor: ApiRequestor);
128
+ protected uploadFile(filePath: string): Promise<SignedUpload>;
129
+ protected uploadAndCall<U extends {
130
+ filePath: string;
131
+ }, R>(opts: U, create: (rest: Omit<U, 'filePath'> & {
132
+ fileUrl: string;
133
+ fileSignature: string;
134
+ }) => Promise<R>): Promise<R>;
135
+ }
136
+
137
+ declare enum AddressPosition {
138
+ Left = "left",
139
+ Right = "right"
140
+ }
141
+
142
+ declare enum DeliveryProduct {
143
+ Cheap = "cheap",
144
+ Fast = "fast",
145
+ Registered = "registered",
146
+ Bulk = "bulk",
147
+ Premium = "premium"
148
+ }
149
+
150
+ declare enum PaperType {
151
+ Normal = "normal",
152
+ Qr = "qr",
153
+ SepaAt = "sepa_at",
154
+ SepaDe = "sepa_de"
155
+ }
156
+
157
+ declare enum PrintMode {
158
+ Simplex = "simplex",
159
+ Duplex = "duplex"
160
+ }
161
+
162
+ declare enum PrintSpectrum {
163
+ Color = "color",
164
+ Grayscale = "grayscale"
165
+ }
166
+
167
+ declare class PresetRelationship {
168
+ private readonly presetId;
169
+ constructor(presetId: string);
170
+ toValue(): {
171
+ preset: {
172
+ data: {
173
+ id: string;
174
+ type: string;
175
+ };
176
+ };
177
+ };
178
+ }
179
+
180
+ interface LetterRecipient {
181
+ name: string;
182
+ street?: string;
183
+ pobox?: string;
184
+ number?: string;
185
+ zip: string;
186
+ city: string;
187
+ country: string;
188
+ }
189
+ interface LetterSender {
190
+ name: string;
191
+ street?: string;
192
+ pobox?: string;
193
+ number?: string;
194
+ zip: string;
195
+ city: string;
196
+ country: string;
197
+ }
198
+ interface LetterMetaData {
199
+ recipient: LetterRecipient;
200
+ sender: LetterSender;
201
+ }
202
+ interface LetterCreateOptions {
203
+ fileUrl: string;
204
+ fileSignature: string;
205
+ fileOriginalName: string;
206
+ addressPosition: AddressPosition;
207
+ autoSend: boolean;
208
+ deliveryProduct?: DeliveryProduct;
209
+ printMode?: PrintMode;
210
+ printSpectrum?: PrintSpectrum;
211
+ metaData?: LetterMetaData;
212
+ preset?: PresetRelationship;
213
+ }
214
+ interface LetterUploadOptions {
215
+ filePath: string;
216
+ fileOriginalName: string;
217
+ addressPosition: AddressPosition;
218
+ autoSend: boolean;
219
+ deliveryProduct?: DeliveryProduct;
220
+ printMode?: PrintMode;
221
+ printSpectrum?: PrintSpectrum;
222
+ metaData?: LetterMetaData;
223
+ preset?: PresetRelationship;
224
+ }
225
+ interface LetterSendOptions {
226
+ letterId: string;
227
+ deliveryProduct: DeliveryProduct;
228
+ printMode: PrintMode;
229
+ printSpectrum: PrintSpectrum;
230
+ }
231
+ interface LetterPriceOptions {
232
+ country: string;
233
+ paperTypes: PaperType[];
234
+ printMode: PrintMode;
235
+ printSpectrum: PrintSpectrum;
236
+ deliveryProduct: DeliveryProduct;
237
+ }
238
+
239
+ declare class Letters extends OrgResource {
240
+ getDetails(letterId: string, params?: Record<string, string>): Promise<PingenResponse>;
241
+ getCollection(params?: Record<string, string>): Promise<PingenResponse>;
242
+ uploadAndCreate(opts: LetterUploadOptions): Promise<PingenResponse>;
243
+ create(opts: LetterCreateOptions): Promise<PingenResponse>;
244
+ private createValidated;
245
+ send(opts: LetterSendOptions): Promise<PingenResponse>;
246
+ cancel(letterId: string): Promise<PingenResponse>;
247
+ delete(letterId: string): Promise<PingenResponse>;
248
+ edit(letterId: string, paperTypes: PaperType[]): Promise<PingenResponse>;
249
+ getFile(letterId: string): Promise<string>;
250
+ calculatePrice(opts: LetterPriceOptions): Promise<PingenResponse>;
251
+ }
252
+
253
+ interface RelationshipData {
254
+ id: string;
255
+ type: string;
256
+ }
257
+ type RelationshipLinkSimple = string;
258
+ interface RelationshipLinkRich {
259
+ href: string;
260
+ meta?: Record<string, unknown>;
261
+ }
262
+ interface RelationshipLinks {
263
+ related?: RelationshipLinkSimple | RelationshipLinkRich;
264
+ }
265
+ interface RelationshipItem {
266
+ links?: RelationshipLinks;
267
+ data?: RelationshipData;
268
+ }
269
+ interface RelationshipMany {
270
+ links?: RelationshipLinks;
271
+ }
272
+
273
+ interface FontInfo {
274
+ name: string;
275
+ is_embedded: boolean;
276
+ }
277
+ interface LetterAttributes {
278
+ status?: string;
279
+ file_original_name?: string;
280
+ file_pages?: number;
281
+ address?: string;
282
+ address_position?: string;
283
+ country?: string;
284
+ delivery_product?: string;
285
+ print_mode?: string;
286
+ print_spectrum?: string;
287
+ price_currency?: string;
288
+ price_value?: number;
289
+ paper_types?: string[];
290
+ fonts?: FontInfo[];
291
+ source?: string;
292
+ tracking_number?: string;
293
+ submitted_at?: string;
294
+ created_at?: string;
295
+ updated_at?: string;
296
+ }
297
+ interface LetterRelationships {
298
+ organisation?: RelationshipItem;
299
+ events?: RelationshipMany;
300
+ batch?: RelationshipItem;
301
+ }
302
+ interface LetterPriceAttributes {
303
+ currency?: string;
304
+ price?: number;
305
+ }
306
+
307
+ declare enum BatchIcon {
308
+ Campaign = "campaign",
309
+ Megaphone = "megaphone",
310
+ WaveHand = "wave-hand",
311
+ Flash = "flash",
312
+ Rocket = "rocket",
313
+ Bell = "bell",
314
+ PercentTag = "percent-tag",
315
+ PercentBadge = "percent-badge",
316
+ Present = "present",
317
+ Receipt = "receipt",
318
+ Document = "document",
319
+ Information = "information",
320
+ Calendar = "calendar",
321
+ Newspaper = "newspaper",
322
+ Crown = "crown",
323
+ Virus = "virus"
324
+ }
325
+ declare enum GroupingType {
326
+ Merge = "merge",
327
+ Zip = "zip"
328
+ }
329
+ declare enum SplitType {
330
+ File = "file",
331
+ Page = "page",
332
+ Custom = "custom",
333
+ QrInvoice = "qr_invoice"
334
+ }
335
+ declare enum SplitPosition {
336
+ FirstPage = "first_page",
337
+ LastPage = "last_page"
338
+ }
339
+ interface BatchDeliveryProduct {
340
+ country: string;
341
+ delivery_product: string;
342
+ }
343
+ declare function createBatchDeliveryProduct(country: string, deliveryProduct: DeliveryProduct): BatchDeliveryProduct;
344
+
345
+ interface BatchCreateOptions {
346
+ fileUrl: string;
347
+ fileSignature: string;
348
+ name: string;
349
+ icon: BatchIcon;
350
+ fileOriginalName: string;
351
+ addressPosition: AddressPosition;
352
+ groupingType: GroupingType;
353
+ splitType: SplitType;
354
+ splitSize?: number;
355
+ splitSeparator?: string;
356
+ splitPosition?: SplitPosition;
357
+ preset?: PresetRelationship;
358
+ }
359
+ interface BatchUploadOptions {
360
+ filePath: string;
361
+ name: string;
362
+ icon: BatchIcon;
363
+ fileOriginalName: string;
364
+ addressPosition: AddressPosition;
365
+ groupingType: GroupingType;
366
+ splitType: SplitType;
367
+ splitSize?: number;
368
+ splitSeparator?: string;
369
+ splitPosition?: SplitPosition;
370
+ preset?: PresetRelationship;
371
+ }
372
+ interface BatchSendOptions {
373
+ batchId: string;
374
+ deliveryProducts: BatchDeliveryProduct[];
375
+ printMode: PrintMode;
376
+ printSpectrum: PrintSpectrum;
377
+ }
378
+ interface BatchEditOptions {
379
+ name?: string;
380
+ icon?: BatchIcon;
381
+ }
382
+
383
+ declare class Batches extends OrgResource {
384
+ getDetails(batchId: string, params?: Record<string, string>): Promise<PingenResponse>;
385
+ getCollection(params?: Record<string, string>): Promise<PingenResponse>;
386
+ uploadAndCreate(opts: BatchUploadOptions): Promise<PingenResponse>;
387
+ create(opts: BatchCreateOptions): Promise<PingenResponse>;
388
+ send(opts: BatchSendOptions): Promise<PingenResponse>;
389
+ cancel(batchId: string): Promise<PingenResponse>;
390
+ delete(batchId: string): Promise<PingenResponse>;
391
+ edit(batchId: string, opts: BatchEditOptions): Promise<PingenResponse>;
392
+ getStatistics(batchId: string): Promise<PingenResponse>;
393
+ }
394
+
395
+ interface BatchAttributes {
396
+ name?: string;
397
+ icon?: string;
398
+ status?: string;
399
+ file_original_name?: string;
400
+ letter_count?: number;
401
+ address_position?: string;
402
+ price_currency?: string;
403
+ price_value?: number;
404
+ print_mode?: string;
405
+ print_spectrum?: string;
406
+ source?: string;
407
+ submitted_at?: string;
408
+ created_at?: string;
409
+ updated_at?: string;
410
+ }
411
+ interface BatchRelationships {
412
+ organisation?: RelationshipItem;
413
+ events?: RelationshipMany;
414
+ }
415
+ interface BatchStatisticsAttributes {
416
+ letter_validating?: number;
417
+ letter_groups?: unknown[];
418
+ letter_countries?: unknown[];
419
+ }
420
+
421
+ interface EbillMetaData {
422
+ invoice_number: string;
423
+ invoice_date: string;
424
+ invoice_due_date: string;
425
+ recipient_identifier: string;
426
+ }
427
+ interface EbillCreateOptions {
428
+ fileUrl: string;
429
+ fileSignature: string;
430
+ fileOriginalName: string;
431
+ autoSend: boolean;
432
+ metaData?: EbillMetaData;
433
+ preset?: PresetRelationship;
434
+ }
435
+ interface EbillUploadOptions {
436
+ filePath: string;
437
+ fileOriginalName: string;
438
+ autoSend: boolean;
439
+ metaData?: EbillMetaData;
440
+ preset?: PresetRelationship;
441
+ }
442
+
443
+ declare class Ebills extends OrgResource {
444
+ getDetails(ebillId: string, params?: Record<string, string>): Promise<PingenResponse>;
445
+ getCollection(params?: Record<string, string>): Promise<PingenResponse>;
446
+ uploadAndCreate(opts: EbillUploadOptions): Promise<PingenResponse>;
447
+ create(opts: EbillCreateOptions): Promise<PingenResponse>;
448
+ cancel(ebillId: string): Promise<PingenResponse>;
449
+ delete(ebillId: string): Promise<PingenResponse>;
450
+ getFile(ebillId: string): Promise<string>;
451
+ }
452
+
453
+ interface EbillAttributes {
454
+ status?: string;
455
+ file_original_name?: string;
456
+ file_pages?: number;
457
+ recipient_identifier?: string;
458
+ recipient_address?: string;
459
+ invoice_number?: string;
460
+ invoice_date?: string;
461
+ invoice_due_date?: string;
462
+ invoice_value?: number;
463
+ invoice_currency?: string;
464
+ invoice_iban?: string;
465
+ invoice_address?: string;
466
+ invoice_reference?: string;
467
+ price_currency?: string;
468
+ price_value?: number;
469
+ source?: string;
470
+ submitted_at?: string;
471
+ created_at?: string;
472
+ updated_at?: string;
473
+ }
474
+ interface EbillRelationships {
475
+ organisation?: RelationshipItem;
476
+ events?: RelationshipMany;
477
+ }
478
+
479
+ interface EmailMetaData {
480
+ sender_name: string;
481
+ recipient_email: string;
482
+ recipient_name: string;
483
+ reply_email: string;
484
+ reply_name: string;
485
+ subject: string;
486
+ content: string;
487
+ }
488
+ interface EmailCreateOptions {
489
+ fileUrl: string;
490
+ fileSignature: string;
491
+ fileOriginalName: string;
492
+ autoSend: boolean;
493
+ metaData?: EmailMetaData;
494
+ preset?: PresetRelationship;
495
+ }
496
+ interface EmailUploadOptions {
497
+ filePath: string;
498
+ fileOriginalName: string;
499
+ autoSend: boolean;
500
+ metaData?: EmailMetaData;
501
+ preset?: PresetRelationship;
502
+ }
503
+
504
+ declare class Emails extends OrgResource {
505
+ getDetails(emailId: string, params?: Record<string, string>): Promise<PingenResponse>;
506
+ getCollection(params?: Record<string, string>): Promise<PingenResponse>;
507
+ uploadAndCreate(opts: EmailUploadOptions): Promise<PingenResponse>;
508
+ create(opts: EmailCreateOptions): Promise<PingenResponse>;
509
+ cancel(emailId: string): Promise<PingenResponse>;
510
+ delete(emailId: string): Promise<PingenResponse>;
511
+ getFile(emailId: string): Promise<string>;
512
+ }
513
+
514
+ interface EmailAttributes {
515
+ status?: string;
516
+ file_original_name?: string;
517
+ file_pages?: number;
518
+ file_url?: string;
519
+ file_url_signature?: string;
520
+ auto_send?: boolean;
521
+ meta_data?: EmailMetaData;
522
+ recipient_identifier?: string;
523
+ price_currency?: string;
524
+ price_value?: number;
525
+ source?: string;
526
+ submitted_at?: string;
527
+ created_at?: string;
528
+ updated_at?: string;
529
+ }
530
+ interface EmailRelationships {
531
+ organisation?: RelationshipItem;
532
+ events?: RelationshipMany;
533
+ preset?: RelationshipItem;
534
+ }
535
+
536
+ declare enum WebhookEventCategory {
537
+ Issues = "issues",
538
+ Sent = "sent",
539
+ Undeliverable = "undeliverable",
540
+ Delivered = "delivered",
541
+ ChannelSubscriptions = "channel_subscriptions"
542
+ }
543
+
544
+ interface WebhookCreateOptions {
545
+ eventCategory: WebhookEventCategory;
546
+ url: string;
547
+ signingKey: string;
548
+ }
549
+
550
+ declare class Webhooks extends OrgResource {
551
+ getDetails(webhookId: string, params?: Record<string, string>): Promise<PingenResponse>;
552
+ getCollection(params?: Record<string, string>): Promise<PingenResponse>;
553
+ create(opts: WebhookCreateOptions): Promise<PingenResponse>;
554
+ delete(webhookId: string): Promise<PingenResponse>;
555
+ }
556
+
557
+ interface WebhookAttributes {
558
+ event_category?: string;
559
+ url?: string;
560
+ signing_key?: string;
561
+ created_at?: string;
562
+ updated_at?: string;
563
+ }
564
+
565
+ declare class LetterEvents extends OrgResource {
566
+ getCollection(letterId: string, params?: Record<string, string>): Promise<PingenResponse>;
567
+ getIssueCollection(params?: Record<string, string>): Promise<PingenResponse>;
568
+ getUndeliverableCollection(params?: Record<string, string>): Promise<PingenResponse>;
569
+ getDeliveredCollection(params?: Record<string, string>): Promise<PingenResponse>;
570
+ getSentCollection(params?: Record<string, string>): Promise<PingenResponse>;
571
+ private eventsFeed;
572
+ }
573
+
574
+ declare class BatchEvents extends OrgResource {
575
+ getCollection(batchId: string, params?: Record<string, string>): Promise<PingenResponse>;
576
+ }
577
+
578
+ declare class EbillEvents extends OrgResource {
579
+ getCollection(ebillId: string, params?: Record<string, string>): Promise<PingenResponse>;
580
+ }
581
+
582
+ declare class EmailEvents extends OrgResource {
583
+ getCollection(emailId: string, params?: Record<string, string>): Promise<PingenResponse>;
584
+ }
585
+
586
+ interface EventAttributes {
587
+ code?: string;
588
+ name?: string;
589
+ description?: string;
590
+ producer?: string;
591
+ location?: string;
592
+ has_image?: boolean;
593
+ data?: unknown[];
594
+ emitted_at?: string;
595
+ created_at?: string;
596
+ updated_at?: string;
597
+ }
598
+ interface EventRelationships {
599
+ letter?: RelationshipItem;
600
+ batch?: RelationshipItem;
601
+ ebill?: RelationshipItem;
602
+ email?: RelationshipItem;
603
+ }
604
+
605
+ declare class Organisations extends BaseResource {
606
+ getDetails(orgId: string, params?: Record<string, string>): Promise<PingenResponse>;
607
+ getCollection(params?: Record<string, string>): Promise<PingenResponse>;
608
+ }
609
+
610
+ interface OrganisationAttributes {
611
+ name?: string;
612
+ status?: string;
613
+ plan?: string;
614
+ billing_mode?: string;
615
+ billing_currency?: string;
616
+ billing_balance?: number;
617
+ missing_credits?: number;
618
+ edition?: string;
619
+ default_country?: string;
620
+ default_address_position?: string;
621
+ data_retention_addresses?: number;
622
+ data_retention_pdf?: number;
623
+ limits_monthly_letters_count?: number;
624
+ color?: string;
625
+ flags?: string[];
626
+ created_at?: string;
627
+ updated_at?: string;
628
+ }
629
+ interface OrganisationRelationships {
630
+ associations?: RelationshipMany;
631
+ }
632
+
633
+ declare class Users extends BaseResource {
634
+ getDetails(params?: Record<string, string>): Promise<PingenResponse>;
635
+ }
636
+
637
+ declare class UserAssociations extends BaseResource {
638
+ getCollection(params?: Record<string, string>): Promise<PingenResponse>;
639
+ }
640
+
641
+ interface UserAttributes {
642
+ first_name?: string;
643
+ last_name?: string;
644
+ email?: string;
645
+ language?: string;
646
+ status?: string;
647
+ edition?: string;
648
+ created_at?: string;
649
+ updated_at?: string;
650
+ }
651
+ interface UserAssociationAttributes {
652
+ role?: string;
653
+ created_at?: string;
654
+ updated_at?: string;
655
+ }
656
+ interface UserAssociationRelationships {
657
+ organisation?: RelationshipItem;
658
+ user?: RelationshipItem;
659
+ }
660
+
661
+ interface PingenClientConfig {
662
+ clientId: string;
663
+ clientSecret: string;
664
+ useStaging?: boolean;
665
+ maxAttempts?: number;
666
+ timeoutMs?: number;
667
+ uploadTimeoutMs?: number;
668
+ }
669
+ declare class PingenClient {
670
+ private readonly requestor;
671
+ private readonly oauth;
672
+ constructor(config: PingenClientConfig);
673
+ constructor(clientId: string, clientSecret: string, useStaging?: boolean);
674
+ ensureToken(): Promise<void>;
675
+ letters(orgId: string): Letters;
676
+ batches(orgId: string): Batches;
677
+ letterEvents(orgId: string): LetterEvents;
678
+ batchEvents(orgId: string): BatchEvents;
679
+ ebillEvents(orgId: string): EbillEvents;
680
+ emailEvents(orgId: string): EmailEvents;
681
+ organisations(): Organisations;
682
+ users(): Users;
683
+ userAssociations(): UserAssociations;
684
+ webhooks(orgId: string): Webhooks;
685
+ ebills(orgId: string): Ebills;
686
+ emails(orgId: string): Emails;
687
+ private buildRequestorOptions;
688
+ }
689
+
690
+ declare class PingenError extends Error {
691
+ readonly status: number;
692
+ readonly body: unknown;
693
+ readonly requestId?: string;
694
+ readonly retryAfterMs?: number;
695
+ constructor(message: string, status: number, body?: unknown, requestId?: string, retryAfterMs?: number);
696
+ }
697
+ declare class PingenBadRequestError extends PingenError {
698
+ }
699
+ declare class PingenUnauthorizedError extends PingenError {
700
+ }
701
+ declare class PingenForbiddenError extends PingenError {
702
+ }
703
+ declare class PingenNotFoundError extends PingenError {
704
+ }
705
+ declare class PingenMethodNotAllowedError extends PingenError {
706
+ }
707
+ declare class PingenNotAcceptableError extends PingenError {
708
+ }
709
+ declare class PingenConflictError extends PingenError {
710
+ }
711
+ declare class PingenGoneError extends PingenError {
712
+ }
713
+ declare class PingenUnsupportedMediaError extends PingenError {
714
+ }
715
+ declare class PingenUnprocessableEntityError extends PingenError {
716
+ }
717
+ declare class PingenDependencyError extends PingenError {
718
+ }
719
+ declare class PingenRateLimitError extends PingenError {
720
+ }
721
+ declare class PingenServerError extends PingenError {
722
+ }
723
+ declare class PingenServiceUnavailableError extends PingenError {
724
+ }
725
+ declare class PingenTimeoutError extends PingenError {
726
+ }
727
+ declare class AuthenticationError extends PingenError {
728
+ constructor(message: string);
729
+ }
730
+ declare class ValidationError extends PingenError {
731
+ readonly field: string;
732
+ constructor(field: string, message: string);
733
+ }
734
+ declare class WebhookSignatureError extends PingenError {
735
+ constructor(message: string);
736
+ }
737
+ declare function createPingenError(message: string, status: number, body?: unknown, requestId?: string, retryAfterMs?: number): PingenError;
738
+
739
+ interface OAuthConfig {
740
+ clientId: string;
741
+ clientSecret: string;
742
+ useStaging?: boolean;
743
+ }
744
+ declare class OAuth {
745
+ private readonly clientId;
746
+ private readonly clientSecret;
747
+ private readonly useStaging;
748
+ private cachedToken;
749
+ private pendingRequest;
750
+ constructor(config: OAuthConfig);
751
+ getAccessToken(): Promise<string>;
752
+ invalidate(): void;
753
+ private fetchToken;
754
+ }
755
+
756
+ interface WebhookEvent {
757
+ body: string;
758
+ data: unknown;
759
+ }
760
+ declare function verifyWebhookSignature(payload: string, signature: string, secret: string): void;
761
+ declare function constructWebhookEvent(payload: string, signature: string, secret: string): WebhookEvent;
762
+
763
+ interface JsonApiEnvelope {
764
+ type: string;
765
+ id?: string;
766
+ attributes?: Record<string, unknown>;
767
+ relationships?: Record<string, unknown>;
768
+ }
769
+ declare function buildJsonApi(env: JsonApiEnvelope): string;
770
+
771
+ declare function definedOnly<T extends Record<string, unknown>>(input: T): Partial<T>;
772
+
773
+ declare function newIdempotencyKey(): string;
774
+
775
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
776
+ declare function isRetryableStatus(method: HttpMethod, status: number): boolean;
777
+ declare function shouldAttachIdempotencyKey(method: HttpMethod): boolean;
778
+ declare function computeBackoffMs(retryAfterHeader: string | undefined, attempt: number): number;
779
+ declare function sleep(ms: number): Promise<void>;
780
+
781
+ interface WebhookEventAttributes {
782
+ reason?: string;
783
+ corrected_address?: CorrectedAddress;
784
+ url?: string;
785
+ created_at?: string;
786
+ }
787
+ interface WebhookEventRelationships {
788
+ organisation?: RelationshipItem;
789
+ letter?: RelationshipItem;
790
+ event?: RelationshipItem;
791
+ }
792
+ interface CorrectedAddress {
793
+ name?: string;
794
+ street?: string;
795
+ number?: string;
796
+ zip?: string;
797
+ city?: string;
798
+ }
799
+ interface WebhookChannelSubscriptionAttributes {
800
+ identifier?: string;
801
+ email?: string;
802
+ name?: string;
803
+ address?: string;
804
+ status?: string;
805
+ approved_at?: string;
806
+ url?: string;
807
+ created_at?: string;
808
+ }
809
+ interface WebhookChannelSubscriptionRelationships {
810
+ organisation?: RelationshipItem;
811
+ channel_ebill?: RelationshipItem;
812
+ }
813
+
814
+ export { AddressPosition, type ApiCollection, type ApiCollectionItem, ApiRequestor, type ApiRequestorOptions, type ApiResource, AuthenticationError, BaseResource, type BatchAttributes, type BatchCreateOptions, type BatchDeliveryProduct, type BatchEditOptions, BatchEvents, BatchIcon, type BatchRelationships, type BatchSendOptions, type BatchStatisticsAttributes, type BatchUploadOptions, Batches, type CollectionLinks, type CollectionMeta, type CorrectedAddress, DeliveryProduct, type EbillAttributes, type EbillCreateOptions, EbillEvents, type EbillMetaData, type EbillRelationships, type EbillUploadOptions, Ebills, type EmailAttributes, type EmailCreateOptions, EmailEvents, type EmailMetaData, type EmailRelationships, type EmailUploadOptions, Emails, type EventAttributes, type EventRelationships, FileUpload, type FileUploadAttributes, type FontInfo, GroupingType, type HttpMethod, type ItemLinks, type JsonApiCollection, type JsonApiEnvelope, type JsonApiResource, type LetterAttributes, type LetterCreateOptions, LetterEvents, type LetterMetaData, type LetterPriceAttributes, type LetterPriceOptions, type LetterRecipient, type LetterRelationships, type LetterSendOptions, type LetterSender, type LetterUploadOptions, Letters, OAuth, type OAuthConfig, OrgResource, type OrganisationAttributes, type OrganisationRelationships, Organisations, PaperType, PingenBadRequestError, PingenClient, type PingenClientConfig, PingenConflictError, PingenDependencyError, PingenError, PingenForbiddenError, PingenGoneError, PingenMethodNotAllowedError, PingenNotAcceptableError, PingenNotFoundError, PingenRateLimitError, PingenResponse, PingenServerError, PingenServiceUnavailableError, PingenTimeoutError, PingenUnauthorizedError, PingenUnprocessableEntityError, PingenUnsupportedMediaError, PresetRelationship, PrintMode, PrintSpectrum, type RelationshipData, type RelationshipItem, type RelationshipLinkRich, type RelationshipLinkSimple, type RelationshipLinks, type RelationshipMany, type ResourceObject, type SignedUpload, SplitPosition, SplitType, type UserAssociationAttributes, type UserAssociationRelationships, UserAssociations, type UserAttributes, Users, ValidationError, type WebhookAttributes, type WebhookChannelSubscriptionAttributes, type WebhookChannelSubscriptionRelationships, type WebhookCreateOptions, type WebhookEvent, type WebhookEventAttributes, WebhookEventCategory, type WebhookEventRelationships, WebhookSignatureError, Webhooks, buildJsonApi, computeBackoffMs, constructWebhookEvent, createBatchDeliveryProduct, createPingenError, definedOnly, isRetryableStatus, newIdempotencyKey, shouldAttachIdempotencyKey, sleep, verifyWebhookSignature };