timetree 0.1.0 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6acdee0d0822340b25b56705ae9ffb72e031a831c44755b87004471bb015c65
4
- data.tar.gz: cf2be6cc1d35cdb59d686b6caed4fd967919369eafceb3867bd0cf5f0459d37a
3
+ metadata.gz: 8300f6f549eec18be34ed686a30ebf8a65764b9477bfff6727c860d1481b24c3
4
+ data.tar.gz: e8aa1930b0aadf03c7e810888ebb65b77a4982f03ddcbc45c3c25881f2395f43
5
5
  SHA512:
6
- metadata.gz: f10a43690969abeae928366c13face88ed28fd3507e6fcd1b708e8bca0d61bc7772dbeaf9d9bff92d3bd24ac55e122aa5a6d84595aa7f8aa312581f682b8d491
7
- data.tar.gz: 91a90869f53fde95f56cd7d0f987d7b376fb5db7ddcff15cbf86b66e1b6bedf90110f158ec4a9eb8b0893934d825c07af1a73f24e8f460f5488fe331fc7682af
6
+ metadata.gz: b4acc3128923537ec051d976f319da28a07c6d4def55725ca442641c69fca0d0ffbcf841da6d464c85c2d6a81227fe3950e7a1bc86b7239281b487f384d6b743
7
+ data.tar.gz: 1a34a2d8388c494c4fe988744d829e857a32589d52fd81356c25a9726056d87f4b2c77654ba15b4b5ad7834d6d1822ddc131693b7328e55bcc686d6d77e8e850
@@ -0,0 +1,34 @@
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
+ version: 2.6.x
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
+
25
+ - name: Publish to RubyGems
26
+ run: |
27
+ mkdir -p $HOME/.gem
28
+ touch $HOME/.gem/credentials
29
+ chmod 0600 $HOME/.gem/credentials
30
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
31
+ gem build *.gemspec
32
+ gem push *.gem
33
+ env:
34
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
@@ -0,0 +1,19 @@
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
data/.gitignore CHANGED
@@ -7,4 +7,5 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
+ coverage
10
11
  Gemfile.lock
@@ -1,3 +1,31 @@
1
+ # 0.1.5
2
+
3
+ - refs #6 setup GitHub Actions.
4
+
5
+ # 0.1.4
6
+
7
+ - updates comments.
8
+
9
+ # 0.1.3
10
+
11
+ - refs #7 #9 make the code coverage 100%.
12
+
13
+ # 0.1.2
14
+
15
+ - refs #1 fix typo Event#recurrences to recurrence
16
+ - refs #2 add a note for debugging guide on README
17
+
18
+ # 0.1.1
19
+
20
+ - set current version on this gem's documentation_uri.
21
+ - fixed typo on README.
22
+
23
+ # 0.1.0
24
+
25
+ - did refactor and wrote comments.
26
+ - started to use zeitwerk.
27
+ - wrote README.
28
+
1
29
  # 0.0.1
2
30
 
3
31
  - Initial release
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
- # Simple TimeTree apis client
1
+ # Simple TimeTree APIs client
2
2
 
3
+ [![Test](https://github.com/koshilife/timetree-api-ruby-client/workflows/Test/badge.svg)](https://github.com/koshilife/timetree-api-ruby-client/actions?query=workflow%3ATest)
3
4
  [![Gem Version](https://badge.fury.io/rb/timetree.svg)](http://badge.fury.io/rb/timetree)
4
5
 
5
6
  ## About
@@ -24,61 +25,60 @@ Or install it yourself as:
24
25
 
25
26
  ## Usage
26
27
 
27
- The Api client needs access token.
28
- Set `access_token` to the value you got by above:
28
+ The APIs client needs access token.
29
+ Set a `token` variable to the value you got by above:
29
30
 
30
31
  ```ruby
31
- # using configure
32
+ # set token by TimeTree.configure methods.
32
33
  TimeTree.configure do |config|
33
34
  config.token = '<YOUR_ACCESS_TOKEN>'
34
35
  end
35
36
  client = TimeTree::Client.new
36
37
 
37
- # using initializer
38
+ # set token by TimeTree::Client initializer.
38
39
  client = TimeTree::Client.new('<YOUR_ACCESS_TOKEN>')
39
40
 
40
- # get a current user's information
41
+ # get a current user's information.
41
42
  user = client.current_user
42
43
  => #<TimeTree::User id:xxx_u001>
43
44
  user.name
44
- => "USER Name 001"
45
+ => "USER Name"
45
46
 
46
- # get current user's calendars
47
+ # get current user's calendars.
47
48
  cals = client.calendars
48
49
  => [#<TimeTree::Calendar id:xxx_cal001>, #<TimeTree::Calendar id:xxx_cal002>, ...]
49
-
50
50
  cal = cals.first
51
51
  cal.name
52
- => "Calendar Name 001"
52
+ => "Calendar Name"
53
53
 
54
- # get upcoming events on the calendar
54
+ # get upcoming events on the calendar.
55
55
  evs = cal.upcoming_events
56
56
  => [#<TimeTree::Event id:xxx_ev001>, #<TimeTree::Event id:xxx_ev002>, ...]
57
57
  ev = evs.first
58
58
  ev.title
59
- => "Event Name 001"
59
+ => "Event Title"
60
60
 
61
- # updates an event
61
+ # updates an event.
62
62
  ev.title += ' Updated'
63
63
  ev.start_at = Time.parse('2020-06-20 09:00 +09:00')
64
64
  ev.end_at = Time.parse('2020-06-20 10:00 +09:00')
65
65
  ev.update
66
66
  => #<TimeTree::Event id:xxx_ev001>
67
67
 
68
- # creates an event
68
+ # creates an event.
69
69
  copy_ev = ev.dup
70
70
  new_ev = copy_ev.create
71
- => #<TimeTree::Event id:xxx_newev001>
71
+ => #<TimeTree::Event id:xxx_new_ev001>
72
72
 
73
- # deletes an event
73
+ # deletes an event.
74
74
  ev.delete
75
75
  => true
76
76
 
77
- # creates comment to an event
78
- ev.create_comment 'HOGE HOGE message.'
77
+ # creates a comment to an event.
78
+ ev.create_comment 'Hi there!'
79
79
  => #<TimeTree::Activity id:xxx_act001>
80
80
 
81
- # check apis error response
81
+ # handles APIs error.
82
82
  begin
83
83
  ev.delete
84
84
  ev.delete # 404 Error occured.
@@ -88,6 +88,13 @@ rescue TimeTree::ApiError => e
88
88
  e.response
89
89
  => #<Faraday::Response>
90
90
  end
91
+
92
+ # if the log level set :debug, you can get the request/response information.
93
+ TimeTree.configuration.logger.level = :debug
94
+ => #<TimeTree::Event id:event_id_001_not_found>
95
+ >> client.event 'cal_id_001', 'event_id_001_not_found'
96
+ 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
97
+ 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"}
91
98
  ```
92
99
 
93
100
  ## Contributing
@@ -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
- raise Error, '@client is nil.' if @client.nil?
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
 
@@ -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(id:, type:, client: nil, attributes: nil, relationships: nil, included: nil)
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
@@ -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 not set.
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
- raise Error, '@client is nil.' if @client.nil?
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 not set.
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
- raise Error, '@client is nil.' if @client.nil?
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 label information used in event.
53
+ # Get a calendar's member information.
56
54
  #
57
- # @return [Array<TimeTree::Label>]
58
- # @raise [TimeTree::Error] if @client is not set.
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 labels
62
- return @labels if defined? @labels
63
- raise Error, '@client is nil.' if @client.nil?
59
+ def members
60
+ return @members if defined? @members
64
61
 
65
- @labels = @client.calendar_labels id
62
+ check_client
63
+ @members = @client.calendar_members id
66
64
  end
67
65
 
68
66
  #
69
- # Get a calendar's member information.
67
+ # Get a calendar's label information used in event.
70
68
  #
71
- # @return [Array<TimeTree::User>]
72
- # @raise [TimeTree::Error] if @client is not set.
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 members
76
- return @members if defined? @members
77
- raise Error, '@client is nil.' if @client.nil?
73
+ def labels
74
+ return @labels if defined? @labels
78
75
 
79
- @members = @client.calendar_members id
76
+ check_client
77
+ @labels = @client.calendar_labels id
80
78
  end
81
79
  end
82
80
  end
@@ -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
- raise Error, 'token is required.' unless ready_token?
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::ApiError] if the nhttp response status is not success.
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 to_model(data, included: nil)
243
- TimeTree::BaseModel.to_model data, client: self, included: included
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 ready_token?
247
- @token.is_a?(String) && !@token.empty?
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)
@@ -17,8 +17,8 @@ module TimeTree
17
17
  attr_accessor :end_at
18
18
  # @return [String]
19
19
  attr_accessor :end_timezone
20
- # @return [String]
21
- attr_accessor :recurrences
20
+ # @return [Array<String>]
21
+ attr_accessor :recurrence
22
22
  # @return [String]
23
23
  attr_accessor :recurring_uuid
24
24
  # @return [String]
@@ -38,9 +38,9 @@ module TimeTree
38
38
  # @return [TimeTree::User]
39
39
  attr_reader :creator
40
40
  # @return [TimeTree::Label]
41
- attr_reader :label
41
+ attr_accessor :label
42
42
  # @return [Array<TimeTree::User>]
43
- attr_reader :attendees
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 not set.
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
- raise Error, 'client is required.' if @client.nil?
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 not set.
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
- raise Error, '@client is nil.' if @client.nil?
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 not set.
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
- raise Error, '@client is nil.' if @client.nil?
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
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TimeTree
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.5'
5
5
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['source_code_uri'] = 'https://github.com/koshilife/timetree-api-ruby-client'
19
19
  spec.metadata['changelog_uri'] = "#{spec.metadata['source_code_uri']}/blob/master/CHANGELOG.md"
20
- spec.metadata['documentation_uri'] = 'https://www.rubydoc.info/gems/timetree/'
20
+ spec.metadata['documentation_uri'] = "https://www.rubydoc.info/gems/timetree/#{spec.version}"
21
21
 
22
22
  # Specify which files should be added to the gem when it is released.
23
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -37,4 +37,5 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency 'minitest-reporters', '~> 1.4.2'
38
38
  spec.add_development_dependency 'rake', '~> 12.0'
39
39
  spec.add_development_dependency 'webmock', '~> 3.7.6'
40
+ spec.add_development_dependency 'simplecov', '~> 0.18.5'
40
41
  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.0
4
+ version: 0.1.5
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-06-23 00:00:00.000000000 Z
11
+ date: 2020-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 3.7.6
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
125
139
  description: Client for accessing TimeTree APIs
126
140
  email:
127
141
  - koshikawa2009@gmail.com
@@ -129,9 +143,10 @@ executables: []
129
143
  extensions: []
130
144
  extra_rdoc_files: []
131
145
  files:
146
+ - ".github/workflows/gem-push.yml"
147
+ - ".github/workflows/test.yml"
132
148
  - ".gitignore"
133
149
  - ".rubocom.yml"
134
- - ".travis.yml"
135
150
  - CHANGELOG.md
136
151
  - CODE_OF_CONDUCT.md
137
152
  - Gemfile
@@ -160,7 +175,7 @@ metadata:
160
175
  homepage_uri: https://github.com/koshilife/timetree-api-ruby-client
161
176
  source_code_uri: https://github.com/koshilife/timetree-api-ruby-client
162
177
  changelog_uri: https://github.com/koshilife/timetree-api-ruby-client/blob/master/CHANGELOG.md
163
- documentation_uri: https://www.rubydoc.info/gems/timetree/
178
+ documentation_uri: https://www.rubydoc.info/gems/timetree/0.1.5
164
179
  post_install_message:
165
180
  rdoc_options: []
166
181
  require_paths:
@@ -176,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
191
  - !ruby/object:Gem::Version
177
192
  version: '0'
178
193
  requirements: []
179
- rubygems_version: 3.1.4
194
+ rubygems_version: 3.0.3
180
195
  signing_key:
181
196
  specification_version: 4
182
197
  summary: Client for accessing TimeTree APIs
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.6.3
6
- before_install: gem install bundler -v 2.1.4