timekit 0.1.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 +7 -0
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTING.md +47 -0
- data/LICENSE.md +20 -0
- data/README.md +359 -0
- data/lib/timekit/app/client.rb +32 -0
- data/lib/timekit/app.rb +6 -0
- data/lib/timekit/authorization.rb +17 -0
- data/lib/timekit/booking/client.rb +40 -0
- data/lib/timekit/booking.rb +6 -0
- data/lib/timekit/calendar/client.rb +37 -0
- data/lib/timekit/calendar.rb +6 -0
- data/lib/timekit/client.rb +45 -0
- data/lib/timekit/config.rb +16 -0
- data/lib/timekit/credential/client.rb +35 -0
- data/lib/timekit/credential.rb +6 -0
- data/lib/timekit/event/client.rb +94 -0
- data/lib/timekit/event.rb +6 -0
- data/lib/timekit/filtercollection.rb +87 -0
- data/lib/timekit/findtime/client.rb +41 -0
- data/lib/timekit/findtime/filtercollections/client.rb +28 -0
- data/lib/timekit/findtime.rb +6 -0
- data/lib/timekit/request.rb +39 -0
- data/lib/timekit/user/client.rb +40 -0
- data/lib/timekit/user.rb +45 -0
- data/lib/timekit/version.rb +45 -0
- data/lib/timekit/widget/client.rb +54 -0
- data/lib/timekit/widget.rb +6 -0
- data/lib/timekit.rb +65 -0
- data/timekit.gemspec +22 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a949e4226d697c9097cb9b375019fe09de090c6e
|
4
|
+
data.tar.gz: af28a8f0b4cef1cf9de19eee1d03b06f76a44d7e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 50ba7321a6251f3703446ec428530b2f7898901dac50b7c9ba0619c2ac206fc5a85e4d3a82afe8e2f83443c6023faf9fa6fa7b00c9f9b2fcb39516d26e438e51
|
7
|
+
data.tar.gz: 48a5d03e9c6f8a0d72483bd4303299b51c5059a0fe3e1497e811e3877e33cbda00e80e522322abd61d9fde1a73f4decab80baf4fe7024b247ea190824f9f8c5e
|
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
## Contributing
|
2
|
+
In the spirit of [free software][free-sw], **everyone** is encouraged to help
|
3
|
+
improve this project. Here are some ways *you* can contribute:
|
4
|
+
|
5
|
+
[free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
|
6
|
+
|
7
|
+
* Use alpha, beta, and pre-release versions.
|
8
|
+
* Report bugs.
|
9
|
+
* Suggest new features.
|
10
|
+
* Write or edit documentation.
|
11
|
+
* Write specifications.
|
12
|
+
* Write code (**no patch is too small**: fix typos, add comments, clean up
|
13
|
+
inconsistent whitespace).
|
14
|
+
* Refactor code.
|
15
|
+
* Fix [issues][].
|
16
|
+
* Review patches.
|
17
|
+
|
18
|
+
[issues]: https://github.com/mgauthier/timekit/issues
|
19
|
+
|
20
|
+
## Submitting an Issue
|
21
|
+
We use the [GitHub issue tracker][issues] to track bugs and features. Before
|
22
|
+
submitting a bug report or feature request, check to make sure it hasn't
|
23
|
+
already been submitted. When submitting a bug report, please include a [Gist][]
|
24
|
+
that includes a stack trace and any details that may be necessary to reproduce
|
25
|
+
the bug, including your gem version, Ruby version, and operating system.
|
26
|
+
Ideally, a bug report should include a pull request with failing specs.
|
27
|
+
|
28
|
+
[gist]: https://gist.github.com/
|
29
|
+
|
30
|
+
## Submitting a Pull Request
|
31
|
+
1. [Fork the repository.][fork]
|
32
|
+
2. [Create a topic branch.][branch]
|
33
|
+
3. Add specs for your unimplemented feature or bug fix.
|
34
|
+
4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
|
35
|
+
5. Implement your feature or bug fix.
|
36
|
+
6. Run `bundle exec rake`. If your specs fail, return to step 5.
|
37
|
+
7. Run `open coverage/index.html`. If your changes are not completely covered
|
38
|
+
by your tests, return to step 3.
|
39
|
+
8. Add documentation for your feature or bug fix.
|
40
|
+
9. Run `bundle exec rake verify_measurements`. If your changes are not 100%
|
41
|
+
documented, go back to step 8.
|
42
|
+
10. Commit and push your changes.
|
43
|
+
11. [Submit a pull request.][pr]
|
44
|
+
|
45
|
+
[fork]: http://help.github.com/fork-a-repo/
|
46
|
+
[branch]: http://learn.github.com/p/branching.html
|
47
|
+
[pr]: http://help.github.com/send-pull-requests/
|
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2016-2016 Michael Gauthier
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,359 @@
|
|
1
|
+
# The Timekit Ruby Gem
|
2
|
+
|
3
|
+
[][gem]
|
4
|
+
|
5
|
+
[gem]: https://rubygems.org/gems/timekit
|
6
|
+
|
7
|
+
A Ruby interface to the Timekit API.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
gem install timekit
|
11
|
+
|
12
|
+
## Configuration
|
13
|
+
Configure the Timekit client before using it
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
Timekit.configure({
|
17
|
+
app : 'your-app-name',
|
18
|
+
email : 'user@example.com',
|
19
|
+
api_token : 'your-api-token'
|
20
|
+
})
|
21
|
+
```
|
22
|
+
|
23
|
+
## Documentation
|
24
|
+
[http://developers.timekit.io/docs]
|
25
|
+
|
26
|
+
## Usage Examples
|
27
|
+
After configuring Timekit you can initialize a `client`,
|
28
|
+
and then you can do the following.
|
29
|
+
|
30
|
+
### Apps
|
31
|
+
|
32
|
+
**Initialize your client**
|
33
|
+
```ruby
|
34
|
+
client = Timekit.app_client
|
35
|
+
```
|
36
|
+
|
37
|
+
**List**
|
38
|
+
```ruby
|
39
|
+
client.list
|
40
|
+
```
|
41
|
+
|
42
|
+
**Create**
|
43
|
+
```ruby
|
44
|
+
client.create('app-name')
|
45
|
+
```
|
46
|
+
|
47
|
+
**Update**
|
48
|
+
```ruby
|
49
|
+
client.update('app-slug')
|
50
|
+
```
|
51
|
+
|
52
|
+
**Delete**
|
53
|
+
```ruby
|
54
|
+
client.delete('app-slug')
|
55
|
+
```
|
56
|
+
|
57
|
+
### Bookings
|
58
|
+
|
59
|
+
**Initialize your client**
|
60
|
+
```ruby
|
61
|
+
client = Timekit.booking_client
|
62
|
+
```
|
63
|
+
|
64
|
+
**List**
|
65
|
+
```ruby
|
66
|
+
client.list
|
67
|
+
```
|
68
|
+
|
69
|
+
**Show**
|
70
|
+
```ruby
|
71
|
+
client.show('booking-id')
|
72
|
+
```
|
73
|
+
|
74
|
+
**Create**
|
75
|
+
```ruby
|
76
|
+
client.create(
|
77
|
+
'booking-graph-type', # 'confirm-decline'
|
78
|
+
{
|
79
|
+
start: 'start-date',
|
80
|
+
end: 'end-date',
|
81
|
+
what: 'booking-title',
|
82
|
+
where: 'booking-address',
|
83
|
+
calendar_id: 'replace-with-id',
|
84
|
+
description: 'booking-description'
|
85
|
+
},
|
86
|
+
{
|
87
|
+
name: 'booking-customer-name',
|
88
|
+
email: 'booking-customer-email',
|
89
|
+
phone: 'booking-customer-phone',
|
90
|
+
voip: 'booking-customer-voip',
|
91
|
+
timezone: 'booking-timezone'
|
92
|
+
},
|
93
|
+
'booking-action', # 'create'
|
94
|
+
}
|
95
|
+
```
|
96
|
+
|
97
|
+
**Update**
|
98
|
+
```ruby
|
99
|
+
client.update('booking-id', 'confirm')
|
100
|
+
```
|
101
|
+
|
102
|
+
### Calendars
|
103
|
+
|
104
|
+
**Initialize your client**
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
client = Timekit.calendar_client
|
108
|
+
```
|
109
|
+
|
110
|
+
**List**
|
111
|
+
```ruby
|
112
|
+
client.list
|
113
|
+
```
|
114
|
+
|
115
|
+
**Show**
|
116
|
+
```ruby
|
117
|
+
client.show('calendar-id')
|
118
|
+
```
|
119
|
+
|
120
|
+
**Create**
|
121
|
+
```ruby
|
122
|
+
client.create(
|
123
|
+
'calendar-name',
|
124
|
+
'calendar-description',
|
125
|
+
'calendar-backgroundcolor',
|
126
|
+
'calendar-foregroundcolor'
|
127
|
+
}
|
128
|
+
```
|
129
|
+
|
130
|
+
**Update**
|
131
|
+
Not yet implemented
|
132
|
+
|
133
|
+
**Delete**
|
134
|
+
```ruby
|
135
|
+
client.delete('calendar-id')
|
136
|
+
```
|
137
|
+
|
138
|
+
|
139
|
+
### Credentials
|
140
|
+
|
141
|
+
**Initialize your client**
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
client = Timekit.credential_client
|
145
|
+
```
|
146
|
+
|
147
|
+
**List**
|
148
|
+
```ruby
|
149
|
+
client.list
|
150
|
+
```
|
151
|
+
|
152
|
+
**Create**
|
153
|
+
```ruby
|
154
|
+
client.create(
|
155
|
+
'credential-type',
|
156
|
+
'credential-scope',
|
157
|
+
'credential-description',
|
158
|
+
'credential-referrer',
|
159
|
+
'credential-expires',
|
160
|
+
)
|
161
|
+
```
|
162
|
+
|
163
|
+
**Delete**
|
164
|
+
```ruby
|
165
|
+
client.delete('credential-id')
|
166
|
+
```
|
167
|
+
|
168
|
+
### Events
|
169
|
+
|
170
|
+
**Initialize your client**
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
client = Timekit.event_client
|
174
|
+
```
|
175
|
+
|
176
|
+
**List**
|
177
|
+
```ruby
|
178
|
+
client.list(
|
179
|
+
'start-time',
|
180
|
+
'end-time'
|
181
|
+
)
|
182
|
+
```
|
183
|
+
|
184
|
+
**Show**
|
185
|
+
```ruby
|
186
|
+
client.show('event-id')
|
187
|
+
```
|
188
|
+
|
189
|
+
**Create**
|
190
|
+
```ruby
|
191
|
+
client.create(
|
192
|
+
'event-start',
|
193
|
+
'event-end',
|
194
|
+
'what',
|
195
|
+
'where',
|
196
|
+
'calendar_id',
|
197
|
+
'participants',
|
198
|
+
'invite',
|
199
|
+
'description',
|
200
|
+
'sync_provider',
|
201
|
+
'my_rsvp',
|
202
|
+
'all_day'
|
203
|
+
)
|
204
|
+
```
|
205
|
+
|
206
|
+
**Update**
|
207
|
+
|
208
|
+
```ruby
|
209
|
+
client.update(
|
210
|
+
'event-id',
|
211
|
+
'event-start',
|
212
|
+
'event-end',
|
213
|
+
'what',
|
214
|
+
'where',
|
215
|
+
'participants',
|
216
|
+
'all_day'
|
217
|
+
)
|
218
|
+
```
|
219
|
+
|
220
|
+
**Delete**
|
221
|
+
```ruby
|
222
|
+
client.delete('event-id')
|
223
|
+
```
|
224
|
+
|
225
|
+
### Findtime
|
226
|
+
|
227
|
+
**Initialize your client**
|
228
|
+
|
229
|
+
```ruby
|
230
|
+
client = Timekit.findtime_client
|
231
|
+
```
|
232
|
+
|
233
|
+
### User
|
234
|
+
|
235
|
+
**Initialize your client**
|
236
|
+
|
237
|
+
```ruby
|
238
|
+
client = Timekit.user_client
|
239
|
+
```
|
240
|
+
|
241
|
+
**Me**
|
242
|
+
```ruby
|
243
|
+
client.me
|
244
|
+
```
|
245
|
+
|
246
|
+
**Timezone**
|
247
|
+
```ruby
|
248
|
+
client.timezone('user-email')
|
249
|
+
```
|
250
|
+
|
251
|
+
**Update**
|
252
|
+
|
253
|
+
```ruby
|
254
|
+
client.update(
|
255
|
+
'user-first_name',
|
256
|
+
'user-last_name',
|
257
|
+
'user-timezone',
|
258
|
+
'user-password'
|
259
|
+
)
|
260
|
+
```
|
261
|
+
|
262
|
+
**Reset Password**
|
263
|
+
```ruby
|
264
|
+
client.reset_password('user-email')
|
265
|
+
```
|
266
|
+
|
267
|
+
### Widget
|
268
|
+
|
269
|
+
**Initialize your client**
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
client = Timekit.widget_client
|
273
|
+
```
|
274
|
+
|
275
|
+
**List**
|
276
|
+
```ruby
|
277
|
+
client.list
|
278
|
+
```
|
279
|
+
|
280
|
+
**Embed**
|
281
|
+
```ruby
|
282
|
+
client.embed('widget-id')
|
283
|
+
```
|
284
|
+
|
285
|
+
**Hosted**
|
286
|
+
```ruby
|
287
|
+
client.hosted('widget-id')
|
288
|
+
```
|
289
|
+
|
290
|
+
**Create**
|
291
|
+
|
292
|
+
```ruby
|
293
|
+
client.create(
|
294
|
+
'widget-config',
|
295
|
+
'widget-name',
|
296
|
+
'widget-slug',
|
297
|
+
)
|
298
|
+
```
|
299
|
+
|
300
|
+
|
301
|
+
**Update**
|
302
|
+
|
303
|
+
```ruby
|
304
|
+
client.update(
|
305
|
+
'widget-id',
|
306
|
+
'widget-config',
|
307
|
+
'widget-name',
|
308
|
+
'widget-slug',
|
309
|
+
)
|
310
|
+
```
|
311
|
+
|
312
|
+
**Delete**
|
313
|
+
```ruby
|
314
|
+
client.delete('widget-id')
|
315
|
+
```
|
316
|
+
|
317
|
+
|
318
|
+
## Supported Ruby Versions
|
319
|
+
This library aims to support and is [tested against][travis] the following Ruby
|
320
|
+
versions:
|
321
|
+
|
322
|
+
* Ruby 2.0.0
|
323
|
+
* Ruby 2.1
|
324
|
+
* Ruby 2.2
|
325
|
+
* JRuby 9.1.1.0
|
326
|
+
|
327
|
+
If something doesn't work on one of these versions, it's a bug.
|
328
|
+
|
329
|
+
This library may inadvertently work (or seem to work) on other Ruby versions,
|
330
|
+
however support will only be provided for the versions listed above.
|
331
|
+
|
332
|
+
If you would like this library to support another Ruby version or
|
333
|
+
implementation, you may volunteer to be a maintainer. Being a maintainer
|
334
|
+
entails making sure all tests run and pass on that implementation. When
|
335
|
+
something breaks on your implementation, you will be responsible for providing
|
336
|
+
patches in a timely fashion. If critical issues for a particular implementation
|
337
|
+
exist at the time of a major release, support for that Ruby version may be
|
338
|
+
dropped.
|
339
|
+
|
340
|
+
## Versioning
|
341
|
+
This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
|
342
|
+
of this scheme should be reported as bugs. Specifically, if a minor or patch
|
343
|
+
version is released that breaks backward compatibility, that version should be
|
344
|
+
immediately yanked and/or a new version should be immediately released that
|
345
|
+
restores compatibility. Breaking changes to the public API will only be
|
346
|
+
introduced with new major versions. As a result of this policy, you can (and
|
347
|
+
should) specify a dependency on this gem using the [Pessimistic Version
|
348
|
+
Constraint][pvc] with two digits of precision. For example:
|
349
|
+
|
350
|
+
spec.add_dependency 'timekit', '~> 1.0'
|
351
|
+
|
352
|
+
[semver]: http://semver.org/
|
353
|
+
[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
354
|
+
|
355
|
+
## Copyright
|
356
|
+
Copyright (c) 20016-2016 Michael Gauthier
|
357
|
+
See [LICENSE][] for details.
|
358
|
+
|
359
|
+
[license]: LICENSE.md
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Timekit
|
2
|
+
class App
|
3
|
+
# Client class for the app resource
|
4
|
+
class Client < Timekit::Client
|
5
|
+
API_PATH = '/apps'.freeze
|
6
|
+
|
7
|
+
def list
|
8
|
+
get(API_PATH)
|
9
|
+
end
|
10
|
+
|
11
|
+
def create(name, settings = {})
|
12
|
+
params = {
|
13
|
+
name: name
|
14
|
+
}
|
15
|
+
|
16
|
+
params[:settings] = settings if settings
|
17
|
+
|
18
|
+
post(API_PATH, params)
|
19
|
+
end
|
20
|
+
|
21
|
+
def update(slug, settings)
|
22
|
+
params = settings
|
23
|
+
|
24
|
+
put(API_PATH + '/' + slug, params)
|
25
|
+
end
|
26
|
+
|
27
|
+
def delete(slug)
|
28
|
+
super(API_PATH + '/' + slug)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/timekit/app.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Timekit
|
2
|
+
class Booking
|
3
|
+
# Client class for the booking resource
|
4
|
+
class Client < Timekit::Client
|
5
|
+
API_PATH = '/bookings'.freeze
|
6
|
+
|
7
|
+
def list
|
8
|
+
get(API_PATH)
|
9
|
+
end
|
10
|
+
|
11
|
+
def show(id)
|
12
|
+
get(API_PATH + '/' + id)
|
13
|
+
end
|
14
|
+
|
15
|
+
def create(
|
16
|
+
graph,
|
17
|
+
event,
|
18
|
+
customer,
|
19
|
+
action = nil
|
20
|
+
)
|
21
|
+
params = {
|
22
|
+
graph: graph,
|
23
|
+
event: event,
|
24
|
+
customer: customer
|
25
|
+
}
|
26
|
+
|
27
|
+
params[:action] = action if action
|
28
|
+
|
29
|
+
post(API_PATH, params)
|
30
|
+
end
|
31
|
+
|
32
|
+
def update(
|
33
|
+
id,
|
34
|
+
action
|
35
|
+
)
|
36
|
+
put(API_PATH + '/' + id + '/' + action)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Timekit
|
2
|
+
class Calendar
|
3
|
+
# Client class for the calendar resource
|
4
|
+
class Client < Timekit::Client
|
5
|
+
API_PATH = '/calendars'.freeze
|
6
|
+
|
7
|
+
def create(
|
8
|
+
name,
|
9
|
+
description,
|
10
|
+
background_color = nil,
|
11
|
+
foreground_color = nil
|
12
|
+
)
|
13
|
+
params = {
|
14
|
+
name: name,
|
15
|
+
description: description
|
16
|
+
}
|
17
|
+
|
18
|
+
params[:backgroundcolor] = background_color if background_color
|
19
|
+
params[:foregroundcolor] = foreground_color if foreground_color
|
20
|
+
|
21
|
+
post(API_PATH, params)
|
22
|
+
end
|
23
|
+
|
24
|
+
def list
|
25
|
+
get(API_PATH)
|
26
|
+
end
|
27
|
+
|
28
|
+
def show(id)
|
29
|
+
get(API_PATH + '/' + id.to_s)
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete(id)
|
33
|
+
super(API_PATH + '/' + id.to_s)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module Timekit
|
4
|
+
class Client
|
5
|
+
def initialize(app = nil, authorization = nil)
|
6
|
+
@app = app || Timekit.config[:app]
|
7
|
+
@authorization = authorization || Timekit.config[:credentials]
|
8
|
+
|
9
|
+
raise 'No app configured' if @app.nil?
|
10
|
+
raise 'No authorization configured' if @authorization.nil?
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
#
|
16
|
+
# Wrapper method for the timekit request methods of the same names
|
17
|
+
#
|
18
|
+
[:get, :put, :post, :delete].each do |verb|
|
19
|
+
define_method(verb) do |path, params = {}|
|
20
|
+
# puts "Timekit::Client::#{verb} => #{path}#{token}"
|
21
|
+
headers = {
|
22
|
+
'Timekit-App' => @app,
|
23
|
+
'Authorization' => http_basic_auth_header
|
24
|
+
}
|
25
|
+
|
26
|
+
Timekit::Request.instance.send(
|
27
|
+
__method__,
|
28
|
+
path,
|
29
|
+
params,
|
30
|
+
headers
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def http_basic_auth_header
|
38
|
+
encoded = Base64.strict_encode64(
|
39
|
+
"#{@authorization.email}:#{@authorization.api_token}"
|
40
|
+
)
|
41
|
+
|
42
|
+
"Basic #{encoded}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Timekit
|
2
|
+
class Config < Hash
|
3
|
+
CONFIG_KEYS = [
|
4
|
+
:credentials,
|
5
|
+
:app
|
6
|
+
].freeze
|
7
|
+
|
8
|
+
def []=(key, value)
|
9
|
+
raise 'Invalid config key' unless CONFIG_KEYS.include?(key)
|
10
|
+
raise 'Invalid config credentials' if key == :credentials &&
|
11
|
+
!value.is_a?(Timekit::Authorization)
|
12
|
+
|
13
|
+
super(key, value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Timekit
|
2
|
+
class Credential
|
3
|
+
# Client class for the credential resource
|
4
|
+
class Client < Timekit::Client
|
5
|
+
API_PATH = '/credentials'.freeze
|
6
|
+
|
7
|
+
def list
|
8
|
+
get(API_PATH)
|
9
|
+
end
|
10
|
+
|
11
|
+
def create(
|
12
|
+
type, # 'client-token' or 'server-token'
|
13
|
+
scopes, # 'global' or 'widget'
|
14
|
+
description,
|
15
|
+
referrer = nil,
|
16
|
+
expires = nil # default 1 year from now (timestamp)
|
17
|
+
)
|
18
|
+
params = {
|
19
|
+
type: type,
|
20
|
+
scopes: scopes,
|
21
|
+
description: description
|
22
|
+
}
|
23
|
+
|
24
|
+
params[:referrer] = referrer if referrer
|
25
|
+
params[:expires] = expires if expires
|
26
|
+
|
27
|
+
post(API_PATH, params)
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete(id)
|
31
|
+
super(API_PATH + '/' + id.to_s)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|