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.
@@ -0,0 +1,12 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ describe Cronofy::DateOrTime do
4
+ context ".coerce" do
5
+ it "takes offset into account" do
6
+ utc = Cronofy::DateOrTime.coerce("2015-04-20T06:00:00Z")
7
+ local = Cronofy::DateOrTime.coerce("2015-04-20T07:00:00+01:00")
8
+
9
+ expect(utc).to eq(local)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,81 @@
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
+
54
+ it "includes the errors in the message" do
55
+ expect(subject.message).to eq('message - {"event_id"=>[{"key"=>"errors.required", "description"=>"required"}]}')
56
+ end
57
+ end
58
+
59
+ context "errors field missing" do
60
+ let(:body) do
61
+ '{
62
+ "unexpected": "json"
63
+ }'
64
+ end
65
+
66
+ it "exposes an empty hash" do
67
+ expect(subject.errors).to eq(Hash.new)
68
+ end
69
+ end
70
+
71
+ context "body not valid json" do
72
+ let(:body) do
73
+ 'Not JSON'
74
+ end
75
+
76
+ it "exposes an empty hash" do
77
+ expect(subject.errors).to eq(Hash.new)
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,121 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ describe Cronofy::Event do
4
+ context "UTC times" do
5
+ let(:json) do
6
+ '{
7
+ "calendar_id": "cal_U9uuErStTG@EAAAB_IsAsykA2DBTWqQTf-f0kJw",
8
+ "event_uid": "evt_external_54008b1a4a41730f8d5c6037",
9
+ "summary": "Company Retreat",
10
+ "description": "",
11
+ "start": "2014-09-06",
12
+ "end": "2014-09-08",
13
+ "deleted": false,
14
+ "location": {
15
+ "description": "Beach"
16
+ },
17
+ "participation_status": "needs_action",
18
+ "transparency": "opaque",
19
+ "event_status": "confirmed",
20
+ "categories": [],
21
+ "attendees": [
22
+ {
23
+ "email": "example@cronofy.com",
24
+ "display_name": "Example Person",
25
+ "status": "needs_action"
26
+ }
27
+ ],
28
+ "created": "2014-09-01T08:00:01Z",
29
+ "updated": "2014-09-01T09:24:16Z"
30
+ }'
31
+ end
32
+
33
+ let(:hash) do
34
+ JSON.parse(json)
35
+ end
36
+
37
+ subject do
38
+ Cronofy::Event.new(hash)
39
+ end
40
+
41
+ it "coerces the start date" do
42
+ expect(subject.start).to eq(Cronofy::DateOrTime.coerce("2014-09-06"))
43
+ end
44
+
45
+ it "coerces the end date" do
46
+ expect(subject.end).to eq(Cronofy::DateOrTime.coerce("2014-09-08"))
47
+ end
48
+
49
+ it "coerces the created time" do
50
+ expect(subject.created).to eq(Time.parse("2014-09-01T08:00:01Z"))
51
+ end
52
+
53
+ it "coerces the updated time" do
54
+ expect(subject.updated).to eq(Time.parse("2014-09-01T09:24:16Z"))
55
+ end
56
+
57
+ it "can be inspected" do
58
+ expect(subject.inspect).to_not be_nil
59
+ end
60
+ end
61
+
62
+ context "localized times" do
63
+ let(:json) do
64
+ '{
65
+ "calendar_id": "cal_U9uuErStTG@EAAAB_IsAsykA2DBTWqQTf-f0kJw",
66
+ "event_uid": "evt_external_54008b1a4a41730f8d5c6037",
67
+ "summary": "Company Retreat",
68
+ "description": "",
69
+ "start": {
70
+ "time": "2014-09-06T13:40:00+01:00",
71
+ "tzid": "Europe/London"
72
+ },
73
+ "end": {
74
+ "time": "2014-09-06T14:10:00+01:00",
75
+ "tzid": "Europe/London"
76
+ },
77
+ "deleted": false,
78
+ "location": {
79
+ "description": "Beach"
80
+ },
81
+ "participation_status": "needs_action",
82
+ "transparency": "opaque",
83
+ "event_status": "confirmed",
84
+ "categories": [],
85
+ "attendees": [
86
+ {
87
+ "email": "example@cronofy.com",
88
+ "display_name": "Example Person",
89
+ "status": "needs_action"
90
+ }
91
+ ],
92
+ "created": "2014-09-01T08:00:01Z",
93
+ "updated": "2014-09-01T09:24:16Z"
94
+ }'
95
+ end
96
+
97
+ let(:hash) do
98
+ JSON.parse(json)
99
+ end
100
+
101
+ subject do
102
+ Cronofy::Event.new(hash)
103
+ end
104
+
105
+ it "coerces the start date" do
106
+ expect(subject.start).to eq(Cronofy::EventTime.coerce("time" => "2014-09-06T13:40:00+01:00", "tzid" => "Europe/London"))
107
+ end
108
+
109
+ it "coerces the end date" do
110
+ expect(subject.end).to eq(Cronofy::EventTime.coerce("time" => "2014-09-06T14:10:00+01:00", "tzid" => "Europe/London"))
111
+ end
112
+
113
+ it "coerces the created time" do
114
+ expect(subject.created).to eq(Time.parse("2014-09-01T08:00:01Z"))
115
+ end
116
+
117
+ it "coerces the updated time" do
118
+ expect(subject.updated).to eq(Time.parse("2014-09-01T09:24:16Z"))
119
+ end
120
+ end
121
+ end
@@ -4,6 +4,6 @@ describe Cronofy::ResponseParser do
4
4
  it 'should return hash from a given response' do
5
5
  response = OpenStruct.new(body: '{"a": 1, "b": 2}')
6
6
  response_parser = Cronofy::ResponseParser.new(response)
7
- expect(response_parser.parse_json).to eq({'a' => 1, 'b' => 2})
7
+ expect(response_parser.json).to eq({'a' => 1, 'b' => 2})
8
8
  end
9
9
  end
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,4 @@
1
1
  require 'ostruct'
2
2
  require 'cronofy'
3
+
4
+ require 'webmock/rspec'
metadata CHANGED
@@ -1,29 +1,70 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cronofy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.37.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergii Paryzhskyi
8
- autorequire:
8
+ - Garry Shutler
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-02-25 00:00:00.000000000 Z
12
+ date: 2022-05-27 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
- name: bundler
15
+ name: hashie
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '2.1'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '5'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '2.1'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '5'
34
+ - !ruby/object:Gem::Dependency
35
+ name: oauth2
15
36
  requirement: !ruby/object:Gem::Requirement
16
37
  requirements:
17
38
  - - "~>"
18
39
  - !ruby/object:Gem::Version
19
- version: '1.7'
20
- type: :development
40
+ version: '1.0'
41
+ type: :runtime
21
42
  prerelease: false
22
43
  version_requirements: !ruby/object:Gem::Requirement
23
44
  requirements:
24
45
  - - "~>"
25
46
  - !ruby/object:Gem::Version
26
- version: '1.7'
47
+ version: '1.0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: bundler
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - - "<"
56
+ - !ruby/object:Gem::Version
57
+ version: '3'
58
+ type: :development
59
+ prerelease: false
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '1.6'
65
+ - - "<"
66
+ - !ruby/object:Gem::Version
67
+ version: '3'
27
68
  - !ruby/object:Gem::Dependency
28
69
  name: rake
29
70
  requirement: !ruby/object:Gem::Requirement
@@ -53,47 +94,54 @@ dependencies:
53
94
  - !ruby/object:Gem::Version
54
95
  version: '3.2'
55
96
  - !ruby/object:Gem::Dependency
56
- name: oauth2
97
+ name: webmock
57
98
  requirement: !ruby/object:Gem::Requirement
58
99
  requirements:
59
100
  - - "~>"
60
101
  - !ruby/object:Gem::Version
61
- version: '1.0'
62
- type: :runtime
102
+ version: 3.9.1
103
+ type: :development
63
104
  prerelease: false
64
105
  version_requirements: !ruby/object:Gem::Requirement
65
106
  requirements:
66
107
  - - "~>"
67
108
  - !ruby/object:Gem::Version
68
- version: '1.0'
69
- description:
109
+ version: 3.9.1
110
+ description: SDK for Cronofy - the Scheduling Platform for Business
70
111
  email:
71
112
  - parizhskiy@gmail.com
113
+ - garry@cronofy.com
72
114
  executables: []
73
115
  extensions: []
74
116
  extra_rdoc_files: []
75
117
  files:
76
- - ".gitignore"
77
- - ".travis.yml"
118
+ - CHANGELOG.md
78
119
  - Gemfile
79
120
  - LICENSE.txt
80
121
  - README.md
81
122
  - Rakefile
82
123
  - cronofy.gemspec
83
124
  - lib/cronofy.rb
125
+ - lib/cronofy/api_key.rb
84
126
  - lib/cronofy/auth.rb
85
127
  - lib/cronofy/client.rb
86
128
  - lib/cronofy/errors.rb
87
129
  - lib/cronofy/response_parser.rb
130
+ - lib/cronofy/time_encoding.rb
131
+ - lib/cronofy/types.rb
88
132
  - lib/cronofy/version.rb
89
- - script/ci
133
+ - spec/lib/cronofy/auth_spec.rb
134
+ - spec/lib/cronofy/client_spec.rb
135
+ - spec/lib/cronofy/date_or_time_spec.rb
136
+ - spec/lib/cronofy/errors_spec.rb
137
+ - spec/lib/cronofy/event_spec.rb
90
138
  - spec/response_parser_spec.rb
91
139
  - spec/spec_helper.rb
92
140
  homepage: https://github.com/cronofy/cronofy-ruby
93
141
  licenses:
94
142
  - MIT
95
143
  metadata: {}
96
- post_install_message:
144
+ post_install_message:
97
145
  rdoc_options: []
98
146
  require_paths:
99
147
  - lib
@@ -108,11 +156,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
156
  - !ruby/object:Gem::Version
109
157
  version: '0'
110
158
  requirements: []
111
- rubyforge_project:
112
- rubygems_version: 2.2.2
113
- signing_key:
159
+ rubygems_version: 3.3.11
160
+ signing_key:
114
161
  specification_version: 4
115
- summary: Cronofy - one API for all the calendars
162
+ summary: Cronofy - the scheduling platform for business
116
163
  test_files:
117
- - spec/response_parser_spec.rb
118
164
  - spec/spec_helper.rb
165
+ - spec/response_parser_spec.rb
166
+ - spec/lib/cronofy/client_spec.rb
167
+ - spec/lib/cronofy/event_spec.rb
168
+ - spec/lib/cronofy/errors_spec.rb
169
+ - spec/lib/cronofy/date_or_time_spec.rb
170
+ - spec/lib/cronofy/auth_spec.rb
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log
data/.travis.yml DELETED
@@ -1,16 +0,0 @@
1
- language: ruby
2
- script: 'script/ci'
3
- rvm:
4
- - 2.0
5
- - 2.1
6
- - 2.2
7
- - jruby-head
8
- - rbx-2
9
- - ruby-head
10
- notifications:
11
- webhooks:
12
- urls:
13
- - https://webhooks.gitter.im/e/9ca8d56f4d3a17425b18
14
- on_success: change # options: [always|never|change] default: always
15
- on_failure: always # options: [always|never|change] default: always
16
- on_start: false # default: false
data/script/ci DELETED
@@ -1,7 +0,0 @@
1
- #! /bin/bash
2
-
3
- # Fail fast
4
- set -o errexit
5
-
6
- bundle install
7
- bundle exec rake spec