figshare_api_v2 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,7 @@
1
1
  module Figshare
2
-
3
2
  # Figshare Private Collections API
4
3
  #
5
4
  class PrivateCollections < Base
6
-
7
5
  # Requests a list of own (or institute's) collections
8
6
  #
9
7
  # @param order [String] "published_date" Default, "modified_date", "views", "cites", "shares"
@@ -12,9 +10,9 @@ module Figshare
12
10
  # @yield [Hash] {id, title, doi, handle, url, published_date}
13
11
  def list(order: 'published_date', order_direction: 'desc', impersonate: nil, &block)
14
12
  args = {}
15
- args["impersonate"] = impersonate if ! impersonate.nil?
16
- args['order'] = order if ! order.nil?
17
- args['order_direction'] = order_direction if ! order_direction.nil?
13
+ args['impersonate'] = impersonate unless impersonate.nil?
14
+ args['order'] = order unless order.nil?
15
+ args['order_direction'] = order_direction unless order_direction.nil?
18
16
  get_paginate(api_query: 'account/collections', args: args, &block)
19
17
  end
20
18
 
@@ -31,35 +29,41 @@ module Figshare
31
29
  # @param order_direction [String] "desc" Default, "asc"
32
30
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
33
31
  # @yield [Hash] {id, title, doi, handle, url, published_date}
34
- def search(institute: false, group_id: nil, impersonate: nil,
35
- published_since: nil, modified_since: nil,
36
- resource_doi: nil, doi: nil, handle: nil,
37
- order: 'published_date', order_direction: 'desc',
38
- search_for:,
39
- &block
40
- )
32
+ def search( search_for:,
33
+ institute: false,
34
+ group_id: nil,
35
+ impersonate: nil,
36
+ published_since: nil,
37
+ modified_since: nil,
38
+ resource_doi: nil,
39
+ doi: nil,
40
+ handle: nil,
41
+ order: 'published_date',
42
+ order_direction: 'desc',
43
+ &block
44
+ )
41
45
  args = { 'search_for' => search_for }
42
- args["impersonate"] = impersonate if ! impersonate.nil?
43
- args['institution'] = @institute_id if ! institute.nil?
44
- args['group_id'] = group_id if ! group_id.nil?
45
- args['resource_doi'] = resource_doi if ! resource_doi.nil?
46
- args['doi'] = doi if ! doi.nil?
47
- args['handle'] = handle if ! handle.nil?
48
- args['published_since'] = published_since if ! published_since.nil?
49
- args['modified_since'] = modified_since if ! modified_since.nil?
50
- args['order'] = order if ! order.nil?
51
- args['order_direction'] = order_direction if ! order_direction.nil?
46
+ args['impersonate'] = impersonate unless impersonate.nil?
47
+ args['institution'] = @institute_id unless institute.nil?
48
+ args['group_id'] = group_id unless group_id.nil?
49
+ args['resource_doi'] = resource_doi unless resource_doi.nil?
50
+ args['doi'] = doi unless doi.nil?
51
+ args['handle'] = handle unless handle.nil?
52
+ args['published_since'] = published_since unless published_since.nil?
53
+ args['modified_since'] = modified_since unless modified_since.nil?
54
+ args['order'] = order unless order.nil?
55
+ args['order_direction'] = order_direction unless order_direction.nil?
52
56
  post(api_query: 'account/collections/search', args: args, &block)
53
57
  end
54
-
58
+
55
59
  # Create a new private Collection by sending collection information
56
60
  #
57
61
  # @param body [Hash] See Figshare API docs
58
62
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
59
63
  def create(body:, impersonate: nil, &block)
60
64
  args = {}
61
- args["impersonate"] = impersonate if ! impersonate.nil?
62
- post(api_query: "account/collections", args: args, data: body, &block)
65
+ args['impersonate'] = impersonate unless impersonate.nil?
66
+ post(api_query: 'account/collections', args: args, data: body, &block)
63
67
  end
64
68
 
65
69
  # Delete a private collection
@@ -68,7 +72,7 @@ module Figshare
68
72
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
69
73
  def collection_delete(collection_id:, impersonate: nil, &block)
70
74
  args = {}
71
- args["impersonate"] = impersonate if ! impersonate.nil?
75
+ args['impersonate'] = impersonate unless impersonate.nil?
72
76
  delete( api_query: "account/collections/#{collection_id}/files/#{file_id}", args: args, &block )
73
77
  end
74
78
 
@@ -79,10 +83,10 @@ module Figshare
79
83
  # @yield [Hash] See figshare api docs
80
84
  def detail(collection_id:, impersonate: nil, &block)
81
85
  args = {}
82
- args["impersonate"] = impersonate if ! impersonate.nil?
86
+ args['impersonate'] = impersonate unless impersonate.nil?
83
87
  get(api_query: "account/collections/#{collection_id}", args: args, &block)
84
88
  end
85
-
89
+
86
90
  # Create a new private Collection by sending collection information
87
91
  #
88
92
  # @param collection_id [Integer] Figshare id of the collection
@@ -90,10 +94,10 @@ module Figshare
90
94
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
91
95
  def update(collection_id:, body:, impersonate: nil, &block)
92
96
  args = {}
93
- args["impersonate"] = impersonate if ! impersonate.nil?
94
- put(api_query: "account/collections", args: args, data: body, &block)
95
- end
96
-
97
+ args['impersonate'] = impersonate unless impersonate.nil?
98
+ put(api_query: "account/collections/#{collection_id}", args: args, data: body, &block)
99
+ end
100
+
97
101
  # Reserve DOI for collection
98
102
  #
99
103
  # @param collection_id [Integer] Figshare id of the collection
@@ -101,8 +105,8 @@ module Figshare
101
105
  # @yield [Hash] { doi }
102
106
  def reserve_doi(collection_id:, impersonate: nil, &block)
103
107
  args = {}
104
- args["impersonate"] = impersonate if ! impersonate.nil?
105
- post(api_query: 'account/collections/#{collection_id}/reserve_doi', args: args, &block)
108
+ args['impersonate'] = impersonate unless impersonate.nil?
109
+ post(api_query: "account/collections/#{collection_id}/reserve_doi", args: args, &block)
106
110
  end
107
111
 
108
112
  # Reserve Handle for collection
@@ -112,12 +116,12 @@ module Figshare
112
116
  # @yield [Hash] { handle }
113
117
  def reserve_handle(collection_id:, impersonate: nil, &block)
114
118
  args = {}
115
- args["impersonate"] = impersonate if ! impersonate.nil?
116
- post(api_query: 'account/collections/#{collection_id}/reserve_handle', args: args, &block)
119
+ args['impersonate'] = impersonate unless impersonate.nil?
120
+ post(api_query: "account/collections/#{collection_id}/reserve_handle", args: args, &block)
117
121
  end
118
122
 
119
- # When a collection is published, a new public version will be generated.
120
- # Any further updates to the collection will affect the private collection data.
123
+ # When a collection is published, a new public version will be generated.
124
+ # Any further updates to the collection will affect the private collection data.
121
125
  # In order to make these changes publicly visible, an explicit publish operation is needed.
122
126
  #
123
127
  # @param collection_id [Integer] Figshare id of the collection
@@ -125,8 +129,8 @@ module Figshare
125
129
  # @yield [Hash] { location }
126
130
  def publish(collection_id:, impersonate: nil, &block)
127
131
  args = {}
128
- args["impersonate"] = impersonate if ! impersonate.nil?
129
- post(api_query: 'account/collections/#{collection_id}/publish', args: args, &block)
132
+ args['impersonate'] = impersonate unless impersonate.nil?
133
+ post(api_query: "account/collections/#{collection_id}/publish", args: args, &block)
130
134
  end
131
135
 
132
136
  # Yield collections authors
@@ -134,9 +138,9 @@ module Figshare
134
138
  # @param collection_id [Integer] Figshare id of the collection
135
139
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
136
140
  # @yield [Hash] {id, full_name, is_active, url_name, orcid_id}
137
- def authors(article_id, impersonate: nil, &block)
141
+ def authors(_article_id, impersonate: nil, &block)
138
142
  args = {}
139
- args["impersonate"] = impersonate if ! impersonate.nil?
143
+ args['impersonate'] = impersonate unless impersonate.nil?
140
144
  get(api_query: "account/collections/#{collection_id}/authors", args: args, &block)
141
145
  end
142
146
 
@@ -146,34 +150,34 @@ module Figshare
146
150
  # @param authors [Array] Can be a mix of { id } and/or { name }
147
151
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
148
152
  # @yield [Hash] { location }
149
- def authors_add(article_id, impersonate: nil, authors:)
153
+ def authors_add(_article_id, authors:, impersonate: nil)
150
154
  args = {}
151
- args["impersonate"] = impersonate if ! impersonate.nil?
152
- post(api_query: "account/collections/#{collection_id}/authors", args: args, data: {"authors" => authors}, &block)
155
+ args['impersonate'] = impersonate unless impersonate.nil?
156
+ post(api_query: "account/collections/#{collection_id}/authors", args: args, data: { 'authors' => authors }, &block)
153
157
  end
154
-
158
+
155
159
  # Replace existing authors list with a new list
156
160
  #
157
161
  # @param collection_id [Integer] Figshare id of the collection
158
162
  # @param authors [Array] Can be a mix of { id } and/or { name }
159
163
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
160
- def authors_replace(article_id, impersonate: nil, authors:)
164
+ def authors_replace(_article_id, authors:, impersonate: nil)
161
165
  args = {}
162
- args["impersonate"] = impersonate if ! impersonate.nil?
163
- put(api_query: "account/collections/#{collection_id}/authors", args: args, data: {"authors" => authors}, &block)
166
+ args['impersonate'] = impersonate unless impersonate.nil?
167
+ put(api_query: "account/collections/#{collection_id}/authors", args: args, data: { 'authors' => authors }, &block)
164
168
  end
165
-
169
+
166
170
  # Remove author from the collection
167
171
  #
168
172
  # @param collection_id [Integer] Figshare id of the collection
169
173
  # @param author_id [Integer] Figshare id for the author
170
174
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
171
- def author_delete(collection_id:, impersonate: nil, author_id:)
175
+ def author_delete(collection_id:, author_id:, impersonate: nil)
172
176
  args = {}
173
- args["impersonate"] = impersonate if ! impersonate.nil?
177
+ args['impersonate'] = impersonate unless impersonate.nil?
174
178
  delete(api_query: "account/collections/#{collection_id}/authors/#{author_id}", args: args, &block)
175
179
  end
176
-
180
+
177
181
  # Yield collection categories
178
182
  #
179
183
  # @param collection_id [Integer] Figshare id of the collection
@@ -181,11 +185,11 @@ module Figshare
181
185
  # @yield [Hash] {parent_id, id, title}
182
186
  def categories(collection_id:, impersonate: nil, &block)
183
187
  args = {}
184
- args["impersonate"] = impersonate if ! impersonate.nil?
185
- get(api_query: 'account/collections/#{collection_id}/categories', args: args, &block)
188
+ args['impersonate'] = impersonate unless impersonate.nil?
189
+ get(api_query: "account/collections/#{collection_id}/categories", args: args, &block)
186
190
  end
187
-
188
- # Associate new categories with the collection.
191
+
192
+ # Associate new categories with the collection.
189
193
  # This will add new categories to the list of already associated categories
190
194
  #
191
195
  # @param collection_id [Integer] Figshare id of the collection
@@ -194,7 +198,7 @@ module Figshare
194
198
  # @yield [Hash] { location }
195
199
  def categories_add(collection_id:, categories:, impersonate: nil, &block)
196
200
  args = {}
197
- args["impersonate"] = impersonate if ! impersonate.nil?
201
+ args['impersonate'] = impersonate unless impersonate.nil?
198
202
  post(api_query: "account/collections/#{collection_id}/categories", args: args, data: { 'categories' => categories }, &block)
199
203
  end
200
204
 
@@ -205,7 +209,7 @@ module Figshare
205
209
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
206
210
  def categories_replace(collection_id:, categories:, impersonate: nil, &block)
207
211
  args = {}
208
- args["impersonate"] = impersonate if ! impersonate.nil?
212
+ args['impersonate'] = impersonate unless impersonate.nil?
209
213
  put(api_query: "account/collections/#{collection_id}/categories", args: args, data: { 'categories' => categories }, &block)
210
214
  end
211
215
 
@@ -216,7 +220,7 @@ module Figshare
216
220
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
217
221
  def categories_delete(collection_id:, category_id:, impersonate: nil, &block)
218
222
  args = {}
219
- args["impersonate"] = impersonate if ! impersonate.nil?
223
+ args['impersonate'] = impersonate unless impersonate.nil?
220
224
  delete(api_query: "account/collections/#{collection_id}/categories/#{category_id}", args: args, &block)
221
225
  end
222
226
 
@@ -227,17 +231,17 @@ module Figshare
227
231
  # @yield [Hash] See Figshare API docs
228
232
  def articles(collection_id:, impersonate: nil, &block)
229
233
  args = {}
230
- args["impersonate"] = impersonate if ! impersonate.nil?
234
+ args['impersonate'] = impersonate unless impersonate.nil?
231
235
  get(api_query: "account/collections/#{collection_id}/articles", args: args, &block)
232
236
  end
233
-
237
+
234
238
  # Get a private article's details (Not a figshare API call. Duplicates PrivateArticles:article_detail)
235
239
  #
236
240
  # @param article_id [Integer] Figshare id of the article
237
241
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
238
242
  def article_detail(article_id:, impersonate: nil, &block)
239
243
  args = {}
240
- args["impersonate"] = impersonate if ! impersonate.nil?
244
+ args['impersonate'] = impersonate unless impersonate.nil?
241
245
  get(api_query: "account/articles/#{article_id}", args: args, &block)
242
246
  end
243
247
 
@@ -245,14 +249,14 @@ module Figshare
245
249
  #
246
250
  # @param collection_id [Integer] Figshare id of the collection
247
251
  # @param articles [Array] array of Figshare article ids
248
- # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
252
+ # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
249
253
  # @yield [Hash] { location }
250
- def articles_add(collection_id:, articles: , impersonate: nil, &block)
254
+ def articles_add(collection_id:, articles:, impersonate: nil, &block)
251
255
  args = {}
252
- args["impersonate"] = impersonate if ! impersonate.nil?
253
- post( api_query: "account/collections/#{collection_id}/articles", args: args, data: { "articles": articles}, &block)
256
+ args['impersonate'] = impersonate unless impersonate.nil?
257
+ post( api_query: "account/collections/#{collection_id}/articles", args: args, data: { articles: articles }, &block)
254
258
  end
255
-
259
+
256
260
  # Get a private article's details (Not a figshare API call. Duplicates PrivateArticles:article_detail)
257
261
  #
258
262
  # @param collection_id [Integer] Figshare id of the collection
@@ -260,21 +264,21 @@ module Figshare
260
264
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
261
265
  def articles_replace(collection_id:, articles:, impersonate: nil, &block)
262
266
  args = {}
263
- args["impersonate"] = impersonate if ! impersonate.nil?
264
- put( api_query: "account/collections/#{collection_id}/articles/#{article_id}", args: args, data: { "articles": articles}, &block)
267
+ args['impersonate'] = impersonate unless impersonate.nil?
268
+ put( api_query: "account/collections/#{collection_id}/articles/#{article_id}", args: args, data: { articles: articles }, &block)
265
269
  end
266
-
270
+
267
271
  # Get a private article's details (Not a figshare API call. Duplicates PrivateArticles:article_detail)
268
272
  #
269
273
  # @param collection_id [Integer] Figshare id of the collection
270
274
  # @param article_id [Integer] Figshare id of the article
271
275
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
272
- def article_delete(collection_id:, article_id: , impersonate: nil, &block)
276
+ def article_delete(collection_id:, article_id:, impersonate: nil, &block)
273
277
  args = {}
274
- args["impersonate"] = impersonate if ! impersonate.nil?
278
+ args['impersonate'] = impersonate unless impersonate.nil?
275
279
  delete( api_query: "account/collections/#{collection_id}/articles/#{article_id}", args: args, &block)
276
280
  end
277
-
281
+
278
282
  # List private links
279
283
  #
280
284
  # @param collection_id [Integer] Figshare id of the collection
@@ -282,10 +286,10 @@ module Figshare
282
286
  # @yield [Hash] {id, is_active, expires_date}
283
287
  def links(collection_id:, impersonate: nil, &block)
284
288
  args = {}
285
- args["impersonate"] = impersonate if ! impersonate.nil?
289
+ args['impersonate'] = impersonate unless impersonate.nil?
286
290
  get(api_query: "account/collections/#{collection_id}/private_links", args: args, &block)
287
291
  end
288
-
292
+
289
293
  # Create new private link for this collection
290
294
  #
291
295
  # @param collection_id [Integer] Figshare id of the collection
@@ -294,21 +298,21 @@ module Figshare
294
298
  # @yield [Hash] { location }
295
299
  def link_create(collection_id:, private_link:, impersonate: nil, &block)
296
300
  args = {}
297
- args["impersonate"] = impersonate if ! impersonate.nil?
301
+ args['impersonate'] = impersonate unless impersonate.nil?
298
302
  post(api_query: "account/collections/#{collection_id}/private_links", args: args, data: private_link, &block)
299
303
  end
300
304
 
301
305
  # Disable/delete private link for this collection
302
306
  #
303
307
  # @param collection_id [Integer] Figshare id of the collection
304
- # @param link_id [Integer]
308
+ # @param link_id [Integer]
305
309
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
306
- def link_delete(collection_id:, link:, impersonate: nil, &block)
310
+ def link_delete(collection_id:, link_id:, impersonate: nil, &block)
307
311
  args = {}
308
- args["impersonate"] = impersonate if ! impersonate.nil?
312
+ args['impersonate'] = impersonate unless impersonate.nil?
309
313
  delete(api_query: "account/collections/#{collection_id}/private_links/#{link_id}", args: args, &block)
310
314
  end
311
-
315
+
312
316
  # Update private link for this collection
313
317
  #
314
318
  # @param collection_id [Integer] Figshare id of the collection
@@ -316,9 +320,8 @@ module Figshare
316
320
  # @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
317
321
  def link_update(collection_id:, link_id:, private_link:, impersonate: nil, &block)
318
322
  args = {}
319
- args["impersonate"] = impersonate if ! impersonate.nil?
323
+ args['impersonate'] = impersonate unless impersonate.nil?
320
324
  put(api_query: "account/collections/#{collection_id}/private_links/#{link_id}", args: args, data: private_link, &block)
321
325
  end
322
-
323
326
  end
324
- end
327
+ end