smartsheet 1.3.0 → 2.77.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/.travis.yml +2 -0
- data/ADVANCED.md +79 -0
- data/CHANGELOG.md +3 -0
- data/README.md +8 -0
- data/lib/smartsheet/client.rb +3 -1
- data/lib/smartsheet/constants.rb +1 -1
- data/lib/smartsheet/endpoints/events/events.rb +21 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eae914214c09e89c42b784bae587d674d5c2773c8f23a55a5514cf2e5bf89141
|
4
|
+
data.tar.gz: a0494874786cea9674006c2253b9e5b61442c8f07ef861a253570fb33ad1d365
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48a942ed00e9f71795c17931e4d02cb01b17e2ea9c025d61f13cd9b5b73b4e841b1b73f55c3ef890948579db17a0897f327376d902ae2ee35f5fb2a46e5b484c
|
7
|
+
data.tar.gz: b8193db2c5ee289df790636ac06b437bc2c60c2849caf4acfbfe774d319cad3988a006c12e0b6cd0d41f4925acbcb76006d9291641513d9fbcc945bc08c8510c
|
data/.travis.yml
CHANGED
@@ -6,8 +6,10 @@ rvm:
|
|
6
6
|
before_install:
|
7
7
|
- git clone https://github.com/smartsheet-platform/smartsheet-sdk-tests.git
|
8
8
|
- smartsheet-sdk-tests/travis_scripts/install_wiremock.sh
|
9
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
9
10
|
- gem install bundler -v 1.15.4
|
10
11
|
|
12
|
+
|
11
13
|
script:
|
12
14
|
- smartsheet-sdk-tests/travis_scripts/start_wiremock.sh
|
13
15
|
- rake test
|
data/ADVANCED.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Advanced Topics for the Smartsheet SDK for Ruby
|
2
|
+
|
3
|
+
## Event Reporting
|
4
|
+
The following sample demonstrates best practices for consuming the event stream returned from the Smartsheet Event Reporting feature.
|
5
|
+
|
6
|
+
The sample uses the `smartsheet_client.events.get` method to request lists of events from the stream. The first request sets the `since` parameter with the point in time (i.e. event occurrence datetime) in the stream from which to start consuming events. The `since` parameter can be set with a datetime value that is either formatted as ISO 8601 (e.g. 2010-01-01T00:00:00Z) or as UNIX epoch (in which case the `numeric_dates` parameter must also be set to `True`. By default the `numeric_dates` parameter is set to `False`).
|
7
|
+
|
8
|
+
To consume the next list of events after the initial list of events is returned, set the `stream_position` parameter with the `next_stream_position` attribute obtained from the previous request and don't set the `since` parameter with any values. This is because when using the `get` method, either the `since` parameter or the `stream_position` parameter should be set, but never both.
|
9
|
+
|
10
|
+
Note that the `more_available` attribute in a response indicates whether more events are immediately available for consumption. If events aren't immediately available, they may still be generating so subsequent requests should keep using the same `stream_position` value until the next list of events is retrieved.
|
11
|
+
|
12
|
+
Many events have additional information available as a part of the event. That information can be accessed from the data stored in the `additional_details` attribute. Information about the additional details provided can be found [here](https://smartsheet-platform.github.io/api-docs/?ruby#event-reporting).
|
13
|
+
|
14
|
+
|
15
|
+
```Ruby
|
16
|
+
require 'smartsheet'
|
17
|
+
require 'time'
|
18
|
+
require 'date'
|
19
|
+
require 'pp'
|
20
|
+
|
21
|
+
# Initialize the client - use your access token here
|
22
|
+
$smartsheet_client = Smartsheet::Client.new(token: '1234')
|
23
|
+
# The `client` variable now contains access to all of the APIs
|
24
|
+
|
25
|
+
today = (DateTime.now)
|
26
|
+
date_week_ago = (today - 7).to_time.utc.iso8601
|
27
|
+
|
28
|
+
|
29
|
+
def get_events(params)
|
30
|
+
result = $smartsheet_client.events.get(params: params)
|
31
|
+
# pp result
|
32
|
+
print_new_sheet_events(result[:data])
|
33
|
+
|
34
|
+
more_events_available = result[:more_available]
|
35
|
+
next_stream_position = result[:next_stream_position]
|
36
|
+
get_next_stream_of_events(more_events_available, next_stream_position)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Subsequent calls require the streamPosition property
|
40
|
+
def get_next_stream_of_events(more_events_available, next_stream_position)
|
41
|
+
params = {
|
42
|
+
stream_position: next_stream_position,
|
43
|
+
max_count: 1
|
44
|
+
}
|
45
|
+
|
46
|
+
if more_events_available
|
47
|
+
get_events(params);
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# This example is looking specifically for new sheet events
|
52
|
+
def print_new_sheet_events(data)
|
53
|
+
data.each do |value|
|
54
|
+
# Find all created sheets
|
55
|
+
if value[:object_type] == "SHEET" && value[:action] == "CREATE"
|
56
|
+
pp value
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
begin
|
64
|
+
params = {
|
65
|
+
since: date_week_ago,
|
66
|
+
max_count: 1
|
67
|
+
}
|
68
|
+
|
69
|
+
# The first call to the events reporting API
|
70
|
+
# requires the since query parameter.
|
71
|
+
# If you pass in an UNIX epoch date, numericDates must be true
|
72
|
+
get_events(params)
|
73
|
+
|
74
|
+
rescue Smartsheet::ApiError => e
|
75
|
+
puts "Error Code: #{e.error_code}"
|
76
|
+
puts "Message: #{e.message}"
|
77
|
+
puts "Ref Id: #{e.ref_id}"
|
78
|
+
end
|
79
|
+
```
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [2.77.0] - 2019-05-08
|
10
|
+
- Added events endpoint to retrieve events that are occurring in your Smartsheet plan.
|
11
|
+
|
9
12
|
## [1.3.0] - 2019-02-11
|
10
13
|
- Added constant for smartsheetgov
|
11
14
|
- Updated documentation regarding the usage of base_url to clarify how clients can access smartsheetgov
|
data/README.md
CHANGED
@@ -222,11 +222,19 @@ response = smartsheet.request(
|
|
222
222
|
)
|
223
223
|
```
|
224
224
|
|
225
|
+
## Advanced Topics
|
226
|
+
For details about more advanced features, see [Advanced Topics](ADVANCED.md).
|
227
|
+
|
225
228
|
## Contributing
|
226
229
|
|
227
230
|
If you would like to contribute a change to the SDK, please fork a branch and then submit a pull request.
|
228
231
|
[More info here.](https://help.github.com/articles/using-pull-requests)
|
229
232
|
|
233
|
+
## Version Numbers
|
234
|
+
Starting from the v2.77.0 release, Smartsheet SDKs will use a new versioning strategy. Since all users are on the Smartsheet API 2.0, the SDK version numbers will start with 2. The 2nd number will be an internal reference number. The 3rd number is for incremental changes.
|
235
|
+
|
236
|
+
For example, v2.77.0 means that you are using our 2.0 version of the API, the API is synched internally to a tag of 77, and then if there are numbers after the last decimal, that will indicate a minor change.
|
237
|
+
|
230
238
|
## Support
|
231
239
|
|
232
240
|
If you have any questions or issues with this SDK please post on [Stack Overflow using the tag "smartsheet-api"](http://stackoverflow.com/questions/tagged/smartsheet-api) or contact us directly at api@smartsheet.com.
|
data/lib/smartsheet/client.rb
CHANGED
@@ -7,6 +7,7 @@ require 'smartsheet/api/request_logger'
|
|
7
7
|
require 'smartsheet/general_request'
|
8
8
|
|
9
9
|
require 'smartsheet/endpoints/contacts/contacts'
|
10
|
+
require 'smartsheet/endpoints/events/events'
|
10
11
|
require 'smartsheet/endpoints/favorites/favorites'
|
11
12
|
require 'smartsheet/endpoints/folders/folders'
|
12
13
|
require 'smartsheet/endpoints/groups/groups'
|
@@ -64,7 +65,7 @@ module Smartsheet
|
|
64
65
|
include GeneralRequest
|
65
66
|
include Smartsheet::Constants
|
66
67
|
|
67
|
-
attr_reader :contacts, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
|
68
|
+
attr_reader :contacts, :events, :favorites, :folders, :groups, :home, :reports, :search, :server_info,
|
68
69
|
:sheets, :sights, :templates, :token, :update_requests, :users, :webhooks,
|
69
70
|
:workspaces
|
70
71
|
|
@@ -159,6 +160,7 @@ module Smartsheet
|
|
159
160
|
|
160
161
|
def build_categories
|
161
162
|
@contacts = Contacts.new(client)
|
163
|
+
@events = Events.new(client)
|
162
164
|
@favorites = Favorites.new(client)
|
163
165
|
@folders = Folders.new(client)
|
164
166
|
@groups = Groups.new(client)
|
data/lib/smartsheet/constants.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Smartsheet
|
2
|
+
# Events Endpoints
|
3
|
+
# @see https://smartsheet-platform.github.io/api-docs/?ruby#event-reporting API Events Docs
|
4
|
+
class Events
|
5
|
+
attr_reader :client
|
6
|
+
private :client
|
7
|
+
|
8
|
+
def initialize(client)
|
9
|
+
@client = client
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(params: {}, header_overrides: {})
|
13
|
+
endpoint_spec = Smartsheet::API::EndpointSpec.new(:get, ['events'])
|
14
|
+
request_spec = Smartsheet::API::RequestSpec.new(
|
15
|
+
header_overrides: header_overrides,
|
16
|
+
params: params
|
17
|
+
)
|
18
|
+
client.make_request(endpoint_spec, request_spec)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
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:
|
4
|
+
version: 2.77.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Smartsheet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -260,6 +260,7 @@ files:
|
|
260
260
|
- ".rubocop.yml"
|
261
261
|
- ".travis.yml"
|
262
262
|
- ".yardopts"
|
263
|
+
- ADVANCED.md
|
263
264
|
- CHANGELOG.md
|
264
265
|
- Gemfile
|
265
266
|
- LICENSE
|
@@ -287,6 +288,7 @@ files:
|
|
287
288
|
- lib/smartsheet/client.rb
|
288
289
|
- lib/smartsheet/constants.rb
|
289
290
|
- lib/smartsheet/endpoints/contacts/contacts.rb
|
291
|
+
- lib/smartsheet/endpoints/events/events.rb
|
290
292
|
- lib/smartsheet/endpoints/favorites/favorites.rb
|
291
293
|
- lib/smartsheet/endpoints/folders/folders.rb
|
292
294
|
- lib/smartsheet/endpoints/groups/groups.rb
|