timetree 0.1.2 → 0.1.7
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/.github/workflows/gem-push.yml +36 -0
- data/.github/workflows/test.yml +21 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +17 -0
- data/README.md +3 -2
- data/lib/timetree/activity.rb +1 -4
- data/lib/timetree/base_model.rb +9 -3
- data/lib/timetree/calendar.rb +18 -20
- data/lib/timetree/client.rb +50 -9
- data/lib/timetree/event.rb +22 -32
- data/lib/timetree/version.rb +1 -1
- data/timetree.gemspec +2 -0
- metadata +34 -5
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bffe4b8c7f5f0b823a2e9ea69366805c162b47c97a0ad38a3f244ac0d9d11362
|
4
|
+
data.tar.gz: a9b07113a787279349db5840bbe10f48c1e9fef4523a3be6a79e7334b81f54d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51114aab5225929e87d24881ff392c65ea45271c80c93f70d46667d51a459c7776976e941b11a5759da1946f6d00d4169c1fc09c87aae4fd810fca60aaae54b7
|
7
|
+
data.tar.gz: 5e82739d7134e02c937cb321e6d783784129188177a565be6f5f7f294d6df509e9444df21f1a2521456f9f0899e56102f9f22534ff3bde35a0e4a04fcf94504e
|
@@ -0,0 +1,36 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [master]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
name: Build + Publish
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Set up Ruby 2.6
|
15
|
+
uses: actions/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: 2.6
|
18
|
+
|
19
|
+
- name: Build and test
|
20
|
+
run: |
|
21
|
+
gem install bundler
|
22
|
+
bundle install --jobs 4 --retry 3
|
23
|
+
bundle exec rake test
|
24
|
+
env:
|
25
|
+
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
|
26
|
+
|
27
|
+
- name: Publish to RubyGems
|
28
|
+
run: |
|
29
|
+
mkdir -p $HOME/.gem
|
30
|
+
touch $HOME/.gem/credentials
|
31
|
+
chmod 0600 $HOME/.gem/credentials
|
32
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
33
|
+
gem build *.gemspec
|
34
|
+
gem push *.gem
|
35
|
+
env:
|
36
|
+
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on: pull_request
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v2
|
11
|
+
- name: Set up Ruby
|
12
|
+
uses: ruby/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: 2.6
|
15
|
+
- name: Build and test
|
16
|
+
run: |
|
17
|
+
gem install bundler
|
18
|
+
bundle install --jobs 4 --retry 3
|
19
|
+
bundle exec rake test
|
20
|
+
env:
|
21
|
+
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
# 0.1.6
|
2
|
+
|
3
|
+
- refs #16 add code coverage to readme.
|
4
|
+
- refs #17 update deprecated `version` for `ruby-version` on gem-push.yml.
|
5
|
+
|
6
|
+
# 0.1.5
|
7
|
+
|
8
|
+
- refs #6 setup GitHub Actions.
|
9
|
+
|
10
|
+
# 0.1.4
|
11
|
+
|
12
|
+
- updates comments.
|
13
|
+
|
14
|
+
# 0.1.3
|
15
|
+
|
16
|
+
- refs #7 #9 make the code coverage 100%.
|
17
|
+
|
1
18
|
# 0.1.2
|
2
19
|
|
3
20
|
- refs #1 fix typo Event#recurrences to recurrence
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Simple TimeTree APIs client
|
2
2
|
|
3
|
+
[](https://github.com/koshilife/timetree-api-ruby-client/actions?query=workflow%3ATest)
|
4
|
+
[](https://codecov.io/gh/koshilife/timetree-api-ruby-client)
|
3
5
|
[](http://badge.fury.io/rb/timetree)
|
6
|
+
[](https://github.com/koshilife/timetree-api-ruby-client/blob/master/LICENSE.txt)
|
4
7
|
|
5
8
|
## About
|
6
9
|
|
@@ -94,8 +97,6 @@ TimeTree.configuration.logger.level = :debug
|
|
94
97
|
>> client.event 'cal_id_001', 'event_id_001_not_found'
|
95
98
|
I, [2020-06-24T10:05:07.294807] INFO -- : GET https://timetreeapis.com/calendars/cal_id_001/events/event_id_001_not_found?include=creator%2Clabel%2Cattendees
|
96
99
|
D, [2020-06-24T10:05:07.562038] DEBUG -- : Response status:404, body:{:type=>"https://developers.timetreeapp.com/en/docs/api#client-failure", :title=>"Not Found", :status=>404, :errors=>"Event not found"}
|
97
|
-
Traceback (most recent call last):
|
98
|
-
TimeTree::ApiError (TimeTree::ApiError)
|
99
100
|
```
|
100
101
|
|
101
102
|
## Contributing
|
data/lib/timetree/activity.rb
CHANGED
@@ -28,10 +28,7 @@ module TimeTree
|
|
28
28
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
29
29
|
# @since 0.0.1
|
30
30
|
def create
|
31
|
-
|
32
|
-
raise Error, 'calendar_id is required.' if calendar_id.nil?
|
33
|
-
raise Error, 'event_id is required.' if event_id.nil?
|
34
|
-
|
31
|
+
check_client
|
35
32
|
@client.create_activity calendar_id, event_id, data_params
|
36
33
|
end
|
37
34
|
|
data/lib/timetree/base_model.rb
CHANGED
@@ -18,7 +18,7 @@ module TimeTree
|
|
18
18
|
# @param client [TimeTree::Client]
|
19
19
|
# @return [TimeTree::User, TimeTree::Label, TimeTree::Calendar, TimeTree::Event, TimeTree::Activity]
|
20
20
|
# A TimeTree model object that be based on the type.
|
21
|
-
# @raise [TimeTree::Error] if the type property is not set.
|
21
|
+
# @raise [TimeTree::Error] if the type property is not set or unknown.
|
22
22
|
# @since 0.0.1
|
23
23
|
def self.to_model(data, included: nil, client: nil)
|
24
24
|
id = data[:id]
|
@@ -47,12 +47,14 @@ module TimeTree
|
|
47
47
|
Event.new(**params)
|
48
48
|
when 'activity'
|
49
49
|
Activity.new(**params)
|
50
|
+
else
|
51
|
+
raise Error, "type '#{type}' is unknown."
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
53
|
-
def initialize(
|
54
|
-
@id = id
|
55
|
+
def initialize(type:, id: nil, client: nil, attributes: nil, relationships: nil, included: nil)
|
55
56
|
@type = type
|
57
|
+
@id = id
|
56
58
|
@client = client
|
57
59
|
set_attributes attributes
|
58
60
|
set_relationships relationships, included
|
@@ -64,6 +66,10 @@ module TimeTree
|
|
64
66
|
|
65
67
|
private
|
66
68
|
|
69
|
+
def check_client
|
70
|
+
raise Error, '@client is nil.' if @client.nil?
|
71
|
+
end
|
72
|
+
|
67
73
|
def to_model(data)
|
68
74
|
self.class.to_model data, client: @client
|
69
75
|
end
|
data/lib/timetree/calendar.rb
CHANGED
@@ -25,12 +25,11 @@ module TimeTree
|
|
25
25
|
# @param event_id [String]
|
26
26
|
# event's id.
|
27
27
|
# @return [TimeTree::Event]
|
28
|
-
# @raise [TimeTree::Error] if @client is
|
28
|
+
# @raise [TimeTree::Error] if @client, @id or the event_id arg is empty.
|
29
29
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
30
30
|
# @since 0.0.1
|
31
31
|
def event(event_id)
|
32
|
-
|
33
|
-
|
32
|
+
check_client
|
34
33
|
@client.event id, event_id
|
35
34
|
end
|
36
35
|
|
@@ -42,41 +41,40 @@ module TimeTree
|
|
42
41
|
# @param timezone [String]
|
43
42
|
# Timezone.
|
44
43
|
# @return [Array<TimeTree::Event>]
|
45
|
-
# @raise [TimeTree::Error] if @client is
|
44
|
+
# @raise [TimeTree::Error] if @client or @id is empty.
|
46
45
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
47
46
|
# @since 0.0.1
|
48
47
|
def upcoming_events(days: 7, timezone: 'UTC')
|
49
|
-
|
50
|
-
|
48
|
+
check_client
|
51
49
|
@client.upcoming_events id, days: days, timezone: timezone
|
52
50
|
end
|
53
51
|
|
54
52
|
#
|
55
|
-
# Get a calendar's
|
53
|
+
# Get a calendar's member information.
|
56
54
|
#
|
57
|
-
# @return [Array<TimeTree::
|
58
|
-
# @raise [TimeTree::Error] if @client is
|
55
|
+
# @return [Array<TimeTree::User>]
|
56
|
+
# @raise [TimeTree::Error] if @client or @id is empty.
|
59
57
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
60
58
|
# @since 0.0.1
|
61
|
-
def
|
62
|
-
return @
|
63
|
-
raise Error, '@client is nil.' if @client.nil?
|
59
|
+
def members
|
60
|
+
return @members if defined? @members
|
64
61
|
|
65
|
-
|
62
|
+
check_client
|
63
|
+
@members = @client.calendar_members id
|
66
64
|
end
|
67
65
|
|
68
66
|
#
|
69
|
-
# Get a calendar's
|
67
|
+
# Get a calendar's label information used in event.
|
70
68
|
#
|
71
|
-
# @return [Array<TimeTree::
|
72
|
-
# @raise [TimeTree::Error] if @client is
|
69
|
+
# @return [Array<TimeTree::Label>]
|
70
|
+
# @raise [TimeTree::Error] if @client or @id is empty.
|
73
71
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
74
72
|
# @since 0.0.1
|
75
|
-
def
|
76
|
-
return @
|
77
|
-
raise Error, '@client is nil.' if @client.nil?
|
73
|
+
def labels
|
74
|
+
return @labels if defined? @labels
|
78
75
|
|
79
|
-
|
76
|
+
check_client
|
77
|
+
@labels = @client.calendar_labels id
|
80
78
|
end
|
81
79
|
end
|
82
80
|
end
|
data/lib/timetree/client.rb
CHANGED
@@ -16,8 +16,7 @@ module TimeTree
|
|
16
16
|
# @param token [String] a TimeTree's access token.
|
17
17
|
def initialize(token = nil)
|
18
18
|
@token = token || TimeTree.configuration.token
|
19
|
-
|
20
|
-
|
19
|
+
check_token
|
21
20
|
@http_cmd = HttpCommand.new(API_HOST, self)
|
22
21
|
end
|
23
22
|
|
@@ -41,9 +40,11 @@ module TimeTree
|
|
41
40
|
# @param include_relationships [Array<symbol>]
|
42
41
|
# includes association's object in the response.
|
43
42
|
# @return [TimeTree::Calendar]
|
43
|
+
# @raise [TimeTree::Error] if the cal_id arg is empty.
|
44
44
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
45
45
|
# @since 0.0.1
|
46
46
|
def calendar(cal_id, include_relationships: nil)
|
47
|
+
check_calendar_id cal_id
|
47
48
|
params = relationships_params(include_relationships, Calendar::RELATIONSHIPS)
|
48
49
|
res = @http_cmd.get "/calendars/#{cal_id}", params
|
49
50
|
raise ApiError, res if res.status != 200
|
@@ -73,9 +74,11 @@ module TimeTree
|
|
73
74
|
#
|
74
75
|
# @param cal_id [String] calendar's id.
|
75
76
|
# @return [Array<TimeTree::Label>]
|
77
|
+
# @raise [TimeTree::Error] if the cal_id arg is empty.
|
76
78
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
77
79
|
# @since 0.0.1
|
78
80
|
def calendar_labels(cal_id)
|
81
|
+
check_calendar_id cal_id
|
79
82
|
res = @http_cmd.get "/calendars/#{cal_id}/labels"
|
80
83
|
raise ApiError, res if res.status != 200
|
81
84
|
|
@@ -87,9 +90,11 @@ module TimeTree
|
|
87
90
|
#
|
88
91
|
# @param cal_id [String] calendar's id.
|
89
92
|
# @return [Array<TimeTree::User>]
|
93
|
+
# @raise [TimeTree::Error] if the cal_id arg is empty.
|
90
94
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
91
95
|
# @since 0.0.1
|
92
96
|
def calendar_members(cal_id)
|
97
|
+
check_calendar_id cal_id
|
93
98
|
res = @http_cmd.get "/calendars/#{cal_id}/members"
|
94
99
|
raise ApiError, res if res.status != 200
|
95
100
|
|
@@ -104,9 +109,13 @@ module TimeTree
|
|
104
109
|
# @param include_relationships [Array<symbol>]
|
105
110
|
# includes association's object in the response.
|
106
111
|
# @return [TimeTree::Event]
|
112
|
+
# @raise [TimeTree::Error] if the cal_id arg is empty.
|
113
|
+
# @raise [TimeTree::Error] if the event_id arg is empty.
|
107
114
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
108
115
|
# @since 0.0.1
|
109
116
|
def event(cal_id, event_id, include_relationships: nil)
|
117
|
+
check_calendar_id cal_id
|
118
|
+
check_event_id event_id
|
110
119
|
params = relationships_params(include_relationships, Event::RELATIONSHIPS)
|
111
120
|
res = @http_cmd.get "/calendars/#{cal_id}/events/#{event_id}", params
|
112
121
|
raise ApiError, res if res.status != 200
|
@@ -125,9 +134,11 @@ module TimeTree
|
|
125
134
|
# @param include_relationships [Array<symbol>]
|
126
135
|
# includes association's object in the response.
|
127
136
|
# @return [Array<TimeTree::Event>]
|
137
|
+
# @raise [TimeTree::Error] if the cal_id arg is empty.
|
128
138
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
129
139
|
# @since 0.0.1
|
130
140
|
def upcoming_events(cal_id, days: 7, timezone: 'UTC', include_relationships: nil)
|
141
|
+
check_calendar_id cal_id
|
131
142
|
params = relationships_params(include_relationships, Event::RELATIONSHIPS)
|
132
143
|
params.merge!(days: days, timezone: timezone)
|
133
144
|
res = @http_cmd.get "/calendars/#{cal_id}/upcoming_events", params
|
@@ -147,9 +158,11 @@ module TimeTree
|
|
147
158
|
# @param cal_id [String] calendar's id.
|
148
159
|
# @param params [Hash] TimeTree request body format.
|
149
160
|
# @return [TimeTree::Event]
|
161
|
+
# @raise [TimeTree::Error] if the cal_id arg is empty.
|
150
162
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
151
163
|
# @since 0.0.1
|
152
164
|
def create_event(cal_id, params)
|
165
|
+
check_calendar_id cal_id
|
153
166
|
res = @http_cmd.post "/calendars/#{cal_id}/events", params
|
154
167
|
raise ApiError, res if res.status != 201
|
155
168
|
|
@@ -166,9 +179,13 @@ module TimeTree
|
|
166
179
|
# @param params [Hash]
|
167
180
|
# event's information specified in TimeTree request body format.
|
168
181
|
# @return [TimeTree::Event]
|
182
|
+
# @raise [TimeTree::Error] if the cal_id arg is empty.
|
183
|
+
# @raise [TimeTree::Error] if the event_id arg is empty.
|
169
184
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
170
185
|
# @since 0.0.1
|
171
186
|
def update_event(cal_id, event_id, params)
|
187
|
+
check_calendar_id cal_id
|
188
|
+
check_event_id event_id
|
172
189
|
res = @http_cmd.put "/calendars/#{cal_id}/events/#{event_id}", params
|
173
190
|
raise ApiError, res if res.status != 200
|
174
191
|
|
@@ -183,9 +200,13 @@ module TimeTree
|
|
183
200
|
# @param cal_id [String] calendar's id.
|
184
201
|
# @param event_id [String] event's id.
|
185
202
|
# @return [true] if the operation succeeded.
|
203
|
+
# @raise [TimeTree::Error] if the cal_id arg is empty.
|
204
|
+
# @raise [TimeTree::Error] if the event_id arg is empty.
|
186
205
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
187
206
|
# @since 0.0.1
|
188
207
|
def delete_event(cal_id, event_id)
|
208
|
+
check_calendar_id cal_id
|
209
|
+
check_event_id event_id
|
189
210
|
res = @http_cmd.delete "/calendars/#{cal_id}/events/#{event_id}"
|
190
211
|
raise ApiError, res if res.status != 204
|
191
212
|
|
@@ -200,9 +221,13 @@ module TimeTree
|
|
200
221
|
# @param params [Hash]
|
201
222
|
# comment's information specified in TimeTree request body format.
|
202
223
|
# @return [TimeTree::Activity]
|
203
|
-
# @raise [TimeTree::
|
224
|
+
# @raise [TimeTree::Error] if the cal_id arg is empty.
|
225
|
+
# @raise [TimeTree::Error] if the event_id arg is empty.
|
226
|
+
# @raise [TimeTree::ApiError] if the http response status is not success.
|
204
227
|
# @since 0.0.1
|
205
228
|
def create_activity(cal_id, event_id, params)
|
229
|
+
check_calendar_id cal_id
|
230
|
+
check_event_id event_id
|
206
231
|
res = @http_cmd.post "/calendars/#{cal_id}/events/#{event_id}/activities", params
|
207
232
|
raise ApiError, res if res.status != 201
|
208
233
|
|
@@ -214,10 +239,10 @@ module TimeTree
|
|
214
239
|
|
215
240
|
def inspect
|
216
241
|
limit_info = nil
|
217
|
-
if @ratelimit_limit
|
242
|
+
if defined?(@ratelimit_limit) && @ratelimit_limit
|
218
243
|
limit_info = " ratelimit:#{@ratelimit_remaining}/#{@ratelimit_limit}"
|
219
244
|
end
|
220
|
-
if @ratelimit_reset_at
|
245
|
+
if defined?(@ratelimit_reset_at) && @ratelimit_reset_at
|
221
246
|
limit_info = "#{limit_info}, reset_at:#{@ratelimit_reset_at.strftime('%m/%d %R')}"
|
222
247
|
end
|
223
248
|
"\#<#{self.class}:#{object_id}#{limit_info}>"
|
@@ -239,12 +264,28 @@ module TimeTree
|
|
239
264
|
|
240
265
|
private
|
241
266
|
|
242
|
-
def
|
243
|
-
|
267
|
+
def check_token
|
268
|
+
check_required_property(@token, 'token')
|
269
|
+
end
|
270
|
+
|
271
|
+
def check_calendar_id(value)
|
272
|
+
check_required_property(value, 'calendar_id')
|
273
|
+
end
|
274
|
+
|
275
|
+
def check_event_id(value)
|
276
|
+
check_required_property(value, 'event_id')
|
244
277
|
end
|
245
278
|
|
246
|
-
def
|
247
|
-
|
279
|
+
def check_required_property(value, name)
|
280
|
+
err = Error.new "#{name} is required."
|
281
|
+
raise err if value.nil?
|
282
|
+
raise err if value.to_s.empty?
|
283
|
+
|
284
|
+
true
|
285
|
+
end
|
286
|
+
|
287
|
+
def to_model(data, included: nil)
|
288
|
+
TimeTree::BaseModel.to_model data, client: self, included: included
|
248
289
|
end
|
249
290
|
|
250
291
|
def relationships_params(relationships, default)
|
data/lib/timetree/event.rb
CHANGED
@@ -38,9 +38,9 @@ module TimeTree
|
|
38
38
|
# @return [TimeTree::User]
|
39
39
|
attr_reader :creator
|
40
40
|
# @return [TimeTree::Label]
|
41
|
-
|
41
|
+
attr_accessor :label
|
42
42
|
# @return [Array<TimeTree::User>]
|
43
|
-
|
43
|
+
attr_accessor :attendees
|
44
44
|
|
45
45
|
TIME_FIELDS = %i[start_at end_at updated_at created_at].freeze
|
46
46
|
RELATIONSHIPS = %i[creator label attendees].freeze
|
@@ -49,44 +49,23 @@ module TimeTree
|
|
49
49
|
# Creates an event to the associated calendar.
|
50
50
|
#
|
51
51
|
# @return [TimeTree::Event]
|
52
|
-
# @raise [TimeTree::Error] if @client is
|
52
|
+
# @raise [TimeTree::Error] if @client or @calendar_id is empty.
|
53
53
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
54
54
|
# @since 0.0.1
|
55
55
|
def create
|
56
|
-
|
57
|
-
|
56
|
+
check_client
|
58
57
|
@client.create_event calendar_id, data_params
|
59
58
|
end
|
60
59
|
|
61
|
-
#
|
62
|
-
# Creates comment to the event.
|
63
|
-
#
|
64
|
-
# @return [TimeTree::Activity]
|
65
|
-
# @raise [TimeTree::Error] if @client is not set.
|
66
|
-
# @raise [TimeTree::ApiError] if the http response status will not success.
|
67
|
-
# @since 0.0.1
|
68
|
-
def create_comment(message)
|
69
|
-
raise Error, '@client is nil.' if @client.nil?
|
70
|
-
|
71
|
-
params = { type: 'activity', attributes: { calendar_id: calendar_id, event_id: id, content: message } }
|
72
|
-
activity = to_model params
|
73
|
-
return if activity.nil?
|
74
|
-
|
75
|
-
activity.create
|
76
|
-
end
|
77
|
-
|
78
60
|
#
|
79
61
|
# Updates the event.
|
80
62
|
#
|
81
63
|
# @return [TimeTree::Event]
|
82
|
-
# @raise [TimeTree::Error] if @client is
|
83
|
-
# @raise [TimeTree::Error] if the id property is not set.
|
64
|
+
# @raise [TimeTree::Error] if @client, @calendar_id or @id is empty.
|
84
65
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
85
66
|
# @since 0.0.1
|
86
67
|
def update
|
87
|
-
|
88
|
-
raise Error, 'id is required.' if id.nil?
|
89
|
-
|
68
|
+
check_client
|
90
69
|
@client.update_event calendar_id, id, data_params
|
91
70
|
end
|
92
71
|
|
@@ -94,17 +73,28 @@ module TimeTree
|
|
94
73
|
# Deletes the event.
|
95
74
|
#
|
96
75
|
# @return [true] if the operation succeeded.
|
97
|
-
# @raise [TimeTree::Error] if @client is
|
98
|
-
# @raise [TimeTree::Error] if the id property is not set.
|
76
|
+
# @raise [TimeTree::Error] if @client, @calendar_id or @id is empty.
|
99
77
|
# @raise [TimeTree::ApiError] if the http response status will not success.
|
100
78
|
# @since 0.0.1
|
101
79
|
def delete
|
102
|
-
|
103
|
-
raise Error, 'id is required.' if id.nil?
|
104
|
-
|
80
|
+
check_client
|
105
81
|
@client.delete_event calendar_id, id
|
106
82
|
end
|
107
83
|
|
84
|
+
#
|
85
|
+
# Creates comment to the event.
|
86
|
+
#
|
87
|
+
# @return [TimeTree::Activity]
|
88
|
+
# @raise [TimeTree::Error] if @client, @calendar_id or @id is empty.
|
89
|
+
# @raise [TimeTree::ApiError] if the http response status will not success.
|
90
|
+
# @since 0.0.1
|
91
|
+
def create_comment(message)
|
92
|
+
check_client
|
93
|
+
params = { type: 'activity', attributes: { calendar_id: calendar_id, event_id: id, content: message } }
|
94
|
+
activity = to_model params
|
95
|
+
activity.create
|
96
|
+
end
|
97
|
+
|
108
98
|
#
|
109
99
|
# convert to a TimeTree request body format.
|
110
100
|
#
|
data/lib/timetree/version.rb
CHANGED
data/timetree.gemspec
CHANGED
@@ -33,8 +33,10 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_runtime_dependency 'zeitwerk', '~> 2.3.0'
|
34
34
|
|
35
35
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
36
|
+
spec.add_development_dependency 'codecov', '~> 0.1.17'
|
36
37
|
spec.add_development_dependency 'minitest', '~> 5.14.0'
|
37
38
|
spec.add_development_dependency 'minitest-reporters', '~> 1.4.2'
|
38
39
|
spec.add_development_dependency 'rake', '~> 12.0'
|
40
|
+
spec.add_development_dependency 'simplecov', '~> 0.18.5'
|
39
41
|
spec.add_development_dependency 'webmock', '~> 3.7.6'
|
40
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timetree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenji Koshikawa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: codecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.1.17
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.1.17
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: minitest
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,20 @@ dependencies:
|
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '12.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.18.5
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.18.5
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: webmock
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,9 +157,10 @@ executables: []
|
|
129
157
|
extensions: []
|
130
158
|
extra_rdoc_files: []
|
131
159
|
files:
|
160
|
+
- ".github/workflows/gem-push.yml"
|
161
|
+
- ".github/workflows/test.yml"
|
132
162
|
- ".gitignore"
|
133
163
|
- ".rubocom.yml"
|
134
|
-
- ".travis.yml"
|
135
164
|
- CHANGELOG.md
|
136
165
|
- CODE_OF_CONDUCT.md
|
137
166
|
- Gemfile
|
@@ -160,7 +189,7 @@ metadata:
|
|
160
189
|
homepage_uri: https://github.com/koshilife/timetree-api-ruby-client
|
161
190
|
source_code_uri: https://github.com/koshilife/timetree-api-ruby-client
|
162
191
|
changelog_uri: https://github.com/koshilife/timetree-api-ruby-client/blob/master/CHANGELOG.md
|
163
|
-
documentation_uri: https://www.rubydoc.info/gems/timetree/0.1.
|
192
|
+
documentation_uri: https://www.rubydoc.info/gems/timetree/0.1.7
|
164
193
|
post_install_message:
|
165
194
|
rdoc_options: []
|
166
195
|
require_paths:
|
@@ -176,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
205
|
- !ruby/object:Gem::Version
|
177
206
|
version: '0'
|
178
207
|
requirements: []
|
179
|
-
rubygems_version: 3.
|
208
|
+
rubygems_version: 3.0.3
|
180
209
|
signing_key:
|
181
210
|
specification_version: 4
|
182
211
|
summary: Client for accessing TimeTree APIs
|