caseblocks_api 0.2.13 → 0.2.14
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.
- data/{README.rdoc → README.md} +1 -1
- data/VERSION +1 -1
- data/caseblocks_api.gemspec +5 -4
- data/lib/caseblocks_api/case_creation_error.rb +4 -0
- data/lib/caseblocks_api.rb +4 -2
- data/spec/caseblocks_api_spec.rb +24 -5
- metadata +6 -5
data/{README.rdoc → README.md}
RENAMED
@@ -23,7 +23,7 @@ Searching with sorting:
|
|
23
23
|
|
24
24
|
Searching for a reduced response:
|
25
25
|
|
26
|
-
`caseblocks.search('CaseTypeName', {given_name: 'Smith'}, fields: ['id', 'given_name', ''created_at'
|
26
|
+
`caseblocks.search('CaseTypeName', {given_name: 'Smith'}, fields: ['id', 'given_name', ''created_at'])`
|
27
27
|
|
28
28
|
== Contributing to caseblocks_api
|
29
29
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.14
|
data/caseblocks_api.gemspec
CHANGED
@@ -5,15 +5,15 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "caseblocks_api"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.14"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mark Provan"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-03-27"
|
13
13
|
s.email = "development@emergeadapt.com"
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE.txt",
|
16
|
-
"README.
|
16
|
+
"README.md"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
19
|
".document",
|
@@ -22,13 +22,14 @@ Gem::Specification.new do |s|
|
|
22
22
|
"Gemfile.lock",
|
23
23
|
"Guardfile",
|
24
24
|
"LICENSE.txt",
|
25
|
-
"README.
|
25
|
+
"README.md",
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
28
|
"caseblocks_api.gemspec",
|
29
29
|
"lib/caseblocks_api.rb",
|
30
30
|
"lib/caseblocks_api/authentication_exception.rb",
|
31
31
|
"lib/caseblocks_api/bucket_results.rb",
|
32
|
+
"lib/caseblocks_api/case_creation_error.rb",
|
32
33
|
"lib/caseblocks_api/get_cases.rb",
|
33
34
|
"lib/caseblocks_api/searcher.rb",
|
34
35
|
"lib/caseblocks_api/update_case.rb",
|
data/lib/caseblocks_api.rb
CHANGED
@@ -2,6 +2,7 @@ require "httparty"
|
|
2
2
|
require "json"
|
3
3
|
require 'active_support/inflector'
|
4
4
|
require "caseblocks_api/authentication_exception"
|
5
|
+
require 'caseblocks_api/case_creation_error'
|
5
6
|
|
6
7
|
module CaseblocksAPI
|
7
8
|
require 'caseblocks_api/bucket_results'
|
@@ -30,8 +31,9 @@ module CaseblocksAPI
|
|
30
31
|
|
31
32
|
def create_case(params, case_type=nil)
|
32
33
|
params.merge!(:case_type_id => fetch_case_type_id(case_type))
|
33
|
-
self.class.post("/case_blocks/cases", :body => {:case => params}.to_json)
|
34
|
-
|
34
|
+
response = self.class.post("/case_blocks/cases", :body => {:case => params}.to_json)
|
35
|
+
raise CaseblocksAPI::CaseCreationError, "Unable to create case - received response code #{response.code}" if response.code != 200
|
36
|
+
end
|
35
37
|
|
36
38
|
private
|
37
39
|
|
data/spec/caseblocks_api_spec.rb
CHANGED
@@ -23,13 +23,32 @@ describe "CaseblocksAPI" do
|
|
23
23
|
describe "creating a case" do
|
24
24
|
let(:caseblocks_client) { CaseblocksAPI::Client.new("username", "password", "http://example.com") }
|
25
25
|
|
26
|
-
|
26
|
+
before do
|
27
27
|
stub_request(:post, "http://example.com/tokens?auth_token=some_token")
|
28
28
|
CaseblocksAPI::Client.stub(:get).and_return({"case_types" => [ {"id" => 1, "name" => 'some_case'} ]})
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
stub_request(:post, "http://example.com/tokens?auth_token=").
|
30
|
+
with(:body => "{\"email\":\"username\",\"password\":\"password\"}",
|
31
|
+
:headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'})
|
32
|
+
end
|
33
|
+
|
34
|
+
context "successfully created on CaseBlocks" do
|
35
|
+
it "should call post" do
|
36
|
+
stub = stub_request(:post, "example.com/case_blocks/cases?auth_token=")
|
37
|
+
.with({body: { 'case' => {'my' => 'params', 'case_type_id' => 1}}.to_json })
|
38
|
+
.to_return(:status => 200, :body => "", :headers => {})
|
39
|
+
caseblocks_client.create_case({'my' => 'params'}, 'some_case')
|
40
|
+
stub.should have_been_made.times(1)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "received non-200 response code from CaseBlocks" do
|
45
|
+
it "should raise exception" do
|
46
|
+
stub = stub_request(:post, "example.com/case_blocks/cases?auth_token=")
|
47
|
+
.with({body: { 'case' => {'my' => 'params', 'case_type_id' => 1}}.to_json })
|
48
|
+
.to_return(:status => 500, :body => "", :headers => {})
|
49
|
+
|
50
|
+
expect{caseblocks_client.create_case({'my' => 'params'}, 'some_case')}.to raise_error(CaseblocksAPI::CaseCreationError, 'Unable to create case - received response code 500')
|
51
|
+
end
|
33
52
|
end
|
34
53
|
end
|
35
54
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caseblocks_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -177,7 +177,7 @@ executables: []
|
|
177
177
|
extensions: []
|
178
178
|
extra_rdoc_files:
|
179
179
|
- LICENSE.txt
|
180
|
-
- README.
|
180
|
+
- README.md
|
181
181
|
files:
|
182
182
|
- .document
|
183
183
|
- .rspec
|
@@ -185,13 +185,14 @@ files:
|
|
185
185
|
- Gemfile.lock
|
186
186
|
- Guardfile
|
187
187
|
- LICENSE.txt
|
188
|
-
- README.
|
188
|
+
- README.md
|
189
189
|
- Rakefile
|
190
190
|
- VERSION
|
191
191
|
- caseblocks_api.gemspec
|
192
192
|
- lib/caseblocks_api.rb
|
193
193
|
- lib/caseblocks_api/authentication_exception.rb
|
194
194
|
- lib/caseblocks_api/bucket_results.rb
|
195
|
+
- lib/caseblocks_api/case_creation_error.rb
|
195
196
|
- lib/caseblocks_api/get_cases.rb
|
196
197
|
- lib/caseblocks_api/searcher.rb
|
197
198
|
- lib/caseblocks_api/update_case.rb
|
@@ -217,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
218
|
version: '0'
|
218
219
|
segments:
|
219
220
|
- 0
|
220
|
-
hash:
|
221
|
+
hash: 240038132313134027
|
221
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
223
|
none: false
|
223
224
|
requirements:
|