smartsheet 2.77.0 → 2.77.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -12
  3. data/.rubocop.yml +4 -4
  4. data/.travis.yml +26 -15
  5. data/.yardopts +3 -3
  6. data/ADVANCED.md +78 -78
  7. data/CHANGELOG.md +115 -112
  8. data/Gemfile +6 -6
  9. data/LICENSE +202 -202
  10. data/README.md +246 -246
  11. data/Rakefile +29 -29
  12. data/bin/console +14 -14
  13. data/bin/setup +8 -8
  14. data/lib/smartsheet.rb +2 -2
  15. data/lib/smartsheet/api/body_builder.rb +25 -25
  16. data/lib/smartsheet/api/endpoint_spec.rb +54 -54
  17. data/lib/smartsheet/api/faraday_adapter/faraday_net_client.rb +45 -45
  18. data/lib/smartsheet/api/faraday_adapter/faraday_response.rb +70 -70
  19. data/lib/smartsheet/api/faraday_adapter/middleware/faraday_error_translator.rb +20 -20
  20. data/lib/smartsheet/api/faraday_adapter/middleware/response_parser.rb +25 -25
  21. data/lib/smartsheet/api/file_spec.rb +55 -55
  22. data/lib/smartsheet/api/header_builder.rb +96 -96
  23. data/lib/smartsheet/api/request.rb +42 -42
  24. data/lib/smartsheet/api/request_client.rb +43 -43
  25. data/lib/smartsheet/api/request_logger.rb +182 -182
  26. data/lib/smartsheet/api/request_spec.rb +57 -57
  27. data/lib/smartsheet/api/response_net_client_decorator.rb +54 -54
  28. data/lib/smartsheet/api/retry_logic.rb +40 -40
  29. data/lib/smartsheet/api/retry_net_client_decorator.rb +37 -37
  30. data/lib/smartsheet/api/url_builder.rb +25 -25
  31. data/lib/smartsheet/client.rb +193 -193
  32. data/lib/smartsheet/constants.rb +18 -18
  33. data/lib/smartsheet/endpoints/contacts/contacts.rb +30 -30
  34. data/lib/smartsheet/endpoints/events/events.rb +20 -20
  35. data/lib/smartsheet/endpoints/favorites/favorites.rb +159 -159
  36. data/lib/smartsheet/endpoints/folders/folders.rb +125 -125
  37. data/lib/smartsheet/endpoints/groups/groups.rb +83 -83
  38. data/lib/smartsheet/endpoints/home/home.rb +20 -20
  39. data/lib/smartsheet/endpoints/reports/reports.rb +100 -100
  40. data/lib/smartsheet/endpoints/reports/reports_share.rb +69 -69
  41. data/lib/smartsheet/endpoints/search/search.rb +30 -30
  42. data/lib/smartsheet/endpoints/server_info/server_info.rb +21 -21
  43. data/lib/smartsheet/endpoints/share/share.rb +58 -58
  44. data/lib/smartsheet/endpoints/sheets/automation_rules.rb +55 -55
  45. data/lib/smartsheet/endpoints/sheets/cells.rb +82 -82
  46. data/lib/smartsheet/endpoints/sheets/columns.rb +66 -66
  47. data/lib/smartsheet/endpoints/sheets/comments.rb +64 -64
  48. data/lib/smartsheet/endpoints/sheets/comments_attachments.rb +78 -78
  49. data/lib/smartsheet/endpoints/sheets/cross_sheet_references.rb +45 -45
  50. data/lib/smartsheet/endpoints/sheets/discussions.rb +84 -84
  51. data/lib/smartsheet/endpoints/sheets/discussions_attachments.rb +22 -22
  52. data/lib/smartsheet/endpoints/sheets/rows.rb +106 -106
  53. data/lib/smartsheet/endpoints/sheets/rows_attachments.rb +92 -92
  54. data/lib/smartsheet/endpoints/sheets/sheets.rb +510 -510
  55. data/lib/smartsheet/endpoints/sheets/sheets_attachments.rb +174 -174
  56. data/lib/smartsheet/endpoints/sheets/sheets_share.rb +69 -69
  57. data/lib/smartsheet/endpoints/sights/sights.rb +101 -101
  58. data/lib/smartsheet/endpoints/sights/sights_share.rb +69 -69
  59. data/lib/smartsheet/endpoints/templates/templates.rb +29 -29
  60. data/lib/smartsheet/endpoints/token/token.rb +65 -65
  61. data/lib/smartsheet/endpoints/update_requests/sent_update_requests.rb +44 -44
  62. data/lib/smartsheet/endpoints/update_requests/update_requests.rb +74 -74
  63. data/lib/smartsheet/endpoints/users/alternate_emails.rb +79 -79
  64. data/lib/smartsheet/endpoints/users/users.rb +77 -77
  65. data/lib/smartsheet/endpoints/webhooks/webhooks.rb +71 -71
  66. data/lib/smartsheet/endpoints/workspaces/workspaces.rb +87 -87
  67. data/lib/smartsheet/endpoints/workspaces/workspaces_share.rb +70 -70
  68. data/lib/smartsheet/error.rb +69 -69
  69. data/lib/smartsheet/general_request.rb +74 -74
  70. data/lib/smartsheet/version.rb +5 -5
  71. data/smartsheet.gemspec +54 -54
  72. metadata +3 -4
@@ -1,21 +1,21 @@
1
- require 'faraday'
2
- require 'smartsheet/error'
3
-
4
- module Smartsheet
5
- module API
6
- module Middleware
7
- # Raises Faraday request errors as {Smartsheet::RequestError RequestErrors}
8
- class FaradayErrorTranslator < Faraday::Middleware
9
- def initialize(app)
10
- super(app)
11
- end
12
-
13
- def call(env)
14
- @app.call(env)
15
- rescue Faraday::Error => e
16
- raise Smartsheet::RequestError, e
17
- end
18
- end
19
- end
20
- end
1
+ require 'faraday'
2
+ require 'smartsheet/error'
3
+
4
+ module Smartsheet
5
+ module API
6
+ module Middleware
7
+ # Raises Faraday request errors as {Smartsheet::RequestError RequestErrors}
8
+ class FaradayErrorTranslator < Faraday::Middleware
9
+ def initialize(app)
10
+ super(app)
11
+ end
12
+
13
+ def call(env)
14
+ @app.call(env)
15
+ rescue Faraday::Error => e
16
+ raise Smartsheet::RequestError, e
17
+ end
18
+ end
19
+ end
20
+ end
21
21
  end
@@ -1,26 +1,26 @@
1
- require 'faraday'
2
- require 'json'
3
- require 'smartsheet/api/faraday_adapter/faraday_response'
4
-
5
- module Smartsheet
6
- module API
7
- module Middleware
8
- # Wraps responses into {FaradayResponse FaradayResponses}, parsing JSON bodies when applicable
9
- class ResponseParser < Faraday::Middleware
10
- def initialize(app)
11
- super(app)
12
- end
13
-
14
- def call(env)
15
- @app.call(env).on_complete do |response_env|
16
- if response_env[:response_headers]['content-type'] =~ /\bapplication\/json\b/
17
- response_env[:body] = JSON.parse(response_env[:body], symbolize_names: true)
18
- end
19
-
20
- response_env[:body] = FaradayResponse.from_response_env response_env
21
- end
22
- end
23
- end
24
- end
25
- end
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'smartsheet/api/faraday_adapter/faraday_response'
4
+
5
+ module Smartsheet
6
+ module API
7
+ module Middleware
8
+ # Wraps responses into {FaradayResponse FaradayResponses}, parsing JSON bodies when applicable
9
+ class ResponseParser < Faraday::Middleware
10
+ def initialize(app)
11
+ super(app)
12
+ end
13
+
14
+ def call(env)
15
+ @app.call(env).on_complete do |response_env|
16
+ if response_env[:response_headers]['content-type'] =~ /\bapplication\/json\b/
17
+ response_env[:body] = JSON.parse(response_env[:body], symbolize_names: true)
18
+ end
19
+
20
+ response_env[:body] = FaradayResponse.from_response_env response_env
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
26
  end
@@ -1,55 +1,55 @@
1
- require 'cgi'
2
- require 'faraday'
3
-
4
- module Smartsheet
5
- module API
6
- # Specification for a file attachment by path, target filename, and MIME content type
7
- class PathFileSpec
8
- attr_reader :upload_io, :filename, :content_type, :file_length
9
-
10
- def initialize(path, filename, content_type)
11
- @file_length = File.size(path)
12
- @filename = (filename.nil? || filename.empty?) ? File.basename(path) : filename
13
- @upload_io = Faraday::UploadIO.new(path, content_type, CGI::escape(@filename))
14
- @content_type = content_type
15
- end
16
- end
17
-
18
- # Specification for a file attachment by {::File}, target filename, file length, and MIME
19
- # content type
20
- class ObjectFileSpec
21
- attr_reader :upload_io, :filename, :content_type, :file_length
22
-
23
- def initialize(file, filename, file_length, content_type)
24
- @file_length = file_length
25
- @filename = filename
26
- @upload_io = Faraday::UploadIO.new(file, content_type, CGI::escape(filename))
27
- @content_type = content_type
28
- end
29
- end
30
-
31
- # Specification for file sheet import by path and MIME content type
32
- class ImportPathFileSpec
33
- attr_reader :upload_io, :filename, :content_type, :file_length
34
-
35
- def initialize(path, content_type)
36
- @file_length = File.size(path)
37
- @filename = nil
38
- @upload_io = Faraday::UploadIO.new(path, content_type)
39
- @content_type = content_type
40
- end
41
- end
42
-
43
- # Specification for file sheet import by {::File}, file length, and MIME content type
44
- class ImportObjectFileSpec
45
- attr_reader :upload_io, :filename, :content_type, :file_length
46
-
47
- def initialize(file, file_length, content_type)
48
- @file_length = file_length
49
- @filename = nil
50
- @upload_io = Faraday::UploadIO.new(file, content_type)
51
- @content_type = content_type
52
- end
53
- end
54
- end
55
- end
1
+ require 'cgi'
2
+ require 'faraday'
3
+
4
+ module Smartsheet
5
+ module API
6
+ # Specification for a file attachment by path, target filename, and MIME content type
7
+ class PathFileSpec
8
+ attr_reader :upload_io, :filename, :content_type, :file_length
9
+
10
+ def initialize(path, filename, content_type)
11
+ @file_length = File.size(path)
12
+ @filename = (filename.nil? || filename.empty?) ? File.basename(path) : filename
13
+ @upload_io = Faraday::UploadIO.new(path, content_type, CGI::escape(@filename))
14
+ @content_type = content_type
15
+ end
16
+ end
17
+
18
+ # Specification for a file attachment by {::File}, target filename, file length, and MIME
19
+ # content type
20
+ class ObjectFileSpec
21
+ attr_reader :upload_io, :filename, :content_type, :file_length
22
+
23
+ def initialize(file, filename, file_length, content_type)
24
+ @file_length = file_length
25
+ @filename = filename
26
+ @upload_io = Faraday::UploadIO.new(file, content_type, CGI::escape(filename))
27
+ @content_type = content_type
28
+ end
29
+ end
30
+
31
+ # Specification for file sheet import by path and MIME content type
32
+ class ImportPathFileSpec
33
+ attr_reader :upload_io, :filename, :content_type, :file_length
34
+
35
+ def initialize(path, content_type)
36
+ @file_length = File.size(path)
37
+ @filename = nil
38
+ @upload_io = Faraday::UploadIO.new(path, content_type)
39
+ @content_type = content_type
40
+ end
41
+ end
42
+
43
+ # Specification for file sheet import by {::File}, file length, and MIME content type
44
+ class ImportObjectFileSpec
45
+ attr_reader :upload_io, :filename, :content_type, :file_length
46
+
47
+ def initialize(file, file_length, content_type)
48
+ @file_length = file_length
49
+ @filename = nil
50
+ @upload_io = Faraday::UploadIO.new(file, content_type)
51
+ @content_type = content_type
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,96 +1,96 @@
1
- require 'cgi'
2
- require 'smartsheet/version'
3
- require 'smartsheet/constants'
4
-
5
- module Smartsheet
6
- module API
7
- # Constructs headers for accessing the Smartsheet API
8
- class HeaderBuilder
9
- include Smartsheet::Constants
10
- def initialize(token, endpoint_spec, request_spec, app_user_agent: nil, assume_user: nil)
11
- @token = token
12
- @endpoint_spec = endpoint_spec
13
- @request_spec = request_spec
14
- @app_user_agent = app_user_agent
15
- @assume_user = assume_user
16
- end
17
-
18
- def build
19
- base_headers
20
- .merge(assume_user)
21
- .merge(endpoint_headers)
22
- .merge(content_type)
23
- .merge(content_disposition)
24
- .merge(content_length)
25
- .merge(request_headers)
26
- end
27
-
28
- private
29
-
30
- attr_accessor :endpoint_spec, :request_spec
31
- attr_reader :token
32
-
33
- def base_headers
34
- base = {
35
- Accept: JSON_TYPE,
36
- 'User-Agent': user_agent
37
- }
38
- base[:Authorization] = "Bearer #{token}" if endpoint_spec.requires_auth?
39
-
40
- base
41
- end
42
-
43
- def user_agent
44
- "#{USER_AGENT}/#{Smartsheet::VERSION}" +
45
- (@app_user_agent.nil? ? '' : "/#{@app_user_agent}")
46
- end
47
-
48
- def assume_user
49
- if @assume_user.nil?
50
- {}
51
- else
52
- {'Assume-User': CGI::escape(@assume_user)}
53
- end
54
- end
55
-
56
- def endpoint_headers
57
- endpoint_spec.headers
58
- end
59
-
60
- def content_type
61
- if endpoint_spec.sending_json? && request_spec.body
62
- {'Content-Type': JSON_TYPE}
63
- elsif endpoint_spec.sending_file?
64
- {'Content-Type': request_spec.content_type}
65
- else
66
- {}
67
- end
68
- end
69
-
70
- def content_disposition
71
- if endpoint_spec.sending_file?
72
- filename_suffix =
73
- if request_spec.filename.nil?
74
- then ''
75
- else "; filename=\"#{CGI::escape(request_spec.filename)}\""
76
- end
77
- {'Content-Disposition': "attachment#{filename_suffix}"}
78
- else
79
- {}
80
- end
81
- end
82
-
83
- def content_length
84
- if endpoint_spec.sending_file?
85
- {'Content-Length': request_spec.file_length.to_s}
86
- else
87
- {}
88
- end
89
- end
90
-
91
- def request_headers
92
- request_spec.header_overrides
93
- end
94
- end
95
- end
96
- end
1
+ require 'cgi'
2
+ require 'smartsheet/version'
3
+ require 'smartsheet/constants'
4
+
5
+ module Smartsheet
6
+ module API
7
+ # Constructs headers for accessing the Smartsheet API
8
+ class HeaderBuilder
9
+ include Smartsheet::Constants
10
+ def initialize(token, endpoint_spec, request_spec, app_user_agent: nil, assume_user: nil)
11
+ @token = token
12
+ @endpoint_spec = endpoint_spec
13
+ @request_spec = request_spec
14
+ @app_user_agent = app_user_agent
15
+ @assume_user = assume_user
16
+ end
17
+
18
+ def build
19
+ base_headers
20
+ .merge(assume_user)
21
+ .merge(endpoint_headers)
22
+ .merge(content_type)
23
+ .merge(content_disposition)
24
+ .merge(content_length)
25
+ .merge(request_headers)
26
+ end
27
+
28
+ private
29
+
30
+ attr_accessor :endpoint_spec, :request_spec
31
+ attr_reader :token
32
+
33
+ def base_headers
34
+ base = {
35
+ Accept: JSON_TYPE,
36
+ 'User-Agent': user_agent
37
+ }
38
+ base[:Authorization] = "Bearer #{token}" if endpoint_spec.requires_auth?
39
+
40
+ base
41
+ end
42
+
43
+ def user_agent
44
+ "#{USER_AGENT}/#{Smartsheet::VERSION}" +
45
+ (@app_user_agent.nil? ? '' : "/#{@app_user_agent}")
46
+ end
47
+
48
+ def assume_user
49
+ if @assume_user.nil?
50
+ {}
51
+ else
52
+ {'Assume-User': CGI::escape(@assume_user)}
53
+ end
54
+ end
55
+
56
+ def endpoint_headers
57
+ endpoint_spec.headers
58
+ end
59
+
60
+ def content_type
61
+ if endpoint_spec.sending_json? && request_spec.body
62
+ {'Content-Type': JSON_TYPE}
63
+ elsif endpoint_spec.sending_file?
64
+ {'Content-Type': request_spec.content_type}
65
+ else
66
+ {}
67
+ end
68
+ end
69
+
70
+ def content_disposition
71
+ if endpoint_spec.sending_file?
72
+ filename_suffix =
73
+ if request_spec.filename.nil?
74
+ then ''
75
+ else "; filename=\"#{CGI::escape(request_spec.filename)}\""
76
+ end
77
+ {'Content-Disposition': "attachment#{filename_suffix}"}
78
+ else
79
+ {}
80
+ end
81
+ end
82
+
83
+ def content_length
84
+ if endpoint_spec.sending_file?
85
+ {'Content-Length': request_spec.file_length.to_s}
86
+ else
87
+ {}
88
+ end
89
+ end
90
+
91
+ def request_headers
92
+ request_spec.header_overrides
93
+ end
94
+ end
95
+ end
96
+ end
@@ -1,43 +1,43 @@
1
- require 'smartsheet/api/url_builder'
2
- require 'smartsheet/api/header_builder'
3
- require 'smartsheet/api/body_builder'
4
-
5
- module Smartsheet
6
- module API
7
- # Full specification for a single request to an endpoint
8
- class Request
9
- attr_reader :method, :url, :headers, :params, :body
10
-
11
- def initialize(
12
- token,
13
- endpoint_spec,
14
- request_spec,
15
- base_url,
16
- app_user_agent: nil,
17
- assume_user: nil
18
- )
19
- @method = endpoint_spec.method
20
- @url = Smartsheet::API::UrlBuilder.new(endpoint_spec, request_spec, base_url).build
21
- @headers = Smartsheet::API::HeaderBuilder.new(
22
- token,
23
- endpoint_spec,
24
- request_spec,
25
- app_user_agent: app_user_agent,
26
- assume_user: assume_user
27
- ).build
28
- @params = request_spec.params
29
- @body = Smartsheet::API::BodyBuilder.new(endpoint_spec, request_spec).build
30
- end
31
-
32
- def ==(other)
33
- other.class == self.class && other.equality_state == equality_state
34
- end
35
-
36
- protected
37
-
38
- def equality_state
39
- [method, url, headers, params, body]
40
- end
41
- end
42
- end
1
+ require 'smartsheet/api/url_builder'
2
+ require 'smartsheet/api/header_builder'
3
+ require 'smartsheet/api/body_builder'
4
+
5
+ module Smartsheet
6
+ module API
7
+ # Full specification for a single request to an endpoint
8
+ class Request
9
+ attr_reader :method, :url, :headers, :params, :body
10
+
11
+ def initialize(
12
+ token,
13
+ endpoint_spec,
14
+ request_spec,
15
+ base_url,
16
+ app_user_agent: nil,
17
+ assume_user: nil
18
+ )
19
+ @method = endpoint_spec.method
20
+ @url = Smartsheet::API::UrlBuilder.new(endpoint_spec, request_spec, base_url).build
21
+ @headers = Smartsheet::API::HeaderBuilder.new(
22
+ token,
23
+ endpoint_spec,
24
+ request_spec,
25
+ app_user_agent: app_user_agent,
26
+ assume_user: assume_user
27
+ ).build
28
+ @params = request_spec.params
29
+ @body = Smartsheet::API::BodyBuilder.new(endpoint_spec, request_spec).build
30
+ end
31
+
32
+ def ==(other)
33
+ other.class == self.class && other.equality_state == equality_state
34
+ end
35
+
36
+ protected
37
+
38
+ def equality_state
39
+ [method, url, headers, params, body]
40
+ end
41
+ end
42
+ end
43
43
  end