internal static DocumentBuilder NewDocumentFromAPIDocument(Silanis.ESL.API.Document apiDocument, Silanis.ESL.API.Package package) { DocumentBuilder documentBuilder = DocumentBuilder.NewDocumentNamed(apiDocument.Name) .WithId(apiDocument.Id) .AtIndex(apiDocument.Index) .WithDescription(apiDocument.Description); foreach (Silanis.ESL.API.Approval apiApproval in apiDocument.Approvals) { Signature signature = SignatureBuilder.NewSignatureFromAPIApproval(apiApproval, package).Build(); documentBuilder.WithSignature(signature); } foreach (Silanis.ESL.API.Field apiField in apiDocument.Fields) { FieldBuilder fieldBuilder = FieldBuilder.NewFieldFromAPIField(apiField); documentBuilder.WithInjectedField(fieldBuilder); } return(documentBuilder); }
internal static SignatureBuilder NewSignatureFromAPIApproval(Silanis.ESL.API.Approval apiApproval, Silanis.ESL.API.Package package) { Silanis.ESL.API.Signer apiSigner = null; foreach (Silanis.ESL.API.Role role in package.Roles) { if (role.Id.Equals(apiApproval.Role)) { apiSigner = role.Signers [0]; } } if (apiSigner == null) { return(null); } SignatureBuilder signatureBuilder = new SignatureBuilder(apiSigner.Email).WithName(apiApproval.Name); Silanis.ESL.API.Field apiSignatureField = null; foreach (Silanis.ESL.API.Field apiField in apiApproval.Fields) { if (apiField.Type == Silanis.ESL.API.FieldType.SIGNATURE) { apiSignatureField = apiField; } else { FieldBuilder fieldBuilder = FieldBuilder.NewFieldFromAPIField(apiField); signatureBuilder.WithField(fieldBuilder); } } if (apiSignatureField == null) { signatureBuilder.WithStyle(SignatureStyle.ACCEPTANCE); signatureBuilder.WithSize(0, 0); } else { signatureBuilder.WithStyle(FromAPIFieldSubType(apiSignatureField.Subtype)) .OnPage(apiSignatureField.Page) .AtPosition(apiSignatureField.Left, apiSignatureField.Top) .WithSize(apiSignatureField.Width, apiSignatureField.Height); if (apiSignatureField.Extract) { signatureBuilder.EnableExtraction(); } } return(signatureBuilder); }