public AbstractRequest createEmbeddedRequest ( EmbeddedRequest embeddedReq ) throws HelloSignException { String url = BASE_URI ; Class < ? > returnType = SignatureRequest . class ; AbstractRequest req = embeddedReq . getRequest ( ) ; if ( req instanceof TemplateSignatureRequest ) { url += SIGNATURE_REQUEST_EMBEDDED_TEMPLATE_URI ; } else if ( req instanceof UnclaimedDraft ) { if ( ( ( UnclaimedDraft ) req ) . getRequest ( ) instanceof TemplateSignatureRequest ) { url += UNCLAIMED_DRAFT_CREATE_EMBEDDED_WITH_TEMPLATE_URI ; } else { url += UNCLAIMED_DRAFT_CREATE_EMBEDDED_URI ; } returnType = UnclaimedDraft . class ; } else { url += SIGNATURE_REQUEST_EMBEDDED_URI ; } try { Constructor < ? > constructor = returnType . getConstructor ( JSONObject . class ) ; return ( AbstractRequest ) constructor . newInstance ( httpClient . withAuth ( auth ) . withPostFields ( embeddedReq . getPostFields ( ) ) . post ( url ) . asJson ( ) ) ; } catch ( Exception ex ) { throw new HelloSignException ( ex ) ; } }
Creates a signature request that can be embedded within your website .