medidata 0.0.1 → 0.1.0

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/medidata/api/client.rb +87 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12a82b143cd97a12a83f592971730feca9678a498aceef53671a919f6f3a6413
4
- data.tar.gz: f4dadff58258bed1a7f6cb9f16dcd0af6a2ee8aae08a698a6acdec048570024f
3
+ metadata.gz: 146862d49091961f51acaac9bf7d019df1df8b4cb8b20567c3074f5b63add0f4
4
+ data.tar.gz: 258d9c11079c2f0a2ec6bf50244eff8094d2ce7729f4143ebc25511b741f8b10
5
5
  SHA512:
6
- metadata.gz: b9af6ed6ceb4d866e0b806c6686bf40ff35155964c0f24871bdbfbfa5eab2eab65e55b11a5ebd6295fbd888afc7ffa49ed2ab5791307e8b55da6b28fa94156f0
7
- data.tar.gz: 84bb1fc78121f31c1b237f939dcf0f817c84153968492cc8f31748e86463f65f80976539334ecbab9fb7d2208a255602ccf1036027bfb0a2a3d6108c741b8dc8
6
+ metadata.gz: 39f711f77dc64d73f2ddc44ffac00ebeb2dda51d7c2c27aeaebc845fbde9d1d430e3b03ce231a2b22ceaa8f5e0b7db01949decfd7c2be407930d3a6eb2045100
7
+ data.tar.gz: df8ff68d9ff8f409cf2763afe4ad0bae357347e457eb0fcb405b9c51a99337203b6b715d90ddda8cb9d503a4aee295e78d3653e16c494ce83f7e75e800dfe386
@@ -135,6 +135,93 @@ module Medidata::API
135
135
  end
136
136
  end
137
137
 
138
+ # Load pending downloads
139
+ #
140
+ # * *Args* :
141
+ # - +limit+ -> The total number of downloads allowed
142
+ # - +offset+ -> Pagination offset
143
+ def downloads_pending(limit: 100, offset: 0)
144
+ params = {
145
+ "query_params": {
146
+ "limit": limit,
147
+ "offset": offset
148
+ }
149
+ }
150
+ res = @rest.ela.downloads.get(params)
151
+ case res.status_code
152
+ when 200 then
153
+ body = res.parsed_body
154
+ raise "Invalid downloads response body" unless body.kind_of?(Array)
155
+ body.map { |row| Medidata::API::Download.new(row) }
156
+ when 400 then
157
+ raise BadRequestError.new("bad request")
158
+ when 401 then
159
+ raise UnauthenticatedError.new("authentication required to load pending downloads")
160
+ when 403 then
161
+ raise PermissionError.new("wrong credentials to load pending downloads")
162
+ else
163
+ raise "Error fetching Medidata downloads <#{res.status_code}>"
164
+ end
165
+ end
166
+
167
+ # Confirm download receipt
168
+ #
169
+ # All downloads received from Medidata are pending by default and
170
+ # clients have to manually mark them as "CONFIRMED". That should be done
171
+ # on a regular basis according to Medidata.
172
+ #
173
+ # * *Args* :
174
+ # - +tref+ -> download's transmission reference
175
+ def downloads_confirm_receipt(tref)
176
+ params = {
177
+ "request_body": {
178
+ "status": "CONFIRMED"
179
+ }
180
+ }
181
+ res = @rest.ela.downloads._(tref).status.put(params)
182
+ case res.status_code
183
+ when 200, 204 then
184
+ true
185
+ when 400 then
186
+ raise BadRequestError.new("bad request")
187
+ when 401 then
188
+ raise UnauthenticatedError.new("authentication required to confirm notification receipt")
189
+ when 403 then
190
+ raise PermissionError.new("wrong credentials to confirm notification receipt")
191
+ when 404 then
192
+ raise MissingError.new("notification not found")
193
+ else
194
+ raise "Error updating notification status <#{res.status_code}>"
195
+ end
196
+ end
197
+
198
+ # Retrieve download's payload
199
+ #
200
+ # * *Args* :
201
+ # - +tref+ -> download's transmission reference
202
+ def download(tref)
203
+ params = {
204
+ "request_headers": {
205
+ "Accept": "application/octet-stream"
206
+ },
207
+ }
208
+ res = @rest.ela.downloads._(tref).get(params)
209
+ case res.status_code
210
+ when 200 then
211
+ res.body
212
+ when 400 then
213
+ raise BadRequestError.new("bad request")
214
+ when 401 then
215
+ raise UnauthenticatedError.new("authentication required to download document")
216
+ when 403 then
217
+ raise PermissionError.new("wrong credentials to download document")
218
+ when 404 then
219
+ raise MissingError.new("notification not found")
220
+ else
221
+ raise "Error downloading document <#{res.status_code}>"
222
+ end
223
+ end
224
+
138
225
  # Load pending notifications
139
226
  #
140
227
  # * *Args* :
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: medidata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denteo AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-30 00:00:00.000000000 Z
11
+ date: 2021-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-types