hellosign-ruby-sdk 3.0.3 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. data/README.md +1 -2
  2. data/Rakefile +2 -2
  3. data/hellosign-ruby-sdk.gemspec +8 -8
  4. data/lib/hello_sign.rb +1 -1
  5. data/lib/hello_sign/api/account.rb +7 -10
  6. data/lib/hello_sign/api/embedded.rb +1 -1
  7. data/lib/hello_sign/api/oauth.rb +7 -9
  8. data/lib/hello_sign/api/signature_request.rb +10 -10
  9. data/lib/hello_sign/api/team.rb +10 -10
  10. data/lib/hello_sign/api/template.rb +6 -7
  11. data/lib/hello_sign/api/unclaimed_draft.rb +2 -4
  12. data/lib/hello_sign/client.rb +11 -11
  13. data/lib/hello_sign/configuration.rb +1 -2
  14. data/lib/hello_sign/resource/base_resource.rb +1 -3
  15. data/lib/hello_sign/resource/resource_array.rb +2 -3
  16. data/lib/hello_sign/resource/template.rb +0 -1
  17. data/lib/hello_sign/version.rb +1 -1
  18. data/spec/fixtures/account.json +15 -1
  19. data/spec/fixtures/error.json +5 -5
  20. data/spec/fixtures/signature_request.json +38 -2
  21. data/spec/fixtures/signature_requests.json +43 -13
  22. data/spec/fixtures/team.json +14 -18
  23. data/spec/fixtures/template.json +53 -1
  24. data/spec/fixtures/templates.json +58 -10
  25. data/spec/fixtures/token.json +13 -13
  26. data/spec/fixtures/unclaimed_draft.json +5 -5
  27. data/spec/hello_sign/api/account_spec.rb +13 -15
  28. data/spec/hello_sign/api/embedded_spec.rb +4 -4
  29. data/spec/hello_sign/api/oauth_spec.rb +9 -10
  30. data/spec/hello_sign/api/signature_request_spec.rb +43 -44
  31. data/spec/hello_sign/api/team_spec.rb +37 -39
  32. data/spec/hello_sign/api/template_spec.rb +21 -21
  33. data/spec/hello_sign/api/unclaimed_draft_spec.rb +13 -13
  34. data/spec/hello_sign/client_spec.rb +50 -51
  35. data/spec/hello_sign/resource/base_resource_spec.rb +18 -16
  36. data/spec/hello_sign_spec.rb +7 -7
  37. data/spec/spec_helper.rb +0 -1
  38. metadata +3 -3
data/README.md CHANGED
@@ -13,11 +13,10 @@ And then execute:
13
13
 
14
14
  $ bundle
15
15
 
16
-
17
16
  ## Configuration
18
17
 
19
18
  Create a config block. At a minimum you'll want to set your [API Key](https://www.hellosign.com/home/myAccount/current_tab/integrations#api) but depending on your usage you'll possibly
20
- want to set your app's [Client ID](https://www.hellosign.com/oauth/createAppForm) and [Client Secret](https://www.hellosign.com/oauth/createAppForma). In Rails you can place it in `config/initializers/hello_sign.rb`
19
+ want to set your app's [Client ID](https://www.hellosign.com/oauth/createAppForm) and [Client Secret](https://www.hellosign.com/oauth/createAppForm). In Rails you can place it in `config/initializers/hello_sign.rb`
21
20
 
22
21
  ```ruby
23
22
  require 'hello_sign'
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new
5
5
 
@@ -4,19 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'hello_sign/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "hellosign-ruby-sdk"
7
+ spec.name = 'hellosign-ruby-sdk'
8
8
  spec.version = HelloSign::VERSION
9
- spec.authors = "HelloSign"
10
- spec.email = "support@hellosign.com"
11
- spec.summary = "A Ruby SDK for the HelloSign API."
12
- spec.description = ""
13
- spec.homepage = "http://www.hellosign.com"
14
- spec.license = "MIT"
9
+ spec.authors = 'HelloSign'
10
+ spec.email = 'support@hellosign.com'
11
+ spec.summary = 'A Ruby SDK for the HelloSign API.'
12
+ spec.description = ''
13
+ spec.homepage = 'http://www.hellosign.com'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.5'
22
22
  spec.add_development_dependency 'rake'
data/lib/hello_sign.rb CHANGED
@@ -16,7 +16,6 @@ module HelloSign
16
16
  client.send(method, *args, &block)
17
17
  end
18
18
 
19
-
20
19
  #
21
20
  # If HelloSign module don't respond_to? method, ask HelloSign::Client whether it respond or not
22
21
  # @param method [Symbol] method name
@@ -26,6 +25,7 @@ module HelloSign
26
25
  end
27
26
 
28
27
  private
28
+
29
29
  def self.client
30
30
  HelloSign::Client.new
31
31
  end
@@ -1,7 +1,6 @@
1
1
  module HelloSign
2
2
  module Api
3
3
 
4
-
5
4
  #
6
5
  # Contains all the api calls for the Account resource.
7
6
  # Take a look at our {https://www.hellosign.com/api/reference#Account account api document}
@@ -20,7 +19,7 @@ module HelloSign
20
19
  # account = @client.get_account
21
20
  #
22
21
  def get_account
23
- HelloSign::Resource::Account.new get("/account")
22
+ HelloSign::Resource::Account.new get('/account')
24
23
  end
25
24
 
26
25
  #
@@ -37,11 +36,10 @@ module HelloSign
37
36
  # @example
38
37
  # account = @client.create_account :email_address => 'newuser@example.com', :password => 'securePW'
39
38
  #
40
- def create_account opts
41
- HelloSign::Resource::Account.new post("/account/create", :body => opts)
39
+ def create_account(opts)
40
+ HelloSign::Resource::Account.new post('/account/create', :body => opts)
42
41
  end
43
42
 
44
-
45
43
  #
46
44
  # Updates the current user's callback URL
47
45
  # @option opts [String] callback_url New user's callback url
@@ -51,11 +49,10 @@ module HelloSign
51
49
  # @example
52
50
  # account = @client.update_account :callback_url => 'https://www.example.com/callback'
53
51
  #
54
- def update_account opts
55
- HelloSign::Resource::Account.new post("/account", :body => opts)
52
+ def update_account(opts)
53
+ HelloSign::Resource::Account.new post('/account', :body => opts)
56
54
  end
57
55
 
58
-
59
56
  #
60
57
  # Check whether an account exists
61
58
  # @option opts [String] email_address user email
@@ -64,8 +61,8 @@ module HelloSign
64
61
  # @example
65
62
  # account = @client.verify :email_address => 'newuser@example.com'
66
63
  #
67
- def verify opts
68
- post("/account/verify", :body => opts).empty? ? false : true
64
+ def verify(opts)
65
+ post('/account/verify', :body => opts).empty? ? false : true
69
66
  end
70
67
  end
71
68
  end
@@ -19,7 +19,7 @@ module HelloSign
19
19
  # @example
20
20
  # embedded = @client.get_embedded_sign_url :signature_id => '50e3542f738adfa7ddd4cbd4c00d2a8ab6e4194b'
21
21
  #
22
- def get_embedded_sign_url opts
22
+ def get_embedded_sign_url(opts)
23
23
  HelloSign::Resource::Embedded.new get("/embedded/sign_url/#{opts[:signature_id]}")
24
24
  end
25
25
  end
@@ -17,7 +17,7 @@ module HelloSign
17
17
  # @param state [String] used for security and must match throughout the flow for a given user.
18
18
  # It can be set to the value of your choice (preferably something random). You should verify it matches the expected value when validating the OAuth callback.
19
19
  # @return [type] [description]
20
- def oauth_url state
20
+ def oauth_url(state)
21
21
  "#{self.oauth_end_point}/oauth/authorize?response_type=code&client_id=#{self.client_id}&state=#{state}"
22
22
  end
23
23
 
@@ -32,15 +32,13 @@ module HelloSign
32
32
  # @example
33
33
  # client = HelloSign::Client.new :api_key => '%apikey%', :client_id => 'cc91c61d00f8bb2ece1428035716b', :client_secret => '1d14434088507ffa390e6f5528465'
34
34
  # client.get_oauth_token :state => '900e06e2', :code =>'1b0d28d90c86c141'
35
- def get_oauth_token opts
35
+ def get_oauth_token(opts)
36
36
  opts[:client_id] = self.client_id
37
37
  opts[:client_secret] = self.client_secret
38
38
  opts[:grant_type] = 'authorization_code'
39
- post('/oauth/token', {:body => opts, :oauth_request => true})
40
-
39
+ post('/oauth/token', { :body => opts, :oauth_request => true })
41
40
  end
42
41
 
43
-
44
42
  #
45
43
  # refresh user oauth token.
46
44
  #
@@ -50,8 +48,8 @@ module HelloSign
50
48
  #
51
49
  # @example
52
50
  # client.refresh_oauth_token :refresh_token => 'hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3'
53
- def refresh_oauth_token refresh_token
54
- post('/oauth/token', {:body => {:grant_type => 'refresh_token', :refresh_token => refresh_token}, :oauth_request => true})
51
+ def refresh_oauth_token(refresh_token)
52
+ post('/oauth/token', { :body => { :grant_type => 'refresh_token', :refresh_token => refresh_token }, :oauth_request => true })
55
53
  end
56
54
 
57
55
 
@@ -61,11 +59,11 @@ module HelloSign
61
59
  # @option opts [String] password new user password
62
60
  #
63
61
  # @return [Hash] details about new user, including oath data
64
- def oauth_create_account opts
62
+ def oauth_create_account(opts)
65
63
  opts[:client_id] = self.client_id
66
64
  opts[:client_secret] = self.client_secret
67
65
 
68
- HelloSign::Resource::Account.new post('/account/create', {:body => opts})
66
+ HelloSign::Resource::Account.new post('/account/create', { :body => opts })
69
67
  end
70
68
  end
71
69
  end
@@ -19,7 +19,7 @@ module HelloSign
19
19
  # @example
20
20
  # signature_request = @client.get_signature_request :signature_request_id => 'fa5c8a0b0f492d768749333ad6fcc214c111e967'
21
21
  #
22
- def get_signature_request opts
22
+ def get_signature_request(opts)
23
23
  HelloSign::Resource::SignatureRequest.new get("/signature_request/#{opts[:signature_request_id]}")
24
24
  end
25
25
 
@@ -32,9 +32,9 @@ module HelloSign
32
32
  # @example
33
33
  # signature_requests = @client.get_signature_requests :page => 1
34
34
  #
35
- def get_signature_requests opts={}
35
+ def get_signature_requests(opts={})
36
36
  path = '/signature_request/list'
37
- path += opts[:page] ? "?page=#{opts[:page]}" : ""
37
+ path += opts[:page] ? "?page=#{opts[:page]}" : ''
38
38
  HelloSign::Resource::ResourceArray.new get(path, opts), 'signature_requests', HelloSign::Resource::SignatureRequest
39
39
  end
40
40
 
@@ -80,7 +80,7 @@ module HelloSign
80
80
  # )
81
81
  #
82
82
 
83
- def send_signature_request opts
83
+ def send_signature_request(opts)
84
84
  prepare_files opts
85
85
  prepare_signers opts
86
86
 
@@ -130,7 +130,7 @@ module HelloSign
130
130
  # }
131
131
  # )
132
132
  #
133
- def send_signature_request_with_template opts
133
+ def send_signature_request_with_template(opts)
134
134
  prepare_signers opts
135
135
  prepare_ccs opts
136
136
  HelloSign::Resource::SignatureRequest.new post('/signature_request/send_with_template', :body => opts)
@@ -145,7 +145,7 @@ module HelloSign
145
145
  # @example
146
146
  # signature_request = @client.remind_signature_request :signature_request_id => '75cdf7dc8b323d43b347e4a3614d1f822bd09491', :email_address => 'john@example.com'
147
147
  #
148
- def remind_signature_request opts
148
+ def remind_signature_request(opts)
149
149
  HelloSign::Resource::SignatureRequest.new post("/signature_request/remind/#{opts[:signature_request_id]}", :body => opts)
150
150
  end
151
151
 
@@ -155,7 +155,7 @@ module HelloSign
155
155
  #
156
156
  # @example
157
157
  # @client.cancel_signature_request :signature_request_id => '75cdf7dc8b323d43b347e4a3614d1f822bd09491'
158
- def cancel_signature_request opts
158
+ def cancel_signature_request(opts)
159
159
  post("/signature_request/cancel/#{opts[:signature_request_id]}", :body => opts)
160
160
  end
161
161
 
@@ -169,7 +169,7 @@ module HelloSign
169
169
  # @example
170
170
  # pdf = @client.signature_request_files :signature_request_id => '75cdf7dc8b323d43b347e4a3614d1f822bd09491'
171
171
  #
172
- def signature_request_files opts
172
+ def signature_request_files(opts)
173
173
  path = "/signature_request/files/#{opts[:signature_request_id]}"
174
174
  if opts[:file_type]
175
175
  path = path + "?file_type=#{opts[:file_type]}"
@@ -219,7 +219,7 @@ module HelloSign
219
219
  # :files => ['NDA.pdf', 'AppendixA.pdf']
220
220
  # )
221
221
  #
222
- def create_embedded_signature_request opts
222
+ def create_embedded_signature_request(opts)
223
223
  opts[:client_id] ||= self.client_id
224
224
  prepare_files opts
225
225
  prepare_signers opts
@@ -273,7 +273,7 @@ module HelloSign
273
273
  # }
274
274
  # )
275
275
  #
276
- def create_embedded_signature_request_with_template opts
276
+ def create_embedded_signature_request_with_template(opts)
277
277
  opts[:client_id] ||= self.client_id
278
278
  prepare_signers opts
279
279
  prepare_ccs opts
@@ -19,7 +19,7 @@ module HelloSign
19
19
  # @example
20
20
  # team = @client.get_team
21
21
  def get_team
22
- HelloSign::Resource::Team.new get("/team")
22
+ HelloSign::Resource::Team.new get('/team')
23
23
  end
24
24
 
25
25
  #
@@ -30,8 +30,8 @@ module HelloSign
30
30
  #
31
31
  # @example
32
32
  # team = @client.create_team :name => 'Team America World Police'
33
- def create_team opts
34
- HelloSign::Resource::Team.new post("/team/create", :body => opts)
33
+ def create_team(opts)
34
+ HelloSign::Resource::Team.new post('/team/create', :body => opts)
35
35
  end
36
36
 
37
37
  #
@@ -42,8 +42,8 @@ module HelloSign
42
42
  #
43
43
  # @example
44
44
  # team = @client.update_team :name => 'New Team Name'
45
- def update_team opts
46
- HelloSign::Resource::Team.new post("/team", :body => opts)
45
+ def update_team(opts)
46
+ HelloSign::Resource::Team.new post('/team', :body => opts)
47
47
  end
48
48
 
49
49
  #
@@ -52,7 +52,7 @@ module HelloSign
52
52
  # @example
53
53
  # team = @client.destroy_team
54
54
  def destroy_team
55
- post("/team/destroy")
55
+ post('/team/destroy')
56
56
  end
57
57
 
58
58
  #
@@ -67,8 +67,8 @@ module HelloSign
67
67
  #
68
68
  # @example
69
69
  # team = @client.add_member_to_team :email_address => 'george@example.com'
70
- def add_member_to_team opts
71
- HelloSign::Resource::Team.new post("/team/add_member", :body => opts)
70
+ def add_member_to_team(opts)
71
+ HelloSign::Resource::Team.new post('/team/add_member', :body => opts)
72
72
  end
73
73
 
74
74
 
@@ -80,8 +80,8 @@ module HelloSign
80
80
  # @return [HelloSign::Resource::Team] updated Team object
81
81
  # @example
82
82
  # team = @client.remove_member_from_team :email_address => 'george@example.com'
83
- def remove_member_from_team opts
84
- HelloSign::Resource::Team.new post("/team/remove_member", :body => opts)
83
+ def remove_member_from_team(opts)
84
+ HelloSign::Resource::Team.new post('/team/remove_member', :body => opts)
85
85
  end
86
86
  end
87
87
  end
@@ -19,7 +19,7 @@ module HelloSign
19
19
  # @example
20
20
  # template = @client.get_template :template_id => 'f57db65d3f933b5316d398057a36176831451a35'
21
21
  #
22
- def get_template opts
22
+ def get_template(opts)
23
23
  HelloSign::Resource::Template.new get("/template/#{opts[:template_id]}")
24
24
  end
25
25
 
@@ -32,13 +32,12 @@ module HelloSign
32
32
  # @example
33
33
  # templates = @client.get_templates :page => 1
34
34
  #
35
- def get_templates opts={}
35
+ def get_templates(opts={})
36
36
  path = '/template/list'
37
- path += opts[:page] ? "?page=#{opts[:page]}" : ""
38
- HelloSign::Resource::ResourceArray.new get(path, opts), "templates", HelloSign::Resource::Template
37
+ path += opts[:page] ? "?page=#{opts[:page]}" : ''
38
+ HelloSign::Resource::ResourceArray.new get(path, opts), 'templates', HelloSign::Resource::Template
39
39
  end
40
40
 
41
-
42
41
  #
43
42
  # Gives the specified Account on your team access to a Template
44
43
  #
@@ -50,7 +49,7 @@ module HelloSign
50
49
  # @example
51
50
  # templates = @client.add_user_to_template :template_id => 'f57db65d3f933b5316d398057a36176831451a35', :email_address => 'george@example.com'
52
51
  #
53
- def add_user_to_template opts
52
+ def add_user_to_template(opts)
54
53
  path = "/template/add_user/#{opts[:template_id]}"
55
54
  opts.delete(:template_id)
56
55
  HelloSign::Resource::Template.new post(path, :body => opts)
@@ -67,7 +66,7 @@ module HelloSign
67
66
  # @example
68
67
  # templates = @client.remove_user_from_template :template_id => 'f57db65d3f933b5316d398057a36176831451a35', :email_address => 'george@example.com'
69
68
  #
70
- def remove_user_from_template opts
69
+ def remove_user_from_template(opts)
71
70
  path = "/template/remove_user/#{opts[:template_id]}"
72
71
  opts.delete(:template_id)
73
72
  HelloSign::Resource::Template.new post(path, :body => opts)
@@ -69,7 +69,6 @@ module HelloSign
69
69
  HelloSign::Resource::UnclaimedDraft.new post('/unclaimed_draft/create', :body => opts)
70
70
  end
71
71
 
72
-
73
72
  #
74
73
  # Creates a new embedded unclaimed draft object that can be launched in an iframe using the claim URL.
75
74
  # @option opts [Integer] test_mode (0) Whether this is a test, the signature request will not be legally binding if set to 1.
@@ -90,7 +89,7 @@ module HelloSign
90
89
  # @option opts [Array<String>] cc_email_addresses The email addresses that should be CCed.
91
90
  #
92
91
  # @return [HelloSign::Resource::UnclaimedDraft] a UnclaimedDraft object
93
-
92
+ #
94
93
  # @example request_signature
95
94
  # unclaimed_draft = @client.create_embedded_unclaimed_draft(
96
95
  # :test_mode => 1,
@@ -112,7 +111,7 @@ module HelloSign
112
111
  # :files => ['NDA.pdf', 'AppendixA.pdf']
113
112
  # )
114
113
  #
115
- def create_embedded_unclaimed_draft opts
114
+ def create_embedded_unclaimed_draft(opts)
116
115
  opts[:client_id] ||= self.client_id
117
116
  prepare_files opts
118
117
  if opts[:type] == 'request_signature'
@@ -121,7 +120,6 @@ module HelloSign
121
120
 
122
121
  HelloSign::Resource::UnclaimedDraft.new post('/unclaimed_draft/create_embedded', :body => opts)
123
122
  end
124
-
125
123
  end
126
124
  end
127
125
  end
@@ -106,7 +106,7 @@ module HelloSign
106
106
  strip_options_whitespace(options)
107
107
  make_connection(options).send method do |request|
108
108
  if options[:oauth_request]
109
- request.url "#{path}", options[:params]
109
+ request.url path, options[:params]
110
110
  else
111
111
  request.url "#{api_version}#{path}", options[:params]
112
112
  end
@@ -122,11 +122,11 @@ module HelloSign
122
122
  logger.level = @log_level
123
123
  end
124
124
 
125
- connection = Faraday.new(:url => url, :headers => {user_agent: user_agent}) do |faraday|
126
- faraday.request :multipart
127
- faraday.request :url_encoded
125
+ connection = Faraday.new(:url => url, :headers => { user_agent: user_agent }) do |faraday|
126
+ faraday.request :multipart
127
+ faraday.request :url_encoded
128
128
  faraday.response :logger, logger if @logging
129
- faraday.adapter :net_http
129
+ faraday.adapter :net_http
130
130
  end
131
131
  if options[:no_auth]
132
132
  elsif auth_token
@@ -147,7 +147,7 @@ module HelloSign
147
147
  end
148
148
 
149
149
  def parse(response)
150
- if response["content-type"] == "application/pdf"
150
+ if response['content-type'] == 'application/pdf'
151
151
  response.body
152
152
  elsif response.body.strip.empty?
153
153
  {}
@@ -162,7 +162,7 @@ module HelloSign
162
162
  "Message: #{response.body}"
163
163
  end
164
164
 
165
- def prepare_files opts
165
+ def prepare_files(opts)
166
166
  if opts[:files]
167
167
  opts[:files].each_with_index do |file, index|
168
168
  if file.is_a? String
@@ -184,16 +184,16 @@ module HelloSign
184
184
  end
185
185
  end
186
186
 
187
- def prepare_signers opts
187
+ def prepare_signers(opts)
188
188
  prepare opts, :signers
189
189
  end
190
190
 
191
- def prepare_ccs opts
191
+ def prepare_ccs(opts)
192
192
  prepare opts, :ccs
193
193
  end
194
194
 
195
195
  def strip_options_whitespace(hash)
196
- hash.each do |k, v|
196
+ hash.each do |_, v|
197
197
  case v
198
198
  when String
199
199
  v.strip!
@@ -205,7 +205,7 @@ module HelloSign
205
205
  end
206
206
  end
207
207
 
208
- def prepare opts, key
208
+ def prepare(opts, key)
209
209
  return unless opts[key]
210
210
  opts[key].each_with_index do |value, index|
211
211
  if value.is_a? String