commcare_api 0.2.0 → 0.3.0

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: 4322550ad4a3e53f6e9388a4ed458495c18700aa
4
- data.tar.gz: fb54c249c1a4249869bfd808ffe98973a265992d
3
+ metadata.gz: c14a4026fd69dc724275ad10685838932c366c64
4
+ data.tar.gz: d1e8487e039c6eef3e591f72ed446146e3667392
5
5
  SHA512:
6
- metadata.gz: 5bdc99e28f71f00154d8d840c26b0277e499777d5f49159bd228a7d26662755b596e9411631a013a5dc517e7bf85cbf99727b0687f6daeffd5d17ab1ca03b8f3
7
- data.tar.gz: e35b94ea9bfbf9dd04d160467aa75e6031265306961647009cfe80b6b7443144bcd503f8ac7686948dc610d1292a63a12e03d2b26fbdc856c6927db6c7700573
6
+ metadata.gz: fe74c5b4504fc85a1a598b1fe5e3767e071de5829f2aa88c690d7dd969fe6cd89b80ab7e67a37b0ed908508211455a85b8d9d35f8446fd1599e37c671dbd090c
7
+ data.tar.gz: 42c363acda95e73db2b24136e6307048fa1e2fa353350cc9f17fac9398a4829debbeef09347d6e6eb09f3d4e6aa3869290b18ad7fd18aeecdea641df44e57885
data/README.md CHANGED
@@ -27,6 +27,7 @@ Or install it yourself as:
27
27
  * [List Web Users](https://wiki.commcarehq.org/display/commcarepublic/List+Web+Users): `get_web_users`, `get_web_user`
28
28
  * [Data Forwarding (GET only)](https://wiki.commcarehq.org/display/commcarepublic/Data+Forwarding): `get_data_forwarding`
29
29
  * [Application Structure](https://wiki.commcarehq.org/display/commcarepublic/Application+Structure+API): `get_application_structure`
30
+ * [Fixture Data (GET only)](https://wiki.commcarehq.org/display/commcarepublic/Fixture+Data)
30
31
 
31
32
  ## Usage
32
33
 
data/commcare_api.gemspec CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.5"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency 'rspec'
23
24
  spec.add_dependency "httpi"
24
25
  spec.add_dependency "httpclient"
25
26
  end
data/lib/commcare_api.rb CHANGED
@@ -68,6 +68,21 @@ module CommcareApi
68
68
  url = build_url(domain, "data-forwarding", {})
69
69
  get_request(url)
70
70
  end
71
+
72
+ def get_fixtures(domain)
73
+ url = build_url(domain, "fixture", {})
74
+ get_request(url)
75
+ end
76
+
77
+ def get_fixture(domain, type)
78
+ url = build_url(domain, "fixture", {fixture_type: type})
79
+ get_request(url)
80
+ end
81
+
82
+ def get_fixture_item(domain, item_id)
83
+ url = build_url(domain, "fixture/#{item_id}", {})
84
+ get_request(url)
85
+ end
71
86
 
72
87
  protected
73
88
 
@@ -1,3 +1,3 @@
1
1
  module CommcareApi
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe CommcareApi do
4
+ ccc = CommcareApi::CommcareConnector.new(ENV["CC_USER"], ENV["CC_PWD"])
5
+
6
+ case_id = ""
7
+ it "get_cases" do
8
+ r = ccc.get_cases(ENV["CC_DOMAIN"])
9
+ case_id = JSON.parse(r.body)["objects"][0]["case_id"]
10
+ expect(r.code).to eq 200
11
+ end
12
+
13
+ it "get_case" do
14
+ r = ccc.get_case(ENV["CC_DOMAIN"], case_id)
15
+ expect(r.code).to eq 200
16
+ end
17
+
18
+ form_id = ""
19
+ it "get_forms" do
20
+ r = ccc.get_forms(ENV["CC_DOMAIN"])
21
+ form_id = JSON.parse(r.body)["objects"][0]["id"]
22
+ expect(r.code).to eq 200
23
+ end
24
+
25
+ it "get_form" do
26
+ r = ccc.get_form(ENV["CC_DOMAIN"], form_id)
27
+ expect(r.code).to eq 200
28
+ end
29
+
30
+ it "get_groups" do
31
+ r = ccc.get_groups(ENV["CC_DOMAIN"])
32
+ expect(r.code).to eq 200
33
+ end
34
+
35
+ mobile_worker_id = ""
36
+ it "get_mobile_workers" do
37
+ r = ccc.get_mobile_workers(ENV["CC_DOMAIN"])
38
+ mobile_worker_id = JSON.parse(r.body)["objects"][0]["id"]
39
+ expect(r.code).to eq 200
40
+ end
41
+
42
+ it "get_mobile_worker" do
43
+ r = ccc.get_mobile_worker(ENV["CC_DOMAIN"], mobile_worker_id)
44
+ expect(r.code).to eq 200
45
+ end
46
+
47
+ web_user_id = ""
48
+ it "get_web_users" do
49
+ r = ccc.get_web_users(ENV["CC_DOMAIN"])
50
+ web_user_id = JSON.parse(r.body)["objects"][0]["id"]
51
+ expect(r.code).to eq 200
52
+ end
53
+
54
+ it "get_web_user" do
55
+ r = ccc.get_web_user(ENV["CC_DOMAIN"], web_user_id)
56
+ expect(r.code).to eq 200
57
+ end
58
+
59
+ it "get_application_structure" do
60
+ r = ccc.get_application_structure(ENV["CC_DOMAIN"])
61
+ expect(r.code).to eq 200
62
+ end
63
+
64
+ it "get_data_forwarding" do
65
+ r = ccc.get_data_forwarding(ENV["CC_DOMAIN"])
66
+ expect(r.code).to eq 200
67
+ end
68
+
69
+ fixture_type = ""
70
+ fixture_item_id = ""
71
+ it "get_fixtures" do
72
+ r = ccc.get_fixtures(ENV["CC_DOMAIN"])
73
+ fixture_type = JSON.parse(r.body)["objects"][0]["fixture_type"]
74
+ fixture_item_id= JSON.parse(r.body)["objects"][0]["id"]
75
+ expect(r.code).to eq 200
76
+ end
77
+
78
+ it "get_fixture" do
79
+ r = ccc.get_fixture(ENV["CC_DOMAIN"], fixture_type)
80
+ expect(r.code).to eq 200
81
+ end
82
+
83
+ it "get_fixture_item" do
84
+ r = ccc.get_fixture_item(ENV["CC_DOMAIN"], fixture_item_id)
85
+ expect(r.code).to eq 200
86
+ end
87
+
88
+ end
@@ -0,0 +1,2 @@
1
+ require 'commcare_api'
2
+ require 'json'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commcare_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Deflaux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-27 00:00:00.000000000 Z
11
+ date: 2014-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: httpi
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -81,6 +95,8 @@ files:
81
95
  - commcare_api.gemspec
82
96
  - lib/commcare_api.rb
83
97
  - lib/commcare_api/version.rb
98
+ - spec/commcare_api_spec.rb
99
+ - spec/spec_helper.rb
84
100
  homepage: ''
85
101
  licenses:
86
102
  - MIT
@@ -105,4 +121,6 @@ rubygems_version: 2.2.1
105
121
  signing_key:
106
122
  specification_version: 4
107
123
  summary: A CommCare API wrapper in Ruby
108
- test_files: []
124
+ test_files:
125
+ - spec/commcare_api_spec.rb
126
+ - spec/spec_helper.rb