smartsheet 2.77.0 → 2.101.1

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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -12
  3. data/.rubocop.yml +4 -4
  4. data/.travis.yml +29 -15
  5. data/.yardopts +3 -3
  6. data/ADVANCED.md +78 -78
  7. data/CHANGELOG.md +133 -112
  8. data/Gemfile +6 -6
  9. data/LICENSE +202 -202
  10. data/README.md +248 -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 +514 -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/sheets/sheets_summaries.rb +123 -0
  58. data/lib/smartsheet/endpoints/sights/sights.rb +101 -101
  59. data/lib/smartsheet/endpoints/sights/sights_share.rb +69 -69
  60. data/lib/smartsheet/endpoints/templates/templates.rb +29 -29
  61. data/lib/smartsheet/endpoints/token/token.rb +70 -66
  62. data/lib/smartsheet/endpoints/update_requests/sent_update_requests.rb +44 -44
  63. data/lib/smartsheet/endpoints/update_requests/update_requests.rb +74 -74
  64. data/lib/smartsheet/endpoints/users/alternate_emails.rb +79 -79
  65. data/lib/smartsheet/endpoints/users/users.rb +123 -77
  66. data/lib/smartsheet/endpoints/webhooks/webhooks.rb +71 -71
  67. data/lib/smartsheet/endpoints/workspaces/workspaces.rb +87 -87
  68. data/lib/smartsheet/endpoints/workspaces/workspaces_share.rb +70 -70
  69. data/lib/smartsheet/error.rb +69 -69
  70. data/lib/smartsheet/general_request.rb +74 -74
  71. data/lib/smartsheet/version.rb +5 -5
  72. data/smartsheet.gemspec +54 -54
  73. metadata +24 -12
@@ -1,107 +1,107 @@
1
- require 'smartsheet/endpoints/sheets/rows_attachments'
2
-
3
- module Smartsheet
4
- # Rows Endpoints
5
- # @see https://smartsheet-platform.github.io/api-docs/?ruby#rows API Rows Docs
6
- #
7
- # @!attribute [r] attachments
8
- # @return [RowsAttachments]
9
- class Rows
10
- attr_reader :client, :attachments
11
- private :client
12
-
13
- def initialize(client)
14
- @client = client
15
-
16
- @attachments = RowsAttachments.new(client)
17
- end
18
-
19
- def add(sheet_id:, body:, params: {}, header_overrides: {})
20
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'rows'], body_type: :json)
21
- request_spec = Smartsheet::API::RequestSpec.new(
22
- header_overrides: header_overrides,
23
- params: params,
24
- body: body,
25
- sheet_id: sheet_id
26
- )
27
- client.make_request(endpoint_spec, request_spec)
28
- end
29
-
30
- def copy_to_another_sheet(sheet_id:, body:, params: {}, header_overrides: {})
31
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'rows', 'copy'], body_type: :json)
32
- request_spec = Smartsheet::API::RequestSpec.new(
33
- header_overrides: header_overrides,
34
- body: body,
35
- params: params,
36
- sheet_id: sheet_id
37
- )
38
- client.make_request(endpoint_spec, request_spec)
39
- end
40
-
41
- def delete(sheet_id:, row_ids:, params: {}, header_overrides: {})
42
- params[:ids] = row_ids.join(',')
43
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:delete, ['sheets', :sheet_id, 'rows'])
44
- request_spec = Smartsheet::API::RequestSpec.new(
45
- header_overrides: header_overrides,
46
- params: params,
47
- sheet_id: sheet_id
48
- )
49
- client.make_request(endpoint_spec, request_spec)
50
- end
51
-
52
- def get(sheet_id:, row_id:, params: {}, header_overrides: {})
53
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id, 'rows', :row_id])
54
- request_spec = Smartsheet::API::RequestSpec.new(
55
- header_overrides: header_overrides,
56
- params: params,
57
- sheet_id: sheet_id,
58
- row_id: row_id
59
- )
60
- client.make_request(endpoint_spec, request_spec)
61
- end
62
-
63
- def move_to_another_sheet(sheet_id:, body:, params: {}, header_overrides: {})
64
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'rows', 'move'], body_type: :json)
65
- request_spec = Smartsheet::API::RequestSpec.new(
66
- header_overrides: header_overrides,
67
- body: body,
68
- params: params,
69
- sheet_id: sheet_id
70
- )
71
- client.make_request(endpoint_spec, request_spec)
72
- end
73
-
74
- def send_via_email(sheet_id:, body:, params: {}, header_overrides: {})
75
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'rows', 'emails'], body_type: :json)
76
- request_spec = Smartsheet::API::RequestSpec.new(
77
- header_overrides: header_overrides,
78
- params: params,
79
- body: body,
80
- sheet_id: sheet_id
81
- )
82
- client.make_request(endpoint_spec, request_spec)
83
- end
84
-
85
- def update(sheet_id:, body:, params: {}, header_overrides: {})
86
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:put, ['sheets', :sheet_id, 'rows'], body_type: :json)
87
- request_spec = Smartsheet::API::RequestSpec.new(
88
- header_overrides: header_overrides,
89
- body: body,
90
- params: params,
91
- sheet_id: sheet_id
92
- )
93
- client.make_request(endpoint_spec, request_spec)
94
- end
95
-
96
- def sort(sheet_id:, body:, params: {}, header_overrides: {})
97
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'sort'], body_type: :json)
98
- request_spec = Smartsheet::API::RequestSpec.new(
99
- header_overrides: header_overrides,
100
- body: body,
101
- params: params,
102
- sheet_id: sheet_id
103
- )
104
- client.make_request(endpoint_spec, request_spec)
105
- end
106
- end
1
+ require 'smartsheet/endpoints/sheets/rows_attachments'
2
+
3
+ module Smartsheet
4
+ # Rows Endpoints
5
+ # @see https://smartsheet-platform.github.io/api-docs/?ruby#rows API Rows Docs
6
+ #
7
+ # @!attribute [r] attachments
8
+ # @return [RowsAttachments]
9
+ class Rows
10
+ attr_reader :client, :attachments
11
+ private :client
12
+
13
+ def initialize(client)
14
+ @client = client
15
+
16
+ @attachments = RowsAttachments.new(client)
17
+ end
18
+
19
+ def add(sheet_id:, body:, params: {}, header_overrides: {})
20
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'rows'], body_type: :json)
21
+ request_spec = Smartsheet::API::RequestSpec.new(
22
+ header_overrides: header_overrides,
23
+ params: params,
24
+ body: body,
25
+ sheet_id: sheet_id
26
+ )
27
+ client.make_request(endpoint_spec, request_spec)
28
+ end
29
+
30
+ def copy_to_another_sheet(sheet_id:, body:, params: {}, header_overrides: {})
31
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'rows', 'copy'], body_type: :json)
32
+ request_spec = Smartsheet::API::RequestSpec.new(
33
+ header_overrides: header_overrides,
34
+ body: body,
35
+ params: params,
36
+ sheet_id: sheet_id
37
+ )
38
+ client.make_request(endpoint_spec, request_spec)
39
+ end
40
+
41
+ def delete(sheet_id:, row_ids:, params: {}, header_overrides: {})
42
+ params[:ids] = row_ids.join(',')
43
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:delete, ['sheets', :sheet_id, 'rows'])
44
+ request_spec = Smartsheet::API::RequestSpec.new(
45
+ header_overrides: header_overrides,
46
+ params: params,
47
+ sheet_id: sheet_id
48
+ )
49
+ client.make_request(endpoint_spec, request_spec)
50
+ end
51
+
52
+ def get(sheet_id:, row_id:, params: {}, header_overrides: {})
53
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id, 'rows', :row_id])
54
+ request_spec = Smartsheet::API::RequestSpec.new(
55
+ header_overrides: header_overrides,
56
+ params: params,
57
+ sheet_id: sheet_id,
58
+ row_id: row_id
59
+ )
60
+ client.make_request(endpoint_spec, request_spec)
61
+ end
62
+
63
+ def move_to_another_sheet(sheet_id:, body:, params: {}, header_overrides: {})
64
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'rows', 'move'], body_type: :json)
65
+ request_spec = Smartsheet::API::RequestSpec.new(
66
+ header_overrides: header_overrides,
67
+ body: body,
68
+ params: params,
69
+ sheet_id: sheet_id
70
+ )
71
+ client.make_request(endpoint_spec, request_spec)
72
+ end
73
+
74
+ def send_via_email(sheet_id:, body:, params: {}, header_overrides: {})
75
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'rows', 'emails'], body_type: :json)
76
+ request_spec = Smartsheet::API::RequestSpec.new(
77
+ header_overrides: header_overrides,
78
+ params: params,
79
+ body: body,
80
+ sheet_id: sheet_id
81
+ )
82
+ client.make_request(endpoint_spec, request_spec)
83
+ end
84
+
85
+ def update(sheet_id:, body:, params: {}, header_overrides: {})
86
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:put, ['sheets', :sheet_id, 'rows'], body_type: :json)
87
+ request_spec = Smartsheet::API::RequestSpec.new(
88
+ header_overrides: header_overrides,
89
+ body: body,
90
+ params: params,
91
+ sheet_id: sheet_id
92
+ )
93
+ client.make_request(endpoint_spec, request_spec)
94
+ end
95
+
96
+ def sort(sheet_id:, body:, params: {}, header_overrides: {})
97
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'sort'], body_type: :json)
98
+ request_spec = Smartsheet::API::RequestSpec.new(
99
+ header_overrides: header_overrides,
100
+ body: body,
101
+ params: params,
102
+ sheet_id: sheet_id
103
+ )
104
+ client.make_request(endpoint_spec, request_spec)
105
+ end
106
+ end
107
107
  end
@@ -1,93 +1,93 @@
1
- require 'smartsheet/api/file_spec'
2
-
3
- module Smartsheet
4
- # Rows Attachments Endpoints
5
- # @see https://smartsheet-platform.github.io/api-docs/?ruby#attachments API Attachments Docs
6
- class RowsAttachments
7
- attr_reader :client
8
- private :client
9
-
10
- def initialize(client)
11
- @client = client
12
- end
13
-
14
- def list(sheet_id:, row_id:, params: {}, header_overrides: {})
15
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
16
- :get,
17
- ['sheets', :sheet_id, 'rows', :row_id, 'attachments']
18
- )
19
- request_spec = Smartsheet::API::RequestSpec.new(
20
- params: params,
21
- header_overrides: header_overrides,
22
- sheet_id: sheet_id,
23
- row_id: row_id
24
- )
25
- client.make_request(endpoint_spec, request_spec)
26
- end
27
-
28
- def attach_url(sheet_id:, row_id:, body:, params: {}, header_overrides: {})
29
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
30
- :post,
31
- ['sheets', :sheet_id, 'rows', :row_id, 'attachments'],
32
- body_type: :json
33
- )
34
- request_spec = Smartsheet::API::RequestSpec.new(
35
- header_overrides: header_overrides,
36
- params: params,
37
- body: body,
38
- sheet_id: sheet_id,
39
- row_id: row_id
40
- )
41
- client.make_request(endpoint_spec, request_spec)
42
- end
43
-
44
- def attach_file(
45
- sheet_id:,
46
- row_id:,
47
- file:,
48
- filename:,
49
- file_length:,
50
- content_type: '',
51
- params: {},
52
- header_overrides: {}
53
- )
54
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
55
- :post,
56
- ['sheets', :sheet_id, 'rows', :row_id, 'attachments'],
57
- body_type: :file
58
- )
59
- request_spec = Smartsheet::API::RequestSpec.new(
60
- params: params,
61
- header_overrides: header_overrides,
62
- file_spec: Smartsheet::API::ObjectFileSpec.new(file, filename, file_length, content_type),
63
- sheet_id: sheet_id,
64
- row_id: row_id
65
- )
66
- client.make_request(endpoint_spec, request_spec)
67
- end
68
-
69
- def attach_file_from_path(
70
- sheet_id:,
71
- row_id:,
72
- path:,
73
- filename: nil,
74
- content_type: '',
75
- params: {},
76
- header_overrides: {}
77
- )
78
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
79
- :post,
80
- ['sheets', :sheet_id, 'rows', :row_id, 'attachments'],
81
- body_type: :file
82
- )
83
- request_spec = Smartsheet::API::RequestSpec.new(
84
- params: params,
85
- header_overrides: header_overrides,
86
- file_spec: Smartsheet::API::PathFileSpec.new(path, filename, content_type),
87
- sheet_id: sheet_id,
88
- row_id: row_id
89
- )
90
- client.make_request(endpoint_spec, request_spec)
91
- end
92
- end
1
+ require 'smartsheet/api/file_spec'
2
+
3
+ module Smartsheet
4
+ # Rows Attachments Endpoints
5
+ # @see https://smartsheet-platform.github.io/api-docs/?ruby#attachments API Attachments Docs
6
+ class RowsAttachments
7
+ attr_reader :client
8
+ private :client
9
+
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ def list(sheet_id:, row_id:, params: {}, header_overrides: {})
15
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
16
+ :get,
17
+ ['sheets', :sheet_id, 'rows', :row_id, 'attachments']
18
+ )
19
+ request_spec = Smartsheet::API::RequestSpec.new(
20
+ params: params,
21
+ header_overrides: header_overrides,
22
+ sheet_id: sheet_id,
23
+ row_id: row_id
24
+ )
25
+ client.make_request(endpoint_spec, request_spec)
26
+ end
27
+
28
+ def attach_url(sheet_id:, row_id:, body:, params: {}, header_overrides: {})
29
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
30
+ :post,
31
+ ['sheets', :sheet_id, 'rows', :row_id, 'attachments'],
32
+ body_type: :json
33
+ )
34
+ request_spec = Smartsheet::API::RequestSpec.new(
35
+ header_overrides: header_overrides,
36
+ params: params,
37
+ body: body,
38
+ sheet_id: sheet_id,
39
+ row_id: row_id
40
+ )
41
+ client.make_request(endpoint_spec, request_spec)
42
+ end
43
+
44
+ def attach_file(
45
+ sheet_id:,
46
+ row_id:,
47
+ file:,
48
+ filename:,
49
+ file_length:,
50
+ content_type: '',
51
+ params: {},
52
+ header_overrides: {}
53
+ )
54
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
55
+ :post,
56
+ ['sheets', :sheet_id, 'rows', :row_id, 'attachments'],
57
+ body_type: :file
58
+ )
59
+ request_spec = Smartsheet::API::RequestSpec.new(
60
+ params: params,
61
+ header_overrides: header_overrides,
62
+ file_spec: Smartsheet::API::ObjectFileSpec.new(file, filename, file_length, content_type),
63
+ sheet_id: sheet_id,
64
+ row_id: row_id
65
+ )
66
+ client.make_request(endpoint_spec, request_spec)
67
+ end
68
+
69
+ def attach_file_from_path(
70
+ sheet_id:,
71
+ row_id:,
72
+ path:,
73
+ filename: nil,
74
+ content_type: '',
75
+ params: {},
76
+ header_overrides: {}
77
+ )
78
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
79
+ :post,
80
+ ['sheets', :sheet_id, 'rows', :row_id, 'attachments'],
81
+ body_type: :file
82
+ )
83
+ request_spec = Smartsheet::API::RequestSpec.new(
84
+ params: params,
85
+ header_overrides: header_overrides,
86
+ file_spec: Smartsheet::API::PathFileSpec.new(path, filename, content_type),
87
+ sheet_id: sheet_id,
88
+ row_id: row_id
89
+ )
90
+ client.make_request(endpoint_spec, request_spec)
91
+ end
92
+ end
93
93
  end
@@ -1,510 +1,514 @@
1
- require 'smartsheet/api/endpoint_spec'
2
- require 'smartsheet/api/request_spec'
3
- require 'smartsheet/constants'
4
- require 'smartsheet/error'
5
-
6
- require 'smartsheet/endpoints/sheets/automation_rules'
7
- require 'smartsheet/endpoints/sheets/cells'
8
- require 'smartsheet/endpoints/sheets/columns'
9
- require 'smartsheet/endpoints/sheets/comments'
10
- require 'smartsheet/endpoints/sheets/cross_sheet_references'
11
- require 'smartsheet/endpoints/sheets/discussions'
12
- require 'smartsheet/endpoints/sheets/rows'
13
- require 'smartsheet/endpoints/sheets/sheets_attachments'
14
- require 'smartsheet/endpoints/sheets/sheets_share'
15
-
16
- module Smartsheet
17
- # Sheets Endpoints
18
- # @see https://smartsheet-platform.github.io/api-docs/?ruby#sheets API Sheets Docs
19
- #
20
- # @!attribute [r] attachments
21
- # @return [SheetsAttachments]
22
- # @!attribute [r] automation_rules
23
- # @return [AutomationRules]
24
- # @!attribute [r] cells
25
- # @return [Cells]
26
- # @!attribute [r] columns
27
- # @return [Columns]
28
- # @!attribute [r] comments
29
- # @return [Comments]
30
- # @!attribute [r] cross_sheet_references
31
- # @return [CrossSheetReferences]
32
- # @!attribute [r] discussions
33
- # @return [Discussions]
34
- # @!attribute [r] rows
35
- # @return [Rows]
36
- # @!attribute [r] share
37
- # @return [SheetsShare]
38
- class Sheets
39
- include Smartsheet::Constants
40
-
41
- attr_reader :client, :attachments, :automation_rules, :cells, :columns, :comments,
42
- :cross_sheet_references, :discussions, :rows, :share
43
- private :client
44
-
45
- def initialize(client)
46
- @client = client
47
-
48
- @attachments = SheetsAttachments.new(client)
49
- @automation_rules = AutomationRules.new(client)
50
- @cells = Cells.new(client)
51
- @columns = Columns.new(client)
52
- @comments = Comments.new(client)
53
- @cross_sheet_references = CrossSheetReferences.new(client)
54
- @discussions = Discussions.new(client)
55
- @rows = Rows.new(client)
56
- @share = SheetsShare.new(client)
57
- end
58
-
59
- def list(params: {}, header_overrides: {})
60
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets'])
61
- request_spec = Smartsheet::API::RequestSpec.new(
62
- params: params,
63
- header_overrides: header_overrides
64
- )
65
- client.make_request(endpoint_spec, request_spec)
66
- end
67
-
68
- def get(sheet_id:, params: {}, header_overrides: {})
69
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id])
70
- request_spec = Smartsheet::API::RequestSpec.new(
71
- params: params,
72
- header_overrides: header_overrides,
73
- sheet_id: sheet_id
74
- )
75
- client.make_request(endpoint_spec, request_spec)
76
- end
77
-
78
- def get_version(sheet_id:, params: {}, header_overrides: {})
79
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id, 'version'])
80
- request_spec = Smartsheet::API::RequestSpec.new(
81
- params: params,
82
- header_overrides: header_overrides,
83
- sheet_id: sheet_id
84
- )
85
- client.make_request(endpoint_spec, request_spec)
86
- end
87
-
88
- def get_as_excel(sheet_id:, params: {}, header_overrides: {})
89
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
90
- :get,
91
- ['sheets', :sheet_id],
92
- headers: {Accept: EXCEL_TYPE}
93
- )
94
- request_spec = Smartsheet::API::RequestSpec.new(
95
- params: params,
96
- header_overrides: header_overrides,
97
- sheet_id: sheet_id
98
- )
99
- client.make_request(endpoint_spec, request_spec)
100
- end
101
-
102
- def get_as_pdf(sheet_id:, params: {}, header_overrides: {})
103
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
104
- :get,
105
- ['sheets', :sheet_id],
106
- headers: {Accept: PDF_TYPE}
107
- )
108
- request_spec = Smartsheet::API::RequestSpec.new(
109
- params: params,
110
- header_overrides: header_overrides,
111
- sheet_id: sheet_id
112
- )
113
- client.make_request(endpoint_spec, request_spec)
114
- end
115
-
116
- def get_as_csv(sheet_id:, params: {}, header_overrides: {})
117
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
118
- :get,
119
- ['sheets', :sheet_id],
120
- headers: {Accept: CSV_TYPE}
121
- )
122
- request_spec = Smartsheet::API::RequestSpec.new(
123
- params: params,
124
- header_overrides: header_overrides,
125
- sheet_id: sheet_id
126
- )
127
- client.make_request(endpoint_spec, request_spec)
128
- end
129
-
130
- def create(body:, params: {}, header_overrides: {})
131
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
132
- :post,
133
- ['sheets'],
134
- body_type: :json
135
- )
136
- request_spec = Smartsheet::API::RequestSpec.new(
137
- params: params,
138
- header_overrides: header_overrides,
139
- body: body
140
- )
141
- client.make_request(endpoint_spec, request_spec)
142
- end
143
-
144
- def create_in_folder(folder_id:, body:, params: {}, header_overrides: {})
145
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
146
- :post,
147
- ['folders', :folder_id, 'sheets'],
148
- body_type: :json
149
- )
150
- request_spec = Smartsheet::API::RequestSpec.new(
151
- params: params,
152
- header_overrides: header_overrides,
153
- body: body,
154
- folder_id: folder_id
155
- )
156
- client.make_request(endpoint_spec, request_spec)
157
- end
158
-
159
- def create_in_workspace(workspace_id:, body:, params: {}, header_overrides: {})
160
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
161
- :post,
162
- ['workspaces', :workspace_id, 'sheets'],
163
- body_type: :json
164
- )
165
- request_spec = Smartsheet::API::RequestSpec.new(
166
- params: params,
167
- header_overrides: header_overrides,
168
- body: body,
169
- workspace_id: workspace_id
170
- )
171
- client.make_request(endpoint_spec, request_spec)
172
- end
173
-
174
- def create_from_template(body:, params: {}, header_overrides: {})
175
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
176
- :post,
177
- ['sheets'],
178
- body_type: :json
179
- )
180
- request_spec = Smartsheet::API::RequestSpec.new(
181
- params: params,
182
- header_overrides: header_overrides,
183
- body: body
184
- )
185
- client.make_request(endpoint_spec, request_spec)
186
- end
187
-
188
- def create_in_folder_from_template(folder_id:, body:, params: {}, header_overrides: {})
189
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
190
- :post,
191
- ['folders', :folder_id, 'sheets'],
192
- body_type: :json
193
- )
194
- request_spec = Smartsheet::API::RequestSpec.new(
195
- params: params,
196
- header_overrides: header_overrides,
197
- body: body,
198
- folder_id: folder_id
199
- )
200
- client.make_request(endpoint_spec, request_spec)
201
- end
202
-
203
- def create_in_workspace_from_template(workspace_id:, body:, params: {}, header_overrides: {})
204
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
205
- :post,
206
- ['workspaces', :workspace_id, 'sheets'],
207
- body_type: :json
208
- )
209
- request_spec = Smartsheet::API::RequestSpec.new(
210
- params: params,
211
- header_overrides: header_overrides,
212
- body: body,
213
- workspace_id: workspace_id
214
- )
215
- client.make_request(endpoint_spec, request_spec)
216
- end
217
-
218
- def import_from_file(file:, file_type:, file_length:, params: {}, header_overrides: {})
219
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
220
- :post,
221
- ['sheets', 'import'],
222
- body_type: :file
223
- )
224
- content_type = file_type_to_content_type(file_type)
225
- request_spec = Smartsheet::API::RequestSpec.new(
226
- params: params,
227
- header_overrides: header_overrides,
228
- file_spec: Smartsheet::API::ImportObjectFileSpec.new(file, file_length, content_type)
229
- )
230
- client.make_request(endpoint_spec, request_spec)
231
- end
232
-
233
- def import_from_file_path(path:, file_type:, params: {}, header_overrides: {})
234
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
235
- :post,
236
- ['sheets', 'import'],
237
- body_type: :file
238
- )
239
- content_type = file_type_to_content_type(file_type)
240
- request_spec = Smartsheet::API::RequestSpec.new(
241
- params: params,
242
- header_overrides: header_overrides,
243
- file_spec: Smartsheet::API::ImportPathFileSpec.new(path, content_type)
244
- )
245
- client.make_request(endpoint_spec, request_spec)
246
- end
247
-
248
- def import_from_file_into_folder(
249
- folder_id:,
250
- file:,
251
- file_type:,
252
- file_length:,
253
- params: {},
254
- header_overrides: {}
255
- )
256
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
257
- :post,
258
- ['folders', :folder_id, 'sheets', 'import'],
259
- body_type: :file
260
- )
261
- content_type = file_type_to_content_type(file_type)
262
- request_spec = Smartsheet::API::RequestSpec.new(
263
- params: params,
264
- header_overrides: header_overrides,
265
- file_spec: Smartsheet::API::ImportObjectFileSpec.new(file, file_length, content_type),
266
- folder_id: folder_id
267
- )
268
- client.make_request(endpoint_spec, request_spec)
269
- end
270
-
271
- def import_from_file_path_into_folder(
272
- folder_id:,
273
- path:,
274
- file_type:,
275
- params: {},
276
- header_overrides: {}
277
- )
278
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
279
- :post,
280
- ['folders', :folder_id, 'sheets', 'import'],
281
- body_type: :file
282
- )
283
- content_type = file_type_to_content_type(file_type)
284
- request_spec = Smartsheet::API::RequestSpec.new(
285
- params: params,
286
- header_overrides: header_overrides,
287
- file_spec: Smartsheet::API::ImportPathFileSpec.new(path, content_type),
288
- folder_id: folder_id
289
- )
290
- client.make_request(endpoint_spec, request_spec)
291
- end
292
-
293
- def import_from_file_into_workspace(
294
- workspace_id:,
295
- file:,
296
- file_type:,
297
- file_length:,
298
- params: {},
299
- header_overrides: {}
300
- )
301
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
302
- :post,
303
- ['workspaces', :workspace_id, 'sheets', 'import'],
304
- body_type: :file
305
- )
306
- content_type = file_type_to_content_type(file_type)
307
- request_spec = Smartsheet::API::RequestSpec.new(
308
- params: params,
309
- header_overrides: header_overrides,
310
- file_spec: Smartsheet::API::ImportObjectFileSpec.new(file, file_length, content_type),
311
- workspace_id: workspace_id
312
- )
313
- client.make_request(endpoint_spec, request_spec)
314
- end
315
-
316
- def import_from_file_path_into_workspace(
317
- workspace_id:,
318
- path:,
319
- file_type:,
320
- params: {},
321
- header_overrides: {}
322
- )
323
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
324
- :post,
325
- ['workspaces', :workspace_id, 'sheets', 'import'],
326
- body_type: :file
327
- )
328
- content_type = file_type_to_content_type(file_type)
329
- request_spec = Smartsheet::API::RequestSpec.new(
330
- params: params,
331
- header_overrides: header_overrides,
332
- file_spec: Smartsheet::API::ImportPathFileSpec.new(path, content_type),
333
- workspace_id: workspace_id
334
- )
335
- client.make_request(endpoint_spec, request_spec)
336
- end
337
-
338
- ### These endpoints are not yet implemented; these endpoints can be re-included once they are
339
- ### active
340
-
341
- # def import_and_replace_sheet_from_file(
342
- # sheet_id:,
343
- # file:,
344
- # file_type:,
345
- # file_length:,
346
- # params: {},
347
- # header_overrides: {}
348
- # )
349
- # endpoint_spec = Smartsheet::API::EndpointSpec.new(
350
- # :post,
351
- # ['sheets', :sheet_id, 'import'],
352
- # body_type: :file
353
- # )
354
- # content_type = file_type_to_content_type(file_type)
355
- # request_spec = Smartsheet::API::RequestSpec.new(
356
- # params: params,
357
- # header_overrides: header_overrides,
358
- # file_spec: Smartsheet::API::ImportObjectFileSpec.new(file, file_length, content_type)
359
- # )
360
- # client.make_request(endpoint_spec, request_spec)
361
- # end
362
-
363
- # def import_and_replace_sheet_from_file_path(
364
- # sheet_id:,
365
- # path:,
366
- # file_type:,
367
- # params: {},
368
- # header_overrides: {}
369
- # )
370
- # endpoint_spec = Smartsheet::API::EndpointSpec.new(
371
- # :post,
372
- # ['sheets', :sheet_id, 'import'],
373
- # body_type: :file
374
- # )
375
- # content_type = file_type_to_content_type(file_type)
376
- # request_spec = Smartsheet::API::RequestSpec.new(
377
- # params: params,
378
- # header_overrides: header_overrides,
379
- # file_spec: Smartsheet::API::ImportPathFileSpec.new(path, content_type)
380
- # )
381
- # client.make_request(endpoint_spec, request_spec)
382
- # end
383
-
384
- def copy(sheet_id:, body:, params: {}, header_overrides: {})
385
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
386
- :post,
387
- ['sheets', :sheet_id, 'copy'],
388
- body_type: :json
389
- )
390
- request_spec = Smartsheet::API::RequestSpec.new(
391
- params: params,
392
- header_overrides: header_overrides,
393
- body: body,
394
- sheet_id: sheet_id
395
- )
396
- client.make_request(endpoint_spec, request_spec)
397
- end
398
-
399
- def move(sheet_id:, body:, params: {}, header_overrides: {})
400
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
401
- :post,
402
- ['sheets', :sheet_id, 'move'],
403
- body_type: :json
404
- )
405
- request_spec = Smartsheet::API::RequestSpec.new(
406
- params: params,
407
- header_overrides: header_overrides,
408
- body: body,
409
- sheet_id: sheet_id
410
- )
411
- client.make_request(endpoint_spec, request_spec)
412
- end
413
-
414
- def update(sheet_id:, body:, params: {}, header_overrides: {})
415
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
416
- :put,
417
- ['sheets', :sheet_id],
418
- body_type: :json
419
- )
420
- request_spec = Smartsheet::API::RequestSpec.new(
421
- params: params,
422
- header_overrides: header_overrides,
423
- body: body,
424
- sheet_id: sheet_id
425
- )
426
- client.make_request(endpoint_spec, request_spec)
427
- end
428
-
429
- def delete(sheet_id:, params: {}, header_overrides: {})
430
- endpoint_spec = Smartsheet::API::EndpointSpec.new(
431
- :delete,
432
- ['sheets', :sheet_id]
433
- )
434
- request_spec = Smartsheet::API::RequestSpec.new(
435
- params: params,
436
- header_overrides: header_overrides,
437
- sheet_id: sheet_id
438
- )
439
- client.make_request(endpoint_spec, request_spec)
440
- end
441
-
442
- def list_for_org(params: {}, header_overrides: {})
443
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:get,['users', 'sheets'])
444
- request_spec = Smartsheet::API::RequestSpec.new(
445
- header_overrides: header_overrides,
446
- params: params
447
- )
448
- client.make_request(endpoint_spec, request_spec)
449
- end
450
-
451
- def get_publish_status(sheet_id:, params: {}, header_overrides: {})
452
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:get,['sheets', :sheet_id, 'publish'])
453
- request_spec = Smartsheet::API::RequestSpec.new(
454
- params: params,
455
- header_overrides: header_overrides,
456
- sheet_id: sheet_id
457
- )
458
- client.make_request(endpoint_spec, request_spec)
459
- end
460
-
461
- def set_publish_status(sheet_id:, body:, params: {}, header_overrides: {})
462
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:put,['sheets', :sheet_id, 'publish'], body_type: :json)
463
- request_spec = Smartsheet::API::RequestSpec.new(
464
- params: params,
465
- header_overrides: header_overrides,
466
- body: body,
467
- sheet_id: sheet_id
468
- )
469
- client.make_request(endpoint_spec, request_spec)
470
- end
471
-
472
- def send_via_email(sheet_id:, body:, params: {}, header_overrides: {})
473
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:post,['sheets', :sheet_id, 'emails'], body_type: :json)
474
- request_spec = Smartsheet::API::RequestSpec.new(
475
- params: params,
476
- header_overrides: header_overrides,
477
- body: body,
478
- sheet_id: sheet_id
479
- )
480
- client.make_request(endpoint_spec, request_spec)
481
- end
482
-
483
- def list_image_urls(body:, params: {}, header_overrides: {})
484
- endpoint_spec = Smartsheet::API::EndpointSpec.new(:post,['imageurls'], body_type: :json)
485
- request_spec = Smartsheet::API::RequestSpec.new(
486
- params: params,
487
- header_overrides: header_overrides,
488
- body: body
489
- )
490
- client.make_request(endpoint_spec, request_spec)
491
- end
492
-
493
- private
494
-
495
- def file_type_to_content_type(file_type)
496
- mapping = {
497
- csv: Constants::CSV_TYPE,
498
- xlsx: Constants::OPENXML_SPREADSHEET_TYPE
499
- }
500
-
501
- mapping.fetch(file_type) do |_|
502
- available_types = mapping.keys.join(', ')
503
-
504
- raise Smartsheet::Error.new(
505
- "Unsupported file type: #{file_type}\nValid types: #{available_types}"
506
- )
507
- end
508
- end
509
- end
510
- end
1
+ require 'smartsheet/api/endpoint_spec'
2
+ require 'smartsheet/api/request_spec'
3
+ require 'smartsheet/constants'
4
+ require 'smartsheet/error'
5
+
6
+ require 'smartsheet/endpoints/sheets/automation_rules'
7
+ require 'smartsheet/endpoints/sheets/cells'
8
+ require 'smartsheet/endpoints/sheets/columns'
9
+ require 'smartsheet/endpoints/sheets/comments'
10
+ require 'smartsheet/endpoints/sheets/cross_sheet_references'
11
+ require 'smartsheet/endpoints/sheets/discussions'
12
+ require 'smartsheet/endpoints/sheets/rows'
13
+ require 'smartsheet/endpoints/sheets/sheets_attachments'
14
+ require 'smartsheet/endpoints/sheets/sheets_summaries'
15
+ require 'smartsheet/endpoints/sheets/sheets_share'
16
+
17
+ module Smartsheet
18
+ # Sheets Endpoints
19
+ # @see https://smartsheet-platform.github.io/api-docs/?ruby#sheets API Sheets Docs
20
+ #
21
+ # @!attribute [r] attachments
22
+ # @return [SheetsAttachments]
23
+ # @!attribute [r] automation_rules
24
+ # @return [AutomationRules]
25
+ # @!attribute [r] cells
26
+ # @return [Cells]
27
+ # @!attribute [r] columns
28
+ # @return [Columns]
29
+ # @!attribute [r] comments
30
+ # @return [Comments]
31
+ # @!attribute [r] cross_sheet_references
32
+ # @return [CrossSheetReferences]
33
+ # @!attribute [r] discussions
34
+ # @return [Discussions]
35
+ # @!attribute [r] summaries
36
+ # @return [Summaries]
37
+ # @!attribute [r] rows
38
+ # @return [Rows]
39
+ # @!attribute [r] share
40
+ # @return [SheetsShare]
41
+ class Sheets
42
+ include Smartsheet::Constants
43
+
44
+ attr_reader :client, :attachments, :automation_rules, :cells, :columns, :comments,
45
+ :cross_sheet_references, :discussions, :summaries, :rows, :share
46
+ private :client
47
+
48
+ def initialize(client)
49
+ @client = client
50
+
51
+ @attachments = SheetsAttachments.new(client)
52
+ @automation_rules = AutomationRules.new(client)
53
+ @cells = Cells.new(client)
54
+ @columns = Columns.new(client)
55
+ @comments = Comments.new(client)
56
+ @cross_sheet_references = CrossSheetReferences.new(client)
57
+ @discussions = Discussions.new(client)
58
+ @summaries = SheetsSummaries.new(client)
59
+ @rows = Rows.new(client)
60
+ @share = SheetsShare.new(client)
61
+ end
62
+
63
+ def list(params: {}, header_overrides: {})
64
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets'])
65
+ request_spec = Smartsheet::API::RequestSpec.new(
66
+ params: params,
67
+ header_overrides: header_overrides
68
+ )
69
+ client.make_request(endpoint_spec, request_spec)
70
+ end
71
+
72
+ def get(sheet_id:, params: {}, header_overrides: {})
73
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id])
74
+ request_spec = Smartsheet::API::RequestSpec.new(
75
+ params: params,
76
+ header_overrides: header_overrides,
77
+ sheet_id: sheet_id
78
+ )
79
+ client.make_request(endpoint_spec, request_spec)
80
+ end
81
+
82
+ def get_version(sheet_id:, params: {}, header_overrides: {})
83
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id, 'version'])
84
+ request_spec = Smartsheet::API::RequestSpec.new(
85
+ params: params,
86
+ header_overrides: header_overrides,
87
+ sheet_id: sheet_id
88
+ )
89
+ client.make_request(endpoint_spec, request_spec)
90
+ end
91
+
92
+ def get_as_excel(sheet_id:, params: {}, header_overrides: {})
93
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
94
+ :get,
95
+ ['sheets', :sheet_id],
96
+ headers: {Accept: EXCEL_TYPE}
97
+ )
98
+ request_spec = Smartsheet::API::RequestSpec.new(
99
+ params: params,
100
+ header_overrides: header_overrides,
101
+ sheet_id: sheet_id
102
+ )
103
+ client.make_request(endpoint_spec, request_spec)
104
+ end
105
+
106
+ def get_as_pdf(sheet_id:, params: {}, header_overrides: {})
107
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
108
+ :get,
109
+ ['sheets', :sheet_id],
110
+ headers: {Accept: PDF_TYPE}
111
+ )
112
+ request_spec = Smartsheet::API::RequestSpec.new(
113
+ params: params,
114
+ header_overrides: header_overrides,
115
+ sheet_id: sheet_id
116
+ )
117
+ client.make_request(endpoint_spec, request_spec)
118
+ end
119
+
120
+ def get_as_csv(sheet_id:, params: {}, header_overrides: {})
121
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
122
+ :get,
123
+ ['sheets', :sheet_id],
124
+ headers: {Accept: CSV_TYPE}
125
+ )
126
+ request_spec = Smartsheet::API::RequestSpec.new(
127
+ params: params,
128
+ header_overrides: header_overrides,
129
+ sheet_id: sheet_id
130
+ )
131
+ client.make_request(endpoint_spec, request_spec)
132
+ end
133
+
134
+ def create(body:, params: {}, header_overrides: {})
135
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
136
+ :post,
137
+ ['sheets'],
138
+ body_type: :json
139
+ )
140
+ request_spec = Smartsheet::API::RequestSpec.new(
141
+ params: params,
142
+ header_overrides: header_overrides,
143
+ body: body
144
+ )
145
+ client.make_request(endpoint_spec, request_spec)
146
+ end
147
+
148
+ def create_in_folder(folder_id:, body:, params: {}, header_overrides: {})
149
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
150
+ :post,
151
+ ['folders', :folder_id, 'sheets'],
152
+ body_type: :json
153
+ )
154
+ request_spec = Smartsheet::API::RequestSpec.new(
155
+ params: params,
156
+ header_overrides: header_overrides,
157
+ body: body,
158
+ folder_id: folder_id
159
+ )
160
+ client.make_request(endpoint_spec, request_spec)
161
+ end
162
+
163
+ def create_in_workspace(workspace_id:, body:, params: {}, header_overrides: {})
164
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
165
+ :post,
166
+ ['workspaces', :workspace_id, 'sheets'],
167
+ body_type: :json
168
+ )
169
+ request_spec = Smartsheet::API::RequestSpec.new(
170
+ params: params,
171
+ header_overrides: header_overrides,
172
+ body: body,
173
+ workspace_id: workspace_id
174
+ )
175
+ client.make_request(endpoint_spec, request_spec)
176
+ end
177
+
178
+ def create_from_template(body:, params: {}, header_overrides: {})
179
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
180
+ :post,
181
+ ['sheets'],
182
+ body_type: :json
183
+ )
184
+ request_spec = Smartsheet::API::RequestSpec.new(
185
+ params: params,
186
+ header_overrides: header_overrides,
187
+ body: body
188
+ )
189
+ client.make_request(endpoint_spec, request_spec)
190
+ end
191
+
192
+ def create_in_folder_from_template(folder_id:, body:, params: {}, header_overrides: {})
193
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
194
+ :post,
195
+ ['folders', :folder_id, 'sheets'],
196
+ body_type: :json
197
+ )
198
+ request_spec = Smartsheet::API::RequestSpec.new(
199
+ params: params,
200
+ header_overrides: header_overrides,
201
+ body: body,
202
+ folder_id: folder_id
203
+ )
204
+ client.make_request(endpoint_spec, request_spec)
205
+ end
206
+
207
+ def create_in_workspace_from_template(workspace_id:, body:, params: {}, header_overrides: {})
208
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
209
+ :post,
210
+ ['workspaces', :workspace_id, 'sheets'],
211
+ body_type: :json
212
+ )
213
+ request_spec = Smartsheet::API::RequestSpec.new(
214
+ params: params,
215
+ header_overrides: header_overrides,
216
+ body: body,
217
+ workspace_id: workspace_id
218
+ )
219
+ client.make_request(endpoint_spec, request_spec)
220
+ end
221
+
222
+ def import_from_file(file:, file_type:, file_length:, params: {}, header_overrides: {})
223
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
224
+ :post,
225
+ ['sheets', 'import'],
226
+ body_type: :file
227
+ )
228
+ content_type = file_type_to_content_type(file_type)
229
+ request_spec = Smartsheet::API::RequestSpec.new(
230
+ params: params,
231
+ header_overrides: header_overrides,
232
+ file_spec: Smartsheet::API::ImportObjectFileSpec.new(file, file_length, content_type)
233
+ )
234
+ client.make_request(endpoint_spec, request_spec)
235
+ end
236
+
237
+ def import_from_file_path(path:, file_type:, params: {}, header_overrides: {})
238
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
239
+ :post,
240
+ ['sheets', 'import'],
241
+ body_type: :file
242
+ )
243
+ content_type = file_type_to_content_type(file_type)
244
+ request_spec = Smartsheet::API::RequestSpec.new(
245
+ params: params,
246
+ header_overrides: header_overrides,
247
+ file_spec: Smartsheet::API::ImportPathFileSpec.new(path, content_type)
248
+ )
249
+ client.make_request(endpoint_spec, request_spec)
250
+ end
251
+
252
+ def import_from_file_into_folder(
253
+ folder_id:,
254
+ file:,
255
+ file_type:,
256
+ file_length:,
257
+ params: {},
258
+ header_overrides: {}
259
+ )
260
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
261
+ :post,
262
+ ['folders', :folder_id, 'sheets', 'import'],
263
+ body_type: :file
264
+ )
265
+ content_type = file_type_to_content_type(file_type)
266
+ request_spec = Smartsheet::API::RequestSpec.new(
267
+ params: params,
268
+ header_overrides: header_overrides,
269
+ file_spec: Smartsheet::API::ImportObjectFileSpec.new(file, file_length, content_type),
270
+ folder_id: folder_id
271
+ )
272
+ client.make_request(endpoint_spec, request_spec)
273
+ end
274
+
275
+ def import_from_file_path_into_folder(
276
+ folder_id:,
277
+ path:,
278
+ file_type:,
279
+ params: {},
280
+ header_overrides: {}
281
+ )
282
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
283
+ :post,
284
+ ['folders', :folder_id, 'sheets', 'import'],
285
+ body_type: :file
286
+ )
287
+ content_type = file_type_to_content_type(file_type)
288
+ request_spec = Smartsheet::API::RequestSpec.new(
289
+ params: params,
290
+ header_overrides: header_overrides,
291
+ file_spec: Smartsheet::API::ImportPathFileSpec.new(path, content_type),
292
+ folder_id: folder_id
293
+ )
294
+ client.make_request(endpoint_spec, request_spec)
295
+ end
296
+
297
+ def import_from_file_into_workspace(
298
+ workspace_id:,
299
+ file:,
300
+ file_type:,
301
+ file_length:,
302
+ params: {},
303
+ header_overrides: {}
304
+ )
305
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
306
+ :post,
307
+ ['workspaces', :workspace_id, 'sheets', 'import'],
308
+ body_type: :file
309
+ )
310
+ content_type = file_type_to_content_type(file_type)
311
+ request_spec = Smartsheet::API::RequestSpec.new(
312
+ params: params,
313
+ header_overrides: header_overrides,
314
+ file_spec: Smartsheet::API::ImportObjectFileSpec.new(file, file_length, content_type),
315
+ workspace_id: workspace_id
316
+ )
317
+ client.make_request(endpoint_spec, request_spec)
318
+ end
319
+
320
+ def import_from_file_path_into_workspace(
321
+ workspace_id:,
322
+ path:,
323
+ file_type:,
324
+ params: {},
325
+ header_overrides: {}
326
+ )
327
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
328
+ :post,
329
+ ['workspaces', :workspace_id, 'sheets', 'import'],
330
+ body_type: :file
331
+ )
332
+ content_type = file_type_to_content_type(file_type)
333
+ request_spec = Smartsheet::API::RequestSpec.new(
334
+ params: params,
335
+ header_overrides: header_overrides,
336
+ file_spec: Smartsheet::API::ImportPathFileSpec.new(path, content_type),
337
+ workspace_id: workspace_id
338
+ )
339
+ client.make_request(endpoint_spec, request_spec)
340
+ end
341
+
342
+ ### These endpoints are not yet implemented; these endpoints can be re-included once they are
343
+ ### active
344
+
345
+ # def import_and_replace_sheet_from_file(
346
+ # sheet_id:,
347
+ # file:,
348
+ # file_type:,
349
+ # file_length:,
350
+ # params: {},
351
+ # header_overrides: {}
352
+ # )
353
+ # endpoint_spec = Smartsheet::API::EndpointSpec.new(
354
+ # :post,
355
+ # ['sheets', :sheet_id, 'import'],
356
+ # body_type: :file
357
+ # )
358
+ # content_type = file_type_to_content_type(file_type)
359
+ # request_spec = Smartsheet::API::RequestSpec.new(
360
+ # params: params,
361
+ # header_overrides: header_overrides,
362
+ # file_spec: Smartsheet::API::ImportObjectFileSpec.new(file, file_length, content_type)
363
+ # )
364
+ # client.make_request(endpoint_spec, request_spec)
365
+ # end
366
+
367
+ # def import_and_replace_sheet_from_file_path(
368
+ # sheet_id:,
369
+ # path:,
370
+ # file_type:,
371
+ # params: {},
372
+ # header_overrides: {}
373
+ # )
374
+ # endpoint_spec = Smartsheet::API::EndpointSpec.new(
375
+ # :post,
376
+ # ['sheets', :sheet_id, 'import'],
377
+ # body_type: :file
378
+ # )
379
+ # content_type = file_type_to_content_type(file_type)
380
+ # request_spec = Smartsheet::API::RequestSpec.new(
381
+ # params: params,
382
+ # header_overrides: header_overrides,
383
+ # file_spec: Smartsheet::API::ImportPathFileSpec.new(path, content_type)
384
+ # )
385
+ # client.make_request(endpoint_spec, request_spec)
386
+ # end
387
+
388
+ def copy(sheet_id:, body:, params: {}, header_overrides: {})
389
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
390
+ :post,
391
+ ['sheets', :sheet_id, 'copy'],
392
+ body_type: :json
393
+ )
394
+ request_spec = Smartsheet::API::RequestSpec.new(
395
+ params: params,
396
+ header_overrides: header_overrides,
397
+ body: body,
398
+ sheet_id: sheet_id
399
+ )
400
+ client.make_request(endpoint_spec, request_spec)
401
+ end
402
+
403
+ def move(sheet_id:, body:, params: {}, header_overrides: {})
404
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
405
+ :post,
406
+ ['sheets', :sheet_id, 'move'],
407
+ body_type: :json
408
+ )
409
+ request_spec = Smartsheet::API::RequestSpec.new(
410
+ params: params,
411
+ header_overrides: header_overrides,
412
+ body: body,
413
+ sheet_id: sheet_id
414
+ )
415
+ client.make_request(endpoint_spec, request_spec)
416
+ end
417
+
418
+ def update(sheet_id:, body:, params: {}, header_overrides: {})
419
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
420
+ :put,
421
+ ['sheets', :sheet_id],
422
+ body_type: :json
423
+ )
424
+ request_spec = Smartsheet::API::RequestSpec.new(
425
+ params: params,
426
+ header_overrides: header_overrides,
427
+ body: body,
428
+ sheet_id: sheet_id
429
+ )
430
+ client.make_request(endpoint_spec, request_spec)
431
+ end
432
+
433
+ def delete(sheet_id:, params: {}, header_overrides: {})
434
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
435
+ :delete,
436
+ ['sheets', :sheet_id]
437
+ )
438
+ request_spec = Smartsheet::API::RequestSpec.new(
439
+ params: params,
440
+ header_overrides: header_overrides,
441
+ sheet_id: sheet_id
442
+ )
443
+ client.make_request(endpoint_spec, request_spec)
444
+ end
445
+
446
+ def list_for_org(params: {}, header_overrides: {})
447
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get,['users', 'sheets'])
448
+ request_spec = Smartsheet::API::RequestSpec.new(
449
+ header_overrides: header_overrides,
450
+ params: params
451
+ )
452
+ client.make_request(endpoint_spec, request_spec)
453
+ end
454
+
455
+ def get_publish_status(sheet_id:, params: {}, header_overrides: {})
456
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get,['sheets', :sheet_id, 'publish'])
457
+ request_spec = Smartsheet::API::RequestSpec.new(
458
+ params: params,
459
+ header_overrides: header_overrides,
460
+ sheet_id: sheet_id
461
+ )
462
+ client.make_request(endpoint_spec, request_spec)
463
+ end
464
+
465
+ def set_publish_status(sheet_id:, body:, params: {}, header_overrides: {})
466
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:put,['sheets', :sheet_id, 'publish'], body_type: :json)
467
+ request_spec = Smartsheet::API::RequestSpec.new(
468
+ params: params,
469
+ header_overrides: header_overrides,
470
+ body: body,
471
+ sheet_id: sheet_id
472
+ )
473
+ client.make_request(endpoint_spec, request_spec)
474
+ end
475
+
476
+ def send_via_email(sheet_id:, body:, params: {}, header_overrides: {})
477
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post,['sheets', :sheet_id, 'emails'], body_type: :json)
478
+ request_spec = Smartsheet::API::RequestSpec.new(
479
+ params: params,
480
+ header_overrides: header_overrides,
481
+ body: body,
482
+ sheet_id: sheet_id
483
+ )
484
+ client.make_request(endpoint_spec, request_spec)
485
+ end
486
+
487
+ def list_image_urls(body:, params: {}, header_overrides: {})
488
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post,['imageurls'], body_type: :json)
489
+ request_spec = Smartsheet::API::RequestSpec.new(
490
+ params: params,
491
+ header_overrides: header_overrides,
492
+ body: body
493
+ )
494
+ client.make_request(endpoint_spec, request_spec)
495
+ end
496
+
497
+ private
498
+
499
+ def file_type_to_content_type(file_type)
500
+ mapping = {
501
+ csv: Constants::CSV_TYPE,
502
+ xlsx: Constants::OPENXML_SPREADSHEET_TYPE
503
+ }
504
+
505
+ mapping.fetch(file_type) do |_|
506
+ available_types = mapping.keys.join(', ')
507
+
508
+ raise Smartsheet::Error.new(
509
+ "Unsupported file type: #{file_type}\nValid types: #{available_types}"
510
+ )
511
+ end
512
+ end
513
+ end
514
+ end