lib/docusign_rest/client.rb in docusign_rest-0.0.3 vs lib/docusign_rest/client.rb in docusign_rest-0.0.4
- old
+ new
@@ -241,12 +241,12 @@
\"requireIdLookup\":false,
\"roleName\":\"#{signer[:role_name]}\",
\"routingOrder\":#{index+1},
\"socialAuthentications\":null,
\"templateAccessCodeRequired\":false,
- \"templateLocked\":#{signer[:template_locked] || 'false'},
- \"templateRequired\":#{signer[:template_required] || 'false'},
+ \"templateLocked\":#{signer[:template_locked] || true},
+ \"templateRequired\":#{signer[:template_required] || true},
\"email\":\"#{signer[:email]}\",
\"name\":\"#{signer[:name]}\",
\"autoNavigation\":false,
\"defaultRecipient\":false,
\"signatureInfo\":null,
@@ -266,24 +266,28 @@
\"numberTabs\":null,
\"radioGroupTabs\":null,
\"signHereTabs\":[
{
\"anchorString\":\"#{signer[:anchor_string]}\",
- \"conditionalParentLabel\":null,
- \"conditionalParentValue\":null,
+ \"anchorXOffset\": \"0\",
+ \"anchorYOffset\": \"0\",
+ \"anchorIgnoreIfNotPresent\": false,
+ \"anchorUnits\": \"pixels\",
+ \"conditionalParentLabel\": null,
+ \"conditionalParentValue\": null,
\"documentId\":\"#{signer[:document_id] || '1'}\",
\"pageNumber\":\"#{signer[:page_number] || '1'}\",
\"recipientId\":\"#{index+1}\",
- \"templateLocked\":#{signer[:template_locked] || 'false'},
- \"templateRequired\":#{signer[:template_required] || 'false'},
+ \"templateLocked\":#{signer[:template_locked] || true},
+ \"templateRequired\":#{signer[:template_required] || true},
\"xPosition\":\"#{signer[:x_position] || '0'}\",
\"yPosition\":\"#{signer[:y_position] || '0'}\",
\"name\":\"#{signer[:sign_here_tab_text] || 'Sign Here'}\",
\"optional\":false,
\"scaleValue\":1,
\"tabLabel\":\"#{signer[:tab_label] || 'Signature 1'}\"
- }
+ },
],
\"signerAttachmentTabs\":null,
\"ssnTabs\":null,
\"textTabs\":null,
\"titleTabs\":null,
@@ -423,11 +427,11 @@
# status - Options include: 'sent', 'created', 'voided' and determine
# if the envelope is sent out immediately or stored for
# sending at a later time
# headers - Allows a client to pass in some
#
- # Returns a response object containing:
+ # Returns a JSON parsed response object containing:
# envelopeId - The envelope's ID
# status - Sent, created, or voided
# statusDateTime - The date/time the envelope was created
# uri - The relative envelope uri
def create_envelope_from_document(options={})
@@ -452,11 +456,12 @@
request = initialize_net_http_multipart_post_request(
uri, post_body, file_params, headers(options[:headers])
)
# Finally do the Net::HTTP request!
- http.request(request)
+ response = http.request(request)
+ parsed_response = JSON.parse(response.body)
end
# Public: allows a template to be dynamically created with several options.
#
@@ -480,11 +485,11 @@
# description - The template description
# name - The template name
# headers - Optional hash of headers to merge into the existing
# required headers for a multipart request.
#
- # Returns a response body containing the template's:
+ # Returns a JSON parsed response body containing the template's:
# name - Name given above
# templateId - The auto-generated ID provided by DocuSign
# Uri - the URI where the template is located on the DocuSign servers
def create_template(options={})
ios = create_file_ios(options[:files])
@@ -514,11 +519,12 @@
request = initialize_net_http_multipart_post_request(
uri, post_body, file_params, headers(options[:headers])
)
# Finally do the Net::HTTP request!
- http.request(request)
+ response = http.request(request)
+ parsed_response = JSON.parse(response.body)
end
# Public: create an envelope for delivery from a template
#
@@ -536,11 +542,11 @@
# this 'signers' and not 'templateRoles' when we build up
# the request in client code.
# headers - Optional hash of headers to merge into the existing
# required headers for a multipart request.
#
- # Returns a response body containing the envelope's:
+ # Returns a JSON parsed response body containing the envelope's:
# name - Name given above
# templateId - The auto-generated ID provided by DocuSign
# Uri - the URI where the template is located on the DocuSign servers
def create_envelope_from_template(options={})
content_type = {'Content-Type' => 'application/json'}
@@ -556,17 +562,15 @@
uri = build_uri("/accounts/#{@acct_id}/envelopes")
http = initialize_net_http_ssl(uri)
- request = Net::HTTP::Post.new(
- uri.request_uri,
- headers(content_type)
- )
+ request = Net::HTTP::Post.new(uri.request_uri, headers(content_type))
request.body = post_body
- http.request(request)
+ response = http.request(request)
+ parsed_response = JSON.parse(response.body)
end
# Public returns the URL for embedded signing
#
@@ -576,11 +580,11 @@
# return_url - the URL you want the user to be directed to after he or she
# completes the document signing
# headers - optional hash of headers to merge into the existing
# required headers for a multipart request.
#
- # Returns the URL for embedded signing which needs to be put in an iFrame
+ # Returns the URL string for embedded signing (can be put in an iFrame)
def get_recipient_view(options={})
content_type = {'Content-Type' => 'application/json'}
content_type.merge(options[:headers]) if options[:headers]
post_body = "{
@@ -593,17 +597,40 @@
uri = build_uri("/accounts/#{@acct_id}/envelopes/#{options[:envelope_id]}/views/recipient")
http = initialize_net_http_ssl(uri)
- request = Net::HTTP::Post.new(
- uri.request_uri,
- headers(content_type)
- )
+ request = Net::HTTP::Post.new(uri.request_uri, headers(content_type))
request.body = post_body
- http.request(request)
+ response = http.request(request)
+ parsed_response = JSON.parse(response.body)
+ parsed_response["url"]
end
+ # Public returns the envelope recipients for a given envelope
+ #
+ # include_tabs - boolean, determines if the tabs for each signer will be
+ # returned in the response, defaults to false.
+ # envelope_id - ID of the envelope for which you want to retrive the
+ # signer info
+ # headers - optional hash of headers to merge into the existing
+ # required headers for a multipart request.
+ #
+ # Returns a hash of detailed info about the envelope including the signer
+ # hash and status of each signer
+ def get_envelope_recipients(options={})
+ content_type = {'Content-Type' => 'application/json'}
+ content_type.merge(options[:headers]) if options[:headers]
+
+ include_tabs = options[:include_tabs] || false
+ include_extended = options[:include_extended] || false
+ uri = build_uri("/accounts/#{@acct_id}/envelopes/#{options[:envelope_id]}/recipients?include_tabs=#{include_tabs}&include_extended=#{include_extended}")
+
+ http = initialize_net_http_ssl(uri)
+ request = Net::HTTP::Get.new(uri.request_uri, headers(content_type))
+ response = http.request(request)
+ parsed_response = JSON.parse(response.body)
+ end
end
end