status_cake 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54631854b22ce18d59ba60b7a63bcd7851b7704c
4
- data.tar.gz: f4b449653d6c70d5870494dd40d6d6029566655d
3
+ metadata.gz: ff3b630f3d2987f2d9118c790d60271954614bfb
4
+ data.tar.gz: af2abdcc4d702c58819615ed5bfc7486a5f5fdce
5
5
  SHA512:
6
- metadata.gz: 795cb752256910ee4a82a51077f0c9c4f622f88dbc46e7a7c880d1907b3d246ae8686b6b23367176b6bf38e31d080f961788e2b948333554395c94bb7e4f740b
7
- data.tar.gz: 081cbbcac9510bd31cbcdcdf9a67da6fa6ff8ca8c23b365f84cdb19c2353e02625efa665f30329957e0192f260cc36c3b2aac71c3dca6662186bf6fbd1d9f90b
6
+ metadata.gz: 2d3dfbd8ef901478af4393f7a0cba12550a0f75babd69392bf835d14f6396f224f1b9ed162aef345dfa2b74adbd0f3524137d1e2d1d58832e44e37964689af51
7
+ data.tar.gz: 83c83f3818a5b381f92643c9e851228ffbe224757269e79d9b425fae9fbf8d830bf34574fe38fec74dab9c98788ca4d59e031ea34040d8443884bd11a570b618
data/README.rdoc CHANGED
@@ -29,6 +29,18 @@ Please be aware that although filtering is supported on any criteria via the gem
29
29
  @sc.pause_test(t)
30
30
  @sc.unpause_test(t)
31
31
 
32
+ === Retrieving Contact Groups
33
+
34
+ @sc.contact_groups('GroupName' => 'Production')
35
+
36
+ === Updating and Insert Contact Groups
37
+
38
+ response = @sc.update_contact_group({
39
+ 'ContactID' => 12345,
40
+ 'GroupName' => 'Test Group',
41
+ 'Email' => 'updated@invalid.com'
42
+ })
43
+
32
44
  == Logging
33
45
 
34
46
  Override the debug_output, see Net::HTTP#set_debug_output for options.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -16,9 +16,22 @@ class StatusCake
16
16
  @auth = {'Username' => opts[:username], 'API' => opts[:api_key]}
17
17
  end
18
18
 
19
- def find(id)
20
- @opts = {headers:@auth, query:{ 'TestID' => id }}
21
- respond(self.class.get("/Tests/Details", @opts))
19
+ def contact_groups(options={})
20
+ @opts = {headers:@auth}
21
+ filter_opts = options
22
+
23
+ contact_groups = respond(self.class.get("/ContactGroups", @opts)) || []
24
+
25
+ unless filter_opts.empty?
26
+ contact_groups.find_all { |t| (t & filter_opts) == filter_opts }
27
+ else
28
+ contact_groups
29
+ end
30
+ end
31
+
32
+ def update_contact_group(contact_group={})
33
+ @opts = {headers:@auth, body:contact_group }
34
+ respond(self.class.put("/ContactGroups/Update",@opts))
22
35
  end
23
36
 
24
37
  def tests(options={})
@@ -27,7 +40,7 @@ class StatusCake
27
40
  filter_opts = options.reject { |k,v| SUPPORTED_QUERIES.index(k) }
28
41
 
29
42
  @opts = {headers:@auth, query:query_opts}
30
- tests = respond(self.class.get("/Tests", @opts))
43
+ tests = respond(self.class.get("/Tests", @opts)) || []
31
44
 
32
45
  unless filter_opts.empty?
33
46
  tests.find_all { |t| (t & filter_opts) == filter_opts }
@@ -36,6 +49,11 @@ class StatusCake
36
49
  end
37
50
  end
38
51
 
52
+ def find_test(id)
53
+ @opts = {headers:@auth, query:{ 'TestID' => id }}
54
+ respond(self.class.get("/Tests/Details", @opts))
55
+ end
56
+
39
57
  def update_test(test={})
40
58
  @opts = {headers:@auth, body:test }
41
59
  respond(self.class.put("/Tests/Update",@opts))
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: https://www.statuscake.com/API/ContactGroups/Update
6
+ body:
7
+ encoding: UTF-8
8
+ string: GroupName=Test%20Contact%20Group%20API&Email=test%40invalid.com
9
+ headers:
10
+ Username:
11
+ - <USER>
12
+ Api:
13
+ - <APIKEY>
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Date:
20
+ - Wed, 11 Jun 2014 21:19:15 GMT
21
+ Server:
22
+ - LiteSpeed
23
+ Connection:
24
+ - close
25
+ X-Powered-By:
26
+ - PHP/5.4.9
27
+ Set-Cookie:
28
+ - PHPSESSID=16001fd974e6af6fe12e5c36d17f9ead; path=/
29
+ Expires:
30
+ - Thu, 19 Nov 1981 08:52:00 GMT
31
+ Cache-Control:
32
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
33
+ Pragma:
34
+ - no-cache
35
+ Content-Type:
36
+ - application/json
37
+ Content-Length:
38
+ - '161'
39
+ body:
40
+ encoding: UTF-8
41
+ string: '{"Success":true,"Message":"Test Inserted","Issues":[],"Data":{"Email":"test@invalid.com","GroupName":"Test
42
+ Contact Group API","Client":"14818"},"InsertID":10564}'
43
+ http_version:
44
+ recorded_at: Wed, 11 Jun 2014 21:19:20 GMT
45
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.statuscake.com/API/ContactGroups
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Username:
11
+ - <USER>
12
+ Api:
13
+ - <APIKEY>
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Date:
20
+ - Wed, 11 Jun 2014 21:10:37 GMT
21
+ Server:
22
+ - LiteSpeed
23
+ Connection:
24
+ - close
25
+ X-Powered-By:
26
+ - PHP/5.4.9
27
+ Set-Cookie:
28
+ - PHPSESSID=e96390eda7cfc292ef505638b8d1af01; path=/
29
+ Expires:
30
+ - Thu, 19 Nov 1981 08:52:00 GMT
31
+ Cache-Control:
32
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
33
+ Pragma:
34
+ - no-cache
35
+ Content-Type:
36
+ - application/json
37
+ Content-Length:
38
+ - '284'
39
+ body:
40
+ encoding: UTF-8
41
+ string: '[{"GroupName":"Test","Emails":["nothing@<USER>.com"],"Mobiles":"","Boxcar":"","Pushover":"","ContactID":10313,"DesktopAlert":0,"PingURL":""},{"GroupName":"All
42
+ Sites","Emails":["nothing@<USER>.com"],"Mobiles":"","Boxcar":"","Pushover":"","ContactID":10395,"DesktopAlert":0,"PingURL":""}]'
43
+ http_version:
44
+ recorded_at: Wed, 11 Jun 2014 21:10:42 GMT
45
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,130 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.statuscake.com/API/ContactGroups
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Username:
11
+ - <USER>
12
+ Api:
13
+ - <APIKEY>
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Date:
20
+ - Wed, 11 Jun 2014 21:19:18 GMT
21
+ Server:
22
+ - LiteSpeed
23
+ Connection:
24
+ - close
25
+ X-Powered-By:
26
+ - PHP/5.4.9
27
+ Set-Cookie:
28
+ - PHPSESSID=7866b25bc852d98af4ce4379f5c7fa86; path=/
29
+ Expires:
30
+ - Thu, 19 Nov 1981 08:52:00 GMT
31
+ Cache-Control:
32
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
33
+ Pragma:
34
+ - no-cache
35
+ Content-Type:
36
+ - application/json
37
+ Content-Length:
38
+ - '440'
39
+ body:
40
+ encoding: UTF-8
41
+ string: '[{"GroupName":"Test","Emails":["nothing@<USER>.com"],"Mobiles":"","Boxcar":"","Pushover":"","ContactID":10313,"DesktopAlert":0,"PingURL":""},{"GroupName":"All
42
+ Sites","Emails":["nothing@<USER>.com"],"Mobiles":"","Boxcar":"","Pushover":"","ContactID":10395,"DesktopAlert":0,"PingURL":""},{"GroupName":"Test
43
+ Contact Group API","Emails":["test@invalid.com"],"Mobiles":"","Boxcar":"","Pushover":"","ContactID":10564,"DesktopAlert":0,"PingURL":""}]'
44
+ http_version:
45
+ recorded_at: Wed, 11 Jun 2014 21:19:22 GMT
46
+ - request:
47
+ method: put
48
+ uri: https://www.statuscake.com/API/ContactGroups/Update
49
+ body:
50
+ encoding: UTF-8
51
+ string: ContactID=10564&GroupName=Test%20Contact%20Group%20API%20-%20Updated&Email=test.updated%40invalid.com
52
+ headers:
53
+ Username:
54
+ - <USER>
55
+ Api:
56
+ - <APIKEY>
57
+ response:
58
+ status:
59
+ code: 200
60
+ message: OK
61
+ headers:
62
+ Date:
63
+ - Wed, 11 Jun 2014 21:19:19 GMT
64
+ Server:
65
+ - LiteSpeed
66
+ Connection:
67
+ - close
68
+ X-Powered-By:
69
+ - PHP/5.4.9
70
+ Set-Cookie:
71
+ - PHPSESSID=80129dbbcbab25f6dcc1ea22bd66a261; path=/
72
+ Expires:
73
+ - Thu, 19 Nov 1981 08:52:00 GMT
74
+ Cache-Control:
75
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
76
+ Pragma:
77
+ - no-cache
78
+ Content-Type:
79
+ - application/json
80
+ Content-Length:
81
+ - '72'
82
+ body:
83
+ encoding: UTF-8
84
+ string: '{"Success":true,"Issues":[],"Message":"Contact Group has been updated!"}'
85
+ http_version:
86
+ recorded_at: Wed, 11 Jun 2014 21:19:23 GMT
87
+ - request:
88
+ method: get
89
+ uri: https://www.statuscake.com/API/ContactGroups
90
+ body:
91
+ encoding: US-ASCII
92
+ string: ''
93
+ headers:
94
+ Username:
95
+ - <USER>
96
+ Api:
97
+ - <APIKEY>
98
+ response:
99
+ status:
100
+ code: 200
101
+ message: OK
102
+ headers:
103
+ Date:
104
+ - Wed, 11 Jun 2014 21:19:21 GMT
105
+ Server:
106
+ - LiteSpeed
107
+ Connection:
108
+ - close
109
+ X-Powered-By:
110
+ - PHP/5.4.9
111
+ Set-Cookie:
112
+ - PHPSESSID=d6365a0832a8517504b5bf1355b38003; path=/
113
+ Expires:
114
+ - Thu, 19 Nov 1981 08:52:00 GMT
115
+ Cache-Control:
116
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
117
+ Pragma:
118
+ - no-cache
119
+ Content-Type:
120
+ - application/json
121
+ Content-Length:
122
+ - '458'
123
+ body:
124
+ encoding: UTF-8
125
+ string: '[{"GroupName":"Test","Emails":["nothing@<USER>.com"],"Mobiles":"","Boxcar":"","Pushover":"","ContactID":10313,"DesktopAlert":0,"PingURL":""},{"GroupName":"All
126
+ Sites","Emails":["nothing@<USER>.com"],"Mobiles":"","Boxcar":"","Pushover":"","ContactID":10395,"DesktopAlert":0,"PingURL":""},{"GroupName":"Test
127
+ Contact Group API - Updated","Emails":["test.updated@invalid.com"],"Mobiles":"","Boxcar":"","Pushover":"","ContactID":10564,"DesktopAlert":0,"PingURL":""}]'
128
+ http_version:
129
+ recorded_at: Wed, 11 Jun 2014 21:19:26 GMT
130
+ recorded_with: VCR 2.9.2
@@ -7,12 +7,11 @@ if ENV['STATUSCAKE_VERBOSE'] == 'true'
7
7
  end
8
8
 
9
9
  describe StatusCake do
10
+ subject do
11
+ StatusCake.new(username: ENV['STATUSCAKE_USER'], api_key: ENV['STATUSCAKE_APIKEY'])
12
+ end
10
13
 
11
- context "simple operations" do
12
- subject do
13
- StatusCake.new(username: ENV['STATUSCAKE_USER'], api_key: ENV['STATUSCAKE_APIKEY'])
14
- end
15
-
14
+ context "tests" do
16
15
  it 'should be able to create a test' do
17
16
  VCR.use_cassette('create_test') do
18
17
  response = subject.update_test({
@@ -35,7 +34,7 @@ describe StatusCake do
35
34
 
36
35
  it 'should be able to retrieve a test by id' do
37
36
  VCR.use_cassette('retrieve_by_id') do
38
- test = subject.find(170051)
37
+ test = subject.find_test(170051)
39
38
  expect(test).not_to be_nil
40
39
  expect(test['WebsiteName']).to eq('google.com')
41
40
  end
@@ -49,6 +48,12 @@ describe StatusCake do
49
48
  end
50
49
  end
51
50
 
51
+ it 'should return blank arrays for no matches' do
52
+ VCR.use_cassette('retrieve_by_name') do
53
+ expect(subject.tests('CUID' => '10395', 'WebsiteName' => 'DOESNOTEXIST')).to eq([])
54
+ end
55
+ end
56
+
52
57
  it 'should be able to unpause a test' do
53
58
  VCR.use_cassette('unpause_test') do
54
59
  response = subject.unpause_test(subject.tests('WebsiteName' => 'google.com', 'CUID' => '10395').first)
@@ -70,4 +75,53 @@ describe StatusCake do
70
75
  end
71
76
  end
72
77
  end
78
+
79
+ context "contact groups" do
80
+ it 'should be able to retrieve contact groups' do
81
+ VCR.use_cassette('retrieve_contact_groups') do
82
+ expect(subject.contact_groups.size).to be 2
83
+ end
84
+ end
85
+
86
+ it 'should be able to retrieve contact groups by name' do
87
+ VCR.use_cassette('retrieve_contact_groups') do
88
+ expect(subject.contact_groups('GroupName' => 'Test').size).to be 1
89
+ end
90
+ end
91
+
92
+ it 'should return blank arrays for no matches' do
93
+ VCR.use_cassette('retrieve_contact_groups') do
94
+ expect(subject.contact_groups('GroupName' => 'DOESNOTEXIST')).to eq([])
95
+ end
96
+ end
97
+
98
+ it 'should be able to create a contact group' do
99
+ VCR.use_cassette('create_contact_group') do
100
+ response = subject.update_contact_group({
101
+ 'GroupName' => 'Test Contact Group API',
102
+ 'Email' => 'test@invalid.com'
103
+ })
104
+ expect(response['Success'] == 'true')
105
+ end
106
+ end
107
+
108
+ it 'should be able to update a contact group' do
109
+ VCR.use_cassette('update_contact_group') do
110
+ cg = subject.contact_groups.find { |c| c['GroupName'] == 'Test Contact Group API' }
111
+ expect(cg).not_to be_nil
112
+
113
+ response = subject.update_contact_group({
114
+ 'ContactID' => cg['ContactID'],
115
+ 'GroupName' => 'Test Contact Group API - Updated',
116
+ 'Email' => 'test.updated@invalid.com'
117
+ })
118
+ expect(response['Success'] == 'true')
119
+
120
+ retrieved_cg = subject.contact_groups.find { |c| c['ContactID'] == cg['ContactID'] }
121
+ expect(retrieved_cg).not_to be_nil
122
+ expect(retrieved_cg['GroupName']).to eq('Test Contact Group API - Updated')
123
+ expect(retrieved_cg['Emails'].first).to eq('test.updated@invalid.com')
124
+ end
125
+ end
126
+ end
73
127
  end
data/status_cake.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: status_cake 0.1.1 ruby lib
5
+ # stub: status_cake 0.1.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "status_cake"
9
- s.version = "0.1.1"
9
+ s.version = "0.1.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Charles Cooke"]
14
- s.date = "2014-06-10"
14
+ s.date = "2014-06-12"
15
15
  s.description = "Ruby gem for StatusCake API - supports basic functions on tests"
16
16
  s.email = "charles@coupa.com"
17
17
  s.extra_rdoc_files = [
@@ -31,13 +31,16 @@ Gem::Specification.new do |s|
31
31
  "lib/status_cake.rb",
32
32
  "lib/status_cake/status_cake.rb",
33
33
  "lib/status_cake/version.rb",
34
+ "spec/fixtures/vcr/create_contact_group.yml",
34
35
  "spec/fixtures/vcr/create_test.yml",
35
36
  "spec/fixtures/vcr/delete_test.yml",
36
37
  "spec/fixtures/vcr/pause_test.yml",
37
38
  "spec/fixtures/vcr/retrieve_all.yml",
38
39
  "spec/fixtures/vcr/retrieve_by_id.yml",
39
40
  "spec/fixtures/vcr/retrieve_by_name.yml",
41
+ "spec/fixtures/vcr/retrieve_contact_groups.yml",
40
42
  "spec/fixtures/vcr/unpause_test.yml",
43
+ "spec/fixtures/vcr/update_contact_group.yml",
41
44
  "spec/spec_helper.rb",
42
45
  "spec/status_cake/status_cake_spec.rb",
43
46
  "status_cake.gemspec"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: status_cake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-10 00:00:00.000000000 Z
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -198,13 +198,16 @@ files:
198
198
  - lib/status_cake.rb
199
199
  - lib/status_cake/status_cake.rb
200
200
  - lib/status_cake/version.rb
201
+ - spec/fixtures/vcr/create_contact_group.yml
201
202
  - spec/fixtures/vcr/create_test.yml
202
203
  - spec/fixtures/vcr/delete_test.yml
203
204
  - spec/fixtures/vcr/pause_test.yml
204
205
  - spec/fixtures/vcr/retrieve_all.yml
205
206
  - spec/fixtures/vcr/retrieve_by_id.yml
206
207
  - spec/fixtures/vcr/retrieve_by_name.yml
208
+ - spec/fixtures/vcr/retrieve_contact_groups.yml
207
209
  - spec/fixtures/vcr/unpause_test.yml
210
+ - spec/fixtures/vcr/update_contact_group.yml
208
211
  - spec/spec_helper.rb
209
212
  - spec/status_cake/status_cake_spec.rb
210
213
  - status_cake.gemspec