cronofy 0.3.0 → 0.3.1

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
2
  SHA1:
3
- metadata.gz: d36dfd5dfa353d4d906d8ca54a6f5de39d584b13
4
- data.tar.gz: 7b38f363878df9bf48df0cf16faba49c42379f67
3
+ metadata.gz: fae8db5f6c35b2a0a08accb20ab5cb3b022e349a
4
+ data.tar.gz: 5a614083fefe94f1a555dde9044caaeaa828e78c
5
5
  SHA512:
6
- metadata.gz: 5025298994becd0ae491eaf498db26578535779bac1535fec7cf27b2e0ef3fdf4a89f71b172f01bb6a04f0c1ce804039fe465d403f5bc2ba7dbba839a17ac0dd
7
- data.tar.gz: 28d0d9200ce72f96978309df3ec1bc9e908af2149b6279a3c7be9852ac4e82f635424f119ba865852aae23e283d54ef5ffd0d7bd5f81ea7dbf07bb0d9a26af2b
6
+ metadata.gz: 50693de9cf548ab27793d6c9b25beeea52a9c6547e678735d01dacc9fb5892f79d4c1f97257d84feba9cf7e56b522645974f0f92033f83498337fb2789b66aea
7
+ data.tar.gz: 84fbad2e4bcbacfa81f2fcd26fa9f4d6d30e2f49856f2aaa7917aab15397ad7ea1f0936e5dd91770c04135b19e5616c570efe6b1ec6358c1afffd6487d6f5368
@@ -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
  #
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Cronofy
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.3.1".freeze
3
3
  end
@@ -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.0
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-04-30 00:00:00.000000000 Z
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