red_cap 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/red_cap/client.rb +10 -2
- data/lib/red_cap/version.rb +1 -1
- data/lib/red_cap.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 294e8dbcbc97397f804b5443e39d7e25fe0a6fd33a5d41af80e9790c6a681441
|
4
|
+
data.tar.gz: 83776913f99befb802225f449943de4d85d0fb7efb775ded2292347bbd141693
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 877c44eee9b61ff514db43f235f78d4442ac53f3efcaaf9b223e6a271ddb5a0a297d0160477dc0ee6b569bcf619199d1b8b649ae863fa87fda1f97ccac577c4c
|
7
|
+
data.tar.gz: 4b36cfffeacc967b4bb3eaaae3aeb841b8a08197a17e4974f1e4725d4714d2c77312144323cac998d7fc738af34f5db41af755cac38862eac6b586e3c273e3a6
|
data/lib/red_cap/client.rb
CHANGED
@@ -28,6 +28,14 @@ class REDCap
|
|
28
28
|
json_api_request(content: "record", records: study_id).first
|
29
29
|
end
|
30
30
|
|
31
|
+
def save_records records
|
32
|
+
json_api_request(content: "record", data: records.to_json)
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete_records study_ids
|
36
|
+
json_api_request(content: "record", action: "delete", records: study_ids)
|
37
|
+
end
|
38
|
+
|
31
39
|
def metadata
|
32
40
|
json_api_request(content: "metadata")
|
33
41
|
end
|
@@ -64,8 +72,8 @@ class REDCap
|
|
64
72
|
connection.options.open_timeout = 300
|
65
73
|
connection.options.timeout = 300
|
66
74
|
response = connection.post nil, options.reverse_merge(token: @token)
|
67
|
-
if
|
68
|
-
raise Error.new(
|
75
|
+
if response.body =~ /^{"error":"/
|
76
|
+
raise Error.new(response.body)
|
69
77
|
end
|
70
78
|
response
|
71
79
|
end
|
data/lib/red_cap/version.rb
CHANGED
data/lib/red_cap.rb
CHANGED
@@ -34,6 +34,15 @@ class REDCap
|
|
34
34
|
client.records(filters.join(" AND "), &block)
|
35
35
|
end
|
36
36
|
|
37
|
+
def update study_id, attributes
|
38
|
+
record = attributes.merge(study_id: study_id).stringify_keys
|
39
|
+
client.save_records [record]
|
40
|
+
end
|
41
|
+
|
42
|
+
def delete study_id
|
43
|
+
client.delete_records [study_id]
|
44
|
+
end
|
45
|
+
|
37
46
|
private
|
38
47
|
|
39
48
|
def client
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: red_cap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|