rightsignature 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,3 +4,4 @@
4
4
  *.swp
5
5
  *.swo
6
6
  Gemfile.lock
7
+ pkg
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -1,13 +1,32 @@
1
1
  module RightSignature
2
2
  module Account
3
+ # Return account information about API user
4
+ #
5
+ # Ex.
6
+ # @rs_connection.user_details
7
+ #
3
8
  def user_details
4
9
  get "/api/users/user_details.xml"
5
10
  end
6
11
 
12
+ # Creates a user on API user's account
13
+ # * name: User's name
14
+ # * email: User's email
15
+ #
16
+ # Ex.
17
+ # @rs_connection.add_user("John Bellingham", "john@example.com")
18
+ #
7
19
  def add_user(name, email)
8
20
  post "/api/users.xml", {:user => {:name => name, :email => email}}
9
21
  end
10
22
 
23
+ # Return account's usage report (# of documents sent)
24
+ # * <b>since</b>: ("month"/"week"/"day") only count documents sent within a certain time
25
+ # * <b>signed</b>: (true/false) only count signed document
26
+ #
27
+ # Ex. Return count of signed documents sent this month
28
+ # @rs_connection.usage_report("month", true)
29
+ #
11
30
  def usage_report(since=nil, signed=nil)
12
31
  options = {}
13
32
  options[:since] = since if since && ["month", "week", "day"].include?(since)
@@ -8,6 +8,22 @@ module RightSignature
8
8
  attr_accessor :oauth_connection
9
9
  attr_accessor :token_connection
10
10
 
11
+ # Creates new instance of RightSignature::Connection to make API calls
12
+ # * <b>creds</b>: Hash of credentials for API Token or OAuth. If both are specified, it uses API Token
13
+ # * Hash key for API Token:
14
+ # * :api_token
15
+ # * Hash keys for OAuth:
16
+ # * :consumer_key
17
+ # * :consumer_secret
18
+ # * :access_token
19
+ # * :access_secret
20
+ #
21
+ # Example for Api Token:
22
+ # @rs_connection = RightSignature::Connection.new(:api_token => "MYTOKEN")
23
+ #
24
+ # Example for OAuth:
25
+ # @rs_connection = RightSignature::Connection.new(:consumer_key => "ckey", :consumer_secret => "csecret", :access_token => "atoken", :access_secret => "asecret")
26
+ #
11
27
  def initialize(creds={})
12
28
  @configuration = {}
13
29
  RightSignature::Connection.oauth_keys.each do |key|
@@ -24,10 +40,14 @@ module RightSignature
24
40
  @configuration
25
41
  end
26
42
 
43
+ # Checks if credentials are set for either API Token or for OAuth
44
+ #
27
45
  def check_credentials
28
46
  raise "Please set load_configuration with #{RightSignature::Connection.api_token_keys.join(',')} or #{RightSignature::Connection.oauth_keys.join(',')}" unless has_api_token? || has_oauth_credentials?
29
47
  end
30
48
 
49
+ # Checks if API Token credentials are set. Does not validate creds with server.
50
+ #
31
51
  def has_api_token?
32
52
  return false if @configuration.nil?
33
53
  RightSignature::Connection.api_token_keys.each do |key|
@@ -37,6 +57,8 @@ module RightSignature
37
57
  return true
38
58
  end
39
59
 
60
+ # Checks if OAuth credentials are set. Does not validate creds with server.
61
+ #
40
62
  def has_oauth_credentials?
41
63
  return false if @configuration.nil?
42
64
  RightSignature::Connection.oauth_keys.each do |key|
@@ -46,14 +68,17 @@ module RightSignature
46
68
  return true
47
69
  end
48
70
 
71
+ # :nodoc:
49
72
  def self.oauth_keys
50
73
  [:consumer_key, :consumer_secret, :access_token, :access_secret].freeze
51
74
  end
52
75
 
76
+ # :nodoc:
53
77
  def self.api_token_keys
54
78
  [:api_token].freeze
55
79
  end
56
80
 
81
+ # :nodoc:
57
82
  def site
58
83
  if has_api_token?
59
84
  RightSignature::TokenConnection.base_uri
@@ -62,6 +87,16 @@ module RightSignature
62
87
  end
63
88
  end
64
89
 
90
+ # PUT request to server
91
+ #
92
+ # Arguments:
93
+ # url: Path of API call
94
+ # body: XML body in hash format
95
+ # url: Hash of HTTP headers to include
96
+ #
97
+ # Example:
98
+ # @rs_connection.put("/api/documents.xml", {:documents=> {}}, {"User-Agent" => "My Own"})
99
+ #
65
100
  def put(url, body={}, headers={})
66
101
  if has_api_token?
67
102
  options = {}
@@ -74,6 +109,15 @@ module RightSignature
74
109
  end
75
110
  end
76
111
 
112
+ # DELETE request to server
113
+ #
114
+ # Arguments:
115
+ # url: Path of API call
116
+ # url: Hash of HTTP headers to include
117
+ #
118
+ # Example:
119
+ # @rs_connection.delete("/api/users.xml", {"User-Agent" => "My Own"})
120
+ #
77
121
  def delete(url, headers={})
78
122
  if has_api_token?
79
123
  options = {}
@@ -85,6 +129,16 @@ module RightSignature
85
129
  end
86
130
  end
87
131
 
132
+ # GET request to server
133
+ #
134
+ # Arguments:
135
+ # url: Path of API call
136
+ # params: Hash of URL parameters to include in request
137
+ # url: Hash of HTTP headers to include
138
+ #
139
+ # Example:
140
+ # @rs_connection.get("/api/documents.xml", {:search => "my term"}, {"User-Agent" => "My Own"})
141
+ #
88
142
  def get(url, params={}, headers={})
89
143
  check_credentials
90
144
 
@@ -101,6 +155,15 @@ module RightSignature
101
155
  end
102
156
  end
103
157
 
158
+ # POST request to server
159
+ #
160
+ # Arguments:
161
+ # url: Path of API call
162
+ # url: Hash of HTTP headers to include
163
+ #
164
+ # Example:
165
+ # @rs_connection.post("/api/users.xml", {"User-Agent" => "My Own"})
166
+ #
104
167
  def post(url, body={}, headers={})
105
168
  check_credentials
106
169
 
@@ -114,6 +177,16 @@ module RightSignature
114
177
  end
115
178
  end
116
179
 
180
+ # Attempts to parse response from a connection and return it as a hash.
181
+ # If response isn't a success, an RightSignature::ResponseError is raised
182
+ #
183
+ # Arguments:
184
+ # url: Path of API call
185
+ # url: Hash of HTTP headers to include
186
+ #
187
+ # Example:
188
+ # @rs_connection.delete("/api/users.xml", {"User-Agent" => "My Own"})
189
+ #
117
190
  def parse_response(response)
118
191
  if response.is_a? Net::HTTPResponse
119
192
  unless response.is_a? Net::HTTPSuccess
@@ -3,6 +3,17 @@ module RightSignature
3
3
  attr_reader :request_token
4
4
  attr_reader :consumer_key, :consumer_secret, :oauth_access_token, :oauth_access_secret
5
5
 
6
+ # Creates new instance of RightSignature::OauthConnection to make API calls
7
+ # * <b>creds</b>: Hash of credentials for OAuth.
8
+ # * Hash keys for OAuth:
9
+ # * :consumer_key
10
+ # * :consumer_secret
11
+ # * :access_token
12
+ # * :access_secret
13
+ #
14
+ # Example:
15
+ # @rs_oauth = RightSignature::OauthConnection.new(:consumer_key => "ckey", :consumer_secret => "csecret", :access_token => "atoken", :access_secret => "asecret")
16
+ #
6
17
  def initialize(credentials={})
7
18
  @consumer_key = credentials[:consumer_key]
8
19
  @consumer_secret = credentials[:consumer_secret]
@@ -10,6 +21,7 @@ module RightSignature
10
21
  @oauth_access_secret = credentials[:access_secret]
11
22
  end
12
23
 
24
+ # Oauth consumer
13
25
  def oauth_consumer
14
26
  check_credentials unless @consumer_key && @consumer_secret
15
27
  @oauth_consumer ||= OAuth::Consumer.new(
@@ -26,21 +38,30 @@ module RightSignature
26
38
  )
27
39
  end
28
40
 
41
+ # Access token
29
42
  def access_token
30
43
  check_credentials
31
44
  @access_token ||= OAuth::AccessToken.new(oauth_consumer, @oauth_access_token, @oauth_access_secret)
32
45
  end
33
-
46
+
47
+ # Replaces access token
48
+ # * <b>access_token</b>: access token key
49
+ # * <b>access_secret</b>: access token secret
50
+ #
34
51
  def set_access_token(access_token, access_secret)
35
52
  @oauth_access_token = access_token
36
53
  @oauth_access_secret = access_secret
37
54
  @access_token = OAuth::AccessToken.new(oauth_consumer, @oauth_access_token, @oauth_access_secret)
38
55
  end
39
56
 
57
+ # Uses consumer to generate a request token.
40
58
  def new_request_token
41
59
  @request_token = oauth_consumer.get_request_token
42
60
  end
43
61
 
62
+ # Uses request token and given OAuth verifier to generate an access token. Requires a request token to be set.
63
+ # * <b>oauth_verifier</b>: OAuth verifier
64
+ #
44
65
  def generate_access_token(oauth_verifier)
45
66
  raise "Please set request token with new_request_token" unless @request_token
46
67
  @access_token = @request_token.get_access_token(:oauth_verifier => oauth_verifier)
@@ -49,6 +70,10 @@ module RightSignature
49
70
  @access_token
50
71
  end
51
72
 
73
+ # Generates HTTP request with oauth credentials. Require access_token to be set.
74
+ # * <b>method</b>: HTTP Method. Ex. ('get'/'post'/'delete'/'put')
75
+ # * <b>options</b>: OAuth::AccessToken options to pass. Last option should be headers
76
+ #
52
77
  def request(method, *options)
53
78
  options.last ||= {}
54
79
  options.last["Accept"] ||= "*/*"
@@ -58,10 +83,12 @@ module RightSignature
58
83
  end
59
84
 
60
85
  private
86
+ # Raises exception if OAuth credentials are not set.
61
87
  def check_credentials
62
88
  raise "Please set #{RightSignature::Connection.oauth_keys.join(', ')}" unless has_oauth_credentials?
63
89
  end
64
90
 
91
+ # Checks if OAuth credentials are set.
65
92
  def has_oauth_credentials?
66
93
  [@consumer_key, @consumer_secret, @oauth_access_token, @oauth_access_secret].each do |cred|
67
94
  return false if cred.nil? || cred.match(/^\s*$/)
@@ -6,11 +6,21 @@ module RightSignature
6
6
 
7
7
  attr_reader :api_token
8
8
 
9
+ # Creates new instance of RightSignature::TokenConnection to make API calls
10
+ # * <b>api_token</b>: API Token.
11
+ #
12
+ # Example:
13
+ # @rs_token = RightSignature::TokenConnection.new("APITOKEN")
14
+ #
9
15
  def initialize(api_token)
10
16
  @api_token = api_token
11
17
  end
12
18
 
13
-
19
+ # Generates HTTP request with token credentials. Require api_token to be set.
20
+ # * <b>method</b>: HTTP Method. Ex. ('get'/'post'/'delete'/'put')
21
+ # * <b>url</b>: request path/url of request
22
+ # * <b>options</b>: HTTPary options to pass. Last option should be headers
23
+ #
14
24
  def request(method, url, options)
15
25
  raise "Please set api_token" if @api_token.nil? || @api_token.empty?
16
26
 
@@ -18,9 +28,9 @@ module RightSignature
18
28
  options[:headers]['api-token'] = @api_token
19
29
  options[:headers]["Accept"] ||= "*/*"
20
30
  options[:headers]["content-type"] ||= "application/xml"
21
- __send__(method, url, options)
31
+ self.class.__send__(method, url, options)
22
32
  end
23
33
 
24
34
  end
25
35
 
26
- end
36
+ end
@@ -2,152 +2,240 @@ module RightSignature
2
2
  module Document
3
3
  include RightSignature::Helpers
4
4
 
5
+ # Lists documents
6
+ # * <b>options</b>: (optional) search filters
7
+ # * <b>:state</b> - (completed/trashed/pending) filter by state
8
+ # * <b>:page</b> - page offset
9
+ # * <b>:per_page</b> - # of entries per page to return
10
+ # * <b>:search</b> - search term filter
11
+ # * <b>:tags</b> - tags filter. Array of ["single_tag", {"tag_key" => "tag_value"}]
12
+ # * <b>:sort</> - sort documents by given attribute.
13
+ # API supports 'created', 'completed', and 'activity'
14
+ # * <b>:range</b> - ('today'/'thisweek'/'thismonth'/'alltime'/Date) return documents with a certain date range.
15
+ # * <b> :recipient_email</b> - filter document where it has a recipient with given email and involves the current OAuth user.
16
+ # * <b> :account</b> - (true/false) include all documents in current account if true.
17
+ #
18
+ # Ex.
19
+ # options = {
20
+ # :state => ['completed', 'trashed'],
21
+ # :page => 1,
22
+ # :per_page => 20,
23
+ # :search => "me",
24
+ # :tags => ["single_tag", "key" => "with_value"]
25
+ # }
26
+ #
27
+ # @rs_connection.documents_list(options)
28
+ #
5
29
  def documents_list(options={})
6
30
  options[:tags] = TagsHelper.mixed_array_to_string_array(options[:tags]) if options[:tags]
7
31
  options[:state] = options[:state].join(',') if options[:state] && options[:state].is_a?(Array)
8
32
  get "/api/documents.xml", options
9
33
  end
10
34
 
35
+ # Gets details for a document
36
+ # * <b>guids</b>: Array of document GUIDs
37
+ #
38
+ # Ex. Get details for document GUID123
39
+ # @rs_connection.document_details("GUID123")
40
+ #
11
41
  def document_details(guid)
12
42
  get "/api/documents/#{guid}.xml"
13
43
  end
14
44
 
45
+ # Gets details for multiple documents.
46
+ # * <b>guids</b>: Array of document GUIDs
47
+ #
48
+ # Ex. Get details for documents GUID123 and GUID345
49
+ # @rs_connection.documents_batch_details(["GUID123","GUID345"])
50
+ #
15
51
  def documents_batch_details(guids)
16
52
  get "/api/documents/#{guids.join(',')}/batch_details.xml"
17
53
  end
18
54
 
55
+ # Sends a reminder for a document
56
+ # * <b>guid</b>: Document GUID
57
+ #
58
+ # Ex. Sends reminder for document GUID123
59
+ # @rs_connection.send_reminder("GUID123")
60
+ #
19
61
  def send_reminder(guid)
20
62
  post "/api/documents/#{guid}/send_reminders.xml", {}
21
63
  end
22
64
 
65
+ # Extends a document's expiration date by 7 days
66
+ # * <b>guid</b>: Document GUID
67
+ #
68
+ # Ex. Extend expiration for document GUID123 by 7 days
69
+ # @rs_connection.trash_document("GUID123")
70
+ #
23
71
  def trash_document(guid)
24
72
  post "/api/documents/#{guid}/trash.xml", {}
25
73
  end
26
74
 
75
+
76
+ # Extends a document's expiration date by 7 days
77
+ # * <b>guid</b>: Document GUID
78
+ #
79
+ # Ex. Extend expiration for document GUID123 by 7 days
80
+ # @rs_connection.extend_document_expiration("GUID123")
81
+ #
27
82
  def extend_document_expiration(guid)
28
83
  post "/api/documents/#{guid}/extend_expiration.xml", {}
29
84
  end
30
85
 
31
- # This will REPLACE the tags on a document
86
+ # <b>REPLACE</b> the tags on a document
32
87
  # tags are an array of 'tag_name' or {'tag_name' => 'value'}
33
- # Hash style:
34
- # {:name => value}
88
+ #
89
+ # Ex. Replaces document GUID123 with tags "single_tag", "hello:bye"
90
+ # @rs_connection.update_document_tags("GUID123", ["single_tag", {"hello" => "bye"}])
35
91
  def update_document_tags(guid, tags)
36
92
  post "/api/documents/#{guid}/update_tags.xml", { :tags => TagsHelper.array_to_xml_hash(tags) }
37
93
  end
38
94
 
39
95
  # Creates a document from a raw data
40
- # * file: file binary. Ex. File.read('myfile.pdf')
41
- # * filename: original filename
42
- # * subject: subject of the document that'll appear in email
43
- # * recipients: Recipients of the document, should be an array of hashes with :name, :email, and :role ('cc' or 'signer').
44
- # An optional :is_sender (true/false) is used to referrence the API User and won't need to supply :name and :email
45
- # Ex. CC to support@rightsignature.com, with sender and john@rightsignature.com as a signer
96
+ # * <b>file</b>: file binary. Ex. File.read('myfile.pdf')
97
+ # * <b>filename</b>: original filename
98
+ # * <b>subject</b>: subject of the document that'll appear in email
99
+ # * <b>recipients</b>: Recipients of the document, should be an array of hashes with :name, :email, and :role ('cc' or 'signer').
100
+ # One of the recipients requires <b>:is_sender</b> (true/false) to reference the API User and won't need to supply :name and :email
101
+ # Ex. CC to support@rightsignature.com, with sender and john@rightsignature.com as a signer
46
102
  # [
47
103
  # {:name => "RightSignature", :email => "support@rightsignature.com", :role => 'cc'},
48
104
  # {:name => "John Bellingham", :email => "john@rightsignature.com", :role => 'signer'},
49
105
  # {'is_sender' => true, :role => 'signer'},
50
106
  # ]
51
- # * options: other optional values
52
- # - description: document description that'll appear in the email
53
- # - action: 'send' or 'redirect'. Redirect will return a token that will allow another person to send the document under API user's account
54
- # - expires_in: number of days before expiring the document. API only allows 2,5,15, or 30.
55
- # - tags: document tags, an array of string or hashes 'single_tag' (for simple tag) or {'tag_name' => 'tag_value'} (for tuples pairs)
56
- # Ex. ['sent_from_api', {"user_id" => "32"}]
57
- # - callback_url: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
58
- # Ex. "http://yoursite/callback"
59
- # - use_text_tags: Document has special Text Tags that RightSignature parse. true or false.
60
- # More info: https://rightsignature.com/apidocs/text_tags
107
+ # * <b>options</b>: other optional values
108
+ # - <b>description</b>: document description that'll appear in the email
109
+ # - <b>action</b>: 'send' or 'redirect'. Redirect will return a token that will allow another person to send the document under API user's account
110
+ # - <b>expires_in</b>: number of days before expiring the document. API only allows 2,5,15, or 30.
111
+ # - <b>tags</b>: document tags, an array of string or hashes 'single_tag' (for simple tag) or {'tag_name' => 'tag_value'} (for tuples pairs)
112
+ # Ex. ['sent_from_api', {"user_id" => "32"}]
113
+ # - <b>callback_url</b>: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
114
+ # Ex. "http://yoursite/callback"
115
+ # - <b>use_text_tags</b>: Document has special Text Tags that RightSignature parse. true or false.
116
+ # More info: https://rightsignature.com/apidocs/text_tags
61
117
  def send_document_from_data(file_data, filename, subject, recipients, options={})
62
118
  send_document(subject, recipients, {:type => "base64", :filename => filename, :value => Base64::encode64(file_data)}, options)
63
119
  end
64
120
 
65
121
  # Creates a document from a File or path to file
66
- # * file: Path to file or File object
67
- # * subject: subject of the document that'll appear in email
68
- # * recipients: Recipients of the document, should be an array of hashes with :name, :email, and :role ('cc' or 'signer').
69
- # An optional :is_sender (true/false) is used to referrence the API User and won't need to supply :name and :email
70
- # Ex. CC to support@rightsignature.com, with sender and john@rightsignature.com as a signer
122
+ # * <b>file</b>: Path to file or File object
123
+ # * <b>subject</b>: subject of the document that'll appear in email
124
+ # * <b>recipients</b>: Recipients of the document, should be an array of hashes with :name, :email, and :role ('cc' or 'signer').
125
+ # One of the recipients requires <b>:is_sender</b> (true/false) to reference the API User and won't need to supply :name and :email
126
+ # Ex. CC to support@rightsignature.com, with sender and john@rightsignature.com as a signer
71
127
  # [
72
128
  # {:name => "RightSignature", :email => "support@rightsignature.com", :role => 'cc'},
73
129
  # {:name => "John Bellingham", :email => "john@rightsignature.com", :role => 'signer'},
74
130
  # {'is_sender' => true, :role => 'signer'},
75
131
  # ]
76
- # * options: other optional values
77
- # - description: document description that'll appear in the email
78
- # - action: 'send' or 'redirect'. Redirect will return a token that will allow another person to send the document under API user's account
79
- # - expires_in: number of days before expiring the document. API only allows 2,5,15, or 30.
80
- # - tags: document tags, an array of string or hashes 'single_tag' (for simple tag) or {'tag_name' => 'tag_value'} (for tuples pairs)
81
- # Ex. ['sent_from_api', {"user_id" => "32"}]
82
- # - callback_url: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
83
- # Ex. "http://yoursite/callback"
84
- # - use_text_tags: Document has special Text Tags that RightSignature parse. true or false.
85
- # More info: https://rightsignature.com/apidocs/text_tags
132
+ # * <b>options</b>: other optional values
133
+ # - <b>description</b>: document description that'll appear in the email
134
+ # - <b>action</b>: 'send' or 'redirect'. Redirect will return a token that will allow another person to send the document under API user's account
135
+ # - <b>expires_in</b>: number of days before expiring the document. API only allows 2,5,15, or 30.
136
+ # - <b>tags</b>: document tags, an array of string or hashes 'single_tag' (for simple tag) or {'tag_name' => 'tag_value'} (for tuples pairs)
137
+ # Ex. ['sent_from_api', {"user_id" => "32"}]
138
+ # - <b>callback_url</b>: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
139
+ # Ex. "http://yoursite/callback"
140
+ # - <b>use_text_tags</b>: Document has special Text Tags that RightSignature parse. true or false.
141
+ # More info: https://rightsignature.com/apidocs/text_tags
142
+ #
143
+ # Example:
144
+ # recipients = [
145
+ # {:name => "RightSignature", :email => "support@rightsignature.com", :role => 'cc'},
146
+ # {:name => "John Bellingham", :email => "john@rightsignature.com", :role => 'signer'},
147
+ # {'is_sender' => true, :role => 'signer'}
148
+ # ]
149
+ # options={
150
+ # :tags => [{:tag => {:name => 'sent_from_api'}}, {:tag => {:name => 'user_id', :value => '12345'}}],
151
+ # :expires_in => '5 days',
152
+ # :action => "redirect",
153
+ # 'callback_location' => "http://example.com/doc_callback",
154
+ # 'use_text_tags' => false
155
+ # }
156
+ # @rs_connection.send_document_from_file("here/is/myfile.pdf", 'My Subject', recipients, options)
157
+ #
86
158
  def send_document_from_file(file, subject, recipients, options={})
87
159
  send_document(subject, recipients, {:type => "base64", :filename => File.basename(file), :value => Base64::encode64(File.read(file)) }, options)
88
160
  end
89
161
 
90
162
  # Creates a document from URL
91
- # * url: URL to file
92
- # * subject: subject of the document that'll appear in email
93
- # * recipients: Recipients of the document, should be an array of hashes with :name, :email, and :role ('cc' or 'signer').
94
- # An optional :is_sender (true/false) is used to referrence the API User and won't need to supply :name and :email
95
- # Ex. CC to support@rightsignature.com, with sender and john@rightsignature.com as a signer
163
+ # * <b>url</b>: URL to file
164
+ # * <b>subject</b>: subject of the document that'll appear in email
165
+ # * <b>recipients</b>: Recipients of the document, should be an array of hashes with :name, :email, and :role ('cc' or 'signer').
166
+ # One of the recipients requires <b>:is_sender</b> (true/false) to reference the API User and won't need to supply :name and :email
167
+ # Ex. CC to support@rightsignature.com, with sender and john@rightsignature.com as a signer
96
168
  # [
97
169
  # {:name => "RightSignature", :email => "support@rightsignature.com", :role => 'cc'},
98
170
  # {:name => "John Bellingham", :email => "john@rightsignature.com", :role => 'signer'},
99
171
  # {'is_sender' => true, :role => 'signer'},
100
172
  # ]
101
- # * options: other optional values
102
- # - description: document description that'll appear in the email
103
- # - action: 'send' or 'redirect'. Redirect will return a token that will allow another person to send the document under API user's account
104
- # - expires_in: number of days before expiring the document. API only allows 2,5,15, or 30.
105
- # - tags: document tags, an array of string or hashes 'single_tag' (for simple tag) or {'tag_name' => 'tag_value'} (for tuples pairs)
106
- # Ex. ['sent_from_api', {"user_id" => "32"}]
107
- # - callback_url: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
108
- # Ex. "http://yoursite/callback"
109
- # - use_text_tags: Document has special Text Tags that RightSignature parse. true or false.
110
- # More info: https://rightsignature.com/apidocs/text_tags
173
+ # * <b>options</b>: other optional values
174
+ # - <b>description</b>: document description that'll appear in the email
175
+ # - <b>action</b>: 'send' or 'redirect'. Redirect will return a token that will allow another person to send the document under API user's account
176
+ # - <b>expires_in</b>: number of days before expiring the document. API only allows 2,5,15, or 30.
177
+ # - <b>tags</b>: document tags, an array of string or hashes 'single_tag' (for simple tag) or {'tag_name' => 'tag_value'} (for tuples pairs)
178
+ # Ex. ['sent_from_api', {"user_id" => "32"}]
179
+ # - <b>callback_url</b>: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
180
+ # Ex. "http://yoursite/callback"
181
+ # - <b>use_text_tags</b>: Document has special Text Tags that RightSignature parse. true or false.
182
+ # More info: https://rightsignature.com/apidocs/text_tags
183
+ #
184
+ # Example:
185
+ # recipients = [
186
+ # {:name => "RightSignature", :email => "support@rightsignature.com", :role => 'cc'},
187
+ # {:name => "John Bellingham", :email => "john@rightsignature.com", :role => 'signer'},
188
+ # {'is_sender' => true, :role => 'signer'}
189
+ # ]
190
+ # options={
191
+ # :tags => [{:tag => {:name => 'sent_from_api'}}, {:tag => {:name => 'user_id', :value => '12345'}}],
192
+ # :expires_in => '5 days',
193
+ # :action => "redirect",
194
+ # 'callback_location' => "http://example.com/doc_callback",
195
+ # 'use_text_tags' => false
196
+ # }
197
+ # @rs_connection.send_document_from_url("http://myfile/here", 'My Subject', recipients, options)
198
+ #
111
199
  def send_document_from_url(url, subject, recipients, options={})
112
200
  send_document(subject, recipients, {:type => "url", :filename => File.basename(url), :value => url }, options)
113
201
  end
114
202
 
115
203
  # Creates a document from a base64 encoded file or publicly available URL
116
- # * document_data: hash of document source :type ('base64' or 'url'), :filename to be used, :value of source (url or base64 encoded binary)
117
- # * subject: subject of the document that'll appear in email
118
- # * recipients: Recipients of the document, should be an array of hashes with :name, :email, and :role ('cc' or 'signer').
119
- # An optional :is_sender (true/false) is used to referrence the API User and won't need to supply :name and :email
120
- # Ex. CC to support@rightsignature.com, with sender and john@rightsignature.com as a signer
204
+ # * <b>document_data</b>: hash of document source :type ('base64' or 'url'), :filename to be used, :value of source (url or base64 encoded binary)
205
+ # * <b>subject</b>: subject of the document that'll appear in email
206
+ # * <b>recipients</b>: Recipients of the document, should be an array of hashes with :name, :email, and :role ('cc' or 'signer').
207
+ # One of the recipients requires <b>:is_sender</b> (true/false) to reference the API User and won't need to supply :name and :email
208
+ # Ex. CC to support@rightsignature.com, with sender and john@rightsignature.com as a signer
121
209
  # [
122
210
  # {:name => "RightSignature", :email => "support@rightsignature.com", :role => 'cc'},
123
211
  # {:name => "John Bellingham", :email => "john@rightsignature.com", :role => 'signer'},
124
212
  # {'is_sender' => true, :role => 'signer'},
125
213
  # ]
126
214
  # * options: other optional values
127
- # - description: document description that'll appear in the email
128
- # - action: 'send' or 'redirect'. Redirect will return a token that will allow another person to send the document under API user's account
129
- # - expires_in: number of days before expiring the document. API only allows 2,5,15, or 30.
130
- # - tags: document tags, an array of string or hashes 'single_tag' (for simple tag) or {'tag_name' => 'tag_value'} (for tuples pairs)
131
- # Ex. ['sent_from_api', {"user_id" => "32"}]
132
- # - callback_url: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
133
- # Ex. "http://yoursite/callback"
134
- # - use_text_tags: Document has special Text Tags that RightSignature parse. true or false.
135
- # More info: https://rightsignature.com/apidocs/text_tags
215
+ # - <b>description</b>: document description that'll appear in the email
216
+ # - <b>action</b>: 'send' or 'redirect'. Redirect will return a token that will allow another person to send the document under API user's account
217
+ # - <b>expires_in</b>: number of days before expiring the document. API only allows 2,5,15, or 30.
218
+ # - <b>tags</b>: document tags, an array of string or hashes 'single_tag' (for simple tag) or {'tag_name' => 'tag_value'} (for tuples pairs)
219
+ # Ex. ['sent_from_api', {"user_id" => "32"}]
220
+ # - <b>callback_url</b>: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
221
+ # Ex. "http://yoursite/callback"
222
+ # - <b>use_text_tags</b>: Document has special Text Tags that RightSignature parse. true or false.
223
+ # More info: https://rightsignature.com/apidocs/text_tags
136
224
  # Ex.
137
- # recipients = [
138
- # {:name => "RightSignature", :email => "support@rightsignature.com", :role => 'cc'},
139
- # {:name => "John Bellingham", :email => "john@rightsignature.com", :role => 'signer'},
140
- # {'is_sender' => true, :role => 'signer'},
141
- # ]
142
- # document_data = {:type => 'base64', :filename => "originalfile.pdf", :value => Base64.encode64(File.read('myfile.pdf','r'))}
143
- # options = {
144
- # :tags => ['sent_from_api', 'user_id' => '12345'],
145
- # :expires_in => '5 days',
146
- # :action => "redirect",
147
- # 'callback_location' => "http://example.com/doc_callback",
148
- # 'use_text_tags' => false
149
- # }
150
- # RightSignature::send_document( "My Subject", recipients, document_data, options)
225
+ # recipients = [
226
+ # {:name => "RightSignature", :email => "support@rightsignature.com", :role => 'cc'},
227
+ # {:name => "John Bellingham", :email => "john@rightsignature.com", :role => 'signer'},
228
+ # {'is_sender' => true, :role => 'signer'},
229
+ # ]
230
+ # document_data = {:type => 'base64', :filename => "originalfile.pdf", :value => Base64.encode64(File.read('myfile.pdf','r'))}
231
+ # options = {
232
+ # :tags => ['sent_from_api', 'user_id' => '12345'],
233
+ # :expires_in => '5 days',
234
+ # :action => "redirect",
235
+ # 'callback_location' => "http://example.com/doc_callback",
236
+ # 'use_text_tags' => false
237
+ # }
238
+ # @rs_connection.send_document( "My Subject", recipients, document_data, options)
151
239
  #
152
240
  def send_document(subject, recipients, document_data, options={})
153
241
  document_hash = {:document => {
@@ -166,41 +254,41 @@ module RightSignature
166
254
  end
167
255
 
168
256
  # Prefills a document from a base64 encoded file or publicly available URL and returns a url that allows someone to send as the API User
169
- # * document_data: hash of document source :type ('base64' or 'url'), :filename to be used, :value of source (url or base64 encoded binary)
170
- # * subject: subject of the document that'll appear in email
171
- # * recipients: Recipients of the document, should be an array of hashes with :name, :email, and :role ('cc' or 'signer').
172
- # An optional :is_sender (true/false) is used to referrence the API User and won't need to supply :name and :email
173
- # Ex. CC to support@rightsignature.com, with sender and john@rightsignature.com as a signer
257
+ # * <b>document_data</b>: hash of document source :type ('base64' or 'url'), :filename to be used, :value of source (url or base64 encoded binary)
258
+ # * <b>subject</b>: subject of the document that'll appear in email
259
+ # * <b>recipients</b>: Recipients of the document, should be an array of hashes with :name, :email, and :role ('cc' or 'signer').
260
+ # One of the recipients requires <b>:is_sender</b> (true/false) to reference the API User and won't need to supply :name and :email
261
+ # Ex. CC to support@rightsignature.com, with sender and john@rightsignature.com as a signer
174
262
  # [
175
263
  # {:name => "RightSignature", :email => "support@rightsignature.com", :role => 'cc'},
176
264
  # {:name => "John Bellingham", :email => "john@rightsignature.com", :role => 'signer'},
177
265
  # {'is_sender' => true, :role => 'signer'},
178
266
  # ]
179
- # * options: other optional values
180
- # - description: document description that'll appear in the email
181
- # - action: 'send' or 'redirect'. Redirect will return a token that will allow another person to send the document under API user's account
182
- # - expires_in: number of days before expiring the document. API only allows 2,5,15, or 30.
183
- # - tags: document tags, an array of string or hashes 'single_tag' (for simple tag) or {'tag_name' => 'tag_value'} (for tuples pairs)
184
- # Ex. ['sent_from_api', {"user_id" => "32"}]
185
- # - callback_url: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
186
- # Ex. "http://yoursite/callback"
187
- # - use_text_tags: Document has special Text Tags that RightSignature parse. true or false.
188
- # More info: https://rightsignature.com/apidocs/text_tags
267
+ # * <b>options</b>: other optional values
268
+ # - <b>description</b>: document description that'll appear in the email
269
+ # - <b>action</b>: 'send' or 'redirect'. Redirect will return a token that will allow another person to send the document under API user's account
270
+ # - <b>expires_in</b>: number of days before expiring the document. API only allows 2,5,15, or 30.
271
+ # - <b>tags</b>: document tags, an array of string or hashes 'single_tag' (for simple tag) or {'tag_name' => 'tag_value'} (for tuples pairs)
272
+ # Ex. ['sent_from_api', {"user_id" => "32"}]
273
+ # - <b>callback_url</b>: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
274
+ # Ex. "http://yoursite/callback"
275
+ # - <b>use_text_tags</b>: Document has special Text Tags that RightSignature parse. true or false.
276
+ # More info: https://rightsignature.com/apidocs/text_tags
189
277
  # Ex.
190
- # recipients = [
191
- # {:name => "RightSignature", :email => "support@rightsignature.com", :role => 'cc'},
192
- # {:name => "John Bellingham", :email => "john@rightsignature.com", :role => 'signer'},
193
- # {'is_sender' => true, :role => 'signer'},
194
- # ]
195
- # document_data = {:type => 'base64', :filename => "originalfile.pdf", :value => Base64.encode64(File.read('myfile.pdf','r'))}
196
- # options = {
197
- # :tags => ['sent_from_api', 'user_id' => '12345'],
198
- # :expires_in => '5 days',
199
- # :action => "redirect",
200
- # 'callback_location' => "http://example.com/doc_callback",
201
- # 'use_text_tags' => false
202
- # }
203
- # RightSignature::generate_document_redirect_url( "My Subject", recipients, document_data, options)
278
+ # recipients = [
279
+ # {:name => "RightSignature", :email => "support@rightsignature.com", :role => 'cc'},
280
+ # {:name => "John Bellingham", :email => "john@rightsignature.com", :role => 'signer'},
281
+ # {'is_sender' => true, :role => 'signer'},
282
+ # ]
283
+ # document_data = {:type => 'base64', :filename => "originalfile.pdf", :value => Base64.encode64(File.read('myfile.pdf','r'))}
284
+ # options = {
285
+ # :tags => ['sent_from_api', 'user_id' => '12345'],
286
+ # :expires_in => '5 days',
287
+ # :action => "redirect",
288
+ # 'callback_location' => "http://example.com/doc_callback",
289
+ # 'use_text_tags' => false
290
+ # }
291
+ # @rs_connection.generate_document_redirect_url( "My Subject", recipients, document_data, options)
204
292
  #
205
293
  def generate_document_redirect_url(subject, recipients, document_data, options={})
206
294
  options[:action] = "redirect"
@@ -209,6 +297,13 @@ module RightSignature
209
297
  "#{site}/builder/new?rt=#{response['document']['redirect_token']}"
210
298
  end
211
299
 
300
+ # Generates signer links for a Document with signers with email of "noemail@rightsignautre.com"
301
+ # * <b>guid</b>: Document GUID
302
+ # * <b>redirect_location</b>: (Optional) URL to redirect each signer after it is completed
303
+ #
304
+ # Ex. Generate signer links for document GUID123 that redirects users to http://mysite/done_signing after signing
305
+ # @rs_connection.get_document_signer_links_for("GUID123", "http://mysite/done_signing")
306
+ #
212
307
  def get_document_signer_links_for(guid, redirect_location = nil)
213
308
  params = {}
214
309
  params[:redirect_location] = URI.encode(redirect_location) if redirect_location
@@ -8,10 +8,12 @@ module RightSignature
8
8
  super((message || @response.message))
9
9
  end
10
10
 
11
+ # returns HTTP Code from response
11
12
  def code
12
13
  @response.code
13
14
  end
14
15
 
16
+ # Suggestions on how to resolve a certain error
15
17
  def common_solutions
16
18
  if @response.code.to_i == 406
17
19
  "Check the Content-Type and makes sure it's the correct type (usually application/json or application/xml), ensure url has .xml or .json at the end, check 'Accept' header to allow xml or json ('*/*' for anything)"
@@ -23,6 +25,8 @@ module RightSignature
23
25
  end
24
26
  end
25
27
 
26
- class TokenResponseError < Exception; end
27
- class OAuthResponseError < Exception; end
28
+ class TokenResponseError < ResponseError # :nodoc:
29
+ end
30
+ class OAuthResponseError < ResponseError # :nodoc:
31
+ end
28
32
  end
@@ -1,6 +1,6 @@
1
- module RightSignature::Helpers
2
- module TagsHelper
3
- class <<self
1
+ module RightSignature::Helpers #:nodoc:
2
+ module TagsHelper #:nodoc:
3
+ class <<self #:nodoc:
4
4
  def mixed_array_to_string_array(array_of_tags)
5
5
  return array_of_tags unless array_of_tags.is_a?(Array)
6
6
 
@@ -32,8 +32,8 @@ module RightSignature::Helpers
32
32
  end
33
33
  end
34
34
 
35
- module RolesHelper
36
- class <<self
35
+ module RolesHelper #:nodoc:
36
+ class <<self #:nodoc:
37
37
  # Converts [{"Role_ID" => {:name => "John", :email => "email@example.com"}}] to
38
38
  # [{:role => {:name => "John", :email => "email@example.com", "@role_id" => "Role_ID"} }]
39
39
  # Tries to guess if it's using Role ID or Role Name
@@ -56,8 +56,8 @@ module RightSignature::Helpers
56
56
  end
57
57
 
58
58
 
59
- module MergeFieldsHelper
60
- class <<self
59
+ module MergeFieldsHelper #:nodoc:
60
+ class <<self #:nodoc:
61
61
  # Converts [{"Role Name" => {:name => "John", :email => "email@example.com"}}] to
62
62
  # [{"role roles_name=\"Role Name\"" => {:role => {:name => "John", :email => "email@example.com"}} }]
63
63
  def array_to_xml_hash(merge_fields_array, use_id=false)
@@ -77,6 +77,7 @@ module RightSignature::Helpers
77
77
  end
78
78
  end
79
79
 
80
+ #:nodoc:
80
81
  def array_to_acceptable_names_hash(acceptable_names)
81
82
  converted_fields = []
82
83
  acceptable_names.each do |name|
@@ -1,51 +1,64 @@
1
1
  module RightSignature
2
2
  module Template
3
3
  include RightSignature::Helpers
4
- # List Templates and passes in optional options.
5
- # Options:
6
- # * page: page number
7
- # * per_page: number of templates to return per page.
8
- # API only supports 10, 20, 30, 40, or 50. Default is 10.
9
- # * tags: filter templates by given tags. Array of strings, for name/value tags colon (:) should separate name and value.
10
- # Ex. "single_tag,tag_key:tag_value" would find templates with 'single_tag' and the name/value of 'tag_key' with value 'tag_value'.
11
- # * search: term to search for in templates.
4
+ # List Templates with optional filters
5
+ # * <b>Options</b>: (optional) Hash of filters to use
6
+ # * <b>page</b>: page number
7
+ # * <b>per_page</b>: number of templates to return per page.
8
+ # API only supports 10, 20, 30, 40, or 50. Default is 10.
9
+ # * <b>tags</b>: filter templates by given tags. Array of strings, for name/value tags colon (:) should separate name and value.
10
+ # Ex. "single_tag,tag_key:tag_value" would find templates with 'single_tag' and the name/value of 'tag_key' with value 'tag_value'.
11
+ # * <b>search</b>: term to search for in templates.
12
+ #
13
+ # Ex.
14
+ # options = {
15
+ # :state => ['completed', 'trashed'],
16
+ # :page => 1,
17
+ # :per_page => 20,
18
+ # :search => "me",
19
+ # :tags => ["single_tag", "key" => "with_value"]
20
+ # }
21
+ # @rs_connection.templates_list(options)
12
22
  def templates_list(options={})
13
23
  options[:tags] = TagsHelper.mixed_array_to_string_array(options[:tags]) if options[:tags]
14
24
  get "/api/templates.xml", options
15
25
  end
16
26
 
27
+ # Gets template details
28
+ # * <b>guid</b>: templates guid. Ex. a_1_zcfdidf8fi23
17
29
  def template_details(guid)
18
30
  get "/api/templates/#{guid}.xml", {}
19
31
  end
20
32
 
21
- # Clones a template so it can be used for sending. Always first step in sending a template.
33
+ # Clones a template so it can be used for sending. Always first step in sending a template.
34
+ # * <b>guid</b>: templates guid. Ex. a_1_zcfdidf8fi23
22
35
  def prepackage(guid)
23
36
  post "/api/templates/#{guid}/prepackage.xml", {}
24
37
  end
25
38
 
26
- # Prefills template.
27
- # * guid: templates guid. Ex. a_1_zcfdidf8fi23
28
- # * subject: subject of the document that'll appear in email
29
- # * roles: Recipients of the document, should be an array of role names and emails in a hash with keys as role_names.
39
+ # Prefills template. Should use a <b>prepackaged</b> template first.
40
+ # * <b>guid</b>: templates guid. Ex. a_1_zcfdidf8fi23
41
+ # * <b>subject</b>: subject of the document that'll appear in email
42
+ # * <b>roles</b>: Recipients of the document, should be an array of role names and emails in a hash with keys as role_names.
30
43
  # Ex. [{"Employee" => {:name => "John Employee", :email => "john@employee.com"}}]
31
44
  # is equivalent to
32
45
  # <role role_name="Employee">
33
46
  # <name>John Employee</name>
34
47
  # <email>john@employee.com</email>
35
48
  # </role>
36
- # * options: other optional values
37
- # - description: document description that'll appear in the email
38
- # - merge_fields: document merge fields, should be an array of merge_field_values in a hash with the merge_field_name.
39
- # Ex. [{"Salary" => "$1,000,000"}]
40
- # is equivalent to
41
- # <merge_field merge_field_name="Salary">
42
- # <value>$1,000,000</value>
43
- # </merge_field>
44
- # - expires_in: number of days before expiring the document. API only allows 2,5,15, or 30.
45
- # - tags: document tags, an array of string or hashes 'single_tag' (for simple tag) or {'tag_name' => 'tag_value'} (for tuples pairs)
46
- # Ex. ['sent_from_api', {"user_id" => "32"}]
47
- # - callback_url: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
48
- # Ex. "http://yoursite/callback"
49
+ # * <b>options</b>: other optional values
50
+ # * <b>description</b>: document description that'll appear in the email
51
+ # * <b>merge_fields</b>: document merge fields, should be an array of merge_field_values in a hash with the merge_field_name.
52
+ # Ex. [{"Salary" => "$1,000,000"}]
53
+ # is equivalent to
54
+ # <merge_field merge_field_name="Salary">
55
+ # <value>$1,000,000</value>
56
+ # </merge_field>
57
+ # * <b>expires_in</b>: number of days before expiring the document. API only allows 2,5,15, or 30.
58
+ # * <b>tags</b>: document tags, an array of string or hashes 'single_tag' (for simple tag) or {'tag_name' => 'tag_value'} (for tuples pairs)
59
+ # Ex. ['sent_from_api', {"user_id" => "32"}]
60
+ # * <b>callback_url</b>: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
61
+ # Ex. "http://yoursite/callback"
49
62
  #
50
63
  # Ex. call with all options used
51
64
  # RightSignature::Template.prefill(
@@ -87,38 +100,80 @@ module RightSignature
87
100
  post "/api/templates.xml", xml_hash
88
101
  end
89
102
 
103
+ # Prepackages and sends template.
104
+ # * <b>guid</b>: templates guid. Ex. a_1_zcfdidf8fi23
105
+ # * <b>roles</b>: Recipients of the document, should be an array of role names and emails in a hash with keys as role_names.
106
+ # Ex. [{"Employee" => {:name => "John Employee", :email => "john@employee.com"}}]
107
+ # is equivalent to
108
+ # <role role_name="Employee">
109
+ # <name>John Employee</name>
110
+ # <email>john@employee.com</email>
111
+ # </role>
112
+ # * <b>options</b>: other optional values
113
+ # * <b>subject</b>: subject of the document that'll appear in email. Defaults to template's subject
114
+ # * <b>description</b>: document description that'll appear in the email
115
+ # * <b>merge_fields</b>: document merge fields, should be an array of merge_field_values in a hash with the merge_field_name.
116
+ # Ex. [{"Salary" => "$1,000,000"}]
117
+ # is equivalent to
118
+ # <merge_field merge_field_name="Salary">
119
+ # <value>$1,000,000</value>
120
+ # </merge_field>
121
+ # * <b>expires_in</b>: number of days before expiring the document. API only allows 2,5,15, or 30.
122
+ # * <b>tags</b>: document tags, an array of {:name => 'tag_name'} (for simple tag) or {:name => 'tag_name', :value => 'value'} (for tuples pairs)
123
+ # Ex. [{:name => 'sent_from_api'}, {:name => "user_id", :value => "32"}]
124
+ # * <b>callback_url</b>: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
125
+ # Ex. "http://yoursite/callback"
126
+ #
127
+ # Ex. call with all options used
128
+ # RightSignature::Template.prepackage_and_send(
129
+ # "a_1_zcfdidf8fi23",
130
+ # "Your Employee Handbook",
131
+ # [{"employee" => {:name => "John Employee", :email => "john@employee.com"}}],
132
+ # {
133
+ # :description => "Please read over the handbook and sign it.",
134
+ # :merge_fields => [
135
+ # { "Department" => "Fun and games" },
136
+ # { "Salary" => "$1,000,000" }
137
+ # ],
138
+ # :expires_in => 5,
139
+ # :tags => [
140
+ # {:name => 'sent_from_api'},
141
+ # {:name => 'user_id', :value => '32'}
142
+ # ],
143
+ # :callback_url => "http://yoursite/callback"
144
+ # })
90
145
  def prepackage_and_send(guid, roles, options={})
91
146
  response = prepackage(guid)
92
147
  new_guid = response["template"]["guid"]
93
148
  send_template(new_guid, options.delete(:subject) || response["template"]["subject"], roles, options)
94
149
  end
95
150
 
96
- # Sends template.
97
- # * guid: templates guid. Ex. a_1_zcfdidf8fi23
98
- # * subject: subject of the document that'll appear in email
99
- # * roles: Recipients of the document, should be an array of role names and emails in a hash with keys as role_names.
151
+ # Sends template. Should use a <b>prepackaged</b> template first. Easier to use <b>prepackage_and_send</b> for most cases.
152
+ # * <b>guid</b>: templates guid. Ex. a_1_zcfdidf8fi23
153
+ # * <b>subject</b>: subject of the document that'll appear in email
154
+ # * <b>roles</b>: Recipients of the document, should be an array of role names and emails in a hash with keys as role_names.
100
155
  # Ex. [{"Employee" => {:name => "John Employee", :email => "john@employee.com"}}]
101
156
  # is equivalent to
102
157
  # <role role_name="Employee">
103
158
  # <name>John Employee</name>
104
159
  # <email>john@employee.com</email>
105
160
  # </role>
106
- # * options: other optional values
107
- # - description: document description that'll appear in the email
108
- # - merge_fields: document merge fields, should be an array of merge_field_values in a hash with the merge_field_name.
109
- # Ex. [{"Salary" => "$1,000,000"}]
110
- # is equivalent to
111
- # <merge_field merge_field_name="Salary">
112
- # <value>$1,000,000</value>
113
- # </merge_field>
114
- # - expires_in: number of days before expiring the document. API only allows 2,5,15, or 30.
115
- # - tags: document tags, an array of {:name => 'tag_name'} (for simple tag) or {:name => 'tag_name', :value => 'value'} (for tuples pairs)
116
- # Ex. [{:name => 'sent_from_api'}, {:name => "user_id", :value => "32"}]
117
- # - callback_url: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
118
- # Ex. "http://yoursite/callback"
161
+ # * <b>options</b>: other optional values
162
+ # * <b>description</b>: document description that'll appear in the email
163
+ # * <b>merge_fields</b>: document merge fields, should be an array of merge_field_values in a hash with the merge_field_name.
164
+ # Ex. [{"Salary" => "$1,000,000"}]
165
+ # is equivalent to
166
+ # <merge_field merge_field_name="Salary">
167
+ # <value>$1,000,000</value>
168
+ # </merge_field>
169
+ # * <b>expires_in</b>: number of days before expiring the document. API only allows 2,5,15, or 30.
170
+ # * <b>tags</b>: document tags, an array of {:name => 'tag_name'} (for simple tag) or {:name => 'tag_name', :value => 'value'} (for tuples pairs)
171
+ # Ex. [{:name => 'sent_from_api'}, {:name => "user_id", :value => "32"}]
172
+ # * <b>callback_url</b>: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
173
+ # Ex. "http://yoursite/callback"
119
174
  #
120
175
  # Ex. call with all options used
121
- # RightSignature::Template.prefill(
176
+ # RightSignature::Template.send_template(
122
177
  # "a_1_zcfdidf8fi23",
123
178
  # "Your Employee Handbook",
124
179
  # [{"employee" => {:name => "John Employee", :email => "john@employee.com"}}],
@@ -140,17 +195,17 @@ module RightSignature
140
195
  end
141
196
 
142
197
  # Creates a URL that give person ability to create a template in your account.
143
- # * options: optional options for redirected person
144
- # - callback_location: URI encoded URL that specifies the location we will POST a callback notification to when the template has been created.
145
- # - redirect_location: A URI encoded URL that specifies the location we will redirect the user to, after they have created a template.
146
- # - tags: tags to add to the template. an array of 'tag_name' (for simple tag) or {'tag_name' => 'value'} (for tuples pairs)
147
- # Ex. ['created_from_api', {"user_id" => "123"}]
148
- # - acceptable_role_names: The user creating the Template will be forced to select one of the values provided.
149
- # There will be no free-form name entry when adding roles to the Template. An array of strings.
150
- # Ex. ["Employee", "Employeer"]
151
- # - acceptable_merge_field_names: The user creating the Template will be forced to select one of the values provided.
152
- # There will be no free-form name entry when adding merge fields to the Template.
153
- # Ex. ["Location", "Tax ID", "Company Name"]
198
+ # * <b>options</b>: optional options for redirected person
199
+ # * <b>callback_location</b>: URI encoded URL that specifies the location we will POST a callback notification to when the template has been created.
200
+ # * <b>redirect_location</b>: A URI encoded URL that specifies the location we will redirect the user to, after they have created a template.
201
+ # * <b>tags</b>: tags to add to the template. an array of 'tag_name' (for simple tag) or {'tag_name' => 'value'} (for tuples pairs)
202
+ # Ex. ['created_from_api', {"user_id" => "123"}]
203
+ # * <b>acceptable_role_names</b>: The user creating the Template will be forced to select one of the values provided.
204
+ # There will be no free-form name entry when adding roles to the Template. An array of strings.
205
+ # Ex. ["Employee", "Employeer"]
206
+ # * <b>acceptable_merge_field_names</b>: The user creating the Template will be forced to select one of the values provided.
207
+ # There will be no free-form name entry when adding merge fields to the Template.
208
+ # Ex. ["Location", "Tax ID", "Company Name"]
154
209
  def generate_build_url(options={})
155
210
  xml_hash = {:template => {}}
156
211
  xml_hash[:template][:tags] = TagsHelper.array_to_xml_hash(options[:tags]) if options[:tags]
@@ -171,30 +226,30 @@ module RightSignature
171
226
  end
172
227
 
173
228
  # Sends template with all roles as embedded signers and returns an array of hashes with :name and :url for each signer link.
174
- # * guid: templates guid. Ex. a_1_zcfdidf8fi23
175
- # * roles: Recipients of the document, should be an array of role names in a hash with keys as role_names.
229
+ # * <b>guid</b>: templates guid. Ex. a_1_zcfdidf8fi23
230
+ # * <b>roles</b>: Recipients of the document, should be an array of role names in a hash with keys as role_names.
176
231
  # Ex. [{"Employee" => {:name => "John Employee"}]
177
232
  # is equivalent to
178
233
  # <role role_name="Employee">
179
234
  # <name>John Employee</name>
180
235
  # <email>noemail@rightsignature.com</email>
181
236
  # </role>
182
- # * options: other optional values
183
- # - subject: subject of the document that'll appear in email. Defaults to Template's subject
184
- # - description: document description that'll appear in the email
185
- # - merge_fields: document merge fields, should be an array of merge_field_values in a hash with the merge_field_name.
186
- # Ex. [{"Salary" => "$1,000,000"}]
187
- # is equivalent to
188
- # <merge_field merge_field_name="Salary">
189
- # <value>$1,000,000</value>
190
- # </merge_field>
191
- # - expires_in: number of days before expiring the document. API only allows 2,5,15, or 30.
192
- # - tags: document tags, an array of {:name => 'tag_name'} (for simple tag) or {:name => 'tag_name', :value => 'value'} (for tuples pairs)
193
- # Ex. [{:name => 'sent_from_api'}, {:name => "user_id", :value => "32"}]
194
- # - callback_url: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
195
- # Ex. "http://yoursite/callback"
196
- # - redirect_location: A URI encoded URL that specifies the location for the signing widget to redirect the user to after it is signed.
197
- # Ex. "http://yoursite/thanks_for_signing"
237
+ # * <b>options</b>: other optional values
238
+ # * <b>subject</b>: subject of the document that'll appear in email. Defaults to Template's subject
239
+ # * <b>description</b>: document description that'll appear in the email
240
+ # * <b>merge_fields</b>: document merge fields, should be an array of merge_field_values in a hash with the merge_field_name.
241
+ # Ex. [{"Salary" => "$1,000,000"}]
242
+ # is equivalent to
243
+ # <merge_field merge_field_name="Salary">
244
+ # <value>$1,000,000</value>
245
+ # </merge_field>
246
+ # * <b>expires_in</b>: number of days before expiring the document. API only allows 2,5,15, or 30.
247
+ # * <b>tags</b>: document tags, an array of {:name => 'tag_name'} (for simple tag) or {:name => 'tag_name', :value => 'value'} (for tuples pairs)
248
+ # Ex. [{:name => 'sent_from_api'}, {:name => "user_id", :value => "32"}]
249
+ # * <b>callback_url</b>: A URI encoded URL that specifies the location for API to POST a callback notification to when the document has been created and signed.
250
+ # Ex. "http://yoursite/callback"
251
+ # * <b>redirect_location</b>: A URI encoded URL that specifies the location for the signing widget to redirect the user to after it is signed.
252
+ # Ex. "http://yoursite/thanks_for_signing"
198
253
  #
199
254
  # Ex. call with all options used
200
255
  # RightSignature::Template.prefill(
@@ -1,3 +1,3 @@
1
1
  module RightSignature
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -8,20 +8,20 @@ describe RightSignature::TokenConnection do
8
8
 
9
9
  it "should create 'api-token' in headers with :api_token credentials, accept of '*/*', and content-type of xml with given method" do
10
10
  token_connection = RightSignature::TokenConnection.new('APITOKEN')
11
- token_connection.should_receive(:get).with("path", {:query => {:search => 'hey there'}, :headers => {"api-token" => "APITOKEN", "Accept" => "*/*", "content-type" => "application/xml"}}).and_return(stub("HTTPartyResponse", :parsed_response => nil))
11
+ token_connection.class.should_receive(:get).with("path", {:query => {:search => 'hey there'}, :headers => {"api-token" => "APITOKEN", "Accept" => "*/*", "content-type" => "application/xml"}}).and_return(stub("HTTPartyResponse", :parsed_response => nil))
12
12
  token_connection.request(:get, "path", {:query => {:search => 'hey there'}})
13
13
  end
14
14
 
15
15
  it "should add 'api-token' to headers with :api_token credentials, accept of '*/*', and content-type of xml with given method" do
16
16
  token_connection = RightSignature::TokenConnection.new('APITOKEN')
17
- token_connection.should_receive(:get).with("path", {:query => {:search => 'hey there'}, :headers => {"api-token" => "APITOKEN", "Accept" => "*/*", "content-type" => "application/xml", :my_header => "someHeader"}}).and_return(stub("HTTPartyResponse", :parsed_response => nil))
17
+ token_connection.class.should_receive(:get).with("path", {:query => {:search => 'hey there'}, :headers => {"api-token" => "APITOKEN", "Accept" => "*/*", "content-type" => "application/xml", :my_header => "someHeader"}}).and_return(stub("HTTPartyResponse", :parsed_response => nil))
18
18
  token_connection.request(:get, "path", {:query => {:search => 'hey there'}, :headers => {:my_header => "someHeader"}})
19
19
  end
20
20
 
21
21
  it "should create 'api-token' in headers with :api_token credentials, accept of '*/*', and content-type of xml to POST method" do
22
22
  token_connection = RightSignature::TokenConnection.new('APITOKEN')
23
- token_connection.should_receive(:post).with("path", {:body => {:document => {:roles => []}}, :headers => {"api-token" => "APITOKEN", "Accept" => "*/*", "content-type" => "application/xml"}}).and_return(stub("HTTPartyResponse", :parsed_response => nil))
23
+ token_connection.class.should_receive(:post).with("path", {:body => {:document => {:roles => []}}, :headers => {"api-token" => "APITOKEN", "Accept" => "*/*", "content-type" => "application/xml"}}).and_return(stub("HTTPartyResponse", :parsed_response => nil))
24
24
  token_connection.request(:post, "path", {:body => {:document => {:roles => []}}})
25
25
  end
26
26
 
27
- end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rightsignature
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-10-12 00:00:00.000000000 Z
14
+ date: 2012-10-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
18
- requirement: !ruby/object:Gem::Requirement
18
+ requirement: &70183818100960 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,15 +23,10 @@ dependencies:
23
23
  version: 1.0.0
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
- requirements:
29
- - - ! '>='
30
- - !ruby/object:Gem::Version
31
- version: 1.0.0
26
+ version_requirements: *70183818100960
32
27
  - !ruby/object:Gem::Dependency
33
28
  name: rspec
34
- requirement: !ruby/object:Gem::Requirement
29
+ requirement: &70183818100180 !ruby/object:Gem::Requirement
35
30
  none: false
36
31
  requirements:
37
32
  - - ! '>='
@@ -39,15 +34,10 @@ dependencies:
39
34
  version: 2.11.0
40
35
  type: :development
41
36
  prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
- requirements:
45
- - - ! '>='
46
- - !ruby/object:Gem::Version
47
- version: 2.11.0
37
+ version_requirements: *70183818100180
48
38
  - !ruby/object:Gem::Dependency
49
39
  name: bundler
50
- requirement: !ruby/object:Gem::Requirement
40
+ requirement: &70183818099240 !ruby/object:Gem::Requirement
51
41
  none: false
52
42
  requirements:
53
43
  - - ! '>='
@@ -55,15 +45,10 @@ dependencies:
55
45
  version: 1.0.0
56
46
  type: :runtime
57
47
  prerelease: false
58
- version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
- requirements:
61
- - - ! '>='
62
- - !ruby/object:Gem::Version
63
- version: 1.0.0
48
+ version_requirements: *70183818099240
64
49
  - !ruby/object:Gem::Dependency
65
50
  name: oauth
66
- requirement: !ruby/object:Gem::Requirement
51
+ requirement: &70183818097840 !ruby/object:Gem::Requirement
67
52
  none: false
68
53
  requirements:
69
54
  - - ! '>='
@@ -71,15 +56,10 @@ dependencies:
71
56
  version: 0.4.0
72
57
  type: :runtime
73
58
  prerelease: false
74
- version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
- requirements:
77
- - - ! '>='
78
- - !ruby/object:Gem::Version
79
- version: 0.4.0
59
+ version_requirements: *70183818097840
80
60
  - !ruby/object:Gem::Dependency
81
61
  name: httparty
82
- requirement: !ruby/object:Gem::Requirement
62
+ requirement: &70183818096560 !ruby/object:Gem::Requirement
83
63
  none: false
84
64
  requirements:
85
65
  - - ! '>='
@@ -87,15 +67,10 @@ dependencies:
87
67
  version: 0.9.0
88
68
  type: :runtime
89
69
  prerelease: false
90
- version_requirements: !ruby/object:Gem::Requirement
91
- none: false
92
- requirements:
93
- - - ! '>='
94
- - !ruby/object:Gem::Version
95
- version: 0.9.0
70
+ version_requirements: *70183818096560
96
71
  - !ruby/object:Gem::Dependency
97
72
  name: xml-fu
98
- requirement: !ruby/object:Gem::Requirement
73
+ requirement: &70183818094620 !ruby/object:Gem::Requirement
99
74
  none: false
100
75
  requirements:
101
76
  - - ! '>='
@@ -103,12 +78,7 @@ dependencies:
103
78
  version: 0.1.7
104
79
  type: :runtime
105
80
  prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- none: false
108
- requirements:
109
- - - ! '>='
110
- - !ruby/object:Gem::Version
111
- version: 0.1.7
81
+ version_requirements: *70183818094620
112
82
  description: Provides a wrapper for the RightSignature API.
113
83
  email:
114
84
  - dev@rightsignature.com
@@ -119,6 +89,7 @@ files:
119
89
  - .gitignore
120
90
  - Gemfile
121
91
  - README.md
92
+ - Rakefile
122
93
  - lib/rightsignature.rb
123
94
  - lib/rightsignature/account.rb
124
95
  - lib/rightsignature/connection.rb
@@ -160,9 +131,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
131
  version: '0'
161
132
  requirements: []
162
133
  rubyforge_project:
163
- rubygems_version: 1.8.24
134
+ rubygems_version: 1.8.11
164
135
  signing_key:
165
136
  specification_version: 3
166
137
  summary: API wrapper for RightSignature
167
138
  test_files: []
168
- has_rdoc: