smartsheet 1.0.0.beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rubocop.yml +5 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE +202 -0
  7. data/README.md +139 -0
  8. data/Rakefile +13 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/lib/smartsheet.rb +3 -0
  12. data/lib/smartsheet/api/body_builder.rb +26 -0
  13. data/lib/smartsheet/api/endpoint_spec.rb +35 -0
  14. data/lib/smartsheet/api/faraday_adapter/faraday_net_client.rb +42 -0
  15. data/lib/smartsheet/api/faraday_adapter/faraday_response.rb +60 -0
  16. data/lib/smartsheet/api/faraday_adapter/middleware/faraday_error_translator.rb +20 -0
  17. data/lib/smartsheet/api/faraday_adapter/middleware/response_parser.rb +25 -0
  18. data/lib/smartsheet/api/file_spec.rb +28 -0
  19. data/lib/smartsheet/api/header_builder.rb +85 -0
  20. data/lib/smartsheet/api/request.rb +29 -0
  21. data/lib/smartsheet/api/request_client.rb +26 -0
  22. data/lib/smartsheet/api/request_logger.rb +148 -0
  23. data/lib/smartsheet/api/request_spec.rb +43 -0
  24. data/lib/smartsheet/api/response_net_client_decorator.rb +47 -0
  25. data/lib/smartsheet/api/retry_logic.rb +37 -0
  26. data/lib/smartsheet/api/retry_net_client_decorator.rb +36 -0
  27. data/lib/smartsheet/api/url_builder.rb +25 -0
  28. data/lib/smartsheet/client.rb +115 -0
  29. data/lib/smartsheet/constants.rb +16 -0
  30. data/lib/smartsheet/endpoints/contacts/contacts.rb +29 -0
  31. data/lib/smartsheet/endpoints/favorites/favorites.rb +158 -0
  32. data/lib/smartsheet/endpoints/folders/folders.rb +124 -0
  33. data/lib/smartsheet/endpoints/groups/groups.rb +82 -0
  34. data/lib/smartsheet/endpoints/home/home.rb +19 -0
  35. data/lib/smartsheet/endpoints/reports/reports.rb +96 -0
  36. data/lib/smartsheet/endpoints/reports/reports_share.rb +68 -0
  37. data/lib/smartsheet/endpoints/search/search.rb +29 -0
  38. data/lib/smartsheet/endpoints/server_info/server_info.rb +19 -0
  39. data/lib/smartsheet/endpoints/share/share.rb +58 -0
  40. data/lib/smartsheet/endpoints/sheets/cells.rb +80 -0
  41. data/lib/smartsheet/endpoints/sheets/columns.rb +65 -0
  42. data/lib/smartsheet/endpoints/sheets/comments.rb +60 -0
  43. data/lib/smartsheet/endpoints/sheets/comments_attachments.rb +77 -0
  44. data/lib/smartsheet/endpoints/sheets/discussions.rb +80 -0
  45. data/lib/smartsheet/endpoints/sheets/discussions_attachments.rb +21 -0
  46. data/lib/smartsheet/endpoints/sheets/rows.rb +91 -0
  47. data/lib/smartsheet/endpoints/sheets/rows_attachments.rb +91 -0
  48. data/lib/smartsheet/endpoints/sheets/sheets.rb +301 -0
  49. data/lib/smartsheet/endpoints/sheets/sheets_attachments.rb +173 -0
  50. data/lib/smartsheet/endpoints/sheets/sheets_share.rb +68 -0
  51. data/lib/smartsheet/endpoints/sights/sights.rb +97 -0
  52. data/lib/smartsheet/endpoints/sights/sights_share.rb +68 -0
  53. data/lib/smartsheet/endpoints/templates/templates.rb +28 -0
  54. data/lib/smartsheet/endpoints/token/token.rb +57 -0
  55. data/lib/smartsheet/endpoints/update_requests/sent_update_requests.rb +42 -0
  56. data/lib/smartsheet/endpoints/update_requests/update_requests.rb +69 -0
  57. data/lib/smartsheet/endpoints/users/alternate_emails.rb +77 -0
  58. data/lib/smartsheet/endpoints/users/users.rb +73 -0
  59. data/lib/smartsheet/endpoints/webhooks/webhooks.rb +70 -0
  60. data/lib/smartsheet/endpoints/workspaces/workspaces.rb +83 -0
  61. data/lib/smartsheet/endpoints/workspaces/workspaces_share.rb +68 -0
  62. data/lib/smartsheet/error.rb +30 -0
  63. data/lib/smartsheet/general_request.rb +53 -0
  64. data/lib/smartsheet/version.rb +5 -0
  65. data/read-write-sheet/config.json +4 -0
  66. data/read-write-sheet/read_write_sheet.rb +89 -0
  67. data/smartsheet.gemspec +47 -0
  68. metadata +279 -0
@@ -0,0 +1,80 @@
1
+ require 'smartsheet/api/file_spec'
2
+
3
+ module Smartsheet
4
+ class Cells
5
+ attr_reader :client
6
+ private :client
7
+
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def get_history(sheet_id:, row_id:, column_id:, params: {}, header_overrides: {})
13
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
14
+ :get,
15
+ ['sheets', :sheet_id, 'rows', :row_id, 'columns', :column_id, 'history']
16
+ )
17
+ request_spec = Smartsheet::API::RequestSpec.new(
18
+ header_overrides: header_overrides,
19
+ params: params,
20
+ sheet_id: sheet_id,
21
+ row_id: row_id,
22
+ column_id: column_id
23
+ )
24
+ client.make_request(endpoint_spec, request_spec)
25
+ end
26
+
27
+ def add_image(
28
+ sheet_id:,
29
+ row_id:,
30
+ column_id:,
31
+ file:,
32
+ filename:,
33
+ file_length:,
34
+ content_type: '',
35
+ params: {},
36
+ header_overrides: {}
37
+ )
38
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
39
+ :post,
40
+ ['sheets', :sheet_id, 'rows', :row_id, 'columns', :column_id, 'cellimages'],
41
+ body_type: :file
42
+ )
43
+ request_spec = Smartsheet::API::RequestSpec.new(
44
+ header_overrides: header_overrides,
45
+ params: params,
46
+ file_spec: Smartsheet::API::ObjectFileSpec.new(file, filename, file_length, content_type),
47
+ sheet_id: sheet_id,
48
+ row_id: row_id,
49
+ column_id: column_id
50
+ )
51
+ client.make_request(endpoint_spec, request_spec)
52
+ end
53
+
54
+ def add_image_from_path(
55
+ sheet_id:,
56
+ row_id:,
57
+ column_id:,
58
+ path:,
59
+ filename: '',
60
+ content_type: '',
61
+ params: {},
62
+ header_overrides: {}
63
+ )
64
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
65
+ :post,
66
+ ['sheets', :sheet_id, 'rows', :row_id, 'columns', :column_id, 'cellimages'],
67
+ body_type: :file
68
+ )
69
+ request_spec = Smartsheet::API::RequestSpec.new(
70
+ header_overrides: header_overrides,
71
+ params: params,
72
+ file_spec: Smartsheet::API::PathFileSpec.new(path, filename, content_type),
73
+ sheet_id: sheet_id,
74
+ row_id: row_id,
75
+ column_id: column_id
76
+ )
77
+ client.make_request(endpoint_spec, request_spec)
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,65 @@
1
+ module Smartsheet
2
+ class Columns
3
+ attr_reader :client
4
+ private :client
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ def add(sheet_id:, body:, params: {}, header_overrides: {})
11
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'columns'], body_type: :json)
12
+ request_spec = Smartsheet::API::RequestSpec.new(
13
+ header_overrides: header_overrides,
14
+ params: params,
15
+ body: body,
16
+ sheet_id: sheet_id
17
+ )
18
+ client.make_request(endpoint_spec, request_spec)
19
+ end
20
+
21
+ def delete(sheet_id:, column_id:, params: {}, header_overrides: {})
22
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:delete, ['sheets', :sheet_id, 'columns', :column_id])
23
+ request_spec = Smartsheet::API::RequestSpec.new(
24
+ params: params,
25
+ header_overrides: header_overrides,
26
+ column_id: column_id,
27
+ sheet_id: sheet_id
28
+ )
29
+ client.make_request(endpoint_spec, request_spec)
30
+ end
31
+
32
+ def get(sheet_id:, column_id:, params: {}, header_overrides: {})
33
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id, 'columns', :column_id])
34
+ request_spec = Smartsheet::API::RequestSpec.new(
35
+ header_overrides: header_overrides,
36
+ params: params,
37
+ column_id: column_id,
38
+ sheet_id: sheet_id
39
+ )
40
+ client.make_request(endpoint_spec, request_spec)
41
+ end
42
+
43
+ def list(sheet_id:, params: {}, header_overrides: {})
44
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id, 'columns'])
45
+ request_spec = Smartsheet::API::RequestSpec.new(
46
+ header_overrides: header_overrides,
47
+ params: params,
48
+ sheet_id: sheet_id
49
+ )
50
+ client.make_request(endpoint_spec, request_spec)
51
+ end
52
+
53
+ def update(sheet_id:, column_id:, body:, params: {}, header_overrides: {})
54
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:put, ['sheets', :sheet_id, 'columns', :column_id], body_type: :json)
55
+ request_spec = Smartsheet::API::RequestSpec.new(
56
+ header_overrides: header_overrides,
57
+ params: params,
58
+ body: body,
59
+ sheet_id: sheet_id,
60
+ column_id: column_id
61
+ )
62
+ client.make_request(endpoint_spec, request_spec)
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,60 @@
1
+ require 'smartsheet/endpoints/sheets/comments_attachments'
2
+
3
+ module Smartsheet
4
+ class Comments
5
+ attr_reader :client, :attachments
6
+ private :client
7
+
8
+ def initialize(client)
9
+ @client = client
10
+
11
+ @attachments = CommentsAttachments.new(client)
12
+ end
13
+
14
+ def add(sheet_id:, discussion_id:, body:, params: {}, header_overrides: {})
15
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'discussions', :discussion_id, 'comments'], body_type: :json)
16
+ request_spec = Smartsheet::API::RequestSpec.new(
17
+ header_overrides: header_overrides,
18
+ params: params,
19
+ body: body,
20
+ sheet_id: sheet_id,
21
+ discussion_id: discussion_id
22
+ )
23
+ client.make_request(endpoint_spec, request_spec)
24
+ end
25
+
26
+ def update(sheet_id:, comment_id:, body:, params: {}, header_overrides: {})
27
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:put, ['sheets', :sheet_id, 'comments', :comment_id], body_type: :json)
28
+ request_spec = Smartsheet::API::RequestSpec.new(
29
+ header_overrides: header_overrides,
30
+ params: params,
31
+ body: body,
32
+ sheet_id: sheet_id,
33
+ comment_id: comment_id
34
+ )
35
+ client.make_request(endpoint_spec, request_spec)
36
+ end
37
+
38
+ def delete(sheet_id:, comment_id:, params: {}, header_overrides: {})
39
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:delete, ['sheets', :sheet_id, 'comments', :comment_id])
40
+ request_spec = Smartsheet::API::RequestSpec.new(
41
+ params: params,
42
+ header_overrides: header_overrides,
43
+ sheet_id: sheet_id,
44
+ comment_id: comment_id
45
+ )
46
+ client.make_request(endpoint_spec, request_spec)
47
+ end
48
+
49
+ def get(sheet_id:, comment_id:, params: {}, header_overrides: {})
50
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id, 'comments', :comment_id])
51
+ request_spec = Smartsheet::API::RequestSpec.new(
52
+ params: params,
53
+ header_overrides: header_overrides,
54
+ sheet_id: sheet_id,
55
+ comment_id: comment_id
56
+ )
57
+ client.make_request(endpoint_spec, request_spec)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,77 @@
1
+ require 'smartsheet/api/file_spec'
2
+
3
+ module Smartsheet
4
+ class CommentsAttachments
5
+ attr_reader :client
6
+ private :client
7
+
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def attach_url(sheet_id:, comment_id:, body:, params: {}, header_overrides: {})
13
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
14
+ :post,
15
+ ['sheets', :sheet_id, 'comments', :comment_id, 'attachments'],
16
+ body_type: :json
17
+ )
18
+ request_spec = Smartsheet::API::RequestSpec.new(
19
+ header_overrides: header_overrides,
20
+ params: params,
21
+ body: body,
22
+ sheet_id: sheet_id,
23
+ comment_id: comment_id
24
+ )
25
+ client.make_request(endpoint_spec, request_spec)
26
+ end
27
+
28
+ def attach_file(
29
+ sheet_id:,
30
+ comment_id:,
31
+ file:,
32
+ filename:,
33
+ file_length:,
34
+ content_type: '',
35
+ params: {},
36
+ header_overrides: {}
37
+ )
38
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
39
+ :post,
40
+ ['sheets', :sheet_id, 'comments', :comment_id, 'attachments'],
41
+ body_type: :file
42
+ )
43
+ request_spec = Smartsheet::API::RequestSpec.new(
44
+ header_overrides: header_overrides,
45
+ params: params,
46
+ file_spec: Smartsheet::API::ObjectFileSpec.new(file, filename, file_length, content_type),
47
+ sheet_id: sheet_id,
48
+ comment_id: comment_id
49
+ )
50
+ client.make_request(endpoint_spec, request_spec)
51
+ end
52
+
53
+ def attach_file_from_path(
54
+ sheet_id:,
55
+ comment_id:,
56
+ path:,
57
+ filename: nil,
58
+ content_type: '',
59
+ params: {},
60
+ header_overrides: {}
61
+ )
62
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(
63
+ :post,
64
+ ['sheets', :sheet_id, 'comments', :comment_id, 'attachments'],
65
+ body_type: :file
66
+ )
67
+ request_spec = Smartsheet::API::RequestSpec.new(
68
+ header_overrides: header_overrides,
69
+ params: params,
70
+ file_spec: Smartsheet::API::PathFileSpec.new(path, filename, content_type),
71
+ sheet_id: sheet_id,
72
+ comment_id: comment_id
73
+ )
74
+ client.make_request(endpoint_spec, request_spec)
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,80 @@
1
+ require 'smartsheet/endpoints/sheets/discussions_attachments'
2
+
3
+ module Smartsheet
4
+ class Discussions
5
+ attr_reader :client, :attachments
6
+ private :client
7
+
8
+ def initialize(client)
9
+ @client = client
10
+
11
+ @attachments = DiscussionsAttachments.new(client)
12
+ end
13
+
14
+ def create_on_row(sheet_id:, row_id:, body:, params: {}, header_overrides: {})
15
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'rows', :row_id, 'discussions'], body_type: :json)
16
+ request_spec = Smartsheet::API::RequestSpec.new(
17
+ params: params,
18
+ header_overrides: header_overrides,
19
+ body: body,
20
+ sheet_id: sheet_id,
21
+ row_id: row_id
22
+ )
23
+ client.make_request(endpoint_spec, request_spec)
24
+ end
25
+
26
+ def create_on_sheet(sheet_id:, body:, params: {}, header_overrides: {})
27
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'discussions'], body_type: :json)
28
+ request_spec = Smartsheet::API::RequestSpec.new(
29
+ params: params,
30
+ header_overrides: header_overrides,
31
+ body: body,
32
+ sheet_id: sheet_id
33
+ )
34
+ client.make_request(endpoint_spec, request_spec)
35
+ end
36
+
37
+ def delete(sheet_id:, discussion_id:, params: {}, header_overrides: {})
38
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:delete, ['sheets', :sheet_id, 'discussions', :discussion_id])
39
+ request_spec = Smartsheet::API::RequestSpec.new(
40
+ params: params,
41
+ header_overrides: header_overrides,
42
+ sheet_id: sheet_id,
43
+ discussion_id: discussion_id
44
+ )
45
+ client.make_request(endpoint_spec, request_spec)
46
+ end
47
+
48
+ def list(sheet_id:, params: {}, header_overrides: {})
49
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id, 'discussions'])
50
+ request_spec = Smartsheet::API::RequestSpec.new(
51
+ header_overrides: header_overrides,
52
+ params: params,
53
+ sheet_id: sheet_id
54
+ )
55
+ client.make_request(endpoint_spec, request_spec)
56
+ end
57
+
58
+ def get(sheet_id:, discussion_id:, params: {}, header_overrides: {})
59
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id, 'discussions', :discussion_id])
60
+ request_spec = Smartsheet::API::RequestSpec.new(
61
+ params: params,
62
+ header_overrides: header_overrides,
63
+ sheet_id: sheet_id,
64
+ discussion_id: discussion_id
65
+ )
66
+ client.make_request(endpoint_spec, request_spec)
67
+ end
68
+
69
+ def list_row_discussions(sheet_id:, row_id:, params: {}, header_overrides: {})
70
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id, 'rows', :row_id, 'discussions'])
71
+ request_spec = Smartsheet::API::RequestSpec.new(
72
+ header_overrides: header_overrides,
73
+ params: params,
74
+ sheet_id: sheet_id,
75
+ row_id: row_id
76
+ )
77
+ client.make_request(endpoint_spec, request_spec)
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,21 @@
1
+ module Smartsheet
2
+ class DiscussionsAttachments
3
+ attr_reader :client
4
+ private :client
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ def list(sheet_id:, discussion_id:, params: {}, header_overrides: {})
11
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id, 'discussions', :discussion_id, 'attachments'])
12
+ request_spec = Smartsheet::API::RequestSpec.new(
13
+ params: params,
14
+ header_overrides: header_overrides,
15
+ sheet_id: sheet_id,
16
+ discussion_id: discussion_id
17
+ )
18
+ client.make_request(endpoint_spec, request_spec)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,91 @@
1
+ require 'smartsheet/endpoints/sheets/rows_attachments'
2
+
3
+ module Smartsheet
4
+ class Rows
5
+ attr_reader :client, :attachments
6
+ private :client
7
+
8
+ def initialize(client)
9
+ @client = client
10
+
11
+ @attachments = RowsAttachments.new(client)
12
+ end
13
+
14
+ def add(sheet_id:, body:, params: {}, header_overrides: {})
15
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'rows'], body_type: :json)
16
+ request_spec = Smartsheet::API::RequestSpec.new(
17
+ header_overrides: header_overrides,
18
+ params: params,
19
+ body: body,
20
+ sheet_id: sheet_id
21
+ )
22
+ client.make_request(endpoint_spec, request_spec)
23
+ end
24
+
25
+ def copy_to_another_sheet(sheet_id:, body:, params: {}, header_overrides: {})
26
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'rows', 'copy'], body_type: :json)
27
+ request_spec = Smartsheet::API::RequestSpec.new(
28
+ header_overrides: header_overrides,
29
+ body: body,
30
+ params: params,
31
+ sheet_id: sheet_id
32
+ )
33
+ client.make_request(endpoint_spec, request_spec)
34
+ end
35
+
36
+ def delete(sheet_id:, row_ids:, params: {}, header_overrides: {})
37
+ params[:ids] = row_ids.join(',')
38
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:delete, ['sheets', :sheet_id, 'rows'])
39
+ request_spec = Smartsheet::API::RequestSpec.new(
40
+ header_overrides: header_overrides,
41
+ params: params,
42
+ sheet_id: sheet_id
43
+ )
44
+ client.make_request(endpoint_spec, request_spec)
45
+ end
46
+
47
+ def get(sheet_id:, row_id:, params: {}, header_overrides: {})
48
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['sheets', :sheet_id, 'rows', :row_id])
49
+ request_spec = Smartsheet::API::RequestSpec.new(
50
+ header_overrides: header_overrides,
51
+ params: params,
52
+ sheet_id: sheet_id,
53
+ row_id: row_id
54
+ )
55
+ client.make_request(endpoint_spec, request_spec)
56
+ end
57
+
58
+ def move_to_another_sheet(sheet_id:, body:, params: {}, header_overrides: {})
59
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'rows', 'move'], body_type: :json)
60
+ request_spec = Smartsheet::API::RequestSpec.new(
61
+ header_overrides: header_overrides,
62
+ body: body,
63
+ params: params,
64
+ sheet_id: sheet_id
65
+ )
66
+ client.make_request(endpoint_spec, request_spec)
67
+ end
68
+
69
+ def send_via_email(sheet_id:, body:, params: {}, header_overrides: {})
70
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:post, ['sheets', :sheet_id, 'rows', 'emails'], body_type: :json)
71
+ request_spec = Smartsheet::API::RequestSpec.new(
72
+ header_overrides: header_overrides,
73
+ params: params,
74
+ body: body,
75
+ sheet_id: sheet_id
76
+ )
77
+ client.make_request(endpoint_spec, request_spec)
78
+ end
79
+
80
+ def update(sheet_id:, body:, params: {}, header_overrides: {})
81
+ endpoint_spec = Smartsheet::API::EndpointSpec.new(:put, ['sheets', :sheet_id, 'rows'], body_type: :json)
82
+ request_spec = Smartsheet::API::RequestSpec.new(
83
+ header_overrides: header_overrides,
84
+ body: body,
85
+ params: params,
86
+ sheet_id: sheet_id
87
+ )
88
+ client.make_request(endpoint_spec, request_spec)
89
+ end
90
+ end
91
+ end