smartsheet 1.0.0.beta.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +4 -0
- data/README.md +4 -3
- data/Rakefile +11 -1
- data/lib/smartsheet/api/endpoint_spec.rb +1 -0
- data/lib/smartsheet/api/faraday_adapter/faraday_net_client.rb +1 -0
- data/lib/smartsheet/api/faraday_adapter/faraday_response.rb +22 -12
- data/lib/smartsheet/api/faraday_adapter/middleware/faraday_error_translator.rb +1 -0
- data/lib/smartsheet/api/faraday_adapter/middleware/response_parser.rb +1 -0
- data/lib/smartsheet/api/file_spec.rb +3 -0
- data/lib/smartsheet/api/request.rb +1 -0
- data/lib/smartsheet/api/request_client.rb +2 -0
- data/lib/smartsheet/api/request_logger.rb +18 -2
- data/lib/smartsheet/api/request_spec.rb +1 -0
- data/lib/smartsheet/api/response_net_client_decorator.rb +10 -2
- data/lib/smartsheet/api/retry_logic.rb +3 -0
- data/lib/smartsheet/api/retry_net_client_decorator.rb +2 -0
- data/lib/smartsheet/api/url_builder.rb +1 -1
- data/lib/smartsheet/client.rb +64 -4
- data/lib/smartsheet/constants.rb +1 -1
- data/lib/smartsheet/endpoints/contacts/contacts.rb +2 -0
- data/lib/smartsheet/endpoints/favorites/favorites.rb +4 -2
- data/lib/smartsheet/endpoints/folders/folders.rb +2 -0
- data/lib/smartsheet/endpoints/groups/groups.rb +2 -0
- data/lib/smartsheet/endpoints/home/home.rb +2 -0
- data/lib/smartsheet/endpoints/reports/reports.rb +5 -0
- data/lib/smartsheet/endpoints/reports/reports_share.rb +2 -0
- data/lib/smartsheet/endpoints/search/search.rb +2 -0
- data/lib/smartsheet/endpoints/server_info/server_info.rb +3 -0
- data/lib/smartsheet/endpoints/share/share.rb +1 -0
- data/lib/smartsheet/endpoints/sheets/cells.rb +2 -0
- data/lib/smartsheet/endpoints/sheets/columns.rb +2 -0
- data/lib/smartsheet/endpoints/sheets/comments.rb +5 -0
- data/lib/smartsheet/endpoints/sheets/comments_attachments.rb +2 -0
- data/lib/smartsheet/endpoints/sheets/discussions.rb +5 -0
- data/lib/smartsheet/endpoints/sheets/discussions_attachments.rb +2 -0
- data/lib/smartsheet/endpoints/sheets/rows.rb +5 -0
- data/lib/smartsheet/endpoints/sheets/rows_attachments.rb +2 -0
- data/lib/smartsheet/endpoints/sheets/sheets.rb +17 -1
- data/lib/smartsheet/endpoints/sheets/sheets_attachments.rb +2 -0
- data/lib/smartsheet/endpoints/sheets/sheets_share.rb +2 -0
- data/lib/smartsheet/endpoints/sights/sights.rb +5 -0
- data/lib/smartsheet/endpoints/sights/sights_share.rb +2 -0
- data/lib/smartsheet/endpoints/templates/templates.rb +2 -0
- data/lib/smartsheet/endpoints/token/token.rb +4 -0
- data/lib/smartsheet/endpoints/update_requests/sent_update_requests.rb +3 -0
- data/lib/smartsheet/endpoints/update_requests/update_requests.rb +6 -0
- data/lib/smartsheet/endpoints/users/alternate_emails.rb +3 -0
- data/lib/smartsheet/endpoints/users/users.rb +5 -0
- data/lib/smartsheet/endpoints/webhooks/webhooks.rb +2 -0
- data/lib/smartsheet/endpoints/workspaces/workspaces.rb +5 -0
- data/lib/smartsheet/endpoints/workspaces/workspaces_share.rb +3 -0
- data/lib/smartsheet/error.rb +42 -2
- data/lib/smartsheet/general_request.rb +22 -0
- data/smartsheet.gemspec +4 -2
- metadata +48 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10a882532db917a8387dc14379d177779e009ad8
|
4
|
+
data.tar.gz: 7c69eb5bef6f194255a9d40cddb0729d68002b4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 812b0a9e9a550ef012e4b32d270c74fad85f1d72f9a927290726945668ea922c3d05a9e2857a0bca4eacec4e8a81f3b2d44f759d99954da8c2e541448c0ff118
|
7
|
+
data.tar.gz: 78f793670867124aca8184428039b2bc8361a024df856c9f774e5da178c086ed047f2c3e6c8344d603197d3dbcc458171deb1eedf9ec5f05734d554831baa715
|
data/.yardopts
ADDED
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
This is an SDK to simplify connecting to the [Smartsheet API](http://www.smartsheet.com/developers/api-documentation) from Ruby applications.
|
4
4
|
|
5
|
-
*Please note that this SDK is beta and may change significantly in the future.*
|
6
|
-
|
7
5
|
## System Requirements
|
8
6
|
|
9
7
|
The SDK supports Ruby versions 2.2 or later.
|
@@ -13,7 +11,7 @@ The SDK supports Ruby versions 2.2 or later.
|
|
13
11
|
Add this line to your application's Gemfile:
|
14
12
|
|
15
13
|
```ruby
|
16
|
-
gem 'smartsheet', '>= 1.0.0
|
14
|
+
gem 'smartsheet', '>= 1.0.0'
|
17
15
|
```
|
18
16
|
|
19
17
|
And then execute:
|
@@ -134,6 +132,9 @@ If you have any questions or issues with this SDK please post on [Stack Overflow
|
|
134
132
|
|
135
133
|
Each specific release is available for download via [GitHub](https://github.com/smartsheet-platform/smartsheet-ruby-sdk/tags).
|
136
134
|
|
135
|
+
**v1.0.0 (Nov 2017)**
|
136
|
+
Full release
|
137
|
+
|
137
138
|
**v1.0.0.beta (October 2017)**
|
138
139
|
Beta release of the Smartsheet SDK for Ruby
|
139
140
|
|
data/Rakefile
CHANGED
@@ -2,12 +2,22 @@ require 'bundler/gem_tasks'
|
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rubycritic/rake_task'
|
4
4
|
|
5
|
-
|
5
|
+
|
6
|
+
Rake::TestTask.new do |t|
|
6
7
|
t.libs << 'test'
|
7
8
|
t.libs << 'lib'
|
8
9
|
t.test_files = FileList['test/**/*_test.rb']
|
9
10
|
end
|
10
11
|
|
12
|
+
namespace :test do
|
13
|
+
Rake::TestTask.new(:units) do |t|
|
14
|
+
t.libs << 'test'
|
15
|
+
t.pattern = 'test/unit/**/*_test.rb'
|
16
|
+
t.verbose = true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
11
21
|
RubyCritic::RakeTask.new
|
12
22
|
|
13
23
|
task default: :test
|
@@ -1,30 +1,39 @@
|
|
1
1
|
module Smartsheet
|
2
2
|
module API
|
3
|
+
# Builds response objects from Faraday response environments
|
3
4
|
class FaradayResponse
|
4
|
-
def self.from_response_env(
|
5
|
-
if
|
6
|
-
FaradayErrorResponse.new(
|
5
|
+
def self.from_response_env(faraday_env)
|
6
|
+
if faraday_env[:body].kind_of?(Hash) && faraday_env[:body].key?(:errorCode)
|
7
|
+
FaradayErrorResponse.new(faraday_env[:body], faraday_env)
|
8
|
+
elsif faraday_env.success?
|
9
|
+
FaradaySuccessResponse.new(faraday_env[:body], faraday_env)
|
7
10
|
else
|
8
|
-
|
11
|
+
raise HttpResponseError.new(
|
12
|
+
status_code: faraday_env[:status],
|
13
|
+
reason_phrase: faraday_env[:reason_phrase],
|
14
|
+
headers: faraday_env[:response_headers],
|
15
|
+
message: "#{faraday_env[:status]} #{faraday_env[:reason_phrase]}"
|
16
|
+
)
|
9
17
|
end
|
10
18
|
end
|
11
19
|
|
12
20
|
attr_reader :status_code, :reason_phrase, :headers
|
13
21
|
|
14
|
-
def initialize(
|
15
|
-
@status_code =
|
16
|
-
@reason_phrase =
|
17
|
-
@headers =
|
22
|
+
def initialize(faraday_env)
|
23
|
+
@status_code = faraday_env[:status]
|
24
|
+
@reason_phrase = faraday_env[:reason_phrase]
|
25
|
+
@headers = faraday_env[:response_headers]
|
18
26
|
end
|
19
27
|
end
|
20
28
|
|
29
|
+
# Provides a Smartsheet error response from a Faraday response environment
|
21
30
|
class FaradayErrorResponse < FaradayResponse
|
22
31
|
RETRYABLE_ERRORS = 4001..4004
|
23
32
|
|
24
33
|
attr_reader :error_code, :message, :ref_id, :detail
|
25
34
|
|
26
|
-
def initialize(result,
|
27
|
-
super(
|
35
|
+
def initialize(result, faraday_env)
|
36
|
+
super(faraday_env)
|
28
37
|
@error_code = result[:errorCode]
|
29
38
|
@message = result[:message]
|
30
39
|
@ref_id = result[:refId]
|
@@ -40,11 +49,12 @@ module Smartsheet
|
|
40
49
|
end
|
41
50
|
end
|
42
51
|
|
52
|
+
# Provides a Smartsheet success response from a Faraday response environment
|
43
53
|
class FaradaySuccessResponse < FaradayResponse
|
44
54
|
attr_reader :result
|
45
55
|
|
46
|
-
def initialize(result,
|
47
|
-
super(
|
56
|
+
def initialize(result, faraday_env)
|
57
|
+
super(faraday_env)
|
48
58
|
@result = result
|
49
59
|
end
|
50
60
|
|
@@ -5,6 +5,7 @@ require 'smartsheet/api/faraday_adapter/faraday_response'
|
|
5
5
|
module Smartsheet
|
6
6
|
module API
|
7
7
|
module Middleware
|
8
|
+
# Wraps responses into {FaradayResponse FaradayResponses}, parsing JSON bodies when applicable
|
8
9
|
class ResponseParser < Faraday::Middleware
|
9
10
|
def initialize(app)
|
10
11
|
super(app)
|
@@ -3,6 +3,7 @@ require 'faraday'
|
|
3
3
|
|
4
4
|
module Smartsheet
|
5
5
|
module API
|
6
|
+
# Specification for a file attachment by path, target filename, and MIME content type
|
6
7
|
class PathFileSpec
|
7
8
|
attr_reader :upload_io, :filename, :content_type, :file_length
|
8
9
|
|
@@ -14,6 +15,8 @@ module Smartsheet
|
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
18
|
+
# Specification for a file attachment by {::File}, target filename, file length, and MIME
|
19
|
+
# content type
|
17
20
|
class ObjectFileSpec
|
18
21
|
attr_reader :upload_io, :filename, :content_type, :file_length
|
19
22
|
|
@@ -2,6 +2,8 @@ require 'smartsheet/error'
|
|
2
2
|
|
3
3
|
module Smartsheet
|
4
4
|
module API
|
5
|
+
# Composes {EndpointSpec endpoint specifications} and {RequestSpec request specifications} to
|
6
|
+
# form a single {Request} that it submits to the provided client
|
5
7
|
class RequestClient
|
6
8
|
def initialize(token, client, base_url, assume_user: nil, logger: MuteRequestLogger.new)
|
7
9
|
@token = token
|
@@ -2,6 +2,7 @@ require 'logger'
|
|
2
2
|
|
3
3
|
module Smartsheet
|
4
4
|
module API
|
5
|
+
# Censors strings and hash values for select blacklisted keys
|
5
6
|
class Censor
|
6
7
|
EXPOSED_CHARS = 4
|
7
8
|
KEY_TO_STRING = ->(k){ k.to_s }
|
@@ -45,6 +46,7 @@ module Smartsheet
|
|
45
46
|
attr_reader :blacklist
|
46
47
|
end
|
47
48
|
|
49
|
+
# Logs request and response information, while censoring OAuth-relevant keys
|
48
50
|
class RequestLogger
|
49
51
|
QUERY_PARAM_CENSOR = Censor.new 'code', 'client_id', 'hash', 'refresh_token'
|
50
52
|
HEADER_CENSOR = Censor.new 'authorization'
|
@@ -80,11 +82,16 @@ module Smartsheet
|
|
80
82
|
log_body('Response', response.result)
|
81
83
|
end
|
82
84
|
|
83
|
-
def
|
85
|
+
def log_api_error_response(request, error)
|
84
86
|
log_request_basics(Logger::ERROR, request)
|
85
87
|
log_api_error(Logger::ERROR, error)
|
86
88
|
end
|
87
89
|
|
90
|
+
def log_http_error_response(request, error)
|
91
|
+
log_request_basics(Logger::ERROR, request)
|
92
|
+
log_http_error(Logger::ERROR, error)
|
93
|
+
end
|
94
|
+
|
88
95
|
private
|
89
96
|
|
90
97
|
attr_reader :logger, :log_full_body
|
@@ -112,6 +119,11 @@ module Smartsheet
|
|
112
119
|
log_headers('Response', response)
|
113
120
|
end
|
114
121
|
|
122
|
+
def log_http_error(level, response)
|
123
|
+
log_status(level, response)
|
124
|
+
log_headers('Response', response)
|
125
|
+
end
|
126
|
+
|
115
127
|
def log_status(level, response)
|
116
128
|
logger.log(level) { "Response: #{response.status_code} #{response.reason_phrase}" }
|
117
129
|
end
|
@@ -147,6 +159,7 @@ module Smartsheet
|
|
147
159
|
end
|
148
160
|
end
|
149
161
|
|
162
|
+
# Stubs all request logging methods by doing nothing (see {RequestLogger})
|
150
163
|
class MuteRequestLogger
|
151
164
|
def log_request(request)
|
152
165
|
end
|
@@ -160,7 +173,10 @@ module Smartsheet
|
|
160
173
|
def log_successful_response(response)
|
161
174
|
end
|
162
175
|
|
163
|
-
def
|
176
|
+
def log_api_error_response(request, error)
|
177
|
+
end
|
178
|
+
|
179
|
+
def log_http_error_response(request, error)
|
164
180
|
end
|
165
181
|
end
|
166
182
|
end
|
@@ -4,6 +4,7 @@ require 'smartsheet/error'
|
|
4
4
|
|
5
5
|
module Smartsheet
|
6
6
|
module API
|
7
|
+
# Passes requests to the decorated client, and parses responses into expected result types
|
7
8
|
class ResponseNetClientDecorator
|
8
9
|
def initialize(client, json_output: false, logger: MuteRequestLogger.new)
|
9
10
|
@json_output = json_output
|
@@ -12,7 +13,14 @@ module Smartsheet
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def make_request(request)
|
15
|
-
|
16
|
+
response = begin
|
17
|
+
client.make_request(request)
|
18
|
+
rescue Smartsheet::HttpResponseError => e
|
19
|
+
logger.log_http_error_response(request, e)
|
20
|
+
raise e
|
21
|
+
end
|
22
|
+
|
23
|
+
parse(request, response)
|
16
24
|
end
|
17
25
|
|
18
26
|
private
|
@@ -24,7 +32,7 @@ module Smartsheet
|
|
24
32
|
logger.log_successful_response(response)
|
25
33
|
parse_success(response)
|
26
34
|
else
|
27
|
-
logger.
|
35
|
+
logger.log_api_error_response(request, response)
|
28
36
|
parse_failure(response)
|
29
37
|
end
|
30
38
|
end
|
@@ -2,6 +2,9 @@ require 'smartsheet/constants'
|
|
2
2
|
|
3
3
|
module Smartsheet
|
4
4
|
module API
|
5
|
+
# Accepts a callable proc and a predicate, calling the proc repeatedly with backoff until the
|
6
|
+
# provided time limit is reached, or until the predicate applied to the proc's result returns
|
7
|
+
# false.
|
5
8
|
class RetryLogic
|
6
9
|
include Smartsheet::Constants
|
7
10
|
|
@@ -2,6 +2,8 @@ require 'smartsheet/api/request_logger'
|
|
2
2
|
|
3
3
|
module Smartsheet
|
4
4
|
module API
|
5
|
+
# Passes requests to the decorated client, retrying the request based on the provided
|
6
|
+
# {RetryLogic} when retry-eligible errors arise
|
5
7
|
class RetryNetClientDecorator
|
6
8
|
SHOULD_RETRY = ->(response) { response.should_retry? }
|
7
9
|
|
@@ -2,7 +2,7 @@ require 'smartsheet/constants'
|
|
2
2
|
|
3
3
|
module Smartsheet
|
4
4
|
module API
|
5
|
-
#
|
5
|
+
# Constructs parameterized URLs for accessing the Smartsheet API
|
6
6
|
class UrlBuilder
|
7
7
|
def initialize(endpoint_spec, request_spec, base_url)
|
8
8
|
@segments = endpoint_spec.url_segments
|
data/lib/smartsheet/client.rb
CHANGED
@@ -25,6 +25,41 @@ require 'smartsheet/endpoints/workspaces/workspaces'
|
|
25
25
|
|
26
26
|
|
27
27
|
module Smartsheet
|
28
|
+
# The entry point to the SDK. API endpoint categories are accessed through this object's readable
|
29
|
+
# attributes.
|
30
|
+
#
|
31
|
+
# @!attribute [r] contacts
|
32
|
+
# @return [Contacts]
|
33
|
+
# @!attribute [r] favorites
|
34
|
+
# @return [Favorites]
|
35
|
+
# @!attribute [r] folders
|
36
|
+
# @return [Folders]
|
37
|
+
# @!attribute [r] groups
|
38
|
+
# @return [Groups]
|
39
|
+
# @!attribute [r] home
|
40
|
+
# @return [Home]
|
41
|
+
# @!attribute [r] reports
|
42
|
+
# @return [Reports]
|
43
|
+
# @!attribute [r] search
|
44
|
+
# @return [Search]
|
45
|
+
# @!attribute [r] server_info
|
46
|
+
# @return [ServerInfo]
|
47
|
+
# @!attribute [r] sheets
|
48
|
+
# @return [Sheets]
|
49
|
+
# @!attribute [r] sights
|
50
|
+
# @return [Sights]
|
51
|
+
# @!attribute [r] templates
|
52
|
+
# @return [Templates]
|
53
|
+
# @!attribute [r] token
|
54
|
+
# @return [Token]
|
55
|
+
# @!attribute [r] update_requests
|
56
|
+
# @return [UpdateRequests]
|
57
|
+
# @!attribute [r] users
|
58
|
+
# @return [Users]
|
59
|
+
# @!attribute [r] webhooks
|
60
|
+
# @return [Webhooks]
|
61
|
+
# @!attribute [r] workspaces
|
62
|
+
# @return [Workspaces]
|
28
63
|
class Client
|
29
64
|
include GeneralRequest
|
30
65
|
include Smartsheet::Constants
|
@@ -33,14 +68,40 @@ module Smartsheet
|
|
33
68
|
:sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
|
34
69
|
:workspaces
|
35
70
|
|
71
|
+
# @param token [String] access token for the API; if nil or empty, uses environment variable
|
72
|
+
# `SMARTSHEET_ACCESS_TOKEN`
|
73
|
+
# @param logger [Logger] a logger to which request and response info will be recorded
|
74
|
+
# @param log_full_body [Boolean] when true, request and response bodies will not be truncated in
|
75
|
+
# the logs
|
76
|
+
# @param json_output [Boolean] when true, endpoints return raw JSON strings instead of hashes
|
77
|
+
# @param assume_user [String] the email address of the user to impersonate; only available for
|
78
|
+
# admin roles
|
79
|
+
# @param max_retry_time [Fixnum] overrides the maximum number of seconds during which eligible
|
80
|
+
# errors will be retried
|
81
|
+
# @param backoff_method [Proc] overrides the backoff calculation method, accepting the index of
|
82
|
+
# the current retry attempt (0-based) and returning the number of seconds to wait before
|
83
|
+
# retrying the call again, or `:stop` to halt retrying and return the latest error.
|
84
|
+
#
|
85
|
+
# Example - Wait 1 second before the first retry, 2 seconds before
|
86
|
+
# the second, and so on:
|
87
|
+
# ```ruby
|
88
|
+
# ->(x){ x + 1 }
|
89
|
+
# ```
|
90
|
+
#
|
91
|
+
# Example - Try twice, then halt:
|
92
|
+
# ```ruby
|
93
|
+
# ->(x){ if x < 2 then x + 1 else :stop end }
|
94
|
+
# ```
|
95
|
+
# @param base_url [String] overrides the base URL used when constructing API calls; for example,
|
96
|
+
# the default takes the form of `https://api.smartsheet.com/2.0`
|
36
97
|
def initialize(
|
37
98
|
token: nil,
|
38
|
-
|
99
|
+
logger: nil,
|
100
|
+
log_full_body: false,
|
39
101
|
json_output: false,
|
102
|
+
assume_user: nil,
|
40
103
|
max_retry_time: nil,
|
41
104
|
backoff_method: nil,
|
42
|
-
logger: nil,
|
43
|
-
log_full_body: false,
|
44
105
|
base_url: API_URL
|
45
106
|
)
|
46
107
|
|
@@ -74,7 +135,6 @@ module Smartsheet
|
|
74
135
|
assume_user: assume_user,
|
75
136
|
logger: request_logger
|
76
137
|
)
|
77
|
-
|
78
138
|
build_categories
|
79
139
|
end
|
80
140
|
|
data/lib/smartsheet/constants.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module Smartsheet
|
2
|
+
# Favorites Endpoints
|
3
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#favorites API Favorites Docs
|
2
4
|
class Favorites
|
3
5
|
attr_reader :client
|
4
6
|
private :client
|
@@ -55,7 +57,7 @@ module Smartsheet
|
|
55
57
|
|
56
58
|
def remove_sight(sight_id:, params: {}, header_overrides: {})
|
57
59
|
remove_favorite(
|
58
|
-
url: ['
|
60
|
+
url: ['sight', :sight_id],
|
59
61
|
params: params,
|
60
62
|
header_overrides: header_overrides,
|
61
63
|
sight_id: sight_id
|
@@ -109,7 +111,7 @@ module Smartsheet
|
|
109
111
|
|
110
112
|
def remove_sights(sight_ids:, params: {}, header_overrides: {})
|
111
113
|
remove_favorites(
|
112
|
-
url: ['
|
114
|
+
url: ['sight'],
|
113
115
|
params: params,
|
114
116
|
header_overrides: header_overrides,
|
115
117
|
object_ids: sight_ids
|
@@ -3,6 +3,11 @@ require 'smartsheet/constants'
|
|
3
3
|
require_relative 'reports_share'
|
4
4
|
|
5
5
|
module Smartsheet
|
6
|
+
# Reports Endpoints
|
7
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#reports API Reports Docs
|
8
|
+
#
|
9
|
+
# @!attribute [r] share
|
10
|
+
# @return [ReportsShare]
|
6
11
|
class Reports
|
7
12
|
include Smartsheet::Constants
|
8
13
|
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'smartsheet/endpoints/sheets/comments_attachments'
|
2
2
|
|
3
3
|
module Smartsheet
|
4
|
+
# Comments Endpoints
|
5
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#comments API Comments Docs
|
6
|
+
#
|
7
|
+
# @!attribute [r] attachments
|
8
|
+
# @return [CommentsAttachments]
|
4
9
|
class Comments
|
5
10
|
attr_reader :client, :attachments
|
6
11
|
private :client
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'smartsheet/endpoints/sheets/discussions_attachments'
|
2
2
|
|
3
3
|
module Smartsheet
|
4
|
+
# Discussions Endpoints
|
5
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#discussions API Discussions Docs
|
6
|
+
#
|
7
|
+
# @!attribute [r] attachments
|
8
|
+
# @return [DiscussionsAttachments]
|
4
9
|
class Discussions
|
5
10
|
attr_reader :client, :attachments
|
6
11
|
private :client
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'smartsheet/endpoints/sheets/rows_attachments'
|
2
2
|
|
3
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]
|
4
9
|
class Rows
|
5
10
|
attr_reader :client, :attachments
|
6
11
|
private :client
|
@@ -11,7 +11,23 @@ require 'smartsheet/endpoints/sheets/sheets_attachments'
|
|
11
11
|
require 'smartsheet/endpoints/sheets/sheets_share'
|
12
12
|
|
13
13
|
module Smartsheet
|
14
|
-
#
|
14
|
+
# Sheets Endpoints
|
15
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#sheets API Sheets Docs
|
16
|
+
#
|
17
|
+
# @!attribute [r] attachments
|
18
|
+
# @return [SheetsAttachments]
|
19
|
+
# @!attribute [r] cells
|
20
|
+
# @return [Cells]
|
21
|
+
# @!attribute [r] columns
|
22
|
+
# @return [Columns]
|
23
|
+
# @!attribute [r] comments
|
24
|
+
# @return [Comments]
|
25
|
+
# @!attribute [r] discussions
|
26
|
+
# @return [Discussions]
|
27
|
+
# @!attribute [r] rows
|
28
|
+
# @return [Rows]
|
29
|
+
# @!attribute [r] share
|
30
|
+
# @return [SheetsShare]
|
15
31
|
class Sheets
|
16
32
|
include Smartsheet::Constants
|
17
33
|
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require_relative 'sights_share'
|
2
2
|
|
3
3
|
module Smartsheet
|
4
|
+
# Sights Endpoints
|
5
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#sights API Sights Docs
|
6
|
+
#
|
7
|
+
# @!attribute [r] share
|
8
|
+
# @return [SightsShare]
|
4
9
|
class Sights
|
5
10
|
attr_reader :client, :share
|
6
11
|
private :client
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'digest'
|
2
2
|
|
3
3
|
module Smartsheet
|
4
|
+
# Token Endpoints
|
5
|
+
#
|
6
|
+
# {#get} and {#refresh} do not require an existing token to call
|
7
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#token API Token Docs
|
4
8
|
class Token
|
5
9
|
attr_reader :client
|
6
10
|
private :client
|
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'smartsheet/endpoints/update_requests/sent_update_requests'
|
2
2
|
|
3
3
|
module Smartsheet
|
4
|
+
# Update Requests Endpoints
|
5
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#update-requests API Update Requests
|
6
|
+
# Docs
|
7
|
+
#
|
8
|
+
# @!attribute [r] sent
|
9
|
+
# @return [SentUpdateRequests]
|
4
10
|
class UpdateRequests
|
5
11
|
attr_reader :client, :sent
|
6
12
|
private :client
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require_relative 'alternate_emails'
|
2
2
|
|
3
3
|
module Smartsheet
|
4
|
+
# Users Endpoints
|
5
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#users API Users Docs
|
6
|
+
#
|
7
|
+
# @!attribute [r] alternate_emails
|
8
|
+
# @return [AlternateEmails]
|
4
9
|
class Users
|
5
10
|
attr_reader :client, :alternate_emails
|
6
11
|
private :client
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require_relative 'workspaces_share'
|
2
2
|
|
3
3
|
module Smartsheet
|
4
|
+
# Workspaces Endpoints
|
5
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#workspaces API Workspaces Docs
|
6
|
+
#
|
7
|
+
# @!attribute [r] share
|
8
|
+
# @return [WorkspacesShare]
|
4
9
|
class Workspaces
|
5
10
|
attr_reader :client, :share
|
6
11
|
private :client
|
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'smartsheet/endpoints/share/share'
|
2
2
|
|
3
3
|
module Smartsheet
|
4
|
+
# Workspace Sharing Endpoints
|
5
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#workspace-sharing API Workspace
|
6
|
+
# Sharing Docs
|
4
7
|
class WorkspacesShare
|
5
8
|
attr_reader :client
|
6
9
|
private :client
|
data/lib/smartsheet/error.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'forwardable'
|
2
2
|
|
3
3
|
module Smartsheet
|
4
|
+
# Top-level Smartsheet Error
|
4
5
|
class Error < StandardError; end
|
5
6
|
|
6
7
|
# Errors for invalid requests, timeouts, etc.
|
@@ -13,11 +14,50 @@ module Smartsheet
|
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
|
-
|
17
|
+
# Errors for generic HTTP error codes
|
18
|
+
# @!attribute [r] status_code
|
19
|
+
# @return [Fixnum] HTTP status code
|
20
|
+
# @!attribute [r] reason_phrase
|
21
|
+
# @return [String] HTTP reason phrase
|
22
|
+
# @!attribute [r] headers
|
23
|
+
# @return [Hash] HTTP response headers
|
24
|
+
class HttpResponseError < Error
|
25
|
+
attr_reader :status_code, :reason_phrase, :headers
|
26
|
+
|
27
|
+
def initialize(status_code:, reason_phrase:, headers:, message:)
|
28
|
+
super(message)
|
29
|
+
|
30
|
+
@status_code = status_code
|
31
|
+
@reason_phrase = reason_phrase
|
32
|
+
@headers = headers
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Errors for Smartsheet API error objects
|
37
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#error-object API Error Object Docs
|
38
|
+
#
|
39
|
+
# @!attribute [r] error_code
|
40
|
+
# @return [Fixnum] Smartsheet error code
|
41
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#complete-error-code-list API Error
|
42
|
+
# Code Docs
|
43
|
+
# @!attribute [r] message
|
44
|
+
# @return [String] Smartsheet error message
|
45
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#complete-error-code-list API Error
|
46
|
+
# Code Docs
|
47
|
+
# @!attribute [r] ref_id
|
48
|
+
# @return [String] Smartsheet error reference ID
|
49
|
+
# @!attribute [r] detail
|
50
|
+
# @return [Hash, Array, nil] optional details for some error scenarios
|
51
|
+
class ApiError < HttpResponseError
|
17
52
|
extend Forwardable
|
18
53
|
|
19
54
|
def initialize(error_response)
|
20
|
-
super(
|
55
|
+
super(
|
56
|
+
status_code: error_response.status_code,
|
57
|
+
reason_phrase: error_response.reason_phrase,
|
58
|
+
headers: error_response.headers,
|
59
|
+
message: error_response.message
|
60
|
+
)
|
21
61
|
@error_response = error_response
|
22
62
|
end
|
23
63
|
|
@@ -2,6 +2,9 @@ require 'smartsheet/api/file_spec'
|
|
2
2
|
|
3
3
|
module Smartsheet
|
4
4
|
module GeneralRequest
|
5
|
+
# Create a custom request using a provided method and URL path
|
6
|
+
# @example Make a GET request to 'https://api.smartsheet.com/2.0/sheets/list'
|
7
|
+
# client.request(method: :get, url_path: 'sheets/list')
|
5
8
|
def request(method:, url_path:, body: nil, params: {}, header_overrides: {})
|
6
9
|
spec = body.nil? ? {} : {body_type: :json}
|
7
10
|
endpoint_spec = Smartsheet::API::EndpointSpec.new(method, [url_path], **spec)
|
@@ -13,6 +16,16 @@ module Smartsheet
|
|
13
16
|
client.make_request(endpoint_spec, request_spec)
|
14
17
|
end
|
15
18
|
|
19
|
+
# Create a custom request using a provided method, URL path, and file details
|
20
|
+
# @example Make a POST request to 'https://api.smartsheet.com/2.0/sheets/1/attachments' with a file
|
21
|
+
# client.request_with_file(
|
22
|
+
# method: :get,
|
23
|
+
# url_path: 'sheets/1/attachments',
|
24
|
+
# file: File.open('my-file.docx'),
|
25
|
+
# file_length: 1000,
|
26
|
+
# filename: 'my-uploaded-file.docx',
|
27
|
+
# content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
28
|
+
# )
|
16
29
|
def request_with_file(
|
17
30
|
method:,
|
18
31
|
url_path:,
|
@@ -32,6 +45,15 @@ module Smartsheet
|
|
32
45
|
client.make_request(endpoint_spec, request_spec)
|
33
46
|
end
|
34
47
|
|
48
|
+
# Create a custom request using a provided method, URL path, and filepath details
|
49
|
+
# @example Make a POST request to 'https://api.smartsheet.com/2.0/sheets/1/attachments' with a file
|
50
|
+
# client.request_with_file_from_path(
|
51
|
+
# method: :get,
|
52
|
+
# url_path: 'sheets/1/attachments',
|
53
|
+
# path: './my-file.docx',
|
54
|
+
# filename: 'my-uploaded-file.docx',
|
55
|
+
# content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
56
|
+
# )
|
35
57
|
def request_with_file_from_path(
|
36
58
|
method:,
|
37
59
|
url_path:,
|
data/smartsheet.gemspec
CHANGED
@@ -14,7 +14,6 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.description = <<-EOF
|
15
15
|
This is an SDK to simplify connecting to the Smartsheet API
|
16
16
|
(http://www.smartsheet.com/developers/api-documentation) from Ruby applications.
|
17
|
-
Please note that this SDK is beta and may change significantly in the future.
|
18
17
|
EOF
|
19
18
|
spec.homepage = 'https://github.com/smartsheet-platform/smartsheet-ruby-sdk'
|
20
19
|
spec.license = 'Apache-2.0'
|
@@ -32,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
32
31
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
32
|
spec.require_paths = ['lib']
|
34
33
|
|
35
|
-
spec.required_ruby_version = '
|
34
|
+
spec.required_ruby_version = '~> 2.2'
|
36
35
|
|
37
36
|
spec.add_dependency 'faraday', '~> 0.13.1'
|
38
37
|
spec.add_dependency 'plissken', '~> 1.2'
|
@@ -47,4 +46,7 @@ Gem::Specification.new do |spec|
|
|
47
46
|
spec.add_development_dependency 'rubocop', '~> 0.49.1'
|
48
47
|
spec.add_development_dependency 'reek', '~> 4.7'
|
49
48
|
spec.add_development_dependency 'rubycritic', '~> 3.2'
|
49
|
+
spec.add_development_dependency 'yard', '~> 0.9'
|
50
|
+
spec.add_development_dependency 'redcarpet', '~> 3.4'
|
51
|
+
spec.add_development_dependency 'github-markup', '~> 1.6'
|
50
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartsheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Smartsheet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -178,10 +178,51 @@ dependencies:
|
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '3.2'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: yard
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0.9'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0.9'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: redcarpet
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '3.4'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '3.4'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: github-markup
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '1.6'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '1.6'
|
181
223
|
description: |2
|
182
224
|
This is an SDK to simplify connecting to the Smartsheet API
|
183
225
|
(http://www.smartsheet.com/developers/api-documentation) from Ruby applications.
|
184
|
-
Please note that this SDK is beta and may change significantly in the future.
|
185
226
|
email: api@smartsheet.com
|
186
227
|
executables: []
|
187
228
|
extensions: []
|
@@ -190,6 +231,7 @@ files:
|
|
190
231
|
- ".gitignore"
|
191
232
|
- ".rubocop.yml"
|
192
233
|
- ".travis.yml"
|
234
|
+
- ".yardopts"
|
193
235
|
- Gemfile
|
194
236
|
- LICENSE
|
195
237
|
- README.md
|
@@ -261,14 +303,14 @@ require_paths:
|
|
261
303
|
- lib
|
262
304
|
required_ruby_version: !ruby/object:Gem::Requirement
|
263
305
|
requirements:
|
264
|
-
- - "
|
306
|
+
- - "~>"
|
265
307
|
- !ruby/object:Gem::Version
|
266
308
|
version: '2.2'
|
267
309
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
268
310
|
requirements:
|
269
|
-
- - "
|
311
|
+
- - ">="
|
270
312
|
- !ruby/object:Gem::Version
|
271
|
-
version:
|
313
|
+
version: '0'
|
272
314
|
requirements: []
|
273
315
|
rubyforge_project:
|
274
316
|
rubygems_version: 2.6.8
|