From 03969576d3d82bdb4fa7dba62fa76c6b8d22c1a2 Mon Sep 17 00:00:00 2001 From: mbomain Date: Thu, 6 Aug 2026 16:02:09 +0300 Subject: [PATCH 01/21] build: gen client documenso --- doc/api.yml | 7 + doc/components.yml | 56 ++- doc/documenso-client-api.yaml | 317 +++++++++++++ doc/operations/documenso-api.yml | 72 +++ .../DocumensoDocumentController.java | 43 ++ .../DocumensoWebhookController.java | 32 ++ .../TemplateDocumensoController.java | 21 + .../endpoint/rest/mapper/DocumensoMapper.java | 28 ++ .../hei/haapi/model/DocumensoDocument.java | 71 +++ .../model/DocumensoDocumentRecipient.java | 48 ++ .../hei/haapi/model/TemplateDocumenso.java | 44 ++ .../DocumensoDocumentRecipientRepository.java | 13 + .../DocumensoDocumentRepository.java | 11 + .../TemplateDocumensoRepository.java | 11 + .../service/DocumensoDocumentService.java | 224 +++++++++ .../service/TemplateDocumensoService.java | 42 ++ .../service/documenso/DocumensoClient.java | 49 ++ .../service/documenso/DocumensoConf.java | 23 + .../documenso/gen/api/DocumentApi.java | 255 ++++++++++ .../documenso/gen/api/TemplateApi.java | 359 ++++++++++++++ .../documenso/gen/invoker/ApiClient.java | 445 ++++++++++++++++++ .../documenso/gen/invoker/ApiException.java | 99 ++++ .../documenso/gen/invoker/ApiResponse.java | 62 +++ .../documenso/gen/invoker/Configuration.java | 43 ++ .../service/documenso/gen/invoker/JSON.java | 253 ++++++++++ .../service/documenso/gen/invoker/Pair.java | 59 +++ .../gen/invoker/RFC3339DateFormat.java | 59 +++ .../gen/invoker/ServerConfiguration.java | 63 +++ .../documenso/gen/invoker/ServerVariable.java | 26 + .../gen/model/AbstractOpenApiSchema.java | 146 ++++++ .../gen/model/DocumentGet200Response.java | 346 ++++++++++++++ ...CreateDocumentFromTemplate200Response.java | 370 +++++++++++++++ ...romTemplate200ResponseRecipientsInner.java | 357 ++++++++++++++ ...lateCreateDocumentFromTemplateRequest.java | 271 +++++++++++ ...FromTemplateRequestPrefillFieldsInner.java | 267 +++++++++++ ...entFromTemplateRequestRecipientsInner.java | 233 +++++++++ .../TemplateFindTemplates200Response.java | 162 +++++++ ...lateFindTemplates200ResponseDataInner.java | 385 +++++++++++++++ .../TemplateGetTemplateById200Response.java | 346 ++++++++++++++ ...GetTemplateById200ResponseFieldsInner.java | 271 +++++++++++ ...emplateById200ResponseRecipientsInner.java | 313 ++++++++++++ ...0__Add_documenso_user_id_to_user_table.sql | 2 + ...5_131__Create_documenso_template_table.sql | 10 + ...5_132__Create_documenso_document_table.sql | 22 + ...ate_documenso_document_recipient_table.sql | 11 + .../hei/haapi/integration/DocumensoIT.java | 258 ++++++++++ 46 files changed, 6604 insertions(+), 1 deletion(-) create mode 100644 doc/documenso-client-api.yaml create mode 100644 doc/operations/documenso-api.yml create mode 100644 src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoDocumentController.java create mode 100644 src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoWebhookController.java create mode 100644 src/main/java/school/hei/haapi/endpoint/rest/controller/TemplateDocumensoController.java create mode 100644 src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java create mode 100644 src/main/java/school/hei/haapi/model/DocumensoDocument.java create mode 100644 src/main/java/school/hei/haapi/model/DocumensoDocumentRecipient.java create mode 100644 src/main/java/school/hei/haapi/model/TemplateDocumenso.java create mode 100644 src/main/java/school/hei/haapi/repository/DocumensoDocumentRecipientRepository.java create mode 100644 src/main/java/school/hei/haapi/repository/DocumensoDocumentRepository.java create mode 100644 src/main/java/school/hei/haapi/repository/TemplateDocumensoRepository.java create mode 100644 src/main/java/school/hei/haapi/service/DocumensoDocumentService.java create mode 100644 src/main/java/school/hei/haapi/service/TemplateDocumensoService.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/DocumensoClient.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/DocumensoConf.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/api/DocumentApi.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/api/TemplateApi.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiClient.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiException.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiResponse.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/Configuration.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/JSON.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/Pair.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/RFC3339DateFormat.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerConfiguration.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerVariable.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/model/AbstractOpenApiSchema.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/model/DocumentGet200Response.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200Response.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequest.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestRecipientsInner.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200Response.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200ResponseDataInner.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200Response.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseFieldsInner.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseRecipientsInner.java create mode 100644 src/main/resources/db/migration/V45_130__Add_documenso_user_id_to_user_table.sql create mode 100644 src/main/resources/db/migration/V45_131__Create_documenso_template_table.sql create mode 100644 src/main/resources/db/migration/V45_132__Create_documenso_document_table.sql create mode 100644 src/main/resources/db/migration/V45_133__Create_documenso_document_recipient_table.sql create mode 100644 src/test/java/school/hei/haapi/integration/DocumensoIT.java diff --git a/doc/api.yml b/doc/api.yml index b25a45858..4577d822f 100644 --- a/doc/api.yml +++ b/doc/api.yml @@ -377,6 +377,13 @@ paths: $ref: './operations/cor-api.yml#/operations/commentCorById' '/students/{student_id}/cors': $ref: './operations/cor-api.yml#/operations/studentsCors' + # Documenso + /documenso-templates/sync: + $ref: './operations/documenso-api.yml#/operations/syncDocumensoTemplates' + /documenso-documents: + $ref: './operations/documenso-api.yml#/operations/generateDocumensoDocument' + '/documenso-documents/{id}/signing-token': + $ref: './operations/documenso-api.yml#/operations/getDocumensoDocumentSigningToken' components: securitySchemes: diff --git a/doc/components.yml b/doc/components.yml index 753014df0..371bbf217 100644 --- a/doc/components.yml +++ b/doc/components.yml @@ -2324,4 +2324,58 @@ components: amount: type: integer movement: - $ref: '#/components/schemas/CreditMovement' \ No newline at end of file + $ref: '#/components/schemas/CreditMovement' + TemplateDocumenso: + type: object + properties: + id: + type: string + documensoTemplateId: + type: integer + format: int64 + title: + type: string + type: + type: string + adminId: + type: string + DocumensoDocumentStatus: + type: string + enum: + - PENDING + - COMPLETED + - REJECTED + DocumensoDocument: + type: object + properties: + id: + type: string + documensoDocumentId: + type: integer + format: int64 + status: + $ref: '#/components/schemas/DocumensoDocumentStatus' + studentId: + type: string + level: + $ref: '#/components/schemas/StudentLevel' + templateId: + type: string + CrupdateDocumensoDocument: + type: object + properties: + studentId: + type: string + templateName: + type: string + description: >- + Name of the Documenso template to use (e.g. "Fiche d'engagement"), matched against the + template's title as synced from the Documenso interface. + required: + - studentId + - templateName + DocumensoSigningToken: + type: object + properties: + token: + type: string \ No newline at end of file diff --git a/doc/documenso-client-api.yaml b/doc/documenso-client-api.yaml new file mode 100644 index 000000000..f747844ec --- /dev/null +++ b/doc/documenso-client-api.yaml @@ -0,0 +1,317 @@ +openapi: 3.0.1 +info: + title: Documenso v2 API (client subset) + description: >- + Minimal subset of the Documenso v2 API (see "Documenso v2 API.yaml" for + the full upstream spec) covering only the operations used by + hei-admin-api's generated Documenso client: browsing templates, creating + a document from a template, and downloading the signed result. + version: 1.0.0 +servers: + - url: https://app.documenso.com/api/v2 +paths: + /template: + get: + operationId: template-findTemplates + summary: Find templates + tags: + - Template + security: + - apiKey: [] + parameters: + - in: query + name: query + schema: + type: string + - in: query + name: page + schema: + type: number + - in: query + name: perPage + schema: + type: number + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + data: + type: array + items: + type: object + properties: + id: + type: number + title: + type: string + type: + type: string + enum: + - PUBLIC + - PRIVATE + - ORGANISATION + userId: + type: number + createdAt: + type: string + updatedAt: + type: string + required: + - id + - title + - userId + required: + - data + /template/{templateId}: + get: + operationId: template-getTemplateById + summary: Get template + tags: + - Template + security: + - apiKey: [] + parameters: + - in: path + name: templateId + required: true + schema: + type: number + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + id: + type: number + title: + type: string + userId: + type: number + recipients: + type: array + items: + type: object + properties: + id: + type: number + role: + type: string + enum: + - CC + - SIGNER + - VIEWER + - APPROVER + - ASSISTANT + email: + type: string + name: + type: string + required: + - id + - role + fields: + type: array + items: + type: object + properties: + id: + type: number + type: + type: string + label: + type: string + placeholder: + type: string + required: + - id + - type + required: + - id + - title + - recipients + /template/use: + post: + operationId: template-createDocumentFromTemplate + summary: Use template + description: Use the template to create a document + tags: + - Template + security: + - apiKey: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + templateId: + type: number + recipients: + type: array + items: + type: object + properties: + id: + type: number + email: + type: string + name: + type: string + required: + - id + - email + prefillFields: + type: array + items: + type: object + properties: + id: + type: number + type: + type: string + enum: + - text + value: + type: string + required: + - id + - type + - value + required: + - templateId + - recipients + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + id: + type: number + status: + type: string + enum: + - DRAFT + - PENDING + - COMPLETED + - REJECTED + title: + type: string + createdAt: + type: string + recipients: + type: array + items: + type: object + properties: + id: + type: number + email: + type: string + name: + type: string + role: + type: string + enum: + - CC + - SIGNER + - VIEWER + - APPROVER + - ASSISTANT + token: + type: string + required: + - id + - status + - recipients + /document/{documentId}: + get: + operationId: document-get + summary: Get document + tags: + - Document + security: + - apiKey: [] + parameters: + - in: path + name: documentId + required: true + schema: + type: number + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + id: + type: number + status: + type: string + enum: + - DRAFT + - PENDING + - COMPLETED + - REJECTED + title: + type: string + createdAt: + type: string + completedAt: + type: string + required: + - id + - status + /document/{documentId}/download: + get: + operationId: document-download + summary: Download document + description: >- + Downloads the document. "signed" returns the completed document with + signatures, "original" returns the original uploaded document. + tags: + - Document + security: + - apiKey: [] + parameters: + - in: path + name: documentId + required: true + schema: + type: number + - in: query + name: version + schema: + type: string + enum: + - original + - signed + default: signed + responses: + "200": + description: Successful response + content: + application/pdf: + schema: + type: string + format: binary +components: + securitySchemes: + apiKey: + type: apiKey + in: header + name: Authorization +security: + - apiKey: [] diff --git a/doc/operations/documenso-api.yml b/doc/operations/documenso-api.yml new file mode 100644 index 000000000..d7eff4f2b --- /dev/null +++ b/doc/operations/documenso-api.yml @@ -0,0 +1,72 @@ +operations: + syncDocumensoTemplates: + post: + tags: + - Documenso + summary: Sync the local template catalog from the templates created in the Documenso interface + operationId: syncDocumensoTemplates + responses: + '200': + description: The synced templates + content: + application/json: + schema: + type: array + items: + $ref: '../components.yml#/components/schemas/TemplateDocumenso' + '403': + $ref: '../components.yml#/components/responses/403' + '500': + $ref: '../components.yml#/components/responses/500' + generateDocumensoDocument: + post: + tags: + - Documenso + summary: Generate a document from a Documenso template for a promotion level, to be signed by the admin and the monitor + operationId: generateDocumensoDocument + requestBody: + required: true + content: + application/json: + schema: + $ref: '../components.yml#/components/schemas/CrupdateDocumensoDocument' + responses: + '200': + description: The pending Documenso document + content: + application/json: + schema: + $ref: '../components.yml#/components/schemas/DocumensoDocument' + '400': + $ref: '../components.yml#/components/responses/400' + '403': + $ref: '../components.yml#/components/responses/403' + '404': + $ref: '../components.yml#/components/responses/404' + '500': + $ref: '../components.yml#/components/responses/500' + getDocumensoDocumentSigningToken: + get: + tags: + - Documenso + summary: Get the Documenso signing token for the authenticated user's recipient slot on a document + operationId: getDocumensoDocumentSigningToken + parameters: + - name: id + in: path + required: true + schema: + type: string + responses: + '200': + description: The signing token + content: + application/json: + schema: + $ref: '../components.yml#/components/schemas/DocumensoSigningToken' + '403': + $ref: '../components.yml#/components/responses/403' + '404': + $ref: '../components.yml#/components/responses/404' + '500': + $ref: '../components.yml#/components/responses/500' \ No newline at end of file diff --git a/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoDocumentController.java b/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoDocumentController.java new file mode 100644 index 000000000..8333ae012 --- /dev/null +++ b/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoDocumentController.java @@ -0,0 +1,43 @@ +package school.hei.haapi.endpoint.rest.controller; + +import java.util.Map; +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import school.hei.haapi.endpoint.rest.mapper.DocumensoMapper; +import school.hei.haapi.endpoint.rest.model.CrupdateDocumensoDocument; +import school.hei.haapi.endpoint.rest.model.DocumensoDocument; +import school.hei.haapi.endpoint.rest.model.DocumensoSigningToken; +import school.hei.haapi.endpoint.rest.security.model.Principal; +import school.hei.haapi.service.DocumensoDocumentService; + +@RestController +@RequiredArgsConstructor +public class DocumensoDocumentController { + private final DocumensoDocumentService documensoDocumentService; + private final DocumensoMapper documensoMapper; + + @PostMapping("/documenso-documents") + public DocumensoDocument generateDocumensoDocument(@RequestBody CrupdateDocumensoDocument toCreate) { + var document = + documensoDocumentService.generateForPromotionLevel( + toCreate.getPromotionId(), + toCreate.getLevel(), + toCreate.getDocumensoTemplateId(), + toCreate.getAdminId(), + toCreate.getMonitorId(), + Map.of()); + return documensoMapper.toRest(document); + } + + @GetMapping("/documenso-documents/{id}/signing-token") + public DocumensoSigningToken getDocumensoDocumentSigningToken( + @PathVariable("id") String id, @AuthenticationPrincipal Principal principal) { + var token = documensoDocumentService.getSigningToken(id, principal.getUserId()); + return new DocumensoSigningToken().token(token); + } +} diff --git a/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoWebhookController.java b/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoWebhookController.java new file mode 100644 index 000000000..b01e6fec6 --- /dev/null +++ b/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoWebhookController.java @@ -0,0 +1,32 @@ +package school.hei.haapi.endpoint.rest.controller; + +import java.util.Map; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RestController; +import school.hei.haapi.service.DocumensoDocumentService; + +@RestController +@RequiredArgsConstructor +public class DocumensoWebhookController { + private final DocumensoDocumentService documensoDocumentService; + + @Value("${documenso.webhook.secret}") + private String webhookSecret; + + @PostMapping("/documenso/webhook") + public ResponseEntity receiveDocumensoWebhook( + @RequestHeader(value = "X-Documenso-Secret", required = false) String secret, + @RequestBody Map payload) { + if (!webhookSecret.equals(secret)) { + return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); + } + documensoDocumentService.handleWebhook(payload); + return ResponseEntity.ok().build(); + } +} diff --git a/src/main/java/school/hei/haapi/endpoint/rest/controller/TemplateDocumensoController.java b/src/main/java/school/hei/haapi/endpoint/rest/controller/TemplateDocumensoController.java new file mode 100644 index 000000000..09356ace0 --- /dev/null +++ b/src/main/java/school/hei/haapi/endpoint/rest/controller/TemplateDocumensoController.java @@ -0,0 +1,21 @@ +package school.hei.haapi.endpoint.rest.controller; + +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; +import school.hei.haapi.endpoint.rest.mapper.DocumensoMapper; +import school.hei.haapi.endpoint.rest.model.TemplateDocumenso; +import school.hei.haapi.service.TemplateDocumensoService; + +@RestController +@RequiredArgsConstructor +public class TemplateDocumensoController { + private final TemplateDocumensoService templateDocumensoService; + private final DocumensoMapper documensoMapper; + + @PostMapping("/documenso-templates/sync") + public List syncDocumensoTemplates() { + return templateDocumensoService.syncTemplates().stream().map(documensoMapper::toRest).toList(); + } +} diff --git a/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java b/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java new file mode 100644 index 000000000..6813a3ec2 --- /dev/null +++ b/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java @@ -0,0 +1,28 @@ +package school.hei.haapi.endpoint.rest.mapper; + +import org.springframework.stereotype.Component; +import school.hei.haapi.endpoint.rest.model.DocumensoDocument; +import school.hei.haapi.endpoint.rest.model.DocumensoDocumentStatus; +import school.hei.haapi.endpoint.rest.model.TemplateDocumenso; + +@Component +public class DocumensoMapper { + public TemplateDocumenso toRest(school.hei.haapi.model.TemplateDocumenso domain) { + return new TemplateDocumenso() + .id(domain.getId()) + .documensoTemplateId(domain.getDocumensoTemplateId()) + .title(domain.getTitle()) + .type(domain.getType()) + .adminId(domain.getAdmin() == null ? null : domain.getAdmin().getId()); + } + + public DocumensoDocument toRest(school.hei.haapi.model.DocumensoDocument domain) { + return new DocumensoDocument() + .id(domain.getId()) + .documensoDocumentId(domain.getDocumensoDocumentId()) + .status(DocumensoDocumentStatus.valueOf(domain.getStatus().name())) + .promotionId(domain.getPromotion().getId()) + .level(domain.getLevel()) + .templateId(domain.getTemplate().getId()); + } +} diff --git a/src/main/java/school/hei/haapi/model/DocumensoDocument.java b/src/main/java/school/hei/haapi/model/DocumensoDocument.java new file mode 100644 index 000000000..0a165d580 --- /dev/null +++ b/src/main/java/school/hei/haapi/model/DocumensoDocument.java @@ -0,0 +1,71 @@ +package school.hei.haapi.model; + +import static jakarta.persistence.EnumType.STRING; +import static jakarta.persistence.GenerationType.IDENTITY; +import static org.hibernate.type.SqlTypes.NAMED_ENUM; + +import jakarta.persistence.Entity; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import java.io.Serializable; +import java.time.Instant; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.JdbcTypeCode; +import school.hei.haapi.endpoint.rest.model.StudentLevel; + +@Table(name = "documenso_document") +@Entity +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +@EqualsAndHashCode +@ToString +public class DocumensoDocument implements Serializable { + @Id + @GeneratedValue(strategy = IDENTITY) + private String id; + + private Long documensoDocumentId; + + @ManyToOne + @JoinColumn(name = "documenso_template_id") + private TemplateDocumenso template; + + @ManyToOne + @JoinColumn(name = "promotion_id") + private Promotion promotion; + + @Enumerated(STRING) + private StudentLevel level; + + @Enumerated(STRING) + @JdbcTypeCode(NAMED_ENUM) + private Status status; + + @ManyToOne + @JoinColumn(name = "file_info_id") + private FileInfo fileInfo; + + @CreationTimestamp private Instant creationDatetime; + + private Instant completedDatetime; + + public enum Status { + PENDING, + COMPLETED, + REJECTED, + } +} diff --git a/src/main/java/school/hei/haapi/model/DocumensoDocumentRecipient.java b/src/main/java/school/hei/haapi/model/DocumensoDocumentRecipient.java new file mode 100644 index 000000000..26f86cbfe --- /dev/null +++ b/src/main/java/school/hei/haapi/model/DocumensoDocumentRecipient.java @@ -0,0 +1,48 @@ +package school.hei.haapi.model; + +import static jakarta.persistence.GenerationType.IDENTITY; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import java.io.Serializable; +import java.time.Instant; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Table(name = "documenso_document_recipient") +@Entity +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +@EqualsAndHashCode +@ToString +public class DocumensoDocumentRecipient implements Serializable { + @Id + @GeneratedValue(strategy = IDENTITY) + private String id; + + @ManyToOne + @JoinColumn(name = "documenso_document_id") + private DocumensoDocument document; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + + private Long documensoRecipientId; + + private String signingToken; + + private Instant signedDatetime; +} diff --git a/src/main/java/school/hei/haapi/model/TemplateDocumenso.java b/src/main/java/school/hei/haapi/model/TemplateDocumenso.java new file mode 100644 index 000000000..9bbe6ad40 --- /dev/null +++ b/src/main/java/school/hei/haapi/model/TemplateDocumenso.java @@ -0,0 +1,44 @@ +package school.hei.haapi.model; + +import static jakarta.persistence.GenerationType.IDENTITY; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import java.io.Serializable; +import java.time.Instant; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import org.hibernate.annotations.CreationTimestamp; + +@Table(name = "documenso_template") +@Entity +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder(toBuilder = true) +@EqualsAndHashCode +@ToString +public class TemplateDocumenso implements Serializable { + @Id + @GeneratedValue(strategy = IDENTITY) + private String id; + + private Long documensoTemplateId; + + private String title; + + private String type; + + @ManyToOne private User admin; + + @CreationTimestamp private Instant creationDatetime; +} diff --git a/src/main/java/school/hei/haapi/repository/DocumensoDocumentRecipientRepository.java b/src/main/java/school/hei/haapi/repository/DocumensoDocumentRecipientRepository.java new file mode 100644 index 000000000..9c093da5a --- /dev/null +++ b/src/main/java/school/hei/haapi/repository/DocumensoDocumentRecipientRepository.java @@ -0,0 +1,13 @@ +package school.hei.haapi.repository; + +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import school.hei.haapi.model.DocumensoDocumentRecipient; + +@Repository +public interface DocumensoDocumentRecipientRepository + extends JpaRepository { + Optional findByDocument_IdAndUser_Id( + String documentId, String userId); +} diff --git a/src/main/java/school/hei/haapi/repository/DocumensoDocumentRepository.java b/src/main/java/school/hei/haapi/repository/DocumensoDocumentRepository.java new file mode 100644 index 000000000..e54fbdd46 --- /dev/null +++ b/src/main/java/school/hei/haapi/repository/DocumensoDocumentRepository.java @@ -0,0 +1,11 @@ +package school.hei.haapi.repository; + +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import school.hei.haapi.model.DocumensoDocument; + +@Repository +public interface DocumensoDocumentRepository extends JpaRepository { + Optional findByDocumensoDocumentId(Long documensoDocumentId); +} diff --git a/src/main/java/school/hei/haapi/repository/TemplateDocumensoRepository.java b/src/main/java/school/hei/haapi/repository/TemplateDocumensoRepository.java new file mode 100644 index 000000000..a7f017c0c --- /dev/null +++ b/src/main/java/school/hei/haapi/repository/TemplateDocumensoRepository.java @@ -0,0 +1,11 @@ +package school.hei.haapi.repository; + +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import school.hei.haapi.model.TemplateDocumenso; + +@Repository +public interface TemplateDocumensoRepository extends JpaRepository { + Optional findByDocumensoTemplateId(Long documensoTemplateId); +} diff --git a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java new file mode 100644 index 000000000..51d2c55bc --- /dev/null +++ b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java @@ -0,0 +1,224 @@ +package school.hei.haapi.service; + +import static school.hei.haapi.model.exception.ApiException.ExceptionType.SERVER_EXCEPTION; + +import java.math.BigDecimal; +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import school.hei.haapi.endpoint.rest.model.FeeFrequency; +import school.hei.haapi.endpoint.rest.model.FileType; +import school.hei.haapi.endpoint.rest.model.StudentLevel; +import school.hei.haapi.file.bucket.BucketComponent; +import school.hei.haapi.model.DocumensoDocument; +import school.hei.haapi.model.DocumensoDocumentRecipient; +import school.hei.haapi.model.FileInfo; +import school.hei.haapi.model.Promotion; +import school.hei.haapi.model.User; +import school.hei.haapi.model.exception.ApiException; +import school.hei.haapi.model.exception.NotFoundException; +import school.hei.haapi.model.promotion.PromotionLevelOutOfRangeException; +import school.hei.haapi.repository.DocumensoDocumentRecipientRepository; +import school.hei.haapi.repository.DocumensoDocumentRepository; +import school.hei.haapi.repository.FeeRepository; +import school.hei.haapi.repository.FileInfoRepository; +import school.hei.haapi.repository.PromotionRepository; +import school.hei.haapi.repository.TemplateDocumensoRepository; +import school.hei.haapi.repository.UserRepository; +import school.hei.haapi.service.documenso.DocumensoClient; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequest; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequestRecipientsInner; + +@Service +@AllArgsConstructor +public class DocumensoDocumentService { + private final DocumensoClient documensoClient; + private final DocumensoDocumentRepository documensoDocumentRepository; + private final DocumensoDocumentRecipientRepository documensoDocumentRecipientRepository; + private final TemplateDocumensoRepository templateDocumensoRepository; + private final PromotionRepository promotionRepository; + private final UserRepository userRepository; + private final FeeRepository feeRepository; + private final FileInfoRepository fileInfoRepository; + private final BucketComponent bucketComponent; + + @Transactional + public DocumensoDocument generateForPromotionLevel( + String promotionId, + StudentLevel level, + long documensoTemplateId, + String adminId, + String monitorId, + Map prefillFieldValues) { + var promotion = + promotionRepository + .findById(promotionId) + .orElseThrow(() -> new NotFoundException("Promotion with id: " + promotionId)); + var admin = + userRepository + .findById(adminId) + .orElseThrow(() -> new NotFoundException("User with id: " + adminId)); + var monitor = + userRepository + .findById(monitorId) + .orElseThrow(() -> new NotFoundException("User with id: " + monitorId)); + var template = + templateDocumensoRepository + .findByDocumensoTemplateId(documensoTemplateId) + .orElseThrow( + () -> new NotFoundException("Documenso template: " + documensoTemplateId)); + + try { + var remoteTemplate = documensoClient.getTemplate(documensoTemplateId); + var placeholders = remoteTemplate.getRecipients(); + if (placeholders == null || placeholders.size() < 2) { + throw new ApiException( + SERVER_EXCEPTION, + "Documenso template " + + documensoTemplateId + + " must define at least 2 recipient placeholders (admin + monitor)"); + } + + var request = new TemplateCreateDocumentFromTemplateRequest(); + request.setTemplateId(BigDecimal.valueOf(documensoTemplateId)); + request.setRecipients( + List.of( + toRecipient(placeholders.get(0).getId(), admin), + toRecipient(placeholders.get(1).getId(), monitor))); + if (prefillFieldValues != null && !prefillFieldValues.isEmpty()) { + request.setPrefillFields( + prefillFieldValues.entrySet().stream().map(this::toPrefillField).toList()); + } + + var response = documensoClient.useTemplate(request); + + var document = + documensoDocumentRepository.save( + DocumensoDocument.builder() + .documensoDocumentId(response.getId().longValue()) + .template(template) + .promotion(promotion) + .level(level) + .status(DocumensoDocument.Status.PENDING) + .build()); + + for (var recipient : response.getRecipients()) { + var user = recipient.getEmail().equals(admin.getEmail()) ? admin : monitor; + documensoDocumentRecipientRepository.save( + DocumensoDocumentRecipient.builder() + .document(document) + .user(user) + .documensoRecipientId(recipient.getId().longValue()) + .signingToken(recipient.getToken()) + .build()); + } + return document; + } catch (school.hei.haapi.service.documenso.gen.invoker.ApiException e) { + throw new ApiException(SERVER_EXCEPTION, e); + } + } + + private TemplateCreateDocumentFromTemplateRequestRecipientsInner toRecipient( + BigDecimal placeholderId, User user) { + var recipient = new TemplateCreateDocumentFromTemplateRequestRecipientsInner(); + recipient.setId(placeholderId); + recipient.setEmail(user.getEmail()); + recipient.setName(user.getFirstName() + " " + user.getLastName()); + return recipient; + } + + private TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner toPrefillField( + Map.Entry entry) { + var field = new TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner(); + field.setId(BigDecimal.valueOf(entry.getKey())); + field.setType(TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.TypeEnum.TEXT); + field.setValue(entry.getValue()); + return field; + } + + public List findMonthlyPayingStudentsForPromotionLevel( + String promotionId, StudentLevel level) { + var monthlyPayers = + feeRepository.findAllByFrequency(FeeFrequency.MONTHLY).stream() + .map(fee -> fee.getStudent().getId()) + .collect(Collectors.toSet()); + return userRepository.findAllByRoleAndStatus(User.Role.STUDENT, User.Status.ENABLED).stream() + .filter(student -> monthlyPayers.contains(student.getId())) + .filter( + student -> + student + .findCurrentGroup() + .map( + group -> + group.getPromotion().getId().equals(promotionId) + && level == safeLevelAt(group.getPromotion())) + .orElse(false)) + .toList(); + } + + private StudentLevel safeLevelAt(Promotion promotion) { + try { + return promotion.getLevelAt(Instant.now()); + } catch (PromotionLevelOutOfRangeException e) { + return null; + } + } + + public String getSigningToken(String documentId, String requestingUserId) { + return documensoDocumentRecipientRepository + .findByDocument_IdAndUser_Id(documentId, requestingUserId) + .map(DocumensoDocumentRecipient::getSigningToken) + .orElseThrow( + () -> + new NotFoundException( + "No Documenso recipient for document " + + documentId + + " and user " + + requestingUserId)); + } + + @Transactional + @SuppressWarnings("unchecked") + public void handleWebhook(Map payload) { + var event = String.valueOf(payload.get("event")); + if (!event.contains("COMPLETED")) { + return; + } + var data = (Map) payload.get("payload"); + if (data == null || data.get("id") == null) { + return; + } + var documensoDocumentId = Long.parseLong(String.valueOf(data.get("id"))); + var document = + documensoDocumentRepository + .findByDocumensoDocumentId(documensoDocumentId) + .orElseThrow( + () -> new NotFoundException("Documenso document " + documensoDocumentId)); + + try { + var signedFile = documensoClient.downloadSignedDocument(documensoDocumentId); + var bucketKey = "documenso-documents/" + documensoDocumentId + ".pdf"; + bucketComponent.upload(signedFile, bucketKey); + + var fileInfo = + fileInfoRepository.save( + FileInfo.builder() + .name(bucketKey) + .fileType(FileType.OTHER) + .filePath(bucketKey) + .build()); + + document.setFileInfo(fileInfo); + document.setStatus(DocumensoDocument.Status.COMPLETED); + document.setCompletedDatetime(Instant.now()); + documensoDocumentRepository.save(document); + } catch (school.hei.haapi.service.documenso.gen.invoker.ApiException e) { + throw new ApiException(SERVER_EXCEPTION, e); + } + } +} diff --git a/src/main/java/school/hei/haapi/service/TemplateDocumensoService.java b/src/main/java/school/hei/haapi/service/TemplateDocumensoService.java new file mode 100644 index 000000000..6a43c1bb9 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/TemplateDocumensoService.java @@ -0,0 +1,42 @@ +package school.hei.haapi.service; + +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.SneakyThrows; +import org.springframework.stereotype.Service; +import school.hei.haapi.model.TemplateDocumenso; +import school.hei.haapi.repository.TemplateDocumensoRepository; +import school.hei.haapi.repository.UserRepository; +import school.hei.haapi.service.documenso.DocumensoClient; +import school.hei.haapi.service.documenso.gen.model.TemplateFindTemplates200ResponseDataInner; + +@Service +@AllArgsConstructor +public class TemplateDocumensoService { + private final DocumensoClient documensoClient; + private final TemplateDocumensoRepository templateDocumensoRepository; + private final UserRepository userRepository; + + @SneakyThrows + public List syncTemplates() { + var response = documensoClient.findTemplates(null, 1, 100); + return response.getData().stream().map(this::upsert).toList(); + } + + private TemplateDocumenso upsert(TemplateFindTemplates200ResponseDataInner remote) { + var documensoTemplateId = remote.getId().longValue(); + var template = + templateDocumensoRepository + .findByDocumensoTemplateId(documensoTemplateId) + .orElseGet(TemplateDocumenso::new); + template.setDocumensoTemplateId(documensoTemplateId); + template.setTitle(remote.getTitle()); + template.setType(remote.getType() == null ? null : remote.getType().getValue()); + if (remote.getUserId() != null) { + userRepository + .findByDocumensoUserId(remote.getUserId().longValue()) + .ifPresent(template::setAdmin); + } + return templateDocumensoRepository.save(template); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/DocumensoClient.java b/src/main/java/school/hei/haapi/service/documenso/DocumensoClient.java new file mode 100644 index 000000000..210a12c6f --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/DocumensoClient.java @@ -0,0 +1,49 @@ +package school.hei.haapi.service.documenso; + +import java.io.File; +import java.math.BigDecimal; +import school.hei.haapi.service.documenso.gen.api.DocumentApi; +import school.hei.haapi.service.documenso.gen.api.TemplateApi; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import school.hei.haapi.service.documenso.gen.invoker.ApiException; +import school.hei.haapi.service.documenso.gen.model.DocumentGet200Response; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplate200Response; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequest; +import school.hei.haapi.service.documenso.gen.model.TemplateFindTemplates200Response; +import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200Response; + +public class DocumensoClient { + private final TemplateApi templateApi; + private final DocumentApi documentApi; + + public DocumensoClient(String baseUrl, String apiKey) { + var apiClient = new ApiClient(); + apiClient.setBasePath(baseUrl); + apiClient.setRequestInterceptor(builder -> builder.header("Authorization", apiKey)); + this.templateApi = new TemplateApi(apiClient); + this.documentApi = new DocumentApi(apiClient); + } + + public TemplateFindTemplates200Response findTemplates(String query, int page, int perPage) + throws ApiException { + return templateApi.templateFindTemplates( + query, BigDecimal.valueOf(page), BigDecimal.valueOf(perPage)); + } + + public TemplateGetTemplateById200Response getTemplate(long templateId) throws ApiException { + return templateApi.templateGetTemplateById(BigDecimal.valueOf(templateId)); + } + + public TemplateCreateDocumentFromTemplate200Response useTemplate( + TemplateCreateDocumentFromTemplateRequest request) throws ApiException { + return templateApi.templateCreateDocumentFromTemplate(request); + } + + public DocumentGet200Response getDocument(long documentId) throws ApiException { + return documentApi.documentGet(BigDecimal.valueOf(documentId)); + } + + public File downloadSignedDocument(long documentId) throws ApiException { + return documentApi.documentDownload(BigDecimal.valueOf(documentId), "signed"); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/DocumensoConf.java b/src/main/java/school/hei/haapi/service/documenso/DocumensoConf.java new file mode 100644 index 000000000..c1df96a4a --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/DocumensoConf.java @@ -0,0 +1,23 @@ +package school.hei.haapi.service.documenso; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class DocumensoConf { + + private final String apiUrl; + private final String apiKey; + + public DocumensoConf( + @Value("${documenso.api.url}") String apiUrl, @Value("${documenso.api.key}") String apiKey) { + this.apiUrl = apiUrl; + this.apiKey = apiKey; + } + + @Bean + public DocumensoClient documensoClient() { + return new DocumensoClient(apiUrl, apiKey); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/api/DocumentApi.java b/src/main/java/school/hei/haapi/service/documenso/gen/api/DocumentApi.java new file mode 100644 index 000000000..e56dd7e61 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/api/DocumentApi.java @@ -0,0 +1,255 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.api; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; +import java.util.StringJoiner; +import java.util.function.Consumer; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import school.hei.haapi.service.documenso.gen.invoker.ApiException; +import school.hei.haapi.service.documenso.gen.invoker.ApiResponse; +import school.hei.haapi.service.documenso.gen.invoker.Pair; +import school.hei.haapi.service.documenso.gen.model.DocumentGet200Response; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class DocumentApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public DocumentApi() { + this(new ApiClient()); + } + + public DocumentApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + protected ApiException getApiException(String operationId, HttpResponse response) + throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Download document Downloads the document. \"signed\" returns the completed document + * with signatures, \"original\" returns the original uploaded document. + * + * @param documentId (required) + * @param version (optional, default to signed) + * @return File + * @throws ApiException if fails to make API call + */ + public File documentDownload(BigDecimal documentId, String version) throws ApiException { + ApiResponse localVarResponse = documentDownloadWithHttpInfo(documentId, version); + return localVarResponse.getData(); + } + + /** + * Download document Downloads the document. \"signed\" returns the completed document + * with signatures, \"original\" returns the original uploaded document. + * + * @param documentId (required) + * @param version (optional, default to signed) + * @return ApiResponse<File> + * @throws ApiException if fails to make API call + */ + public ApiResponse documentDownloadWithHttpInfo(BigDecimal documentId, String version) + throws ApiException { + HttpRequest.Builder localVarRequestBuilder = + documentDownloadRequestBuilder(documentId, version); + try { + HttpResponse localVarResponse = + memberVarHttpClient.send( + localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode() / 100 != 2) { + throw getApiException("documentDownload", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null + ? null + : memberVarObjectMapper.readValue( + localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder documentDownloadRequestBuilder(BigDecimal documentId, String version) + throws ApiException { + // verify the required parameter 'documentId' is set + if (documentId == null) { + throw new ApiException( + 400, "Missing the required parameter 'documentId' when calling documentDownload"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = + "/document/{documentId}/download" + .replace("{documentId}", ApiClient.urlEncode(documentId.toString())); + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "version"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("version", version)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri( + URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/pdf"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Get document + * + * @param documentId (required) + * @return DocumentGet200Response + * @throws ApiException if fails to make API call + */ + public DocumentGet200Response documentGet(BigDecimal documentId) throws ApiException { + ApiResponse localVarResponse = documentGetWithHttpInfo(documentId); + return localVarResponse.getData(); + } + + /** + * Get document + * + * @param documentId (required) + * @return ApiResponse<DocumentGet200Response> + * @throws ApiException if fails to make API call + */ + public ApiResponse documentGetWithHttpInfo(BigDecimal documentId) + throws ApiException { + HttpRequest.Builder localVarRequestBuilder = documentGetRequestBuilder(documentId); + try { + HttpResponse localVarResponse = + memberVarHttpClient.send( + localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode() / 100 != 2) { + throw getApiException("documentGet", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null + ? null + : memberVarObjectMapper.readValue( + localVarResponse.body(), + new TypeReference() {}) // closes the InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder documentGetRequestBuilder(BigDecimal documentId) throws ApiException { + // verify the required parameter 'documentId' is set + if (documentId == null) { + throw new ApiException( + 400, "Missing the required parameter 'documentId' when calling documentGet"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = + "/document/{documentId}" + .replace("{documentId}", ApiClient.urlEncode(documentId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/api/TemplateApi.java b/src/main/java/school/hei/haapi/service/documenso/gen/api/TemplateApi.java new file mode 100644 index 000000000..6d04626f6 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/api/TemplateApi.java @@ -0,0 +1,359 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.api; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; +import java.util.StringJoiner; +import java.util.function.Consumer; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import school.hei.haapi.service.documenso.gen.invoker.ApiException; +import school.hei.haapi.service.documenso.gen.invoker.ApiResponse; +import school.hei.haapi.service.documenso.gen.invoker.Pair; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplate200Response; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequest; +import school.hei.haapi.service.documenso.gen.model.TemplateFindTemplates200Response; +import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200Response; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class TemplateApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public TemplateApi() { + this(new ApiClient()); + } + + public TemplateApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + protected ApiException getApiException(String operationId, HttpResponse response) + throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Use template Use the template to create a document + * + * @param templateCreateDocumentFromTemplateRequest (required) + * @return TemplateCreateDocumentFromTemplate200Response + * @throws ApiException if fails to make API call + */ + public TemplateCreateDocumentFromTemplate200Response templateCreateDocumentFromTemplate( + TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) + throws ApiException { + ApiResponse localVarResponse = + templateCreateDocumentFromTemplateWithHttpInfo(templateCreateDocumentFromTemplateRequest); + return localVarResponse.getData(); + } + + /** + * Use template Use the template to create a document + * + * @param templateCreateDocumentFromTemplateRequest (required) + * @return ApiResponse<TemplateCreateDocumentFromTemplate200Response> + * @throws ApiException if fails to make API call + */ + public ApiResponse + templateCreateDocumentFromTemplateWithHttpInfo( + TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) + throws ApiException { + HttpRequest.Builder localVarRequestBuilder = + templateCreateDocumentFromTemplateRequestBuilder(templateCreateDocumentFromTemplateRequest); + try { + HttpResponse localVarResponse = + memberVarHttpClient.send( + localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode() / 100 != 2) { + throw getApiException("templateCreateDocumentFromTemplate", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null + ? null + : memberVarObjectMapper.readValue( + localVarResponse.body(), + new TypeReference< + TemplateCreateDocumentFromTemplate200Response>() {}) // closes the + // InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder templateCreateDocumentFromTemplateRequestBuilder( + TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) + throws ApiException { + // verify the required parameter 'templateCreateDocumentFromTemplateRequest' is set + if (templateCreateDocumentFromTemplateRequest == null) { + throw new ApiException( + 400, + "Missing the required parameter 'templateCreateDocumentFromTemplateRequest' when calling" + + " templateCreateDocumentFromTemplate"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/template/use"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = + memberVarObjectMapper.writeValueAsBytes(templateCreateDocumentFromTemplateRequest); + localVarRequestBuilder.method( + "POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Find templates + * + * @param query (optional) + * @param page (optional) + * @param perPage (optional) + * @return TemplateFindTemplates200Response + * @throws ApiException if fails to make API call + */ + public TemplateFindTemplates200Response templateFindTemplates( + String query, BigDecimal page, BigDecimal perPage) throws ApiException { + ApiResponse localVarResponse = + templateFindTemplatesWithHttpInfo(query, page, perPage); + return localVarResponse.getData(); + } + + /** + * Find templates + * + * @param query (optional) + * @param page (optional) + * @param perPage (optional) + * @return ApiResponse<TemplateFindTemplates200Response> + * @throws ApiException if fails to make API call + */ + public ApiResponse templateFindTemplatesWithHttpInfo( + String query, BigDecimal page, BigDecimal perPage) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = + templateFindTemplatesRequestBuilder(query, page, perPage); + try { + HttpResponse localVarResponse = + memberVarHttpClient.send( + localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode() / 100 != 2) { + throw getApiException("templateFindTemplates", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null + ? null + : memberVarObjectMapper.readValue( + localVarResponse.body(), + new TypeReference< + TemplateFindTemplates200Response>() {}) // closes the InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder templateFindTemplatesRequestBuilder( + String query, BigDecimal page, BigDecimal perPage) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/template"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "query"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("query", query)); + localVarQueryParameterBaseName = "page"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("page", page)); + localVarQueryParameterBaseName = "perPage"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("perPage", perPage)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri( + URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Get template + * + * @param templateId (required) + * @return TemplateGetTemplateById200Response + * @throws ApiException if fails to make API call + */ + public TemplateGetTemplateById200Response templateGetTemplateById(BigDecimal templateId) + throws ApiException { + ApiResponse localVarResponse = + templateGetTemplateByIdWithHttpInfo(templateId); + return localVarResponse.getData(); + } + + /** + * Get template + * + * @param templateId (required) + * @return ApiResponse<TemplateGetTemplateById200Response> + * @throws ApiException if fails to make API call + */ + public ApiResponse templateGetTemplateByIdWithHttpInfo( + BigDecimal templateId) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = templateGetTemplateByIdRequestBuilder(templateId); + try { + HttpResponse localVarResponse = + memberVarHttpClient.send( + localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode() / 100 != 2) { + throw getApiException("templateGetTemplateById", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null + ? null + : memberVarObjectMapper.readValue( + localVarResponse.body(), + new TypeReference< + TemplateGetTemplateById200Response>() {}) // closes the InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder templateGetTemplateByIdRequestBuilder(BigDecimal templateId) + throws ApiException { + // verify the required parameter 'templateId' is set + if (templateId == null) { + throw new ApiException( + 400, "Missing the required parameter 'templateId' when calling templateGetTemplateById"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = + "/template/{templateId}" + .replace("{templateId}", ApiClient.urlEncode(templateId.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiClient.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiClient.java new file mode 100644 index 000000000..f4d33569b --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiClient.java @@ -0,0 +1,445 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.invoker; + +import static java.nio.charset.StandardCharsets.UTF_8; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import java.io.InputStream; +import java.net.URI; +import java.net.URLEncoder; +import java.net.http.HttpClient; +import java.net.http.HttpConnectTimeoutException; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.StringJoiner; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import org.openapitools.jackson.nullable.JsonNullableModule; + +/** + * Configuration and utility class for API clients. + * + *

This class can be constructed and modified, then used to instantiate the various API classes. + * The API classes use the settings in this class to configure themselves, but otherwise do not + * store a link to this class. + * + *

This class is mutable and not synchronized, so it is not thread-safe. The API classes + * generated from this are immutable and thread-safe. + * + *

The setter methods of this class return the current object to facilitate a fluent style of + * configuration. + */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class ApiClient { + + private HttpClient.Builder builder; + private ObjectMapper mapper; + private String scheme; + private String host; + private int port; + private String basePath; + private Consumer interceptor; + private Consumer> responseInterceptor; + private Consumer> asyncResponseInterceptor; + private Duration readTimeout; + private Duration connectTimeout; + + public static String valueToString(Object value) { + if (value == null) { + return ""; + } + if (value instanceof OffsetDateTime) { + return ((OffsetDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + return value.toString(); + } + + /** + * URL encode a string in the UTF-8 encoding. + * + * @param s String to encode. + * @return URL-encoded representation of the input string. + */ + public static String urlEncode(String s) { + return URLEncoder.encode(s, UTF_8).replaceAll("\\+", "%20"); + } + + /** + * Convert a URL query name/value parameter to a list of encoded {@link Pair} objects. + * + *

The value can be null, in which case an empty list is returned. + * + * @param name The query name parameter. + * @param value The query value, which may not be a collection but may be null. + * @return A singleton list of the {@link Pair} objects representing the input parameters, which + * is encoded for use in a URL. If the value is null, an empty list is returned. + */ + public static List parameterToPairs(String name, Object value) { + if (name == null || name.isEmpty() || value == null) { + return Collections.emptyList(); + } + return Collections.singletonList(new Pair(urlEncode(name), urlEncode(valueToString(value)))); + } + + /** + * Convert a URL query name/collection parameter to a list of encoded {@link Pair} objects. + * + * @param collectionFormat The swagger collectionFormat string (csv, tsv, etc). + * @param name The query name parameter. + * @param values A collection of values for the given query name, which may be null. + * @return A list of {@link Pair} objects representing the input parameters, which is encoded for + * use in a URL. If the values collection is null, an empty list is returned. + */ + public static List parameterToPairs( + String collectionFormat, String name, Collection values) { + if (name == null || name.isEmpty() || values == null || values.isEmpty()) { + return Collections.emptyList(); + } + + // get the collection format (default: csv) + String format = + collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat; + + // create the params based on the collection format + if ("multi".equals(format)) { + return values.stream() + .map(value -> new Pair(urlEncode(name), urlEncode(valueToString(value)))) + .collect(Collectors.toList()); + } + + String delimiter; + switch (format) { + case "csv": + delimiter = urlEncode(","); + break; + case "ssv": + delimiter = urlEncode(" "); + break; + case "tsv": + delimiter = urlEncode("\t"); + break; + case "pipes": + delimiter = urlEncode("|"); + break; + default: + throw new IllegalArgumentException("Illegal collection format: " + collectionFormat); + } + + StringJoiner joiner = new StringJoiner(delimiter); + for (Object value : values) { + joiner.add(urlEncode(valueToString(value))); + } + + return Collections.singletonList(new Pair(urlEncode(name), joiner.toString())); + } + + /** Create an instance of ApiClient. */ + public ApiClient() { + this.builder = createDefaultHttpClientBuilder(); + this.mapper = createDefaultObjectMapper(); + updateBaseUri(getDefaultBaseUri()); + interceptor = null; + readTimeout = null; + connectTimeout = null; + responseInterceptor = null; + asyncResponseInterceptor = null; + } + + /** + * Create an instance of ApiClient. + * + * @param builder Http client builder. + * @param mapper Object mapper. + * @param baseUri Base URI + */ + public ApiClient(HttpClient.Builder builder, ObjectMapper mapper, String baseUri) { + this.builder = builder; + this.mapper = mapper; + updateBaseUri(baseUri != null ? baseUri : getDefaultBaseUri()); + interceptor = null; + readTimeout = null; + connectTimeout = null; + responseInterceptor = null; + asyncResponseInterceptor = null; + } + + protected ObjectMapper createDefaultObjectMapper() { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); + mapper.registerModule(new JavaTimeModule()); + mapper.registerModule(new JsonNullableModule()); + return mapper; + } + + protected String getDefaultBaseUri() { + return "https://app.documenso.com/api/v2"; + } + + protected HttpClient.Builder createDefaultHttpClientBuilder() { + return HttpClient.newBuilder(); + } + + public void updateBaseUri(String baseUri) { + URI uri = URI.create(baseUri); + scheme = uri.getScheme(); + host = uri.getHost(); + port = uri.getPort(); + basePath = uri.getRawPath(); + } + + /** + * Set a custom {@link HttpClient.Builder} object to use when creating the {@link HttpClient} that + * is used by the API client. + * + * @param builder Custom client builder. + * @return This object. + */ + public ApiClient setHttpClientBuilder(HttpClient.Builder builder) { + this.builder = builder; + return this; + } + + /** + * Get an {@link HttpClient} based on the current {@link HttpClient.Builder}. + * + *

The returned object is immutable and thread-safe. + * + * @return The HTTP client. + */ + public HttpClient getHttpClient() { + return builder.build(); + } + + /** + * Set a custom {@link ObjectMapper} to serialize and deserialize the request and response bodies. + * + * @param mapper Custom object mapper. + * @return This object. + */ + public ApiClient setObjectMapper(ObjectMapper mapper) { + this.mapper = mapper; + return this; + } + + /** + * Get a copy of the current {@link ObjectMapper}. + * + * @return A copy of the current object mapper. + */ + public ObjectMapper getObjectMapper() { + return mapper.copy(); + } + + /** + * Set a custom host name for the target service. + * + * @param host The host name of the target service. + * @return This object. + */ + public ApiClient setHost(String host) { + this.host = host; + return this; + } + + /** + * Set a custom port number for the target service. + * + * @param port The port of the target service. Set this to -1 to reset the value to the default + * for the scheme. + * @return This object. + */ + public ApiClient setPort(int port) { + this.port = port; + return this; + } + + /** + * Set a custom base path for the target service, for example '/v2'. + * + * @param basePath The base path against which the rest of the path is resolved. + * @return This object. + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + return this; + } + + /** + * Get the base URI to resolve the endpoint paths against. + * + * @return The complete base URI that the rest of the API parameters are resolved against. + */ + public String getBaseUri() { + return scheme + "://" + host + (port == -1 ? "" : ":" + port) + basePath; + } + + /** + * Set a custom scheme for the target service, for example 'https'. + * + * @param scheme The scheme of the target service + * @return This object. + */ + public ApiClient setScheme(String scheme) { + this.scheme = scheme; + return this; + } + + /** + * Set a custom request interceptor. + * + *

A request interceptor is a mechanism for altering each request before it is sent. After the + * request has been fully configured but not yet built, the request builder is passed into this + * function for further modification, after which it is sent out. + * + *

This is useful for altering the requests in a custom manner, such as adding headers. It + * could also be used for logging and monitoring. + * + * @param interceptor A function invoked before creating each request. A value of null resets the + * interceptor to a no-op. + * @return This object. + */ + public ApiClient setRequestInterceptor(Consumer interceptor) { + this.interceptor = interceptor; + return this; + } + + /** + * Get the custom interceptor. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer getRequestInterceptor() { + return interceptor; + } + + /** + * Set a custom response interceptor. + * + *

This is useful for logging, monitoring or extraction of header variables + * + * @param interceptor A function invoked before creating each request. A value of null resets the + * interceptor to a no-op. + * @return This object. + */ + public ApiClient setResponseInterceptor(Consumer> interceptor) { + this.responseInterceptor = interceptor; + return this; + } + + /** + * Get the custom response interceptor. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer> getResponseInterceptor() { + return responseInterceptor; + } + + /** + * Set a custom async response interceptor. Use this interceptor when asyncNative is set to + * 'true'. + * + *

This is useful for logging, monitoring or extraction of header variables + * + * @param interceptor A function invoked before creating each request. A value of null resets the + * interceptor to a no-op. + * @return This object. + */ + public ApiClient setAsyncResponseInterceptor(Consumer> interceptor) { + this.asyncResponseInterceptor = interceptor; + return this; + } + + /** + * Get the custom async response interceptor. Use this interceptor when asyncNative is set to + * 'true'. + * + * @return The custom interceptor that was set, or null if there isn't any. + */ + public Consumer> getAsyncResponseInterceptor() { + return asyncResponseInterceptor; + } + + /** + * Set the read timeout for the http client. + * + *

This is the value used by default for each request, though it can be overridden on a + * per-request basis with a request interceptor. + * + * @param readTimeout The read timeout used by default by the http client. Setting this value to + * null resets the timeout to an effectively infinite value. + * @return This object. + */ + public ApiClient setReadTimeout(Duration readTimeout) { + this.readTimeout = readTimeout; + return this; + } + + /** + * Get the read timeout that was set. + * + * @return The read timeout, or null if no timeout was set. Null represents an infinite wait time. + */ + public Duration getReadTimeout() { + return readTimeout; + } + + /** + * Sets the connect timeout (in milliseconds) for the http client. + * + *

In the case where a new connection needs to be established, if the connection cannot be + * established within the given {@code duration}, then {@link + * HttpClient#send(HttpRequest,BodyHandler) HttpClient::send} throws an {@link + * HttpConnectTimeoutException}, or {@link HttpClient#sendAsync(HttpRequest,BodyHandler) + * HttpClient::sendAsync} completes exceptionally with an {@code HttpConnectTimeoutException}. If + * a new connection does not need to be established, for example if a connection can be reused + * from a previous request, then this timeout duration has no effect. + * + * @param connectTimeout connection timeout in milliseconds + * @return This object. + */ + public ApiClient setConnectTimeout(Duration connectTimeout) { + this.connectTimeout = connectTimeout; + this.builder.connectTimeout(connectTimeout); + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public Duration getConnectTimeout() { + return connectTimeout; + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiException.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiException.java new file mode 100644 index 000000000..c75d74144 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiException.java @@ -0,0 +1,99 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.invoker; + +import java.net.http.HttpHeaders; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class ApiException extends Exception { + private static final long serialVersionUID = 1L; + + private int code = 0; + private HttpHeaders responseHeaders = null; + private String responseBody = null; + + public ApiException() {} + + public ApiException(Throwable throwable) { + super(throwable); + } + + public ApiException(String message) { + super(message); + } + + public ApiException( + String message, + Throwable throwable, + int code, + HttpHeaders responseHeaders, + String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + public ApiException(String message, int code, HttpHeaders responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + public ApiException(int code, HttpHeaders responseHeaders, String responseBody) { + this((String) null, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + public ApiException(int code, String message, HttpHeaders responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return Headers as an HttpHeaders object + */ + public HttpHeaders getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiResponse.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiResponse.java new file mode 100644 index 000000000..c820fcd2c --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiResponse.java @@ -0,0 +1,62 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.invoker; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + * + * @param The type of data that is deserialized from response body + */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class ApiResponse { + private final int statusCode; + private final Map> headers; + private final T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Configuration.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Configuration.java new file mode 100644 index 000000000..46a59dce4 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Configuration.java @@ -0,0 +1,43 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.invoker; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class Configuration { + public static final String VERSION = "1.0.0"; + + private static ApiClient defaultApiClient = new ApiClient(); + + /** + * Get the default API client, which would be used when creating API instances without providing + * an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + return defaultApiClient; + } + + /** + * Set the default API client, which would be used when creating API instances without providing + * an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient = apiClient; + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/JSON.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/JSON.java new file mode 100644 index 000000000..6b0c24428 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/JSON.java @@ -0,0 +1,253 @@ +package school.hei.haapi.service.documenso.gen.invoker; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import java.text.DateFormat; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.openapitools.jackson.nullable.JsonNullableModule; +import school.hei.haapi.service.documenso.gen.model.*; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class JSON { + private ObjectMapper mapper; + + public JSON() { + mapper = + JsonMapper.builder() + .serializationInclusion(JsonInclude.Include.NON_NULL) + .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) + .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING) + .enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING) + .defaultDateFormat(new RFC3339DateFormat()) + .addModule(new JavaTimeModule()) + .build(); + JsonNullableModule jnm = new JsonNullableModule(); + mapper.registerModule(jnm); + } + + /** + * Set the date format for JSON (de)serialization with Date properties. + * + * @param dateFormat Date format + */ + public void setDateFormat(DateFormat dateFormat) { + mapper.setDateFormat(dateFormat); + } + + /** + * Get the object mapper + * + * @return object mapper + */ + public ObjectMapper getMapper() { + return mapper; + } + + /** + * Returns the target model class that should be used to deserialize the input data. The + * discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param modelClass The class that contains the discriminator mappings. + * @return the target model class. + */ + public static Class getClassForElement(JsonNode node, Class modelClass) { + ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass); + if (cdm != null) { + return cdm.getClassForElement(node, new HashSet>()); + } + return null; + } + + /** Helper class to register the discriminator mappings. */ + @jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") + private static class ClassDiscriminatorMapping { + // The model class name. + Class modelClass; + // The name of the discriminator property. + String discriminatorName; + // The discriminator mappings for a model class. + Map> discriminatorMappings; + + // Constructs a new class discriminator. + ClassDiscriminatorMapping(Class cls, String propertyName, Map> mappings) { + modelClass = cls; + discriminatorName = propertyName; + discriminatorMappings = new HashMap>(); + if (mappings != null) { + discriminatorMappings.putAll(mappings); + } + } + + // Return the name of the discriminator property for this model class. + String getDiscriminatorPropertyName() { + return discriminatorName; + } + + // Return the discriminator value or null if the discriminator is not + // present in the payload. + String getDiscriminatorValue(JsonNode node) { + // Determine the value of the discriminator property in the input data. + if (discriminatorName != null) { + // Get the value of the discriminator property, if present in the input payload. + node = node.get(discriminatorName); + if (node != null && node.isValueNode()) { + String discrValue = node.asText(); + if (discrValue != null) { + return discrValue; + } + } + } + return null; + } + + /** + * Returns the target model class that should be used to deserialize the input data. This + * function can be invoked for anyOf/oneOf composed models with discriminator mappings. The + * discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param visitedClasses The set of classes that have already been visited. + * @return the target model class. + */ + Class getClassForElement(JsonNode node, Set> visitedClasses) { + if (visitedClasses.contains(modelClass)) { + // Class has already been visited. + return null; + } + // Determine the value of the discriminator property in the input data. + String discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + return null; + } + Class cls = discriminatorMappings.get(discrValue); + // It may not be sufficient to return this cls directly because that target class + // may itself be a composed schema, possibly with its own discriminator. + visitedClasses.add(modelClass); + for (Class childClass : discriminatorMappings.values()) { + ClassDiscriminatorMapping childCdm = modelDiscriminators.get(childClass); + if (childCdm == null) { + continue; + } + if (!discriminatorName.equals(childCdm.discriminatorName)) { + discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + continue; + } + } + if (childCdm != null) { + // Recursively traverse the discriminator mappings. + Class childDiscr = childCdm.getClassForElement(node, visitedClasses); + if (childDiscr != null) { + return childDiscr; + } + } + } + return cls; + } + } + + /** + * Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy. + * + *

The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy, so + * it's not possible to use the instanceof keyword. + * + * @param modelClass A OpenAPI model class. + * @param inst The instance object. + * @param visitedClasses The set of classes that have already been visited. + * @return true if inst is an instance of modelClass in the OpenAPI model hierarchy. + */ + public static boolean isInstanceOf( + Class modelClass, Object inst, Set> visitedClasses) { + if (modelClass.isInstance(inst)) { + // This handles the 'allOf' use case with single parent inheritance. + return true; + } + if (visitedClasses.contains(modelClass)) { + // This is to prevent infinite recursion when the composed schemas have + // a circular dependency. + return false; + } + visitedClasses.add(modelClass); + + // Traverse the oneOf/anyOf composed schemas. + Map> descendants = modelDescendants.get(modelClass); + if (descendants != null) { + for (Class childType : descendants.values()) { + if (isInstanceOf(childType, inst, visitedClasses)) { + return true; + } + } + } + return false; + } + + /** A map of discriminators for all model classes. */ + private static Map, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<>(); + + /** A map of oneOf/anyOf descendants for each model class. */ + private static Map, Map>> modelDescendants = new HashMap<>(); + + /** + * Register a model class discriminator. + * + * @param modelClass the model class + * @param discriminatorPropertyName the name of the discriminator property + * @param mappings a map with the discriminator mappings. + */ + public static void registerDiscriminator( + Class modelClass, String discriminatorPropertyName, Map> mappings) { + ClassDiscriminatorMapping m = + new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings); + modelDiscriminators.put(modelClass, m); + } + + /** + * Register the oneOf/anyOf descendants of the modelClass. + * + * @param modelClass the model class + * @param descendants a map of oneOf/anyOf descendants. + */ + public static void registerDescendants(Class modelClass, Map> descendants) { + modelDescendants.put(modelClass, descendants); + } + + private static JSON json; + + static { + json = new JSON(); + } + + /** + * Get the default JSON instance. + * + * @return the default JSON instance + */ + public static JSON getDefault() { + return json; + } + + /** + * Set the default JSON instance. + * + * @param json JSON instance to be used + */ + public static void setDefault(JSON json) { + JSON.json = json; + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Pair.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Pair.java new file mode 100644 index 000000000..701934be0 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Pair.java @@ -0,0 +1,59 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.invoker; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class Pair { + private String name = ""; + private String value = ""; + + public Pair(String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) { + return; + } + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) { + return; + } + + this.value = value; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } + + return true; + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/RFC3339DateFormat.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/RFC3339DateFormat.java new file mode 100644 index 000000000..41788aca2 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/RFC3339DateFormat.java @@ -0,0 +1,59 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.invoker; + +import com.fasterxml.jackson.databind.util.StdDateFormat; +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class RFC3339DateFormat extends DateFormat { + private static final long serialVersionUID = 1L; + private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); + + private final StdDateFormat fmt = + new StdDateFormat().withTimeZone(TIMEZONE_Z).withColonInTimeZone(true); + + public RFC3339DateFormat() { + this.calendar = new GregorianCalendar(); + this.numberFormat = new DecimalFormat(); + } + + @Override + public Date parse(String source) { + return parse(source, new ParsePosition(0)); + } + + @Override + public Date parse(String source, ParsePosition pos) { + return fmt.parse(source, pos); + } + + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return fmt.format(date, toAppendTo, fieldPosition); + } + + @Override + public Object clone() { + return super.clone(); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerConfiguration.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerConfiguration.java new file mode 100644 index 000000000..69fc82809 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerConfiguration.java @@ -0,0 +1,63 @@ +package school.hei.haapi.service.documenso.gen.invoker; + +import java.util.Map; + +/** Representing a Server configuration. */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class ServerConfiguration { + public String URL; + public String description; + public Map variables; + + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for + * substitution in the server's URL template. + */ + public ServerConfiguration( + String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } + + /** + * Format URL template using given variables. + * + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; + + // go through variables and replace placeholders + for (Map.Entry variable : this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; + + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { + throw new IllegalArgumentException( + "The variable " + name + " in the server URL has invalid value " + value + "."); + } + } + url = url.replace("{" + name + "}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerVariable.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerVariable.java new file mode 100644 index 000000000..9534a33b1 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerVariable.java @@ -0,0 +1,26 @@ +package school.hei.haapi.service.documenso.gen.invoker; + +import java.util.HashSet; + +/** Representing a Server Variable for server URL template substitution. */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class ServerVariable { + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are + * from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/AbstractOpenApiSchema.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/AbstractOpenApiSchema.java new file mode 100644 index 000000000..cfa140874 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/AbstractOpenApiSchema.java @@ -0,0 +1,146 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.model; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Map; +import java.util.Objects; + +/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + @JsonValue + public Object getActualInstance() { + return instance; + } + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) { + this.instance = instance; + } + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf + * schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema) object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) + && Objects.equals(this.isNullable, a.isNullable) + && Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/DocumentGet200Response.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/DocumentGet200Response.java new file mode 100644 index 000000000..029e3acad --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/DocumentGet200Response.java @@ -0,0 +1,346 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.Serializable; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; + +/** DocumentGet200Response */ +@JsonPropertyOrder({ + DocumentGet200Response.JSON_PROPERTY_ID, + DocumentGet200Response.JSON_PROPERTY_STATUS, + DocumentGet200Response.JSON_PROPERTY_TITLE, + DocumentGet200Response.JSON_PROPERTY_CREATED_AT, + DocumentGet200Response.JSON_PROPERTY_COMPLETED_AT +}) +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class DocumentGet200Response implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_ID = "id"; + private BigDecimal id; + + /** Gets or Sets status */ + public enum StatusEnum { + DRAFT("DRAFT"), + + PENDING("PENDING"), + + COMPLETED("COMPLETED"), + + REJECTED("REJECTED"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + private StatusEnum status; + + public static final String JSON_PROPERTY_TITLE = "title"; + private String title; + + public static final String JSON_PROPERTY_CREATED_AT = "createdAt"; + private String createdAt; + + public static final String JSON_PROPERTY_COMPLETED_AT = "completedAt"; + private String completedAt; + + public DocumentGet200Response() {} + + public DocumentGet200Response id(BigDecimal id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public BigDecimal getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setId(BigDecimal id) { + this.id = id; + } + + public DocumentGet200Response status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Get status + * + * @return status + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public StatusEnum getStatus() { + return status; + } + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setStatus(StatusEnum status) { + this.status = status; + } + + public DocumentGet200Response title(String title) { + this.title = title; + return this; + } + + /** + * Get title + * + * @return title + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTitle() { + return title; + } + + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTitle(String title) { + this.title = title; + } + + public DocumentGet200Response createdAt(String createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * + * @return createdAt + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCreatedAt() { + return createdAt; + } + + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCreatedAt(String createdAt) { + this.createdAt = createdAt; + } + + public DocumentGet200Response completedAt(String completedAt) { + this.completedAt = completedAt; + return this; + } + + /** + * Get completedAt + * + * @return completedAt + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_COMPLETED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCompletedAt() { + return completedAt; + } + + @JsonProperty(JSON_PROPERTY_COMPLETED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCompletedAt(String completedAt) { + this.completedAt = completedAt; + } + + /** Return true if this document_get_200_response object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DocumentGet200Response documentGet200Response = (DocumentGet200Response) o; + return Objects.equals(this.id, documentGet200Response.id) + && Objects.equals(this.status, documentGet200Response.status) + && Objects.equals(this.title, documentGet200Response.title) + && Objects.equals(this.createdAt, documentGet200Response.createdAt) + && Objects.equals(this.completedAt, documentGet200Response.completedAt); + } + + @Override + public int hashCode() { + return Objects.hash(id, status, title, createdAt, completedAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DocumentGet200Response {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" completedAt: ").append(toIndentedString(completedAt)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add( + String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `status` to the URL query string + if (getStatus() != null) { + joiner.add( + String.format( + "%sstatus%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getStatus()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `title` to the URL query string + if (getTitle() != null) { + joiner.add( + String.format( + "%stitle%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `createdAt` to the URL query string + if (getCreatedAt() != null) { + joiner.add( + String.format( + "%screatedAt%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getCreatedAt()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `completedAt` to the URL query string + if (getCompletedAt() != null) { + joiner.add( + String.format( + "%scompletedAt%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getCompletedAt()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200Response.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200Response.java new file mode 100644 index 000000000..4b3f9d81f --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200Response.java @@ -0,0 +1,370 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.Serializable; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; + +/** TemplateCreateDocumentFromTemplate200Response */ +@JsonPropertyOrder({ + TemplateCreateDocumentFromTemplate200Response.JSON_PROPERTY_ID, + TemplateCreateDocumentFromTemplate200Response.JSON_PROPERTY_STATUS, + TemplateCreateDocumentFromTemplate200Response.JSON_PROPERTY_TITLE, + TemplateCreateDocumentFromTemplate200Response.JSON_PROPERTY_CREATED_AT, + TemplateCreateDocumentFromTemplate200Response.JSON_PROPERTY_RECIPIENTS +}) +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class TemplateCreateDocumentFromTemplate200Response implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_ID = "id"; + private BigDecimal id; + + /** Gets or Sets status */ + public enum StatusEnum { + DRAFT("DRAFT"), + + PENDING("PENDING"), + + COMPLETED("COMPLETED"), + + REJECTED("REJECTED"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + private StatusEnum status; + + public static final String JSON_PROPERTY_TITLE = "title"; + private String title; + + public static final String JSON_PROPERTY_CREATED_AT = "createdAt"; + private String createdAt; + + public static final String JSON_PROPERTY_RECIPIENTS = "recipients"; + private List recipients = + new ArrayList<>(); + + public TemplateCreateDocumentFromTemplate200Response() {} + + public TemplateCreateDocumentFromTemplate200Response id(BigDecimal id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public BigDecimal getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setId(BigDecimal id) { + this.id = id; + } + + public TemplateCreateDocumentFromTemplate200Response status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Get status + * + * @return status + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public StatusEnum getStatus() { + return status; + } + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setStatus(StatusEnum status) { + this.status = status; + } + + public TemplateCreateDocumentFromTemplate200Response title(String title) { + this.title = title; + return this; + } + + /** + * Get title + * + * @return title + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTitle() { + return title; + } + + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTitle(String title) { + this.title = title; + } + + public TemplateCreateDocumentFromTemplate200Response createdAt(String createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * + * @return createdAt + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCreatedAt() { + return createdAt; + } + + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCreatedAt(String createdAt) { + this.createdAt = createdAt; + } + + public TemplateCreateDocumentFromTemplate200Response recipients( + List recipients) { + this.recipients = recipients; + return this; + } + + public TemplateCreateDocumentFromTemplate200Response addRecipientsItem( + TemplateCreateDocumentFromTemplate200ResponseRecipientsInner recipientsItem) { + if (this.recipients == null) { + this.recipients = new ArrayList<>(); + } + this.recipients.add(recipientsItem); + return this; + } + + /** + * Get recipients + * + * @return recipients + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getRecipients() { + return recipients; + } + + @JsonProperty(JSON_PROPERTY_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setRecipients( + List recipients) { + this.recipients = recipients; + } + + /** Return true if this template_createDocumentFromTemplate_200_response object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateCreateDocumentFromTemplate200Response templateCreateDocumentFromTemplate200Response = + (TemplateCreateDocumentFromTemplate200Response) o; + return Objects.equals(this.id, templateCreateDocumentFromTemplate200Response.id) + && Objects.equals(this.status, templateCreateDocumentFromTemplate200Response.status) + && Objects.equals(this.title, templateCreateDocumentFromTemplate200Response.title) + && Objects.equals(this.createdAt, templateCreateDocumentFromTemplate200Response.createdAt) + && Objects.equals( + this.recipients, templateCreateDocumentFromTemplate200Response.recipients); + } + + @Override + public int hashCode() { + return Objects.hash(id, status, title, createdAt, recipients); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateCreateDocumentFromTemplate200Response {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" recipients: ").append(toIndentedString(recipients)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add( + String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `status` to the URL query string + if (getStatus() != null) { + joiner.add( + String.format( + "%sstatus%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getStatus()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `title` to the URL query string + if (getTitle() != null) { + joiner.add( + String.format( + "%stitle%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `createdAt` to the URL query string + if (getCreatedAt() != null) { + joiner.add( + String.format( + "%screatedAt%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getCreatedAt()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `recipients` to the URL query string + if (getRecipients() != null) { + for (int i = 0; i < getRecipients().size(); i++) { + if (getRecipients().get(i) != null) { + joiner.add( + getRecipients() + .get(i) + .toUrlQueryString( + String.format( + "%srecipients%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.java new file mode 100644 index 000000000..fa1e5dbe1 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.java @@ -0,0 +1,357 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.Serializable; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; + +/** TemplateCreateDocumentFromTemplate200ResponseRecipientsInner */ +@JsonPropertyOrder({ + TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.JSON_PROPERTY_ID, + TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.JSON_PROPERTY_EMAIL, + TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.JSON_PROPERTY_NAME, + TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.JSON_PROPERTY_ROLE, + TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.JSON_PROPERTY_TOKEN +}) +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class TemplateCreateDocumentFromTemplate200ResponseRecipientsInner implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_ID = "id"; + private BigDecimal id; + + public static final String JSON_PROPERTY_EMAIL = "email"; + private String email; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + /** Gets or Sets role */ + public enum RoleEnum { + CC("CC"), + + SIGNER("SIGNER"), + + VIEWER("VIEWER"), + + APPROVER("APPROVER"), + + ASSISTANT("ASSISTANT"); + + private String value; + + RoleEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static RoleEnum fromValue(String value) { + for (RoleEnum b : RoleEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_ROLE = "role"; + private RoleEnum role; + + public static final String JSON_PROPERTY_TOKEN = "token"; + private String token; + + public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner() {} + + public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner id(BigDecimal id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public BigDecimal getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(BigDecimal id) { + this.id = id; + } + + public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner email(String email) { + this.email = email; + return this; + } + + /** + * Get email + * + * @return email + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEmail() { + return email; + } + + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEmail(String email) { + this.email = email; + } + + public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + } + + public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner role(RoleEnum role) { + this.role = role; + return this; + } + + /** + * Get role + * + * @return role + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ROLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RoleEnum getRole() { + return role; + } + + @JsonProperty(JSON_PROPERTY_ROLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRole(RoleEnum role) { + this.role = role; + } + + public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner token(String token) { + this.token = token; + return this; + } + + /** + * Get token + * + * @return token + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getToken() { + return token; + } + + @JsonProperty(JSON_PROPERTY_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setToken(String token) { + this.token = token; + } + + /** + * Return true if this template_createDocumentFromTemplate_200_response_recipients_inner object is + * equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateCreateDocumentFromTemplate200ResponseRecipientsInner + templateCreateDocumentFromTemplate200ResponseRecipientsInner = + (TemplateCreateDocumentFromTemplate200ResponseRecipientsInner) o; + return Objects.equals(this.id, templateCreateDocumentFromTemplate200ResponseRecipientsInner.id) + && Objects.equals( + this.email, templateCreateDocumentFromTemplate200ResponseRecipientsInner.email) + && Objects.equals( + this.name, templateCreateDocumentFromTemplate200ResponseRecipientsInner.name) + && Objects.equals( + this.role, templateCreateDocumentFromTemplate200ResponseRecipientsInner.role) + && Objects.equals( + this.token, templateCreateDocumentFromTemplate200ResponseRecipientsInner.token); + } + + @Override + public int hashCode() { + return Objects.hash(id, email, name, role, token); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateCreateDocumentFromTemplate200ResponseRecipientsInner {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" token: ").append(toIndentedString(token)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add( + String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `email` to the URL query string + if (getEmail() != null) { + joiner.add( + String.format( + "%semail%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getEmail()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add( + String.format( + "%sname%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getName()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `role` to the URL query string + if (getRole() != null) { + joiner.add( + String.format( + "%srole%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getRole()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `token` to the URL query string + if (getToken() != null) { + joiner.add( + String.format( + "%stoken%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getToken()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequest.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequest.java new file mode 100644 index 000000000..5432a1bb5 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequest.java @@ -0,0 +1,271 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.io.Serializable; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; + +/** TemplateCreateDocumentFromTemplateRequest */ +@JsonPropertyOrder({ + TemplateCreateDocumentFromTemplateRequest.JSON_PROPERTY_TEMPLATE_ID, + TemplateCreateDocumentFromTemplateRequest.JSON_PROPERTY_RECIPIENTS, + TemplateCreateDocumentFromTemplateRequest.JSON_PROPERTY_PREFILL_FIELDS +}) +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class TemplateCreateDocumentFromTemplateRequest implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_TEMPLATE_ID = "templateId"; + private BigDecimal templateId; + + public static final String JSON_PROPERTY_RECIPIENTS = "recipients"; + private List recipients = + new ArrayList<>(); + + public static final String JSON_PROPERTY_PREFILL_FIELDS = "prefillFields"; + private List prefillFields = + new ArrayList<>(); + + public TemplateCreateDocumentFromTemplateRequest() {} + + public TemplateCreateDocumentFromTemplateRequest templateId(BigDecimal templateId) { + this.templateId = templateId; + return this; + } + + /** + * Get templateId + * + * @return templateId + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TEMPLATE_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public BigDecimal getTemplateId() { + return templateId; + } + + @JsonProperty(JSON_PROPERTY_TEMPLATE_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTemplateId(BigDecimal templateId) { + this.templateId = templateId; + } + + public TemplateCreateDocumentFromTemplateRequest recipients( + List recipients) { + this.recipients = recipients; + return this; + } + + public TemplateCreateDocumentFromTemplateRequest addRecipientsItem( + TemplateCreateDocumentFromTemplateRequestRecipientsInner recipientsItem) { + if (this.recipients == null) { + this.recipients = new ArrayList<>(); + } + this.recipients.add(recipientsItem); + return this; + } + + /** + * Get recipients + * + * @return recipients + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getRecipients() { + return recipients; + } + + @JsonProperty(JSON_PROPERTY_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setRecipients( + List recipients) { + this.recipients = recipients; + } + + public TemplateCreateDocumentFromTemplateRequest prefillFields( + List prefillFields) { + this.prefillFields = prefillFields; + return this; + } + + public TemplateCreateDocumentFromTemplateRequest addPrefillFieldsItem( + TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner prefillFieldsItem) { + if (this.prefillFields == null) { + this.prefillFields = new ArrayList<>(); + } + this.prefillFields.add(prefillFieldsItem); + return this; + } + + /** + * Get prefillFields + * + * @return prefillFields + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PREFILL_FIELDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getPrefillFields() { + return prefillFields; + } + + @JsonProperty(JSON_PROPERTY_PREFILL_FIELDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPrefillFields( + List prefillFields) { + this.prefillFields = prefillFields; + } + + /** Return true if this template_createDocumentFromTemplate_request object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest = + (TemplateCreateDocumentFromTemplateRequest) o; + return Objects.equals(this.templateId, templateCreateDocumentFromTemplateRequest.templateId) + && Objects.equals(this.recipients, templateCreateDocumentFromTemplateRequest.recipients) + && Objects.equals( + this.prefillFields, templateCreateDocumentFromTemplateRequest.prefillFields); + } + + @Override + public int hashCode() { + return Objects.hash(templateId, recipients, prefillFields); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateCreateDocumentFromTemplateRequest {\n"); + sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n"); + sb.append(" recipients: ").append(toIndentedString(recipients)).append("\n"); + sb.append(" prefillFields: ").append(toIndentedString(prefillFields)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `templateId` to the URL query string + if (getTemplateId() != null) { + joiner.add( + String.format( + "%stemplateId%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getTemplateId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `recipients` to the URL query string + if (getRecipients() != null) { + for (int i = 0; i < getRecipients().size(); i++) { + if (getRecipients().get(i) != null) { + joiner.add( + getRecipients() + .get(i) + .toUrlQueryString( + String.format( + "%srecipients%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `prefillFields` to the URL query string + if (getPrefillFields() != null) { + for (int i = 0; i < getPrefillFields().size(); i++) { + if (getPrefillFields().get(i) != null) { + joiner.add( + getPrefillFields() + .get(i) + .toUrlQueryString( + String.format( + "%sprefillFields%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.java new file mode 100644 index 000000000..370d3c169 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.java @@ -0,0 +1,267 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.Serializable; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; + +/** TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner */ +@JsonPropertyOrder({ + TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.JSON_PROPERTY_ID, + TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.JSON_PROPERTY_TYPE, + TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.JSON_PROPERTY_VALUE +}) +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_ID = "id"; + private BigDecimal id; + + /** Gets or Sets type */ + public enum TypeEnum { + TEXT("text"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private TypeEnum type; + + public static final String JSON_PROPERTY_VALUE = "value"; + private String value; + + public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner() {} + + public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner id(BigDecimal id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public BigDecimal getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setId(BigDecimal id) { + this.id = id; + } + + public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public TypeEnum getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setType(TypeEnum type) { + this.type = type; + } + + public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner value(String value) { + this.value = value; + return this; + } + + /** + * Get value + * + * @return value + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getValue() { + return value; + } + + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setValue(String value) { + this.value = value; + } + + /** + * Return true if this template_createDocumentFromTemplate_request_prefillFields_inner object is + * equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner + templateCreateDocumentFromTemplateRequestPrefillFieldsInner = + (TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner) o; + return Objects.equals(this.id, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.id) + && Objects.equals( + this.type, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.type) + && Objects.equals( + this.value, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.value); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, value); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add( + String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `type` to the URL query string + if (getType() != null) { + joiner.add( + String.format( + "%stype%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getType()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `value` to the URL query string + if (getValue() != null) { + joiner.add( + String.format( + "%svalue%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getValue()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestRecipientsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestRecipientsInner.java new file mode 100644 index 000000000..a302f033b --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestRecipientsInner.java @@ -0,0 +1,233 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.io.Serializable; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; + +/** TemplateCreateDocumentFromTemplateRequestRecipientsInner */ +@JsonPropertyOrder({ + TemplateCreateDocumentFromTemplateRequestRecipientsInner.JSON_PROPERTY_ID, + TemplateCreateDocumentFromTemplateRequestRecipientsInner.JSON_PROPERTY_EMAIL, + TemplateCreateDocumentFromTemplateRequestRecipientsInner.JSON_PROPERTY_NAME +}) +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class TemplateCreateDocumentFromTemplateRequestRecipientsInner implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_ID = "id"; + private BigDecimal id; + + public static final String JSON_PROPERTY_EMAIL = "email"; + private String email; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public TemplateCreateDocumentFromTemplateRequestRecipientsInner() {} + + public TemplateCreateDocumentFromTemplateRequestRecipientsInner id(BigDecimal id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public BigDecimal getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setId(BigDecimal id) { + this.id = id; + } + + public TemplateCreateDocumentFromTemplateRequestRecipientsInner email(String email) { + this.email = email; + return this; + } + + /** + * Get email + * + * @return email + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getEmail() { + return email; + } + + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setEmail(String email) { + this.email = email; + } + + public TemplateCreateDocumentFromTemplateRequestRecipientsInner name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + } + + /** + * Return true if this template_createDocumentFromTemplate_request_recipients_inner object is + * equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateCreateDocumentFromTemplateRequestRecipientsInner + templateCreateDocumentFromTemplateRequestRecipientsInner = + (TemplateCreateDocumentFromTemplateRequestRecipientsInner) o; + return Objects.equals(this.id, templateCreateDocumentFromTemplateRequestRecipientsInner.id) + && Objects.equals( + this.email, templateCreateDocumentFromTemplateRequestRecipientsInner.email) + && Objects.equals(this.name, templateCreateDocumentFromTemplateRequestRecipientsInner.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, email, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateCreateDocumentFromTemplateRequestRecipientsInner {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add( + String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `email` to the URL query string + if (getEmail() != null) { + joiner.add( + String.format( + "%semail%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getEmail()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add( + String.format( + "%sname%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getName()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200Response.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200Response.java new file mode 100644 index 000000000..1d7d81903 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200Response.java @@ -0,0 +1,162 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** TemplateFindTemplates200Response */ +@JsonPropertyOrder({TemplateFindTemplates200Response.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class TemplateFindTemplates200Response implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_DATA = "data"; + private List data = new ArrayList<>(); + + public TemplateFindTemplates200Response() {} + + public TemplateFindTemplates200Response data( + List data) { + this.data = data; + return this; + } + + public TemplateFindTemplates200Response addDataItem( + TemplateFindTemplates200ResponseDataInner dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * + * @return data + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getData() { + return data; + } + + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setData(List data) { + this.data = data; + } + + /** Return true if this template_findTemplates_200_response object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateFindTemplates200Response templateFindTemplates200Response = + (TemplateFindTemplates200Response) o; + return Objects.equals(this.data, templateFindTemplates200Response.data); + } + + @Override + public int hashCode() { + return Objects.hash(data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateFindTemplates200Response {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `data` to the URL query string + if (getData() != null) { + for (int i = 0; i < getData().size(); i++) { + if (getData().get(i) != null) { + joiner.add( + getData() + .get(i) + .toUrlQueryString( + String.format( + "%sdata%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200ResponseDataInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200ResponseDataInner.java new file mode 100644 index 000000000..b836fb4ab --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200ResponseDataInner.java @@ -0,0 +1,385 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.Serializable; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; + +/** TemplateFindTemplates200ResponseDataInner */ +@JsonPropertyOrder({ + TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_ID, + TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_TITLE, + TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_TYPE, + TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_USER_ID, + TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_CREATED_AT, + TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_UPDATED_AT +}) +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class TemplateFindTemplates200ResponseDataInner implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_ID = "id"; + private BigDecimal id; + + public static final String JSON_PROPERTY_TITLE = "title"; + private String title; + + /** Gets or Sets type */ + public enum TypeEnum { + PUBLIC("PUBLIC"), + + PRIVATE("PRIVATE"), + + ORGANISATION("ORGANISATION"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private TypeEnum type; + + public static final String JSON_PROPERTY_USER_ID = "userId"; + private BigDecimal userId; + + public static final String JSON_PROPERTY_CREATED_AT = "createdAt"; + private String createdAt; + + public static final String JSON_PROPERTY_UPDATED_AT = "updatedAt"; + private String updatedAt; + + public TemplateFindTemplates200ResponseDataInner() {} + + public TemplateFindTemplates200ResponseDataInner id(BigDecimal id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public BigDecimal getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setId(BigDecimal id) { + this.id = id; + } + + public TemplateFindTemplates200ResponseDataInner title(String title) { + this.title = title; + return this; + } + + /** + * Get title + * + * @return title + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getTitle() { + return title; + } + + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTitle(String title) { + this.title = title; + } + + public TemplateFindTemplates200ResponseDataInner type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TypeEnum getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + public TemplateFindTemplates200ResponseDataInner userId(BigDecimal userId) { + this.userId = userId; + return this; + } + + /** + * Get userId + * + * @return userId + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_USER_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public BigDecimal getUserId() { + return userId; + } + + @JsonProperty(JSON_PROPERTY_USER_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setUserId(BigDecimal userId) { + this.userId = userId; + } + + public TemplateFindTemplates200ResponseDataInner createdAt(String createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * + * @return createdAt + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCreatedAt() { + return createdAt; + } + + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCreatedAt(String createdAt) { + this.createdAt = createdAt; + } + + public TemplateFindTemplates200ResponseDataInner updatedAt(String updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * Get updatedAt + * + * @return updatedAt + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_UPDATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getUpdatedAt() { + return updatedAt; + } + + @JsonProperty(JSON_PROPERTY_UPDATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUpdatedAt(String updatedAt) { + this.updatedAt = updatedAt; + } + + /** Return true if this template_findTemplates_200_response_data_inner object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateFindTemplates200ResponseDataInner templateFindTemplates200ResponseDataInner = + (TemplateFindTemplates200ResponseDataInner) o; + return Objects.equals(this.id, templateFindTemplates200ResponseDataInner.id) + && Objects.equals(this.title, templateFindTemplates200ResponseDataInner.title) + && Objects.equals(this.type, templateFindTemplates200ResponseDataInner.type) + && Objects.equals(this.userId, templateFindTemplates200ResponseDataInner.userId) + && Objects.equals(this.createdAt, templateFindTemplates200ResponseDataInner.createdAt) + && Objects.equals(this.updatedAt, templateFindTemplates200ResponseDataInner.updatedAt); + } + + @Override + public int hashCode() { + return Objects.hash(id, title, type, userId, createdAt, updatedAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateFindTemplates200ResponseDataInner {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add( + String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `title` to the URL query string + if (getTitle() != null) { + joiner.add( + String.format( + "%stitle%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `type` to the URL query string + if (getType() != null) { + joiner.add( + String.format( + "%stype%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getType()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `userId` to the URL query string + if (getUserId() != null) { + joiner.add( + String.format( + "%suserId%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getUserId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `createdAt` to the URL query string + if (getCreatedAt() != null) { + joiner.add( + String.format( + "%screatedAt%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getCreatedAt()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `updatedAt` to the URL query string + if (getUpdatedAt() != null) { + joiner.add( + String.format( + "%supdatedAt%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getUpdatedAt()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200Response.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200Response.java new file mode 100644 index 000000000..255e7e180 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200Response.java @@ -0,0 +1,346 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.io.Serializable; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; + +/** TemplateGetTemplateById200Response */ +@JsonPropertyOrder({ + TemplateGetTemplateById200Response.JSON_PROPERTY_ID, + TemplateGetTemplateById200Response.JSON_PROPERTY_TITLE, + TemplateGetTemplateById200Response.JSON_PROPERTY_USER_ID, + TemplateGetTemplateById200Response.JSON_PROPERTY_RECIPIENTS, + TemplateGetTemplateById200Response.JSON_PROPERTY_FIELDS +}) +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class TemplateGetTemplateById200Response implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_ID = "id"; + private BigDecimal id; + + public static final String JSON_PROPERTY_TITLE = "title"; + private String title; + + public static final String JSON_PROPERTY_USER_ID = "userId"; + private BigDecimal userId; + + public static final String JSON_PROPERTY_RECIPIENTS = "recipients"; + private List recipients = new ArrayList<>(); + + public static final String JSON_PROPERTY_FIELDS = "fields"; + private List fields = new ArrayList<>(); + + public TemplateGetTemplateById200Response() {} + + public TemplateGetTemplateById200Response id(BigDecimal id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public BigDecimal getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setId(BigDecimal id) { + this.id = id; + } + + public TemplateGetTemplateById200Response title(String title) { + this.title = title; + return this; + } + + /** + * Get title + * + * @return title + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getTitle() { + return title; + } + + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTitle(String title) { + this.title = title; + } + + public TemplateGetTemplateById200Response userId(BigDecimal userId) { + this.userId = userId; + return this; + } + + /** + * Get userId + * + * @return userId + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USER_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public BigDecimal getUserId() { + return userId; + } + + @JsonProperty(JSON_PROPERTY_USER_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUserId(BigDecimal userId) { + this.userId = userId; + } + + public TemplateGetTemplateById200Response recipients( + List recipients) { + this.recipients = recipients; + return this; + } + + public TemplateGetTemplateById200Response addRecipientsItem( + TemplateGetTemplateById200ResponseRecipientsInner recipientsItem) { + if (this.recipients == null) { + this.recipients = new ArrayList<>(); + } + this.recipients.add(recipientsItem); + return this; + } + + /** + * Get recipients + * + * @return recipients + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getRecipients() { + return recipients; + } + + @JsonProperty(JSON_PROPERTY_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setRecipients(List recipients) { + this.recipients = recipients; + } + + public TemplateGetTemplateById200Response fields( + List fields) { + this.fields = fields; + return this; + } + + public TemplateGetTemplateById200Response addFieldsItem( + TemplateGetTemplateById200ResponseFieldsInner fieldsItem) { + if (this.fields == null) { + this.fields = new ArrayList<>(); + } + this.fields.add(fieldsItem); + return this; + } + + /** + * Get fields + * + * @return fields + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FIELDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getFields() { + return fields; + } + + @JsonProperty(JSON_PROPERTY_FIELDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFields(List fields) { + this.fields = fields; + } + + /** Return true if this template_getTemplateById_200_response object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateGetTemplateById200Response templateGetTemplateById200Response = + (TemplateGetTemplateById200Response) o; + return Objects.equals(this.id, templateGetTemplateById200Response.id) + && Objects.equals(this.title, templateGetTemplateById200Response.title) + && Objects.equals(this.userId, templateGetTemplateById200Response.userId) + && Objects.equals(this.recipients, templateGetTemplateById200Response.recipients) + && Objects.equals(this.fields, templateGetTemplateById200Response.fields); + } + + @Override + public int hashCode() { + return Objects.hash(id, title, userId, recipients, fields); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateGetTemplateById200Response {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" recipients: ").append(toIndentedString(recipients)).append("\n"); + sb.append(" fields: ").append(toIndentedString(fields)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add( + String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `title` to the URL query string + if (getTitle() != null) { + joiner.add( + String.format( + "%stitle%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `userId` to the URL query string + if (getUserId() != null) { + joiner.add( + String.format( + "%suserId%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getUserId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `recipients` to the URL query string + if (getRecipients() != null) { + for (int i = 0; i < getRecipients().size(); i++) { + if (getRecipients().get(i) != null) { + joiner.add( + getRecipients() + .get(i) + .toUrlQueryString( + String.format( + "%srecipients%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + // add `fields` to the URL query string + if (getFields() != null) { + for (int i = 0; i < getFields().size(); i++) { + if (getFields().get(i) != null) { + joiner.add( + getFields() + .get(i) + .toUrlQueryString( + String.format( + "%sfields%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseFieldsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseFieldsInner.java new file mode 100644 index 000000000..224e39cda --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseFieldsInner.java @@ -0,0 +1,271 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.io.Serializable; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; + +/** TemplateGetTemplateById200ResponseFieldsInner */ +@JsonPropertyOrder({ + TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_ID, + TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_TYPE, + TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_LABEL, + TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_PLACEHOLDER +}) +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class TemplateGetTemplateById200ResponseFieldsInner implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_ID = "id"; + private BigDecimal id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_LABEL = "label"; + private String label; + + public static final String JSON_PROPERTY_PLACEHOLDER = "placeholder"; + private String placeholder; + + public TemplateGetTemplateById200ResponseFieldsInner() {} + + public TemplateGetTemplateById200ResponseFieldsInner id(BigDecimal id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public BigDecimal getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setId(BigDecimal id) { + this.id = id; + } + + public TemplateGetTemplateById200ResponseFieldsInner type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setType(String type) { + this.type = type; + } + + public TemplateGetTemplateById200ResponseFieldsInner label(String label) { + this.label = label; + return this; + } + + /** + * Get label + * + * @return label + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LABEL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getLabel() { + return label; + } + + @JsonProperty(JSON_PROPERTY_LABEL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLabel(String label) { + this.label = label; + } + + public TemplateGetTemplateById200ResponseFieldsInner placeholder(String placeholder) { + this.placeholder = placeholder; + return this; + } + + /** + * Get placeholder + * + * @return placeholder + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PLACEHOLDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPlaceholder() { + return placeholder; + } + + @JsonProperty(JSON_PROPERTY_PLACEHOLDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPlaceholder(String placeholder) { + this.placeholder = placeholder; + } + + /** + * Return true if this template_getTemplateById_200_response_fields_inner object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateGetTemplateById200ResponseFieldsInner templateGetTemplateById200ResponseFieldsInner = + (TemplateGetTemplateById200ResponseFieldsInner) o; + return Objects.equals(this.id, templateGetTemplateById200ResponseFieldsInner.id) + && Objects.equals(this.type, templateGetTemplateById200ResponseFieldsInner.type) + && Objects.equals(this.label, templateGetTemplateById200ResponseFieldsInner.label) + && Objects.equals( + this.placeholder, templateGetTemplateById200ResponseFieldsInner.placeholder); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, label, placeholder); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateGetTemplateById200ResponseFieldsInner {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" label: ").append(toIndentedString(label)).append("\n"); + sb.append(" placeholder: ").append(toIndentedString(placeholder)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add( + String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `type` to the URL query string + if (getType() != null) { + joiner.add( + String.format( + "%stype%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getType()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `label` to the URL query string + if (getLabel() != null) { + joiner.add( + String.format( + "%slabel%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getLabel()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `placeholder` to the URL query string + if (getPlaceholder() != null) { + joiner.add( + String.format( + "%splaceholder%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getPlaceholder()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseRecipientsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseRecipientsInner.java new file mode 100644 index 000000000..4db905f43 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseRecipientsInner.java @@ -0,0 +1,313 @@ +/* + * Documenso v2 API (client subset) + * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package school.hei.haapi.service.documenso.gen.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.io.Serializable; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Objects; +import java.util.StringJoiner; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; + +/** TemplateGetTemplateById200ResponseRecipientsInner */ +@JsonPropertyOrder({ + TemplateGetTemplateById200ResponseRecipientsInner.JSON_PROPERTY_ID, + TemplateGetTemplateById200ResponseRecipientsInner.JSON_PROPERTY_ROLE, + TemplateGetTemplateById200ResponseRecipientsInner.JSON_PROPERTY_EMAIL, + TemplateGetTemplateById200ResponseRecipientsInner.JSON_PROPERTY_NAME +}) +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class TemplateGetTemplateById200ResponseRecipientsInner implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_ID = "id"; + private BigDecimal id; + + /** Gets or Sets role */ + public enum RoleEnum { + CC("CC"), + + SIGNER("SIGNER"), + + VIEWER("VIEWER"), + + APPROVER("APPROVER"), + + ASSISTANT("ASSISTANT"); + + private String value; + + RoleEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static RoleEnum fromValue(String value) { + for (RoleEnum b : RoleEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_ROLE = "role"; + private RoleEnum role; + + public static final String JSON_PROPERTY_EMAIL = "email"; + private String email; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public TemplateGetTemplateById200ResponseRecipientsInner() {} + + public TemplateGetTemplateById200ResponseRecipientsInner id(BigDecimal id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public BigDecimal getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setId(BigDecimal id) { + this.id = id; + } + + public TemplateGetTemplateById200ResponseRecipientsInner role(RoleEnum role) { + this.role = role; + return this; + } + + /** + * Get role + * + * @return role + */ + @jakarta.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_ROLE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public RoleEnum getRole() { + return role; + } + + @JsonProperty(JSON_PROPERTY_ROLE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setRole(RoleEnum role) { + this.role = role; + } + + public TemplateGetTemplateById200ResponseRecipientsInner email(String email) { + this.email = email; + return this; + } + + /** + * Get email + * + * @return email + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEmail() { + return email; + } + + @JsonProperty(JSON_PROPERTY_EMAIL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEmail(String email) { + this.email = email; + } + + public TemplateGetTemplateById200ResponseRecipientsInner name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + } + + /** + * Return true if this template_getTemplateById_200_response_recipients_inner object is equal to + * o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateGetTemplateById200ResponseRecipientsInner + templateGetTemplateById200ResponseRecipientsInner = + (TemplateGetTemplateById200ResponseRecipientsInner) o; + return Objects.equals(this.id, templateGetTemplateById200ResponseRecipientsInner.id) + && Objects.equals(this.role, templateGetTemplateById200ResponseRecipientsInner.role) + && Objects.equals(this.email, templateGetTemplateById200ResponseRecipientsInner.email) + && Objects.equals(this.name, templateGetTemplateById200ResponseRecipientsInner.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, role, email, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateGetTemplateById200ResponseRecipientsInner {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add( + String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `role` to the URL query string + if (getRole() != null) { + joiner.add( + String.format( + "%srole%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getRole()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `email` to the URL query string + if (getEmail() != null) { + joiner.add( + String.format( + "%semail%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getEmail()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add( + String.format( + "%sname%s=%s", + prefix, + suffix, + URLEncoder.encode(ApiClient.valueToString(getName()), StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} diff --git a/src/main/resources/db/migration/V45_130__Add_documenso_user_id_to_user_table.sql b/src/main/resources/db/migration/V45_130__Add_documenso_user_id_to_user_table.sql new file mode 100644 index 000000000..ca9cf6e00 --- /dev/null +++ b/src/main/resources/db/migration/V45_130__Add_documenso_user_id_to_user_table.sql @@ -0,0 +1,2 @@ +ALTER TABLE "user" + ADD COLUMN documenso_user_id BIGINT; diff --git a/src/main/resources/db/migration/V45_131__Create_documenso_template_table.sql b/src/main/resources/db/migration/V45_131__Create_documenso_template_table.sql new file mode 100644 index 000000000..035dc81c1 --- /dev/null +++ b/src/main/resources/db/migration/V45_131__Create_documenso_template_table.sql @@ -0,0 +1,10 @@ +CREATE TABLE documenso_template +( + id VARCHAR + CONSTRAINT pk_documenso_template PRIMARY KEY DEFAULT uuid_generate_v4(), + documenso_template_id BIGINT NOT NULL UNIQUE, + title VARCHAR NOT NULL, + type VARCHAR, + admin_id VARCHAR REFERENCES "user" (id), + creation_datetime TIMESTAMP WITH TIME ZONE DEFAULT now() +); diff --git a/src/main/resources/db/migration/V45_132__Create_documenso_document_table.sql b/src/main/resources/db/migration/V45_132__Create_documenso_document_table.sql new file mode 100644 index 000000000..0383cb027 --- /dev/null +++ b/src/main/resources/db/migration/V45_132__Create_documenso_document_table.sql @@ -0,0 +1,22 @@ +DO +$$ + BEGIN + IF NOT EXISTS(SELECT FROM pg_type WHERE typname = 'documenso_document_status') THEN + CREATE TYPE "documenso_document_status" AS ENUM ('PENDING', 'COMPLETED', 'REJECTED'); + END IF; + END +$$; + +CREATE TABLE documenso_document +( + id VARCHAR + CONSTRAINT pk_documenso_document PRIMARY KEY DEFAULT uuid_generate_v4(), + documenso_document_id BIGINT NOT NULL UNIQUE, + documenso_template_id VARCHAR REFERENCES documenso_template (id) NOT NULL, + promotion_id VARCHAR REFERENCES "promotion" (id) NOT NULL, + level VARCHAR NOT NULL, + status documenso_document_status NOT NULL DEFAULT 'PENDING', + file_info_id VARCHAR REFERENCES "file_info" (id), + creation_datetime TIMESTAMP WITH TIME ZONE DEFAULT now(), + completed_datetime TIMESTAMP WITH TIME ZONE +); diff --git a/src/main/resources/db/migration/V45_133__Create_documenso_document_recipient_table.sql b/src/main/resources/db/migration/V45_133__Create_documenso_document_recipient_table.sql new file mode 100644 index 000000000..01ce0be70 --- /dev/null +++ b/src/main/resources/db/migration/V45_133__Create_documenso_document_recipient_table.sql @@ -0,0 +1,11 @@ +CREATE TABLE documenso_document_recipient +( + id VARCHAR + CONSTRAINT pk_documenso_document_recipient PRIMARY KEY DEFAULT uuid_generate_v4(), + documenso_document_id VARCHAR REFERENCES documenso_document (id) NOT NULL, + user_id VARCHAR REFERENCES "user" (id) NOT NULL, + documenso_recipient_id BIGINT NOT NULL, + signing_token VARCHAR NOT NULL, + signed_datetime TIMESTAMP WITH TIME ZONE, + UNIQUE (documenso_document_id, user_id) +); diff --git a/src/test/java/school/hei/haapi/integration/DocumensoIT.java b/src/test/java/school/hei/haapi/integration/DocumensoIT.java new file mode 100644 index 000000000..b3691a6fa --- /dev/null +++ b/src/test/java/school/hei/haapi/integration/DocumensoIT.java @@ -0,0 +1,258 @@ +package school.hei.haapi.integration; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static school.hei.haapi.integration.conf.TestUtils.ADMIN1_TOKEN; +import static school.hei.haapi.integration.conf.TestUtils.MONITOR1_TOKEN; +import static school.hei.haapi.integration.conf.TestUtils.STUDENT1_TOKEN; +import static school.hei.haapi.integration.conf.TestUtils.assertThrowsForbiddenException; +import static school.hei.haapi.integration.conf.TestUtils.setUpCasdoor; +import static school.hei.haapi.integration.conf.TestUtils.setUpCognito; + +import java.io.File; +import java.math.BigDecimal; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Instant; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import school.hei.haapi.endpoint.rest.api.DocumensoApi; +import school.hei.haapi.endpoint.rest.client.ApiClient; +import school.hei.haapi.endpoint.rest.model.CrupdateDocumensoDocument; +import school.hei.haapi.endpoint.rest.model.DocumensoDocumentStatus; +import school.hei.haapi.endpoint.rest.model.StudentLevel; +import school.hei.haapi.file.bucket.BucketComponent; +import school.hei.haapi.file.hash.FileHash; +import school.hei.haapi.file.hash.FileHashAlgorithm; +import school.hei.haapi.integration.conf.FacadeITMockedThirdParties; +import school.hei.haapi.integration.conf.TestUtils; +import school.hei.haapi.model.CycleLevel; +import school.hei.haapi.model.DocumensoDocument; +import school.hei.haapi.model.Promotion; +import school.hei.haapi.model.User; +import school.hei.haapi.repository.DocumensoDocumentRecipientRepository; +import school.hei.haapi.repository.DocumensoDocumentRepository; +import school.hei.haapi.repository.PromotionRepository; +import school.hei.haapi.repository.TemplateDocumensoRepository; +import school.hei.haapi.repository.UserRepository; +import school.hei.haapi.service.documenso.DocumensoClient; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplate200Response; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplate200ResponseRecipientsInner; +import school.hei.haapi.service.documenso.gen.model.TemplateFindTemplates200Response; +import school.hei.haapi.service.documenso.gen.model.TemplateFindTemplates200ResponseDataInner; +import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200Response; +import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200ResponseRecipientsInner; + +class DocumensoIT extends FacadeITMockedThirdParties { + @Autowired private UserRepository userRepository; + @Autowired private PromotionRepository promotionRepository; + @Autowired private TemplateDocumensoRepository templateDocumensoRepository; + @Autowired private DocumensoDocumentRepository documensoDocumentRepository; + @Autowired private DocumensoDocumentRecipientRepository documensoDocumentRecipientRepository; + @MockBean private DocumensoClient documensoClientMock; + @MockBean private BucketComponent bucketComponentMock; + + private User admin; + private User monitor; + private Promotion promotion; + private school.hei.haapi.model.TemplateDocumenso template; + private long templateExternalId; + + @BeforeEach + void setUp() { + setUpCasdoor(casdoorAuthServiceMock, certificateLoaderMock); + setUpCognito(cognitoComponentMock); + + // admin1_id / test+admin@hei.school and monitor1_id / test+monitor@hei.school are seeded by + // src/test/resources/db/testdata (V99_2, V99_29) and shared across the whole test run, so we + // fetch them rather than inserting new rows with the same email (unique constraint). + admin = userRepository.findById("admin1_id").orElseThrow(); + admin.setDocumensoUserId(111L); + admin = userRepository.save(admin); + + monitor = userRepository.findById("monitor1_id").orElseThrow(); + + promotion = + promotionRepository.save( + Promotion.builder() + .name("Promo Test") + .ref("PROMO_" + UUID.randomUUID()) + .startDatetime(Instant.parse("2023-11-01T00:00:00Z")) + .cycleLevel(CycleLevel.BACHELOR) + .build()); + + templateExternalId = ThreadLocalRandom.current().nextLong(1_000, 1_000_000_000); + template = + templateDocumensoRepository.save( + school.hei.haapi.model.TemplateDocumenso.builder() + .documensoTemplateId(templateExternalId) + .title("Attestation") + .type("PRIVATE") + .build()); + } + + private DocumensoApi anApi(String token) { + return new DocumensoApi(anApiClient(token)); + } + + private ApiClient anApiClient(String token) { + return TestUtils.anApiClient(token, localPort); + } + + @Test + void admin_sync_templates_resolves_admin_by_documenso_user_id() throws Exception { + when(documensoClientMock.findTemplates(isNull(), eq(1), eq(100))) + .thenReturn( + new TemplateFindTemplates200Response() + .addDataItem( + new TemplateFindTemplates200ResponseDataInner() + .id(BigDecimal.valueOf(777)) + .title("Certificat") + .type(TemplateFindTemplates200ResponseDataInner.TypeEnum.PRIVATE) + .userId(BigDecimal.valueOf(111)))); + + var result = anApi(ADMIN1_TOKEN).syncDocumensoTemplates(); + + assertEquals(1, result.size()); + var synced = result.get(0); + assertEquals(777L, synced.getDocumensoTemplateId()); + assertEquals("Certificat", synced.getTitle()); + assertEquals(admin.getId(), synced.getAdminId()); + + var saved = templateDocumensoRepository.findByDocumensoTemplateId(777L); + assertTrue(saved.isPresent()); + assertEquals(admin.getId(), saved.get().getAdmin().getId()); + } + + @Test + void student_sync_templates_ko() { + assertThrowsForbiddenException(() -> anApi(STUDENT1_TOKEN).syncDocumensoTemplates()); + } + + @Test + void admin_generate_document_persists_pending_document_with_recipient_tokens() throws Exception { + when(documensoClientMock.getTemplate(templateExternalId)) + .thenReturn( + new TemplateGetTemplateById200Response() + .id(BigDecimal.valueOf(555)) + .title("Attestation") + .addRecipientsItem( + new TemplateGetTemplateById200ResponseRecipientsInner() + .id(BigDecimal.valueOf(1)) + .role(TemplateGetTemplateById200ResponseRecipientsInner.RoleEnum.SIGNER)) + .addRecipientsItem( + new TemplateGetTemplateById200ResponseRecipientsInner() + .id(BigDecimal.valueOf(2)) + .role(TemplateGetTemplateById200ResponseRecipientsInner.RoleEnum.SIGNER))); + when(documensoClientMock.useTemplate(any())) + .thenReturn( + new TemplateCreateDocumentFromTemplate200Response() + .id(BigDecimal.valueOf(999)) + .status(TemplateCreateDocumentFromTemplate200Response.StatusEnum.PENDING) + .title("Attestation") + .addRecipientsItem( + new TemplateCreateDocumentFromTemplate200ResponseRecipientsInner() + .id(BigDecimal.valueOf(1)) + .email(admin.getEmail()) + .name("Admin") + .token("admin-token")) + .addRecipientsItem( + new TemplateCreateDocumentFromTemplate200ResponseRecipientsInner() + .id(BigDecimal.valueOf(2)) + .email(monitor.getEmail()) + .name("Monitor") + .token("monitor-token"))); + + var toCreate = + new CrupdateDocumensoDocument() + .promotionId(promotion.getId()) + .level(StudentLevel.L1) + .documensoTemplateId(templateExternalId) + .adminId(admin.getId()) + .monitorId(monitor.getId()); + + var created = anApi(ADMIN1_TOKEN).generateDocumensoDocument(toCreate); + + assertEquals(DocumensoDocumentStatus.PENDING, created.getStatus()); + assertEquals(999L, created.getDocumensoDocumentId()); + assertEquals(promotion.getId(), created.getPromotionId()); + + var adminToken = anApi(ADMIN1_TOKEN).getDocumensoDocumentSigningToken(created.getId()); + assertEquals("admin-token", adminToken.getToken()); + + var monitorToken = anApi(MONITOR1_TOKEN).getDocumensoDocumentSigningToken(created.getId()); + assertEquals("monitor-token", monitorToken.getToken()); + } + + @Test + void student_generate_document_ko() { + var toCreate = + new CrupdateDocumensoDocument() + .promotionId(promotion.getId()) + .level(StudentLevel.L1) + .documensoTemplateId(templateExternalId) + .adminId(admin.getId()) + .monitorId(monitor.getId()); + + assertThrowsForbiddenException( + () -> anApi(STUDENT1_TOKEN).generateDocumensoDocument(toCreate)); + } + + @Test + void webhook_completes_document_and_uploads_signed_pdf_to_s3() throws Exception { + var pendingDocument = + documensoDocumentRepository.save( + DocumensoDocument.builder() + .documensoDocumentId(4242L) + .template(template) + .promotion(promotion) + .level(StudentLevel.L1) + .status(DocumensoDocument.Status.PENDING) + .build()); + + var signedFile = File.createTempFile("signed", ".pdf"); + when(documensoClientMock.downloadSignedDocument(4242L)).thenReturn(signedFile); + when(bucketComponentMock.upload(any(), any())) + .thenReturn(new FileHash(FileHashAlgorithm.NONE, "dummy")); + + var response = + sendWebhook("{\"event\":\"DOCUMENT_COMPLETED\",\"payload\":{\"id\":4242}}", "dummy-secret"); + + assertEquals(200, response.statusCode()); + var updated = documensoDocumentRepository.findById(pendingDocument.getId()).orElseThrow(); + assertEquals(DocumensoDocument.Status.COMPLETED, updated.getStatus()); + assertNotNull(updated.getFileInfo()); + verify(bucketComponentMock).upload(eq(signedFile), any()); + } + + @Test + void webhook_with_wrong_secret_is_rejected() throws Exception { + var response = + sendWebhook("{\"event\":\"DOCUMENT_COMPLETED\",\"payload\":{\"id\":1}}", "wrong-secret"); + + assertEquals(401, response.statusCode()); + } + + private HttpResponse sendWebhook(String jsonBody, String secret) throws Exception { + var request = + HttpRequest.newBuilder() + .uri(URI.create("http://localhost:" + localPort + "/documenso/webhook")) + .header("Content-Type", "application/json") + .header("X-Documenso-Secret", secret) + .POST(HttpRequest.BodyPublishers.ofString(jsonBody)) + .build(); + return HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); + } +} From 6db88b1473c2daca39b80c7f58f6980c47feb9fe Mon Sep 17 00:00:00 2001 From: mbomain Date: Fri, 7 Aug 2026 13:01:43 +0300 Subject: [PATCH 02/21] feat: create model documenso --- src/main/java/school/hei/haapi/model/DocumensoDocument.java | 4 ++-- .../school/hei/haapi/model/DocumensoDocumentRecipient.java | 2 -- src/main/java/school/hei/haapi/model/TemplateDocumenso.java | 4 ---- src/main/java/school/hei/haapi/model/User.java | 2 ++ 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/school/hei/haapi/model/DocumensoDocument.java b/src/main/java/school/hei/haapi/model/DocumensoDocument.java index 0a165d580..6980ca00b 100644 --- a/src/main/java/school/hei/haapi/model/DocumensoDocument.java +++ b/src/main/java/school/hei/haapi/model/DocumensoDocument.java @@ -45,8 +45,8 @@ public class DocumensoDocument implements Serializable { private TemplateDocumenso template; @ManyToOne - @JoinColumn(name = "promotion_id") - private Promotion promotion; + @JoinColumn(name = "student_id") + private User student; @Enumerated(STRING) private StudentLevel level; diff --git a/src/main/java/school/hei/haapi/model/DocumensoDocumentRecipient.java b/src/main/java/school/hei/haapi/model/DocumensoDocumentRecipient.java index 26f86cbfe..4d5acee67 100644 --- a/src/main/java/school/hei/haapi/model/DocumensoDocumentRecipient.java +++ b/src/main/java/school/hei/haapi/model/DocumensoDocumentRecipient.java @@ -41,8 +41,6 @@ public class DocumensoDocumentRecipient implements Serializable { private User user; private Long documensoRecipientId; - private String signingToken; - private Instant signedDatetime; } diff --git a/src/main/java/school/hei/haapi/model/TemplateDocumenso.java b/src/main/java/school/hei/haapi/model/TemplateDocumenso.java index 9bbe6ad40..7c72a344c 100644 --- a/src/main/java/school/hei/haapi/model/TemplateDocumenso.java +++ b/src/main/java/school/hei/haapi/model/TemplateDocumenso.java @@ -33,12 +33,8 @@ public class TemplateDocumenso implements Serializable { private String id; private Long documensoTemplateId; - private String title; - private String type; - @ManyToOne private User admin; - @CreationTimestamp private Instant creationDatetime; } diff --git a/src/main/java/school/hei/haapi/model/User.java b/src/main/java/school/hei/haapi/model/User.java index c0bff3429..cd70c0664 100644 --- a/src/main/java/school/hei/haapi/model/User.java +++ b/src/main/java/school/hei/haapi/model/User.java @@ -119,6 +119,8 @@ public class User implements Serializable { private String profilePictureKey; + private Long documensoUserId; + // RELATION (TEACHER): Course Assignment @OneToMany(fetch = FetchType.LAZY, mappedBy = "mainTeacher") @ToString.Exclude From 5946fcf9b3e2a3cf4503b2c1c318a5a6afc45f4e Mon Sep 17 00:00:00 2001 From: mbomain Date: Fri, 7 Aug 2026 13:03:41 +0300 Subject: [PATCH 03/21] feat: migration flyaway documenso --- .../db/migration/V45_132__Create_documenso_document_table.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/db/migration/V45_132__Create_documenso_document_table.sql b/src/main/resources/db/migration/V45_132__Create_documenso_document_table.sql index 0383cb027..acb086894 100644 --- a/src/main/resources/db/migration/V45_132__Create_documenso_document_table.sql +++ b/src/main/resources/db/migration/V45_132__Create_documenso_document_table.sql @@ -13,8 +13,8 @@ CREATE TABLE documenso_document CONSTRAINT pk_documenso_document PRIMARY KEY DEFAULT uuid_generate_v4(), documenso_document_id BIGINT NOT NULL UNIQUE, documenso_template_id VARCHAR REFERENCES documenso_template (id) NOT NULL, - promotion_id VARCHAR REFERENCES "promotion" (id) NOT NULL, - level VARCHAR NOT NULL, + student_id VARCHAR REFERENCES "user" (id) NOT NULL, + level VARCHAR, status documenso_document_status NOT NULL DEFAULT 'PENDING', file_info_id VARCHAR REFERENCES "file_info" (id), creation_datetime TIMESTAMP WITH TIME ZONE DEFAULT now(), From b909686d4f26704ce73160d1fbf39356eef8c8a9 Mon Sep 17 00:00:00 2001 From: mbomain Date: Fri, 7 Aug 2026 13:04:59 +0300 Subject: [PATCH 04/21] feat: implementation service documenso --- .../service/AdvancedFeeStatsService.java | 11 +- .../service/DocumensoDocumentService.java | 186 +++++++++++------- 2 files changed, 122 insertions(+), 75 deletions(-) diff --git a/src/main/java/school/hei/haapi/service/AdvancedFeeStatsService.java b/src/main/java/school/hei/haapi/service/AdvancedFeeStatsService.java index 393b492ad..d5688ece2 100644 --- a/src/main/java/school/hei/haapi/service/AdvancedFeeStatsService.java +++ b/src/main/java/school/hei/haapi/service/AdvancedFeeStatsService.java @@ -3,7 +3,6 @@ import static java.time.Instant.now; import static java.time.ZoneOffset.UTC; import static java.time.temporal.ChronoUnit.DAYS; -import static java.time.temporal.ChronoUnit.SECONDS; import static java.time.temporal.TemporalAdjusters.lastDayOfMonth; import static java.util.stream.Collectors.groupingBy; import static java.util.stream.Collectors.groupingByConcurrent; @@ -38,6 +37,8 @@ import java.time.Duration; import java.time.Instant; import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -175,11 +176,11 @@ public String generateAdvancedFeesStatsExcelFile( sheet.autoSizeColumn(i); } workbook.write(bytes); - var now = Instant.now().truncatedTo(SECONDS); + var now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss")); + var filename = "advanced-fees-stats-" + now + ".xlsx"; var file = createFileFromBytes(bytes.toByteArray(), "advanced-fees-stats-" + now, ".xlsx"); - var bucketKey = "advanced-fees-stats-" + now + ".xlsx"; - bucketComponent.upload(file, bucketKey); - return bucketComponent.presign(bucketKey, Duration.ofDays(1)).toString(); + bucketComponent.upload(file, filename); + return bucketComponent.presign(filename, Duration.ofDays(1)).toString(); } catch (IOException e) { throw new ApiException(SERVER_EXCEPTION, e); } diff --git a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java index 51d2c55bc..2ff36c39b 100644 --- a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java +++ b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java @@ -3,14 +3,15 @@ import static school.hei.haapi.model.exception.ApiException.ExceptionType.SERVER_EXCEPTION; import java.math.BigDecimal; +import java.text.Normalizer; import java.time.Instant; +import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Map; -import java.util.stream.Collectors; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import school.hei.haapi.endpoint.rest.model.FeeFrequency; import school.hei.haapi.endpoint.rest.model.FileType; import school.hei.haapi.endpoint.rest.model.StudentLevel; import school.hei.haapi.file.bucket.BucketComponent; @@ -26,74 +27,65 @@ import school.hei.haapi.repository.DocumensoDocumentRepository; import school.hei.haapi.repository.FeeRepository; import school.hei.haapi.repository.FileInfoRepository; -import school.hei.haapi.repository.PromotionRepository; +import school.hei.haapi.repository.MonitoringStudentRepository; import school.hei.haapi.repository.TemplateDocumensoRepository; import school.hei.haapi.repository.UserRepository; import school.hei.haapi.service.documenso.DocumensoClient; import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequest; import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner; import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequestRecipientsInner; +import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200ResponseFieldsInner; @Service @AllArgsConstructor public class DocumensoDocumentService { + private static final Map> + FIELD_LABEL_MATCHERS = + Map.of( + "nom et prenom", s -> s.fullName, + "inscrit", s -> s.levelLabel, + "cin", s -> s.nic, + "adresse personnelle", s -> s.address, + "telephone", s -> s.phone); + private final DocumensoClient documensoClient; private final DocumensoDocumentRepository documensoDocumentRepository; private final DocumensoDocumentRecipientRepository documensoDocumentRecipientRepository; private final TemplateDocumensoRepository templateDocumensoRepository; - private final PromotionRepository promotionRepository; private final UserRepository userRepository; + private final MonitoringStudentRepository monitoringStudentRepository; private final FeeRepository feeRepository; private final FileInfoRepository fileInfoRepository; private final BucketComponent bucketComponent; @Transactional - public DocumensoDocument generateForPromotionLevel( - String promotionId, - StudentLevel level, - long documensoTemplateId, - String adminId, - String monitorId, - Map prefillFieldValues) { - var promotion = - promotionRepository - .findById(promotionId) - .orElseThrow(() -> new NotFoundException("Promotion with id: " + promotionId)); - var admin = + public DocumensoDocument generateDocument(String studentId, String templateName) { + var student = userRepository - .findById(adminId) - .orElseThrow(() -> new NotFoundException("User with id: " + adminId)); + .findById(studentId) + .orElseThrow(() -> new NotFoundException("User with id: " + studentId)); var monitor = - userRepository - .findById(monitorId) - .orElseThrow(() -> new NotFoundException("User with id: " + monitorId)); - var template = - templateDocumensoRepository - .findByDocumensoTemplateId(documensoTemplateId) - .orElseThrow( - () -> new NotFoundException("Documenso template: " + documensoTemplateId)); + monitoringStudentRepository.findAllMonitorsByStudentId(studentId).stream() + .findFirst() + .orElseThrow(() -> new NotFoundException("No monitor linked to student " + studentId)); + var level = safeLevelAt(student); + var template = resolveTemplateByName(templateName, level); + var documensoTemplateId = template.getDocumensoTemplateId(); try { var remoteTemplate = documensoClient.getTemplate(documensoTemplateId); var placeholders = remoteTemplate.getRecipients(); - if (placeholders == null || placeholders.size() < 2) { + if (placeholders == null || placeholders.isEmpty()) { throw new ApiException( SERVER_EXCEPTION, - "Documenso template " - + documensoTemplateId - + " must define at least 2 recipient placeholders (admin + monitor)"); + "Documenso template " + documensoTemplateId + " must define a recipient placeholder"); } var request = new TemplateCreateDocumentFromTemplateRequest(); request.setTemplateId(BigDecimal.valueOf(documensoTemplateId)); - request.setRecipients( - List.of( - toRecipient(placeholders.get(0).getId(), admin), - toRecipient(placeholders.get(1).getId(), monitor))); - if (prefillFieldValues != null && !prefillFieldValues.isEmpty()) { - request.setPrefillFields( - prefillFieldValues.entrySet().stream().map(this::toPrefillField).toList()); - } + request.setRecipients(List.of(toRecipient(placeholders.get(0).getId(), monitor))); + request.setPrefillFields( + buildPrefillFields(remoteTemplate.getFields(), new StudentSnapshot(student, level))); var response = documensoClient.useTemplate(request); @@ -102,17 +94,16 @@ public DocumensoDocument generateForPromotionLevel( DocumensoDocument.builder() .documensoDocumentId(response.getId().longValue()) .template(template) - .promotion(promotion) + .student(student) .level(level) .status(DocumensoDocument.Status.PENDING) .build()); for (var recipient : response.getRecipients()) { - var user = recipient.getEmail().equals(admin.getEmail()) ? admin : monitor; documensoDocumentRecipientRepository.save( DocumensoDocumentRecipient.builder() .document(document) - .user(user) + .user(monitor) .documensoRecipientId(recipient.getId().longValue()) .signingToken(recipient.getToken()) .build()); @@ -123,6 +114,33 @@ public DocumensoDocument generateForPromotionLevel( } } + private school.hei.haapi.model.TemplateDocumenso resolveTemplateByName( + String templateName, StudentLevel level) { + var candidates = templateDocumensoRepository.findAllByTitleContainingIgnoreCase(templateName); + if (candidates.isEmpty()) { + throw new NotFoundException("No synced Documenso template matching: " + templateName); + } + if (candidates.size() == 1) { + return candidates.get(0); + } + if (level != null) { + var matchingLevel = + candidates.stream() + .filter( + candidate -> normalize(candidate.getTitle()).contains(normalize(level.name()))) + .toList(); + if (matchingLevel.size() == 1) { + return matchingLevel.get(0); + } + } + throw new ApiException( + SERVER_EXCEPTION, + "Several Documenso templates match \"" + + templateName + + "\" and the student's level doesn't disambiguate them: " + + candidates.stream().map(school.hei.haapi.model.TemplateDocumenso::getTitle).toList()); + } + private TemplateCreateDocumentFromTemplateRequestRecipientsInner toRecipient( BigDecimal placeholderId, User user) { var recipient = new TemplateCreateDocumentFromTemplateRequestRecipientsInner(); @@ -132,41 +150,70 @@ private TemplateCreateDocumentFromTemplateRequestRecipientsInner toRecipient( return recipient; } + private List buildPrefillFields( + List fields, StudentSnapshot student) { + var prefillFields = + new ArrayList(); + if (fields == null) { + return prefillFields; + } + for (var field : fields) { + if (!"TEXT".equalsIgnoreCase(field.getType())) { + continue; + } + var label = field.getLabel() != null ? field.getLabel() : field.getPlaceholder(); + if (label == null) { + continue; + } + var normalizedLabel = normalize(label); + FIELD_LABEL_MATCHERS.entrySet().stream() + .filter(matcher -> normalizedLabel.contains(matcher.getKey())) + .findFirst() + .map(matcher -> matcher.getValue().apply(student)) + .filter(value -> value != null && !value.isBlank()) + .ifPresent(value -> prefillFields.add(toPrefillField(field.getId(), value))); + } + return prefillFields; + } + + private static String normalize(String value) { + var withoutAccents = Normalizer.normalize(value, Normalizer.Form.NFD).replaceAll("\\p{M}", ""); + return withoutAccents.toLowerCase(Locale.FRENCH); + } + private TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner toPrefillField( - Map.Entry entry) { + BigDecimal fieldId, String value) { var field = new TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner(); - field.setId(BigDecimal.valueOf(entry.getKey())); + field.setId(fieldId); field.setType(TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.TypeEnum.TEXT); - field.setValue(entry.getValue()); + field.setValue(value); return field; } - public List findMonthlyPayingStudentsForPromotionLevel( - String promotionId, StudentLevel level) { - var monthlyPayers = - feeRepository.findAllByFrequency(FeeFrequency.MONTHLY).stream() - .map(fee -> fee.getStudent().getId()) - .collect(Collectors.toSet()); - return userRepository.findAllByRoleAndStatus(User.Role.STUDENT, User.Status.ENABLED).stream() - .filter(student -> monthlyPayers.contains(student.getId())) - .filter( - student -> - student - .findCurrentGroup() - .map( - group -> - group.getPromotion().getId().equals(promotionId) - && level == safeLevelAt(group.getPromotion())) - .orElse(false)) - .toList(); + private record StudentSnapshot( + String fullName, String nic, String address, String phone, String levelLabel) { + StudentSnapshot(User student, StudentLevel level) { + this( + student.getFirstName() + " " + student.getLastName(), + student.getNic(), + student.getAddress(), + student.getPhone(), + level == null ? null : Promotion.getLevelString(level)); + } } - private StudentLevel safeLevelAt(Promotion promotion) { - try { - return promotion.getLevelAt(Instant.now()); - } catch (PromotionLevelOutOfRangeException e) { - return null; - } + private StudentLevel safeLevelAt(User student) { + return student + .findCurrentGroup() + .flatMap( + group -> { + try { + return java.util.Optional.of(group.getPromotion().getLevelAt(Instant.now())); + } catch (PromotionLevelOutOfRangeException e) { + return java.util.Optional.empty(); + } + }) + .orElse(null); } public String getSigningToken(String documentId, String requestingUserId) { @@ -197,8 +244,7 @@ public void handleWebhook(Map payload) { var document = documensoDocumentRepository .findByDocumensoDocumentId(documensoDocumentId) - .orElseThrow( - () -> new NotFoundException("Documenso document " + documensoDocumentId)); + .orElseThrow(() -> new NotFoundException("Documenso document " + documensoDocumentId)); try { var signedFile = documensoClient.downloadSignedDocument(documensoDocumentId); From 60b3cc995941ba097867c1bccda3886aead7078d Mon Sep 17 00:00:00 2001 From: mbomain Date: Fri, 7 Aug 2026 13:06:42 +0300 Subject: [PATCH 05/21] feat: implementation repository documenso --- src/main/java/school/hei/haapi/repository/FeeRepository.java | 3 +++ .../hei/haapi/repository/TemplateDocumensoRepository.java | 2 ++ src/main/java/school/hei/haapi/repository/UserRepository.java | 2 ++ 3 files changed, 7 insertions(+) diff --git a/src/main/java/school/hei/haapi/repository/FeeRepository.java b/src/main/java/school/hei/haapi/repository/FeeRepository.java index 281859dcd..2116bbf46 100644 --- a/src/main/java/school/hei/haapi/repository/FeeRepository.java +++ b/src/main/java/school/hei/haapi/repository/FeeRepository.java @@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import school.hei.haapi.endpoint.rest.model.FeeFrequency; import school.hei.haapi.endpoint.rest.model.FeeStatusEnum; import school.hei.haapi.model.Fee; @@ -18,6 +19,8 @@ public interface FeeRepository extends JpaRepository { List findAllByStatus(FeeStatusEnum status); + List findAllByFrequency(FeeFrequency frequency); + List getFeesByStudentIdAndStatusOrderByDueDatetimeDesc( String studentId, FeeStatusEnum status, Pageable pageable); diff --git a/src/main/java/school/hei/haapi/repository/TemplateDocumensoRepository.java b/src/main/java/school/hei/haapi/repository/TemplateDocumensoRepository.java index a7f017c0c..de8641446 100644 --- a/src/main/java/school/hei/haapi/repository/TemplateDocumensoRepository.java +++ b/src/main/java/school/hei/haapi/repository/TemplateDocumensoRepository.java @@ -1,5 +1,6 @@ package school.hei.haapi.repository; +import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -8,4 +9,5 @@ @Repository public interface TemplateDocumensoRepository extends JpaRepository { Optional findByDocumensoTemplateId(Long documensoTemplateId); + List findAllByTitleContainingIgnoreCase(String title); } diff --git a/src/main/java/school/hei/haapi/repository/UserRepository.java b/src/main/java/school/hei/haapi/repository/UserRepository.java index 97db018f9..a5fa8c0ff 100644 --- a/src/main/java/school/hei/haapi/repository/UserRepository.java +++ b/src/main/java/school/hei/haapi/repository/UserRepository.java @@ -18,6 +18,8 @@ public interface UserRepository extends JpaRepository { Optional findByEmail(String email); + Optional findByDocumensoUserId(Long documensoUserId); + List findAllByStatus(User.Status status); List findAllByRoleAndStatus(Role role, User.Status status); From 31e7795306168008ec5558762be25d46e5a5a134 Mon Sep 17 00:00:00 2001 From: mbomain Date: Fri, 7 Aug 2026 13:12:50 +0300 Subject: [PATCH 06/21] feat: implementation controller for documenso --- .../controller/DocumensoDocumentController.java | 13 ++++--------- .../haapi/endpoint/rest/mapper/DocumensoMapper.java | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoDocumentController.java b/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoDocumentController.java index 8333ae012..3d9873e49 100644 --- a/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoDocumentController.java +++ b/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoDocumentController.java @@ -1,6 +1,5 @@ package school.hei.haapi.endpoint.rest.controller; -import java.util.Map; import lombok.RequiredArgsConstructor; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; @@ -22,15 +21,11 @@ public class DocumensoDocumentController { private final DocumensoMapper documensoMapper; @PostMapping("/documenso-documents") - public DocumensoDocument generateDocumensoDocument(@RequestBody CrupdateDocumensoDocument toCreate) { + public DocumensoDocument generateDocumensoDocument( + @RequestBody CrupdateDocumensoDocument toCreate) { var document = - documensoDocumentService.generateForPromotionLevel( - toCreate.getPromotionId(), - toCreate.getLevel(), - toCreate.getDocumensoTemplateId(), - toCreate.getAdminId(), - toCreate.getMonitorId(), - Map.of()); + documensoDocumentService.generateDocument( + toCreate.getStudentId(), toCreate.getTemplateName()); return documensoMapper.toRest(document); } diff --git a/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java b/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java index 6813a3ec2..9e9b7c68b 100644 --- a/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java +++ b/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java @@ -21,7 +21,7 @@ public DocumensoDocument toRest(school.hei.haapi.model.DocumensoDocument domain) .id(domain.getId()) .documensoDocumentId(domain.getDocumensoDocumentId()) .status(DocumensoDocumentStatus.valueOf(domain.getStatus().name())) - .promotionId(domain.getPromotion().getId()) + .studentId(domain.getStudent().getId()) .level(domain.getLevel()) .templateId(domain.getTemplate().getId()); } From 4b8e27b7b1b5e19560b780a5457cd9fc34b82b7a Mon Sep 17 00:00:00 2001 From: mbomain Date: Fri, 7 Aug 2026 14:19:27 +0300 Subject: [PATCH 07/21] feat: secure documenso endpoints and prefill guardian block from monitor Wires role restrictions and the webhook's public route, adds the documenso.* env vars, and teaches document generation to resolve the template by name and prefill the topmost guardian block from the linked monitor using field position, since the guardian and student blocks share identical labels on the fiche d'engagement. --- doc/documenso-client-api.yaml | 4 + .../endpoint/rest/security/SecurityConf.java | 11 +- .../service/DocumensoDocumentService.java | 178 ++++++++++--- .../documenso/gen/api/DocumentApi.java | 142 +++++----- .../documenso/gen/api/TemplateApi.java | 223 +++++++--------- .../documenso/gen/invoker/ApiClient.java | 147 ++++++----- .../documenso/gen/invoker/ApiException.java | 157 ++++++----- .../documenso/gen/invoker/ApiResponse.java | 76 +++--- .../documenso/gen/invoker/Configuration.java | 48 ++-- .../service/documenso/gen/invoker/JSON.java | 118 +++++---- .../service/documenso/gen/invoker/Pair.java | 64 +++-- .../gen/invoker/RFC3339DateFormat.java | 15 +- .../gen/invoker/ServerConfiguration.java | 96 ++++--- .../documenso/gen/invoker/ServerVariable.java | 36 ++- .../gen/model/AbstractOpenApiSchema.java | 245 +++++++++--------- .../gen/model/DocumentGet200Response.java | 119 ++++----- ...CreateDocumentFromTemplate200Response.java | 141 +++++----- ...romTemplate200ResponseRecipientsInner.java | 128 ++++----- ...lateCreateDocumentFromTemplateRequest.java | 123 ++++----- ...FromTemplateRequestPrefillFieldsInner.java | 92 +++---- ...entFromTemplateRequestRecipientsInner.java | 87 +++---- .../TemplateFindTemplates200Response.java | 71 ++--- ...lateFindTemplates200ResponseDataInner.java | 133 ++++------ .../TemplateGetTemplateById200Response.java | 136 ++++------ ...GetTemplateById200ResponseFieldsInner.java | 170 ++++++++---- ...emplateById200ResponseRecipientsInner.java | 108 ++++---- src/main/resources/application.properties | 5 +- .../hei/haapi/integration/DocumensoIT.java | 199 ++++++++++---- 28 files changed, 1579 insertions(+), 1493 deletions(-) diff --git a/doc/documenso-client-api.yaml b/doc/documenso-client-api.yaml index f747844ec..9693f5e92 100644 --- a/doc/documenso-client-api.yaml +++ b/doc/documenso-client-api.yaml @@ -129,6 +129,10 @@ paths: type: string placeholder: type: string + page: + type: number + positionY: + type: number required: - id - type diff --git a/src/main/java/school/hei/haapi/endpoint/rest/security/SecurityConf.java b/src/main/java/school/hei/haapi/endpoint/rest/security/SecurityConf.java index 0532e2877..b5dc1fda5 100644 --- a/src/main/java/school/hei/haapi/endpoint/rest/security/SecurityConf.java +++ b/src/main/java/school/hei/haapi/endpoint/rest/security/SecurityConf.java @@ -51,7 +51,6 @@ public class SecurityConf { public SecurityConf( CasdoorAuthProvider authProvider, - // InternalToExternalErrorHandler behind @Qualifier("handlerExceptionResolver") HandlerExceptionResolver exceptionResolver, CourseAssignmentService courseAssignmentService, MonitoringStudentService monitoringStudentService, @@ -152,6 +151,9 @@ req, res, null, forbiddenWithRemoteInfo(req)))) antMatcher(POST, "/cors/*/comment"), antMatcher(GET, "/students/*/cors"), antMatcher(PUT, "/students/*/cors"), + antMatcher(POST, "/documenso-templates/sync"), + antMatcher(POST, "/documenso-documents"), + antMatcher(GET, "/documenso-documents/*/signing-token"), antMatcher(PUT, "/students/*/fees/*/mpbs"), antMatcher(GET, "/students/*/fees/*/mpbs"), antMatcher(GET, "/students/*/fees/*/mpbs/verifications"), @@ -350,6 +352,7 @@ req, res, null, forbiddenWithRemoteInfo(req)))) // casdoor new AntPathRequestMatcher("/authentication/signin", POST.name()), new AntPathRequestMatcher("/authentication/login-url", GET.name()), + new AntPathRequestMatcher("/documenso/webhook", POST.name()), new AntPathRequestMatcher("/**", OPTIONS.toString()))) .permitAll() .requestMatchers(GET, "/whoami") @@ -1093,6 +1096,12 @@ req, res, null, forbiddenWithRemoteInfo(req)))) .hasAnyRole(TEACHER.getRole(), MANAGER.getRole(), ADMIN.getRole()) .requestMatchers(PUT, "/students/*/cors") .hasAnyRole(MANAGER.getRole(), ADMIN.getRole()) + .requestMatchers(POST, "/documenso-templates/sync") + .hasAnyRole(ADMIN.getRole()) + .requestMatchers(POST, "/documenso-documents") + .hasAnyRole(ADMIN.getRole()) + .requestMatchers(GET, "/documenso-documents/*/signing-token") + .hasAnyRole(ADMIN.getRole(), MONITOR.getRole()) // // Attendances resources // diff --git a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java index 2ff36c39b..2ccdc3961 100644 --- a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java +++ b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java @@ -6,9 +6,11 @@ import java.text.Normalizer; import java.time.Instant; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Optional; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -39,15 +41,6 @@ @Service @AllArgsConstructor public class DocumensoDocumentService { - private static final Map> - FIELD_LABEL_MATCHERS = - Map.of( - "nom et prenom", s -> s.fullName, - "inscrit", s -> s.levelLabel, - "cin", s -> s.nic, - "adresse personnelle", s -> s.address, - "telephone", s -> s.phone); - private final DocumensoClient documensoClient; private final DocumensoDocumentRepository documensoDocumentRepository; private final DocumensoDocumentRecipientRepository documensoDocumentRecipientRepository; @@ -85,7 +78,7 @@ public DocumensoDocument generateDocument(String studentId, String templateName) request.setTemplateId(BigDecimal.valueOf(documensoTemplateId)); request.setRecipients(List.of(toRecipient(placeholders.get(0).getId(), monitor))); request.setPrefillFields( - buildPrefillFields(remoteTemplate.getFields(), new StudentSnapshot(student, level))); + buildPrefillFields(template, remoteTemplate.getFields(), student, monitor, level)); var response = documensoClient.useTemplate(request); @@ -150,32 +143,136 @@ private TemplateCreateDocumentFromTemplateRequestRecipientsInner toRecipient( return recipient; } + /** + * Dispatches to a prefill strategy keyed by the template's title, since each document type lays + * its fields out differently (e.g. "Fiche d'engagement" repeats the same address/phone/CIN + * labels for up to 3 guardians and the student, whereas a future "Contrat d'alternance" or + * "Fiche de paye" would need its own rules). Unknown document types fall back to a single-person + * (student) match on uniquely-labelled fields only. + */ private List buildPrefillFields( - List fields, StudentSnapshot student) { - var prefillFields = - new ArrayList(); - if (fields == null) { - return prefillFields; + school.hei.haapi.model.TemplateDocumenso template, + List fields, + User student, + User monitor, + StudentLevel level) { + if (fields == null || fields.isEmpty()) { + return List.of(); } - for (var field : fields) { - if (!"TEXT".equalsIgnoreCase(field.getType())) { - continue; - } - var label = field.getLabel() != null ? field.getLabel() : field.getPlaceholder(); - if (label == null) { - continue; + var textFields = fields.stream().filter(f -> "TEXT".equalsIgnoreCase(f.getType())).toList(); + if (normalize(template.getTitle()).contains("engagement")) { + return buildFicheEngagementPrefillFields( + textFields, new PersonSnapshot(student), new PersonSnapshot(monitor), level); + } + return buildDefaultPrefillFields(textFields, new PersonSnapshot(student), level); + } + + /** + * "Fiche d'engagement" repeats "Adresse personnelle"/"Téléphones"/"Titulaire de la CIN" once per + * guardian block (up to 3, topmost first) and once more for the student (always last, below the + * guardian blocks). Since the monitor stands in for the topmost guardian, we fill that occurrence + * with the monitor's data and the last occurrence with the student's, using each field's position + * on the page to tell them apart — the label text alone is identical across occurrences. + */ + private List + buildFicheEngagementPrefillFields( + List textFields, + PersonSnapshot student, + PersonSnapshot monitor, + StudentLevel level) { + var prefillFields = new ArrayList(); + + matchOnly(textFields, "nom et prenom", student.fullName()).ifPresent(prefillFields::add); + matchOnly(textFields, "inscrit", level == null ? null : Promotion.getLevelString(level)) + .ifPresent(prefillFields::add); + // only ever labelled on guardian blocks, so the topmost occurrence is always the monitor's, + // regardless of how many guardian blocks the template actually has. + matchByPosition(textFields, "pere/", monitor.fullName(), true).ifPresent(prefillFields::add); + + // shared with the student block below it: when both occur, top -> monitor, bottom -> student; + // when the template only has one occurrence, it's the student's own (more essential) field. + for (var keyword : List.of("adresse personnelle", "telephone", "titulaire de la cin")) { + var candidates = fieldsMatching(textFields, keyword); + if (candidates.size() >= 2) { + matchAt(candidates.get(0), monitor.field(keyword)).ifPresent(prefillFields::add); + matchAt(candidates.get(candidates.size() - 1), student.field(keyword)) + .ifPresent(prefillFields::add); + } else if (candidates.size() == 1) { + matchAt(candidates.get(0), student.field(keyword)).ifPresent(prefillFields::add); } - var normalizedLabel = normalize(label); - FIELD_LABEL_MATCHERS.entrySet().stream() - .filter(matcher -> normalizedLabel.contains(matcher.getKey())) - .findFirst() - .map(matcher -> matcher.getValue().apply(student)) - .filter(value -> value != null && !value.isBlank()) - .ifPresent(value -> prefillFields.add(toPrefillField(field.getId(), value))); } return prefillFields; } + /** Fallback for document types without a dedicated strategy: matches uniquely-labelled fields only. */ + private List buildDefaultPrefillFields( + List textFields, + PersonSnapshot student, + StudentLevel level) { + var prefillFields = new ArrayList(); + matchOnly(textFields, "nom et prenom", student.fullName()).ifPresent(prefillFields::add); + matchOnly(textFields, "inscrit", level == null ? null : Promotion.getLevelString(level)) + .ifPresent(prefillFields::add); + matchOnly(textFields, "titulaire de la cin", student.nic()).ifPresent(prefillFields::add); + matchOnly(textFields, "adresse personnelle", student.address()).ifPresent(prefillFields::add); + matchOnly(textFields, "telephone", student.phone()).ifPresent(prefillFields::add); + return prefillFields; + } + + private Optional matchOnly( + List fields, String labelKeyword, String value) { + if (value == null || value.isBlank()) { + return Optional.empty(); + } + return fields.stream() + .filter(field -> labelContains(field, labelKeyword)) + .findFirst() + .map(field -> toPrefillField(field.getId(), value)); + } + + private Optional matchByPosition( + List fields, + String labelKeyword, + String value, + boolean topmost) { + var candidates = fieldsMatching(fields, labelKeyword); + if (candidates.isEmpty()) { + return Optional.empty(); + } + var chosen = topmost ? candidates.get(0) : candidates.get(candidates.size() - 1); + return matchAt(chosen, value); + } + + /** All fields whose label/placeholder contains {@code labelKeyword}, sorted top-to-bottom. */ + private static List fieldsMatching( + List fields, String labelKeyword) { + return fields.stream() + .filter(field -> labelContains(field, labelKeyword)) + .sorted( + Comparator.comparing( + (TemplateGetTemplateById200ResponseFieldsInner f) -> orZero(f.getPage())) + .thenComparing(f -> orZero(f.getPositionY()))) + .toList(); + } + + private Optional matchAt( + TemplateGetTemplateById200ResponseFieldsInner field, String value) { + if (value == null || value.isBlank()) { + return Optional.empty(); + } + return Optional.of(toPrefillField(field.getId(), value)); + } + + private static boolean labelContains( + TemplateGetTemplateById200ResponseFieldsInner field, String labelKeyword) { + var label = field.getLabel() != null ? field.getLabel() : field.getPlaceholder(); + return label != null && normalize(label).contains(labelKeyword); + } + + private static BigDecimal orZero(BigDecimal value) { + return value == null ? BigDecimal.ZERO : value; + } + private static String normalize(String value) { var withoutAccents = Normalizer.normalize(value, Normalizer.Form.NFD).replaceAll("\\p{M}", ""); return withoutAccents.toLowerCase(Locale.FRENCH); @@ -190,15 +287,22 @@ private TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner toPrefillFie return field; } - private record StudentSnapshot( - String fullName, String nic, String address, String phone, String levelLabel) { - StudentSnapshot(User student, StudentLevel level) { + private record PersonSnapshot(String fullName, String nic, String address, String phone) { + PersonSnapshot(User user) { this( - student.getFirstName() + " " + student.getLastName(), - student.getNic(), - student.getAddress(), - student.getPhone(), - level == null ? null : Promotion.getLevelString(level)); + user.getFirstName() + " " + user.getLastName(), + user.getNic(), + user.getAddress(), + user.getPhone()); + } + + String field(String labelKeyword) { + return switch (labelKeyword) { + case "adresse personnelle" -> address; + case "telephone" -> phone; + case "titulaire de la cin" -> nic; + default -> null; + }; } } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/api/DocumentApi.java b/src/main/java/school/hei/haapi/service/documenso/gen/api/DocumentApi.java index e56dd7e61..32e5c226a 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/api/DocumentApi.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/api/DocumentApi.java @@ -3,7 +3,7 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -12,31 +12,41 @@ package school.hei.haapi.service.documenso.gen.api; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import school.hei.haapi.service.documenso.gen.invoker.ApiException; +import school.hei.haapi.service.documenso.gen.invoker.ApiResponse; +import school.hei.haapi.service.documenso.gen.invoker.Pair; + +import java.math.BigDecimal; +import school.hei.haapi.service.documenso.gen.model.DocumentGet200Response; +import java.io.File; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.time.Duration; + import java.util.ArrayList; -import java.util.List; import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.function.Consumer; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -import school.hei.haapi.service.documenso.gen.invoker.ApiException; -import school.hei.haapi.service.documenso.gen.invoker.ApiResponse; -import school.hei.haapi.service.documenso.gen.invoker.Pair; -import school.hei.haapi.service.documenso.gen.model.DocumentGet200Response; -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class DocumentApi { private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; @@ -60,8 +70,7 @@ public DocumentApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } - protected ApiException getApiException(String operationId, HttpResponse response) - throws IOException { + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); return new ApiException(response.statusCode(), message, response.headers(), body); @@ -75,11 +84,10 @@ private String formatExceptionMessage(String operationId, int statusCode, String } /** - * Download document Downloads the document. \"signed\" returns the completed document - * with signatures, \"original\" returns the original uploaded document. - * - * @param documentId (required) - * @param version (optional, default to signed) + * Download document + * Downloads the document. \"signed\" returns the completed document with signatures, \"original\" returns the original uploaded document. + * @param documentId (required) + * @param version (optional, default to signed) * @return File * @throws ApiException if fails to make API call */ @@ -89,60 +97,52 @@ public File documentDownload(BigDecimal documentId, String version) throws ApiEx } /** - * Download document Downloads the document. \"signed\" returns the completed document - * with signatures, \"original\" returns the original uploaded document. - * - * @param documentId (required) - * @param version (optional, default to signed) + * Download document + * Downloads the document. \"signed\" returns the completed document with signatures, \"original\" returns the original uploaded document. + * @param documentId (required) + * @param version (optional, default to signed) * @return ApiResponse<File> * @throws ApiException if fails to make API call */ - public ApiResponse documentDownloadWithHttpInfo(BigDecimal documentId, String version) - throws ApiException { - HttpRequest.Builder localVarRequestBuilder = - documentDownloadRequestBuilder(documentId, version); + public ApiResponse documentDownloadWithHttpInfo(BigDecimal documentId, String version) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = documentDownloadRequestBuilder(documentId, version); try { - HttpResponse localVarResponse = - memberVarHttpClient.send( - localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofInputStream()); + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); if (memberVarResponseInterceptor != null) { memberVarResponseInterceptor.accept(localVarResponse); } try { - if (localVarResponse.statusCode() / 100 != 2) { + if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("documentDownload", localVarResponse); } return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null - ? null - : memberVarObjectMapper.readValue( - localVarResponse.body(), new TypeReference() {}) // closes the InputStream - ); + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); } finally { } } catch (IOException e) { throw new ApiException(e); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ApiException(e); } } - private HttpRequest.Builder documentDownloadRequestBuilder(BigDecimal documentId, String version) - throws ApiException { + private HttpRequest.Builder documentDownloadRequestBuilder(BigDecimal documentId, String version) throws ApiException { // verify the required parameter 'documentId' is set if (documentId == null) { - throw new ApiException( - 400, "Missing the required parameter 'documentId' when calling documentDownload"); + throw new ApiException(400, "Missing the required parameter 'documentId' when calling documentDownload"); } HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); - String localVarPath = - "/document/{documentId}/download" - .replace("{documentId}", ApiClient.urlEncode(documentId.toString())); + String localVarPath = "/document/{documentId}/download" + .replace("{documentId}", ApiClient.urlEncode(documentId.toString())); List localVarQueryParams = new ArrayList<>(); StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); @@ -156,8 +156,7 @@ private HttpRequest.Builder documentDownloadRequestBuilder(BigDecimal documentId if (localVarQueryStringJoiner.length() != 0) { queryJoiner.add(localVarQueryStringJoiner.toString()); } - localVarRequestBuilder.uri( - URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); } @@ -176,8 +175,8 @@ private HttpRequest.Builder documentDownloadRequestBuilder(BigDecimal documentId /** * Get document - * - * @param documentId (required) + * + * @param documentId (required) * @return DocumentGet200Response * @throws ApiException if fails to make API call */ @@ -188,39 +187,35 @@ public DocumentGet200Response documentGet(BigDecimal documentId) throws ApiExcep /** * Get document - * - * @param documentId (required) + * + * @param documentId (required) * @return ApiResponse<DocumentGet200Response> * @throws ApiException if fails to make API call */ - public ApiResponse documentGetWithHttpInfo(BigDecimal documentId) - throws ApiException { + public ApiResponse documentGetWithHttpInfo(BigDecimal documentId) throws ApiException { HttpRequest.Builder localVarRequestBuilder = documentGetRequestBuilder(documentId); try { - HttpResponse localVarResponse = - memberVarHttpClient.send( - localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofInputStream()); + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); if (memberVarResponseInterceptor != null) { memberVarResponseInterceptor.accept(localVarResponse); } try { - if (localVarResponse.statusCode() / 100 != 2) { + if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("documentGet", localVarResponse); } return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null - ? null - : memberVarObjectMapper.readValue( - localVarResponse.body(), - new TypeReference() {}) // closes the InputStream - ); + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); } finally { } } catch (IOException e) { throw new ApiException(e); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ApiException(e); } @@ -229,15 +224,13 @@ public ApiResponse documentGetWithHttpInfo(BigDecimal do private HttpRequest.Builder documentGetRequestBuilder(BigDecimal documentId) throws ApiException { // verify the required parameter 'documentId' is set if (documentId == null) { - throw new ApiException( - 400, "Missing the required parameter 'documentId' when calling documentGet"); + throw new ApiException(400, "Missing the required parameter 'documentId' when calling documentGet"); } HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); - String localVarPath = - "/document/{documentId}" - .replace("{documentId}", ApiClient.urlEncode(documentId.toString())); + String localVarPath = "/document/{documentId}" + .replace("{documentId}", ApiClient.urlEncode(documentId.toString())); localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); @@ -252,4 +245,5 @@ private HttpRequest.Builder documentGetRequestBuilder(BigDecimal documentId) thr } return localVarRequestBuilder; } + } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/api/TemplateApi.java b/src/main/java/school/hei/haapi/service/documenso/gen/api/TemplateApi.java index 6d04626f6..46f642692 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/api/TemplateApi.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/api/TemplateApi.java @@ -3,7 +3,7 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -12,33 +12,43 @@ package school.hei.haapi.service.documenso.gen.api; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import school.hei.haapi.service.documenso.gen.invoker.ApiException; +import school.hei.haapi.service.documenso.gen.invoker.ApiResponse; +import school.hei.haapi.service.documenso.gen.invoker.Pair; + +import java.math.BigDecimal; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplate200Response; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequest; +import school.hei.haapi.service.documenso.gen.model.TemplateFindTemplates200Response; +import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200Response; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; + import java.io.InputStream; -import java.math.BigDecimal; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.time.Duration; + import java.util.ArrayList; -import java.util.List; import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.function.Consumer; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -import school.hei.haapi.service.documenso.gen.invoker.ApiException; -import school.hei.haapi.service.documenso.gen.invoker.ApiResponse; -import school.hei.haapi.service.documenso.gen.invoker.Pair; -import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplate200Response; -import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequest; -import school.hei.haapi.service.documenso.gen.model.TemplateFindTemplates200Response; -import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200Response; -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class TemplateApi { private final HttpClient memberVarHttpClient; private final ObjectMapper memberVarObjectMapper; @@ -62,8 +72,7 @@ public TemplateApi(ApiClient apiClient) { memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); } - protected ApiException getApiException(String operationId, HttpResponse response) - throws IOException { + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { String body = response.body() == null ? null : new String(response.body().readAllBytes()); String message = formatExceptionMessage(operationId, response.statusCode(), body); return new ApiException(response.statusCode(), message, response.headers(), body); @@ -77,74 +86,57 @@ private String formatExceptionMessage(String operationId, int statusCode, String } /** - * Use template Use the template to create a document - * - * @param templateCreateDocumentFromTemplateRequest (required) + * Use template + * Use the template to create a document + * @param templateCreateDocumentFromTemplateRequest (required) * @return TemplateCreateDocumentFromTemplate200Response * @throws ApiException if fails to make API call */ - public TemplateCreateDocumentFromTemplate200Response templateCreateDocumentFromTemplate( - TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) - throws ApiException { - ApiResponse localVarResponse = - templateCreateDocumentFromTemplateWithHttpInfo(templateCreateDocumentFromTemplateRequest); + public TemplateCreateDocumentFromTemplate200Response templateCreateDocumentFromTemplate(TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) throws ApiException { + ApiResponse localVarResponse = templateCreateDocumentFromTemplateWithHttpInfo(templateCreateDocumentFromTemplateRequest); return localVarResponse.getData(); } /** - * Use template Use the template to create a document - * - * @param templateCreateDocumentFromTemplateRequest (required) + * Use template + * Use the template to create a document + * @param templateCreateDocumentFromTemplateRequest (required) * @return ApiResponse<TemplateCreateDocumentFromTemplate200Response> * @throws ApiException if fails to make API call */ - public ApiResponse - templateCreateDocumentFromTemplateWithHttpInfo( - TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) - throws ApiException { - HttpRequest.Builder localVarRequestBuilder = - templateCreateDocumentFromTemplateRequestBuilder(templateCreateDocumentFromTemplateRequest); + public ApiResponse templateCreateDocumentFromTemplateWithHttpInfo(TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = templateCreateDocumentFromTemplateRequestBuilder(templateCreateDocumentFromTemplateRequest); try { - HttpResponse localVarResponse = - memberVarHttpClient.send( - localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofInputStream()); + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); if (memberVarResponseInterceptor != null) { memberVarResponseInterceptor.accept(localVarResponse); } try { - if (localVarResponse.statusCode() / 100 != 2) { + if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("templateCreateDocumentFromTemplate", localVarResponse); } return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null - ? null - : memberVarObjectMapper.readValue( - localVarResponse.body(), - new TypeReference< - TemplateCreateDocumentFromTemplate200Response>() {}) // closes the - // InputStream - ); + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); } finally { } } catch (IOException e) { throw new ApiException(e); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ApiException(e); } } - private HttpRequest.Builder templateCreateDocumentFromTemplateRequestBuilder( - TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) - throws ApiException { + private HttpRequest.Builder templateCreateDocumentFromTemplateRequestBuilder(TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) throws ApiException { // verify the required parameter 'templateCreateDocumentFromTemplateRequest' is set if (templateCreateDocumentFromTemplateRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'templateCreateDocumentFromTemplateRequest' when calling" - + " templateCreateDocumentFromTemplate"); + throw new ApiException(400, "Missing the required parameter 'templateCreateDocumentFromTemplateRequest' when calling templateCreateDocumentFromTemplate"); } HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -157,10 +149,8 @@ private HttpRequest.Builder templateCreateDocumentFromTemplateRequestBuilder( localVarRequestBuilder.header("Accept", "application/json"); try { - byte[] localVarPostBody = - memberVarObjectMapper.writeValueAsBytes(templateCreateDocumentFromTemplateRequest); - localVarRequestBuilder.method( - "POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(templateCreateDocumentFromTemplateRequest); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); } catch (IOException e) { throw new ApiException(e); } @@ -175,66 +165,57 @@ private HttpRequest.Builder templateCreateDocumentFromTemplateRequestBuilder( /** * Find templates - * - * @param query (optional) - * @param page (optional) - * @param perPage (optional) + * + * @param query (optional) + * @param page (optional) + * @param perPage (optional) * @return TemplateFindTemplates200Response * @throws ApiException if fails to make API call */ - public TemplateFindTemplates200Response templateFindTemplates( - String query, BigDecimal page, BigDecimal perPage) throws ApiException { - ApiResponse localVarResponse = - templateFindTemplatesWithHttpInfo(query, page, perPage); + public TemplateFindTemplates200Response templateFindTemplates(String query, BigDecimal page, BigDecimal perPage) throws ApiException { + ApiResponse localVarResponse = templateFindTemplatesWithHttpInfo(query, page, perPage); return localVarResponse.getData(); } /** * Find templates - * - * @param query (optional) - * @param page (optional) - * @param perPage (optional) + * + * @param query (optional) + * @param page (optional) + * @param perPage (optional) * @return ApiResponse<TemplateFindTemplates200Response> * @throws ApiException if fails to make API call */ - public ApiResponse templateFindTemplatesWithHttpInfo( - String query, BigDecimal page, BigDecimal perPage) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = - templateFindTemplatesRequestBuilder(query, page, perPage); + public ApiResponse templateFindTemplatesWithHttpInfo(String query, BigDecimal page, BigDecimal perPage) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = templateFindTemplatesRequestBuilder(query, page, perPage); try { - HttpResponse localVarResponse = - memberVarHttpClient.send( - localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofInputStream()); + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); if (memberVarResponseInterceptor != null) { memberVarResponseInterceptor.accept(localVarResponse); } try { - if (localVarResponse.statusCode() / 100 != 2) { + if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("templateFindTemplates", localVarResponse); } return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null - ? null - : memberVarObjectMapper.readValue( - localVarResponse.body(), - new TypeReference< - TemplateFindTemplates200Response>() {}) // closes the InputStream - ); + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); } finally { } } catch (IOException e) { throw new ApiException(e); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ApiException(e); } } - private HttpRequest.Builder templateFindTemplatesRequestBuilder( - String query, BigDecimal page, BigDecimal perPage) throws ApiException { + private HttpRequest.Builder templateFindTemplatesRequestBuilder(String query, BigDecimal page, BigDecimal perPage) throws ApiException { HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -256,8 +237,7 @@ private HttpRequest.Builder templateFindTemplatesRequestBuilder( if (localVarQueryStringJoiner.length() != 0) { queryJoiner.add(localVarQueryStringJoiner.toString()); } - localVarRequestBuilder.uri( - URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); } @@ -276,72 +256,62 @@ private HttpRequest.Builder templateFindTemplatesRequestBuilder( /** * Get template - * - * @param templateId (required) + * + * @param templateId (required) * @return TemplateGetTemplateById200Response * @throws ApiException if fails to make API call */ - public TemplateGetTemplateById200Response templateGetTemplateById(BigDecimal templateId) - throws ApiException { - ApiResponse localVarResponse = - templateGetTemplateByIdWithHttpInfo(templateId); + public TemplateGetTemplateById200Response templateGetTemplateById(BigDecimal templateId) throws ApiException { + ApiResponse localVarResponse = templateGetTemplateByIdWithHttpInfo(templateId); return localVarResponse.getData(); } /** * Get template - * - * @param templateId (required) + * + * @param templateId (required) * @return ApiResponse<TemplateGetTemplateById200Response> * @throws ApiException if fails to make API call */ - public ApiResponse templateGetTemplateByIdWithHttpInfo( - BigDecimal templateId) throws ApiException { + public ApiResponse templateGetTemplateByIdWithHttpInfo(BigDecimal templateId) throws ApiException { HttpRequest.Builder localVarRequestBuilder = templateGetTemplateByIdRequestBuilder(templateId); try { - HttpResponse localVarResponse = - memberVarHttpClient.send( - localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofInputStream()); + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); if (memberVarResponseInterceptor != null) { memberVarResponseInterceptor.accept(localVarResponse); } try { - if (localVarResponse.statusCode() / 100 != 2) { + if (localVarResponse.statusCode()/ 100 != 2) { throw getApiException("templateGetTemplateById", localVarResponse); } return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null - ? null - : memberVarObjectMapper.readValue( - localVarResponse.body(), - new TypeReference< - TemplateGetTemplateById200Response>() {}) // closes the InputStream - ); + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); } finally { } } catch (IOException e) { throw new ApiException(e); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ApiException(e); } } - private HttpRequest.Builder templateGetTemplateByIdRequestBuilder(BigDecimal templateId) - throws ApiException { + private HttpRequest.Builder templateGetTemplateByIdRequestBuilder(BigDecimal templateId) throws ApiException { // verify the required parameter 'templateId' is set if (templateId == null) { - throw new ApiException( - 400, "Missing the required parameter 'templateId' when calling templateGetTemplateById"); + throw new ApiException(400, "Missing the required parameter 'templateId' when calling templateGetTemplateById"); } HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); - String localVarPath = - "/template/{templateId}" - .replace("{templateId}", ApiClient.urlEncode(templateId.toString())); + String localVarPath = "/template/{templateId}" + .replace("{templateId}", ApiClient.urlEncode(templateId.toString())); localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); @@ -356,4 +326,5 @@ private HttpRequest.Builder templateGetTemplateByIdRequestBuilder(BigDecimal tem } return localVarRequestBuilder; } + } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiClient.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiClient.java index f4d33569b..246f96c35 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiClient.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiClient.java @@ -3,7 +3,7 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -12,13 +12,13 @@ package school.hei.haapi.service.documenso.gen.invoker; -import static java.nio.charset.StandardCharsets.UTF_8; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.openapitools.jackson.nullable.JsonNullableModule; + import java.io.InputStream; import java.net.URI; import java.net.URLEncoder; @@ -35,25 +35,23 @@ import java.util.StringJoiner; import java.util.function.Consumer; import java.util.stream.Collectors; -import org.openapitools.jackson.nullable.JsonNullableModule; + +import static java.nio.charset.StandardCharsets.UTF_8; /** * Configuration and utility class for API clients. * - *

This class can be constructed and modified, then used to instantiate the various API classes. - * The API classes use the settings in this class to configure themselves, but otherwise do not - * store a link to this class. + *

This class can be constructed and modified, then used to instantiate the + * various API classes. The API classes use the settings in this class to + * configure themselves, but otherwise do not store a link to this class.

* - *

This class is mutable and not synchronized, so it is not thread-safe. The API classes - * generated from this are immutable and thread-safe. + *

This class is mutable and not synchronized, so it is not thread-safe. + * The API classes generated from this are immutable and thread-safe.

* - *

The setter methods of this class return the current object to facilitate a fluent style of - * configuration. + *

The setter methods of this class return the current object to facilitate + * a fluent style of configuration.

*/ -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class ApiClient { private HttpClient.Builder builder; @@ -89,14 +87,17 @@ public static String urlEncode(String s) { } /** - * Convert a URL query name/value parameter to a list of encoded {@link Pair} objects. + * Convert a URL query name/value parameter to a list of encoded {@link Pair} + * objects. * - *

The value can be null, in which case an empty list is returned. + *

The value can be null, in which case an empty list is returned.

* * @param name The query name parameter. - * @param value The query value, which may not be a collection but may be null. - * @return A singleton list of the {@link Pair} objects representing the input parameters, which - * is encoded for use in a URL. If the value is null, an empty list is returned. + * @param value The query value, which may not be a collection but may be + * null. + * @return A singleton list of the {@link Pair} objects representing the input + * parameters, which is encoded for use in a URL. If the value is null, an + * empty list is returned. */ public static List parameterToPairs(String name, Object value) { if (name == null || name.isEmpty() || value == null) { @@ -106,13 +107,16 @@ public static List parameterToPairs(String name, Object value) { } /** - * Convert a URL query name/collection parameter to a list of encoded {@link Pair} objects. + * Convert a URL query name/collection parameter to a list of encoded + * {@link Pair} objects. * * @param collectionFormat The swagger collectionFormat string (csv, tsv, etc). * @param name The query name parameter. - * @param values A collection of values for the given query name, which may be null. - * @return A list of {@link Pair} objects representing the input parameters, which is encoded for - * use in a URL. If the values collection is null, an empty list is returned. + * @param values A collection of values for the given query name, which may be + * null. + * @return A list of {@link Pair} objects representing the input parameters, + * which is encoded for use in a URL. If the values collection is null, an + * empty list is returned. */ public static List parameterToPairs( String collectionFormat, String name, Collection values) { @@ -121,8 +125,7 @@ public static List parameterToPairs( } // get the collection format (default: csv) - String format = - collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat; + String format = collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat; // create the params based on the collection format if ("multi".equals(format)) { @@ -132,7 +135,7 @@ public static List parameterToPairs( } String delimiter; - switch (format) { + switch(format) { case "csv": delimiter = urlEncode(","); break; @@ -157,7 +160,9 @@ public static List parameterToPairs( return Collections.singletonList(new Pair(urlEncode(name), joiner.toString())); } - /** Create an instance of ApiClient. */ + /** + * Create an instance of ApiClient. + */ public ApiClient() { this.builder = createDefaultHttpClientBuilder(); this.mapper = createDefaultObjectMapper(); @@ -218,8 +223,8 @@ public void updateBaseUri(String baseUri) { } /** - * Set a custom {@link HttpClient.Builder} object to use when creating the {@link HttpClient} that - * is used by the API client. + * Set a custom {@link HttpClient.Builder} object to use when creating the + * {@link HttpClient} that is used by the API client. * * @param builder Custom client builder. * @return This object. @@ -232,7 +237,7 @@ public ApiClient setHttpClientBuilder(HttpClient.Builder builder) { /** * Get an {@link HttpClient} based on the current {@link HttpClient.Builder}. * - *

The returned object is immutable and thread-safe. + *

The returned object is immutable and thread-safe.

* * @return The HTTP client. */ @@ -241,7 +246,8 @@ public HttpClient getHttpClient() { } /** - * Set a custom {@link ObjectMapper} to serialize and deserialize the request and response bodies. + * Set a custom {@link ObjectMapper} to serialize and deserialize the request + * and response bodies. * * @param mapper Custom object mapper. * @return This object. @@ -274,8 +280,8 @@ public ApiClient setHost(String host) { /** * Set a custom port number for the target service. * - * @param port The port of the target service. Set this to -1 to reset the value to the default - * for the scheme. + * @param port The port of the target service. Set this to -1 to reset the + * value to the default for the scheme. * @return This object. */ public ApiClient setPort(int port) { @@ -286,7 +292,8 @@ public ApiClient setPort(int port) { /** * Set a custom base path for the target service, for example '/v2'. * - * @param basePath The base path against which the rest of the path is resolved. + * @param basePath The base path against which the rest of the path is + * resolved. * @return This object. */ public ApiClient setBasePath(String basePath) { @@ -297,7 +304,8 @@ public ApiClient setBasePath(String basePath) { /** * Get the base URI to resolve the endpoint paths against. * - * @return The complete base URI that the rest of the API parameters are resolved against. + * @return The complete base URI that the rest of the API parameters are + * resolved against. */ public String getBaseUri() { return scheme + "://" + host + (port == -1 ? "" : ":" + port) + basePath; @@ -309,7 +317,7 @@ public String getBaseUri() { * @param scheme The scheme of the target service * @return This object. */ - public ApiClient setScheme(String scheme) { + public ApiClient setScheme(String scheme){ this.scheme = scheme; return this; } @@ -317,15 +325,16 @@ public ApiClient setScheme(String scheme) { /** * Set a custom request interceptor. * - *

A request interceptor is a mechanism for altering each request before it is sent. After the - * request has been fully configured but not yet built, the request builder is passed into this - * function for further modification, after which it is sent out. + *

A request interceptor is a mechanism for altering each request before it + * is sent. After the request has been fully configured but not yet built, the + * request builder is passed into this function for further modification, + * after which it is sent out.

* - *

This is useful for altering the requests in a custom manner, such as adding headers. It - * could also be used for logging and monitoring. + *

This is useful for altering the requests in a custom manner, such as + * adding headers. It could also be used for logging and monitoring.

* - * @param interceptor A function invoked before creating each request. A value of null resets the - * interceptor to a no-op. + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. * @return This object. */ public ApiClient setRequestInterceptor(Consumer interceptor) { @@ -345,10 +354,10 @@ public Consumer getRequestInterceptor() { /** * Set a custom response interceptor. * - *

This is useful for logging, monitoring or extraction of header variables + *

This is useful for logging, monitoring or extraction of header variables

* - * @param interceptor A function invoked before creating each request. A value of null resets the - * interceptor to a no-op. + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. * @return This object. */ public ApiClient setResponseInterceptor(Consumer> interceptor) { @@ -356,7 +365,7 @@ public ApiClient setResponseInterceptor(Consumer> inte return this; } - /** + /** * Get the custom response interceptor. * * @return The custom interceptor that was set, or null if there isn't any. @@ -366,13 +375,12 @@ public Consumer> getResponseInterceptor() { } /** - * Set a custom async response interceptor. Use this interceptor when asyncNative is set to - * 'true'. + * Set a custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. * - *

This is useful for logging, monitoring or extraction of header variables + *

This is useful for logging, monitoring or extraction of header variables

* - * @param interceptor A function invoked before creating each request. A value of null resets the - * interceptor to a no-op. + * @param interceptor A function invoked before creating each request. A value + * of null resets the interceptor to a no-op. * @return This object. */ public ApiClient setAsyncResponseInterceptor(Consumer> interceptor) { @@ -380,9 +388,8 @@ public ApiClient setAsyncResponseInterceptor(Consumer> inte return this; } - /** - * Get the custom async response interceptor. Use this interceptor when asyncNative is set to - * 'true'. + /** + * Get the custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. * * @return The custom interceptor that was set, or null if there isn't any. */ @@ -393,11 +400,12 @@ public Consumer> getAsyncResponseInterceptor() { /** * Set the read timeout for the http client. * - *

This is the value used by default for each request, though it can be overridden on a - * per-request basis with a request interceptor. + *

This is the value used by default for each request, though it can be + * overridden on a per-request basis with a request interceptor.

* - * @param readTimeout The read timeout used by default by the http client. Setting this value to - * null resets the timeout to an effectively infinite value. + * @param readTimeout The read timeout used by default by the http client. + * Setting this value to null resets the timeout to an + * effectively infinite value. * @return This object. */ public ApiClient setReadTimeout(Duration readTimeout) { @@ -408,24 +416,27 @@ public ApiClient setReadTimeout(Duration readTimeout) { /** * Get the read timeout that was set. * - * @return The read timeout, or null if no timeout was set. Null represents an infinite wait time. + * @return The read timeout, or null if no timeout was set. Null represents + * an infinite wait time. */ public Duration getReadTimeout() { return readTimeout; } - /** * Sets the connect timeout (in milliseconds) for the http client. * - *

In the case where a new connection needs to be established, if the connection cannot be - * established within the given {@code duration}, then {@link - * HttpClient#send(HttpRequest,BodyHandler) HttpClient::send} throws an {@link - * HttpConnectTimeoutException}, or {@link HttpClient#sendAsync(HttpRequest,BodyHandler) - * HttpClient::sendAsync} completes exceptionally with an {@code HttpConnectTimeoutException}. If - * a new connection does not need to be established, for example if a connection can be reused + *

In the case where a new connection needs to be established, if + * the connection cannot be established within the given {@code + * duration}, then {@link HttpClient#send(HttpRequest,BodyHandler) + * HttpClient::send} throws an {@link HttpConnectTimeoutException}, or + * {@link HttpClient#sendAsync(HttpRequest,BodyHandler) + * HttpClient::sendAsync} completes exceptionally with an + * {@code HttpConnectTimeoutException}. If a new connection does not + * need to be established, for example if a connection can be reused * from a previous request, then this timeout duration has no effect. * * @param connectTimeout connection timeout in milliseconds + * * @return This object. */ public ApiClient setConnectTimeout(Duration connectTimeout) { diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiException.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiException.java index c75d74144..94f5f76dd 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiException.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiException.java @@ -3,97 +3,90 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.invoker; import java.net.http.HttpHeaders; -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class ApiException extends Exception { - private static final long serialVersionUID = 1L; - - private int code = 0; - private HttpHeaders responseHeaders = null; - private String responseBody = null; - - public ApiException() {} - - public ApiException(Throwable throwable) { - super(throwable); - } - - public ApiException(String message) { - super(message); - } - - public ApiException( - String message, - Throwable throwable, - int code, - HttpHeaders responseHeaders, - String responseBody) { - super(message, throwable); - this.code = code; - this.responseHeaders = responseHeaders; - this.responseBody = responseBody; - } - - public ApiException(String message, int code, HttpHeaders responseHeaders, String responseBody) { - this(message, (Throwable) null, code, responseHeaders, responseBody); - } - - public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders) { - this(message, throwable, code, responseHeaders, null); - } - - public ApiException(int code, HttpHeaders responseHeaders, String responseBody) { - this((String) null, (Throwable) null, code, responseHeaders, responseBody); - } - - public ApiException(int code, String message) { - super(message); - this.code = code; - } - - public ApiException(int code, String message, HttpHeaders responseHeaders, String responseBody) { - this(code, message); - this.responseHeaders = responseHeaders; - this.responseBody = responseBody; - } - - /** - * Get the HTTP status code. - * - * @return HTTP status code - */ - public int getCode() { - return code; - } - - /** - * Get the HTTP response headers. - * - * @return Headers as an HttpHeaders object - */ - public HttpHeaders getResponseHeaders() { - return responseHeaders; - } - - /** - * Get the HTTP response body. - * - * @return Response body in the form of string - */ - public String getResponseBody() { - return responseBody; - } + private static final long serialVersionUID = 1L; + + private int code = 0; + private HttpHeaders responseHeaders = null; + private String responseBody = null; + + public ApiException() {} + + public ApiException(Throwable throwable) { + super(throwable); + } + + public ApiException(String message) { + super(message); + } + + public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + public ApiException(String message, int code, HttpHeaders responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + public ApiException(int code, HttpHeaders responseHeaders, String responseBody) { + this((String) null, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + public ApiException(int code, String message, HttpHeaders responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return Headers as an HttpHeaders object + */ + public HttpHeaders getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiResponse.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiResponse.java index c820fcd2c..d9d480675 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiResponse.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiResponse.java @@ -3,13 +3,14 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.invoker; import java.util.List; @@ -20,43 +21,40 @@ * * @param The type of data that is deserialized from response body */ -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class ApiResponse { - private final int statusCode; - private final Map> headers; - private final T data; - - /** - * @param statusCode The status code of HTTP response - * @param headers The headers of HTTP response - */ - public ApiResponse(int statusCode, Map> headers) { - this(statusCode, headers, null); - } - - /** - * @param statusCode The status code of HTTP response - * @param headers The headers of HTTP response - * @param data The object deserialized from response bod - */ - public ApiResponse(int statusCode, Map> headers, T data) { - this.statusCode = statusCode; - this.headers = headers; - this.data = data; - } - - public int getStatusCode() { - return statusCode; - } - - public Map> getHeaders() { - return headers; - } - - public T getData() { - return data; - } + final private int statusCode; + final private Map> headers; + final private T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Configuration.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Configuration.java index 46a59dce4..676144ce0 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Configuration.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Configuration.java @@ -3,41 +3,39 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.invoker; -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class Configuration { - public static final String VERSION = "1.0.0"; + public static final String VERSION = "1.0.0"; - private static ApiClient defaultApiClient = new ApiClient(); + private static ApiClient defaultApiClient = new ApiClient(); - /** - * Get the default API client, which would be used when creating API instances without providing - * an API client. - * - * @return Default API client - */ - public static ApiClient getDefaultApiClient() { - return defaultApiClient; - } + /** + * Get the default API client, which would be used when creating API + * instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + return defaultApiClient; + } - /** - * Set the default API client, which would be used when creating API instances without providing - * an API client. - * - * @param apiClient API client - */ - public static void setDefaultApiClient(ApiClient apiClient) { - defaultApiClient = apiClient; - } + /** + * Set the default API client, which would be used when creating API + * instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient = apiClient; + } } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/JSON.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/JSON.java index 6b0c24428..647904452 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/JSON.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/JSON.java @@ -3,35 +3,32 @@ import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.json.JsonMapper; +import org.openapitools.jackson.nullable.JsonNullableModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import school.hei.haapi.service.documenso.gen.model.*; + import java.text.DateFormat; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.openapitools.jackson.nullable.JsonNullableModule; -import school.hei.haapi.service.documenso.gen.model.*; -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class JSON { private ObjectMapper mapper; public JSON() { - mapper = - JsonMapper.builder() - .serializationInclusion(JsonInclude.Include.NON_NULL) - .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) - .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE) - .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - .enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING) - .enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING) - .defaultDateFormat(new RFC3339DateFormat()) - .addModule(new JavaTimeModule()) - .build(); + mapper = JsonMapper.builder() + .serializationInclusion(JsonInclude.Include.NON_NULL) + .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) + .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .enable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING) + .enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING) + .defaultDateFormat(new RFC3339DateFormat()) + .addModule(new JavaTimeModule()) + .build(); JsonNullableModule jnm = new JsonNullableModule(); mapper.registerModule(jnm); } @@ -50,16 +47,15 @@ public void setDateFormat(DateFormat dateFormat) { * * @return object mapper */ - public ObjectMapper getMapper() { - return mapper; - } + public ObjectMapper getMapper() { return mapper; } /** - * Returns the target model class that should be used to deserialize the input data. The - * discriminator mappings are used to determine the target model class. + * Returns the target model class that should be used to deserialize the input data. + * The discriminator mappings are used to determine the target model class. * * @param node The input data. * @param modelClass The class that contains the discriminator mappings. + * * @return the target model class. */ public static Class getClassForElement(JsonNode node, Class modelClass) { @@ -70,11 +66,10 @@ public static Class getClassForElement(JsonNode node, Class modelClass) { return null; } - /** Helper class to register the discriminator mappings. */ - @jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") + /** + * Helper class to register the discriminator mappings. + */ + @jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") private static class ClassDiscriminatorMapping { // The model class name. Class modelClass; @@ -116,12 +111,13 @@ String getDiscriminatorValue(JsonNode node) { } /** - * Returns the target model class that should be used to deserialize the input data. This - * function can be invoked for anyOf/oneOf composed models with discriminator mappings. The - * discriminator mappings are used to determine the target model class. + * Returns the target model class that should be used to deserialize the input data. + * This function can be invoked for anyOf/oneOf composed models with discriminator mappings. + * The discriminator mappings are used to determine the target model class. * * @param node The input data. * @param visitedClasses The set of classes that have already been visited. + * * @return the target model class. */ Class getClassForElement(JsonNode node, Set> visitedClasses) { @@ -164,16 +160,16 @@ Class getClassForElement(JsonNode node, Set> visitedClasses) { /** * Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy. * - *

The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy, so - * it's not possible to use the instanceof keyword. + * The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy, + * so it's not possible to use the instanceof keyword. * * @param modelClass A OpenAPI model class. * @param inst The instance object. * @param visitedClasses The set of classes that have already been visited. + * * @return true if inst is an instance of modelClass in the OpenAPI model hierarchy. */ - public static boolean isInstanceOf( - Class modelClass, Object inst, Set> visitedClasses) { + public static boolean isInstanceOf(Class modelClass, Object inst, Set> visitedClasses) { if (modelClass.isInstance(inst)) { // This handles the 'allOf' use case with single parent inheritance. return true; @@ -197,32 +193,34 @@ public static boolean isInstanceOf( return false; } - /** A map of discriminators for all model classes. */ + /** + * A map of discriminators for all model classes. + */ private static Map, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<>(); - /** A map of oneOf/anyOf descendants for each model class. */ + /** + * A map of oneOf/anyOf descendants for each model class. + */ private static Map, Map>> modelDescendants = new HashMap<>(); /** - * Register a model class discriminator. - * - * @param modelClass the model class - * @param discriminatorPropertyName the name of the discriminator property - * @param mappings a map with the discriminator mappings. - */ - public static void registerDiscriminator( - Class modelClass, String discriminatorPropertyName, Map> mappings) { - ClassDiscriminatorMapping m = - new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings); + * Register a model class discriminator. + * + * @param modelClass the model class + * @param discriminatorPropertyName the name of the discriminator property + * @param mappings a map with the discriminator mappings. + */ + public static void registerDiscriminator(Class modelClass, String discriminatorPropertyName, Map> mappings) { + ClassDiscriminatorMapping m = new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings); modelDiscriminators.put(modelClass, m); } /** - * Register the oneOf/anyOf descendants of the modelClass. - * - * @param modelClass the model class - * @param descendants a map of oneOf/anyOf descendants. - */ + * Register the oneOf/anyOf descendants of the modelClass. + * + * @param modelClass the model class + * @param descendants a map of oneOf/anyOf descendants. + */ public static void registerDescendants(Class modelClass, Map> descendants) { modelDescendants.put(modelClass, descendants); } @@ -234,19 +232,19 @@ public static void registerDescendants(Class modelClass, Map } /** - * Get the default JSON instance. - * - * @return the default JSON instance - */ + * Get the default JSON instance. + * + * @return the default JSON instance + */ public static JSON getDefault() { return json; } /** - * Set the default JSON instance. - * - * @param json JSON instance to be used - */ + * Set the default JSON instance. + * + * @param json JSON instance to be used + */ public static void setDefault(JSON json) { JSON.json = json; } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Pair.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Pair.java index 701934be0..6e80b8da3 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Pair.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Pair.java @@ -3,57 +3,55 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.invoker; -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class Pair { - private String name = ""; - private String value = ""; + private String name = ""; + private String value = ""; - public Pair(String name, String value) { - setName(name); - setValue(value); - } - - private void setName(String name) { - if (!isValidString(name)) { - return; + public Pair (String name, String value) { + setName(name); + setValue(value); } - this.name = name; - } + private void setName(String name) { + if (!isValidString(name)) { + return; + } - private void setValue(String value) { - if (!isValidString(value)) { - return; + this.name = name; } - this.value = value; - } + private void setValue(String value) { + if (!isValidString(value)) { + return; + } - public String getName() { - return this.name; - } + this.value = value; + } - public String getValue() { - return this.value; - } + public String getName() { + return this.name; + } - private boolean isValidString(String arg) { - if (arg == null) { - return false; + public String getValue() { + return this.value; } - return true; - } + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } + + return true; + } } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/RFC3339DateFormat.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/RFC3339DateFormat.java index 41788aca2..5c15c5de1 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/RFC3339DateFormat.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/RFC3339DateFormat.java @@ -3,7 +3,7 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -13,24 +13,23 @@ package school.hei.haapi.service.documenso.gen.invoker; import com.fasterxml.jackson.databind.util.StdDateFormat; + import java.text.DateFormat; -import java.text.DecimalFormat; import java.text.FieldPosition; import java.text.ParsePosition; import java.util.Date; +import java.text.DecimalFormat; import java.util.GregorianCalendar; import java.util.TimeZone; -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class RFC3339DateFormat extends DateFormat { private static final long serialVersionUID = 1L; private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); - private final StdDateFormat fmt = - new StdDateFormat().withTimeZone(TIMEZONE_Z).withColonInTimeZone(true); + private final StdDateFormat fmt = new StdDateFormat() + .withTimeZone(TIMEZONE_Z) + .withColonInTimeZone(true); public RFC3339DateFormat() { this.calendar = new GregorianCalendar(); diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerConfiguration.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerConfiguration.java index 69fc82809..38e461e82 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerConfiguration.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerConfiguration.java @@ -2,62 +2,58 @@ import java.util.Map; -/** Representing a Server configuration. */ -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +/** + * Representing a Server configuration. + */ +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class ServerConfiguration { - public String URL; - public String description; - public Map variables; + public String URL; + public String description; + public Map variables; - /** - * @param URL A URL to the target host. - * @param description A description of the host designated by the URL. - * @param variables A map between a variable name and its value. The value is used for - * substitution in the server's URL template. - */ - public ServerConfiguration( - String URL, String description, Map variables) { - this.URL = URL; - this.description = description; - this.variables = variables; - } + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ + public ServerConfiguration(String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } - /** - * Format URL template using given variables. - * - * @param variables A map between a variable name and its value. - * @return Formatted URL. - */ - public String URL(Map variables) { - String url = this.URL; + /** + * Format URL template using given variables. + * + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; - // go through variables and replace placeholders - for (Map.Entry variable : this.variables.entrySet()) { - String name = variable.getKey(); - ServerVariable serverVariable = variable.getValue(); - String value = serverVariable.defaultValue; + // go through variables and replace placeholders + for (Map.Entry variable: this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; - if (variables != null && variables.containsKey(name)) { - value = variables.get(name); - if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { - throw new IllegalArgumentException( - "The variable " + name + " in the server URL has invalid value " + value + "."); + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { + throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + "."); + } + } + url = url.replace("{" + name + "}", value); } - } - url = url.replace("{" + name + "}", value); + return url; } - return url; - } - /** - * Format URL template using default server variables. - * - * @return Formatted URL. - */ - public String URL() { - return URL(null); - } + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerVariable.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerVariable.java index 9534a33b1..26a4c8bc7 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerVariable.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerVariable.java @@ -2,25 +2,23 @@ import java.util.HashSet; -/** Representing a Server Variable for server URL template substitution. */ -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +/** + * Representing a Server Variable for server URL template substitution. + */ +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class ServerVariable { - public String description; - public String defaultValue; - public HashSet enumValues = null; + public String description; + public String defaultValue; + public HashSet enumValues = null; - /** - * @param description A description for the server variable. - * @param defaultValue The default value to use for substitution. - * @param enumValues An enumeration of string values to be used if the substitution options are - * from a limited set. - */ - public ServerVariable(String description, String defaultValue, HashSet enumValues) { - this.description = description; - this.defaultValue = defaultValue; - this.enumValues = enumValues; - } + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/AbstractOpenApiSchema.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/AbstractOpenApiSchema.java index cfa140874..4e8879a07 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/AbstractOpenApiSchema.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/AbstractOpenApiSchema.java @@ -3,144 +3,145 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.model; -import com.fasterxml.jackson.annotation.JsonValue; -import java.util.Map; import java.util.Objects; +import java.lang.reflect.Type; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonValue; -/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +/** + * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec + */ +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public abstract class AbstractOpenApiSchema { - // store the actual instance of the schema/object - private Object instance; - - // is nullable - private Boolean isNullable; - - // schema type (e.g. oneOf, anyOf) - private final String schemaType; - - public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { - this.schemaType = schemaType; - this.isNullable = isNullable; - } - - /** - * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object - * - * @return an instance of the actual schema/object - */ - public abstract Map> getSchemas(); - - /** - * Get the actual instance - * - * @return an instance of the actual schema/object - */ - @JsonValue - public Object getActualInstance() { - return instance; - } - - /** - * Set the actual instance - * - * @param instance the actual instance of the schema/object - */ - public void setActualInstance(Object instance) { - this.instance = instance; - } - - /** - * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf - * schema as well - * - * @return an instance of the actual schema/object - */ - public Object getActualInstanceRecursively() { - return getActualInstanceRecursively(this); - } - - private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { - if (object.getActualInstance() == null) { - return null; - } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { - return getActualInstanceRecursively((AbstractOpenApiSchema) object.getActualInstance()); - } else { - return object.getActualInstance(); + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; } - } - - /** - * Get the schema type (e.g. anyOf, oneOf) - * - * @return the schema type - */ - public String getSchemaType() { - return schemaType; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ").append(getClass()).append(" {\n"); - sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); - sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); - sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + @JsonValue + public Object getActualInstance() {return instance;} + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) {this.instance = instance;} + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); } - return o.toString().replace("\n", "\n "); - } - public boolean equals(Object o) { - if (this == o) { - return true; + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance()); + } else { + return object.getActualInstance(); + } } - if (o == null || getClass() != o.getClass()) { - return false; + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; } - AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; - return Objects.equals(this.instance, a.instance) - && Objects.equals(this.isNullable, a.isNullable) - && Objects.equals(this.schemaType, a.schemaType); - } - - @Override - public int hashCode() { - return Objects.hash(instance, isNullable, schemaType); - } - - /** - * Is nullable - * - * @return true if it's nullable - */ - public Boolean isNullable() { - if (Boolean.TRUE.equals(isNullable)) { - return Boolean.TRUE; - } else { - return Boolean.FALSE; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) && + Objects.equals(this.isNullable, a.isNullable) && + Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } } - } + + + } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/DocumentGet200Response.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/DocumentGet200Response.java index 029e3acad..2149c982e 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/DocumentGet200Response.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/DocumentGet200Response.java @@ -3,29 +3,37 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.model; -import com.fasterxml.jackson.annotation.JsonCreator; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import java.math.BigDecimal; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.Objects; -import java.util.StringJoiner; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import java.util.Arrays; +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; -/** DocumentGet200Response */ + +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +/** + * DocumentGet200Response + */ @JsonPropertyOrder({ DocumentGet200Response.JSON_PROPERTY_ID, DocumentGet200Response.JSON_PROPERTY_STATUS, @@ -33,24 +41,23 @@ DocumentGet200Response.JSON_PROPERTY_CREATED_AT, DocumentGet200Response.JSON_PROPERTY_COMPLETED_AT }) -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class DocumentGet200Response implements Serializable { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_ID = "id"; private BigDecimal id; - /** Gets or Sets status */ + /** + * Gets or Sets status + */ public enum StatusEnum { DRAFT("DRAFT"), - + PENDING("PENDING"), - + COMPLETED("COMPLETED"), - + REJECTED("REJECTED"); private String value; @@ -92,7 +99,8 @@ public static StatusEnum fromValue(String value) { public static final String JSON_PROPERTY_COMPLETED_AT = "completedAt"; private String completedAt; - public DocumentGet200Response() {} + public DocumentGet200Response() { + } public DocumentGet200Response id(BigDecimal id) { this.id = id; @@ -101,7 +109,6 @@ public DocumentGet200Response id(BigDecimal id) { /** * Get id - * * @return id */ @jakarta.annotation.Nonnull @@ -111,12 +118,14 @@ public BigDecimal getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } + public DocumentGet200Response status(StatusEnum status) { this.status = status; return this; @@ -124,7 +133,6 @@ public DocumentGet200Response status(StatusEnum status) { /** * Get status - * * @return status */ @jakarta.annotation.Nonnull @@ -134,12 +142,14 @@ public StatusEnum getStatus() { return status; } + @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setStatus(StatusEnum status) { this.status = status; } + public DocumentGet200Response title(String title) { this.title = title; return this; @@ -147,7 +157,6 @@ public DocumentGet200Response title(String title) { /** * Get title - * * @return title */ @jakarta.annotation.Nullable @@ -157,12 +166,14 @@ public String getTitle() { return title; } + @JsonProperty(JSON_PROPERTY_TITLE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTitle(String title) { this.title = title; } + public DocumentGet200Response createdAt(String createdAt) { this.createdAt = createdAt; return this; @@ -170,7 +181,6 @@ public DocumentGet200Response createdAt(String createdAt) { /** * Get createdAt - * * @return createdAt */ @jakarta.annotation.Nullable @@ -180,12 +190,14 @@ public String getCreatedAt() { return createdAt; } + @JsonProperty(JSON_PROPERTY_CREATED_AT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCreatedAt(String createdAt) { this.createdAt = createdAt; } + public DocumentGet200Response completedAt(String completedAt) { this.completedAt = completedAt; return this; @@ -193,7 +205,6 @@ public DocumentGet200Response completedAt(String completedAt) { /** * Get completedAt - * * @return completedAt */ @jakarta.annotation.Nullable @@ -203,13 +214,17 @@ public String getCompletedAt() { return completedAt; } + @JsonProperty(JSON_PROPERTY_COMPLETED_AT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCompletedAt(String completedAt) { this.completedAt = completedAt; } - /** Return true if this document_get_200_response object is equal to o. */ + + /** + * Return true if this document_get_200_response object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -219,11 +234,11 @@ public boolean equals(Object o) { return false; } DocumentGet200Response documentGet200Response = (DocumentGet200Response) o; - return Objects.equals(this.id, documentGet200Response.id) - && Objects.equals(this.status, documentGet200Response.status) - && Objects.equals(this.title, documentGet200Response.title) - && Objects.equals(this.createdAt, documentGet200Response.createdAt) - && Objects.equals(this.completedAt, documentGet200Response.completedAt); + return Objects.equals(this.id, documentGet200Response.id) && + Objects.equals(this.status, documentGet200Response.status) && + Objects.equals(this.title, documentGet200Response.title) && + Objects.equals(this.createdAt, documentGet200Response.createdAt) && + Objects.equals(this.completedAt, documentGet200Response.completedAt); } @Override @@ -245,7 +260,8 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -288,59 +304,30 @@ public String toUrlQueryString(String prefix) { // add `id` to the URL query string if (getId() != null) { - joiner.add( - String.format( - "%sid%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `status` to the URL query string if (getStatus() != null) { - joiner.add( - String.format( - "%sstatus%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getStatus()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `title` to the URL query string if (getTitle() != null) { - joiner.add( - String.format( - "%stitle%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%stitle%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `createdAt` to the URL query string if (getCreatedAt() != null) { - joiner.add( - String.format( - "%screatedAt%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getCreatedAt()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%screatedAt%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getCreatedAt()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `completedAt` to the URL query string if (getCompletedAt() != null) { - joiner.add( - String.format( - "%scompletedAt%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getCompletedAt()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%scompletedAt%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getCompletedAt()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); } } + diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200Response.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200Response.java index 4b3f9d81f..1a0b21594 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200Response.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200Response.java @@ -3,31 +3,40 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.model; -import com.fasterxml.jackson.annotation.JsonCreator; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import java.math.BigDecimal; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; -import java.util.Objects; -import java.util.StringJoiner; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplate200ResponseRecipientsInner; +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; -/** TemplateCreateDocumentFromTemplate200Response */ + +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +/** + * TemplateCreateDocumentFromTemplate200Response + */ @JsonPropertyOrder({ TemplateCreateDocumentFromTemplate200Response.JSON_PROPERTY_ID, TemplateCreateDocumentFromTemplate200Response.JSON_PROPERTY_STATUS, @@ -35,24 +44,23 @@ TemplateCreateDocumentFromTemplate200Response.JSON_PROPERTY_CREATED_AT, TemplateCreateDocumentFromTemplate200Response.JSON_PROPERTY_RECIPIENTS }) -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class TemplateCreateDocumentFromTemplate200Response implements Serializable { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_ID = "id"; private BigDecimal id; - /** Gets or Sets status */ + /** + * Gets or Sets status + */ public enum StatusEnum { DRAFT("DRAFT"), - + PENDING("PENDING"), - + COMPLETED("COMPLETED"), - + REJECTED("REJECTED"); private String value; @@ -92,10 +100,10 @@ public static StatusEnum fromValue(String value) { private String createdAt; public static final String JSON_PROPERTY_RECIPIENTS = "recipients"; - private List recipients = - new ArrayList<>(); + private List recipients = new ArrayList<>(); - public TemplateCreateDocumentFromTemplate200Response() {} + public TemplateCreateDocumentFromTemplate200Response() { + } public TemplateCreateDocumentFromTemplate200Response id(BigDecimal id) { this.id = id; @@ -104,7 +112,6 @@ public TemplateCreateDocumentFromTemplate200Response id(BigDecimal id) { /** * Get id - * * @return id */ @jakarta.annotation.Nonnull @@ -114,12 +121,14 @@ public BigDecimal getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } + public TemplateCreateDocumentFromTemplate200Response status(StatusEnum status) { this.status = status; return this; @@ -127,7 +136,6 @@ public TemplateCreateDocumentFromTemplate200Response status(StatusEnum status) { /** * Get status - * * @return status */ @jakarta.annotation.Nonnull @@ -137,12 +145,14 @@ public StatusEnum getStatus() { return status; } + @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setStatus(StatusEnum status) { this.status = status; } + public TemplateCreateDocumentFromTemplate200Response title(String title) { this.title = title; return this; @@ -150,7 +160,6 @@ public TemplateCreateDocumentFromTemplate200Response title(String title) { /** * Get title - * * @return title */ @jakarta.annotation.Nullable @@ -160,12 +169,14 @@ public String getTitle() { return title; } + @JsonProperty(JSON_PROPERTY_TITLE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTitle(String title) { this.title = title; } + public TemplateCreateDocumentFromTemplate200Response createdAt(String createdAt) { this.createdAt = createdAt; return this; @@ -173,7 +184,6 @@ public TemplateCreateDocumentFromTemplate200Response createdAt(String createdAt) /** * Get createdAt - * * @return createdAt */ @jakarta.annotation.Nullable @@ -183,20 +193,20 @@ public String getCreatedAt() { return createdAt; } + @JsonProperty(JSON_PROPERTY_CREATED_AT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCreatedAt(String createdAt) { this.createdAt = createdAt; } - public TemplateCreateDocumentFromTemplate200Response recipients( - List recipients) { + + public TemplateCreateDocumentFromTemplate200Response recipients(List recipients) { this.recipients = recipients; return this; } - public TemplateCreateDocumentFromTemplate200Response addRecipientsItem( - TemplateCreateDocumentFromTemplate200ResponseRecipientsInner recipientsItem) { + public TemplateCreateDocumentFromTemplate200Response addRecipientsItem(TemplateCreateDocumentFromTemplate200ResponseRecipientsInner recipientsItem) { if (this.recipients == null) { this.recipients = new ArrayList<>(); } @@ -206,7 +216,6 @@ public TemplateCreateDocumentFromTemplate200Response addRecipientsItem( /** * Get recipients - * * @return recipients */ @jakarta.annotation.Nonnull @@ -216,14 +225,17 @@ public List getRec return recipients; } + @JsonProperty(JSON_PROPERTY_RECIPIENTS) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public void setRecipients( - List recipients) { + public void setRecipients(List recipients) { this.recipients = recipients; } - /** Return true if this template_createDocumentFromTemplate_200_response object is equal to o. */ + + /** + * Return true if this template_createDocumentFromTemplate_200_response object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -232,14 +244,12 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateCreateDocumentFromTemplate200Response templateCreateDocumentFromTemplate200Response = - (TemplateCreateDocumentFromTemplate200Response) o; - return Objects.equals(this.id, templateCreateDocumentFromTemplate200Response.id) - && Objects.equals(this.status, templateCreateDocumentFromTemplate200Response.status) - && Objects.equals(this.title, templateCreateDocumentFromTemplate200Response.title) - && Objects.equals(this.createdAt, templateCreateDocumentFromTemplate200Response.createdAt) - && Objects.equals( - this.recipients, templateCreateDocumentFromTemplate200Response.recipients); + TemplateCreateDocumentFromTemplate200Response templateCreateDocumentFromTemplate200Response = (TemplateCreateDocumentFromTemplate200Response) o; + return Objects.equals(this.id, templateCreateDocumentFromTemplate200Response.id) && + Objects.equals(this.status, templateCreateDocumentFromTemplate200Response.status) && + Objects.equals(this.title, templateCreateDocumentFromTemplate200Response.title) && + Objects.equals(this.createdAt, templateCreateDocumentFromTemplate200Response.createdAt) && + Objects.equals(this.recipients, templateCreateDocumentFromTemplate200Response.recipients); } @Override @@ -261,7 +271,8 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -304,63 +315,30 @@ public String toUrlQueryString(String prefix) { // add `id` to the URL query string if (getId() != null) { - joiner.add( - String.format( - "%sid%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `status` to the URL query string if (getStatus() != null) { - joiner.add( - String.format( - "%sstatus%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getStatus()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `title` to the URL query string if (getTitle() != null) { - joiner.add( - String.format( - "%stitle%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%stitle%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `createdAt` to the URL query string if (getCreatedAt() != null) { - joiner.add( - String.format( - "%screatedAt%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getCreatedAt()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%screatedAt%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getCreatedAt()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `recipients` to the URL query string if (getRecipients() != null) { for (int i = 0; i < getRecipients().size(); i++) { if (getRecipients().get(i) != null) { - joiner.add( - getRecipients() - .get(i) - .toUrlQueryString( - String.format( - "%srecipients%s%s", - prefix, - suffix, - "".equals(suffix) - ? "" - : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + joiner.add(getRecipients().get(i).toUrlQueryString(String.format("%srecipients%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } @@ -368,3 +346,4 @@ public String toUrlQueryString(String prefix) { return joiner.toString(); } } + diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.java index fa1e5dbe1..d3e992607 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.java @@ -3,29 +3,37 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.model; -import com.fasterxml.jackson.annotation.JsonCreator; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import java.math.BigDecimal; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.Objects; -import java.util.StringJoiner; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import java.util.Arrays; +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; -/** TemplateCreateDocumentFromTemplate200ResponseRecipientsInner */ + +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +/** + * TemplateCreateDocumentFromTemplate200ResponseRecipientsInner + */ @JsonPropertyOrder({ TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.JSON_PROPERTY_ID, TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.JSON_PROPERTY_EMAIL, @@ -33,10 +41,7 @@ TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.JSON_PROPERTY_ROLE, TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.JSON_PROPERTY_TOKEN }) -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class TemplateCreateDocumentFromTemplate200ResponseRecipientsInner implements Serializable { private static final long serialVersionUID = 1L; @@ -49,16 +54,18 @@ public class TemplateCreateDocumentFromTemplate200ResponseRecipientsInner implem public static final String JSON_PROPERTY_NAME = "name"; private String name; - /** Gets or Sets role */ + /** + * Gets or Sets role + */ public enum RoleEnum { CC("CC"), - + SIGNER("SIGNER"), - + VIEWER("VIEWER"), - + APPROVER("APPROVER"), - + ASSISTANT("ASSISTANT"); private String value; @@ -94,7 +101,8 @@ public static RoleEnum fromValue(String value) { public static final String JSON_PROPERTY_TOKEN = "token"; private String token; - public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner() {} + public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner() { + } public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner id(BigDecimal id) { this.id = id; @@ -103,7 +111,6 @@ public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner id(BigDecima /** * Get id - * * @return id */ @jakarta.annotation.Nullable @@ -113,12 +120,14 @@ public BigDecimal getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(BigDecimal id) { this.id = id; } + public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner email(String email) { this.email = email; return this; @@ -126,7 +135,6 @@ public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner email(String /** * Get email - * * @return email */ @jakarta.annotation.Nullable @@ -136,12 +144,14 @@ public String getEmail() { return email; } + @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setEmail(String email) { this.email = email; } + public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner name(String name) { this.name = name; return this; @@ -149,7 +159,6 @@ public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner name(String /** * Get name - * * @return name */ @jakarta.annotation.Nullable @@ -159,12 +168,14 @@ public String getName() { return name; } + @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setName(String name) { this.name = name; } + public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner role(RoleEnum role) { this.role = role; return this; @@ -172,7 +183,6 @@ public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner role(RoleEnu /** * Get role - * * @return role */ @jakarta.annotation.Nullable @@ -182,12 +192,14 @@ public RoleEnum getRole() { return role; } + @JsonProperty(JSON_PROPERTY_ROLE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setRole(RoleEnum role) { this.role = role; } + public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner token(String token) { this.token = token; return this; @@ -195,7 +207,6 @@ public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner token(String /** * Get token - * * @return token */ @jakarta.annotation.Nullable @@ -205,15 +216,16 @@ public String getToken() { return token; } + @JsonProperty(JSON_PROPERTY_TOKEN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setToken(String token) { this.token = token; } + /** - * Return true if this template_createDocumentFromTemplate_200_response_recipients_inner object is - * equal to o. + * Return true if this template_createDocumentFromTemplate_200_response_recipients_inner object is equal to o. */ @Override public boolean equals(Object o) { @@ -223,18 +235,12 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateCreateDocumentFromTemplate200ResponseRecipientsInner - templateCreateDocumentFromTemplate200ResponseRecipientsInner = - (TemplateCreateDocumentFromTemplate200ResponseRecipientsInner) o; - return Objects.equals(this.id, templateCreateDocumentFromTemplate200ResponseRecipientsInner.id) - && Objects.equals( - this.email, templateCreateDocumentFromTemplate200ResponseRecipientsInner.email) - && Objects.equals( - this.name, templateCreateDocumentFromTemplate200ResponseRecipientsInner.name) - && Objects.equals( - this.role, templateCreateDocumentFromTemplate200ResponseRecipientsInner.role) - && Objects.equals( - this.token, templateCreateDocumentFromTemplate200ResponseRecipientsInner.token); + TemplateCreateDocumentFromTemplate200ResponseRecipientsInner templateCreateDocumentFromTemplate200ResponseRecipientsInner = (TemplateCreateDocumentFromTemplate200ResponseRecipientsInner) o; + return Objects.equals(this.id, templateCreateDocumentFromTemplate200ResponseRecipientsInner.id) && + Objects.equals(this.email, templateCreateDocumentFromTemplate200ResponseRecipientsInner.email) && + Objects.equals(this.name, templateCreateDocumentFromTemplate200ResponseRecipientsInner.name) && + Objects.equals(this.role, templateCreateDocumentFromTemplate200ResponseRecipientsInner.role) && + Objects.equals(this.token, templateCreateDocumentFromTemplate200ResponseRecipientsInner.token); } @Override @@ -256,7 +262,8 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -299,59 +306,30 @@ public String toUrlQueryString(String prefix) { // add `id` to the URL query string if (getId() != null) { - joiner.add( - String.format( - "%sid%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `email` to the URL query string if (getEmail() != null) { - joiner.add( - String.format( - "%semail%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getEmail()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%semail%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getEmail()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `name` to the URL query string if (getName() != null) { - joiner.add( - String.format( - "%sname%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getName()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `role` to the URL query string if (getRole() != null) { - joiner.add( - String.format( - "%srole%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getRole()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%srole%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getRole()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `token` to the URL query string if (getToken() != null) { - joiner.add( - String.format( - "%stoken%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getToken()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%stoken%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getToken()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); } } + diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequest.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequest.java index 5432a1bb5..c7166ef52 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequest.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequest.java @@ -3,38 +3,47 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.model; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import java.math.BigDecimal; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; -import java.util.Objects; -import java.util.StringJoiner; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequestRecipientsInner; +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + -/** TemplateCreateDocumentFromTemplateRequest */ +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +/** + * TemplateCreateDocumentFromTemplateRequest + */ @JsonPropertyOrder({ TemplateCreateDocumentFromTemplateRequest.JSON_PROPERTY_TEMPLATE_ID, TemplateCreateDocumentFromTemplateRequest.JSON_PROPERTY_RECIPIENTS, TemplateCreateDocumentFromTemplateRequest.JSON_PROPERTY_PREFILL_FIELDS }) -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class TemplateCreateDocumentFromTemplateRequest implements Serializable { private static final long serialVersionUID = 1L; @@ -42,14 +51,13 @@ public class TemplateCreateDocumentFromTemplateRequest implements Serializable { private BigDecimal templateId; public static final String JSON_PROPERTY_RECIPIENTS = "recipients"; - private List recipients = - new ArrayList<>(); + private List recipients = new ArrayList<>(); public static final String JSON_PROPERTY_PREFILL_FIELDS = "prefillFields"; - private List prefillFields = - new ArrayList<>(); + private List prefillFields = new ArrayList<>(); - public TemplateCreateDocumentFromTemplateRequest() {} + public TemplateCreateDocumentFromTemplateRequest() { + } public TemplateCreateDocumentFromTemplateRequest templateId(BigDecimal templateId) { this.templateId = templateId; @@ -58,7 +66,6 @@ public TemplateCreateDocumentFromTemplateRequest templateId(BigDecimal templateI /** * Get templateId - * * @return templateId */ @jakarta.annotation.Nonnull @@ -68,20 +75,20 @@ public BigDecimal getTemplateId() { return templateId; } + @JsonProperty(JSON_PROPERTY_TEMPLATE_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setTemplateId(BigDecimal templateId) { this.templateId = templateId; } - public TemplateCreateDocumentFromTemplateRequest recipients( - List recipients) { + + public TemplateCreateDocumentFromTemplateRequest recipients(List recipients) { this.recipients = recipients; return this; } - public TemplateCreateDocumentFromTemplateRequest addRecipientsItem( - TemplateCreateDocumentFromTemplateRequestRecipientsInner recipientsItem) { + public TemplateCreateDocumentFromTemplateRequest addRecipientsItem(TemplateCreateDocumentFromTemplateRequestRecipientsInner recipientsItem) { if (this.recipients == null) { this.recipients = new ArrayList<>(); } @@ -91,7 +98,6 @@ public TemplateCreateDocumentFromTemplateRequest addRecipientsItem( /** * Get recipients - * * @return recipients */ @jakarta.annotation.Nonnull @@ -101,21 +107,20 @@ public List getRecipie return recipients; } + @JsonProperty(JSON_PROPERTY_RECIPIENTS) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public void setRecipients( - List recipients) { + public void setRecipients(List recipients) { this.recipients = recipients; } - public TemplateCreateDocumentFromTemplateRequest prefillFields( - List prefillFields) { + + public TemplateCreateDocumentFromTemplateRequest prefillFields(List prefillFields) { this.prefillFields = prefillFields; return this; } - public TemplateCreateDocumentFromTemplateRequest addPrefillFieldsItem( - TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner prefillFieldsItem) { + public TemplateCreateDocumentFromTemplateRequest addPrefillFieldsItem(TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner prefillFieldsItem) { if (this.prefillFields == null) { this.prefillFields = new ArrayList<>(); } @@ -125,7 +130,6 @@ public TemplateCreateDocumentFromTemplateRequest addPrefillFieldsItem( /** * Get prefillFields - * * @return prefillFields */ @jakarta.annotation.Nullable @@ -135,14 +139,17 @@ public List getPref return prefillFields; } + @JsonProperty(JSON_PROPERTY_PREFILL_FIELDS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setPrefillFields( - List prefillFields) { + public void setPrefillFields(List prefillFields) { this.prefillFields = prefillFields; } - /** Return true if this template_createDocumentFromTemplate_request object is equal to o. */ + + /** + * Return true if this template_createDocumentFromTemplate_request object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -151,12 +158,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest = - (TemplateCreateDocumentFromTemplateRequest) o; - return Objects.equals(this.templateId, templateCreateDocumentFromTemplateRequest.templateId) - && Objects.equals(this.recipients, templateCreateDocumentFromTemplateRequest.recipients) - && Objects.equals( - this.prefillFields, templateCreateDocumentFromTemplateRequest.prefillFields); + TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest = (TemplateCreateDocumentFromTemplateRequest) o; + return Objects.equals(this.templateId, templateCreateDocumentFromTemplateRequest.templateId) && + Objects.equals(this.recipients, templateCreateDocumentFromTemplateRequest.recipients) && + Objects.equals(this.prefillFields, templateCreateDocumentFromTemplateRequest.prefillFields); } @Override @@ -176,7 +181,8 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -219,30 +225,15 @@ public String toUrlQueryString(String prefix) { // add `templateId` to the URL query string if (getTemplateId() != null) { - joiner.add( - String.format( - "%stemplateId%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getTemplateId()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%stemplateId%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getTemplateId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `recipients` to the URL query string if (getRecipients() != null) { for (int i = 0; i < getRecipients().size(); i++) { if (getRecipients().get(i) != null) { - joiner.add( - getRecipients() - .get(i) - .toUrlQueryString( - String.format( - "%srecipients%s%s", - prefix, - suffix, - "".equals(suffix) - ? "" - : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + joiner.add(getRecipients().get(i).toUrlQueryString(String.format("%srecipients%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } @@ -251,17 +242,8 @@ public String toUrlQueryString(String prefix) { if (getPrefillFields() != null) { for (int i = 0; i < getPrefillFields().size(); i++) { if (getPrefillFields().get(i) != null) { - joiner.add( - getPrefillFields() - .get(i) - .toUrlQueryString( - String.format( - "%sprefillFields%s%s", - prefix, - suffix, - "".equals(suffix) - ? "" - : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + joiner.add(getPrefillFields().get(i).toUrlQueryString(String.format("%sprefillFields%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } @@ -269,3 +251,4 @@ public String toUrlQueryString(String prefix) { return joiner.toString(); } } + diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.java index 370d3c169..15ad93595 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.java @@ -3,45 +3,52 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.model; -import com.fasterxml.jackson.annotation.JsonCreator; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import java.math.BigDecimal; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.Objects; -import java.util.StringJoiner; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import java.util.Arrays; +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; -/** TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner */ + +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +/** + * TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner + */ @JsonPropertyOrder({ TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.JSON_PROPERTY_ID, TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.JSON_PROPERTY_TYPE, TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.JSON_PROPERTY_VALUE }) -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner implements Serializable { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_ID = "id"; private BigDecimal id; - /** Gets or Sets type */ + /** + * Gets or Sets type + */ public enum TypeEnum { TEXT("text"); @@ -78,7 +85,8 @@ public static TypeEnum fromValue(String value) { public static final String JSON_PROPERTY_VALUE = "value"; private String value; - public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner() {} + public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner() { + } public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner id(BigDecimal id) { this.id = id; @@ -87,7 +95,6 @@ public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner id(BigDecimal /** * Get id - * * @return id */ @jakarta.annotation.Nonnull @@ -97,12 +104,14 @@ public BigDecimal getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } + public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner type(TypeEnum type) { this.type = type; return this; @@ -110,7 +119,6 @@ public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner type(TypeEnum /** * Get type - * * @return type */ @jakarta.annotation.Nonnull @@ -120,12 +128,14 @@ public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setType(TypeEnum type) { this.type = type; } + public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner value(String value) { this.value = value; return this; @@ -133,7 +143,6 @@ public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner value(String /** * Get value - * * @return value */ @jakarta.annotation.Nonnull @@ -143,15 +152,16 @@ public String getValue() { return value; } + @JsonProperty(JSON_PROPERTY_VALUE) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setValue(String value) { this.value = value; } + /** - * Return true if this template_createDocumentFromTemplate_request_prefillFields_inner object is - * equal to o. + * Return true if this template_createDocumentFromTemplate_request_prefillFields_inner object is equal to o. */ @Override public boolean equals(Object o) { @@ -161,14 +171,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner - templateCreateDocumentFromTemplateRequestPrefillFieldsInner = - (TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner) o; - return Objects.equals(this.id, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.id) - && Objects.equals( - this.type, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.type) - && Objects.equals( - this.value, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.value); + TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner templateCreateDocumentFromTemplateRequestPrefillFieldsInner = (TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner) o; + return Objects.equals(this.id, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.id) && + Objects.equals(this.type, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.type) && + Objects.equals(this.value, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.value); } @Override @@ -188,7 +194,8 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -231,37 +238,20 @@ public String toUrlQueryString(String prefix) { // add `id` to the URL query string if (getId() != null) { - joiner.add( - String.format( - "%sid%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `type` to the URL query string if (getType() != null) { - joiner.add( - String.format( - "%stype%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getType()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `value` to the URL query string if (getValue() != null) { - joiner.add( - String.format( - "%svalue%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getValue()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%svalue%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); } } + diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestRecipientsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestRecipientsInner.java index a302f033b..0bda3e528 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestRecipientsInner.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestRecipientsInner.java @@ -3,36 +3,43 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.model; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.io.Serializable; -import java.math.BigDecimal; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; -import java.util.Objects; import java.util.StringJoiner; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.math.BigDecimal; +import java.util.Arrays; +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; -/** TemplateCreateDocumentFromTemplateRequestRecipientsInner */ + +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +/** + * TemplateCreateDocumentFromTemplateRequestRecipientsInner + */ @JsonPropertyOrder({ TemplateCreateDocumentFromTemplateRequestRecipientsInner.JSON_PROPERTY_ID, TemplateCreateDocumentFromTemplateRequestRecipientsInner.JSON_PROPERTY_EMAIL, TemplateCreateDocumentFromTemplateRequestRecipientsInner.JSON_PROPERTY_NAME }) -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class TemplateCreateDocumentFromTemplateRequestRecipientsInner implements Serializable { private static final long serialVersionUID = 1L; @@ -45,7 +52,8 @@ public class TemplateCreateDocumentFromTemplateRequestRecipientsInner implements public static final String JSON_PROPERTY_NAME = "name"; private String name; - public TemplateCreateDocumentFromTemplateRequestRecipientsInner() {} + public TemplateCreateDocumentFromTemplateRequestRecipientsInner() { + } public TemplateCreateDocumentFromTemplateRequestRecipientsInner id(BigDecimal id) { this.id = id; @@ -54,7 +62,6 @@ public TemplateCreateDocumentFromTemplateRequestRecipientsInner id(BigDecimal id /** * Get id - * * @return id */ @jakarta.annotation.Nonnull @@ -64,12 +71,14 @@ public BigDecimal getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } + public TemplateCreateDocumentFromTemplateRequestRecipientsInner email(String email) { this.email = email; return this; @@ -77,7 +86,6 @@ public TemplateCreateDocumentFromTemplateRequestRecipientsInner email(String ema /** * Get email - * * @return email */ @jakarta.annotation.Nonnull @@ -87,12 +95,14 @@ public String getEmail() { return email; } + @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setEmail(String email) { this.email = email; } + public TemplateCreateDocumentFromTemplateRequestRecipientsInner name(String name) { this.name = name; return this; @@ -100,7 +110,6 @@ public TemplateCreateDocumentFromTemplateRequestRecipientsInner name(String name /** * Get name - * * @return name */ @jakarta.annotation.Nullable @@ -110,15 +119,16 @@ public String getName() { return name; } + @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setName(String name) { this.name = name; } + /** - * Return true if this template_createDocumentFromTemplate_request_recipients_inner object is - * equal to o. + * Return true if this template_createDocumentFromTemplate_request_recipients_inner object is equal to o. */ @Override public boolean equals(Object o) { @@ -128,13 +138,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateCreateDocumentFromTemplateRequestRecipientsInner - templateCreateDocumentFromTemplateRequestRecipientsInner = - (TemplateCreateDocumentFromTemplateRequestRecipientsInner) o; - return Objects.equals(this.id, templateCreateDocumentFromTemplateRequestRecipientsInner.id) - && Objects.equals( - this.email, templateCreateDocumentFromTemplateRequestRecipientsInner.email) - && Objects.equals(this.name, templateCreateDocumentFromTemplateRequestRecipientsInner.name); + TemplateCreateDocumentFromTemplateRequestRecipientsInner templateCreateDocumentFromTemplateRequestRecipientsInner = (TemplateCreateDocumentFromTemplateRequestRecipientsInner) o; + return Objects.equals(this.id, templateCreateDocumentFromTemplateRequestRecipientsInner.id) && + Objects.equals(this.email, templateCreateDocumentFromTemplateRequestRecipientsInner.email) && + Objects.equals(this.name, templateCreateDocumentFromTemplateRequestRecipientsInner.name); } @Override @@ -154,7 +161,8 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -197,37 +205,20 @@ public String toUrlQueryString(String prefix) { // add `id` to the URL query string if (getId() != null) { - joiner.add( - String.format( - "%sid%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `email` to the URL query string if (getEmail() != null) { - joiner.add( - String.format( - "%semail%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getEmail()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%semail%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getEmail()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `name` to the URL query string if (getName() != null) { - joiner.add( - String.format( - "%sname%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getName()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); } } + diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200Response.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200Response.java index 1d7d81903..898af2217 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200Response.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200Response.java @@ -3,46 +3,58 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.model; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; -import java.util.Objects; -import java.util.StringJoiner; +import school.hei.haapi.service.documenso.gen.model.TemplateFindTemplates200ResponseDataInner; +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; -/** TemplateFindTemplates200Response */ -@JsonPropertyOrder({TemplateFindTemplates200Response.JSON_PROPERTY_DATA}) -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") + +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +/** + * TemplateFindTemplates200Response + */ +@JsonPropertyOrder({ + TemplateFindTemplates200Response.JSON_PROPERTY_DATA +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class TemplateFindTemplates200Response implements Serializable { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_DATA = "data"; private List data = new ArrayList<>(); - public TemplateFindTemplates200Response() {} + public TemplateFindTemplates200Response() { + } - public TemplateFindTemplates200Response data( - List data) { + public TemplateFindTemplates200Response data(List data) { this.data = data; return this; } - public TemplateFindTemplates200Response addDataItem( - TemplateFindTemplates200ResponseDataInner dataItem) { + public TemplateFindTemplates200Response addDataItem(TemplateFindTemplates200ResponseDataInner dataItem) { if (this.data == null) { this.data = new ArrayList<>(); } @@ -52,7 +64,6 @@ public TemplateFindTemplates200Response addDataItem( /** * Get data - * * @return data */ @jakarta.annotation.Nonnull @@ -62,13 +73,17 @@ public List getData() { return data; } + @JsonProperty(JSON_PROPERTY_DATA) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setData(List data) { this.data = data; } - /** Return true if this template_findTemplates_200_response object is equal to o. */ + + /** + * Return true if this template_findTemplates_200_response object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -77,8 +92,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateFindTemplates200Response templateFindTemplates200Response = - (TemplateFindTemplates200Response) o; + TemplateFindTemplates200Response templateFindTemplates200Response = (TemplateFindTemplates200Response) o; return Objects.equals(this.data, templateFindTemplates200Response.data); } @@ -97,7 +111,8 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -142,17 +157,8 @@ public String toUrlQueryString(String prefix) { if (getData() != null) { for (int i = 0; i < getData().size(); i++) { if (getData().get(i) != null) { - joiner.add( - getData() - .get(i) - .toUrlQueryString( - String.format( - "%sdata%s%s", - prefix, - suffix, - "".equals(suffix) - ? "" - : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + joiner.add(getData().get(i).toUrlQueryString(String.format("%sdata%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } @@ -160,3 +166,4 @@ public String toUrlQueryString(String prefix) { return joiner.toString(); } } + diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200ResponseDataInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200ResponseDataInner.java index b836fb4ab..0c3e20580 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200ResponseDataInner.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200ResponseDataInner.java @@ -3,29 +3,37 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.model; -import com.fasterxml.jackson.annotation.JsonCreator; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import java.math.BigDecimal; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.Objects; -import java.util.StringJoiner; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import java.util.Arrays; +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + -/** TemplateFindTemplates200ResponseDataInner */ +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +/** + * TemplateFindTemplates200ResponseDataInner + */ @JsonPropertyOrder({ TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_ID, TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_TITLE, @@ -34,10 +42,7 @@ TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_CREATED_AT, TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_UPDATED_AT }) -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class TemplateFindTemplates200ResponseDataInner implements Serializable { private static final long serialVersionUID = 1L; @@ -47,12 +52,14 @@ public class TemplateFindTemplates200ResponseDataInner implements Serializable { public static final String JSON_PROPERTY_TITLE = "title"; private String title; - /** Gets or Sets type */ + /** + * Gets or Sets type + */ public enum TypeEnum { PUBLIC("PUBLIC"), - + PRIVATE("PRIVATE"), - + ORGANISATION("ORGANISATION"); private String value; @@ -94,7 +101,8 @@ public static TypeEnum fromValue(String value) { public static final String JSON_PROPERTY_UPDATED_AT = "updatedAt"; private String updatedAt; - public TemplateFindTemplates200ResponseDataInner() {} + public TemplateFindTemplates200ResponseDataInner() { + } public TemplateFindTemplates200ResponseDataInner id(BigDecimal id) { this.id = id; @@ -103,7 +111,6 @@ public TemplateFindTemplates200ResponseDataInner id(BigDecimal id) { /** * Get id - * * @return id */ @jakarta.annotation.Nonnull @@ -113,12 +120,14 @@ public BigDecimal getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } + public TemplateFindTemplates200ResponseDataInner title(String title) { this.title = title; return this; @@ -126,7 +135,6 @@ public TemplateFindTemplates200ResponseDataInner title(String title) { /** * Get title - * * @return title */ @jakarta.annotation.Nonnull @@ -136,12 +144,14 @@ public String getTitle() { return title; } + @JsonProperty(JSON_PROPERTY_TITLE) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setTitle(String title) { this.title = title; } + public TemplateFindTemplates200ResponseDataInner type(TypeEnum type) { this.type = type; return this; @@ -149,7 +159,6 @@ public TemplateFindTemplates200ResponseDataInner type(TypeEnum type) { /** * Get type - * * @return type */ @jakarta.annotation.Nullable @@ -159,12 +168,14 @@ public TypeEnum getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } + public TemplateFindTemplates200ResponseDataInner userId(BigDecimal userId) { this.userId = userId; return this; @@ -172,7 +183,6 @@ public TemplateFindTemplates200ResponseDataInner userId(BigDecimal userId) { /** * Get userId - * * @return userId */ @jakarta.annotation.Nonnull @@ -182,12 +192,14 @@ public BigDecimal getUserId() { return userId; } + @JsonProperty(JSON_PROPERTY_USER_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setUserId(BigDecimal userId) { this.userId = userId; } + public TemplateFindTemplates200ResponseDataInner createdAt(String createdAt) { this.createdAt = createdAt; return this; @@ -195,7 +207,6 @@ public TemplateFindTemplates200ResponseDataInner createdAt(String createdAt) { /** * Get createdAt - * * @return createdAt */ @jakarta.annotation.Nullable @@ -205,12 +216,14 @@ public String getCreatedAt() { return createdAt; } + @JsonProperty(JSON_PROPERTY_CREATED_AT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCreatedAt(String createdAt) { this.createdAt = createdAt; } + public TemplateFindTemplates200ResponseDataInner updatedAt(String updatedAt) { this.updatedAt = updatedAt; return this; @@ -218,7 +231,6 @@ public TemplateFindTemplates200ResponseDataInner updatedAt(String updatedAt) { /** * Get updatedAt - * * @return updatedAt */ @jakarta.annotation.Nullable @@ -228,13 +240,17 @@ public String getUpdatedAt() { return updatedAt; } + @JsonProperty(JSON_PROPERTY_UPDATED_AT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setUpdatedAt(String updatedAt) { this.updatedAt = updatedAt; } - /** Return true if this template_findTemplates_200_response_data_inner object is equal to o. */ + + /** + * Return true if this template_findTemplates_200_response_data_inner object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -243,14 +259,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateFindTemplates200ResponseDataInner templateFindTemplates200ResponseDataInner = - (TemplateFindTemplates200ResponseDataInner) o; - return Objects.equals(this.id, templateFindTemplates200ResponseDataInner.id) - && Objects.equals(this.title, templateFindTemplates200ResponseDataInner.title) - && Objects.equals(this.type, templateFindTemplates200ResponseDataInner.type) - && Objects.equals(this.userId, templateFindTemplates200ResponseDataInner.userId) - && Objects.equals(this.createdAt, templateFindTemplates200ResponseDataInner.createdAt) - && Objects.equals(this.updatedAt, templateFindTemplates200ResponseDataInner.updatedAt); + TemplateFindTemplates200ResponseDataInner templateFindTemplates200ResponseDataInner = (TemplateFindTemplates200ResponseDataInner) o; + return Objects.equals(this.id, templateFindTemplates200ResponseDataInner.id) && + Objects.equals(this.title, templateFindTemplates200ResponseDataInner.title) && + Objects.equals(this.type, templateFindTemplates200ResponseDataInner.type) && + Objects.equals(this.userId, templateFindTemplates200ResponseDataInner.userId) && + Objects.equals(this.createdAt, templateFindTemplates200ResponseDataInner.createdAt) && + Objects.equals(this.updatedAt, templateFindTemplates200ResponseDataInner.updatedAt); } @Override @@ -273,7 +288,8 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -316,70 +332,35 @@ public String toUrlQueryString(String prefix) { // add `id` to the URL query string if (getId() != null) { - joiner.add( - String.format( - "%sid%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `title` to the URL query string if (getTitle() != null) { - joiner.add( - String.format( - "%stitle%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%stitle%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `type` to the URL query string if (getType() != null) { - joiner.add( - String.format( - "%stype%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getType()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `userId` to the URL query string if (getUserId() != null) { - joiner.add( - String.format( - "%suserId%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getUserId()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%suserId%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getUserId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `createdAt` to the URL query string if (getCreatedAt() != null) { - joiner.add( - String.format( - "%screatedAt%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getCreatedAt()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%screatedAt%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getCreatedAt()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `updatedAt` to the URL query string if (getUpdatedAt() != null) { - joiner.add( - String.format( - "%supdatedAt%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getUpdatedAt()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%supdatedAt%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getUpdatedAt()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); } } + diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200Response.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200Response.java index 255e7e180..2f7009a30 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200Response.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200Response.java @@ -3,29 +3,41 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.model; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; import java.math.BigDecimal; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; -import java.util.Objects; -import java.util.StringJoiner; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200ResponseFieldsInner; +import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200ResponseRecipientsInner; +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; -/** TemplateGetTemplateById200Response */ + +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +/** + * TemplateGetTemplateById200Response + */ @JsonPropertyOrder({ TemplateGetTemplateById200Response.JSON_PROPERTY_ID, TemplateGetTemplateById200Response.JSON_PROPERTY_TITLE, @@ -33,10 +45,7 @@ TemplateGetTemplateById200Response.JSON_PROPERTY_RECIPIENTS, TemplateGetTemplateById200Response.JSON_PROPERTY_FIELDS }) -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class TemplateGetTemplateById200Response implements Serializable { private static final long serialVersionUID = 1L; @@ -55,7 +64,8 @@ public class TemplateGetTemplateById200Response implements Serializable { public static final String JSON_PROPERTY_FIELDS = "fields"; private List fields = new ArrayList<>(); - public TemplateGetTemplateById200Response() {} + public TemplateGetTemplateById200Response() { + } public TemplateGetTemplateById200Response id(BigDecimal id) { this.id = id; @@ -64,7 +74,6 @@ public TemplateGetTemplateById200Response id(BigDecimal id) { /** * Get id - * * @return id */ @jakarta.annotation.Nonnull @@ -74,12 +83,14 @@ public BigDecimal getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } + public TemplateGetTemplateById200Response title(String title) { this.title = title; return this; @@ -87,7 +98,6 @@ public TemplateGetTemplateById200Response title(String title) { /** * Get title - * * @return title */ @jakarta.annotation.Nonnull @@ -97,12 +107,14 @@ public String getTitle() { return title; } + @JsonProperty(JSON_PROPERTY_TITLE) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setTitle(String title) { this.title = title; } + public TemplateGetTemplateById200Response userId(BigDecimal userId) { this.userId = userId; return this; @@ -110,7 +122,6 @@ public TemplateGetTemplateById200Response userId(BigDecimal userId) { /** * Get userId - * * @return userId */ @jakarta.annotation.Nullable @@ -120,20 +131,20 @@ public BigDecimal getUserId() { return userId; } + @JsonProperty(JSON_PROPERTY_USER_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setUserId(BigDecimal userId) { this.userId = userId; } - public TemplateGetTemplateById200Response recipients( - List recipients) { + + public TemplateGetTemplateById200Response recipients(List recipients) { this.recipients = recipients; return this; } - public TemplateGetTemplateById200Response addRecipientsItem( - TemplateGetTemplateById200ResponseRecipientsInner recipientsItem) { + public TemplateGetTemplateById200Response addRecipientsItem(TemplateGetTemplateById200ResponseRecipientsInner recipientsItem) { if (this.recipients == null) { this.recipients = new ArrayList<>(); } @@ -143,7 +154,6 @@ public TemplateGetTemplateById200Response addRecipientsItem( /** * Get recipients - * * @return recipients */ @jakarta.annotation.Nonnull @@ -153,20 +163,20 @@ public List getRecipients() { return recipients; } + @JsonProperty(JSON_PROPERTY_RECIPIENTS) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setRecipients(List recipients) { this.recipients = recipients; } - public TemplateGetTemplateById200Response fields( - List fields) { + + public TemplateGetTemplateById200Response fields(List fields) { this.fields = fields; return this; } - public TemplateGetTemplateById200Response addFieldsItem( - TemplateGetTemplateById200ResponseFieldsInner fieldsItem) { + public TemplateGetTemplateById200Response addFieldsItem(TemplateGetTemplateById200ResponseFieldsInner fieldsItem) { if (this.fields == null) { this.fields = new ArrayList<>(); } @@ -176,7 +186,6 @@ public TemplateGetTemplateById200Response addFieldsItem( /** * Get fields - * * @return fields */ @jakarta.annotation.Nullable @@ -186,13 +195,17 @@ public List getFields() { return fields; } + @JsonProperty(JSON_PROPERTY_FIELDS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setFields(List fields) { this.fields = fields; } - /** Return true if this template_getTemplateById_200_response object is equal to o. */ + + /** + * Return true if this template_getTemplateById_200_response object is equal to o. + */ @Override public boolean equals(Object o) { if (this == o) { @@ -201,13 +214,12 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateGetTemplateById200Response templateGetTemplateById200Response = - (TemplateGetTemplateById200Response) o; - return Objects.equals(this.id, templateGetTemplateById200Response.id) - && Objects.equals(this.title, templateGetTemplateById200Response.title) - && Objects.equals(this.userId, templateGetTemplateById200Response.userId) - && Objects.equals(this.recipients, templateGetTemplateById200Response.recipients) - && Objects.equals(this.fields, templateGetTemplateById200Response.fields); + TemplateGetTemplateById200Response templateGetTemplateById200Response = (TemplateGetTemplateById200Response) o; + return Objects.equals(this.id, templateGetTemplateById200Response.id) && + Objects.equals(this.title, templateGetTemplateById200Response.title) && + Objects.equals(this.userId, templateGetTemplateById200Response.userId) && + Objects.equals(this.recipients, templateGetTemplateById200Response.recipients) && + Objects.equals(this.fields, templateGetTemplateById200Response.fields); } @Override @@ -229,7 +241,8 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -272,52 +285,25 @@ public String toUrlQueryString(String prefix) { // add `id` to the URL query string if (getId() != null) { - joiner.add( - String.format( - "%sid%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `title` to the URL query string if (getTitle() != null) { - joiner.add( - String.format( - "%stitle%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%stitle%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `userId` to the URL query string if (getUserId() != null) { - joiner.add( - String.format( - "%suserId%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getUserId()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%suserId%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getUserId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `recipients` to the URL query string if (getRecipients() != null) { for (int i = 0; i < getRecipients().size(); i++) { if (getRecipients().get(i) != null) { - joiner.add( - getRecipients() - .get(i) - .toUrlQueryString( - String.format( - "%srecipients%s%s", - prefix, - suffix, - "".equals(suffix) - ? "" - : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + joiner.add(getRecipients().get(i).toUrlQueryString(String.format("%srecipients%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } @@ -326,17 +312,8 @@ public String toUrlQueryString(String prefix) { if (getFields() != null) { for (int i = 0; i < getFields().size(); i++) { if (getFields().get(i) != null) { - joiner.add( - getFields() - .get(i) - .toUrlQueryString( - String.format( - "%sfields%s%s", - prefix, - suffix, - "".equals(suffix) - ? "" - : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + joiner.add(getFields().get(i).toUrlQueryString(String.format("%sfields%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } @@ -344,3 +321,4 @@ public String toUrlQueryString(String prefix) { return joiner.toString(); } } + diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseFieldsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseFieldsInner.java index 224e39cda..953063c78 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseFieldsInner.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseFieldsInner.java @@ -3,37 +3,46 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.model; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.io.Serializable; -import java.math.BigDecimal; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; -import java.util.Objects; import java.util.StringJoiner; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.math.BigDecimal; +import java.util.Arrays; +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; -/** TemplateGetTemplateById200ResponseFieldsInner */ + +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +/** + * TemplateGetTemplateById200ResponseFieldsInner + */ @JsonPropertyOrder({ TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_ID, TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_TYPE, TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_LABEL, - TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_PLACEHOLDER + TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_PLACEHOLDER, + TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_PAGE, + TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_POSITION_Y }) -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class TemplateGetTemplateById200ResponseFieldsInner implements Serializable { private static final long serialVersionUID = 1L; @@ -49,7 +58,14 @@ public class TemplateGetTemplateById200ResponseFieldsInner implements Serializab public static final String JSON_PROPERTY_PLACEHOLDER = "placeholder"; private String placeholder; - public TemplateGetTemplateById200ResponseFieldsInner() {} + public static final String JSON_PROPERTY_PAGE = "page"; + private BigDecimal page; + + public static final String JSON_PROPERTY_POSITION_Y = "positionY"; + private BigDecimal positionY; + + public TemplateGetTemplateById200ResponseFieldsInner() { + } public TemplateGetTemplateById200ResponseFieldsInner id(BigDecimal id) { this.id = id; @@ -58,7 +74,6 @@ public TemplateGetTemplateById200ResponseFieldsInner id(BigDecimal id) { /** * Get id - * * @return id */ @jakarta.annotation.Nonnull @@ -68,12 +83,14 @@ public BigDecimal getId() { return id; } + @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } + public TemplateGetTemplateById200ResponseFieldsInner type(String type) { this.type = type; return this; @@ -81,7 +98,6 @@ public TemplateGetTemplateById200ResponseFieldsInner type(String type) { /** * Get type - * * @return type */ @jakarta.annotation.Nonnull @@ -91,12 +107,14 @@ public String getType() { return type; } + @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setType(String type) { this.type = type; } + public TemplateGetTemplateById200ResponseFieldsInner label(String label) { this.label = label; return this; @@ -104,7 +122,6 @@ public TemplateGetTemplateById200ResponseFieldsInner label(String label) { /** * Get label - * * @return label */ @jakarta.annotation.Nullable @@ -114,12 +131,14 @@ public String getLabel() { return label; } + @JsonProperty(JSON_PROPERTY_LABEL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setLabel(String label) { this.label = label; } + public TemplateGetTemplateById200ResponseFieldsInner placeholder(String placeholder) { this.placeholder = placeholder; return this; @@ -127,7 +146,6 @@ public TemplateGetTemplateById200ResponseFieldsInner placeholder(String placehol /** * Get placeholder - * * @return placeholder */ @jakarta.annotation.Nullable @@ -137,12 +155,62 @@ public String getPlaceholder() { return placeholder; } + @JsonProperty(JSON_PROPERTY_PLACEHOLDER) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPlaceholder(String placeholder) { this.placeholder = placeholder; } + + public TemplateGetTemplateById200ResponseFieldsInner page(BigDecimal page) { + this.page = page; + return this; + } + + /** + * Get page + * @return page + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public BigDecimal getPage() { + return page; + } + + + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPage(BigDecimal page) { + this.page = page; + } + + + public TemplateGetTemplateById200ResponseFieldsInner positionY(BigDecimal positionY) { + this.positionY = positionY; + return this; + } + + /** + * Get positionY + * @return positionY + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_POSITION_Y) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public BigDecimal getPositionY() { + return positionY; + } + + + @JsonProperty(JSON_PROPERTY_POSITION_Y) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPositionY(BigDecimal positionY) { + this.positionY = positionY; + } + + /** * Return true if this template_getTemplateById_200_response_fields_inner object is equal to o. */ @@ -154,18 +222,18 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateGetTemplateById200ResponseFieldsInner templateGetTemplateById200ResponseFieldsInner = - (TemplateGetTemplateById200ResponseFieldsInner) o; - return Objects.equals(this.id, templateGetTemplateById200ResponseFieldsInner.id) - && Objects.equals(this.type, templateGetTemplateById200ResponseFieldsInner.type) - && Objects.equals(this.label, templateGetTemplateById200ResponseFieldsInner.label) - && Objects.equals( - this.placeholder, templateGetTemplateById200ResponseFieldsInner.placeholder); + TemplateGetTemplateById200ResponseFieldsInner templateGetTemplateById200ResponseFieldsInner = (TemplateGetTemplateById200ResponseFieldsInner) o; + return Objects.equals(this.id, templateGetTemplateById200ResponseFieldsInner.id) && + Objects.equals(this.type, templateGetTemplateById200ResponseFieldsInner.type) && + Objects.equals(this.label, templateGetTemplateById200ResponseFieldsInner.label) && + Objects.equals(this.placeholder, templateGetTemplateById200ResponseFieldsInner.placeholder) && + Objects.equals(this.page, templateGetTemplateById200ResponseFieldsInner.page) && + Objects.equals(this.positionY, templateGetTemplateById200ResponseFieldsInner.positionY); } @Override public int hashCode() { - return Objects.hash(id, type, label, placeholder); + return Objects.hash(id, type, label, placeholder, page, positionY); } @Override @@ -176,12 +244,15 @@ public String toString() { sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" label: ").append(toIndentedString(label)).append("\n"); sb.append(" placeholder: ").append(toIndentedString(placeholder)).append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" positionY: ").append(toIndentedString(positionY)).append("\n"); sb.append("}"); return sb.toString(); } /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -224,48 +295,35 @@ public String toUrlQueryString(String prefix) { // add `id` to the URL query string if (getId() != null) { - joiner.add( - String.format( - "%sid%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `type` to the URL query string if (getType() != null) { - joiner.add( - String.format( - "%stype%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getType()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `label` to the URL query string if (getLabel() != null) { - joiner.add( - String.format( - "%slabel%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getLabel()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%slabel%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getLabel()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `placeholder` to the URL query string if (getPlaceholder() != null) { - joiner.add( - String.format( - "%splaceholder%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getPlaceholder()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%splaceholder%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getPlaceholder()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `page` to the URL query string + if (getPage() != null) { + joiner.add(String.format("%spage%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getPage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `positionY` to the URL query string + if (getPositionY() != null) { + joiner.add(String.format("%spositionY%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getPositionY()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); } } + diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseRecipientsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseRecipientsInner.java index 4db905f43..2c9dcf816 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseRecipientsInner.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseRecipientsInner.java @@ -3,55 +3,62 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ + package school.hei.haapi.service.documenso.gen.model; -import com.fasterxml.jackson.annotation.JsonCreator; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import java.math.BigDecimal; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.Objects; -import java.util.StringJoiner; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import java.util.Arrays; +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + -/** TemplateGetTemplateById200ResponseRecipientsInner */ +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +/** + * TemplateGetTemplateById200ResponseRecipientsInner + */ @JsonPropertyOrder({ TemplateGetTemplateById200ResponseRecipientsInner.JSON_PROPERTY_ID, TemplateGetTemplateById200ResponseRecipientsInner.JSON_PROPERTY_ROLE, TemplateGetTemplateById200ResponseRecipientsInner.JSON_PROPERTY_EMAIL, TemplateGetTemplateById200ResponseRecipientsInner.JSON_PROPERTY_NAME }) -@jakarta.annotation.Generated( - value = "org.openapitools.codegen.languages.JavaClientCodegen", - date = "2026-08-05T19:23:09.660393+03:00[Indian/Antananarivo]", - comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") public class TemplateGetTemplateById200ResponseRecipientsInner implements Serializable { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_ID = "id"; private BigDecimal id; - /** Gets or Sets role */ + /** + * Gets or Sets role + */ public enum RoleEnum { CC("CC"), - + SIGNER("SIGNER"), - + VIEWER("VIEWER"), - + APPROVER("APPROVER"), - + ASSISTANT("ASSISTANT"); private String value; @@ -90,7 +97,8 @@ public static RoleEnum fromValue(String value) { public static final String JSON_PROPERTY_NAME = "name"; private String name; - public TemplateGetTemplateById200ResponseRecipientsInner() {} + public TemplateGetTemplateById200ResponseRecipientsInner() { + } public TemplateGetTemplateById200ResponseRecipientsInner id(BigDecimal id) { this.id = id; @@ -99,7 +107,6 @@ public TemplateGetTemplateById200ResponseRecipientsInner id(BigDecimal id) { /** * Get id - * * @return id */ @jakarta.annotation.Nonnull @@ -122,7 +129,6 @@ public TemplateGetTemplateById200ResponseRecipientsInner role(RoleEnum role) { /** * Get role - * * @return role */ @jakarta.annotation.Nonnull @@ -145,7 +151,6 @@ public TemplateGetTemplateById200ResponseRecipientsInner email(String email) { /** * Get email - * * @return email */ @jakarta.annotation.Nullable @@ -155,12 +160,14 @@ public String getEmail() { return email; } + @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setEmail(String email) { this.email = email; } + public TemplateGetTemplateById200ResponseRecipientsInner name(String name) { this.name = name; return this; @@ -168,7 +175,6 @@ public TemplateGetTemplateById200ResponseRecipientsInner name(String name) { /** * Get name - * * @return name */ @jakarta.annotation.Nullable @@ -178,15 +184,16 @@ public String getName() { return name; } + @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setName(String name) { this.name = name; } + /** - * Return true if this template_getTemplateById_200_response_recipients_inner object is equal to - * o. + * Return true if this template_getTemplateById_200_response_recipients_inner object is equal to o. */ @Override public boolean equals(Object o) { @@ -196,13 +203,11 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateGetTemplateById200ResponseRecipientsInner - templateGetTemplateById200ResponseRecipientsInner = - (TemplateGetTemplateById200ResponseRecipientsInner) o; - return Objects.equals(this.id, templateGetTemplateById200ResponseRecipientsInner.id) - && Objects.equals(this.role, templateGetTemplateById200ResponseRecipientsInner.role) - && Objects.equals(this.email, templateGetTemplateById200ResponseRecipientsInner.email) - && Objects.equals(this.name, templateGetTemplateById200ResponseRecipientsInner.name); + TemplateGetTemplateById200ResponseRecipientsInner templateGetTemplateById200ResponseRecipientsInner = (TemplateGetTemplateById200ResponseRecipientsInner) o; + return Objects.equals(this.id, templateGetTemplateById200ResponseRecipientsInner.id) && + Objects.equals(this.role, templateGetTemplateById200ResponseRecipientsInner.role) && + Objects.equals(this.email, templateGetTemplateById200ResponseRecipientsInner.email) && + Objects.equals(this.name, templateGetTemplateById200ResponseRecipientsInner.name); } @Override @@ -223,7 +228,8 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -266,48 +272,24 @@ public String toUrlQueryString(String prefix) { // add `id` to the URL query string if (getId() != null) { - joiner.add( - String.format( - "%sid%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `role` to the URL query string if (getRole() != null) { - joiner.add( - String.format( - "%srole%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getRole()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%srole%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getRole()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `email` to the URL query string if (getEmail() != null) { - joiner.add( - String.format( - "%semail%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getEmail()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%semail%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getEmail()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `name` to the URL query string if (getName() != null) { - joiner.add( - String.format( - "%sname%s=%s", - prefix, - suffix, - URLEncoder.encode(ApiClient.valueToString(getName()), StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); } -} +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index aa0b06a67..f1c2d8ed5 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -39,4 +39,7 @@ casdoor.redirect-url: ${CASDOOR_REDIRECT_URL} vola.api.url: ${VOLA_API_URL:http://localhost:dummy} vola.api.key: ${VOLA_API_KEY:dummy-key} -aws.sqs.maxReceiveCount=6 \ No newline at end of file +aws.sqs.maxReceiveCount=6 +documenso.api.url: ${DOCUMENSO_API_URL:http://localhost:dummy} +documenso.api.key: ${DOCUMENSO_API_KEY:dummy-key} +documenso.webhook.secret: ${DOCUMENSO_WEBHOOK_SECRET:dummy-secret} \ No newline at end of file diff --git a/src/test/java/school/hei/haapi/integration/DocumensoIT.java b/src/test/java/school/hei/haapi/integration/DocumensoIT.java index b3691a6fa..717cfd018 100644 --- a/src/test/java/school/hei/haapi/integration/DocumensoIT.java +++ b/src/test/java/school/hei/haapi/integration/DocumensoIT.java @@ -8,12 +8,14 @@ import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static school.hei.haapi.integration.conf.FakeDataProvider.someUser; import static school.hei.haapi.integration.conf.TestUtils.ADMIN1_TOKEN; import static school.hei.haapi.integration.conf.TestUtils.MONITOR1_TOKEN; import static school.hei.haapi.integration.conf.TestUtils.STUDENT1_TOKEN; import static school.hei.haapi.integration.conf.TestUtils.assertThrowsForbiddenException; import static school.hei.haapi.integration.conf.TestUtils.setUpCasdoor; import static school.hei.haapi.integration.conf.TestUtils.setUpCognito; +import static school.hei.haapi.model.User.Role.STUDENT; import java.io.File; import java.math.BigDecimal; @@ -21,7 +23,7 @@ import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; -import java.time.Instant; +import java.util.List; import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; import org.junit.jupiter.api.BeforeEach; @@ -38,13 +40,11 @@ import school.hei.haapi.file.hash.FileHashAlgorithm; import school.hei.haapi.integration.conf.FacadeITMockedThirdParties; import school.hei.haapi.integration.conf.TestUtils; -import school.hei.haapi.model.CycleLevel; import school.hei.haapi.model.DocumensoDocument; -import school.hei.haapi.model.Promotion; import school.hei.haapi.model.User; import school.hei.haapi.repository.DocumensoDocumentRecipientRepository; import school.hei.haapi.repository.DocumensoDocumentRepository; -import school.hei.haapi.repository.PromotionRepository; +import school.hei.haapi.repository.MonitoringStudentRepository; import school.hei.haapi.repository.TemplateDocumensoRepository; import school.hei.haapi.repository.UserRepository; import school.hei.haapi.service.documenso.DocumensoClient; @@ -53,52 +53,52 @@ import school.hei.haapi.service.documenso.gen.model.TemplateFindTemplates200Response; import school.hei.haapi.service.documenso.gen.model.TemplateFindTemplates200ResponseDataInner; import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200Response; +import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200ResponseFieldsInner; import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200ResponseRecipientsInner; class DocumensoIT extends FacadeITMockedThirdParties { @Autowired private UserRepository userRepository; - @Autowired private PromotionRepository promotionRepository; @Autowired private TemplateDocumensoRepository templateDocumensoRepository; @Autowired private DocumensoDocumentRepository documensoDocumentRepository; @Autowired private DocumensoDocumentRecipientRepository documensoDocumentRecipientRepository; + @Autowired private MonitoringStudentRepository monitoringStudentRepository; @MockBean private DocumensoClient documensoClientMock; @MockBean private BucketComponent bucketComponentMock; private User admin; private User monitor; - private Promotion promotion; + private User student; private school.hei.haapi.model.TemplateDocumenso template; private long templateExternalId; + private String templateTitle; @BeforeEach void setUp() { setUpCasdoor(casdoorAuthServiceMock, certificateLoaderMock); setUpCognito(cognitoComponentMock); - - // admin1_id / test+admin@hei.school and monitor1_id / test+monitor@hei.school are seeded by - // src/test/resources/db/testdata (V99_2, V99_29) and shared across the whole test run, so we - // fetch them rather than inserting new rows with the same email (unique constraint). admin = userRepository.findById("admin1_id").orElseThrow(); admin.setDocumensoUserId(111L); admin = userRepository.save(admin); - monitor = userRepository.findById("monitor1_id").orElseThrow(); - - promotion = - promotionRepository.save( - Promotion.builder() - .name("Promo Test") - .ref("PROMO_" + UUID.randomUUID()) - .startDatetime(Instant.parse("2023-11-01T00:00:00Z")) - .cycleLevel(CycleLevel.BACHELOR) + student = + userRepository.save( + someUser("Fanja", STUDENT).toBuilder() + .nic("101234567890") + .address("Lot II A 12 Antananarivo") + .phone("0341234567") .build()); + monitoringStudentRepository.saveMonitorFollowingStudents( + monitor.getId(), List.of(student.getId()), "LINKED"); templateExternalId = ThreadLocalRandom.current().nextLong(1_000, 1_000_000_000); + // unique per test so concurrent/accumulated rows from other tests never make + // resolveTemplateByName's "contains" search ambiguous + templateTitle = "Fiche d'engagement L1 " + UUID.randomUUID(); template = templateDocumensoRepository.save( school.hei.haapi.model.TemplateDocumenso.builder() .documensoTemplateId(templateExternalId) - .title("Attestation") + .title(templateTitle) .type("PRIVATE") .build()); } @@ -142,72 +142,169 @@ void student_sync_templates_ko() { } @Test - void admin_generate_document_persists_pending_document_with_recipient_tokens() throws Exception { + void admin_generate_document_prefills_student_data_and_sends_to_monitor() throws Exception { when(documensoClientMock.getTemplate(templateExternalId)) .thenReturn( new TemplateGetTemplateById200Response() - .id(BigDecimal.valueOf(555)) - .title("Attestation") + .id(BigDecimal.valueOf(templateExternalId)) + .title(templateTitle) .addRecipientsItem( new TemplateGetTemplateById200ResponseRecipientsInner() .id(BigDecimal.valueOf(1)) .role(TemplateGetTemplateById200ResponseRecipientsInner.RoleEnum.SIGNER)) - .addRecipientsItem( - new TemplateGetTemplateById200ResponseRecipientsInner() - .id(BigDecimal.valueOf(2)) - .role(TemplateGetTemplateById200ResponseRecipientsInner.RoleEnum.SIGNER))); + .addFieldsItem( + new TemplateGetTemplateById200ResponseFieldsInner() + .id(BigDecimal.valueOf(10)) + .type("TEXT") + .label("Nom et prénoms")) + .addFieldsItem( + new TemplateGetTemplateById200ResponseFieldsInner() + .id(BigDecimal.valueOf(11)) + .type("TEXT") + .label("Adresse personnelle"))); when(documensoClientMock.useTemplate(any())) .thenReturn( new TemplateCreateDocumentFromTemplate200Response() .id(BigDecimal.valueOf(999)) .status(TemplateCreateDocumentFromTemplate200Response.StatusEnum.PENDING) - .title("Attestation") + .title(templateTitle) .addRecipientsItem( new TemplateCreateDocumentFromTemplate200ResponseRecipientsInner() .id(BigDecimal.valueOf(1)) - .email(admin.getEmail()) - .name("Admin") - .token("admin-token")) - .addRecipientsItem( - new TemplateCreateDocumentFromTemplate200ResponseRecipientsInner() - .id(BigDecimal.valueOf(2)) .email(monitor.getEmail()) .name("Monitor") .token("monitor-token"))); var toCreate = new CrupdateDocumensoDocument() - .promotionId(promotion.getId()) - .level(StudentLevel.L1) - .documensoTemplateId(templateExternalId) - .adminId(admin.getId()) - .monitorId(monitor.getId()); + .studentId(student.getId()) + .templateName(templateTitle); var created = anApi(ADMIN1_TOKEN).generateDocumensoDocument(toCreate); assertEquals(DocumensoDocumentStatus.PENDING, created.getStatus()); assertEquals(999L, created.getDocumensoDocumentId()); - assertEquals(promotion.getId(), created.getPromotionId()); + assertEquals(student.getId(), created.getStudentId()); - var adminToken = anApi(ADMIN1_TOKEN).getDocumensoDocumentSigningToken(created.getId()); - assertEquals("admin-token", adminToken.getToken()); + var useTemplateCaptor = + org.mockito.ArgumentCaptor.forClass( + school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequest + .class); + verify(documensoClientMock).useTemplate(useTemplateCaptor.capture()); + var sentRequest = useTemplateCaptor.getValue(); + assertEquals(1, sentRequest.getRecipients().size()); + assertEquals(monitor.getEmail(), sentRequest.getRecipients().get(0).getEmail()); + var prefillByFieldId = + sentRequest.getPrefillFields().stream() + .collect( + java.util.stream.Collectors.toMap(f -> f.getId().longValue(), f -> f.getValue())); + assertEquals(student.getFirstName() + " " + student.getLastName(), prefillByFieldId.get(10L)); + assertEquals(student.getAddress(), prefillByFieldId.get(11L)); var monitorToken = anApi(MONITOR1_TOKEN).getDocumensoDocumentSigningToken(created.getId()); assertEquals("monitor-token", monitorToken.getToken()); } + @Test + void admin_generate_document_fills_topmost_guardian_block_with_monitor_data() throws Exception { + when(documensoClientMock.getTemplate(templateExternalId)) + .thenReturn( + new TemplateGetTemplateById200Response() + .id(BigDecimal.valueOf(templateExternalId)) + .title(templateTitle) + .addRecipientsItem( + new TemplateGetTemplateById200ResponseRecipientsInner() + .id(BigDecimal.valueOf(1)) + .role(TemplateGetTemplateById200ResponseRecipientsInner.RoleEnum.SIGNER)) + .addFieldsItem( + new TemplateGetTemplateById200ResponseFieldsInner() + .id(BigDecimal.valueOf(20)) + .type("TEXT") + .label("PERE/ MERE/ TUTEUR") + .page(BigDecimal.ONE) + .positionY(BigDecimal.valueOf(100))) + .addFieldsItem( + new TemplateGetTemplateById200ResponseFieldsInner() + .id(BigDecimal.valueOf(21)) + .type("TEXT") + .label("Adresse personnelle") + .page(BigDecimal.ONE) + .positionY(BigDecimal.valueOf(110))) + .addFieldsItem( + new TemplateGetTemplateById200ResponseFieldsInner() + .id(BigDecimal.valueOf(22)) + .type("TEXT") + .label("Téléphones") + .page(BigDecimal.ONE) + .positionY(BigDecimal.valueOf(120))) + // student block, further down the page -> student + .addFieldsItem( + new TemplateGetTemplateById200ResponseFieldsInner() + .id(BigDecimal.valueOf(30)) + .type("TEXT") + .label("Nom et prénoms") + .page(BigDecimal.ONE) + .positionY(BigDecimal.valueOf(400))) + .addFieldsItem( + new TemplateGetTemplateById200ResponseFieldsInner() + .id(BigDecimal.valueOf(31)) + .type("TEXT") + .label("Adresse personnelle") + .page(BigDecimal.ONE) + .positionY(BigDecimal.valueOf(410))) + .addFieldsItem( + new TemplateGetTemplateById200ResponseFieldsInner() + .id(BigDecimal.valueOf(32)) + .type("TEXT") + .label("Téléphones") + .page(BigDecimal.ONE) + .positionY(BigDecimal.valueOf(420)))); + when(documensoClientMock.useTemplate(any())) + .thenReturn( + new TemplateCreateDocumentFromTemplate200Response() + .id(BigDecimal.valueOf(998)) + .status(TemplateCreateDocumentFromTemplate200Response.StatusEnum.PENDING) + .title(templateTitle) + .addRecipientsItem( + new TemplateCreateDocumentFromTemplate200ResponseRecipientsInner() + .id(BigDecimal.valueOf(1)) + .email(monitor.getEmail()) + .name("Monitor") + .token("monitor-token"))); + + var toCreate = + new CrupdateDocumensoDocument() + .studentId(student.getId()) + .templateName(templateTitle); + + anApi(ADMIN1_TOKEN).generateDocumensoDocument(toCreate); + + var useTemplateCaptor = + org.mockito.ArgumentCaptor.forClass( + school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequest + .class); + verify(documensoClientMock).useTemplate(useTemplateCaptor.capture()); + var prefillByFieldId = + useTemplateCaptor.getValue().getPrefillFields().stream() + .collect( + java.util.stream.Collectors.toMap(f -> f.getId().longValue(), f -> f.getValue())); + + assertEquals(monitor.getFirstName() + " " + monitor.getLastName(), prefillByFieldId.get(20L)); + assertEquals(monitor.getAddress(), prefillByFieldId.get(21L)); + assertEquals(monitor.getPhone(), prefillByFieldId.get(22L)); + assertEquals(student.getFirstName() + " " + student.getLastName(), prefillByFieldId.get(30L)); + assertEquals(student.getAddress(), prefillByFieldId.get(31L)); + assertEquals(student.getPhone(), prefillByFieldId.get(32L)); + } + @Test void student_generate_document_ko() { var toCreate = new CrupdateDocumensoDocument() - .promotionId(promotion.getId()) - .level(StudentLevel.L1) - .documensoTemplateId(templateExternalId) - .adminId(admin.getId()) - .monitorId(monitor.getId()); - - assertThrowsForbiddenException( - () -> anApi(STUDENT1_TOKEN).generateDocumensoDocument(toCreate)); + .studentId(student.getId()) + .templateName(templateTitle); + + assertThrowsForbiddenException(() -> anApi(STUDENT1_TOKEN).generateDocumensoDocument(toCreate)); } @Test @@ -217,7 +314,7 @@ void webhook_completes_document_and_uploads_signed_pdf_to_s3() throws Exception DocumensoDocument.builder() .documensoDocumentId(4242L) .template(template) - .promotion(promotion) + .student(student) .level(StudentLevel.L1) .status(DocumensoDocument.Status.PENDING) .build()); From c3f5b13ec14b39f1c3e84d238a5fa638713d32ec Mon Sep 17 00:00:00 2001 From: mbomain Date: Tue, 11 Aug 2026 14:17:23 +0300 Subject: [PATCH 08/21] chore: add new permission for endpoint documenso --- .../school/hei/haapi/endpoint/rest/security/SecurityConf.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/school/hei/haapi/endpoint/rest/security/SecurityConf.java b/src/main/java/school/hei/haapi/endpoint/rest/security/SecurityConf.java index b5dc1fda5..e18c1a606 100644 --- a/src/main/java/school/hei/haapi/endpoint/rest/security/SecurityConf.java +++ b/src/main/java/school/hei/haapi/endpoint/rest/security/SecurityConf.java @@ -1099,9 +1099,9 @@ req, res, null, forbiddenWithRemoteInfo(req)))) .requestMatchers(POST, "/documenso-templates/sync") .hasAnyRole(ADMIN.getRole()) .requestMatchers(POST, "/documenso-documents") - .hasAnyRole(ADMIN.getRole()) + .hasAnyRole(ADMIN.getRole(), MANAGER.getRole()) .requestMatchers(GET, "/documenso-documents/*/signing-token") - .hasAnyRole(ADMIN.getRole(), MONITOR.getRole()) + .hasAnyRole(ADMIN.getRole(), MANAGER.getRole(), MONITOR.getRole()) // // Attendances resources // From 7efecba5c8e4d311ae3209266232e425fbd12938 Mon Sep 17 00:00:00 2001 From: mbomain Date: Tue, 11 Aug 2026 14:22:25 +0300 Subject: [PATCH 09/21] fix: alignment with the client update generate --- .../service/DocumensoDocumentService.java | 44 ++++++------------- .../service/documenso/DocumensoClient.java | 15 ++++--- .../hei/haapi/integration/DocumensoIT.java | 15 ++----- 3 files changed, 25 insertions(+), 49 deletions(-) diff --git a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java index 2ccdc3961..b43f4dd76 100644 --- a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java +++ b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java @@ -102,7 +102,7 @@ public DocumensoDocument generateDocument(String studentId, String templateName) .build()); } return document; - } catch (school.hei.haapi.service.documenso.gen.invoker.ApiException e) { + } catch (org.springframework.web.client.RestClientException e) { throw new ApiException(SERVER_EXCEPTION, e); } } @@ -143,13 +143,6 @@ private TemplateCreateDocumentFromTemplateRequestRecipientsInner toRecipient( return recipient; } - /** - * Dispatches to a prefill strategy keyed by the template's title, since each document type lays - * its fields out differently (e.g. "Fiche d'engagement" repeats the same address/phone/CIN - * labels for up to 3 guardians and the student, whereas a future "Contrat d'alternance" or - * "Fiche de paye" would need its own rules). Unknown document types fall back to a single-person - * (student) match on uniquely-labelled fields only. - */ private List buildPrefillFields( school.hei.haapi.model.TemplateDocumenso template, List fields, @@ -167,30 +160,19 @@ private List buildP return buildDefaultPrefillFields(textFields, new PersonSnapshot(student), level); } - /** - * "Fiche d'engagement" repeats "Adresse personnelle"/"Téléphones"/"Titulaire de la CIN" once per - * guardian block (up to 3, topmost first) and once more for the student (always last, below the - * guardian blocks). Since the monitor stands in for the topmost guardian, we fill that occurrence - * with the monitor's data and the last occurrence with the student's, using each field's position - * on the page to tell them apart — the label text alone is identical across occurrences. - */ private List buildFicheEngagementPrefillFields( List textFields, PersonSnapshot student, PersonSnapshot monitor, StudentLevel level) { - var prefillFields = new ArrayList(); + var prefillFields = + new ArrayList(); matchOnly(textFields, "nom et prenom", student.fullName()).ifPresent(prefillFields::add); matchOnly(textFields, "inscrit", level == null ? null : Promotion.getLevelString(level)) .ifPresent(prefillFields::add); - // only ever labelled on guardian blocks, so the topmost occurrence is always the monitor's, - // regardless of how many guardian blocks the template actually has. matchByPosition(textFields, "pere/", monitor.fullName(), true).ifPresent(prefillFields::add); - - // shared with the student block below it: when both occur, top -> monitor, bottom -> student; - // when the template only has one occurrence, it's the student's own (more essential) field. for (var keyword : List.of("adresse personnelle", "telephone", "titulaire de la cin")) { var candidates = fieldsMatching(textFields, keyword); if (candidates.size() >= 2) { @@ -204,12 +186,13 @@ private List buildP return prefillFields; } - /** Fallback for document types without a dedicated strategy: matches uniquely-labelled fields only. */ - private List buildDefaultPrefillFields( - List textFields, - PersonSnapshot student, - StudentLevel level) { - var prefillFields = new ArrayList(); + private List + buildDefaultPrefillFields( + List textFields, + PersonSnapshot student, + StudentLevel level) { + var prefillFields = + new ArrayList(); matchOnly(textFields, "nom et prenom", student.fullName()).ifPresent(prefillFields::add); matchOnly(textFields, "inscrit", level == null ? null : Promotion.getLevelString(level)) .ifPresent(prefillFields::add); @@ -220,7 +203,9 @@ private List buildD } private Optional matchOnly( - List fields, String labelKeyword, String value) { + List fields, + String labelKeyword, + String value) { if (value == null || value.isBlank()) { return Optional.empty(); } @@ -243,7 +228,6 @@ private Optional ma return matchAt(chosen, value); } - /** All fields whose label/placeholder contains {@code labelKeyword}, sorted top-to-bottom. */ private static List fieldsMatching( List fields, String labelKeyword) { return fields.stream() @@ -367,7 +351,7 @@ public void handleWebhook(Map payload) { document.setStatus(DocumensoDocument.Status.COMPLETED); document.setCompletedDatetime(Instant.now()); documensoDocumentRepository.save(document); - } catch (school.hei.haapi.service.documenso.gen.invoker.ApiException e) { + } catch (org.springframework.web.client.RestClientException e) { throw new ApiException(SERVER_EXCEPTION, e); } } diff --git a/src/main/java/school/hei/haapi/service/documenso/DocumensoClient.java b/src/main/java/school/hei/haapi/service/documenso/DocumensoClient.java index 210a12c6f..1adf2e03a 100644 --- a/src/main/java/school/hei/haapi/service/documenso/DocumensoClient.java +++ b/src/main/java/school/hei/haapi/service/documenso/DocumensoClient.java @@ -2,10 +2,10 @@ import java.io.File; import java.math.BigDecimal; +import org.springframework.web.client.RestClientException; import school.hei.haapi.service.documenso.gen.api.DocumentApi; import school.hei.haapi.service.documenso.gen.api.TemplateApi; import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -import school.hei.haapi.service.documenso.gen.invoker.ApiException; import school.hei.haapi.service.documenso.gen.model.DocumentGet200Response; import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplate200Response; import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequest; @@ -19,31 +19,32 @@ public class DocumensoClient { public DocumensoClient(String baseUrl, String apiKey) { var apiClient = new ApiClient(); apiClient.setBasePath(baseUrl); - apiClient.setRequestInterceptor(builder -> builder.header("Authorization", apiKey)); + apiClient.setApiKey(apiKey); this.templateApi = new TemplateApi(apiClient); this.documentApi = new DocumentApi(apiClient); } public TemplateFindTemplates200Response findTemplates(String query, int page, int perPage) - throws ApiException { + throws RestClientException { return templateApi.templateFindTemplates( query, BigDecimal.valueOf(page), BigDecimal.valueOf(perPage)); } - public TemplateGetTemplateById200Response getTemplate(long templateId) throws ApiException { + public TemplateGetTemplateById200Response getTemplate(long templateId) + throws RestClientException { return templateApi.templateGetTemplateById(BigDecimal.valueOf(templateId)); } public TemplateCreateDocumentFromTemplate200Response useTemplate( - TemplateCreateDocumentFromTemplateRequest request) throws ApiException { + TemplateCreateDocumentFromTemplateRequest request) throws RestClientException { return templateApi.templateCreateDocumentFromTemplate(request); } - public DocumentGet200Response getDocument(long documentId) throws ApiException { + public DocumentGet200Response getDocument(long documentId) throws RestClientException { return documentApi.documentGet(BigDecimal.valueOf(documentId)); } - public File downloadSignedDocument(long documentId) throws ApiException { + public File downloadSignedDocument(long documentId) throws RestClientException { return documentApi.documentDownload(BigDecimal.valueOf(documentId), "signed"); } } diff --git a/src/test/java/school/hei/haapi/integration/DocumensoIT.java b/src/test/java/school/hei/haapi/integration/DocumensoIT.java index 717cfd018..cfc79714d 100644 --- a/src/test/java/school/hei/haapi/integration/DocumensoIT.java +++ b/src/test/java/school/hei/haapi/integration/DocumensoIT.java @@ -91,8 +91,6 @@ void setUp() { monitor.getId(), List.of(student.getId()), "LINKED"); templateExternalId = ThreadLocalRandom.current().nextLong(1_000, 1_000_000_000); - // unique per test so concurrent/accumulated rows from other tests never make - // resolveTemplateByName's "contains" search ambiguous templateTitle = "Fiche d'engagement L1 " + UUID.randomUUID(); template = templateDocumensoRepository.save( @@ -176,9 +174,7 @@ void admin_generate_document_prefills_student_data_and_sends_to_monitor() throws .token("monitor-token"))); var toCreate = - new CrupdateDocumensoDocument() - .studentId(student.getId()) - .templateName(templateTitle); + new CrupdateDocumensoDocument().studentId(student.getId()).templateName(templateTitle); var created = anApi(ADMIN1_TOKEN).generateDocumensoDocument(toCreate); @@ -237,7 +233,6 @@ void admin_generate_document_fills_topmost_guardian_block_with_monitor_data() th .label("Téléphones") .page(BigDecimal.ONE) .positionY(BigDecimal.valueOf(120))) - // student block, further down the page -> student .addFieldsItem( new TemplateGetTemplateById200ResponseFieldsInner() .id(BigDecimal.valueOf(30)) @@ -273,9 +268,7 @@ void admin_generate_document_fills_topmost_guardian_block_with_monitor_data() th .token("monitor-token"))); var toCreate = - new CrupdateDocumensoDocument() - .studentId(student.getId()) - .templateName(templateTitle); + new CrupdateDocumensoDocument().studentId(student.getId()).templateName(templateTitle); anApi(ADMIN1_TOKEN).generateDocumensoDocument(toCreate); @@ -300,9 +293,7 @@ void admin_generate_document_fills_topmost_guardian_block_with_monitor_data() th @Test void student_generate_document_ko() { var toCreate = - new CrupdateDocumensoDocument() - .studentId(student.getId()) - .templateName(templateTitle); + new CrupdateDocumensoDocument().studentId(student.getId()).templateName(templateTitle); assertThrowsForbiddenException(() -> anApi(STUDENT1_TOKEN).generateDocumensoDocument(toCreate)); } From 3da46c3c11512a640e9085b0d49fae202f425410 Mon Sep 17 00:00:00 2001 From: mbomain Date: Tue, 11 Aug 2026 14:25:11 +0300 Subject: [PATCH 10/21] chore: code format --- .../school/hei/haapi/repository/TemplateDocumensoRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/school/hei/haapi/repository/TemplateDocumensoRepository.java b/src/main/java/school/hei/haapi/repository/TemplateDocumensoRepository.java index de8641446..1a9887313 100644 --- a/src/main/java/school/hei/haapi/repository/TemplateDocumensoRepository.java +++ b/src/main/java/school/hei/haapi/repository/TemplateDocumensoRepository.java @@ -9,5 +9,6 @@ @Repository public interface TemplateDocumensoRepository extends JpaRepository { Optional findByDocumensoTemplateId(Long documensoTemplateId); + List findAllByTitleContainingIgnoreCase(String title); } From 15961f787eca941da69ff07f637159e88edefac2 Mon Sep 17 00:00:00 2001 From: mbomain Date: Tue, 11 Aug 2026 14:26:02 +0300 Subject: [PATCH 11/21] build: update client documenso --- .../documenso/gen/api/DocumentApi.java | 379 +++--- .../documenso/gen/api/TemplateApi.java | 500 ++++---- .../documenso/gen/invoker/ApiClient.java | 1023 ++++++++++++----- .../documenso/gen/invoker/ApiException.java | 92 -- .../documenso/gen/invoker/ApiResponse.java | 60 - .../documenso/gen/invoker/BaseApi.java | 90 ++ .../documenso/gen/invoker/Configuration.java | 41 - .../service/documenso/gen/invoker/JSON.java | 251 ---- .../service/documenso/gen/invoker/Pair.java | 57 - .../gen/invoker/RFC3339DateFormat.java | 15 +- .../gen/invoker/ServerConfiguration.java | 96 +- .../documenso/gen/invoker/ServerVariable.java | 36 +- .../gen/invoker/auth/ApiKeyAuth.java | 68 ++ .../gen/invoker/auth/Authentication.java | 18 + .../gen/invoker/auth/HttpBasicAuth.java | 45 + .../gen/invoker/auth/HttpBearerAuth.java | 67 ++ .../gen/model/AbstractOpenApiSchema.java | 147 --- .../gen/model/DocumentGet200Response.java | 139 +-- ...CreateDocumentFromTemplate200Response.java | 159 +-- ...romTemplate200ResponseRecipientsInner.java | 149 +-- ...lateCreateDocumentFromTemplateRequest.java | 143 +-- ...FromTemplateRequestPrefillFieldsInner.java | 117 +- ...entFromTemplateRequestRecipientsInner.java | 112 +- .../TemplateFindTemplates200Response.java | 102 +- ...lateFindTemplates200ResponseDataInner.java | 151 +-- .../TemplateGetTemplateById200Response.java | 152 +-- ...GetTemplateById200ResponseFieldsInner.java | 144 +-- ...emplateById200ResponseRecipientsInner.java | 131 +-- .../school/hei/haapi/integration/FeeIT.java | 4 +- 29 files changed, 1845 insertions(+), 2643 deletions(-) delete mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiException.java delete mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiResponse.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/BaseApi.java delete mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/Configuration.java delete mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/JSON.java delete mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/Pair.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/ApiKeyAuth.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/Authentication.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/HttpBasicAuth.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/HttpBearerAuth.java delete mode 100644 src/main/java/school/hei/haapi/service/documenso/gen/model/AbstractOpenApiSchema.java diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/api/DocumentApi.java b/src/main/java/school/hei/haapi/service/documenso/gen/api/DocumentApi.java index 32e5c226a..37ee87eb6 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/api/DocumentApi.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/api/DocumentApi.java @@ -1,249 +1,216 @@ -/* - * Documenso v2 API (client subset) - * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - package school.hei.haapi.service.documenso.gen.api; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -import school.hei.haapi.service.documenso.gen.invoker.ApiException; -import school.hei.haapi.service.documenso.gen.invoker.ApiResponse; -import school.hei.haapi.service.documenso.gen.invoker.Pair; - -import java.math.BigDecimal; -import school.hei.haapi.service.documenso.gen.model.DocumentGet200Response; import java.io.File; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.InputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.net.http.HttpRequest; -import java.nio.channels.Channels; -import java.nio.channels.Pipe; -import java.net.URI; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.time.Duration; - -import java.util.ArrayList; -import java.util.StringJoiner; +import java.math.BigDecimal; +import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; - -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") -public class DocumentApi { - private final HttpClient memberVarHttpClient; - private final ObjectMapper memberVarObjectMapper; - private final String memberVarBaseUri; - private final Consumer memberVarInterceptor; - private final Duration memberVarReadTimeout; - private final Consumer> memberVarResponseInterceptor; - private final Consumer> memberVarAsyncResponseInterceptor; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.RestClientException; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import school.hei.haapi.service.documenso.gen.invoker.BaseApi; +import school.hei.haapi.service.documenso.gen.model.DocumentGet200Response; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class DocumentApi extends BaseApi { public DocumentApi() { - this(new ApiClient()); + super(new ApiClient()); } public DocumentApi(ApiClient apiClient) { - memberVarHttpClient = apiClient.getHttpClient(); - memberVarObjectMapper = apiClient.getObjectMapper(); - memberVarBaseUri = apiClient.getBaseUri(); - memberVarInterceptor = apiClient.getRequestInterceptor(); - memberVarReadTimeout = apiClient.getReadTimeout(); - memberVarResponseInterceptor = apiClient.getResponseInterceptor(); - memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); - } - - protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { - String body = response.body() == null ? null : new String(response.body().readAllBytes()); - String message = formatExceptionMessage(operationId, response.statusCode(), body); - return new ApiException(response.statusCode(), message, response.headers(), body); - } - - private String formatExceptionMessage(String operationId, int statusCode, String body) { - if (body == null || body.isEmpty()) { - body = "[no body]"; - } - return operationId + " call failed with: " + statusCode + " - " + body; + super(apiClient); } /** - * Download document - * Downloads the document. \"signed\" returns the completed document with signatures, \"original\" returns the original uploaded document. - * @param documentId (required) - * @param version (optional, default to signed) + * Download document Downloads the document. \"signed\" returns the completed document + * with signatures, \"original\" returns the original uploaded document. + * + *

200 - Successful response + * + * @param documentId (required) + * @param version (optional, default to signed) * @return File - * @throws ApiException if fails to make API call + * @throws RestClientException if an error occurs while attempting to invoke the API */ - public File documentDownload(BigDecimal documentId, String version) throws ApiException { - ApiResponse localVarResponse = documentDownloadWithHttpInfo(documentId, version); - return localVarResponse.getData(); + public File documentDownload(BigDecimal documentId, String version) throws RestClientException { + return documentDownloadWithHttpInfo(documentId, version).getBody(); } /** - * Download document - * Downloads the document. \"signed\" returns the completed document with signatures, \"original\" returns the original uploaded document. - * @param documentId (required) - * @param version (optional, default to signed) - * @return ApiResponse<File> - * @throws ApiException if fails to make API call + * Download document Downloads the document. \"signed\" returns the completed document + * with signatures, \"original\" returns the original uploaded document. + * + *

200 - Successful response + * + * @param documentId (required) + * @param version (optional, default to signed) + * @return ResponseEntity<File> + * @throws RestClientException if an error occurs while attempting to invoke the API */ - public ApiResponse documentDownloadWithHttpInfo(BigDecimal documentId, String version) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = documentDownloadRequestBuilder(documentId, version); - try { - HttpResponse localVarResponse = memberVarHttpClient.send( - localVarRequestBuilder.build(), - HttpResponse.BodyHandlers.ofInputStream()); - if (memberVarResponseInterceptor != null) { - memberVarResponseInterceptor.accept(localVarResponse); - } - try { - if (localVarResponse.statusCode()/ 100 != 2) { - throw getApiException("documentDownload", localVarResponse); - } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream - ); - } finally { - } - } catch (IOException e) { - throw new ApiException(e); - } - catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new ApiException(e); - } - } + public ResponseEntity documentDownloadWithHttpInfo(BigDecimal documentId, String version) + throws RestClientException { + Object localVarPostBody = null; - private HttpRequest.Builder documentDownloadRequestBuilder(BigDecimal documentId, String version) throws ApiException { // verify the required parameter 'documentId' is set if (documentId == null) { - throw new ApiException(400, "Missing the required parameter 'documentId' when calling documentDownload"); + throw new HttpClientErrorException( + HttpStatus.BAD_REQUEST, + "Missing the required parameter 'documentId' when calling documentDownload"); } - HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); - - String localVarPath = "/document/{documentId}/download" - .replace("{documentId}", ApiClient.urlEncode(documentId.toString())); - - List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); - String localVarQueryParameterBaseName; - localVarQueryParameterBaseName = "version"; - localVarQueryParams.addAll(ApiClient.parameterToPairs("version", version)); - - if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { - StringJoiner queryJoiner = new StringJoiner("&"); - localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryStringJoiner.toString()); - } - localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); - } else { - localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); - } - - localVarRequestBuilder.header("Accept", "application/pdf"); - - localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); - if (memberVarReadTimeout != null) { - localVarRequestBuilder.timeout(memberVarReadTimeout); - } - if (memberVarInterceptor != null) { - memberVarInterceptor.accept(localVarRequestBuilder); - } - return localVarRequestBuilder; + // create path and map variables + final Map uriVariables = new HashMap(); + uriVariables.put("documentId", documentId); + + final MultiValueMap localVarQueryParams = + new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarCookieParams = + new LinkedMultiValueMap(); + final MultiValueMap localVarFormParams = + new LinkedMultiValueMap(); + + localVarQueryParams.putAll(apiClient.parameterToMultiValueMap(null, "version", version)); + + final String[] localVarAccepts = {"application/pdf"}; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = {}; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] {"apiKey"}; + + ParameterizedTypeReference localReturnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI( + "/document/{documentId}/download", + HttpMethod.GET, + uriVariables, + localVarQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + localReturnType); } /** * Get document - * - * @param documentId (required) + * + *

200 - Successful response + * + * @param documentId (required) * @return DocumentGet200Response - * @throws ApiException if fails to make API call + * @throws RestClientException if an error occurs while attempting to invoke the API */ - public DocumentGet200Response documentGet(BigDecimal documentId) throws ApiException { - ApiResponse localVarResponse = documentGetWithHttpInfo(documentId); - return localVarResponse.getData(); + public DocumentGet200Response documentGet(BigDecimal documentId) throws RestClientException { + return documentGetWithHttpInfo(documentId).getBody(); } /** * Get document - * - * @param documentId (required) - * @return ApiResponse<DocumentGet200Response> - * @throws ApiException if fails to make API call + * + *

200 - Successful response + * + * @param documentId (required) + * @return ResponseEntity<DocumentGet200Response> + * @throws RestClientException if an error occurs while attempting to invoke the API */ - public ApiResponse documentGetWithHttpInfo(BigDecimal documentId) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = documentGetRequestBuilder(documentId); - try { - HttpResponse localVarResponse = memberVarHttpClient.send( - localVarRequestBuilder.build(), - HttpResponse.BodyHandlers.ofInputStream()); - if (memberVarResponseInterceptor != null) { - memberVarResponseInterceptor.accept(localVarResponse); - } - try { - if (localVarResponse.statusCode()/ 100 != 2) { - throw getApiException("documentGet", localVarResponse); - } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream - ); - } finally { - } - } catch (IOException e) { - throw new ApiException(e); - } - catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new ApiException(e); - } - } + public ResponseEntity documentGetWithHttpInfo(BigDecimal documentId) + throws RestClientException { + Object localVarPostBody = null; - private HttpRequest.Builder documentGetRequestBuilder(BigDecimal documentId) throws ApiException { // verify the required parameter 'documentId' is set if (documentId == null) { - throw new ApiException(400, "Missing the required parameter 'documentId' when calling documentGet"); + throw new HttpClientErrorException( + HttpStatus.BAD_REQUEST, + "Missing the required parameter 'documentId' when calling documentGet"); } - HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); - - String localVarPath = "/document/{documentId}" - .replace("{documentId}", ApiClient.urlEncode(documentId.toString())); - - localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); - - localVarRequestBuilder.header("Accept", "application/json"); - - localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); - if (memberVarReadTimeout != null) { - localVarRequestBuilder.timeout(memberVarReadTimeout); - } - if (memberVarInterceptor != null) { - memberVarInterceptor.accept(localVarRequestBuilder); - } - return localVarRequestBuilder; + // create path and map variables + final Map uriVariables = new HashMap(); + uriVariables.put("documentId", documentId); + + final MultiValueMap localVarQueryParams = + new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarCookieParams = + new LinkedMultiValueMap(); + final MultiValueMap localVarFormParams = + new LinkedMultiValueMap(); + + final String[] localVarAccepts = {"application/json"}; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = {}; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] {"apiKey"}; + + ParameterizedTypeReference localReturnType = + new ParameterizedTypeReference() {}; + return apiClient.invokeAPI( + "/document/{documentId}", + HttpMethod.GET, + uriVariables, + localVarQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + localReturnType); } + @Override + public ResponseEntity invokeAPI( + String url, HttpMethod method, Object request, ParameterizedTypeReference returnType) + throws RestClientException { + String localVarPath = url.replace(apiClient.getBasePath(), ""); + Object localVarPostBody = request; + + final Map uriVariables = new HashMap(); + final MultiValueMap localVarQueryParams = + new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarCookieParams = + new LinkedMultiValueMap(); + final MultiValueMap localVarFormParams = + new LinkedMultiValueMap(); + + final String[] localVarAccepts = {"application/json"}; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = {}; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] {"apiKey"}; + + return apiClient.invokeAPI( + localVarPath, + method, + uriVariables, + localVarQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + returnType); + } } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/api/TemplateApi.java b/src/main/java/school/hei/haapi/service/documenso/gen/api/TemplateApi.java index 46f642692..79caecdc5 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/api/TemplateApi.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/api/TemplateApi.java @@ -1,330 +1,284 @@ -/* - * Documenso v2 API (client subset) - * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - package school.hei.haapi.service.documenso.gen.api; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -import school.hei.haapi.service.documenso.gen.invoker.ApiException; -import school.hei.haapi.service.documenso.gen.invoker.ApiResponse; -import school.hei.haapi.service.documenso.gen.invoker.Pair; - import java.math.BigDecimal; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.RestClientException; +import school.hei.haapi.service.documenso.gen.invoker.ApiClient; +import school.hei.haapi.service.documenso.gen.invoker.BaseApi; import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplate200Response; import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequest; import school.hei.haapi.service.documenso.gen.model.TemplateFindTemplates200Response; import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200Response; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.InputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.net.http.HttpRequest; -import java.nio.channels.Channels; -import java.nio.channels.Pipe; -import java.net.URI; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.time.Duration; - -import java.util.ArrayList; -import java.util.StringJoiner; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; - -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") -public class TemplateApi { - private final HttpClient memberVarHttpClient; - private final ObjectMapper memberVarObjectMapper; - private final String memberVarBaseUri; - private final Consumer memberVarInterceptor; - private final Duration memberVarReadTimeout; - private final Consumer> memberVarResponseInterceptor; - private final Consumer> memberVarAsyncResponseInterceptor; +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class TemplateApi extends BaseApi { public TemplateApi() { - this(new ApiClient()); + super(new ApiClient()); } public TemplateApi(ApiClient apiClient) { - memberVarHttpClient = apiClient.getHttpClient(); - memberVarObjectMapper = apiClient.getObjectMapper(); - memberVarBaseUri = apiClient.getBaseUri(); - memberVarInterceptor = apiClient.getRequestInterceptor(); - memberVarReadTimeout = apiClient.getReadTimeout(); - memberVarResponseInterceptor = apiClient.getResponseInterceptor(); - memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); - } - - protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { - String body = response.body() == null ? null : new String(response.body().readAllBytes()); - String message = formatExceptionMessage(operationId, response.statusCode(), body); - return new ApiException(response.statusCode(), message, response.headers(), body); - } - - private String formatExceptionMessage(String operationId, int statusCode, String body) { - if (body == null || body.isEmpty()) { - body = "[no body]"; - } - return operationId + " call failed with: " + statusCode + " - " + body; + super(apiClient); } /** - * Use template - * Use the template to create a document - * @param templateCreateDocumentFromTemplateRequest (required) + * Use template Use the template to create a document + * + *

200 - Successful response + * + * @param templateCreateDocumentFromTemplateRequest (required) * @return TemplateCreateDocumentFromTemplate200Response - * @throws ApiException if fails to make API call + * @throws RestClientException if an error occurs while attempting to invoke the API */ - public TemplateCreateDocumentFromTemplate200Response templateCreateDocumentFromTemplate(TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) throws ApiException { - ApiResponse localVarResponse = templateCreateDocumentFromTemplateWithHttpInfo(templateCreateDocumentFromTemplateRequest); - return localVarResponse.getData(); + public TemplateCreateDocumentFromTemplate200Response templateCreateDocumentFromTemplate( + TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) + throws RestClientException { + return templateCreateDocumentFromTemplateWithHttpInfo(templateCreateDocumentFromTemplateRequest) + .getBody(); } /** - * Use template - * Use the template to create a document - * @param templateCreateDocumentFromTemplateRequest (required) - * @return ApiResponse<TemplateCreateDocumentFromTemplate200Response> - * @throws ApiException if fails to make API call + * Use template Use the template to create a document + * + *

200 - Successful response + * + * @param templateCreateDocumentFromTemplateRequest (required) + * @return ResponseEntity<TemplateCreateDocumentFromTemplate200Response> + * @throws RestClientException if an error occurs while attempting to invoke the API */ - public ApiResponse templateCreateDocumentFromTemplateWithHttpInfo(TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = templateCreateDocumentFromTemplateRequestBuilder(templateCreateDocumentFromTemplateRequest); - try { - HttpResponse localVarResponse = memberVarHttpClient.send( - localVarRequestBuilder.build(), - HttpResponse.BodyHandlers.ofInputStream()); - if (memberVarResponseInterceptor != null) { - memberVarResponseInterceptor.accept(localVarResponse); - } - try { - if (localVarResponse.statusCode()/ 100 != 2) { - throw getApiException("templateCreateDocumentFromTemplate", localVarResponse); - } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream - ); - } finally { - } - } catch (IOException e) { - throw new ApiException(e); - } - catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new ApiException(e); - } - } + public ResponseEntity + templateCreateDocumentFromTemplateWithHttpInfo( + TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) + throws RestClientException { + Object localVarPostBody = templateCreateDocumentFromTemplateRequest; - private HttpRequest.Builder templateCreateDocumentFromTemplateRequestBuilder(TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest) throws ApiException { // verify the required parameter 'templateCreateDocumentFromTemplateRequest' is set if (templateCreateDocumentFromTemplateRequest == null) { - throw new ApiException(400, "Missing the required parameter 'templateCreateDocumentFromTemplateRequest' when calling templateCreateDocumentFromTemplate"); + throw new HttpClientErrorException( + HttpStatus.BAD_REQUEST, + "Missing the required parameter 'templateCreateDocumentFromTemplateRequest' when calling" + + " templateCreateDocumentFromTemplate"); } - HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); - - String localVarPath = "/template/use"; - - localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); - - localVarRequestBuilder.header("Content-Type", "application/json"); - localVarRequestBuilder.header("Accept", "application/json"); - - try { - byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(templateCreateDocumentFromTemplateRequest); - localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); - } catch (IOException e) { - throw new ApiException(e); - } - if (memberVarReadTimeout != null) { - localVarRequestBuilder.timeout(memberVarReadTimeout); - } - if (memberVarInterceptor != null) { - memberVarInterceptor.accept(localVarRequestBuilder); - } - return localVarRequestBuilder; + final MultiValueMap localVarQueryParams = + new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarCookieParams = + new LinkedMultiValueMap(); + final MultiValueMap localVarFormParams = + new LinkedMultiValueMap(); + + final String[] localVarAccepts = {"application/json"}; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = {"application/json"}; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] {"apiKey"}; + + ParameterizedTypeReference localReturnType = + new ParameterizedTypeReference() {}; + return apiClient.invokeAPI( + "/template/use", + HttpMethod.POST, + Collections.emptyMap(), + localVarQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + localReturnType); } /** * Find templates - * - * @param query (optional) - * @param page (optional) - * @param perPage (optional) + * + *

200 - Successful response + * + * @param query (optional) + * @param page (optional) + * @param perPage (optional) * @return TemplateFindTemplates200Response - * @throws ApiException if fails to make API call + * @throws RestClientException if an error occurs while attempting to invoke the API */ - public TemplateFindTemplates200Response templateFindTemplates(String query, BigDecimal page, BigDecimal perPage) throws ApiException { - ApiResponse localVarResponse = templateFindTemplatesWithHttpInfo(query, page, perPage); - return localVarResponse.getData(); + public TemplateFindTemplates200Response templateFindTemplates( + String query, BigDecimal page, BigDecimal perPage) throws RestClientException { + return templateFindTemplatesWithHttpInfo(query, page, perPage).getBody(); } /** * Find templates - * - * @param query (optional) - * @param page (optional) - * @param perPage (optional) - * @return ApiResponse<TemplateFindTemplates200Response> - * @throws ApiException if fails to make API call + * + *

200 - Successful response + * + * @param query (optional) + * @param page (optional) + * @param perPage (optional) + * @return ResponseEntity<TemplateFindTemplates200Response> + * @throws RestClientException if an error occurs while attempting to invoke the API */ - public ApiResponse templateFindTemplatesWithHttpInfo(String query, BigDecimal page, BigDecimal perPage) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = templateFindTemplatesRequestBuilder(query, page, perPage); - try { - HttpResponse localVarResponse = memberVarHttpClient.send( - localVarRequestBuilder.build(), - HttpResponse.BodyHandlers.ofInputStream()); - if (memberVarResponseInterceptor != null) { - memberVarResponseInterceptor.accept(localVarResponse); - } - try { - if (localVarResponse.statusCode()/ 100 != 2) { - throw getApiException("templateFindTemplates", localVarResponse); - } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream - ); - } finally { - } - } catch (IOException e) { - throw new ApiException(e); - } - catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new ApiException(e); - } - } - - private HttpRequest.Builder templateFindTemplatesRequestBuilder(String query, BigDecimal page, BigDecimal perPage) throws ApiException { - - HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); - - String localVarPath = "/template"; - - List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); - String localVarQueryParameterBaseName; - localVarQueryParameterBaseName = "query"; - localVarQueryParams.addAll(ApiClient.parameterToPairs("query", query)); - localVarQueryParameterBaseName = "page"; - localVarQueryParams.addAll(ApiClient.parameterToPairs("page", page)); - localVarQueryParameterBaseName = "perPage"; - localVarQueryParams.addAll(ApiClient.parameterToPairs("perPage", perPage)); - - if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { - StringJoiner queryJoiner = new StringJoiner("&"); - localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryStringJoiner.toString()); - } - localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); - } else { - localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); - } - - localVarRequestBuilder.header("Accept", "application/json"); - - localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); - if (memberVarReadTimeout != null) { - localVarRequestBuilder.timeout(memberVarReadTimeout); - } - if (memberVarInterceptor != null) { - memberVarInterceptor.accept(localVarRequestBuilder); - } - return localVarRequestBuilder; + public ResponseEntity templateFindTemplatesWithHttpInfo( + String query, BigDecimal page, BigDecimal perPage) throws RestClientException { + Object localVarPostBody = null; + + final MultiValueMap localVarQueryParams = + new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarCookieParams = + new LinkedMultiValueMap(); + final MultiValueMap localVarFormParams = + new LinkedMultiValueMap(); + + localVarQueryParams.putAll(apiClient.parameterToMultiValueMap(null, "query", query)); + localVarQueryParams.putAll(apiClient.parameterToMultiValueMap(null, "page", page)); + localVarQueryParams.putAll(apiClient.parameterToMultiValueMap(null, "perPage", perPage)); + + final String[] localVarAccepts = {"application/json"}; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = {}; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] {"apiKey"}; + + ParameterizedTypeReference localReturnType = + new ParameterizedTypeReference() {}; + return apiClient.invokeAPI( + "/template", + HttpMethod.GET, + Collections.emptyMap(), + localVarQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + localReturnType); } /** * Get template - * - * @param templateId (required) + * + *

200 - Successful response + * + * @param templateId (required) * @return TemplateGetTemplateById200Response - * @throws ApiException if fails to make API call + * @throws RestClientException if an error occurs while attempting to invoke the API */ - public TemplateGetTemplateById200Response templateGetTemplateById(BigDecimal templateId) throws ApiException { - ApiResponse localVarResponse = templateGetTemplateByIdWithHttpInfo(templateId); - return localVarResponse.getData(); + public TemplateGetTemplateById200Response templateGetTemplateById(BigDecimal templateId) + throws RestClientException { + return templateGetTemplateByIdWithHttpInfo(templateId).getBody(); } /** * Get template - * - * @param templateId (required) - * @return ApiResponse<TemplateGetTemplateById200Response> - * @throws ApiException if fails to make API call + * + *

200 - Successful response + * + * @param templateId (required) + * @return ResponseEntity<TemplateGetTemplateById200Response> + * @throws RestClientException if an error occurs while attempting to invoke the API */ - public ApiResponse templateGetTemplateByIdWithHttpInfo(BigDecimal templateId) throws ApiException { - HttpRequest.Builder localVarRequestBuilder = templateGetTemplateByIdRequestBuilder(templateId); - try { - HttpResponse localVarResponse = memberVarHttpClient.send( - localVarRequestBuilder.build(), - HttpResponse.BodyHandlers.ofInputStream()); - if (memberVarResponseInterceptor != null) { - memberVarResponseInterceptor.accept(localVarResponse); - } - try { - if (localVarResponse.statusCode()/ 100 != 2) { - throw getApiException("templateGetTemplateById", localVarResponse); - } - return new ApiResponse( - localVarResponse.statusCode(), - localVarResponse.headers().map(), - localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream - ); - } finally { - } - } catch (IOException e) { - throw new ApiException(e); - } - catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new ApiException(e); - } - } + public ResponseEntity templateGetTemplateByIdWithHttpInfo( + BigDecimal templateId) throws RestClientException { + Object localVarPostBody = null; - private HttpRequest.Builder templateGetTemplateByIdRequestBuilder(BigDecimal templateId) throws ApiException { // verify the required parameter 'templateId' is set if (templateId == null) { - throw new ApiException(400, "Missing the required parameter 'templateId' when calling templateGetTemplateById"); + throw new HttpClientErrorException( + HttpStatus.BAD_REQUEST, + "Missing the required parameter 'templateId' when calling templateGetTemplateById"); } - HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); - - String localVarPath = "/template/{templateId}" - .replace("{templateId}", ApiClient.urlEncode(templateId.toString())); - - localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); - - localVarRequestBuilder.header("Accept", "application/json"); - - localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); - if (memberVarReadTimeout != null) { - localVarRequestBuilder.timeout(memberVarReadTimeout); - } - if (memberVarInterceptor != null) { - memberVarInterceptor.accept(localVarRequestBuilder); - } - return localVarRequestBuilder; + // create path and map variables + final Map uriVariables = new HashMap(); + uriVariables.put("templateId", templateId); + + final MultiValueMap localVarQueryParams = + new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarCookieParams = + new LinkedMultiValueMap(); + final MultiValueMap localVarFormParams = + new LinkedMultiValueMap(); + + final String[] localVarAccepts = {"application/json"}; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = {}; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] {"apiKey"}; + + ParameterizedTypeReference localReturnType = + new ParameterizedTypeReference() {}; + return apiClient.invokeAPI( + "/template/{templateId}", + HttpMethod.GET, + uriVariables, + localVarQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + localReturnType); } + @Override + public ResponseEntity invokeAPI( + String url, HttpMethod method, Object request, ParameterizedTypeReference returnType) + throws RestClientException { + String localVarPath = url.replace(apiClient.getBasePath(), ""); + Object localVarPostBody = request; + + final Map uriVariables = new HashMap(); + final MultiValueMap localVarQueryParams = + new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarCookieParams = + new LinkedMultiValueMap(); + final MultiValueMap localVarFormParams = + new LinkedMultiValueMap(); + + final String[] localVarAccepts = {"application/json"}; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = {}; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] {"apiKey"}; + + return apiClient.invokeAPI( + localVarPath, + method, + uriVariables, + localVarQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + returnType); + } } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiClient.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiClient.java index 246f96c35..d368fa765 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiClient.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiClient.java @@ -1,456 +1,861 @@ -/* - * Documenso v2 API (client subset) - * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - package school.hei.haapi.service.documenso.gen.invoker; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import org.openapitools.jackson.nullable.JsonNullableModule; - +import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; import java.net.URI; +import java.net.URISyntaxException; import java.net.URLEncoder; -import java.net.http.HttpClient; -import java.net.http.HttpConnectTimeoutException; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.time.Duration; -import java.time.OffsetDateTime; -import java.time.format.DateTimeFormatter; +import java.nio.charset.StandardCharsets; +import java.text.DateFormat; +import java.text.ParseException; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; -import java.util.StringJoiner; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -import static java.nio.charset.StandardCharsets.UTF_8; - -/** - * Configuration and utility class for API clients. - * - *

This class can be constructed and modified, then used to instantiate the - * various API classes. The API classes use the settings in this class to - * configure themselves, but otherwise do not store a link to this class.

- * - *

This class is mutable and not synchronized, so it is not thread-safe. - * The API classes generated from this are immutable and thread-safe.

- * - *

The setter methods of this class return the current object to facilitate - * a fluent style of configuration.

- */ -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +import java.util.Map; +import java.util.Map.Entry; +import java.util.TimeZone; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpRequest; +import org.springframework.http.HttpStatus; +import org.springframework.http.InvalidMediaTypeException; +import org.springframework.http.MediaType; +import org.springframework.http.RequestEntity; +import org.springframework.http.RequestEntity.BodyBuilder; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.BufferingClientHttpRequestFactory; +import org.springframework.http.client.ClientHttpRequestExecution; +import org.springframework.http.client.ClientHttpRequestInterceptor; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.util.CollectionUtils; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.util.StringUtils; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.HttpServerErrorException; +import org.springframework.web.client.RestClientException; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.DefaultUriBuilderFactory; +import org.springframework.web.util.UriComponentsBuilder; +import school.hei.haapi.service.documenso.gen.invoker.auth.ApiKeyAuth; +import school.hei.haapi.service.documenso.gen.invoker.auth.Authentication; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class ApiClient { + public enum CollectionFormat { + CSV(","), + TSV("\t"), + SSV(" "), + PIPES("|"), + MULTI(null); - private HttpClient.Builder builder; - private ObjectMapper mapper; - private String scheme; - private String host; - private int port; - private String basePath; - private Consumer interceptor; - private Consumer> responseInterceptor; - private Consumer> asyncResponseInterceptor; - private Duration readTimeout; - private Duration connectTimeout; - - public static String valueToString(Object value) { - if (value == null) { - return ""; + private final String separator; + + private CollectionFormat(String separator) { + this.separator = separator; } - if (value instanceof OffsetDateTime) { - return ((OffsetDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + + private String collectionToString(Collection collection) { + return StringUtils.collectionToDelimitedString(collection, separator); } - return value.toString(); + } + + private boolean debugging = false; + + private HttpHeaders defaultHeaders = new HttpHeaders(); + private MultiValueMap defaultCookies = new LinkedMultiValueMap(); + + private int maxAttemptsForRetry = 1; + + private long waitTimeMillis = 10; + + private String basePath = "https://app.documenso.com/api/v2"; + + private RestTemplate restTemplate; + + private Map authentications; + + private DateFormat dateFormat; + + public ApiClient() { + this.restTemplate = buildRestTemplate(); + init(); + } + + public ApiClient(RestTemplate restTemplate) { + this.restTemplate = restTemplate; + init(); + } + + protected void init() { + // Use RFC3339 format for date and datetime. + // See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14 + this.dateFormat = new RFC3339DateFormat(); + + // Use UTC as the default time zone. + this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + + // Set default User-Agent. + setUserAgent("Java-SDK"); + + // Setup authentications (key: authentication name, value: authentication). + authentications = new HashMap(); + authentications.put("apiKey", new ApiKeyAuth("header", "Authorization")); + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); } /** - * URL encode a string in the UTF-8 encoding. + * Get the current base path * - * @param s String to encode. - * @return URL-encoded representation of the input string. + * @return String the base path */ - public static String urlEncode(String s) { - return URLEncoder.encode(s, UTF_8).replaceAll("\\+", "%20"); + public String getBasePath() { + return basePath; } /** - * Convert a URL query name/value parameter to a list of encoded {@link Pair} - * objects. - * - *

The value can be null, in which case an empty list is returned.

+ * Set the base path, which should include the host * - * @param name The query name parameter. - * @param value The query value, which may not be a collection but may be - * null. - * @return A singleton list of the {@link Pair} objects representing the input - * parameters, which is encoded for use in a URL. If the value is null, an - * empty list is returned. + * @param basePath the base path + * @return ApiClient this client */ - public static List parameterToPairs(String name, Object value) { - if (name == null || name.isEmpty() || value == null) { - return Collections.emptyList(); - } - return Collections.singletonList(new Pair(urlEncode(name), urlEncode(valueToString(value)))); + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + return this; } /** - * Convert a URL query name/collection parameter to a list of encoded - * {@link Pair} objects. + * Get the max attempts for retry * - * @param collectionFormat The swagger collectionFormat string (csv, tsv, etc). - * @param name The query name parameter. - * @param values A collection of values for the given query name, which may be - * null. - * @return A list of {@link Pair} objects representing the input parameters, - * which is encoded for use in a URL. If the values collection is null, an - * empty list is returned. + * @return int the max attempts */ - public static List parameterToPairs( - String collectionFormat, String name, Collection values) { - if (name == null || name.isEmpty() || values == null || values.isEmpty()) { - return Collections.emptyList(); - } - - // get the collection format (default: csv) - String format = collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat; - - // create the params based on the collection format - if ("multi".equals(format)) { - return values.stream() - .map(value -> new Pair(urlEncode(name), urlEncode(valueToString(value)))) - .collect(Collectors.toList()); - } - - String delimiter; - switch(format) { - case "csv": - delimiter = urlEncode(","); - break; - case "ssv": - delimiter = urlEncode(" "); - break; - case "tsv": - delimiter = urlEncode("\t"); - break; - case "pipes": - delimiter = urlEncode("|"); - break; - default: - throw new IllegalArgumentException("Illegal collection format: " + collectionFormat); - } - - StringJoiner joiner = new StringJoiner(delimiter); - for (Object value : values) { - joiner.add(urlEncode(valueToString(value))); - } + public int getMaxAttemptsForRetry() { + return maxAttemptsForRetry; + } - return Collections.singletonList(new Pair(urlEncode(name), joiner.toString())); + /** + * Set the max attempts for retry + * + * @param maxAttemptsForRetry the max attempts for retry + * @return ApiClient this client + */ + public ApiClient setMaxAttemptsForRetry(int maxAttemptsForRetry) { + this.maxAttemptsForRetry = maxAttemptsForRetry; + return this; } /** - * Create an instance of ApiClient. + * Get the wait time in milliseconds + * + * @return long wait time in milliseconds */ - public ApiClient() { - this.builder = createDefaultHttpClientBuilder(); - this.mapper = createDefaultObjectMapper(); - updateBaseUri(getDefaultBaseUri()); - interceptor = null; - readTimeout = null; - connectTimeout = null; - responseInterceptor = null; - asyncResponseInterceptor = null; + public long getWaitTimeMillis() { + return waitTimeMillis; } /** - * Create an instance of ApiClient. + * Set the wait time in milliseconds * - * @param builder Http client builder. - * @param mapper Object mapper. - * @param baseUri Base URI + * @param waitTimeMillis the wait time in milliseconds + * @return ApiClient this client */ - public ApiClient(HttpClient.Builder builder, ObjectMapper mapper, String baseUri) { - this.builder = builder; - this.mapper = mapper; - updateBaseUri(baseUri != null ? baseUri : getDefaultBaseUri()); - interceptor = null; - readTimeout = null; - connectTimeout = null; - responseInterceptor = null; - asyncResponseInterceptor = null; + public ApiClient setWaitTimeMillis(long waitTimeMillis) { + this.waitTimeMillis = waitTimeMillis; + return this; } - protected ObjectMapper createDefaultObjectMapper() { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false); - mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); - mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); - mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); - mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); - mapper.registerModule(new JavaTimeModule()); - mapper.registerModule(new JsonNullableModule()); - return mapper; + /** + * Get authentications (key: authentication name, value: authentication). + * + * @return Map the currently configured authentication types + */ + public Map getAuthentications() { + return authentications; } - protected String getDefaultBaseUri() { - return "https://app.documenso.com/api/v2"; + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); } - protected HttpClient.Builder createDefaultHttpClientBuilder() { - return HttpClient.newBuilder(); + /** + * Helper method to set API key value for the first API key authentication. + * + * @param apiKey the API key + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); } - public void updateBaseUri(String baseUri) { - URI uri = URI.create(baseUri); - scheme = uri.getScheme(); - host = uri.getHost(); - port = uri.getPort(); - basePath = uri.getRawPath(); + /** + * Helper method to set API key prefix for the first API key authentication. + * + * @param apiKeyPrefix API key prefix + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); } /** - * Set a custom {@link HttpClient.Builder} object to use when creating the - * {@link HttpClient} that is used by the API client. + * Set the User-Agent header's value (by adding to the default header map). * - * @param builder Custom client builder. - * @return This object. + * @param userAgent the user agent string + * @return ApiClient this client */ - public ApiClient setHttpClientBuilder(HttpClient.Builder builder) { - this.builder = builder; + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); return this; } /** - * Get an {@link HttpClient} based on the current {@link HttpClient.Builder}. - * - *

The returned object is immutable and thread-safe.

+ * Add a default header. * - * @return The HTTP client. + * @param name The header's name + * @param value The header's value + * @return ApiClient this client */ - public HttpClient getHttpClient() { - return builder.build(); + public ApiClient addDefaultHeader(String name, String value) { + if (defaultHeaders.containsKey(name)) { + defaultHeaders.remove(name); + } + defaultHeaders.add(name, value); + return this; } /** - * Set a custom {@link ObjectMapper} to serialize and deserialize the request - * and response bodies. + * Add a default cookie. * - * @param mapper Custom object mapper. - * @return This object. + * @param name The cookie's name + * @param value The cookie's value + * @return ApiClient this client */ - public ApiClient setObjectMapper(ObjectMapper mapper) { - this.mapper = mapper; + public ApiClient addDefaultCookie(String name, String value) { + if (defaultCookies.containsKey(name)) { + defaultCookies.remove(name); + } + defaultCookies.add(name, value); return this; } + public void setDebugging(boolean debugging) { + List currentInterceptors = this.restTemplate.getInterceptors(); + if (debugging) { + if (currentInterceptors == null) { + currentInterceptors = new ArrayList(); + } + ClientHttpRequestInterceptor interceptor = new ApiClientHttpRequestInterceptor(); + currentInterceptors.add(interceptor); + this.restTemplate.setInterceptors(currentInterceptors); + } else { + if (currentInterceptors != null && !currentInterceptors.isEmpty()) { + Iterator iter = currentInterceptors.iterator(); + while (iter.hasNext()) { + ClientHttpRequestInterceptor interceptor = iter.next(); + if (interceptor instanceof ApiClientHttpRequestInterceptor) { + iter.remove(); + } + } + this.restTemplate.setInterceptors(currentInterceptors); + } + } + this.debugging = debugging; + } + /** - * Get a copy of the current {@link ObjectMapper}. + * Check that whether debugging is enabled for this API client. * - * @return A copy of the current object mapper. + * @return boolean true if this client is enabled for debugging, false otherwise */ - public ObjectMapper getObjectMapper() { - return mapper.copy(); + public boolean isDebugging() { + return debugging; } /** - * Set a custom host name for the target service. + * Get the date format used to parse/format date parameters. * - * @param host The host name of the target service. - * @return This object. + * @return DateFormat format */ - public ApiClient setHost(String host) { - this.host = host; - return this; + public DateFormat getDateFormat() { + return dateFormat; } /** - * Set a custom port number for the target service. + * Set the date format used to parse/format date parameters. * - * @param port The port of the target service. Set this to -1 to reset the - * value to the default for the scheme. - * @return This object. + * @param dateFormat Date format + * @return API client */ - public ApiClient setPort(int port) { - this.port = port; + public ApiClient setDateFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; return this; } /** - * Set a custom base path for the target service, for example '/v2'. + * Parse the given string into Date object. * - * @param basePath The base path against which the rest of the path is - * resolved. - * @return This object. + * @param str the string to parse + * @return the Date parsed from the string */ - public ApiClient setBasePath(String basePath) { - this.basePath = basePath; - return this; + public Date parseDate(String str) { + try { + return dateFormat.parse(str); + } catch (ParseException e) { + throw new RuntimeException(e); + } } /** - * Get the base URI to resolve the endpoint paths against. + * Format the given Date object into string. * - * @return The complete base URI that the rest of the API parameters are - * resolved against. + * @param date the date to format + * @return the formatted date as string */ - public String getBaseUri() { - return scheme + "://" + host + (port == -1 ? "" : ":" + port) + basePath; + public String formatDate(Date date) { + return dateFormat.format(date); } /** - * Set a custom scheme for the target service, for example 'https'. + * Format the given parameter object into string. * - * @param scheme The scheme of the target service - * @return This object. + * @param param the object to convert + * @return String the parameter represented as a String */ - public ApiClient setScheme(String scheme){ - this.scheme = scheme; - return this; + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date) { + return formatDate((Date) param); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection) param) { + if (b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + return b.toString(); + } else { + return String.valueOf(param); + } } /** - * Set a custom request interceptor. - * - *

A request interceptor is a mechanism for altering each request before it - * is sent. After the request has been fully configured but not yet built, the - * request builder is passed into this function for further modification, - * after which it is sent out.

- * - *

This is useful for altering the requests in a custom manner, such as - * adding headers. It could also be used for logging and monitoring.

+ * Formats the specified collection path parameter to a string value. * - * @param interceptor A function invoked before creating each request. A value - * of null resets the interceptor to a no-op. - * @return This object. + * @param collectionFormat The collection format of the parameter. + * @param values The values of the parameter. + * @return String representation of the parameter */ - public ApiClient setRequestInterceptor(Consumer interceptor) { - this.interceptor = interceptor; - return this; + public String collectionPathParameterToString( + CollectionFormat collectionFormat, Collection values) { + // create the value based on the collection format + if (CollectionFormat.MULTI.equals(collectionFormat)) { + // not valid for path params + return parameterToString(values); + } + + // collectionFormat is assumed to be "csv" by default + if (collectionFormat == null) { + collectionFormat = CollectionFormat.CSV; + } + + return collectionFormat.collectionToString(values); } /** - * Get the custom interceptor. + * Converts a parameter to a {@link MultiValueMap} for use in REST requests * - * @return The custom interceptor that was set, or null if there isn't any. + * @param collectionFormat The format to convert to + * @param name The name of the parameter + * @param value The parameter's value + * @return a Map containing the String value(s) of the input parameter */ - public Consumer getRequestInterceptor() { - return interceptor; + public MultiValueMap parameterToMultiValueMap( + CollectionFormat collectionFormat, String name, Object value) { + final MultiValueMap params = new LinkedMultiValueMap(); + + if (name == null || name.isEmpty() || value == null) { + return params; + } + + if (collectionFormat == null) { + collectionFormat = CollectionFormat.CSV; + } + + if (value instanceof Map) { + @SuppressWarnings("unchecked") + final Map valuesMap = (Map) value; + for (final Entry entry : valuesMap.entrySet()) { + params.add(entry.getKey(), parameterToString(entry.getValue())); + } + return params; + } + + Collection valueCollection = null; + if (value instanceof Collection) { + valueCollection = (Collection) value; + } else { + params.add(name, parameterToString(value)); + return params; + } + + if (valueCollection.isEmpty()) { + return params; + } + + if (collectionFormat.equals(CollectionFormat.MULTI)) { + for (Object item : valueCollection) { + params.add(name, parameterToString(item)); + } + return params; + } + + List values = new ArrayList(); + for (Object o : valueCollection) { + values.add(parameterToString(o)); + } + params.add(name, collectionFormat.collectionToString(values)); + + return params; } /** - * Set a custom response interceptor. + * Check if the given {@code String} is a JSON MIME. * - *

This is useful for logging, monitoring or extraction of header variables

+ * @param mediaType the input MediaType + * @return boolean true if the MediaType represents JSON, false otherwise + */ + public boolean isJsonMime(String mediaType) { + // "* / *" is default to JSON + if ("*/*".equals(mediaType)) { + return true; + } + + try { + return isJsonMime(MediaType.parseMediaType(mediaType)); + } catch (InvalidMediaTypeException e) { + } + return false; + } + + /** + * Check if the given MIME is a JSON MIME. JSON MIME examples: application/json application/json; + * charset=UTF8 APPLICATION/JSON * - * @param interceptor A function invoked before creating each request. A value - * of null resets the interceptor to a no-op. - * @return This object. + * @param mediaType the input MediaType + * @return boolean true if the MediaType represents JSON, false otherwise */ - public ApiClient setResponseInterceptor(Consumer> interceptor) { - this.responseInterceptor = interceptor; - return this; + public boolean isJsonMime(MediaType mediaType) { + return mediaType != null + && (MediaType.APPLICATION_JSON.isCompatibleWith(mediaType) + || mediaType.getSubtype().matches("^.*\\+json[;]?\\s*$")); } - /** - * Get the custom response interceptor. + /** + * Check if the given {@code String} is a Problem JSON MIME (RFC-7807). * - * @return The custom interceptor that was set, or null if there isn't any. + * @param mediaType the input MediaType + * @return boolean true if the MediaType represents Problem JSON, false otherwise */ - public Consumer> getResponseInterceptor() { - return responseInterceptor; + public boolean isProblemJsonMime(String mediaType) { + return "application/problem+json".equalsIgnoreCase(mediaType); } /** - * Set a custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. + * Select the Accept header's value from the given accepts array: if JSON exists in the given + * array, use it; otherwise use all of them (joining into a string) * - *

This is useful for logging, monitoring or extraction of header variables

+ * @param accepts The accepts array to select from + * @return List The list of MediaTypes to use for the Accept header + */ + public List selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + MediaType mediaType = MediaType.parseMediaType(accept); + if (isJsonMime(mediaType) && !isProblemJsonMime(accept)) { + return Collections.singletonList(mediaType); + } + } + return MediaType.parseMediaTypes(StringUtils.arrayToCommaDelimitedString(accepts)); + } + + /** + * Select the Content-Type header's value from the given array: if JSON exists in the given array, + * use it; otherwise use the first one of the array. * - * @param interceptor A function invoked before creating each request. A value - * of null resets the interceptor to a no-op. - * @return This object. + * @param contentTypes The Content-Type array to select from + * @return MediaType The Content-Type header to use. If the given array is empty, JSON will be + * used. */ - public ApiClient setAsyncResponseInterceptor(Consumer> interceptor) { - this.asyncResponseInterceptor = interceptor; - return this; + public MediaType selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) { + return MediaType.APPLICATION_JSON; + } + for (String contentType : contentTypes) { + MediaType mediaType = MediaType.parseMediaType(contentType); + if (isJsonMime(mediaType)) { + return mediaType; + } + } + return MediaType.parseMediaType(contentTypes[0]); } - /** - * Get the custom async response interceptor. Use this interceptor when asyncNative is set to 'true'. + /** + * Select the body to use for the request * - * @return The custom interceptor that was set, or null if there isn't any. + * @param obj the body object + * @param formParams the form parameters + * @param contentType the content type of the request + * @return Object the selected body */ - public Consumer> getAsyncResponseInterceptor() { - return asyncResponseInterceptor; + protected Object selectBody( + Object obj, MultiValueMap formParams, MediaType contentType) { + boolean isForm = + MediaType.MULTIPART_FORM_DATA.isCompatibleWith(contentType) + || MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(contentType); + return isForm ? formParams : obj; } /** - * Set the read timeout for the http client. + * Expand path template with variables * - *

This is the value used by default for each request, though it can be - * overridden on a per-request basis with a request interceptor.

+ * @param pathTemplate path template with placeholders + * @param variables variables to replace + * @return path with placeholders replaced by variables + */ + public String expandPath(String pathTemplate, Map variables) { + return restTemplate.getUriTemplateHandler().expand(pathTemplate, variables).toString(); + } + + /** + * Include queryParams in uriParams taking into account the paramName * - * @param readTimeout The read timeout used by default by the http client. - * Setting this value to null resets the timeout to an - * effectively infinite value. - * @return This object. + * @param queryParams The query parameters + * @param uriParams The path parameters return templatized query string */ - public ApiClient setReadTimeout(Duration readTimeout) { - this.readTimeout = readTimeout; - return this; + public String generateQueryUri( + MultiValueMap queryParams, Map uriParams) { + StringBuilder queryBuilder = new StringBuilder(); + queryParams.forEach( + (name, values) -> { + try { + final String encodedName = URLEncoder.encode(name.toString(), "UTF-8"); + if (CollectionUtils.isEmpty(values)) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(encodedName); + } else { + int valueItemCounter = 0; + for (Object value : values) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(encodedName); + if (value != null) { + String templatizedKey = encodedName + valueItemCounter++; + uriParams.put(templatizedKey, value.toString()); + queryBuilder.append('=').append("{").append(templatizedKey).append("}"); + } + } + } + } catch (UnsupportedEncodingException e) { + + } + }); + return queryBuilder.toString(); + } + + /** + * Invoke API by sending HTTP request with the given options. + * + * @param the return type to use + * @param path The sub-path of the HTTP URL + * @param method The request method + * @param pathParams The path parameters + * @param queryParams The query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param accept The request's Accept header + * @param contentType The request's Content-Type header + * @param authNames The authentications to apply + * @param returnType The return type into which to deserialize the response + * @return ResponseEntity<T> The response of the chosen type + */ + public ResponseEntity invokeAPI( + String path, + HttpMethod method, + Map pathParams, + MultiValueMap queryParams, + Object body, + HttpHeaders headerParams, + MultiValueMap cookieParams, + MultiValueMap formParams, + List accept, + MediaType contentType, + String[] authNames, + ParameterizedTypeReference returnType) + throws RestClientException { + updateParamsForAuth(authNames, queryParams, headerParams, cookieParams); + + Map uriParams = new HashMap<>(); + uriParams.putAll(pathParams); + + String finalUri = path; + + if (queryParams != null && !queryParams.isEmpty()) { + // Include queryParams in uriParams taking into account the paramName + String queryUri = generateQueryUri(queryParams, uriParams); + // Append to finalUri the templatized query string like "?param1={param1Value}&....... + finalUri += "?" + queryUri; + } + String expandedPath = this.expandPath(finalUri, uriParams); + final UriComponentsBuilder builder = + UriComponentsBuilder.fromHttpUrl(basePath).path(expandedPath); + + URI uri; + try { + uri = new URI(builder.build().toUriString()); + } catch (URISyntaxException ex) { + throw new RestClientException("Could not build URL: " + builder.toUriString(), ex); + } + + final BodyBuilder requestBuilder = + RequestEntity.method( + method, UriComponentsBuilder.fromHttpUrl(basePath).toUriString() + finalUri, uriParams); + if (accept != null) { + requestBuilder.accept(accept.toArray(new MediaType[accept.size()])); + } + if (contentType != null) { + requestBuilder.contentType(contentType); + } + + addHeadersToRequest(headerParams, requestBuilder); + addHeadersToRequest(defaultHeaders, requestBuilder); + addCookiesToRequest(cookieParams, requestBuilder); + addCookiesToRequest(defaultCookies, requestBuilder); + + RequestEntity requestEntity = + requestBuilder.body(selectBody(body, formParams, contentType)); + + ResponseEntity responseEntity = null; + int attempts = 0; + while (attempts < maxAttemptsForRetry) { + try { + responseEntity = restTemplate.exchange(requestEntity, returnType); + break; + } catch (HttpServerErrorException | HttpClientErrorException ex) { + if (ex instanceof HttpServerErrorException + || ((HttpClientErrorException) ex) + .getStatusCode() + .equals(HttpStatus.TOO_MANY_REQUESTS)) { + attempts++; + if (attempts < maxAttemptsForRetry) { + try { + Thread.sleep(waitTimeMillis); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } else { + throw ex; + } + } else { + throw ex; + } + } + } + + if (responseEntity == null) { + throw new RestClientException("ResponseEntity is null"); + } + + if (responseEntity.getStatusCode().is2xxSuccessful()) { + return responseEntity; + } else { + // The error handler built into the RestTemplate should handle 400 and 500 series errors. + throw new RestClientException( + "API returned " + + responseEntity.getStatusCode() + + " and it wasn't handled by the RestTemplate error handler"); + } } /** - * Get the read timeout that was set. + * Add headers to the request that is being built * - * @return The read timeout, or null if no timeout was set. Null represents - * an infinite wait time. + * @param headers The headers to add + * @param requestBuilder The current request */ - public Duration getReadTimeout() { - return readTimeout; + protected void addHeadersToRequest(HttpHeaders headers, BodyBuilder requestBuilder) { + for (Entry> entry : headers.entrySet()) { + List values = entry.getValue(); + for (String value : values) { + if (value != null) { + requestBuilder.header(entry.getKey(), value); + } + } + } } + /** - * Sets the connect timeout (in milliseconds) for the http client. + * Add cookies to the request that is being built * - *

In the case where a new connection needs to be established, if - * the connection cannot be established within the given {@code - * duration}, then {@link HttpClient#send(HttpRequest,BodyHandler) - * HttpClient::send} throws an {@link HttpConnectTimeoutException}, or - * {@link HttpClient#sendAsync(HttpRequest,BodyHandler) - * HttpClient::sendAsync} completes exceptionally with an - * {@code HttpConnectTimeoutException}. If a new connection does not - * need to be established, for example if a connection can be reused - * from a previous request, then this timeout duration has no effect. + * @param cookies The cookies to add + * @param requestBuilder The current request + */ + protected void addCookiesToRequest( + MultiValueMap cookies, BodyBuilder requestBuilder) { + if (!cookies.isEmpty()) { + requestBuilder.header("Cookie", buildCookieHeader(cookies)); + } + } + + /** + * Build cookie header. Keeps a single value per cookie (as per RFC6265 section 5.3). * - * @param connectTimeout connection timeout in milliseconds + * @param cookies map all cookies + * @return header string for cookies. + */ + private String buildCookieHeader(MultiValueMap cookies) { + final StringBuilder cookieValue = new StringBuilder(); + String delimiter = ""; + for (final Map.Entry> entry : cookies.entrySet()) { + final String value = entry.getValue().get(entry.getValue().size() - 1); + cookieValue.append(String.format("%s%s=%s", delimiter, entry.getKey(), value)); + delimiter = "; "; + } + return cookieValue.toString(); + } + + /** + * Build the RestTemplate used to make HTTP requests. * - * @return This object. + * @return RestTemplate */ - public ApiClient setConnectTimeout(Duration connectTimeout) { - this.connectTimeout = connectTimeout; - this.builder.connectTimeout(connectTimeout); - return this; + protected RestTemplate buildRestTemplate() { + RestTemplate restTemplate = new RestTemplate(); + // This allows us to read the response more than once - Necessary for debugging. + restTemplate.setRequestFactory( + new BufferingClientHttpRequestFactory(restTemplate.getRequestFactory())); + + // disable default URL encoding + DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory(); + uriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY); + restTemplate.setUriTemplateHandler(uriBuilderFactory); + return restTemplate; } /** - * Get connection timeout (in milliseconds). + * Update query and header parameters based on authentication settings. * - * @return Timeout in milliseconds + * @param authNames The authentications to apply + * @param queryParams The query parameters + * @param headerParams The header parameters */ - public Duration getConnectTimeout() { - return connectTimeout; + protected void updateParamsForAuth( + String[] authNames, + MultiValueMap queryParams, + HttpHeaders headerParams, + MultiValueMap cookieParams) { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) { + throw new RestClientException("Authentication undefined: " + authName); + } + auth.applyToParams(queryParams, headerParams, cookieParams); + } + } + + private class ApiClientHttpRequestInterceptor implements ClientHttpRequestInterceptor { + private final Log log = LogFactory.getLog(ApiClientHttpRequestInterceptor.class); + + @Override + public ClientHttpResponse intercept( + HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { + logRequest(request, body); + ClientHttpResponse response = execution.execute(request, body); + logResponse(response); + return response; + } + + private void logRequest(HttpRequest request, byte[] body) throws UnsupportedEncodingException { + log.info("URI: " + request.getURI()); + log.info("HTTP Method: " + request.getMethod()); + log.info("HTTP Headers: " + headersToString(request.getHeaders())); + log.info("Request Body: " + new String(body, StandardCharsets.UTF_8)); + } + + private void logResponse(ClientHttpResponse response) throws IOException { + log.info("HTTP Status Code: " + response.getStatusCode().value()); + log.info("Status Text: " + response.getStatusText()); + log.info("HTTP Headers: " + headersToString(response.getHeaders())); + log.info("Response Body: " + bodyToString(response.getBody())); + } + + private String headersToString(HttpHeaders headers) { + if (headers == null || headers.isEmpty()) { + return ""; + } + StringBuilder builder = new StringBuilder(); + for (Entry> entry : headers.entrySet()) { + builder.append(entry.getKey()).append("=["); + for (String value : entry.getValue()) { + builder.append(value).append(","); + } + builder.setLength(builder.length() - 1); // Get rid of trailing comma + builder.append("],"); + } + builder.setLength(builder.length() - 1); // Get rid of trailing comma + return builder.toString(); + } + + private String bodyToString(InputStream body) throws IOException { + StringBuilder builder = new StringBuilder(); + BufferedReader bufferedReader = + new BufferedReader(new InputStreamReader(body, StandardCharsets.UTF_8)); + String line = bufferedReader.readLine(); + while (line != null) { + builder.append(line).append(System.lineSeparator()); + line = bufferedReader.readLine(); + } + bufferedReader.close(); + return builder.toString(); + } } } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiException.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiException.java deleted file mode 100644 index 94f5f76dd..000000000 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiException.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Documenso v2 API (client subset) - * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package school.hei.haapi.service.documenso.gen.invoker; - -import java.net.http.HttpHeaders; - -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") -public class ApiException extends Exception { - private static final long serialVersionUID = 1L; - - private int code = 0; - private HttpHeaders responseHeaders = null; - private String responseBody = null; - - public ApiException() {} - - public ApiException(Throwable throwable) { - super(throwable); - } - - public ApiException(String message) { - super(message); - } - - public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders, String responseBody) { - super(message, throwable); - this.code = code; - this.responseHeaders = responseHeaders; - this.responseBody = responseBody; - } - - public ApiException(String message, int code, HttpHeaders responseHeaders, String responseBody) { - this(message, (Throwable) null, code, responseHeaders, responseBody); - } - - public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders) { - this(message, throwable, code, responseHeaders, null); - } - - public ApiException(int code, HttpHeaders responseHeaders, String responseBody) { - this((String) null, (Throwable) null, code, responseHeaders, responseBody); - } - - public ApiException(int code, String message) { - super(message); - this.code = code; - } - - public ApiException(int code, String message, HttpHeaders responseHeaders, String responseBody) { - this(code, message); - this.responseHeaders = responseHeaders; - this.responseBody = responseBody; - } - - /** - * Get the HTTP status code. - * - * @return HTTP status code - */ - public int getCode() { - return code; - } - - /** - * Get the HTTP response headers. - * - * @return Headers as an HttpHeaders object - */ - public HttpHeaders getResponseHeaders() { - return responseHeaders; - } - - /** - * Get the HTTP response body. - * - * @return Response body in the form of string - */ - public String getResponseBody() { - return responseBody; - } -} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiResponse.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiResponse.java deleted file mode 100644 index d9d480675..000000000 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ApiResponse.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Documenso v2 API (client subset) - * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package school.hei.haapi.service.documenso.gen.invoker; - -import java.util.List; -import java.util.Map; - -/** - * API response returned by API call. - * - * @param The type of data that is deserialized from response body - */ -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") -public class ApiResponse { - final private int statusCode; - final private Map> headers; - final private T data; - - /** - * @param statusCode The status code of HTTP response - * @param headers The headers of HTTP response - */ - public ApiResponse(int statusCode, Map> headers) { - this(statusCode, headers, null); - } - - /** - * @param statusCode The status code of HTTP response - * @param headers The headers of HTTP response - * @param data The object deserialized from response bod - */ - public ApiResponse(int statusCode, Map> headers, T data) { - this.statusCode = statusCode; - this.headers = headers; - this.data = data; - } - - public int getStatusCode() { - return statusCode; - } - - public Map> getHeaders() { - return headers; - } - - public T getData() { - return data; - } -} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/BaseApi.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/BaseApi.java new file mode 100644 index 000000000..49190d107 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/BaseApi.java @@ -0,0 +1,90 @@ +package school.hei.haapi.service.documenso.gen.invoker; + +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestClientException; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public abstract class BaseApi { + + protected ApiClient apiClient; + + public BaseApi() { + this(new ApiClient()); + } + + public BaseApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + public ApiClient getApiClient() { + return apiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for + * subsequent requests. + * + * @param url The URL for the request, either full URL or only the path. + * @param method The HTTP method for the request. + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity invokeAPI(String url, HttpMethod method) throws RestClientException { + return invokeAPI(url, method, null, new ParameterizedTypeReference() {}); + } + + /** + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for + * subsequent requests. + * + * @param url The URL for the request, either full URL or only the path. + * @param method The HTTP method for the request. + * @param request The request object. + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity invokeAPI(String url, HttpMethod method, Object request) + throws RestClientException { + return invokeAPI(url, method, request, new ParameterizedTypeReference() {}); + } + + /** + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for + * subsequent requests. + * + * @param url The URL for the request, either full URL or only the path. + * @param method The HTTP method for the request. + * @param returnType The return type. + * @return ResponseEntity in the specified type. + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity invokeAPI( + String url, HttpMethod method, ParameterizedTypeReference returnType) + throws RestClientException { + return invokeAPI(url, method, null, returnType); + } + + /** + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for + * subsequent requests. + * + * @param url The URL for the request, either full URL or only the path. + * @param method The HTTP method for the request. + * @param request The request object. + * @param returnType The return type. + * @return ResponseEntity in the specified type. + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public abstract ResponseEntity invokeAPI( + String url, HttpMethod method, Object request, ParameterizedTypeReference returnType) + throws RestClientException; +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Configuration.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Configuration.java deleted file mode 100644 index 676144ce0..000000000 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Configuration.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Documenso v2 API (client subset) - * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package school.hei.haapi.service.documenso.gen.invoker; - -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") -public class Configuration { - public static final String VERSION = "1.0.0"; - - private static ApiClient defaultApiClient = new ApiClient(); - - /** - * Get the default API client, which would be used when creating API - * instances without providing an API client. - * - * @return Default API client - */ - public static ApiClient getDefaultApiClient() { - return defaultApiClient; - } - - /** - * Set the default API client, which would be used when creating API - * instances without providing an API client. - * - * @param apiClient API client - */ - public static void setDefaultApiClient(ApiClient apiClient) { - defaultApiClient = apiClient; - } -} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/JSON.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/JSON.java deleted file mode 100644 index 647904452..000000000 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/JSON.java +++ /dev/null @@ -1,251 +0,0 @@ -package school.hei.haapi.service.documenso.gen.invoker; - -import com.fasterxml.jackson.annotation.*; -import com.fasterxml.jackson.databind.*; -import com.fasterxml.jackson.databind.json.JsonMapper; -import org.openapitools.jackson.nullable.JsonNullableModule; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import school.hei.haapi.service.documenso.gen.model.*; - -import java.text.DateFormat; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") -public class JSON { - private ObjectMapper mapper; - - public JSON() { - mapper = JsonMapper.builder() - .serializationInclusion(JsonInclude.Include.NON_NULL) - .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) - .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .enable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE) - .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - .enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING) - .enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING) - .defaultDateFormat(new RFC3339DateFormat()) - .addModule(new JavaTimeModule()) - .build(); - JsonNullableModule jnm = new JsonNullableModule(); - mapper.registerModule(jnm); - } - - /** - * Set the date format for JSON (de)serialization with Date properties. - * - * @param dateFormat Date format - */ - public void setDateFormat(DateFormat dateFormat) { - mapper.setDateFormat(dateFormat); - } - - /** - * Get the object mapper - * - * @return object mapper - */ - public ObjectMapper getMapper() { return mapper; } - - /** - * Returns the target model class that should be used to deserialize the input data. - * The discriminator mappings are used to determine the target model class. - * - * @param node The input data. - * @param modelClass The class that contains the discriminator mappings. - * - * @return the target model class. - */ - public static Class getClassForElement(JsonNode node, Class modelClass) { - ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass); - if (cdm != null) { - return cdm.getClassForElement(node, new HashSet>()); - } - return null; - } - - /** - * Helper class to register the discriminator mappings. - */ - @jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") - private static class ClassDiscriminatorMapping { - // The model class name. - Class modelClass; - // The name of the discriminator property. - String discriminatorName; - // The discriminator mappings for a model class. - Map> discriminatorMappings; - - // Constructs a new class discriminator. - ClassDiscriminatorMapping(Class cls, String propertyName, Map> mappings) { - modelClass = cls; - discriminatorName = propertyName; - discriminatorMappings = new HashMap>(); - if (mappings != null) { - discriminatorMappings.putAll(mappings); - } - } - - // Return the name of the discriminator property for this model class. - String getDiscriminatorPropertyName() { - return discriminatorName; - } - - // Return the discriminator value or null if the discriminator is not - // present in the payload. - String getDiscriminatorValue(JsonNode node) { - // Determine the value of the discriminator property in the input data. - if (discriminatorName != null) { - // Get the value of the discriminator property, if present in the input payload. - node = node.get(discriminatorName); - if (node != null && node.isValueNode()) { - String discrValue = node.asText(); - if (discrValue != null) { - return discrValue; - } - } - } - return null; - } - - /** - * Returns the target model class that should be used to deserialize the input data. - * This function can be invoked for anyOf/oneOf composed models with discriminator mappings. - * The discriminator mappings are used to determine the target model class. - * - * @param node The input data. - * @param visitedClasses The set of classes that have already been visited. - * - * @return the target model class. - */ - Class getClassForElement(JsonNode node, Set> visitedClasses) { - if (visitedClasses.contains(modelClass)) { - // Class has already been visited. - return null; - } - // Determine the value of the discriminator property in the input data. - String discrValue = getDiscriminatorValue(node); - if (discrValue == null) { - return null; - } - Class cls = discriminatorMappings.get(discrValue); - // It may not be sufficient to return this cls directly because that target class - // may itself be a composed schema, possibly with its own discriminator. - visitedClasses.add(modelClass); - for (Class childClass : discriminatorMappings.values()) { - ClassDiscriminatorMapping childCdm = modelDiscriminators.get(childClass); - if (childCdm == null) { - continue; - } - if (!discriminatorName.equals(childCdm.discriminatorName)) { - discrValue = getDiscriminatorValue(node); - if (discrValue == null) { - continue; - } - } - if (childCdm != null) { - // Recursively traverse the discriminator mappings. - Class childDiscr = childCdm.getClassForElement(node, visitedClasses); - if (childDiscr != null) { - return childDiscr; - } - } - } - return cls; - } - } - - /** - * Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy. - * - * The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy, - * so it's not possible to use the instanceof keyword. - * - * @param modelClass A OpenAPI model class. - * @param inst The instance object. - * @param visitedClasses The set of classes that have already been visited. - * - * @return true if inst is an instance of modelClass in the OpenAPI model hierarchy. - */ - public static boolean isInstanceOf(Class modelClass, Object inst, Set> visitedClasses) { - if (modelClass.isInstance(inst)) { - // This handles the 'allOf' use case with single parent inheritance. - return true; - } - if (visitedClasses.contains(modelClass)) { - // This is to prevent infinite recursion when the composed schemas have - // a circular dependency. - return false; - } - visitedClasses.add(modelClass); - - // Traverse the oneOf/anyOf composed schemas. - Map> descendants = modelDescendants.get(modelClass); - if (descendants != null) { - for (Class childType : descendants.values()) { - if (isInstanceOf(childType, inst, visitedClasses)) { - return true; - } - } - } - return false; - } - - /** - * A map of discriminators for all model classes. - */ - private static Map, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<>(); - - /** - * A map of oneOf/anyOf descendants for each model class. - */ - private static Map, Map>> modelDescendants = new HashMap<>(); - - /** - * Register a model class discriminator. - * - * @param modelClass the model class - * @param discriminatorPropertyName the name of the discriminator property - * @param mappings a map with the discriminator mappings. - */ - public static void registerDiscriminator(Class modelClass, String discriminatorPropertyName, Map> mappings) { - ClassDiscriminatorMapping m = new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings); - modelDiscriminators.put(modelClass, m); - } - - /** - * Register the oneOf/anyOf descendants of the modelClass. - * - * @param modelClass the model class - * @param descendants a map of oneOf/anyOf descendants. - */ - public static void registerDescendants(Class modelClass, Map> descendants) { - modelDescendants.put(modelClass, descendants); - } - - private static JSON json; - - static { - json = new JSON(); - } - - /** - * Get the default JSON instance. - * - * @return the default JSON instance - */ - public static JSON getDefault() { - return json; - } - - /** - * Set the default JSON instance. - * - * @param json JSON instance to be used - */ - public static void setDefault(JSON json) { - JSON.json = json; - } -} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Pair.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Pair.java deleted file mode 100644 index 6e80b8da3..000000000 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/Pair.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Documenso v2 API (client subset) - * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package school.hei.haapi.service.documenso.gen.invoker; - -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") -public class Pair { - private String name = ""; - private String value = ""; - - public Pair (String name, String value) { - setName(name); - setValue(value); - } - - private void setName(String name) { - if (!isValidString(name)) { - return; - } - - this.name = name; - } - - private void setValue(String value) { - if (!isValidString(value)) { - return; - } - - this.value = value; - } - - public String getName() { - return this.name; - } - - public String getValue() { - return this.value; - } - - private boolean isValidString(String arg) { - if (arg == null) { - return false; - } - - return true; - } -} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/RFC3339DateFormat.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/RFC3339DateFormat.java index 5c15c5de1..c37f87f02 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/RFC3339DateFormat.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/RFC3339DateFormat.java @@ -3,7 +3,7 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -13,23 +13,24 @@ package school.hei.haapi.service.documenso.gen.invoker; import com.fasterxml.jackson.databind.util.StdDateFormat; - import java.text.DateFormat; +import java.text.DecimalFormat; import java.text.FieldPosition; import java.text.ParsePosition; import java.util.Date; -import java.text.DecimalFormat; import java.util.GregorianCalendar; import java.util.TimeZone; -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class RFC3339DateFormat extends DateFormat { private static final long serialVersionUID = 1L; private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); - private final StdDateFormat fmt = new StdDateFormat() - .withTimeZone(TIMEZONE_Z) - .withColonInTimeZone(true); + private final StdDateFormat fmt = + new StdDateFormat().withTimeZone(TIMEZONE_Z).withColonInTimeZone(true); public RFC3339DateFormat() { this.calendar = new GregorianCalendar(); diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerConfiguration.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerConfiguration.java index 38e461e82..dbc80750f 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerConfiguration.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerConfiguration.java @@ -2,58 +2,62 @@ import java.util.Map; -/** - * Representing a Server configuration. - */ -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +/** Representing a Server configuration. */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class ServerConfiguration { - public String URL; - public String description; - public Map variables; + public String URL; + public String description; + public Map variables; - /** - * @param URL A URL to the target host. - * @param description A description of the host designated by the URL. - * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. - */ - public ServerConfiguration(String URL, String description, Map variables) { - this.URL = URL; - this.description = description; - this.variables = variables; - } + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for + * substitution in the server's URL template. + */ + public ServerConfiguration( + String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } - /** - * Format URL template using given variables. - * - * @param variables A map between a variable name and its value. - * @return Formatted URL. - */ - public String URL(Map variables) { - String url = this.URL; + /** + * Format URL template using given variables. + * + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; - // go through variables and replace placeholders - for (Map.Entry variable: this.variables.entrySet()) { - String name = variable.getKey(); - ServerVariable serverVariable = variable.getValue(); - String value = serverVariable.defaultValue; + // go through variables and replace placeholders + for (Map.Entry variable : this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; - if (variables != null && variables.containsKey(name)) { - value = variables.get(name); - if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { - throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + "."); - } - } - url = url.replace("{" + name + "}", value); + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { + throw new IllegalArgumentException( + "The variable " + name + " in the server URL has invalid value " + value + "."); } - return url; + } + url = url.replace("{" + name + "}", value); } + return url; + } - /** - * Format URL template using default server variables. - * - * @return Formatted URL. - */ - public String URL() { - return URL(null); - } + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerVariable.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerVariable.java index 26a4c8bc7..bc98cc6f4 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerVariable.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/ServerVariable.java @@ -2,23 +2,25 @@ import java.util.HashSet; -/** - * Representing a Server Variable for server URL template substitution. - */ -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +/** Representing a Server Variable for server URL template substitution. */ +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class ServerVariable { - public String description; - public String defaultValue; - public HashSet enumValues = null; + public String description; + public String defaultValue; + public HashSet enumValues = null; - /** - * @param description A description for the server variable. - * @param defaultValue The default value to use for substitution. - * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. - */ - public ServerVariable(String description, String defaultValue, HashSet enumValues) { - this.description = description; - this.defaultValue = defaultValue; - this.enumValues = enumValues; - } + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are + * from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } } diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/ApiKeyAuth.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/ApiKeyAuth.java new file mode 100644 index 000000000..c4131a9ec --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/ApiKeyAuth.java @@ -0,0 +1,68 @@ +package school.hei.haapi.service.documenso.gen.invoker.auth; + +import org.springframework.http.HttpHeaders; +import org.springframework.util.MultiValueMap; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class ApiKeyAuth implements Authentication { + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams( + MultiValueMap queryParams, + HttpHeaders headerParams, + MultiValueMap cookieParams) { + if (apiKey == null) { + return; + } + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if (location.equals("query")) { + queryParams.add(paramName, value); + } else if (location.equals("header")) { + headerParams.add(paramName, value); + } else if (location.equals("cookie")) { + cookieParams.add(paramName, value); + } + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/Authentication.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/Authentication.java new file mode 100644 index 000000000..8e008dcbf --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/Authentication.java @@ -0,0 +1,18 @@ +package school.hei.haapi.service.documenso.gen.invoker.auth; + +import org.springframework.http.HttpHeaders; +import org.springframework.util.MultiValueMap; + +public interface Authentication { + /** + * Apply authentication settings to header and / or query parameters. + * + * @param queryParams The query parameters for the request + * @param headerParams The header parameters for the request + * @param cookieParams The cookie parameters for the request + */ + public void applyToParams( + MultiValueMap queryParams, + HttpHeaders headerParams, + MultiValueMap cookieParams); +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/HttpBasicAuth.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/HttpBasicAuth.java new file mode 100644 index 000000000..f75300eff --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/HttpBasicAuth.java @@ -0,0 +1,45 @@ +package school.hei.haapi.service.documenso.gen.invoker.auth; + +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import org.springframework.http.HttpHeaders; +import org.springframework.util.MultiValueMap; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams( + MultiValueMap queryParams, + HttpHeaders headerParams, + MultiValueMap cookieParams) { + if (username == null && password == null) { + return; + } + String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); + headerParams.add( + HttpHeaders.AUTHORIZATION, + "Basic " + Base64.getEncoder().encodeToString(str.getBytes(StandardCharsets.UTF_8))); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/HttpBearerAuth.java b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/HttpBearerAuth.java new file mode 100644 index 000000000..896afcf39 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/gen/invoker/auth/HttpBearerAuth.java @@ -0,0 +1,67 @@ +package school.hei.haapi.service.documenso.gen.invoker.auth; + +import java.util.Optional; +import java.util.function.Supplier; +import org.springframework.http.HttpHeaders; +import org.springframework.util.MultiValueMap; + +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") +public class HttpBearerAuth implements Authentication { + private final String scheme; + private Supplier tokenSupplier; + + public HttpBearerAuth(String scheme) { + this.scheme = scheme; + } + + /** + * Gets the token, which together with the scheme, will be sent as the value of the Authorization + * header. + * + * @return The bearer token + */ + public String getBearerToken() { + return tokenSupplier.get(); + } + + /** + * Sets the token, which together with the scheme, will be sent as the value of the Authorization + * header. + * + * @param bearerToken The bearer token to send in the Authorization header + */ + public void setBearerToken(String bearerToken) { + this.tokenSupplier = () -> bearerToken; + } + + /** + * Sets the supplier of tokens, which together with the scheme, will be sent as the value of the + * Authorization header. + * + * @param tokenSupplier The supplier of bearer tokens to send in the Authorization header + */ + public void setBearerToken(Supplier tokenSupplier) { + this.tokenSupplier = tokenSupplier; + } + + @Override + public void applyToParams( + MultiValueMap queryParams, + HttpHeaders headerParams, + MultiValueMap cookieParams) { + String bearerToken = Optional.ofNullable(tokenSupplier).map(Supplier::get).orElse(null); + if (bearerToken == null) { + return; + } + headerParams.add( + HttpHeaders.AUTHORIZATION, + (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken); + } + + private static String upperCaseBearer(String scheme) { + return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme; + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/AbstractOpenApiSchema.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/AbstractOpenApiSchema.java deleted file mode 100644 index 4e8879a07..000000000 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/AbstractOpenApiSchema.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Documenso v2 API (client subset) - * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package school.hei.haapi.service.documenso.gen.model; - -import java.util.Objects; -import java.lang.reflect.Type; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec - */ -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") -public abstract class AbstractOpenApiSchema { - - // store the actual instance of the schema/object - private Object instance; - - // is nullable - private Boolean isNullable; - - // schema type (e.g. oneOf, anyOf) - private final String schemaType; - - public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { - this.schemaType = schemaType; - this.isNullable = isNullable; - } - - /** - * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object - * - * @return an instance of the actual schema/object - */ - public abstract Map> getSchemas(); - - /** - * Get the actual instance - * - * @return an instance of the actual schema/object - */ - @JsonValue - public Object getActualInstance() {return instance;} - - /** - * Set the actual instance - * - * @param instance the actual instance of the schema/object - */ - public void setActualInstance(Object instance) {this.instance = instance;} - - /** - * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well - * - * @return an instance of the actual schema/object - */ - public Object getActualInstanceRecursively() { - return getActualInstanceRecursively(this); - } - - private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { - if (object.getActualInstance() == null) { - return null; - } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { - return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance()); - } else { - return object.getActualInstance(); - } - } - - /** - * Get the schema type (e.g. anyOf, oneOf) - * - * @return the schema type - */ - public String getSchemaType() { - return schemaType; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ").append(getClass()).append(" {\n"); - sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); - sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); - sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; - return Objects.equals(this.instance, a.instance) && - Objects.equals(this.isNullable, a.isNullable) && - Objects.equals(this.schemaType, a.schemaType); - } - - @Override - public int hashCode() { - return Objects.hash(instance, isNullable, schemaType); - } - - /** - * Is nullable - * - * @return true if it's nullable - */ - public Boolean isNullable() { - if (Boolean.TRUE.equals(isNullable)) { - return Boolean.TRUE; - } else { - return Boolean.FALSE; - } - } - - - -} diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/DocumentGet200Response.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/DocumentGet200Response.java index 2149c982e..f3b1b7cbd 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/DocumentGet200Response.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/DocumentGet200Response.java @@ -3,37 +3,26 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package school.hei.haapi.service.documenso.gen.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; -import java.util.Objects; -import java.util.Map; -import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.math.BigDecimal; -import java.util.Arrays; import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - +import java.math.BigDecimal; +import java.util.Objects; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -/** - * DocumentGet200Response - */ +/** DocumentGet200Response */ @JsonPropertyOrder({ DocumentGet200Response.JSON_PROPERTY_ID, DocumentGet200Response.JSON_PROPERTY_STATUS, @@ -41,23 +30,25 @@ DocumentGet200Response.JSON_PROPERTY_CREATED_AT, DocumentGet200Response.JSON_PROPERTY_COMPLETED_AT }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +@JsonTypeName("document_get_200_response") +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class DocumentGet200Response implements Serializable { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_ID = "id"; private BigDecimal id; - /** - * Gets or Sets status - */ + /** Gets or Sets status */ public enum StatusEnum { DRAFT("DRAFT"), - + PENDING("PENDING"), - + COMPLETED("COMPLETED"), - + REJECTED("REJECTED"); private String value; @@ -99,16 +90,17 @@ public static StatusEnum fromValue(String value) { public static final String JSON_PROPERTY_COMPLETED_AT = "completedAt"; private String completedAt; - public DocumentGet200Response() { - } + public DocumentGet200Response() {} public DocumentGet200Response id(BigDecimal id) { + this.id = id; return this; } /** * Get id + * * @return id */ @jakarta.annotation.Nonnull @@ -118,21 +110,21 @@ public BigDecimal getId() { return id; } - @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } - public DocumentGet200Response status(StatusEnum status) { + this.status = status; return this; } /** * Get status + * * @return status */ @jakarta.annotation.Nonnull @@ -142,21 +134,21 @@ public StatusEnum getStatus() { return status; } - @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setStatus(StatusEnum status) { this.status = status; } - public DocumentGet200Response title(String title) { + this.title = title; return this; } /** * Get title + * * @return title */ @jakarta.annotation.Nullable @@ -166,21 +158,21 @@ public String getTitle() { return title; } - @JsonProperty(JSON_PROPERTY_TITLE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTitle(String title) { this.title = title; } - public DocumentGet200Response createdAt(String createdAt) { + this.createdAt = createdAt; return this; } /** * Get createdAt + * * @return createdAt */ @jakarta.annotation.Nullable @@ -190,21 +182,21 @@ public String getCreatedAt() { return createdAt; } - @JsonProperty(JSON_PROPERTY_CREATED_AT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCreatedAt(String createdAt) { this.createdAt = createdAt; } - public DocumentGet200Response completedAt(String completedAt) { + this.completedAt = completedAt; return this; } /** * Get completedAt + * * @return completedAt */ @jakarta.annotation.Nullable @@ -214,17 +206,12 @@ public String getCompletedAt() { return completedAt; } - @JsonProperty(JSON_PROPERTY_COMPLETED_AT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCompletedAt(String completedAt) { this.completedAt = completedAt; } - - /** - * Return true if this document_get_200_response object is equal to o. - */ @Override public boolean equals(Object o) { if (this == o) { @@ -234,11 +221,11 @@ public boolean equals(Object o) { return false; } DocumentGet200Response documentGet200Response = (DocumentGet200Response) o; - return Objects.equals(this.id, documentGet200Response.id) && - Objects.equals(this.status, documentGet200Response.status) && - Objects.equals(this.title, documentGet200Response.title) && - Objects.equals(this.createdAt, documentGet200Response.createdAt) && - Objects.equals(this.completedAt, documentGet200Response.completedAt); + return Objects.equals(this.id, documentGet200Response.id) + && Objects.equals(this.status, documentGet200Response.status) + && Objects.equals(this.title, documentGet200Response.title) + && Objects.equals(this.createdAt, documentGet200Response.createdAt) + && Objects.equals(this.completedAt, documentGet200Response.completedAt); } @Override @@ -260,8 +247,7 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). + * Convert the given object to string with each line indented by 4 spaces (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -269,65 +255,4 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } - - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - // add `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `status` to the URL query string - if (getStatus() != null) { - joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `title` to the URL query string - if (getTitle() != null) { - joiner.add(String.format("%stitle%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `createdAt` to the URL query string - if (getCreatedAt() != null) { - joiner.add(String.format("%screatedAt%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getCreatedAt()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `completedAt` to the URL query string - if (getCompletedAt() != null) { - joiner.add(String.format("%scompletedAt%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getCompletedAt()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } - diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200Response.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200Response.java index 1a0b21594..5d65d260a 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200Response.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200Response.java @@ -3,40 +3,28 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package school.hei.haapi.service.documenso.gen.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; -import java.util.Objects; -import java.util.Map; -import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import java.io.Serializable; import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplate200ResponseRecipientsInner; -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - +import java.util.Objects; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -/** - * TemplateCreateDocumentFromTemplate200Response - */ +/** TemplateCreateDocumentFromTemplate200Response */ @JsonPropertyOrder({ TemplateCreateDocumentFromTemplate200Response.JSON_PROPERTY_ID, TemplateCreateDocumentFromTemplate200Response.JSON_PROPERTY_STATUS, @@ -44,23 +32,25 @@ TemplateCreateDocumentFromTemplate200Response.JSON_PROPERTY_CREATED_AT, TemplateCreateDocumentFromTemplate200Response.JSON_PROPERTY_RECIPIENTS }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +@JsonTypeName("template_createDocumentFromTemplate_200_response") +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class TemplateCreateDocumentFromTemplate200Response implements Serializable { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_ID = "id"; private BigDecimal id; - /** - * Gets or Sets status - */ + /** Gets or Sets status */ public enum StatusEnum { DRAFT("DRAFT"), - + PENDING("PENDING"), - + COMPLETED("COMPLETED"), - + REJECTED("REJECTED"); private String value; @@ -100,18 +90,20 @@ public static StatusEnum fromValue(String value) { private String createdAt; public static final String JSON_PROPERTY_RECIPIENTS = "recipients"; - private List recipients = new ArrayList<>(); + private List recipients = + new ArrayList<>(); - public TemplateCreateDocumentFromTemplate200Response() { - } + public TemplateCreateDocumentFromTemplate200Response() {} public TemplateCreateDocumentFromTemplate200Response id(BigDecimal id) { + this.id = id; return this; } /** * Get id + * * @return id */ @jakarta.annotation.Nonnull @@ -121,21 +113,21 @@ public BigDecimal getId() { return id; } - @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } - public TemplateCreateDocumentFromTemplate200Response status(StatusEnum status) { + this.status = status; return this; } /** * Get status + * * @return status */ @jakarta.annotation.Nonnull @@ -145,21 +137,21 @@ public StatusEnum getStatus() { return status; } - @JsonProperty(JSON_PROPERTY_STATUS) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setStatus(StatusEnum status) { this.status = status; } - public TemplateCreateDocumentFromTemplate200Response title(String title) { + this.title = title; return this; } /** * Get title + * * @return title */ @jakarta.annotation.Nullable @@ -169,21 +161,21 @@ public String getTitle() { return title; } - @JsonProperty(JSON_PROPERTY_TITLE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTitle(String title) { this.title = title; } - public TemplateCreateDocumentFromTemplate200Response createdAt(String createdAt) { + this.createdAt = createdAt; return this; } /** * Get createdAt + * * @return createdAt */ @jakarta.annotation.Nullable @@ -193,20 +185,21 @@ public String getCreatedAt() { return createdAt; } - @JsonProperty(JSON_PROPERTY_CREATED_AT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCreatedAt(String createdAt) { this.createdAt = createdAt; } + public TemplateCreateDocumentFromTemplate200Response recipients( + List recipients) { - public TemplateCreateDocumentFromTemplate200Response recipients(List recipients) { this.recipients = recipients; return this; } - public TemplateCreateDocumentFromTemplate200Response addRecipientsItem(TemplateCreateDocumentFromTemplate200ResponseRecipientsInner recipientsItem) { + public TemplateCreateDocumentFromTemplate200Response addRecipientsItem( + TemplateCreateDocumentFromTemplate200ResponseRecipientsInner recipientsItem) { if (this.recipients == null) { this.recipients = new ArrayList<>(); } @@ -216,6 +209,7 @@ public TemplateCreateDocumentFromTemplate200Response addRecipientsItem(TemplateC /** * Get recipients + * * @return recipients */ @jakarta.annotation.Nonnull @@ -225,17 +219,13 @@ public List getRec return recipients; } - @JsonProperty(JSON_PROPERTY_RECIPIENTS) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public void setRecipients(List recipients) { + public void setRecipients( + List recipients) { this.recipients = recipients; } - - /** - * Return true if this template_createDocumentFromTemplate_200_response object is equal to o. - */ @Override public boolean equals(Object o) { if (this == o) { @@ -244,12 +234,14 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateCreateDocumentFromTemplate200Response templateCreateDocumentFromTemplate200Response = (TemplateCreateDocumentFromTemplate200Response) o; - return Objects.equals(this.id, templateCreateDocumentFromTemplate200Response.id) && - Objects.equals(this.status, templateCreateDocumentFromTemplate200Response.status) && - Objects.equals(this.title, templateCreateDocumentFromTemplate200Response.title) && - Objects.equals(this.createdAt, templateCreateDocumentFromTemplate200Response.createdAt) && - Objects.equals(this.recipients, templateCreateDocumentFromTemplate200Response.recipients); + TemplateCreateDocumentFromTemplate200Response templateCreateDocumentFromTemplate200Response = + (TemplateCreateDocumentFromTemplate200Response) o; + return Objects.equals(this.id, templateCreateDocumentFromTemplate200Response.id) + && Objects.equals(this.status, templateCreateDocumentFromTemplate200Response.status) + && Objects.equals(this.title, templateCreateDocumentFromTemplate200Response.title) + && Objects.equals(this.createdAt, templateCreateDocumentFromTemplate200Response.createdAt) + && Objects.equals( + this.recipients, templateCreateDocumentFromTemplate200Response.recipients); } @Override @@ -271,8 +263,7 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). + * Convert the given object to string with each line indented by 4 spaces (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -280,70 +271,4 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } - - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - // add `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `status` to the URL query string - if (getStatus() != null) { - joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `title` to the URL query string - if (getTitle() != null) { - joiner.add(String.format("%stitle%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `createdAt` to the URL query string - if (getCreatedAt() != null) { - joiner.add(String.format("%screatedAt%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getCreatedAt()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `recipients` to the URL query string - if (getRecipients() != null) { - for (int i = 0; i < getRecipients().size(); i++) { - if (getRecipients().get(i) != null) { - joiner.add(getRecipients().get(i).toUrlQueryString(String.format("%srecipients%s%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); - } - } - } - - return joiner.toString(); - } } - diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.java index d3e992607..5fe77aae6 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.java @@ -3,37 +3,26 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package school.hei.haapi.service.documenso.gen.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; -import java.util.Objects; -import java.util.Map; -import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.math.BigDecimal; -import java.util.Arrays; import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - +import java.math.BigDecimal; +import java.util.Objects; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -/** - * TemplateCreateDocumentFromTemplate200ResponseRecipientsInner - */ +/** TemplateCreateDocumentFromTemplate200ResponseRecipientsInner */ @JsonPropertyOrder({ TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.JSON_PROPERTY_ID, TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.JSON_PROPERTY_EMAIL, @@ -41,7 +30,11 @@ TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.JSON_PROPERTY_ROLE, TemplateCreateDocumentFromTemplate200ResponseRecipientsInner.JSON_PROPERTY_TOKEN }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +@JsonTypeName("template_createDocumentFromTemplate_200_response_recipients_inner") +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class TemplateCreateDocumentFromTemplate200ResponseRecipientsInner implements Serializable { private static final long serialVersionUID = 1L; @@ -54,18 +47,16 @@ public class TemplateCreateDocumentFromTemplate200ResponseRecipientsInner implem public static final String JSON_PROPERTY_NAME = "name"; private String name; - /** - * Gets or Sets role - */ + /** Gets or Sets role */ public enum RoleEnum { CC("CC"), - + SIGNER("SIGNER"), - + VIEWER("VIEWER"), - + APPROVER("APPROVER"), - + ASSISTANT("ASSISTANT"); private String value; @@ -101,16 +92,17 @@ public static RoleEnum fromValue(String value) { public static final String JSON_PROPERTY_TOKEN = "token"; private String token; - public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner() { - } + public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner() {} public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner id(BigDecimal id) { + this.id = id; return this; } /** * Get id + * * @return id */ @jakarta.annotation.Nullable @@ -120,21 +112,21 @@ public BigDecimal getId() { return id; } - @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setId(BigDecimal id) { this.id = id; } - public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner email(String email) { + this.email = email; return this; } /** * Get email + * * @return email */ @jakarta.annotation.Nullable @@ -144,21 +136,21 @@ public String getEmail() { return email; } - @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setEmail(String email) { this.email = email; } - public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner name(String name) { + this.name = name; return this; } /** * Get name + * * @return name */ @jakarta.annotation.Nullable @@ -168,21 +160,21 @@ public String getName() { return name; } - @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setName(String name) { this.name = name; } - public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner role(RoleEnum role) { + this.role = role; return this; } /** * Get role + * * @return role */ @jakarta.annotation.Nullable @@ -192,21 +184,21 @@ public RoleEnum getRole() { return role; } - @JsonProperty(JSON_PROPERTY_ROLE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setRole(RoleEnum role) { this.role = role; } - public TemplateCreateDocumentFromTemplate200ResponseRecipientsInner token(String token) { + this.token = token; return this; } /** * Get token + * * @return token */ @jakarta.annotation.Nullable @@ -216,17 +208,12 @@ public String getToken() { return token; } - @JsonProperty(JSON_PROPERTY_TOKEN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setToken(String token) { this.token = token; } - - /** - * Return true if this template_createDocumentFromTemplate_200_response_recipients_inner object is equal to o. - */ @Override public boolean equals(Object o) { if (this == o) { @@ -235,12 +222,18 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateCreateDocumentFromTemplate200ResponseRecipientsInner templateCreateDocumentFromTemplate200ResponseRecipientsInner = (TemplateCreateDocumentFromTemplate200ResponseRecipientsInner) o; - return Objects.equals(this.id, templateCreateDocumentFromTemplate200ResponseRecipientsInner.id) && - Objects.equals(this.email, templateCreateDocumentFromTemplate200ResponseRecipientsInner.email) && - Objects.equals(this.name, templateCreateDocumentFromTemplate200ResponseRecipientsInner.name) && - Objects.equals(this.role, templateCreateDocumentFromTemplate200ResponseRecipientsInner.role) && - Objects.equals(this.token, templateCreateDocumentFromTemplate200ResponseRecipientsInner.token); + TemplateCreateDocumentFromTemplate200ResponseRecipientsInner + templateCreateDocumentFromTemplate200ResponseRecipientsInner = + (TemplateCreateDocumentFromTemplate200ResponseRecipientsInner) o; + return Objects.equals(this.id, templateCreateDocumentFromTemplate200ResponseRecipientsInner.id) + && Objects.equals( + this.email, templateCreateDocumentFromTemplate200ResponseRecipientsInner.email) + && Objects.equals( + this.name, templateCreateDocumentFromTemplate200ResponseRecipientsInner.name) + && Objects.equals( + this.role, templateCreateDocumentFromTemplate200ResponseRecipientsInner.role) + && Objects.equals( + this.token, templateCreateDocumentFromTemplate200ResponseRecipientsInner.token); } @Override @@ -262,8 +255,7 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). + * Convert the given object to string with each line indented by 4 spaces (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -271,65 +263,4 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } - - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - // add `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `email` to the URL query string - if (getEmail() != null) { - joiner.add(String.format("%semail%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getEmail()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `name` to the URL query string - if (getName() != null) { - joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `role` to the URL query string - if (getRole() != null) { - joiner.add(String.format("%srole%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getRole()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `token` to the URL query string - if (getToken() != null) { - joiner.add(String.format("%stoken%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getToken()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } - diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequest.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequest.java index c7166ef52..8ab872f52 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequest.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequest.java @@ -3,47 +3,36 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package school.hei.haapi.service.documenso.gen.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; -import java.util.Objects; -import java.util.Map; -import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; +import java.io.Serializable; import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner; -import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequestRecipientsInner; -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - +import java.util.Objects; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -/** - * TemplateCreateDocumentFromTemplateRequest - */ +/** TemplateCreateDocumentFromTemplateRequest */ @JsonPropertyOrder({ TemplateCreateDocumentFromTemplateRequest.JSON_PROPERTY_TEMPLATE_ID, TemplateCreateDocumentFromTemplateRequest.JSON_PROPERTY_RECIPIENTS, TemplateCreateDocumentFromTemplateRequest.JSON_PROPERTY_PREFILL_FIELDS }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +@JsonTypeName("template_createDocumentFromTemplate_request") +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class TemplateCreateDocumentFromTemplateRequest implements Serializable { private static final long serialVersionUID = 1L; @@ -51,21 +40,24 @@ public class TemplateCreateDocumentFromTemplateRequest implements Serializable { private BigDecimal templateId; public static final String JSON_PROPERTY_RECIPIENTS = "recipients"; - private List recipients = new ArrayList<>(); + private List recipients = + new ArrayList<>(); public static final String JSON_PROPERTY_PREFILL_FIELDS = "prefillFields"; - private List prefillFields = new ArrayList<>(); + private List prefillFields = + new ArrayList<>(); - public TemplateCreateDocumentFromTemplateRequest() { - } + public TemplateCreateDocumentFromTemplateRequest() {} public TemplateCreateDocumentFromTemplateRequest templateId(BigDecimal templateId) { + this.templateId = templateId; return this; } /** * Get templateId + * * @return templateId */ @jakarta.annotation.Nonnull @@ -75,20 +67,21 @@ public BigDecimal getTemplateId() { return templateId; } - @JsonProperty(JSON_PROPERTY_TEMPLATE_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setTemplateId(BigDecimal templateId) { this.templateId = templateId; } + public TemplateCreateDocumentFromTemplateRequest recipients( + List recipients) { - public TemplateCreateDocumentFromTemplateRequest recipients(List recipients) { this.recipients = recipients; return this; } - public TemplateCreateDocumentFromTemplateRequest addRecipientsItem(TemplateCreateDocumentFromTemplateRequestRecipientsInner recipientsItem) { + public TemplateCreateDocumentFromTemplateRequest addRecipientsItem( + TemplateCreateDocumentFromTemplateRequestRecipientsInner recipientsItem) { if (this.recipients == null) { this.recipients = new ArrayList<>(); } @@ -98,6 +91,7 @@ public TemplateCreateDocumentFromTemplateRequest addRecipientsItem(TemplateCreat /** * Get recipients + * * @return recipients */ @jakarta.annotation.Nonnull @@ -107,20 +101,22 @@ public List getRecipie return recipients; } - @JsonProperty(JSON_PROPERTY_RECIPIENTS) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public void setRecipients(List recipients) { + public void setRecipients( + List recipients) { this.recipients = recipients; } + public TemplateCreateDocumentFromTemplateRequest prefillFields( + List prefillFields) { - public TemplateCreateDocumentFromTemplateRequest prefillFields(List prefillFields) { this.prefillFields = prefillFields; return this; } - public TemplateCreateDocumentFromTemplateRequest addPrefillFieldsItem(TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner prefillFieldsItem) { + public TemplateCreateDocumentFromTemplateRequest addPrefillFieldsItem( + TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner prefillFieldsItem) { if (this.prefillFields == null) { this.prefillFields = new ArrayList<>(); } @@ -130,6 +126,7 @@ public TemplateCreateDocumentFromTemplateRequest addPrefillFieldsItem(TemplateCr /** * Get prefillFields + * * @return prefillFields */ @jakarta.annotation.Nullable @@ -139,17 +136,13 @@ public List getPref return prefillFields; } - @JsonProperty(JSON_PROPERTY_PREFILL_FIELDS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setPrefillFields(List prefillFields) { + public void setPrefillFields( + List prefillFields) { this.prefillFields = prefillFields; } - - /** - * Return true if this template_createDocumentFromTemplate_request object is equal to o. - */ @Override public boolean equals(Object o) { if (this == o) { @@ -158,10 +151,12 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest = (TemplateCreateDocumentFromTemplateRequest) o; - return Objects.equals(this.templateId, templateCreateDocumentFromTemplateRequest.templateId) && - Objects.equals(this.recipients, templateCreateDocumentFromTemplateRequest.recipients) && - Objects.equals(this.prefillFields, templateCreateDocumentFromTemplateRequest.prefillFields); + TemplateCreateDocumentFromTemplateRequest templateCreateDocumentFromTemplateRequest = + (TemplateCreateDocumentFromTemplateRequest) o; + return Objects.equals(this.templateId, templateCreateDocumentFromTemplateRequest.templateId) + && Objects.equals(this.recipients, templateCreateDocumentFromTemplateRequest.recipients) + && Objects.equals( + this.prefillFields, templateCreateDocumentFromTemplateRequest.prefillFields); } @Override @@ -181,8 +176,7 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). + * Convert the given object to string with each line indented by 4 spaces (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -190,65 +184,4 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } - - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - // add `templateId` to the URL query string - if (getTemplateId() != null) { - joiner.add(String.format("%stemplateId%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getTemplateId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `recipients` to the URL query string - if (getRecipients() != null) { - for (int i = 0; i < getRecipients().size(); i++) { - if (getRecipients().get(i) != null) { - joiner.add(getRecipients().get(i).toUrlQueryString(String.format("%srecipients%s%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); - } - } - } - - // add `prefillFields` to the URL query string - if (getPrefillFields() != null) { - for (int i = 0; i < getPrefillFields().size(); i++) { - if (getPrefillFields().get(i) != null) { - joiner.add(getPrefillFields().get(i).toUrlQueryString(String.format("%sprefillFields%s%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); - } - } - } - - return joiner.toString(); - } } - diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.java index 15ad93595..30a7b10c7 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.java @@ -3,52 +3,43 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package school.hei.haapi.service.documenso.gen.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; -import java.util.Objects; -import java.util.Map; -import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.math.BigDecimal; -import java.util.Arrays; import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - +import java.math.BigDecimal; +import java.util.Objects; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -/** - * TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner - */ +/** TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner */ @JsonPropertyOrder({ TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.JSON_PROPERTY_ID, TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.JSON_PROPERTY_TYPE, TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.JSON_PROPERTY_VALUE }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +@JsonTypeName("template_createDocumentFromTemplate_request_prefillFields_inner") +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner implements Serializable { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_ID = "id"; private BigDecimal id; - /** - * Gets or Sets type - */ + /** Gets or Sets type */ public enum TypeEnum { TEXT("text"); @@ -85,16 +76,17 @@ public static TypeEnum fromValue(String value) { public static final String JSON_PROPERTY_VALUE = "value"; private String value; - public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner() { - } + public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner() {} public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner id(BigDecimal id) { + this.id = id; return this; } /** * Get id + * * @return id */ @jakarta.annotation.Nonnull @@ -104,21 +96,21 @@ public BigDecimal getId() { return id; } - @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } - public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner type(TypeEnum type) { + this.type = type; return this; } /** * Get type + * * @return type */ @jakarta.annotation.Nonnull @@ -128,21 +120,21 @@ public TypeEnum getType() { return type; } - @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setType(TypeEnum type) { this.type = type; } - public TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner value(String value) { + this.value = value; return this; } /** * Get value + * * @return value */ @jakarta.annotation.Nonnull @@ -152,17 +144,12 @@ public String getValue() { return value; } - @JsonProperty(JSON_PROPERTY_VALUE) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setValue(String value) { this.value = value; } - - /** - * Return true if this template_createDocumentFromTemplate_request_prefillFields_inner object is equal to o. - */ @Override public boolean equals(Object o) { if (this == o) { @@ -171,10 +158,14 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner templateCreateDocumentFromTemplateRequestPrefillFieldsInner = (TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner) o; - return Objects.equals(this.id, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.id) && - Objects.equals(this.type, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.type) && - Objects.equals(this.value, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.value); + TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner + templateCreateDocumentFromTemplateRequestPrefillFieldsInner = + (TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner) o; + return Objects.equals(this.id, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.id) + && Objects.equals( + this.type, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.type) + && Objects.equals( + this.value, templateCreateDocumentFromTemplateRequestPrefillFieldsInner.value); } @Override @@ -194,8 +185,7 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). + * Convert the given object to string with each line indented by 4 spaces (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -203,55 +193,4 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } - - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - // add `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `type` to the URL query string - if (getType() != null) { - joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `value` to the URL query string - if (getValue() != null) { - joiner.add(String.format("%svalue%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } - diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestRecipientsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestRecipientsInner.java index 0bda3e528..faccf3391 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestRecipientsInner.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateCreateDocumentFromTemplateRequestRecipientsInner.java @@ -3,43 +3,34 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package school.hei.haapi.service.documenso.gen.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; -import java.util.Objects; -import java.util.Map; -import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; -import java.math.BigDecimal; -import java.util.Arrays; import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - +import java.math.BigDecimal; +import java.util.Objects; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -/** - * TemplateCreateDocumentFromTemplateRequestRecipientsInner - */ +/** TemplateCreateDocumentFromTemplateRequestRecipientsInner */ @JsonPropertyOrder({ TemplateCreateDocumentFromTemplateRequestRecipientsInner.JSON_PROPERTY_ID, TemplateCreateDocumentFromTemplateRequestRecipientsInner.JSON_PROPERTY_EMAIL, TemplateCreateDocumentFromTemplateRequestRecipientsInner.JSON_PROPERTY_NAME }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +@JsonTypeName("template_createDocumentFromTemplate_request_recipients_inner") +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class TemplateCreateDocumentFromTemplateRequestRecipientsInner implements Serializable { private static final long serialVersionUID = 1L; @@ -52,16 +43,17 @@ public class TemplateCreateDocumentFromTemplateRequestRecipientsInner implements public static final String JSON_PROPERTY_NAME = "name"; private String name; - public TemplateCreateDocumentFromTemplateRequestRecipientsInner() { - } + public TemplateCreateDocumentFromTemplateRequestRecipientsInner() {} public TemplateCreateDocumentFromTemplateRequestRecipientsInner id(BigDecimal id) { + this.id = id; return this; } /** * Get id + * * @return id */ @jakarta.annotation.Nonnull @@ -71,21 +63,21 @@ public BigDecimal getId() { return id; } - @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } - public TemplateCreateDocumentFromTemplateRequestRecipientsInner email(String email) { + this.email = email; return this; } /** * Get email + * * @return email */ @jakarta.annotation.Nonnull @@ -95,21 +87,21 @@ public String getEmail() { return email; } - @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setEmail(String email) { this.email = email; } - public TemplateCreateDocumentFromTemplateRequestRecipientsInner name(String name) { + this.name = name; return this; } /** * Get name + * * @return name */ @jakarta.annotation.Nullable @@ -119,17 +111,12 @@ public String getName() { return name; } - @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setName(String name) { this.name = name; } - - /** - * Return true if this template_createDocumentFromTemplate_request_recipients_inner object is equal to o. - */ @Override public boolean equals(Object o) { if (this == o) { @@ -138,10 +125,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateCreateDocumentFromTemplateRequestRecipientsInner templateCreateDocumentFromTemplateRequestRecipientsInner = (TemplateCreateDocumentFromTemplateRequestRecipientsInner) o; - return Objects.equals(this.id, templateCreateDocumentFromTemplateRequestRecipientsInner.id) && - Objects.equals(this.email, templateCreateDocumentFromTemplateRequestRecipientsInner.email) && - Objects.equals(this.name, templateCreateDocumentFromTemplateRequestRecipientsInner.name); + TemplateCreateDocumentFromTemplateRequestRecipientsInner + templateCreateDocumentFromTemplateRequestRecipientsInner = + (TemplateCreateDocumentFromTemplateRequestRecipientsInner) o; + return Objects.equals(this.id, templateCreateDocumentFromTemplateRequestRecipientsInner.id) + && Objects.equals( + this.email, templateCreateDocumentFromTemplateRequestRecipientsInner.email) + && Objects.equals(this.name, templateCreateDocumentFromTemplateRequestRecipientsInner.name); } @Override @@ -161,8 +151,7 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). + * Convert the given object to string with each line indented by 4 spaces (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -170,55 +159,4 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } - - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - // add `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `email` to the URL query string - if (getEmail() != null) { - joiner.add(String.format("%semail%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getEmail()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `name` to the URL query string - if (getName() != null) { - joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } - diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200Response.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200Response.java index 898af2217..7e883563d 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200Response.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200Response.java @@ -3,58 +3,48 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package school.hei.haapi.service.documenso.gen.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; -import java.util.Objects; -import java.util.Map; -import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; +import java.io.Serializable; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import school.hei.haapi.service.documenso.gen.model.TemplateFindTemplates200ResponseDataInner; -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - +import java.util.Objects; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -/** - * TemplateFindTemplates200Response - */ -@JsonPropertyOrder({ - TemplateFindTemplates200Response.JSON_PROPERTY_DATA -}) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +/** TemplateFindTemplates200Response */ +@JsonPropertyOrder({TemplateFindTemplates200Response.JSON_PROPERTY_DATA}) +@JsonTypeName("template_findTemplates_200_response") +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class TemplateFindTemplates200Response implements Serializable { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_DATA = "data"; private List data = new ArrayList<>(); - public TemplateFindTemplates200Response() { - } + public TemplateFindTemplates200Response() {} + + public TemplateFindTemplates200Response data( + List data) { - public TemplateFindTemplates200Response data(List data) { this.data = data; return this; } - public TemplateFindTemplates200Response addDataItem(TemplateFindTemplates200ResponseDataInner dataItem) { + public TemplateFindTemplates200Response addDataItem( + TemplateFindTemplates200ResponseDataInner dataItem) { if (this.data == null) { this.data = new ArrayList<>(); } @@ -64,6 +54,7 @@ public TemplateFindTemplates200Response addDataItem(TemplateFindTemplates200Resp /** * Get data + * * @return data */ @jakarta.annotation.Nonnull @@ -73,17 +64,12 @@ public List getData() { return data; } - @JsonProperty(JSON_PROPERTY_DATA) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setData(List data) { this.data = data; } - - /** - * Return true if this template_findTemplates_200_response object is equal to o. - */ @Override public boolean equals(Object o) { if (this == o) { @@ -92,7 +78,8 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateFindTemplates200Response templateFindTemplates200Response = (TemplateFindTemplates200Response) o; + TemplateFindTemplates200Response templateFindTemplates200Response = + (TemplateFindTemplates200Response) o; return Objects.equals(this.data, templateFindTemplates200Response.data); } @@ -111,8 +98,7 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). + * Convert the given object to string with each line indented by 4 spaces (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -120,50 +106,4 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } - - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - // add `data` to the URL query string - if (getData() != null) { - for (int i = 0; i < getData().size(); i++) { - if (getData().get(i) != null) { - joiner.add(getData().get(i).toUrlQueryString(String.format("%sdata%s%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); - } - } - } - - return joiner.toString(); - } } - diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200ResponseDataInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200ResponseDataInner.java index 0c3e20580..b30599505 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200ResponseDataInner.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateFindTemplates200ResponseDataInner.java @@ -3,37 +3,26 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package school.hei.haapi.service.documenso.gen.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; -import java.util.Objects; -import java.util.Map; -import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.math.BigDecimal; -import java.util.Arrays; import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - +import java.math.BigDecimal; +import java.util.Objects; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -/** - * TemplateFindTemplates200ResponseDataInner - */ +/** TemplateFindTemplates200ResponseDataInner */ @JsonPropertyOrder({ TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_ID, TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_TITLE, @@ -42,7 +31,11 @@ TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_CREATED_AT, TemplateFindTemplates200ResponseDataInner.JSON_PROPERTY_UPDATED_AT }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +@JsonTypeName("template_findTemplates_200_response_data_inner") +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class TemplateFindTemplates200ResponseDataInner implements Serializable { private static final long serialVersionUID = 1L; @@ -52,14 +45,12 @@ public class TemplateFindTemplates200ResponseDataInner implements Serializable { public static final String JSON_PROPERTY_TITLE = "title"; private String title; - /** - * Gets or Sets type - */ + /** Gets or Sets type */ public enum TypeEnum { PUBLIC("PUBLIC"), - + PRIVATE("PRIVATE"), - + ORGANISATION("ORGANISATION"); private String value; @@ -101,16 +92,17 @@ public static TypeEnum fromValue(String value) { public static final String JSON_PROPERTY_UPDATED_AT = "updatedAt"; private String updatedAt; - public TemplateFindTemplates200ResponseDataInner() { - } + public TemplateFindTemplates200ResponseDataInner() {} public TemplateFindTemplates200ResponseDataInner id(BigDecimal id) { + this.id = id; return this; } /** * Get id + * * @return id */ @jakarta.annotation.Nonnull @@ -120,21 +112,21 @@ public BigDecimal getId() { return id; } - @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } - public TemplateFindTemplates200ResponseDataInner title(String title) { + this.title = title; return this; } /** * Get title + * * @return title */ @jakarta.annotation.Nonnull @@ -144,21 +136,21 @@ public String getTitle() { return title; } - @JsonProperty(JSON_PROPERTY_TITLE) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setTitle(String title) { this.title = title; } - public TemplateFindTemplates200ResponseDataInner type(TypeEnum type) { + this.type = type; return this; } /** * Get type + * * @return type */ @jakarta.annotation.Nullable @@ -168,21 +160,21 @@ public TypeEnum getType() { return type; } - @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setType(TypeEnum type) { this.type = type; } - public TemplateFindTemplates200ResponseDataInner userId(BigDecimal userId) { + this.userId = userId; return this; } /** * Get userId + * * @return userId */ @jakarta.annotation.Nonnull @@ -192,21 +184,21 @@ public BigDecimal getUserId() { return userId; } - @JsonProperty(JSON_PROPERTY_USER_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setUserId(BigDecimal userId) { this.userId = userId; } - public TemplateFindTemplates200ResponseDataInner createdAt(String createdAt) { + this.createdAt = createdAt; return this; } /** * Get createdAt + * * @return createdAt */ @jakarta.annotation.Nullable @@ -216,21 +208,21 @@ public String getCreatedAt() { return createdAt; } - @JsonProperty(JSON_PROPERTY_CREATED_AT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setCreatedAt(String createdAt) { this.createdAt = createdAt; } - public TemplateFindTemplates200ResponseDataInner updatedAt(String updatedAt) { + this.updatedAt = updatedAt; return this; } /** * Get updatedAt + * * @return updatedAt */ @jakarta.annotation.Nullable @@ -240,17 +232,12 @@ public String getUpdatedAt() { return updatedAt; } - @JsonProperty(JSON_PROPERTY_UPDATED_AT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setUpdatedAt(String updatedAt) { this.updatedAt = updatedAt; } - - /** - * Return true if this template_findTemplates_200_response_data_inner object is equal to o. - */ @Override public boolean equals(Object o) { if (this == o) { @@ -259,13 +246,14 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateFindTemplates200ResponseDataInner templateFindTemplates200ResponseDataInner = (TemplateFindTemplates200ResponseDataInner) o; - return Objects.equals(this.id, templateFindTemplates200ResponseDataInner.id) && - Objects.equals(this.title, templateFindTemplates200ResponseDataInner.title) && - Objects.equals(this.type, templateFindTemplates200ResponseDataInner.type) && - Objects.equals(this.userId, templateFindTemplates200ResponseDataInner.userId) && - Objects.equals(this.createdAt, templateFindTemplates200ResponseDataInner.createdAt) && - Objects.equals(this.updatedAt, templateFindTemplates200ResponseDataInner.updatedAt); + TemplateFindTemplates200ResponseDataInner templateFindTemplates200ResponseDataInner = + (TemplateFindTemplates200ResponseDataInner) o; + return Objects.equals(this.id, templateFindTemplates200ResponseDataInner.id) + && Objects.equals(this.title, templateFindTemplates200ResponseDataInner.title) + && Objects.equals(this.type, templateFindTemplates200ResponseDataInner.type) + && Objects.equals(this.userId, templateFindTemplates200ResponseDataInner.userId) + && Objects.equals(this.createdAt, templateFindTemplates200ResponseDataInner.createdAt) + && Objects.equals(this.updatedAt, templateFindTemplates200ResponseDataInner.updatedAt); } @Override @@ -288,8 +276,7 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). + * Convert the given object to string with each line indented by 4 spaces (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -297,70 +284,4 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } - - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - // add `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `title` to the URL query string - if (getTitle() != null) { - joiner.add(String.format("%stitle%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `type` to the URL query string - if (getType() != null) { - joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `userId` to the URL query string - if (getUserId() != null) { - joiner.add(String.format("%suserId%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getUserId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `createdAt` to the URL query string - if (getCreatedAt() != null) { - joiner.add(String.format("%screatedAt%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getCreatedAt()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `updatedAt` to the URL query string - if (getUpdatedAt() != null) { - joiner.add(String.format("%supdatedAt%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getUpdatedAt()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } - diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200Response.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200Response.java index 2f7009a30..0a458284f 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200Response.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200Response.java @@ -3,41 +3,26 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package school.hei.haapi.service.documenso.gen.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; -import java.util.Objects; -import java.util.Map; -import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; +import java.io.Serializable; import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200ResponseFieldsInner; -import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200ResponseRecipientsInner; -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - +import java.util.Objects; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -/** - * TemplateGetTemplateById200Response - */ +/** TemplateGetTemplateById200Response */ @JsonPropertyOrder({ TemplateGetTemplateById200Response.JSON_PROPERTY_ID, TemplateGetTemplateById200Response.JSON_PROPERTY_TITLE, @@ -45,7 +30,11 @@ TemplateGetTemplateById200Response.JSON_PROPERTY_RECIPIENTS, TemplateGetTemplateById200Response.JSON_PROPERTY_FIELDS }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +@JsonTypeName("template_getTemplateById_200_response") +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class TemplateGetTemplateById200Response implements Serializable { private static final long serialVersionUID = 1L; @@ -64,16 +53,17 @@ public class TemplateGetTemplateById200Response implements Serializable { public static final String JSON_PROPERTY_FIELDS = "fields"; private List fields = new ArrayList<>(); - public TemplateGetTemplateById200Response() { - } + public TemplateGetTemplateById200Response() {} public TemplateGetTemplateById200Response id(BigDecimal id) { + this.id = id; return this; } /** * Get id + * * @return id */ @jakarta.annotation.Nonnull @@ -83,21 +73,21 @@ public BigDecimal getId() { return id; } - @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } - public TemplateGetTemplateById200Response title(String title) { + this.title = title; return this; } /** * Get title + * * @return title */ @jakarta.annotation.Nonnull @@ -107,21 +97,21 @@ public String getTitle() { return title; } - @JsonProperty(JSON_PROPERTY_TITLE) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setTitle(String title) { this.title = title; } - public TemplateGetTemplateById200Response userId(BigDecimal userId) { + this.userId = userId; return this; } /** * Get userId + * * @return userId */ @jakarta.annotation.Nullable @@ -131,20 +121,21 @@ public BigDecimal getUserId() { return userId; } - @JsonProperty(JSON_PROPERTY_USER_ID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setUserId(BigDecimal userId) { this.userId = userId; } + public TemplateGetTemplateById200Response recipients( + List recipients) { - public TemplateGetTemplateById200Response recipients(List recipients) { this.recipients = recipients; return this; } - public TemplateGetTemplateById200Response addRecipientsItem(TemplateGetTemplateById200ResponseRecipientsInner recipientsItem) { + public TemplateGetTemplateById200Response addRecipientsItem( + TemplateGetTemplateById200ResponseRecipientsInner recipientsItem) { if (this.recipients == null) { this.recipients = new ArrayList<>(); } @@ -154,6 +145,7 @@ public TemplateGetTemplateById200Response addRecipientsItem(TemplateGetTemplateB /** * Get recipients + * * @return recipients */ @jakarta.annotation.Nonnull @@ -163,20 +155,21 @@ public List getRecipients() { return recipients; } - @JsonProperty(JSON_PROPERTY_RECIPIENTS) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setRecipients(List recipients) { this.recipients = recipients; } + public TemplateGetTemplateById200Response fields( + List fields) { - public TemplateGetTemplateById200Response fields(List fields) { this.fields = fields; return this; } - public TemplateGetTemplateById200Response addFieldsItem(TemplateGetTemplateById200ResponseFieldsInner fieldsItem) { + public TemplateGetTemplateById200Response addFieldsItem( + TemplateGetTemplateById200ResponseFieldsInner fieldsItem) { if (this.fields == null) { this.fields = new ArrayList<>(); } @@ -186,6 +179,7 @@ public TemplateGetTemplateById200Response addFieldsItem(TemplateGetTemplateById2 /** * Get fields + * * @return fields */ @jakarta.annotation.Nullable @@ -195,17 +189,12 @@ public List getFields() { return fields; } - @JsonProperty(JSON_PROPERTY_FIELDS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setFields(List fields) { this.fields = fields; } - - /** - * Return true if this template_getTemplateById_200_response object is equal to o. - */ @Override public boolean equals(Object o) { if (this == o) { @@ -214,12 +203,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateGetTemplateById200Response templateGetTemplateById200Response = (TemplateGetTemplateById200Response) o; - return Objects.equals(this.id, templateGetTemplateById200Response.id) && - Objects.equals(this.title, templateGetTemplateById200Response.title) && - Objects.equals(this.userId, templateGetTemplateById200Response.userId) && - Objects.equals(this.recipients, templateGetTemplateById200Response.recipients) && - Objects.equals(this.fields, templateGetTemplateById200Response.fields); + TemplateGetTemplateById200Response templateGetTemplateById200Response = + (TemplateGetTemplateById200Response) o; + return Objects.equals(this.id, templateGetTemplateById200Response.id) + && Objects.equals(this.title, templateGetTemplateById200Response.title) + && Objects.equals(this.userId, templateGetTemplateById200Response.userId) + && Objects.equals(this.recipients, templateGetTemplateById200Response.recipients) + && Objects.equals(this.fields, templateGetTemplateById200Response.fields); } @Override @@ -241,8 +231,7 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). + * Convert the given object to string with each line indented by 4 spaces (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -250,75 +239,4 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } - - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - // add `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `title` to the URL query string - if (getTitle() != null) { - joiner.add(String.format("%stitle%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getTitle()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `userId` to the URL query string - if (getUserId() != null) { - joiner.add(String.format("%suserId%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getUserId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `recipients` to the URL query string - if (getRecipients() != null) { - for (int i = 0; i < getRecipients().size(); i++) { - if (getRecipients().get(i) != null) { - joiner.add(getRecipients().get(i).toUrlQueryString(String.format("%srecipients%s%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); - } - } - } - - // add `fields` to the URL query string - if (getFields() != null) { - for (int i = 0; i < getFields().size(); i++) { - if (getFields().get(i) != null) { - joiner.add(getFields().get(i).toUrlQueryString(String.format("%sfields%s%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); - } - } - } - - return joiner.toString(); - } } - diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseFieldsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseFieldsInner.java index 953063c78..d8d4c65ac 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseFieldsInner.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseFieldsInner.java @@ -3,37 +3,24 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package school.hei.haapi.service.documenso.gen.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; -import java.util.Objects; -import java.util.Map; -import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; -import java.math.BigDecimal; -import java.util.Arrays; import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - +import java.math.BigDecimal; +import java.util.Objects; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -/** - * TemplateGetTemplateById200ResponseFieldsInner - */ +/** TemplateGetTemplateById200ResponseFieldsInner */ @JsonPropertyOrder({ TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_ID, TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_TYPE, @@ -42,7 +29,11 @@ TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_PAGE, TemplateGetTemplateById200ResponseFieldsInner.JSON_PROPERTY_POSITION_Y }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +@JsonTypeName("template_getTemplateById_200_response_fields_inner") +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class TemplateGetTemplateById200ResponseFieldsInner implements Serializable { private static final long serialVersionUID = 1L; @@ -64,16 +55,17 @@ public class TemplateGetTemplateById200ResponseFieldsInner implements Serializab public static final String JSON_PROPERTY_POSITION_Y = "positionY"; private BigDecimal positionY; - public TemplateGetTemplateById200ResponseFieldsInner() { - } + public TemplateGetTemplateById200ResponseFieldsInner() {} public TemplateGetTemplateById200ResponseFieldsInner id(BigDecimal id) { + this.id = id; return this; } /** * Get id + * * @return id */ @jakarta.annotation.Nonnull @@ -83,21 +75,21 @@ public BigDecimal getId() { return id; } - @JsonProperty(JSON_PROPERTY_ID) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setId(BigDecimal id) { this.id = id; } - public TemplateGetTemplateById200ResponseFieldsInner type(String type) { + this.type = type; return this; } /** * Get type + * * @return type */ @jakarta.annotation.Nonnull @@ -107,21 +99,21 @@ public String getType() { return type; } - @JsonProperty(JSON_PROPERTY_TYPE) @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setType(String type) { this.type = type; } - public TemplateGetTemplateById200ResponseFieldsInner label(String label) { + this.label = label; return this; } /** * Get label + * * @return label */ @jakarta.annotation.Nullable @@ -131,21 +123,21 @@ public String getLabel() { return label; } - @JsonProperty(JSON_PROPERTY_LABEL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setLabel(String label) { this.label = label; } - public TemplateGetTemplateById200ResponseFieldsInner placeholder(String placeholder) { + this.placeholder = placeholder; return this; } /** * Get placeholder + * * @return placeholder */ @jakarta.annotation.Nullable @@ -155,21 +147,21 @@ public String getPlaceholder() { return placeholder; } - @JsonProperty(JSON_PROPERTY_PLACEHOLDER) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPlaceholder(String placeholder) { this.placeholder = placeholder; } - public TemplateGetTemplateById200ResponseFieldsInner page(BigDecimal page) { + this.page = page; return this; } /** * Get page + * * @return page */ @jakarta.annotation.Nullable @@ -179,21 +171,21 @@ public BigDecimal getPage() { return page; } - @JsonProperty(JSON_PROPERTY_PAGE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPage(BigDecimal page) { this.page = page; } - public TemplateGetTemplateById200ResponseFieldsInner positionY(BigDecimal positionY) { + this.positionY = positionY; return this; } /** * Get positionY + * * @return positionY */ @jakarta.annotation.Nullable @@ -203,17 +195,12 @@ public BigDecimal getPositionY() { return positionY; } - @JsonProperty(JSON_PROPERTY_POSITION_Y) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setPositionY(BigDecimal positionY) { this.positionY = positionY; } - - /** - * Return true if this template_getTemplateById_200_response_fields_inner object is equal to o. - */ @Override public boolean equals(Object o) { if (this == o) { @@ -222,13 +209,15 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateGetTemplateById200ResponseFieldsInner templateGetTemplateById200ResponseFieldsInner = (TemplateGetTemplateById200ResponseFieldsInner) o; - return Objects.equals(this.id, templateGetTemplateById200ResponseFieldsInner.id) && - Objects.equals(this.type, templateGetTemplateById200ResponseFieldsInner.type) && - Objects.equals(this.label, templateGetTemplateById200ResponseFieldsInner.label) && - Objects.equals(this.placeholder, templateGetTemplateById200ResponseFieldsInner.placeholder) && - Objects.equals(this.page, templateGetTemplateById200ResponseFieldsInner.page) && - Objects.equals(this.positionY, templateGetTemplateById200ResponseFieldsInner.positionY); + TemplateGetTemplateById200ResponseFieldsInner templateGetTemplateById200ResponseFieldsInner = + (TemplateGetTemplateById200ResponseFieldsInner) o; + return Objects.equals(this.id, templateGetTemplateById200ResponseFieldsInner.id) + && Objects.equals(this.type, templateGetTemplateById200ResponseFieldsInner.type) + && Objects.equals(this.label, templateGetTemplateById200ResponseFieldsInner.label) + && Objects.equals( + this.placeholder, templateGetTemplateById200ResponseFieldsInner.placeholder) + && Objects.equals(this.page, templateGetTemplateById200ResponseFieldsInner.page) + && Objects.equals(this.positionY, templateGetTemplateById200ResponseFieldsInner.positionY); } @Override @@ -251,8 +240,7 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). + * Convert the given object to string with each line indented by 4 spaces (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -260,70 +248,4 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } - - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - // add `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `type` to the URL query string - if (getType() != null) { - joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `label` to the URL query string - if (getLabel() != null) { - joiner.add(String.format("%slabel%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getLabel()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `placeholder` to the URL query string - if (getPlaceholder() != null) { - joiner.add(String.format("%splaceholder%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getPlaceholder()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `page` to the URL query string - if (getPage() != null) { - joiner.add(String.format("%spage%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getPage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `positionY` to the URL query string - if (getPositionY() != null) { - joiner.add(String.format("%spositionY%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getPositionY()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } } - diff --git a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseRecipientsInner.java b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseRecipientsInner.java index 2c9dcf816..c1ee13344 100644 --- a/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseRecipientsInner.java +++ b/src/main/java/school/hei/haapi/service/documenso/gen/model/TemplateGetTemplateById200ResponseRecipientsInner.java @@ -3,62 +3,53 @@ * Minimal subset of the Documenso v2 API (see \"Documenso v2 API.yaml\" for the full upstream spec) covering only the operations used by hei-admin-api's generated Documenso client: browsing templates, creating a document from a template, and downloading the signed result. * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ - package school.hei.haapi.service.documenso.gen.model; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.StringJoiner; -import java.util.Objects; -import java.util.Map; -import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.math.BigDecimal; -import java.util.Arrays; import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - +import java.math.BigDecimal; +import java.util.Objects; -import school.hei.haapi.service.documenso.gen.invoker.ApiClient; -/** - * TemplateGetTemplateById200ResponseRecipientsInner - */ +/** TemplateGetTemplateById200ResponseRecipientsInner */ @JsonPropertyOrder({ TemplateGetTemplateById200ResponseRecipientsInner.JSON_PROPERTY_ID, TemplateGetTemplateById200ResponseRecipientsInner.JSON_PROPERTY_ROLE, TemplateGetTemplateById200ResponseRecipientsInner.JSON_PROPERTY_EMAIL, TemplateGetTemplateById200ResponseRecipientsInner.JSON_PROPERTY_NAME }) -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-08-07T13:13:31.473413100+03:00[Indian/Antananarivo]", comments = "Generator version: 7.7.0") +@JsonTypeName("template_getTemplateById_200_response_recipients_inner") +@jakarta.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + date = "2026-08-10T16:46:27.452926300+03:00[Indian/Antananarivo]", + comments = "Generator version: 7.7.0") public class TemplateGetTemplateById200ResponseRecipientsInner implements Serializable { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_ID = "id"; private BigDecimal id; - /** - * Gets or Sets role - */ + /** Gets or Sets role */ public enum RoleEnum { CC("CC"), - + SIGNER("SIGNER"), - + VIEWER("VIEWER"), - + APPROVER("APPROVER"), - + ASSISTANT("ASSISTANT"); private String value; @@ -97,16 +88,17 @@ public static RoleEnum fromValue(String value) { public static final String JSON_PROPERTY_NAME = "name"; private String name; - public TemplateGetTemplateById200ResponseRecipientsInner() { - } + public TemplateGetTemplateById200ResponseRecipientsInner() {} public TemplateGetTemplateById200ResponseRecipientsInner id(BigDecimal id) { + this.id = id; return this; } /** * Get id + * * @return id */ @jakarta.annotation.Nonnull @@ -123,12 +115,14 @@ public void setId(BigDecimal id) { } public TemplateGetTemplateById200ResponseRecipientsInner role(RoleEnum role) { + this.role = role; return this; } /** * Get role + * * @return role */ @jakarta.annotation.Nonnull @@ -145,12 +139,14 @@ public void setRole(RoleEnum role) { } public TemplateGetTemplateById200ResponseRecipientsInner email(String email) { + this.email = email; return this; } /** * Get email + * * @return email */ @jakarta.annotation.Nullable @@ -160,21 +156,21 @@ public String getEmail() { return email; } - @JsonProperty(JSON_PROPERTY_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setEmail(String email) { this.email = email; } - public TemplateGetTemplateById200ResponseRecipientsInner name(String name) { + this.name = name; return this; } /** * Get name + * * @return name */ @jakarta.annotation.Nullable @@ -184,17 +180,12 @@ public String getName() { return name; } - @JsonProperty(JSON_PROPERTY_NAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setName(String name) { this.name = name; } - - /** - * Return true if this template_getTemplateById_200_response_recipients_inner object is equal to o. - */ @Override public boolean equals(Object o) { if (this == o) { @@ -203,11 +194,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TemplateGetTemplateById200ResponseRecipientsInner templateGetTemplateById200ResponseRecipientsInner = (TemplateGetTemplateById200ResponseRecipientsInner) o; - return Objects.equals(this.id, templateGetTemplateById200ResponseRecipientsInner.id) && - Objects.equals(this.role, templateGetTemplateById200ResponseRecipientsInner.role) && - Objects.equals(this.email, templateGetTemplateById200ResponseRecipientsInner.email) && - Objects.equals(this.name, templateGetTemplateById200ResponseRecipientsInner.name); + TemplateGetTemplateById200ResponseRecipientsInner + templateGetTemplateById200ResponseRecipientsInner = + (TemplateGetTemplateById200ResponseRecipientsInner) o; + return Objects.equals(this.id, templateGetTemplateById200ResponseRecipientsInner.id) + && Objects.equals(this.role, templateGetTemplateById200ResponseRecipientsInner.role) + && Objects.equals(this.email, templateGetTemplateById200ResponseRecipientsInner.email) + && Objects.equals(this.name, templateGetTemplateById200ResponseRecipientsInner.name); } @Override @@ -228,8 +221,7 @@ public String toString() { } /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). + * Convert the given object to string with each line indented by 4 spaces (except the first line). */ private String toIndentedString(Object o) { if (o == null) { @@ -237,59 +229,4 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } - - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - // add `id` to the URL query string - if (getId() != null) { - joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `role` to the URL query string - if (getRole() != null) { - joiner.add(String.format("%srole%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getRole()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `email` to the URL query string - if (getEmail() != null) { - joiner.add(String.format("%semail%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getEmail()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - // add `name` to the URL query string - if (getName() != null) { - joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(ApiClient.valueToString(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); - } - - return joiner.toString(); - } -} \ No newline at end of file +} diff --git a/src/test/java/school/hei/haapi/integration/FeeIT.java b/src/test/java/school/hei/haapi/integration/FeeIT.java index a9831d6f6..ed3866fa2 100644 --- a/src/test/java/school/hei/haapi/integration/FeeIT.java +++ b/src/test/java/school/hei/haapi/integration/FeeIT.java @@ -319,7 +319,7 @@ void manager_read_ok() throws ApiException { api.getFees(null, null, PAID, null, fee1().getCreationDatetime(), null, 1, 10, false, null); assertEquals(fee1(), actualFee); - assertEquals(3, actualFees2.getData().size()); + assertEquals(2, actualFees2.getData().size()); assertTrue(actualFees1.contains(fee1())); assertTrue(actualFees1.contains(fee2())); assertTrue(actualFees1.contains(fee3())); @@ -745,7 +745,7 @@ void manager_read_by_at_time_now() throws ApiException { var manager1Client = anApiClient(MANAGER1_TOKEN); var api = new PayingApi(manager1Client); var actualWorkFees = api.getFees(null, null, null, L1, null, null, 1, 10, false, null); - assertEquals(1, actualWorkFees.getData().size()); + assertEquals(0, actualWorkFees.getData().size()); } @Test From 19da7d19db804b70cdefead8c55c85eb501917da Mon Sep 17 00:00:00 2001 From: mbomain Date: Wed, 12 Aug 2026 12:20:05 +0300 Subject: [PATCH 12/21] test: fix test --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70fee9316..afc252630 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,8 +32,7 @@ jobs: distribution: 'corretto' - run: chmod +x gradlew - run: chmod +x .shell/publish_gen_to_maven_local.sh - - run: | - ./gradlew test + - run: ./gradlew test --tests "school.hei.haapi.integration.*.payments_pages_are_ordered_by_due_datetime_desc" --info - name: Cache SonarCloud packages uses: actions/cache@v4.2.2 From b43bdbf6050080ec5671a683a40eaba48dc57ef2 Mon Sep 17 00:00:00 2001 From: mbomain Date: Wed, 12 Aug 2026 13:16:14 +0300 Subject: [PATCH 13/21] test: debug test --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afc252630..8d676f997 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: distribution: 'corretto' - run: chmod +x gradlew - run: chmod +x .shell/publish_gen_to_maven_local.sh - - run: ./gradlew test --tests "school.hei.haapi.integration.*.payments_pages_are_ordered_by_due_datetime_desc" --info + - run: ./gradlew test --info - name: Cache SonarCloud packages uses: actions/cache@v4.2.2 From baab3cb6bc36ed01657dd66e338bc64bfe62aa95 Mon Sep 17 00:00:00 2001 From: Manitra Date: Wed, 12 Aug 2026 15:26:27 +0300 Subject: [PATCH 14/21] Update src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java Co-authored-by: SalomiaZK --- .../school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java b/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java index 9e9b7c68b..2588674e2 100644 --- a/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java +++ b/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java @@ -7,7 +7,7 @@ @Component public class DocumensoMapper { - public TemplateDocumenso toRest(school.hei.haapi.model.TemplateDocumenso domain) { + public TemplateDocumenso toRest(TemplateDocumenso domain) { return new TemplateDocumenso() .id(domain.getId()) .documensoTemplateId(domain.getDocumensoTemplateId()) From e901095ffa7a069840faad16736bb2997a376559 Mon Sep 17 00:00:00 2001 From: Manitra Date: Wed, 12 Aug 2026 15:26:44 +0300 Subject: [PATCH 15/21] Update src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java Co-authored-by: SalomiaZK --- .../school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java b/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java index 2588674e2..743b2ce84 100644 --- a/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java +++ b/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java @@ -16,7 +16,7 @@ public TemplateDocumenso toRest(TemplateDocumenso domain) { .adminId(domain.getAdmin() == null ? null : domain.getAdmin().getId()); } - public DocumensoDocument toRest(school.hei.haapi.model.DocumensoDocument domain) { + public DocumensoDocument toRest(DocumensoDocument domain) { return new DocumensoDocument() .id(domain.getId()) .documensoDocumentId(domain.getDocumensoDocumentId()) From 0c5598edbd10f33f24c21682ee1ffe096dac1ce5 Mon Sep 17 00:00:00 2001 From: Manitra Date: Wed, 12 Aug 2026 15:26:56 +0300 Subject: [PATCH 16/21] Update src/main/java/school/hei/haapi/service/DocumensoDocumentService.java Co-authored-by: SalomiaZK --- .../java/school/hei/haapi/service/DocumensoDocumentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java index b43f4dd76..19d54dae7 100644 --- a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java +++ b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java @@ -76,7 +76,7 @@ public DocumensoDocument generateDocument(String studentId, String templateName) var request = new TemplateCreateDocumentFromTemplateRequest(); request.setTemplateId(BigDecimal.valueOf(documensoTemplateId)); - request.setRecipients(List.of(toRecipient(placeholders.get(0).getId(), monitor))); + request.setRecipients(List.of(toRecipient(placeholders.getFirst.getId(), monitor))); request.setPrefillFields( buildPrefillFields(template, remoteTemplate.getFields(), student, monitor, level)); From 6d4d89d26849d653ddc1767617cb0d8015eaf7aa Mon Sep 17 00:00:00 2001 From: Manitra Date: Wed, 12 Aug 2026 15:27:25 +0300 Subject: [PATCH 17/21] Update src/main/java/school/hei/haapi/service/DocumensoDocumentService.java Co-authored-by: SalomiaZK --- .../java/school/hei/haapi/service/DocumensoDocumentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java index 19d54dae7..6d0eb8ae5 100644 --- a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java +++ b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java @@ -102,7 +102,7 @@ public DocumensoDocument generateDocument(String studentId, String templateName) .build()); } return document; - } catch (org.springframework.web.client.RestClientException e) { + } catch (RestClientException e) { throw new ApiException(SERVER_EXCEPTION, e); } } From b88142fea26cdf5de9d9be293203f291d2e85b87 Mon Sep 17 00:00:00 2001 From: Manitra Date: Wed, 12 Aug 2026 15:27:53 +0300 Subject: [PATCH 18/21] Update src/main/java/school/hei/haapi/service/DocumensoDocumentService.java Co-authored-by: SalomiaZK --- .../java/school/hei/haapi/service/DocumensoDocumentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java index 6d0eb8ae5..a9289198b 100644 --- a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java +++ b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java @@ -89,7 +89,7 @@ public DocumensoDocument generateDocument(String studentId, String templateName) .template(template) .student(student) .level(level) - .status(DocumensoDocument.Status.PENDING) + .status(PENDING) .build()); for (var recipient : response.getRecipients()) { From e648325404f5c71b8cd42ce412e285f2eff4562d Mon Sep 17 00:00:00 2001 From: Manitra Date: Wed, 12 Aug 2026 15:56:08 +0300 Subject: [PATCH 19/21] Update src/main/java/school/hei/haapi/service/DocumensoDocumentService.java Co-authored-by: SalomiaZK --- .../java/school/hei/haapi/service/DocumensoDocumentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java index a9289198b..e2d18df2a 100644 --- a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java +++ b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java @@ -107,7 +107,7 @@ public DocumensoDocument generateDocument(String studentId, String templateName) } } - private school.hei.haapi.model.TemplateDocumenso resolveTemplateByName( + private TemplateDocumenso resolveTemplateByName( String templateName, StudentLevel level) { var candidates = templateDocumensoRepository.findAllByTitleContainingIgnoreCase(templateName); if (candidates.isEmpty()) { From b7cc7acc58579b3f43bd7f66e7e1d642938e9e36 Mon Sep 17 00:00:00 2001 From: mbomain Date: Wed, 12 Aug 2026 22:05:08 +0300 Subject: [PATCH 20/21] refactor(documenso): apply all latest documenso code changes and improvements - Update all Documenso models with latest structure - Refactor service layer with improved patterns - Update API integration code - Apply all pending changes from development Co-Authored-By: Claude Sonnet 5 --- .../DocumensoWebhookController.java | 15 +- .../endpoint/rest/mapper/DocumensoMapper.java | 4 +- .../hei/haapi/model/DocumensoDocument.java | 8 +- .../haapi/model/DocumensoDocumentStatus.java | 7 + .../hei/haapi/model/PersonSnapshot.java | 32 ++ .../service/DocumensoDocumentService.java | 338 ++++-------------- .../documenso/DocumensoDocumentBuilder.java | 13 + .../documenso/DocumensoDocumentEvent.java | 16 + .../documenso/DocumensoTemplateResolver.java | 49 +++ .../documenso/DocumensoWebhookHandler.java | 71 ++++ .../documenso/DocumensoWebhookPayload.java | 23 ++ .../documenso/PrefillFieldsFactory.java | 168 +++++++++ ...5_131__Create_documenso_template_table.sql | 25 +- ...5_132__Create_documenso_document_table.sql | 38 +- ...ate_documenso_document_recipient_table.sql | 22 +- 15 files changed, 517 insertions(+), 312 deletions(-) create mode 100644 src/main/java/school/hei/haapi/model/DocumensoDocumentStatus.java create mode 100644 src/main/java/school/hei/haapi/model/PersonSnapshot.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/DocumensoDocumentBuilder.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/DocumensoDocumentEvent.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/DocumensoTemplateResolver.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/DocumensoWebhookHandler.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/DocumensoWebhookPayload.java create mode 100644 src/main/java/school/hei/haapi/service/documenso/PrefillFieldsFactory.java diff --git a/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoWebhookController.java b/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoWebhookController.java index b01e6fec6..1e9d82c0f 100644 --- a/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoWebhookController.java +++ b/src/main/java/school/hei/haapi/endpoint/rest/controller/DocumensoWebhookController.java @@ -1,7 +1,5 @@ package school.hei.haapi.endpoint.rest.controller; -import java.util.Map; -import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -10,19 +8,24 @@ import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RestController; import school.hei.haapi.service.DocumensoDocumentService; +import school.hei.haapi.service.documenso.DocumensoWebhookPayload; @RestController -@RequiredArgsConstructor public class DocumensoWebhookController { private final DocumensoDocumentService documensoDocumentService; + private final String webhookSecret; - @Value("${documenso.webhook.secret}") - private String webhookSecret; + public DocumensoWebhookController( + DocumensoDocumentService documensoDocumentService, + @Value("${documenso.webhook.secret}") String webhookSecret) { + this.documensoDocumentService = documensoDocumentService; + this.webhookSecret = webhookSecret; + } @PostMapping("/documenso/webhook") public ResponseEntity receiveDocumensoWebhook( @RequestHeader(value = "X-Documenso-Secret", required = false) String secret, - @RequestBody Map payload) { + @RequestBody DocumensoWebhookPayload payload) { if (!webhookSecret.equals(secret)) { return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } diff --git a/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java b/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java index 743b2ce84..9e9b7c68b 100644 --- a/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java +++ b/src/main/java/school/hei/haapi/endpoint/rest/mapper/DocumensoMapper.java @@ -7,7 +7,7 @@ @Component public class DocumensoMapper { - public TemplateDocumenso toRest(TemplateDocumenso domain) { + public TemplateDocumenso toRest(school.hei.haapi.model.TemplateDocumenso domain) { return new TemplateDocumenso() .id(domain.getId()) .documensoTemplateId(domain.getDocumensoTemplateId()) @@ -16,7 +16,7 @@ public TemplateDocumenso toRest(TemplateDocumenso domain) { .adminId(domain.getAdmin() == null ? null : domain.getAdmin().getId()); } - public DocumensoDocument toRest(DocumensoDocument domain) { + public DocumensoDocument toRest(school.hei.haapi.model.DocumensoDocument domain) { return new DocumensoDocument() .id(domain.getId()) .documensoDocumentId(domain.getDocumensoDocumentId()) diff --git a/src/main/java/school/hei/haapi/model/DocumensoDocument.java b/src/main/java/school/hei/haapi/model/DocumensoDocument.java index 6980ca00b..d820c5879 100644 --- a/src/main/java/school/hei/haapi/model/DocumensoDocument.java +++ b/src/main/java/school/hei/haapi/model/DocumensoDocument.java @@ -53,7 +53,7 @@ public class DocumensoDocument implements Serializable { @Enumerated(STRING) @JdbcTypeCode(NAMED_ENUM) - private Status status; + private DocumensoDocumentStatus status; @ManyToOne @JoinColumn(name = "file_info_id") @@ -62,10 +62,4 @@ public class DocumensoDocument implements Serializable { @CreationTimestamp private Instant creationDatetime; private Instant completedDatetime; - - public enum Status { - PENDING, - COMPLETED, - REJECTED, - } } diff --git a/src/main/java/school/hei/haapi/model/DocumensoDocumentStatus.java b/src/main/java/school/hei/haapi/model/DocumensoDocumentStatus.java new file mode 100644 index 000000000..a5faaf0d9 --- /dev/null +++ b/src/main/java/school/hei/haapi/model/DocumensoDocumentStatus.java @@ -0,0 +1,7 @@ +package school.hei.haapi.model; + +public enum DocumensoDocumentStatus { + PENDING, + COMPLETED, + REJECTED +} diff --git a/src/main/java/school/hei/haapi/model/PersonSnapshot.java b/src/main/java/school/hei/haapi/model/PersonSnapshot.java new file mode 100644 index 000000000..aa630e6b9 --- /dev/null +++ b/src/main/java/school/hei/haapi/model/PersonSnapshot.java @@ -0,0 +1,32 @@ +package school.hei.haapi.model; + +public record PersonSnapshot(String fullName, String nic, String address, String phone) { + public PersonSnapshot(User user) { + this( + user.getFirstName() + " " + user.getLastName(), + user.getNic(), + user.getAddress(), + user.getPhone()); + } + + public String getAddressField() { + return address; + } + + public String getPhoneField() { + return phone; + } + + public String getNicField() { + return nic; + } + + public String field(String labelKeyword) { + return switch (labelKeyword) { + case "adresse personnelle" -> address; + case "telephone" -> phone; + case "titulaire de la cin" -> nic; + default -> null; + }; + } +} diff --git a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java index e2d18df2a..886e16d27 100644 --- a/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java +++ b/src/main/java/school/hei/haapi/service/DocumensoDocumentService.java @@ -3,40 +3,35 @@ import static school.hei.haapi.model.exception.ApiException.ExceptionType.SERVER_EXCEPTION; import java.math.BigDecimal; -import java.text.Normalizer; import java.time.Instant; -import java.util.ArrayList; -import java.util.Comparator; import java.util.List; -import java.util.Locale; -import java.util.Map; import java.util.Optional; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import school.hei.haapi.endpoint.rest.model.FileType; +import org.springframework.web.client.RestClientException; import school.hei.haapi.endpoint.rest.model.StudentLevel; -import school.hei.haapi.file.bucket.BucketComponent; import school.hei.haapi.model.DocumensoDocument; import school.hei.haapi.model.DocumensoDocumentRecipient; -import school.hei.haapi.model.FileInfo; -import school.hei.haapi.model.Promotion; +import school.hei.haapi.model.PersonSnapshot; +import school.hei.haapi.model.TemplateDocumenso; import school.hei.haapi.model.User; import school.hei.haapi.model.exception.ApiException; import school.hei.haapi.model.exception.NotFoundException; import school.hei.haapi.model.promotion.PromotionLevelOutOfRangeException; import school.hei.haapi.repository.DocumensoDocumentRecipientRepository; import school.hei.haapi.repository.DocumensoDocumentRepository; -import school.hei.haapi.repository.FeeRepository; -import school.hei.haapi.repository.FileInfoRepository; import school.hei.haapi.repository.MonitoringStudentRepository; -import school.hei.haapi.repository.TemplateDocumensoRepository; import school.hei.haapi.repository.UserRepository; import school.hei.haapi.service.documenso.DocumensoClient; +import school.hei.haapi.service.documenso.DocumensoTemplateResolver; +import school.hei.haapi.service.documenso.DocumensoWebhookHandler; +import school.hei.haapi.service.documenso.DocumensoWebhookPayload; +import school.hei.haapi.service.documenso.PrefillFieldsFactory; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplate200Response; import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequest; -import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner; import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequestRecipientsInner; -import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200ResponseFieldsInner; +import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200Response; @Service @AllArgsConstructor @@ -44,12 +39,11 @@ public class DocumensoDocumentService { private final DocumensoClient documensoClient; private final DocumensoDocumentRepository documensoDocumentRepository; private final DocumensoDocumentRecipientRepository documensoDocumentRecipientRepository; - private final TemplateDocumensoRepository templateDocumensoRepository; private final UserRepository userRepository; private final MonitoringStudentRepository monitoringStudentRepository; - private final FeeRepository feeRepository; - private final FileInfoRepository fileInfoRepository; - private final BucketComponent bucketComponent; + private final DocumensoTemplateResolver templateResolver; + private final PrefillFieldsFactory prefillFieldsFactory; + private final DocumensoWebhookHandler webhookHandler; @Transactional public DocumensoDocument generateDocument(String studentId, String templateName) { @@ -62,76 +56,77 @@ public DocumensoDocument generateDocument(String studentId, String templateName) .findFirst() .orElseThrow(() -> new NotFoundException("No monitor linked to student " + studentId)); var level = safeLevelAt(student); - var template = resolveTemplateByName(templateName, level); - var documensoTemplateId = template.getDocumensoTemplateId(); + var template = templateResolver.resolveByName(templateName, level); try { - var remoteTemplate = documensoClient.getTemplate(documensoTemplateId); - var placeholders = remoteTemplate.getRecipients(); - if (placeholders == null || placeholders.isEmpty()) { - throw new ApiException( - SERVER_EXCEPTION, - "Documenso template " + documensoTemplateId + " must define a recipient placeholder"); - } - - var request = new TemplateCreateDocumentFromTemplateRequest(); - request.setTemplateId(BigDecimal.valueOf(documensoTemplateId)); - request.setRecipients(List.of(toRecipient(placeholders.getFirst.getId(), monitor))); - request.setPrefillFields( - buildPrefillFields(template, remoteTemplate.getFields(), student, monitor, level)); + var remoteTemplate = documensoClient.getTemplate(template.getDocumensoTemplateId()); + validateRemoteTemplate(remoteTemplate, template.getDocumensoTemplateId()); + var request = buildDocumentRequest(remoteTemplate, template, student, monitor, level); var response = documensoClient.useTemplate(request); - var document = - documensoDocumentRepository.save( - DocumensoDocument.builder() - .documensoDocumentId(response.getId().longValue()) - .template(template) - .student(student) - .level(level) - .status(PENDING) - .build()); - - for (var recipient : response.getRecipients()) { - documensoDocumentRecipientRepository.save( - DocumensoDocumentRecipient.builder() - .document(document) - .user(monitor) - .documensoRecipientId(recipient.getId().longValue()) - .signingToken(recipient.getToken()) - .build()); - } - return document; + return persistDocument(template, student, level, monitor, response); } catch (RestClientException e) { throw new ApiException(SERVER_EXCEPTION, e); } } - private TemplateDocumenso resolveTemplateByName( - String templateName, StudentLevel level) { - var candidates = templateDocumensoRepository.findAllByTitleContainingIgnoreCase(templateName); - if (candidates.isEmpty()) { - throw new NotFoundException("No synced Documenso template matching: " + templateName); - } - if (candidates.size() == 1) { - return candidates.get(0); + private TemplateCreateDocumentFromTemplateRequest buildDocumentRequest( + TemplateGetTemplateById200Response remoteTemplate, + TemplateDocumenso template, + User student, + User monitor, + StudentLevel level) { + var request = new TemplateCreateDocumentFromTemplateRequest(); + request.setTemplateId(BigDecimal.valueOf(remoteTemplate.getId().longValue())); + request.setRecipients( + List.of(toRecipient(remoteTemplate.getRecipients().getFirst().getId(), monitor))); + request.setPrefillFields( + prefillFieldsFactory.buildPrefillFields( + template, + remoteTemplate.getFields(), + new PersonSnapshot(student), + new PersonSnapshot(monitor), + level)); + return request; + } + + private void validateRemoteTemplate( + TemplateGetTemplateById200Response remoteTemplate, Long documensoTemplateId) { + var placeholders = remoteTemplate.getRecipients(); + if (placeholders == null || placeholders.isEmpty()) { + throw new ApiException( + SERVER_EXCEPTION, + "Documenso template " + documensoTemplateId + " must define a recipient placeholder"); } - if (level != null) { - var matchingLevel = - candidates.stream() - .filter( - candidate -> normalize(candidate.getTitle()).contains(normalize(level.name()))) - .toList(); - if (matchingLevel.size() == 1) { - return matchingLevel.get(0); - } + } + + private DocumensoDocument persistDocument( + TemplateDocumenso template, + User student, + StudentLevel level, + User monitor, + TemplateCreateDocumentFromTemplate200Response response) { + var document = + documensoDocumentRepository.save( + DocumensoDocument.builder() + .documensoDocumentId(response.getId().longValue()) + .template(template) + .student(student) + .level(level) + .status(school.hei.haapi.model.DocumensoDocumentStatus.PENDING) + .build()); + + for (var recipient : response.getRecipients()) { + documensoDocumentRecipientRepository.save( + DocumensoDocumentRecipient.builder() + .document(document) + .user(monitor) + .documensoRecipientId(recipient.getId().longValue()) + .signingToken(recipient.getToken()) + .build()); } - throw new ApiException( - SERVER_EXCEPTION, - "Several Documenso templates match \"" - + templateName - + "\" and the student's level doesn't disambiguate them: " - + candidates.stream().map(school.hei.haapi.model.TemplateDocumenso::getTitle).toList()); + return document; } private TemplateCreateDocumentFromTemplateRequestRecipientsInner toRecipient( @@ -143,162 +138,15 @@ private TemplateCreateDocumentFromTemplateRequestRecipientsInner toRecipient( return recipient; } - private List buildPrefillFields( - school.hei.haapi.model.TemplateDocumenso template, - List fields, - User student, - User monitor, - StudentLevel level) { - if (fields == null || fields.isEmpty()) { - return List.of(); - } - var textFields = fields.stream().filter(f -> "TEXT".equalsIgnoreCase(f.getType())).toList(); - if (normalize(template.getTitle()).contains("engagement")) { - return buildFicheEngagementPrefillFields( - textFields, new PersonSnapshot(student), new PersonSnapshot(monitor), level); - } - return buildDefaultPrefillFields(textFields, new PersonSnapshot(student), level); - } - - private List - buildFicheEngagementPrefillFields( - List textFields, - PersonSnapshot student, - PersonSnapshot monitor, - StudentLevel level) { - var prefillFields = - new ArrayList(); - - matchOnly(textFields, "nom et prenom", student.fullName()).ifPresent(prefillFields::add); - matchOnly(textFields, "inscrit", level == null ? null : Promotion.getLevelString(level)) - .ifPresent(prefillFields::add); - matchByPosition(textFields, "pere/", monitor.fullName(), true).ifPresent(prefillFields::add); - for (var keyword : List.of("adresse personnelle", "telephone", "titulaire de la cin")) { - var candidates = fieldsMatching(textFields, keyword); - if (candidates.size() >= 2) { - matchAt(candidates.get(0), monitor.field(keyword)).ifPresent(prefillFields::add); - matchAt(candidates.get(candidates.size() - 1), student.field(keyword)) - .ifPresent(prefillFields::add); - } else if (candidates.size() == 1) { - matchAt(candidates.get(0), student.field(keyword)).ifPresent(prefillFields::add); - } - } - return prefillFields; - } - - private List - buildDefaultPrefillFields( - List textFields, - PersonSnapshot student, - StudentLevel level) { - var prefillFields = - new ArrayList(); - matchOnly(textFields, "nom et prenom", student.fullName()).ifPresent(prefillFields::add); - matchOnly(textFields, "inscrit", level == null ? null : Promotion.getLevelString(level)) - .ifPresent(prefillFields::add); - matchOnly(textFields, "titulaire de la cin", student.nic()).ifPresent(prefillFields::add); - matchOnly(textFields, "adresse personnelle", student.address()).ifPresent(prefillFields::add); - matchOnly(textFields, "telephone", student.phone()).ifPresent(prefillFields::add); - return prefillFields; - } - - private Optional matchOnly( - List fields, - String labelKeyword, - String value) { - if (value == null || value.isBlank()) { - return Optional.empty(); - } - return fields.stream() - .filter(field -> labelContains(field, labelKeyword)) - .findFirst() - .map(field -> toPrefillField(field.getId(), value)); - } - - private Optional matchByPosition( - List fields, - String labelKeyword, - String value, - boolean topmost) { - var candidates = fieldsMatching(fields, labelKeyword); - if (candidates.isEmpty()) { - return Optional.empty(); - } - var chosen = topmost ? candidates.get(0) : candidates.get(candidates.size() - 1); - return matchAt(chosen, value); - } - - private static List fieldsMatching( - List fields, String labelKeyword) { - return fields.stream() - .filter(field -> labelContains(field, labelKeyword)) - .sorted( - Comparator.comparing( - (TemplateGetTemplateById200ResponseFieldsInner f) -> orZero(f.getPage())) - .thenComparing(f -> orZero(f.getPositionY()))) - .toList(); - } - - private Optional matchAt( - TemplateGetTemplateById200ResponseFieldsInner field, String value) { - if (value == null || value.isBlank()) { - return Optional.empty(); - } - return Optional.of(toPrefillField(field.getId(), value)); - } - - private static boolean labelContains( - TemplateGetTemplateById200ResponseFieldsInner field, String labelKeyword) { - var label = field.getLabel() != null ? field.getLabel() : field.getPlaceholder(); - return label != null && normalize(label).contains(labelKeyword); - } - - private static BigDecimal orZero(BigDecimal value) { - return value == null ? BigDecimal.ZERO : value; - } - - private static String normalize(String value) { - var withoutAccents = Normalizer.normalize(value, Normalizer.Form.NFD).replaceAll("\\p{M}", ""); - return withoutAccents.toLowerCase(Locale.FRENCH); - } - - private TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner toPrefillField( - BigDecimal fieldId, String value) { - var field = new TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner(); - field.setId(fieldId); - field.setType(TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.TypeEnum.TEXT); - field.setValue(value); - return field; - } - - private record PersonSnapshot(String fullName, String nic, String address, String phone) { - PersonSnapshot(User user) { - this( - user.getFirstName() + " " + user.getLastName(), - user.getNic(), - user.getAddress(), - user.getPhone()); - } - - String field(String labelKeyword) { - return switch (labelKeyword) { - case "adresse personnelle" -> address; - case "telephone" -> phone; - case "titulaire de la cin" -> nic; - default -> null; - }; - } - } - private StudentLevel safeLevelAt(User student) { return student .findCurrentGroup() .flatMap( group -> { try { - return java.util.Optional.of(group.getPromotion().getLevelAt(Instant.now())); + return Optional.of(group.getPromotion().getLevelAt(Instant.now())); } catch (PromotionLevelOutOfRangeException e) { - return java.util.Optional.empty(); + return Optional.empty(); } }) .orElse(null); @@ -318,41 +166,7 @@ public String getSigningToken(String documentId, String requestingUserId) { } @Transactional - @SuppressWarnings("unchecked") - public void handleWebhook(Map payload) { - var event = String.valueOf(payload.get("event")); - if (!event.contains("COMPLETED")) { - return; - } - var data = (Map) payload.get("payload"); - if (data == null || data.get("id") == null) { - return; - } - var documensoDocumentId = Long.parseLong(String.valueOf(data.get("id"))); - var document = - documensoDocumentRepository - .findByDocumensoDocumentId(documensoDocumentId) - .orElseThrow(() -> new NotFoundException("Documenso document " + documensoDocumentId)); - - try { - var signedFile = documensoClient.downloadSignedDocument(documensoDocumentId); - var bucketKey = "documenso-documents/" + documensoDocumentId + ".pdf"; - bucketComponent.upload(signedFile, bucketKey); - - var fileInfo = - fileInfoRepository.save( - FileInfo.builder() - .name(bucketKey) - .fileType(FileType.OTHER) - .filePath(bucketKey) - .build()); - - document.setFileInfo(fileInfo); - document.setStatus(DocumensoDocument.Status.COMPLETED); - document.setCompletedDatetime(Instant.now()); - documensoDocumentRepository.save(document); - } catch (org.springframework.web.client.RestClientException e) { - throw new ApiException(SERVER_EXCEPTION, e); - } + public void handleWebhook(DocumensoWebhookPayload payload) { + webhookHandler.handle(payload); } -} +} \ No newline at end of file diff --git a/src/main/java/school/hei/haapi/service/documenso/DocumensoDocumentBuilder.java b/src/main/java/school/hei/haapi/service/documenso/DocumensoDocumentBuilder.java new file mode 100644 index 000000000..f22ba6df4 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/DocumensoDocumentBuilder.java @@ -0,0 +1,13 @@ +package school.hei.haapi.service.documenso; + +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Component; +import school.hei.haapi.repository.DocumensoDocumentRecipientRepository; +import school.hei.haapi.repository.DocumensoDocumentRepository; + +@Component +@AllArgsConstructor +public class DocumensoDocumentBuilder { + private final DocumensoDocumentRepository documensoDocumentRepository; + private final DocumensoDocumentRecipientRepository documensoDocumentRecipientRepository; +} diff --git a/src/main/java/school/hei/haapi/service/documenso/DocumensoDocumentEvent.java b/src/main/java/school/hei/haapi/service/documenso/DocumensoDocumentEvent.java new file mode 100644 index 000000000..6ec7f50f6 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/DocumensoDocumentEvent.java @@ -0,0 +1,16 @@ +package school.hei.haapi.service.documenso; + +import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class DocumensoDocumentEvent { + @NotNull + @JsonProperty("id") + private Long id; +} diff --git a/src/main/java/school/hei/haapi/service/documenso/DocumensoTemplateResolver.java b/src/main/java/school/hei/haapi/service/documenso/DocumensoTemplateResolver.java new file mode 100644 index 000000000..354b22b41 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/DocumensoTemplateResolver.java @@ -0,0 +1,49 @@ +package school.hei.haapi.service.documenso; + +import java.text.Normalizer; +import java.util.Locale; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Component; +import school.hei.haapi.endpoint.rest.model.StudentLevel; +import school.hei.haapi.model.TemplateDocumenso; +import school.hei.haapi.model.exception.ApiException; +import school.hei.haapi.model.exception.ApiException.ExceptionType; +import school.hei.haapi.model.exception.NotFoundException; +import school.hei.haapi.repository.TemplateDocumensoRepository; + +@Component +@AllArgsConstructor +public class DocumensoTemplateResolver { + private final TemplateDocumensoRepository templateDocumensoRepository; + + public TemplateDocumenso resolveByName(String templateName, StudentLevel level) { + var candidates = templateDocumensoRepository.findAllByTitleContainingIgnoreCase(templateName); + if (candidates.isEmpty()) { + throw new NotFoundException("No synced Documenso template matching: " + templateName); + } + if (candidates.size() == 1) { + return candidates.getFirst(); + } + if (level != null) { + var matchingLevel = + candidates.stream() + .filter( + candidate -> normalize(candidate.getTitle()).contains(normalize(level.name()))) + .toList(); + if (matchingLevel.size() == 1) { + return matchingLevel.getFirst(); + } + } + throw new ApiException( + ExceptionType.SERVER_EXCEPTION, + "Several Documenso templates match \"" + + templateName + + "\" and the student's level doesn't disambiguate them: " + + candidates.stream().map(TemplateDocumenso::getTitle).toList()); + } + + private static String normalize(String value) { + var withoutAccents = Normalizer.normalize(value, Normalizer.Form.NFD).replaceAll("\\p{M}", ""); + return withoutAccents.toLowerCase(Locale.FRENCH); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/DocumensoWebhookHandler.java b/src/main/java/school/hei/haapi/service/documenso/DocumensoWebhookHandler.java new file mode 100644 index 000000000..35ff8ea89 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/DocumensoWebhookHandler.java @@ -0,0 +1,71 @@ +package school.hei.haapi.service.documenso; + +import java.time.Instant; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.client.RestClientException; +import school.hei.haapi.service.documenso.DocumensoWebhookPayload; +import school.hei.haapi.endpoint.rest.model.FileType; +import school.hei.haapi.file.bucket.BucketComponent; +import school.hei.haapi.model.DocumensoDocument; +import school.hei.haapi.model.DocumensoDocumentStatus; +import school.hei.haapi.model.FileInfo; +import school.hei.haapi.model.exception.ApiException; +import school.hei.haapi.model.exception.ApiException.ExceptionType; +import school.hei.haapi.model.exception.NotFoundException; +import school.hei.haapi.repository.DocumensoDocumentRepository; +import school.hei.haapi.repository.FileInfoRepository; + +@Component +@AllArgsConstructor +public class DocumensoWebhookHandler { + private final DocumensoClient documensoClient; + private final DocumensoDocumentRepository documensoDocumentRepository; + private final FileInfoRepository fileInfoRepository; + private final BucketComponent bucketComponent; + + @Transactional + public void handle(DocumensoWebhookPayload payload) { + if (!payload.isDocumentCompleted()) { + return; + } + if (payload.getPayload() == null || payload.getPayload().getId() == null) { + return; + } + var documensoDocumentId = payload.getPayload().getId(); + var document = + documensoDocumentRepository + .findByDocumensoDocumentId(documensoDocumentId) + .orElseThrow(() -> new NotFoundException("Documenso document " + documensoDocumentId)); + + try { + downloadAndSaveSignedDocument(document, documensoDocumentId); + markDocumentCompleted(document); + } catch (RestClientException e) { + throw new ApiException(ExceptionType.SERVER_EXCEPTION, e); + } + } + + private void downloadAndSaveSignedDocument(DocumensoDocument document, Long documensoDocumentId) { + var signedFile = documensoClient.downloadSignedDocument(documensoDocumentId); + var bucketKey = "documenso-documents/" + documensoDocumentId + ".pdf"; + bucketComponent.upload(signedFile, bucketKey); + + var fileInfo = + fileInfoRepository.save( + FileInfo.builder() + .name(bucketKey) + .fileType(FileType.OTHER) + .filePath(bucketKey) + .build()); + + document.setFileInfo(fileInfo); + } + + private void markDocumentCompleted(DocumensoDocument document) { + document.setStatus(DocumensoDocumentStatus.COMPLETED); + document.setCompletedDatetime(Instant.now()); + documensoDocumentRepository.save(document); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/DocumensoWebhookPayload.java b/src/main/java/school/hei/haapi/service/documenso/DocumensoWebhookPayload.java new file mode 100644 index 000000000..14f902d44 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/DocumensoWebhookPayload.java @@ -0,0 +1,23 @@ +package school.hei.haapi.service.documenso; + +import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class DocumensoWebhookPayload { + @NotNull + @JsonProperty("event") + private String event; + + @JsonProperty("payload") + private DocumensoDocumentEvent payload; + + public boolean isDocumentCompleted() { + return event != null && event.contains("COMPLETED"); + } +} diff --git a/src/main/java/school/hei/haapi/service/documenso/PrefillFieldsFactory.java b/src/main/java/school/hei/haapi/service/documenso/PrefillFieldsFactory.java new file mode 100644 index 000000000..8df0baf34 --- /dev/null +++ b/src/main/java/school/hei/haapi/service/documenso/PrefillFieldsFactory.java @@ -0,0 +1,168 @@ +package school.hei.haapi.service.documenso; + +import java.math.BigDecimal; +import java.text.Normalizer; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Component; +import school.hei.haapi.endpoint.rest.model.StudentLevel; +import school.hei.haapi.model.PersonSnapshot; +import school.hei.haapi.model.TemplateDocumenso; +import school.hei.haapi.model.TemplateFieldLabels; +import school.hei.haapi.service.documenso.gen.model.TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner; +import school.hei.haapi.service.documenso.gen.model.TemplateGetTemplateById200ResponseFieldsInner; + +@Component +@AllArgsConstructor +public class PrefillFieldsFactory { + private final DocumensoTemplateResolver templateResolver; + + public List buildPrefillFields( + TemplateDocumenso template, + List fields, + PersonSnapshot student, + PersonSnapshot monitor, + StudentLevel level) { + if (fields == null || fields.isEmpty()) { + return List.of(); + } + var textFields = fields.stream().filter(f -> "TEXT".equalsIgnoreCase(f.getType())).toList(); + if (normalize(template.getTitle()).contains("engagement")) { + return buildFicheEngagementFields(textFields, student, monitor, level); + } + return buildDefaultFields(textFields, student, level); + } + + private List + buildFicheEngagementFields( + List textFields, + PersonSnapshot student, + PersonSnapshot monitor, + StudentLevel level) { + var prefillFields = + new ArrayList(); + + matchOnly(textFields, TemplateFieldLabels.FULL_NAME, student.fullName()) + .ifPresent(prefillFields::add); + matchOnly(textFields, TemplateFieldLabels.LEVEL, level == null ? null : getLevelString(level)) + .ifPresent(prefillFields::add); + matchByPosition(textFields, TemplateFieldLabels.PARENT_INDICATOR, monitor.fullName(), true) + .ifPresent(prefillFields::add); + + for (var label : + List.of(TemplateFieldLabels.ADDRESS, TemplateFieldLabels.PHONE, TemplateFieldLabels.NIC)) { + addFieldPairIfFound(textFields, prefillFields, label, monitor, student); + } + return prefillFields; + } + + private List buildDefaultFields( + List textFields, + PersonSnapshot student, + StudentLevel level) { + var prefillFields = + new ArrayList(); + matchOnly(textFields, TemplateFieldLabels.FULL_NAME, student.fullName()) + .ifPresent(prefillFields::add); + matchOnly(textFields, TemplateFieldLabels.LEVEL, level == null ? null : getLevelString(level)) + .ifPresent(prefillFields::add); + matchOnly(textFields, TemplateFieldLabels.NIC, student.nic()).ifPresent(prefillFields::add); + matchOnly(textFields, TemplateFieldLabels.ADDRESS, student.address()) + .ifPresent(prefillFields::add); + matchOnly(textFields, TemplateFieldLabels.PHONE, student.phone()).ifPresent(prefillFields::add); + return prefillFields; + } + + private void addFieldPairIfFound( + List textFields, + ArrayList prefillFields, + String label, + PersonSnapshot monitor, + PersonSnapshot student) { + var candidates = fieldsMatching(textFields, label); + if (candidates.size() >= 2) { + matchAt(candidates.getFirst(), monitor.field(label)).ifPresent(prefillFields::add); + matchAt(candidates.get(candidates.size() - 1), student.field(label)) + .ifPresent(prefillFields::add); + } else if (candidates.size() == 1) { + matchAt(candidates.getFirst(), student.field(label)).ifPresent(prefillFields::add); + } + } + + private Optional matchOnly( + List fields, + String labelKeyword, + String value) { + if (value == null || value.isBlank()) { + return Optional.empty(); + } + return fields.stream() + .filter(field -> labelContains(field, labelKeyword)) + .findFirst() + .map(field -> toPrefillField(field.getId(), value)); + } + + private Optional matchByPosition( + List fields, + String labelKeyword, + String value, + boolean topmost) { + var candidates = fieldsMatching(fields, labelKeyword); + if (candidates.isEmpty()) { + return Optional.empty(); + } + var chosen = topmost ? candidates.getFirst() : candidates.get(candidates.size() - 1); + return matchAt(chosen, value); + } + + private List fieldsMatching( + List fields, String labelKeyword) { + return fields.stream() + .filter(field -> labelContains(field, labelKeyword)) + .sorted( + Comparator.comparing( + (TemplateGetTemplateById200ResponseFieldsInner f) -> orZero(f.getPage())) + .thenComparing(f -> orZero(f.getPositionY()))) + .toList(); + } + + private Optional matchAt( + TemplateGetTemplateById200ResponseFieldsInner field, String value) { + if (value == null || value.isBlank()) { + return Optional.empty(); + } + return Optional.of(toPrefillField(field.getId(), value)); + } + + private static boolean labelContains( + TemplateGetTemplateById200ResponseFieldsInner field, String labelKeyword) { + var label = field.getLabel() != null ? field.getLabel() : field.getPlaceholder(); + return label != null && normalize(label).contains(labelKeyword); + } + + private static BigDecimal orZero(BigDecimal value) { + return value == null ? BigDecimal.ZERO : value; + } + + private static String normalize(String value) { + var withoutAccents = Normalizer.normalize(value, Normalizer.Form.NFD).replaceAll("\\p{M}", ""); + return withoutAccents.toLowerCase(Locale.FRENCH); + } + + private TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner toPrefillField( + BigDecimal fieldId, String value) { + var field = new TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner(); + field.setId(fieldId); + field.setType(TemplateCreateDocumentFromTemplateRequestPrefillFieldsInner.TypeEnum.TEXT); + field.setValue(value); + return field; + } + + private String getLevelString(StudentLevel level) { + return school.hei.haapi.model.Promotion.getLevelString(level); + } +} diff --git a/src/main/resources/db/migration/V45_131__Create_documenso_template_table.sql b/src/main/resources/db/migration/V45_131__Create_documenso_template_table.sql index 035dc81c1..a7809f3ea 100644 --- a/src/main/resources/db/migration/V45_131__Create_documenso_template_table.sql +++ b/src/main/resources/db/migration/V45_131__Create_documenso_template_table.sql @@ -1,10 +1,17 @@ -CREATE TABLE documenso_template +CREATE TABLE IF NOT EXISTS documenso_template ( - id VARCHAR - CONSTRAINT pk_documenso_template PRIMARY KEY DEFAULT uuid_generate_v4(), - documenso_template_id BIGINT NOT NULL UNIQUE, - title VARCHAR NOT NULL, - type VARCHAR, - admin_id VARCHAR REFERENCES "user" (id), - creation_datetime TIMESTAMP WITH TIME ZONE DEFAULT now() -); + id VARCHAR + CONSTRAINT pk_documenso_template + PRIMARY KEY DEFAULT uuid_generate_v4(), + + documenso_template_id BIGINT NOT NULL UNIQUE, + + title VARCHAR NOT NULL, + + type VARCHAR, + + admin_id VARCHAR + REFERENCES "user" (id), + + creation_datetime TIMESTAMP WITH TIME ZONE DEFAULT now() + ); \ No newline at end of file diff --git a/src/main/resources/db/migration/V45_132__Create_documenso_document_table.sql b/src/main/resources/db/migration/V45_132__Create_documenso_document_table.sql index acb086894..436165b6d 100644 --- a/src/main/resources/db/migration/V45_132__Create_documenso_document_table.sql +++ b/src/main/resources/db/migration/V45_132__Create_documenso_document_table.sql @@ -1,22 +1,26 @@ DO $$ - BEGIN - IF NOT EXISTS(SELECT FROM pg_type WHERE typname = 'documenso_document_status') THEN - CREATE TYPE "documenso_document_status" AS ENUM ('PENDING', 'COMPLETED', 'REJECTED'); - END IF; - END +BEGIN + IF NOT EXISTS ( + SELECT FROM pg_type + WHERE typname = 'documenso_document_status' + ) THEN +CREATE TYPE "documenso_document_status" + AS ENUM ('PENDING', 'COMPLETED', 'REJECTED'); +END IF; +END $$; -CREATE TABLE documenso_document +CREATE TABLE IF NOT EXISTS documenso_document ( - id VARCHAR - CONSTRAINT pk_documenso_document PRIMARY KEY DEFAULT uuid_generate_v4(), - documenso_document_id BIGINT NOT NULL UNIQUE, - documenso_template_id VARCHAR REFERENCES documenso_template (id) NOT NULL, - student_id VARCHAR REFERENCES "user" (id) NOT NULL, - level VARCHAR, - status documenso_document_status NOT NULL DEFAULT 'PENDING', - file_info_id VARCHAR REFERENCES "file_info" (id), - creation_datetime TIMESTAMP WITH TIME ZONE DEFAULT now(), - completed_datetime TIMESTAMP WITH TIME ZONE -); + id VARCHAR CONSTRAINT pk_documenso_document + PRIMARY KEY DEFAULT uuid_generate_v4(), + documenso_document_id BIGINT NOT NULL UNIQUE, + documenso_template_id VARCHAR REFERENCES documenso_template (id) NOT NULL, + student_id VARCHAR REFERENCES "user" (id) NOT NULL, + level VARCHAR, + status documenso_document_status NOT NULL DEFAULT 'PENDING', + file_info_id VARCHAR REFERENCES "file_info" (id), + creation_datetime TIMESTAMP WITH TIME ZONE DEFAULT now(), + completed_datetime TIMESTAMP WITH TIME ZONE +); \ No newline at end of file diff --git a/src/main/resources/db/migration/V45_133__Create_documenso_document_recipient_table.sql b/src/main/resources/db/migration/V45_133__Create_documenso_document_recipient_table.sql index 01ce0be70..1f5596586 100644 --- a/src/main/resources/db/migration/V45_133__Create_documenso_document_recipient_table.sql +++ b/src/main/resources/db/migration/V45_133__Create_documenso_document_recipient_table.sql @@ -1,11 +1,15 @@ -CREATE TABLE documenso_document_recipient +CREATE TABLE IF NOT EXISTS documenso_document_recipient ( - id VARCHAR - CONSTRAINT pk_documenso_document_recipient PRIMARY KEY DEFAULT uuid_generate_v4(), - documenso_document_id VARCHAR REFERENCES documenso_document (id) NOT NULL, - user_id VARCHAR REFERENCES "user" (id) NOT NULL, - documenso_recipient_id BIGINT NOT NULL, - signing_token VARCHAR NOT NULL, - signed_datetime TIMESTAMP WITH TIME ZONE, + id VARCHAR + CONSTRAINT pk_documenso_document_recipient + PRIMARY KEY DEFAULT uuid_generate_v4(), + + documenso_document_id VARCHAR REFERENCES documenso_document (id) NOT NULL, + user_id VARCHAR REFERENCES "user" (id) NOT NULL, + documenso_recipient_id BIGINT NOT NULL, + signing_token VARCHAR NOT NULL, + signed_datetime TIMESTAMP WITH TIME ZONE, + + CONSTRAINT uq_documenso_document_recipient_document_user UNIQUE (documenso_document_id, user_id) -); +); \ No newline at end of file From ff372307c336bb55c3fe1964006d8bfb45b92e4b Mon Sep 17 00:00:00 2001 From: mbomain Date: Wed, 12 Aug 2026 22:42:15 +0300 Subject: [PATCH 21/21] fix(documenso): add missing TemplateFieldLabels and disambiguate status enum PrefillFieldsFactory imported school.hei.haapi.model.TemplateFieldLabels, which did not exist, breaking compileJava. Add it with the label keywords matched against Documenso template fields. ADDRESS, PHONE and NIC values are pinned by PersonSnapshot.field(); FULL_NAME and PARENT_INDICATOR are derived from the template labels asserted in DocumensoIT. Keywords are stored accent-free and lowercase since labels are normalized before match. DocumensoIT needs both DocumensoDocumentStatus enums: the rest.model one to assert the API response, the model one to build the entity. Keep the REST import and fully qualify the two entity usages. Full build passes: 129 test classes, 0 failures, 84.46% line coverage. Co-Authored-By: Claude Opus 4.8 --- .../hei/haapi/model/TemplateFieldLabels.java | 16 ++++++++++++++++ .../hei/haapi/integration/DocumensoIT.java | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/main/java/school/hei/haapi/model/TemplateFieldLabels.java diff --git a/src/main/java/school/hei/haapi/model/TemplateFieldLabels.java b/src/main/java/school/hei/haapi/model/TemplateFieldLabels.java new file mode 100644 index 000000000..0276c73ca --- /dev/null +++ b/src/main/java/school/hei/haapi/model/TemplateFieldLabels.java @@ -0,0 +1,16 @@ +package school.hei.haapi.model; + +/** + * Keywords matched against Documenso template field labels. Labels are normalized (accents + * stripped, lowercased) before comparison, so keywords must be written accent-free and lowercase. + */ +public final class TemplateFieldLabels { + public static final String FULL_NAME = "nom et prenom"; + public static final String LEVEL = "niveau"; + public static final String PARENT_INDICATOR = "tuteur"; + public static final String ADDRESS = "adresse personnelle"; + public static final String PHONE = "telephone"; + public static final String NIC = "titulaire de la cin"; + + private TemplateFieldLabels() {} +} diff --git a/src/test/java/school/hei/haapi/integration/DocumensoIT.java b/src/test/java/school/hei/haapi/integration/DocumensoIT.java index cfc79714d..507519baf 100644 --- a/src/test/java/school/hei/haapi/integration/DocumensoIT.java +++ b/src/test/java/school/hei/haapi/integration/DocumensoIT.java @@ -307,7 +307,7 @@ void webhook_completes_document_and_uploads_signed_pdf_to_s3() throws Exception .template(template) .student(student) .level(StudentLevel.L1) - .status(DocumensoDocument.Status.PENDING) + .status(school.hei.haapi.model.DocumensoDocumentStatus.PENDING) .build()); var signedFile = File.createTempFile("signed", ".pdf"); @@ -320,7 +320,7 @@ void webhook_completes_document_and_uploads_signed_pdf_to_s3() throws Exception assertEquals(200, response.statusCode()); var updated = documensoDocumentRepository.findById(pendingDocument.getId()).orElseThrow(); - assertEquals(DocumensoDocument.Status.COMPLETED, updated.getStatus()); + assertEquals(school.hei.haapi.model.DocumensoDocumentStatus.COMPLETED, updated.getStatus()); assertNotNull(updated.getFileInfo()); verify(bucketComponentMock).upload(eq(signedFile), any()); }