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,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,510 @@
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_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