caseblocks_api 0.2.12 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +16 -1
- data/VERSION +1 -1
- data/caseblocks_api.gemspec +4 -4
- data/lib/caseblocks_api.rb +1 -1
- data/lib/caseblocks_api/searcher.rb +21 -0
- data/spec/lib/caseblocks_api/get_cases_spec.rb +0 -1
- data/spec/lib/caseblocks_api/searcher_spec.rb +33 -0
- metadata +5 -5
- data/lib/caseblocks_api/finder.rb +0 -28
- data/spec/lib/caseblocks_api/find_case_by_property_spec.rb +0 -31
data/README.rdoc
CHANGED
@@ -8,7 +8,22 @@ Create a new Case:
|
|
8
8
|
|
9
9
|
`caseblocks.create_case({:title => "This is a Case!", :due_at => "tomorrow")`
|
10
10
|
|
11
|
-
|
11
|
+
Searching for cases:
|
12
|
+
|
13
|
+
`caseblocks.search('CaseTypeName', {telephone_number: '12334', given_name: 'Smith'})`
|
14
|
+
|
15
|
+
Searching with pagination:
|
16
|
+
|
17
|
+
`caseblocks.search('CaseTypeName', {given_name: 'Smith'}, page: 0, page_size: 10)`
|
18
|
+
|
19
|
+
Searching with sorting:
|
20
|
+
|
21
|
+
`caseblocks.search('CaseTypeName', {given_name: 'Smith'}, sort_by: [{field: 'created_at', direction: 'desc'}])`
|
22
|
+
`caseblocks.search('CaseTypeName', {given_name: 'Smith'}, sort_by: [{field: 'created_at', direction: 'asc'}])`
|
23
|
+
|
24
|
+
Searching for a reduced response:
|
25
|
+
|
26
|
+
`caseblocks.search('CaseTypeName', {given_name: 'Smith'}, fields: ['id', 'given_name', ''created_at'}])`
|
12
27
|
|
13
28
|
== Contributing to caseblocks_api
|
14
29
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.13
|
data/caseblocks_api.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
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.13"
|
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-02-
|
12
|
+
s.date = "2013-02-19"
|
13
13
|
s.email = "development@emergeadapt.com"
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE.txt",
|
@@ -29,13 +29,13 @@ Gem::Specification.new do |s|
|
|
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/finder.rb",
|
33
32
|
"lib/caseblocks_api/get_cases.rb",
|
33
|
+
"lib/caseblocks_api/searcher.rb",
|
34
34
|
"lib/caseblocks_api/update_case.rb",
|
35
35
|
"spec/caseblocks_api_spec.rb",
|
36
36
|
"spec/lib/caseblocks_api/bucket_results_spec.rb",
|
37
|
-
"spec/lib/caseblocks_api/find_case_by_property_spec.rb",
|
38
37
|
"spec/lib/caseblocks_api/get_cases_spec.rb",
|
38
|
+
"spec/lib/caseblocks_api/searcher_spec.rb",
|
39
39
|
"spec/lib/caseblocks_api/update_case_spec.rb",
|
40
40
|
"spec/spec_helper.rb",
|
41
41
|
"spec/support/fake_http_party.rb"
|
data/lib/caseblocks_api.rb
CHANGED
@@ -5,7 +5,7 @@ require "caseblocks_api/authentication_exception"
|
|
5
5
|
|
6
6
|
module CaseblocksAPI
|
7
7
|
require 'caseblocks_api/bucket_results'
|
8
|
-
require 'caseblocks_api/
|
8
|
+
require 'caseblocks_api/searcher'
|
9
9
|
require 'caseblocks_api/update_case'
|
10
10
|
require 'caseblocks_api/get_cases'
|
11
11
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'caseblocks_api'
|
2
|
+
require 'active_support/inflector'
|
3
|
+
|
4
|
+
module CaseblocksAPI
|
5
|
+
class Searcher
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def execute_search(case_type, criteria, options={})
|
11
|
+
body = {properties: criteria}.merge(options).to_json
|
12
|
+
@client.post("/case_blocks/#{case_type}/search", :body => body)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Client
|
17
|
+
def search(case_type, criteria, options={})
|
18
|
+
Searcher.new(self.class).execute_search(case_type, criteria, options)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CaseblocksAPI::Searcher do
|
4
|
+
|
5
|
+
let(:client) { double('client') }
|
6
|
+
let(:finder) { CaseblocksAPI::Searcher.new(client) }
|
7
|
+
let(:case_type) { 'the_case_type' }
|
8
|
+
|
9
|
+
context "search with case type alone and empty properties" do
|
10
|
+
it "should pass them onto a POST request" do
|
11
|
+
expected_body = {body: {properties: {}}.to_json}
|
12
|
+
client.should_receive(:post).with("/case_blocks/#{case_type}/search", expected_body)
|
13
|
+
finder.execute_search(case_type, {})
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "search with case type with properties" do
|
18
|
+
it "should pass them onto a POST request" do
|
19
|
+
expected_body = {body: {properties: {order_number: '12334', client_surname: 'Smith'}}.to_json}
|
20
|
+
client.should_receive(:post).with("/case_blocks/#{case_type}/search", expected_body)
|
21
|
+
finder.execute_search(case_type, {order_number: '12334', client_surname: 'Smith'})
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "search with case type with properties and options" do
|
26
|
+
it "should pass them onto a POST request" do
|
27
|
+
expected_body = {body: {properties: {order_number: '12334', client_surname: 'Smith'}, page: 0, page_size: 10}.to_json}
|
28
|
+
client.should_receive(:post).with("/case_blocks/#{case_type}/search", expected_body)
|
29
|
+
finder.execute_search(case_type, {order_number: '12334', client_surname: 'Smith'}, page: 0, page_size: 10)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
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.13
|
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-02-
|
12
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -192,13 +192,13 @@ files:
|
|
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/finder.rb
|
196
195
|
- lib/caseblocks_api/get_cases.rb
|
196
|
+
- lib/caseblocks_api/searcher.rb
|
197
197
|
- lib/caseblocks_api/update_case.rb
|
198
198
|
- spec/caseblocks_api_spec.rb
|
199
199
|
- spec/lib/caseblocks_api/bucket_results_spec.rb
|
200
|
-
- spec/lib/caseblocks_api/find_case_by_property_spec.rb
|
201
200
|
- spec/lib/caseblocks_api/get_cases_spec.rb
|
201
|
+
- spec/lib/caseblocks_api/searcher_spec.rb
|
202
202
|
- spec/lib/caseblocks_api/update_case_spec.rb
|
203
203
|
- spec/spec_helper.rb
|
204
204
|
- spec/support/fake_http_party.rb
|
@@ -217,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
217
|
version: '0'
|
218
218
|
segments:
|
219
219
|
- 0
|
220
|
-
hash:
|
220
|
+
hash: 2296649421097839558
|
221
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
222
|
none: false
|
223
223
|
requirements:
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'caseblocks_api'
|
2
|
-
require 'active_support/inflector'
|
3
|
-
|
4
|
-
module CaseblocksAPI
|
5
|
-
class Finder
|
6
|
-
def initialize(client)
|
7
|
-
@client = client
|
8
|
-
end
|
9
|
-
|
10
|
-
def execute_single(case_type, property_name, value, page, page_size)
|
11
|
-
@client.get("/case_blocks/#{case_type}/search", {query: {search: true, property: property_name, value: value, page: page, page_size: page_size}})
|
12
|
-
end
|
13
|
-
|
14
|
-
def execute_multiple(case_type, properties, page, page_size)
|
15
|
-
@client.post("/case_blocks/#{case_type}/search", :body => {search: true, properties: properties, page: page, page_size: page_size }.to_json)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class Client
|
20
|
-
def find_by_property(case_type, property_name, value, page, page_size)
|
21
|
-
Finder.new(self.class).execute_single(case_type, property_name, value, page, page_size)
|
22
|
-
end
|
23
|
-
|
24
|
-
def find_by_properties(case_type, properties, page, page_size)
|
25
|
-
Finder.new(self.class).execute_multiple(case_type, properties, page, page_size)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
describe CaseblocksAPI::Finder do
|
5
|
-
|
6
|
-
Given (:client) { FakeHttpParty.new }
|
7
|
-
Given (:case_type) { 'the_case_type' }
|
8
|
-
|
9
|
-
context "find by a single property" do
|
10
|
-
Given (:property_name) { "order_number" }
|
11
|
-
Given (:value) { "2000391" }
|
12
|
-
Given (:page) { "0" }
|
13
|
-
Given (:page_size) { "100" }
|
14
|
-
Given (:find_by_property) { CaseblocksAPI::Finder.new(client) }
|
15
|
-
When (:result) { find_by_property.execute_single(case_type, property_name, value, page, page_size) }
|
16
|
-
Then { expect(result).to eql client.result}
|
17
|
-
Then { expect(client.requested_url).to eql "/case_blocks/#{case_type}/search" }
|
18
|
-
Then { expect(client.params).to eql({query: {search: true, property: property_name, value: value, page: page, page_size: page_size}}) }
|
19
|
-
end
|
20
|
-
|
21
|
-
context "finding by multiple properties" do
|
22
|
-
Given (:properties) { {order_number: '12334', client_surname: 'Smith'} }
|
23
|
-
Given (:page) { "0" }
|
24
|
-
Given (:page_size) { "100" }
|
25
|
-
Given (:find_by_properties) { CaseblocksAPI::Finder.new(client) }
|
26
|
-
When (:result) { find_by_properties.execute_multiple(case_type, properties, page, page_size) }
|
27
|
-
Then { expect(client.requested_url).to eql "/case_blocks/#{case_type}/search" }
|
28
|
-
Then { expect(client.params).to eql({body: {search: true, properties: properties, page: page, page_size: page_size}.to_json}) }
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|