cronofy 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cronofy/client.rb +7 -0
- data/lib/cronofy/errors.rb +8 -0
- data/lib/cronofy/version.rb +1 -1
- data/spec/lib/cronofy/errors_spec.rb +77 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fae8db5f6c35b2a0a08accb20ab5cb3b022e349a
|
4
|
+
data.tar.gz: 5a614083fefe94f1a555dde9044caaeaa828e78c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50693de9cf548ab27793d6c9b25beeea52a9c6547e678735d01dacc9fb5892f79d4c1f97257d84feba9cf7e56b522645974f0f92033f83498337fb2789b66aea
|
7
|
+
data.tar.gz: 84fbad2e4bcbacfa81f2fcd26fa9f4d6d30e2f49856f2aaa7917aab15397ad7ea1f0936e5dd91770c04135b19e5616c570efe6b1ec6358c1afffd6487d6f5368
|
data/lib/cronofy/client.rb
CHANGED
@@ -130,6 +130,13 @@ module Cronofy
|
|
130
130
|
# ever existed within the given window should
|
131
131
|
# be included or excluded from the results
|
132
132
|
# (optional).
|
133
|
+
# :include_managed - A Boolean specifying whether events that you
|
134
|
+
# are managing for the account should be
|
135
|
+
# included or excluded from the results
|
136
|
+
# (optional).
|
137
|
+
# :only_managed - A Boolean specifying whether only events that
|
138
|
+
# you are managing for the account should
|
139
|
+
# trigger notifications (optional).
|
133
140
|
# :last_modified - The Time that events must be modified on or
|
134
141
|
# after in order to be returned (optional).
|
135
142
|
#
|
data/lib/cronofy/errors.rb
CHANGED
@@ -42,6 +42,14 @@ module Cronofy
|
|
42
42
|
end
|
43
43
|
|
44
44
|
class InvalidRequestError < APIError
|
45
|
+
def errors
|
46
|
+
@errors ||= begin
|
47
|
+
json = JSON.parse(self.body)
|
48
|
+
json.fetch("errors", Hash.new)
|
49
|
+
rescue
|
50
|
+
Hash.new
|
51
|
+
end
|
52
|
+
end
|
45
53
|
end
|
46
54
|
|
47
55
|
class TooManyRequestsError < APIError
|
data/lib/cronofy/version.rb
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Cronofy::Errors do
|
4
|
+
class ResponseStub
|
5
|
+
attr_reader :status
|
6
|
+
attr_reader :headers
|
7
|
+
attr_reader :body
|
8
|
+
|
9
|
+
def initialize(status: nil, headers: nil, body: nil)
|
10
|
+
@status = status
|
11
|
+
@headers = headers
|
12
|
+
@body = body
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:status) { 200 }
|
17
|
+
let(:headers) { Hash.new }
|
18
|
+
let(:body) { nil }
|
19
|
+
|
20
|
+
let(:response) do
|
21
|
+
ResponseStub.new(status: status, headers: headers, body: body)
|
22
|
+
end
|
23
|
+
|
24
|
+
context "422 Unprocessable response" do
|
25
|
+
let(:status) { 422 }
|
26
|
+
|
27
|
+
subject do
|
28
|
+
Cronofy::InvalidRequestError.new('message', response)
|
29
|
+
end
|
30
|
+
|
31
|
+
context "expected body" do
|
32
|
+
let(:body) do
|
33
|
+
'{
|
34
|
+
"errors": {
|
35
|
+
"event_id": [
|
36
|
+
{
|
37
|
+
"key": "errors.required",
|
38
|
+
"description": "required"
|
39
|
+
}
|
40
|
+
]
|
41
|
+
}
|
42
|
+
}'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "makes the errors accessible" do
|
46
|
+
deserialized_errors = JSON.parse(body)["errors"]
|
47
|
+
|
48
|
+
expect(deserialized_errors).to_not be_nil
|
49
|
+
expect(deserialized_errors).to_not be_empty
|
50
|
+
|
51
|
+
expect(subject.errors).to eq(deserialized_errors)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "errors field missing" do
|
56
|
+
let(:body) do
|
57
|
+
'{
|
58
|
+
"unexpected": "json"
|
59
|
+
}'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "exposes an empty hash" do
|
63
|
+
expect(subject.errors).to eq(Hash.new)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "body not valid json" do
|
68
|
+
let(:body) do
|
69
|
+
'Not JSON'
|
70
|
+
end
|
71
|
+
|
72
|
+
it "exposes an empty hash" do
|
73
|
+
expect(subject.errors).to eq(Hash.new)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cronofy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergii Paryzhskyi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- spec/lib/cronofy/auth_spec.rb
|
119
119
|
- spec/lib/cronofy/client_spec.rb
|
120
120
|
- spec/lib/cronofy/date_or_time_spec.rb
|
121
|
+
- spec/lib/cronofy/errors_spec.rb
|
121
122
|
- spec/response_parser_spec.rb
|
122
123
|
- spec/spec_helper.rb
|
123
124
|
homepage: https://github.com/cronofy/cronofy-ruby
|
@@ -148,5 +149,6 @@ test_files:
|
|
148
149
|
- spec/lib/cronofy/auth_spec.rb
|
149
150
|
- spec/lib/cronofy/client_spec.rb
|
150
151
|
- spec/lib/cronofy/date_or_time_spec.rb
|
152
|
+
- spec/lib/cronofy/errors_spec.rb
|
151
153
|
- spec/response_parser_spec.rb
|
152
154
|
- spec/spec_helper.rb
|