cronofy 0.0.5 → 0.37.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1be096b17b4eb2b3422337a2d168b7f27559493c
4
- data.tar.gz: e696a6175e17d0465912d7810342cfd1352b7191
2
+ SHA256:
3
+ metadata.gz: 72f9a743962bf3c47bdef28e93c0fd4d7cf5fd66101eec219f028ea90fe6291c
4
+ data.tar.gz: ec455881ea2d6df1e86896508453dbcc6d89173275d23a1fe92b565ee01e1144
5
5
  SHA512:
6
- metadata.gz: 5ea577cd0076d2aa66cdf8c7ecd6791aa1d80ef216a51535d51a46b351b586ef7fcb4456ce8cb4be78c010f8bcf82f6b12239f82d2948131324c6ae746696f9b
7
- data.tar.gz: 0071814777c83e679d6b704595b756c6aa709c4540430fff18a2b29caefcbbeca8309390931259fd9b5c5159fb1e82c34920e2f9c65aebe11ee6490919223d74
6
+ metadata.gz: c00a81c85732364c3b6cc384c9bbdc1f10fbacfa756c09959734abbefbe65f58f9de764a8e019f40ba0ec17f4355fb4900c4a457e0cac2d98a0a8dfc653886fd
7
+ data.tar.gz: 6529d3936e84d1721b458bfdfd2acb91585ba7b425d49c7b839f2cdce621d7ae1ba9d1896c471aaecdc6e16474c6f7b0002aa09a64b1390684e5601fa64f35c7
data/CHANGELOG.md ADDED
@@ -0,0 +1,262 @@
1
+ ## [0.37.7]
2
+
3
+ * Update Gem description
4
+
5
+ ## [0.37.6]
6
+
7
+ * Adds support for disabling and fetching the status of Real-Time Scheduling links [#100]
8
+
9
+ ## [0.37.5]
10
+
11
+ * Support `query_periods` as well as the original `available_periods` for Real-Time Scheduling and Real-Time Sequencing [#99]
12
+
13
+ ## [0.37.4]
14
+
15
+ * Support client_secret only clients being able to authorize `#availability` calls. [#97]
16
+
17
+ ## [0.37.3]
18
+
19
+ * Support `hmac_valid` as well as the original `hmac_match` for Client to verify a HMAC from a push notification using the client's secret.[#95]
20
+
21
+ ## [0.37.2]
22
+
23
+ * Support `query_periods` as well as the original `available_periods` for Availability Query and Sequenced Availability [#91]
24
+
25
+ ## [0.37.1]
26
+
27
+ * Rename `data_centre` to `data_centre` (with aliases for backwards compatibility) [#90]
28
+
29
+ ## [0.37.0]
30
+
31
+ * Add `revoke_by_token` and `revoke_by_sub` to the Client [#86]
32
+
33
+ ## [0.36.1]
34
+
35
+ * Loosen the version requirement on Hashie to allow 4.X
36
+
37
+ ## [0.36.0]
38
+
39
+ * Add support for Available Periods [#81]
40
+
41
+ ## [0.35.0]
42
+
43
+ * Add specific errors for network issues [#77]
44
+
45
+ ## [0.34.0]
46
+
47
+ * Support removing a participant from a Smart Invite [#75]
48
+
49
+ ## [0.33.0]
50
+
51
+ * Support listing Availability Rules [#74]
52
+
53
+ ## [0.32.0]
54
+
55
+ * Support Availability Rules and Scheduling Conversations [#64]
56
+
57
+ ## [0.31.2]
58
+
59
+ * Support parsing new Availability response formats [#73]
60
+
61
+ ## [0.31.1]
62
+
63
+ * No Authorization header for Real-Time Scheduling and Real-Time Sequencing [#72]
64
+
65
+ ## [0.31.0]
66
+
67
+ * Added support for Element Tokens [#69]
68
+
69
+ ## [0.30.0]
70
+
71
+ * Added support for sequencing, buffers and intervals [#62]
72
+ * Dropped support for Ruby 2.1
73
+
74
+ ## [0.29.0]
75
+
76
+ * Added types for propose new time replies [#60]
77
+
78
+ ## [0.28.1]
79
+
80
+ * Fixed double encoding issue [#59]
81
+
82
+ ## [0.28.0]
83
+
84
+ * Added support for handling subs from Token responses [#58]
85
+
86
+ ## [0.27.0]
87
+
88
+ * Added support for Application Calendars [#57]
89
+
90
+ ## [0.26.1]
91
+
92
+ * Prevent error when disable\_warnings not available [#56]
93
+
94
+ ## [0.26.0]
95
+
96
+ * Support for batch endpoint [#53]
97
+
98
+ ## [0.25.1]
99
+
100
+ * Support for Cancelling Smart Invites [#55]
101
+
102
+ ## [0.25.0]
103
+
104
+ * Support for Smart Invites [#49]
105
+ * Fix warning in Ruby 2.4 [#50]
106
+
107
+ ## [0.24.1]
108
+
109
+ * Disable Hashie warnings [#52]
110
+
111
+ ## [0.24.0]
112
+
113
+ * Support for revoking profile authorization [#48]
114
+
115
+ ## [0.23.0]
116
+
117
+ * Support for color with calendar creation and event upsert [#46]
118
+ * Helper to verify push notification HMACs [#45]
119
+
120
+ ## [0.22.0]
121
+
122
+ * Splitting of Add to Calendar and Real time scheduling [#44]
123
+ * Support for explicit linking of accounts [#43]
124
+
125
+ ## [0.21.0]
126
+
127
+ * Support Add To Calendar with availability [#40]
128
+
129
+ ## [0.20.0]
130
+
131
+ * Change invalid request message to include errors [#36]
132
+ * Pass through times as-is if already Strings [#37]
133
+ * Support bulk delete from specific calendars [#38]
134
+
135
+ ## [0.19.0]
136
+
137
+ * Support setting event transparency [#31]
138
+ * Support Add To Calendar [#35]
139
+
140
+ ## [0.18.0]
141
+
142
+ * Support multiple data centres [#30]
143
+
144
+ ## [0.17.0]
145
+
146
+ * Support member-specific available periods for Availability API [#27]
147
+
148
+ ## [0.16.0]
149
+
150
+ * Support Availability API [#26]
151
+
152
+ ## [0.15.0]
153
+
154
+ * Support for upcoming geo location feature [#24]
155
+
156
+ ## [0.14.0]
157
+
158
+ * Support for setting participant status [#20]
159
+
160
+ ## [0.13.0]
161
+
162
+ * Support for listing resources [#18]
163
+
164
+ ## [0.12.0]
165
+
166
+ * Support for deleting external events [#17]
167
+
168
+ ## [0.11.0]
169
+
170
+ * Support for Enterprise Connect [#13]
171
+ * Support for elevating permissions [#16]
172
+
173
+
174
+ [0.11.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.11.0
175
+ [0.12.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.12.0
176
+ [0.13.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.13.0
177
+ [0.14.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.14.0
178
+ [0.15.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.15.0
179
+ [0.16.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.16.0
180
+ [0.17.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.17.0
181
+ [0.18.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.18.0
182
+ [0.19.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.19.0
183
+ [0.20.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.20.0
184
+ [0.21.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.21.0
185
+ [0.22.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.22.0
186
+ [0.23.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.23.0
187
+ [0.24.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.24.0
188
+ [0.24.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.24.1
189
+ [0.25.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.25.0
190
+ [0.25.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.25.1
191
+ [0.26.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.26.0
192
+ [0.26.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.26.1
193
+ [0.27.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.27.0
194
+ [0.28.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.28.0
195
+ [0.28.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.28.1
196
+ [0.29.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.29.0
197
+ [0.30.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.30.0
198
+ [0.31.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.0
199
+ [0.31.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.1
200
+ [0.31.2]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.2
201
+ [0.32.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.32.0
202
+ [0.33.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.33.0
203
+ [0.34.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.34.0
204
+ [0.35.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.35.0
205
+ [0.36.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.36.0
206
+ [0.36.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.36.1
207
+ [0.37.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.0
208
+ [0.37.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.1
209
+ [0.37.2]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.2
210
+ [0.37.3]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.3
211
+ [0.37.4]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.4
212
+ [0.37.5]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.5
213
+ [0.37.6]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.6
214
+ [0.37.7]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.7
215
+
216
+ [#13]: https://github.com/cronofy/cronofy-ruby/pull/13
217
+ [#16]: https://github.com/cronofy/cronofy-ruby/pull/16
218
+ [#17]: https://github.com/cronofy/cronofy-ruby/pull/17
219
+ [#18]: https://github.com/cronofy/cronofy-ruby/pull/18
220
+ [#20]: https://github.com/cronofy/cronofy-ruby/pull/20
221
+ [#24]: https://github.com/cronofy/cronofy-ruby/pull/24
222
+ [#26]: https://github.com/cronofy/cronofy-ruby/pull/26
223
+ [#27]: https://github.com/cronofy/cronofy-ruby/pull/27
224
+ [#30]: https://github.com/cronofy/cronofy-ruby/pull/30
225
+ [#31]: https://github.com/cronofy/cronofy-ruby/pull/31
226
+ [#35]: https://github.com/cronofy/cronofy-ruby/pull/35
227
+ [#36]: https://github.com/cronofy/cronofy-ruby/pull/36
228
+ [#37]: https://github.com/cronofy/cronofy-ruby/pull/37
229
+ [#38]: https://github.com/cronofy/cronofy-ruby/pull/38
230
+ [#40]: https://github.com/cronofy/cronofy-ruby/pull/40
231
+ [#43]: https://github.com/cronofy/cronofy-ruby/pull/43
232
+ [#44]: https://github.com/cronofy/cronofy-ruby/pull/44
233
+ [#45]: https://github.com/cronofy/cronofy-ruby/pull/45
234
+ [#46]: https://github.com/cronofy/cronofy-ruby/pull/46
235
+ [#48]: https://github.com/cronofy/cronofy-ruby/pull/48
236
+ [#49]: https://github.com/cronofy/cronofy-ruby/pull/49
237
+ [#50]: https://github.com/cronofy/cronofy-ruby/pull/50
238
+ [#52]: https://github.com/cronofy/cronofy-ruby/pull/52
239
+ [#53]: https://github.com/cronofy/cronofy-ruby/pull/53
240
+ [#55]: https://github.com/cronofy/cronofy-ruby/pull/55
241
+ [#56]: https://github.com/cronofy/cronofy-ruby/pull/56
242
+ [#57]: https://github.com/cronofy/cronofy-ruby/pull/57
243
+ [#58]: https://github.com/cronofy/cronofy-ruby/pull/58
244
+ [#59]: https://github.com/cronofy/cronofy-ruby/pull/59
245
+ [#60]: https://github.com/cronofy/cronofy-ruby/pull/60
246
+ [#62]: https://github.com/cronofy/cronofy-ruby/pull/62
247
+ [#64]: https://github.com/cronofy/cronofy-ruby/pull/64
248
+ [#69]: https://github.com/cronofy/cronofy-ruby/pull/69
249
+ [#72]: https://github.com/cronofy/cronofy-ruby/pull/72
250
+ [#73]: https://github.com/cronofy/cronofy-ruby/pull/73
251
+ [#74]: https://github.com/cronofy/cronofy-ruby/pull/74
252
+ [#75]: https://github.com/cronofy/cronofy-ruby/pull/75
253
+ [#77]: https://github.com/cronofy/cronofy-ruby/pull/77
254
+ [#81]: https://github.com/cronofy/cronofy-ruby/pull/81
255
+ [#85]: https://github.com/cronofy/cronofy-ruby/pull/85
256
+ [#86]: https://github.com/cronofy/cronofy-ruby/pull/86
257
+ [#90]: https://github.com/cronofy/cronofy-ruby/pull/90
258
+ [#91]: https://github.com/cronofy/cronofy-ruby/pull/91
259
+ [#95]: https://github.com/cronofy/cronofy-ruby/pull/95
260
+ [#97]: https://github.com/cronofy/cronofy-ruby/pull/97
261
+ [#99]: https://github.com/cronofy/cronofy-ruby/pull/99
262
+ [#100]: https://github.com/cronofy/cronofy-ruby/pull/100
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem "rack", "~> 1.0"
data/README.md CHANGED
@@ -1,10 +1,9 @@
1
1
  # Cronofy
2
2
 
3
- [![Build Status](https://travis-ci.org/cronofy/cronofy-ruby.svg?branch=master)](https://travis-ci.org/cronofy/cronofy-ruby)
3
+ [![ruby CI](https://github.com/cronofy/cronofy-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/cronofy/cronofy-ruby/actions/workflows/ci.yml)
4
4
  [![Gem Version](https://badge.fury.io/rb/cronofy.svg)](http://badge.fury.io/rb/cronofy)
5
- [![Join the chat at https://gitter.im/cronofy/cronofy-ruby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cronofy/cronofy-ruby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
6
5
 
7
- [Cronofy](http://www.cronofy.com) - one API for all the calendars (Google, Outlook, iCloud, Exchange). This gem is an interface for easy use of [Cronofy API](http://www.cronofy.com/developers/api) with Ruby.
6
+ [Cronofy](https://www.cronofy.com) - the scheduling platform for business
8
7
 
9
8
  ## Installation
10
9
 
@@ -14,83 +13,138 @@ Add this line to your application's Gemfile:
14
13
  gem 'cronofy'
15
14
  ```
16
15
 
17
- And then execute:
16
+ And then at your command prompt run:
18
17
 
19
- $ bundle
18
+ ```
19
+ bundle install
20
+ ```
20
21
 
21
- Or install it yourself as:
22
+ ## Usage
22
23
 
23
- $ gem install cronofy
24
+ In order to use the Cronofy API you will need to [create a developer account](https://app.cronofy.com/sign_up/new).
24
25
 
25
- ## Usage
26
+ From there you can [create an OAuth application](https://app.cronofy.com/oauth/applications/new)
27
+ to obtain an OAuth `client_id` and `client_secret` to be able to use the full API.
28
+
29
+ ## Creating a client
30
+
31
+ To make calls to the Cronofy API you must create a `Cronofy::Client`. This takes
32
+ five keyword arguments, all of which are optional:
26
33
 
27
- You have to register on cronofy website and create an application there. You will get a client id and client secret which you will have to pass to initializer. You can also pass a token and refresh token that you will get later, or leave it blank in case if you don't have it now:
28
34
  ```ruby
29
- cronofy = Cronofy::Client.new('CLIENT_ID', 'CLIENT_SECRET', 'TOKEN', 'REFRESH_TOKEN')
35
+ cronofy = Cronofy::Client.new(
36
+ client_id: 'CLIENT_ID',
37
+ client_secret: 'CLIENT_SECRET',
38
+ access_token: 'ACCESS_TOKEN',
39
+ refresh_token: 'REFRESH_TOKEN',
40
+ data_center: :de
41
+ )
30
42
  ```
31
43
 
32
- Generate a link for a user to grant access for his calendars:
44
+ When using a [personal access token](https://app.cronofy.com/oauth/applications/5447ae289bd94726da00000f/tokens)
45
+ you only need to provide the `access_token` argument.
46
+
47
+ When working against your own OAuth application you will need to provide the
48
+ `client_id` and `client_secret` when [going through the authorization process](https://www.cronofy.com/developers/api/#authorization)
49
+ for a user, and when [refreshing an access token](https://www.cronofy.com/developers/api/#token-refresh).
50
+
51
+ If `client_id` and `client_secret` are not specified explicitly the values from
52
+ the environment variables `CRONOFY_CLIENT_ID` and `CRONOFY_CLIENT_SECRET` will
53
+ be used if present.
54
+
55
+ `data_center` is the two-letter designation for the data center you want to operate against - for example `:de` for Germany, or `:au` for Australia. When omitted, this defaults to the US data center.
56
+
57
+ ## Authorization
58
+
59
+ [API documentation](https://www.cronofy.com/developers/api/#authorization)
60
+
61
+ Generate a link for a user to grant access to their calendars:
62
+
33
63
  ```ruby
34
- cronofy.user_auth_link('http://localhost:3000/oauth2/callback')
64
+ authorization_url = cronofy.user_auth_link('http://yoursite.dev/oauth2/callback')
35
65
  ```
36
66
 
37
- The specified url is a page on your website that will handle callback and get a code parameter out of it. On a callback you will have a param[:code] that you will need in order to get a token:
67
+ The callback URL is a page on your website that will handle the OAuth 2.0
68
+ callback and receive a `code` parameter. You can then use that code to retrieve
69
+ an OAuth token granting access to the user's Cronofy account:
70
+
38
71
  ```ruby
39
- token = cronofy.get_token_from_code(code, 'http://localhost:3000/oauth2/callback')
72
+ response = cronofy.get_token_from_code(code, 'http://yoursite.dev/oauth2/callback')
40
73
  ```
41
- You can now save a token to pass it later to initializer.
42
74
 
43
- Get a list of all the user calendars:
75
+ You should save the response's `access_token` and `refresh_token` for later use.
76
+
77
+ Note that the **exact same** callback URL must be passed to both methods for
78
+ access to be granted.
79
+
80
+ If you use the [omniauth gem](https://rubygems.org/gems/omniauth), you can use
81
+ our [omniauth-cronofy strategy gem](https://rubygems.org/gems/omniauth-cronofy)
82
+ to perform this process.
83
+
84
+ ## List calendars
85
+
86
+ [API documentation](https://www.cronofy.com/developers/api/#calendars)
87
+
88
+ Get a list of all the user's calendars:
89
+
44
90
  ```ruby
45
- cronofy.list_calendars
91
+ calendars = cronofy.list_calendars
46
92
  ```
47
93
 
48
- You will get a list of user's calendars in a json format. The example of such a response:
49
- ```json
50
- {
51
- "calendars":[
52
- {
53
- "provider_name":"google",
54
- "profile_name":"YYYYYYYY@gmail.com",
55
- "calendar_id":"cal_YYYYYYYY-UNIQUE_CAL_ID_HERE-YYYYYYYY",
56
- "calendar_name":"Office Calendar",
57
- "calendar_readonly":false,
58
- "calendar_deleted":false
59
- },
60
- {
61
- "provider_name":"google",
62
- "profile_name":"XXXXXXX@gmail.com",
63
- "calendar_id":"cal_XXXXXXXX-UNIQUE_CAL_ID_HERE-XXXXXXXXX",
64
- "calendar_name":"Home Calendar",
65
- "calendar_readonly":false,
66
- "calendar_deleted":false
67
- }
68
- ]
69
- }
94
+ ## Read events
95
+
96
+ [API documentation](https://www.cronofy.com/developers/api/#read-events)
97
+
98
+ Get a list of events from the user's calendars:
99
+
100
+ ```ruby
101
+ events = cronofy.read_events
70
102
  ```
71
103
 
72
- To create/update an event in user's calendar:
104
+ Note that the gem handles iterating through the pages on your behalf.
105
+
106
+ ## Create or update events
107
+
108
+ [API documentation](https://www.cronofy.com/developers/api/#upsert-event)
109
+
110
+ To create/update an event in the user's calendar:
111
+
73
112
  ```ruby
74
113
  event_data = {
75
- event_id: 'uniq-id', # uniq id of event
114
+ event_id: 'uniq-id',
76
115
  summary: 'Event summary',
77
116
  description: 'Event description',
78
- start: Time.now + 60 * 60 * 24, # will be converted to .utc.iso8601 internally,
79
- end: Time.now + 60 * 60 * 25, # the same convertion here
117
+ start: Time.now + 60 * 60 * 24,
118
+ end: Time.now + 60 * 60 * 25,
80
119
  location: {
81
120
  description: "Meeting room"
82
121
  }
83
122
  }
84
- cronofy.upsert(calendar_id, event_data)
123
+
124
+ cronofy.upsert_event(calendar_id, event_data)
85
125
  ```
86
126
 
127
+ ## Delete events
128
+
129
+ [API documentation](https://www.cronofy.com/developers/api/#delete-event)
130
+
87
131
  To delete an event from user's calendar:
132
+
88
133
  ```ruby
89
- cronofy.delete_event(calendar_id, event_id)
134
+ cronofy.delete_event(calendar_id, 'uniq-id')
90
135
  ```
91
136
 
137
+ ## A feature I want is not in the SDK, how do I get it?
138
+
139
+ We add features to this SDK as they are requested, to focus on developing the Cronofy API.
140
+
141
+ If you're comfortable contributing support for an endpoint or attribute, then we love to receive pull requests!
142
+ Please create a PR mentioning the feature/API endpoint you’ve added and we’ll review it as soon as we can.
143
+
144
+ If you would like to request a feature is added by our team then please let us know by getting in touch via [support@cronofy.com](mailto:support@cronofy.com).
145
+
92
146
  ## Links
93
147
 
94
- * [API Docs](http://www.cronofy.com/developers/api)
148
+ * [API documentation](https://www.cronofy.com/developers/api)
95
149
  * [API mailing list](https://groups.google.com/d/forum/cronofy-api)
96
150
 
data/cronofy.gemspec CHANGED
@@ -1,24 +1,27 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'cronofy/version'
1
+ require File.expand_path('../lib/cronofy/version', __FILE__)
5
2
 
6
3
  Gem::Specification.new do |spec|
7
4
  spec.name = "cronofy"
8
5
  spec.version = Cronofy::VERSION
9
- spec.authors = ["Sergii Paryzhskyi"]
10
- spec.email = ["parizhskiy@gmail.com"]
11
- spec.summary = %q{Cronofy - one API for all the calendars}
6
+ spec.authors = ["Sergii Paryzhskyi", "Garry Shutler"]
7
+ spec.email = ["parizhskiy@gmail.com", "garry@cronofy.com"]
8
+ spec.summary = %q{Cronofy - the scheduling platform for business}
9
+ spec.description = %q{SDK for Cronofy - the Scheduling Platform for Business}
12
10
  spec.homepage = "https://github.com/cronofy/cronofy-ruby"
13
11
  spec.license = "MIT"
14
12
 
15
- spec.files = `git ls-files -z`.split("\x0")
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
13
  spec.require_paths = ["lib"]
19
14
 
20
- spec.add_development_dependency "bundler", "~> 1.7"
21
- spec.add_development_dependency "rake", "~> 10.0"
22
- spec.add_development_dependency "rspec", "~> 3.2"
15
+ spec.files = %w{CHANGELOG.md Gemfile LICENSE.txt README.md Rakefile cronofy.gemspec}
16
+ spec.files += Dir['lib/**/*.rb']
17
+ spec.files += Dir['spec/**/*.rb']
18
+ spec.test_files = Dir['spec/**/*.rb']
19
+
20
+ spec.add_runtime_dependency "hashie", ">= 2.1", "< 5"
23
21
  spec.add_runtime_dependency "oauth2", "~> 1.0"
22
+
23
+ spec.add_development_dependency "bundler", ">= 1.6", "< 3"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.2"
26
+ spec.add_development_dependency "webmock", "~> 3.9.1"
24
27
  end
@@ -0,0 +1,73 @@
1
+ require "oauth2"
2
+
3
+ module Cronofy
4
+ class ApiKey
5
+ def initialize(client, client_secret)
6
+ @client = client
7
+ @client_secret = client_secret
8
+ end
9
+
10
+ # Make a request with the API Key
11
+ #
12
+ # @param [Symbol] verb the HTTP request method
13
+ # @param [String] path the HTTP URL path of the request
14
+ # @param [Hash] opts the options to make the request with
15
+ # @see Client#request
16
+ def request(verb, path, opts = {}, &block)
17
+ configure_authentication!(opts)
18
+ do_request { @client.request(verb, path, opts, &block) }
19
+ end
20
+
21
+ # Make a GET request with the API Key
22
+ #
23
+ # @see ApiKey#request
24
+ def get(path, opts = {}, &block)
25
+ request(:get, path, opts, &block)
26
+ end
27
+
28
+ # Make a POST request with the API Key
29
+ #
30
+ # @see ApiKey#request
31
+ def post(path, opts = {}, &block)
32
+ request(:post, path, opts, &block)
33
+ end
34
+
35
+ # Make a PUT request with the API Key
36
+ #
37
+ # @see ApiKey#request
38
+ def put(path, opts = {}, &block)
39
+ request(:put, path, opts, &block)
40
+ end
41
+
42
+ # Make a PATCH request with the API Key
43
+ #
44
+ # @see ApiKey#request
45
+ def patch(path, opts = {}, &block)
46
+ request(:patch, path, opts, &block)
47
+ end
48
+
49
+ private
50
+
51
+ def headers
52
+ {'Authorization' => "Bearer #{@client_secret}"}
53
+ end
54
+
55
+ def configure_authentication!(opts)
56
+ opts[:headers] ||= {}
57
+ opts[:headers].merge!(headers)
58
+ end
59
+
60
+ def do_request(&block)
61
+ if blank?(@client_secret)
62
+ raise CredentialsMissingError.new("OAuth client_id and client_secret must be set")
63
+ end
64
+ block.call
65
+ rescue OAuth2::Error => e
66
+ raise Errors.map_error(e)
67
+ end
68
+
69
+ def blank?(value)
70
+ value.nil? || value.strip.empty?
71
+ end
72
+ end
73
+ end