hellosign-api 1.0.0

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 (75) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +15 -0
  5. data/CONTRIBUTING.md +42 -0
  6. data/Gemfile +13 -0
  7. data/Guardfile +14 -0
  8. data/LICENSE +21 -0
  9. data/README.md +112 -0
  10. data/Rakefile +16 -0
  11. data/hellosign-api.gemspec +54 -0
  12. data/lib/hello_sign/.error.rb.swp +0 -0
  13. data/lib/hello_sign/api/account.rb +78 -0
  14. data/lib/hello_sign/api/api_app.rb +121 -0
  15. data/lib/hello_sign/api/bulk_send_job.rb +62 -0
  16. data/lib/hello_sign/api/embedded.rb +68 -0
  17. data/lib/hello_sign/api/oauth.rb +95 -0
  18. data/lib/hello_sign/api/signature_request.rb +691 -0
  19. data/lib/hello_sign/api/team.rb +107 -0
  20. data/lib/hello_sign/api/template.rb +227 -0
  21. data/lib/hello_sign/api/unclaimed_draft.rb +328 -0
  22. data/lib/hello_sign/api.rb +31 -0
  23. data/lib/hello_sign/client.rb +372 -0
  24. data/lib/hello_sign/configuration.rb +78 -0
  25. data/lib/hello_sign/error.rb +99 -0
  26. data/lib/hello_sign/resource/account.rb +43 -0
  27. data/lib/hello_sign/resource/api_app.rb +43 -0
  28. data/lib/hello_sign/resource/base_resource.rb +73 -0
  29. data/lib/hello_sign/resource/bulk_send_job.rb +43 -0
  30. data/lib/hello_sign/resource/embedded.rb +43 -0
  31. data/lib/hello_sign/resource/resource_array.rb +56 -0
  32. data/lib/hello_sign/resource/signature_request.rb +43 -0
  33. data/lib/hello_sign/resource/team.rb +43 -0
  34. data/lib/hello_sign/resource/template.rb +43 -0
  35. data/lib/hello_sign/resource/template_draft.rb +44 -0
  36. data/lib/hello_sign/resource/unclaimed_draft.rb +44 -0
  37. data/lib/hello_sign/resource.rb +33 -0
  38. data/lib/hello_sign/version.rb +25 -0
  39. data/lib/hello_sign.rb +50 -0
  40. data/lib/hellosign-ruby-sdk.rb +4 -0
  41. data/spec/fixtures/account.json +15 -0
  42. data/spec/fixtures/api_app.json +16 -0
  43. data/spec/fixtures/api_apps.json +43 -0
  44. data/spec/fixtures/bulk_send_job.json +88 -0
  45. data/spec/fixtures/bulk_send_jobs.json +22 -0
  46. data/spec/fixtures/embedded.json +6 -0
  47. data/spec/fixtures/empty.pdf +0 -0
  48. data/spec/fixtures/error.json +6 -0
  49. data/spec/fixtures/file.json +0 -0
  50. data/spec/fixtures/headers.json +18 -0
  51. data/spec/fixtures/nda.pdf +0 -0
  52. data/spec/fixtures/signature_request.json +45 -0
  53. data/spec/fixtures/signature_requests.json +44 -0
  54. data/spec/fixtures/team.json +15 -0
  55. data/spec/fixtures/template.json +53 -0
  56. data/spec/fixtures/templates.json +59 -0
  57. data/spec/fixtures/token.json +14 -0
  58. data/spec/fixtures/unclaimed_draft.json +6 -0
  59. data/spec/hello_sign/.error_spec.rb.swp +0 -0
  60. data/spec/hello_sign/api/account_spec.rb +42 -0
  61. data/spec/hello_sign/api/api_app_spec.rb +104 -0
  62. data/spec/hello_sign/api/bulk_send_job_spec.rb +53 -0
  63. data/spec/hello_sign/api/embedded_spec.rb +23 -0
  64. data/spec/hello_sign/api/oauth_spec.rb +27 -0
  65. data/spec/hello_sign/api/signature_request_spec.rb +268 -0
  66. data/spec/hello_sign/api/team_spec.rb +101 -0
  67. data/spec/hello_sign/api/template_spec.rb +172 -0
  68. data/spec/hello_sign/api/unclaimed_draft_spec.rb +145 -0
  69. data/spec/hello_sign/client_spec.rb +191 -0
  70. data/spec/hello_sign/error_spec.rb +10 -0
  71. data/spec/hello_sign/resource/base_resource_spec.rb +53 -0
  72. data/spec/hello_sign_spec.rb +57 -0
  73. data/spec/scenarios/uploads_spec.rb +19 -0
  74. data/spec/spec_helper.rb +104 -0
  75. metadata +261 -0
@@ -0,0 +1,95 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (C) 2014 hellosign.com
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ module HelloSign
24
+ module Api
25
+ # Contains all the API calls for OAuth workflows.
26
+ # OAuth allows you to perform actions on behalf of other users after they grant you the authorization to do so.
27
+ # See our OAuth API documentation (https://app.hellosign.com/api/oauthWalkthrough) for more information.
28
+ #
29
+ # @author [hellosign]
30
+
31
+ module OAuth
32
+
33
+ # Returns the OAuth URL where users can authorize your application to perform actions on their behalf.
34
+ # @param state [String] Random security value that must match throughout the user's flow.
35
+ # 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.
36
+ def oauth_url(state)
37
+ "#{self.oauth_end_point}/oauth/authorize?response_type=code&client_id=#{self.client_id}&state=#{state}"
38
+ end
39
+
40
+ # Retrieves the OAuth token
41
+ # @option opts [String] state Random security value that was used when you created oauth_url for a specific user.
42
+ # @option opts [String] code The code passed to your callback when the user granted access.
43
+ # @option opts [String] client_id The ApiApp Client ID.
44
+ # @option opts [String] client_secret The secret token of your ApiApp.
45
+ #
46
+ # @return [Hash] OAuth data of the user
47
+ #
48
+ # @example
49
+ # client = HelloSign::Client.new(
50
+ # api_key: '%apikey%',
51
+ # client_id: 'cc91c61d00f8bb2ece1428035716b',
52
+ # client_secret: '1d14434088507ffa390e6f5528465'
53
+ # )
54
+ # client.get_oauth_token(
55
+ # state: '900e06e2',
56
+ # code:'1b0d28d90c86c141'
57
+ # )
58
+ def get_oauth_token(opts)
59
+ opts[:client_id] = self.client_id
60
+ opts[:client_secret] = self.client_secret
61
+ opts[:grant_type] = 'authorization_code'
62
+ post('/oauth/token', { body: opts, oauth_request: true })
63
+ end
64
+
65
+ # Refreshes the user's OAuth token.
66
+ # @option opts [String] refresh_token The token provided when the access token has expired.
67
+ #
68
+ # @return [Hash] Refreshed OAuth info
69
+ #
70
+ # @example
71
+ # client.refresh_oauth_token refresh_token: 'hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3'
72
+ def refresh_oauth_token(opts)
73
+ opts[:client_id] = self.client_id
74
+ opts[:client_secret] = self.client_secret
75
+ opts[:grant_type] = 'refresh_token'
76
+ post('/oauth/token', { body: opts, oauth_request: true })
77
+ end
78
+
79
+ # Creates a new user and retrieves the OAuth token. The user will receive an email asking them to confirm the access being granted.
80
+ # Your app will not be able to perform actions on behalf of this user until they confirm.
81
+ # @option opts [String] email_address New user's email address.
82
+ #
83
+ # @return [Hash] details about new user, including OAuth data
84
+ #
85
+ # @example
86
+ # client.oauth_create_account email_address: 'new_user@example.com'
87
+ def oauth_create_account(opts)
88
+ opts[:client_id] = self.client_id
89
+ opts[:client_secret] = self.client_secret
90
+
91
+ HelloSign::Resource::Account.new post('/account/create', { body: opts })
92
+ end
93
+ end
94
+ end
95
+ end