figshare_api_v2 0.9.1
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.
- checksums.yaml +7 -0
- data/History.txt +58 -0
- data/Manifest.txt +18 -0
- data/README.md +74 -0
- data/Rakefile +31 -0
- data/lib/authors.rb +41 -0
- data/lib/base.rb +262 -0
- data/lib/figshare_api_v2.rb +121 -0
- data/lib/institutions.rb +238 -0
- data/lib/oai_pmh.rb +6 -0
- data/lib/other.rb +51 -0
- data/lib/private_articles.rb +354 -0
- data/lib/private_collections.rb +324 -0
- data/lib/private_projects.rb +308 -0
- data/lib/public_articles.rb +125 -0
- data/lib/public_collections.rb +105 -0
- data/lib/public_projects.rb +66 -0
- data/lib/stats.rb +16 -0
- data/lib/upload.rb +215 -0
- metadata +140 -0
@@ -0,0 +1,324 @@
|
|
1
|
+
module Figshare
|
2
|
+
|
3
|
+
# Figshare Private Collections API
|
4
|
+
#
|
5
|
+
class PrivateCollections < Base
|
6
|
+
|
7
|
+
# Requests a list of own (or institute's) collections
|
8
|
+
#
|
9
|
+
# @param order [String] "published_date" Default, "modified_date", "views", "cites", "shares"
|
10
|
+
# @param order_direction [String] "desc" Default, "asc"
|
11
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
12
|
+
# @yield [Hash] {id, title, doi, handle, url, published_date}
|
13
|
+
def list(order: 'published_date', order_direction: 'desc', impersonate: nil, &block)
|
14
|
+
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?
|
18
|
+
get_paginate(api_query: 'account/collections', args: args, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Search within the own (or institute's) collections
|
22
|
+
#
|
23
|
+
# @param institution [Boolean] Just our institution
|
24
|
+
# @param group_id [Integer] Only return this group's collections
|
25
|
+
# @param published_since [Time] Return results if published after this time
|
26
|
+
# @param modified_since [Time] Return results if modified after this time
|
27
|
+
# @param resource_doi [String] Matches this resource doi
|
28
|
+
# @param doi [String] Matches this doi
|
29
|
+
# @param handle [String] Matches this handle
|
30
|
+
# @param order [String] "published_date" Default, "modified_date", "views", "cites", "shares"
|
31
|
+
# @param order_direction [String] "desc" Default, "asc"
|
32
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
33
|
+
# @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
|
+
)
|
41
|
+
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?
|
52
|
+
post(api_query: 'account/collections/search', args: args, &block)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Create a new private Collection by sending collection information
|
56
|
+
#
|
57
|
+
# @param body [Hash] See Figshare API docs
|
58
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
59
|
+
def create(body:, impersonate: nil, &block)
|
60
|
+
args = {}
|
61
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
62
|
+
post(api_query: "account/collections", args: args, data: body, &block)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Delete a private collection
|
66
|
+
#
|
67
|
+
# @param collection_id [Integer] Figshare id of the collection
|
68
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
69
|
+
def collection_delete(collection_id:, impersonate: nil, &block)
|
70
|
+
args = {}
|
71
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
72
|
+
delete( api_query: "account/collections/#{collection_id}/files/#{file_id}", args: args, &block )
|
73
|
+
end
|
74
|
+
|
75
|
+
# Return details of specific collection (default version)
|
76
|
+
#
|
77
|
+
# @param collection_id [Integer] Figshare id of the collection
|
78
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
79
|
+
# @yield [Hash] See figshare api docs
|
80
|
+
def detail(collection_id:, impersonate: nil, &block)
|
81
|
+
args = {}
|
82
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
83
|
+
get(api_query: "account/collections/#{collection_id}", args: args, &block)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Create a new private Collection by sending collection information
|
87
|
+
#
|
88
|
+
# @param collection_id [Integer] Figshare id of the collection
|
89
|
+
# @param body [Hash] See Figshare API docs
|
90
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
91
|
+
def update(collection_id:, body:, impersonate: nil, &block)
|
92
|
+
args = {}
|
93
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
94
|
+
put(api_query: "account/collections", args: args, data: body, &block)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Reserve DOI for collection
|
98
|
+
#
|
99
|
+
# @param collection_id [Integer] Figshare id of the collection
|
100
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
101
|
+
# @yield [Hash] { doi }
|
102
|
+
def reserve_doi(collection_id:, impersonate: nil, &block)
|
103
|
+
args = {}
|
104
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
105
|
+
post(api_query: 'account/collections/#{collection_id}/reserve_doi', args: args, &block)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Reserve Handle for collection
|
109
|
+
#
|
110
|
+
# @param collection_id [Integer] Figshare id of the collection
|
111
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
112
|
+
# @yield [Hash] { handle }
|
113
|
+
def reserve_handle(collection_id:, impersonate: nil, &block)
|
114
|
+
args = {}
|
115
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
116
|
+
post(api_query: 'account/collections/#{collection_id}/reserve_handle', args: args, &block)
|
117
|
+
end
|
118
|
+
|
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.
|
121
|
+
# In order to make these changes publicly visible, an explicit publish operation is needed.
|
122
|
+
#
|
123
|
+
# @param collection_id [Integer] Figshare id of the collection
|
124
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
125
|
+
# @yield [Hash] { location }
|
126
|
+
def publish(collection_id:, impersonate: nil, &block)
|
127
|
+
args = {}
|
128
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
129
|
+
post(api_query: 'account/collections/#{collection_id}/publish', args: args, &block)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Yield collections authors
|
133
|
+
#
|
134
|
+
# @param collection_id [Integer] Figshare id of the collection
|
135
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
136
|
+
# @yield [Hash] {id, full_name, is_active, url_name, orcid_id}
|
137
|
+
def authors(article_id, impersonate: nil, &block)
|
138
|
+
args = {}
|
139
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
140
|
+
get(api_query: "account/collections/#{collection_id}/authors", args: args, &block)
|
141
|
+
end
|
142
|
+
|
143
|
+
# Associate new authors with the collection. This will add new authors to the list of already associated authors
|
144
|
+
#
|
145
|
+
# @param collection_id [Integer] Figshare id of the collection
|
146
|
+
# @param authors [Array] Can be a mix of { id } and/or { name }
|
147
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
148
|
+
# @yield [Hash] { location }
|
149
|
+
def authors_add(article_id, impersonate: nil, authors:)
|
150
|
+
args = {}
|
151
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
152
|
+
post(api_query: "account/collections/#{collection_id}/authors", args: args, data: {"authors" => authors}, &block)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Replace existing authors list with a new list
|
156
|
+
#
|
157
|
+
# @param collection_id [Integer] Figshare id of the collection
|
158
|
+
# @param authors [Array] Can be a mix of { id } and/or { name }
|
159
|
+
# @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:)
|
161
|
+
args = {}
|
162
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
163
|
+
put(api_query: "account/collections/#{collection_id}/authors", args: args, data: {"authors" => authors}, &block)
|
164
|
+
end
|
165
|
+
|
166
|
+
# Remove author from the collection
|
167
|
+
#
|
168
|
+
# @param collection_id [Integer] Figshare id of the collection
|
169
|
+
# @param author_id [Integer] Figshare id for the author
|
170
|
+
# @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:)
|
172
|
+
args = {}
|
173
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
174
|
+
delete(api_query: "account/collections/#{collection_id}/authors/#{author_id}", args: args, &block)
|
175
|
+
end
|
176
|
+
|
177
|
+
# Yield collection categories
|
178
|
+
#
|
179
|
+
# @param collection_id [Integer] Figshare id of the collection
|
180
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
181
|
+
# @yield [Hash] {parent_id, id, title}
|
182
|
+
def categories(collection_id:, impersonate: nil, &block)
|
183
|
+
args = {}
|
184
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
185
|
+
get(api_query: 'account/collections/#{collection_id}/categories', args: args, &block)
|
186
|
+
end
|
187
|
+
|
188
|
+
# Associate new categories with the collection.
|
189
|
+
# This will add new categories to the list of already associated categories
|
190
|
+
#
|
191
|
+
# @param collection_id [Integer] Figshare id of the collection
|
192
|
+
# @param categories [Array] [ categorie_id, ... ]
|
193
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
194
|
+
# @yield [Hash] { location }
|
195
|
+
def categories_add(collection_id:, categories:, impersonate: nil, &block)
|
196
|
+
args = {}
|
197
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
198
|
+
post(api_query: "account/collections/#{collection_id}/categories", args: args, data: { 'categories' => categories }, &block)
|
199
|
+
end
|
200
|
+
|
201
|
+
# Associate new categories with the collection. This will remove all already associated categories and add these new ones
|
202
|
+
#
|
203
|
+
# @param collection_id [Integer] Figshare id of the collection
|
204
|
+
# @param categories [Array] [ categorie_id, ... ]
|
205
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
206
|
+
def categories_replace(collection_id:, categories:, impersonate: nil, &block)
|
207
|
+
args = {}
|
208
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
209
|
+
put(api_query: "account/collections/#{collection_id}/categories", args: args, data: { 'categories' => categories }, &block)
|
210
|
+
end
|
211
|
+
|
212
|
+
# Delete category from collection's categories
|
213
|
+
#
|
214
|
+
# @param collection_id [Integer] Figshare id of the collection
|
215
|
+
# @param category_id [Integer] Figshare id of the category
|
216
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
217
|
+
def categories_delete(collection_id:, category_id:, impersonate: nil, &block)
|
218
|
+
args = {}
|
219
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
220
|
+
delete(api_query: "account/collections/#{collection_id}/categories/#{category_id}", args: args, &block)
|
221
|
+
end
|
222
|
+
|
223
|
+
# Yield collection articles
|
224
|
+
#
|
225
|
+
# @param collection_id [Integer] Figshare id of the collection
|
226
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
227
|
+
# @yield [Hash] See Figshare API docs
|
228
|
+
def articles(collection_id:, impersonate: nil, &block)
|
229
|
+
args = {}
|
230
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
231
|
+
get(api_query: "account/collections/#{collection_id}/articles", args: args, &block)
|
232
|
+
end
|
233
|
+
|
234
|
+
# Get a private article's details (Not a figshare API call. Duplicates PrivateArticles:article_detail)
|
235
|
+
#
|
236
|
+
# @param article_id [Integer] Figshare id of the article
|
237
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
238
|
+
def article_detail(article_id:, impersonate: nil, &block)
|
239
|
+
args = {}
|
240
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
241
|
+
get(api_query: "account/articles/#{article_id}", args: args, &block)
|
242
|
+
end
|
243
|
+
|
244
|
+
# Associate new articles with the collection. This will add new articles to the list of already associated articles
|
245
|
+
#
|
246
|
+
# @param collection_id [Integer] Figshare id of the collection
|
247
|
+
# @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
|
249
|
+
# @yield [Hash] { location }
|
250
|
+
def articles_add(collection_id:, articles: , impersonate: nil, &block)
|
251
|
+
args = {}
|
252
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
253
|
+
post( api_query: "account/collections/#{collection_id}/articles/#{article_id}", args: args, data: { "articles": articles}, &block)
|
254
|
+
end
|
255
|
+
|
256
|
+
# Get a private article's details (Not a figshare API call. Duplicates PrivateArticles:article_detail)
|
257
|
+
#
|
258
|
+
# @param collection_id [Integer] Figshare id of the collection
|
259
|
+
# @param articles [Array] array of Figshare article ids
|
260
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
261
|
+
def articles_replace(collection_id:, articles:, impersonate: nil, &block)
|
262
|
+
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)
|
265
|
+
end
|
266
|
+
|
267
|
+
# Get a private article's details (Not a figshare API call. Duplicates PrivateArticles:article_detail)
|
268
|
+
#
|
269
|
+
# @param collection_id [Integer] Figshare id of the collection
|
270
|
+
# @param article_id [Integer] Figshare id of the article
|
271
|
+
# @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)
|
273
|
+
args = {}
|
274
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
275
|
+
delete( api_query: "account/collections/#{collection_id}/articles/#{article_id}", args: args, &block)
|
276
|
+
end
|
277
|
+
|
278
|
+
# List private links
|
279
|
+
#
|
280
|
+
# @param collection_id [Integer] Figshare id of the collection
|
281
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
282
|
+
# @yield [Hash] {id, is_active, expires_date}
|
283
|
+
def links(collection_id:, impersonate: nil, &block)
|
284
|
+
args = {}
|
285
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
286
|
+
get(api_query: "account/collections/#{collection_id}/private_links", args: args, &block)
|
287
|
+
end
|
288
|
+
|
289
|
+
# Create new private link for this collection
|
290
|
+
#
|
291
|
+
# @param collection_id [Integer] Figshare id of the collection
|
292
|
+
# @param private_link [Hash] { expires_date, read_only }
|
293
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
294
|
+
# @yield [Hash] { location }
|
295
|
+
def link_create(collection_id:, private_link:, impersonate: nil, &block)
|
296
|
+
args = {}
|
297
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
298
|
+
post(api_query: "account/collections/#{collection_id}/private_links", args: args, data: private_link, &block)
|
299
|
+
end
|
300
|
+
|
301
|
+
# Disable/delete private link for this collection
|
302
|
+
#
|
303
|
+
# @param collection_id [Integer] Figshare id of the collection
|
304
|
+
# @param link_id [Integer]
|
305
|
+
# @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)
|
307
|
+
args = {}
|
308
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
309
|
+
delete(api_query: "account/collections/#{collection_id}/private_links/#{link_id}", args: args, &block)
|
310
|
+
end
|
311
|
+
|
312
|
+
# Update private link for this collection
|
313
|
+
#
|
314
|
+
# @param collection_id [Integer] Figshare id of the collection
|
315
|
+
# @param private_link [Hash] { expires_date, read_only }
|
316
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
317
|
+
def link_update(collection_id:, link_id:, private_link:, impersonate: nil, &block)
|
318
|
+
args = {}
|
319
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
320
|
+
put(api_query: "account/collections/#{collection_id}/private_links/#{link_id}", args: args, data: private_link, &block)
|
321
|
+
end
|
322
|
+
|
323
|
+
end
|
324
|
+
end
|
@@ -0,0 +1,308 @@
|
|
1
|
+
module Figshare
|
2
|
+
|
3
|
+
# Figshare private project api
|
4
|
+
#
|
5
|
+
class PrivateProjects < Base
|
6
|
+
# Requests a list private projects
|
7
|
+
#
|
8
|
+
# @param storage [String] group, individual (only return collections from this institution)
|
9
|
+
# @param roles [String] Any combination of owner, collaborator, viewer separated by comma. Examples: "owner" or "owner,collaborator".
|
10
|
+
# @param order [String] "published_date" Default, "modified_date", "views", "cites", "shares"
|
11
|
+
# @param order_direction [String] "desc" Default, "asc"
|
12
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
13
|
+
# @yield [Hash] {role, storage, url, published_date, id, title}
|
14
|
+
def list(storage: nil, roles: nil, order: 'published_date', order_direction: 'desc', impersonate: nil, &block)
|
15
|
+
args = {}
|
16
|
+
args['storage'] = storage if ! storage.nil?
|
17
|
+
args['roles'] = roles if ! roles.nil?
|
18
|
+
args['order'] = order if ! order.nil?
|
19
|
+
args['order_direction'] = order_direction if ! order_direction.nil?
|
20
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
21
|
+
get_paginate(api_query: 'account/projects', args: args, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Search within the own (or institute's) projects
|
25
|
+
#
|
26
|
+
# @param institution [Boolean] Just our institution
|
27
|
+
# @param group_id [Integer] Only return this group's project
|
28
|
+
# @param published_since [Time] Return results if published after this time
|
29
|
+
# @param modified_since [Time] Return results if modified after this time
|
30
|
+
# @param order [String] "published_date" Default, "modified_date", "views", "cites", "shares"
|
31
|
+
# @param order_direction [String] "desc" Default, "asc"
|
32
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
33
|
+
# @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
|
+
order: 'published_date', order_direction: 'desc',
|
37
|
+
search_for:,
|
38
|
+
&block
|
39
|
+
)
|
40
|
+
args = { 'search_for' => search_for }
|
41
|
+
args['institution'] = @institute_id if ! institute.nil?
|
42
|
+
args['group'] = group_id if ! group_id.nil?
|
43
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
44
|
+
args['published_since'] = published_since if ! published_since.nil?
|
45
|
+
args['modified_since'] = modified_since if ! modified_since.nil?
|
46
|
+
args['order'] = order if ! order.nil?
|
47
|
+
args['order_direction'] = order_direction if ! order_direction.nil?
|
48
|
+
post(api_query: 'account/projects/search', args: args, &block)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Create a new project
|
52
|
+
#
|
53
|
+
# @param title [String]
|
54
|
+
# @param description [String]
|
55
|
+
# @param funding [String]
|
56
|
+
# @param funding_list [Array] [{id, title}, ... ]
|
57
|
+
# #param group_id [Integer] Figshare group the project falls under.
|
58
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
59
|
+
# @yield [Hash] { location }
|
60
|
+
def create(title:, description:, funding: '', funding_list: [], group_id:, impersonate: nil, &block)
|
61
|
+
args = { "title" => title,
|
62
|
+
"description" => description,
|
63
|
+
"group_id" => group_id,
|
64
|
+
"funding" => funding,
|
65
|
+
"funding_list" => funding_list
|
66
|
+
}
|
67
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
68
|
+
post(api_query: 'account/projects', args: args, &block)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Delete an existing project
|
72
|
+
#
|
73
|
+
# @param project_id [Integer] Figshare project ID
|
74
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
75
|
+
def project_delete(project_id:, impersonate: nil, &block)
|
76
|
+
args = {}
|
77
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
78
|
+
delete(api_query: 'account/projects/#{project_id}', args: args, &block)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Return details of specific private project
|
82
|
+
#
|
83
|
+
# @param project_id [Integer] Figshare id of the project_id
|
84
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
85
|
+
# @yield [Hash] See figshare api docs
|
86
|
+
def detail(project_id:, impersonate: nil, &block)
|
87
|
+
args = {}
|
88
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
89
|
+
get(api_query: "account/projects/#{project_id}", args: args, &block)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Update an existing project
|
93
|
+
#
|
94
|
+
# @param project_id [Integer] Figshare id of the project_id
|
95
|
+
# @param title [String]
|
96
|
+
# @param description [String]
|
97
|
+
# @param funding [String]
|
98
|
+
# @param funding_list [Array] [{id, title}, ... ]
|
99
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
100
|
+
# @yield [Hash] { location }
|
101
|
+
def update(project_id:, title: nil, description: nil, funding: nil, funding_list: nil, impersonate: nil, &block)
|
102
|
+
args = {}
|
103
|
+
args["title"] = title if ! title.nil?
|
104
|
+
args["description"] = description if ! description.nil?
|
105
|
+
args["funding"] = funding if ! funding.nil?
|
106
|
+
args["funding_list"] = funding_list if ! funding_list.nil?
|
107
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
108
|
+
put(api_query: "account/projects/#{project_id}", args: args, &block)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Publish a project
|
112
|
+
#
|
113
|
+
# @param project_id [Integer] Figshare id of the project
|
114
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
115
|
+
# @yield [Hash] Message
|
116
|
+
def publish(project_id:, impersonate: nil, &block)
|
117
|
+
args = {}
|
118
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
119
|
+
post(api_query: "account/projects/#{project_id}/publish", args: args, &block)
|
120
|
+
end
|
121
|
+
|
122
|
+
# List projects notes
|
123
|
+
#
|
124
|
+
# @param project_id [Integer] Figshare id of the project
|
125
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
126
|
+
# @yield [Hash] {id, user_id, abstract, user_name, created_date, modified_date}
|
127
|
+
def notes(project_id:, impersonate: nil, &block)
|
128
|
+
args = {}
|
129
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
130
|
+
get_paginate(api_query: "account/projects/#{project_id}/notes", args: args, &block)
|
131
|
+
end
|
132
|
+
|
133
|
+
# Create a project note
|
134
|
+
#
|
135
|
+
# @param project_id [Integer] Figshare id of the project
|
136
|
+
# @param text [String] The note
|
137
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
138
|
+
# @yield [Hash] { location }
|
139
|
+
def note_create(project_id:, text:, impersonate: nil, &block)
|
140
|
+
args = { 'text' => text }
|
141
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
142
|
+
post(api_query: "account/projects/#{project_id}/notes", args: args, &block)
|
143
|
+
end
|
144
|
+
|
145
|
+
# Delete a project note
|
146
|
+
#
|
147
|
+
# @param project_id [Integer] Figshare id of the project
|
148
|
+
# @param note_id [Integer] Figshare id of the note
|
149
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
150
|
+
def note_delete(project_id:, note_id:, impersonate: nil, &block)
|
151
|
+
args = {}
|
152
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
153
|
+
delete(api_query: "account/projects/#{project_id}/notes/#{note_id}", args: args, &block)
|
154
|
+
end
|
155
|
+
|
156
|
+
# Get a note's text
|
157
|
+
#
|
158
|
+
# @param project_id [Integer] Figshare id of the project
|
159
|
+
# @param note_id [Integer] Figshare id of the note
|
160
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
161
|
+
# @yield [Hash] { text }
|
162
|
+
def note_detail(impersonate: nil, &block)
|
163
|
+
args = {}
|
164
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
165
|
+
get(api_query: "account/projects/#{project_id}/notes/#{note_id}", args: args, &block)
|
166
|
+
end
|
167
|
+
|
168
|
+
# update a project note
|
169
|
+
#
|
170
|
+
# @param project_id [Integer] Figshare id of the project
|
171
|
+
# @param note_id [Integer] Figshare id of the note
|
172
|
+
# @param text [String] The note
|
173
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
174
|
+
def note_create(project_id:, note_id:, text:, impersonate: nil, &block)
|
175
|
+
args = { 'text' => text }
|
176
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
177
|
+
put(api_query: "account/projects/#{project_id}/notes/#{note_id}", args: args, &block)
|
178
|
+
end
|
179
|
+
|
180
|
+
# Leave a project (Please note: project's owner cannot leave the project.)
|
181
|
+
#
|
182
|
+
# @param project_id [Integer] Figshare id of the project_id
|
183
|
+
def private_project_collaborators_leave(project_id:, impersonate: nil, &block)
|
184
|
+
args = {}
|
185
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
186
|
+
post(api_query: "account/projects/#{project_id}/leave", args: args, &block)
|
187
|
+
end
|
188
|
+
|
189
|
+
# Get the project collaborators
|
190
|
+
#
|
191
|
+
# @param project_id [Integer] Figshare id of the project_id
|
192
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
193
|
+
# @yield [Hash] { status, role_name, user_id, name }
|
194
|
+
def collaborators(project_id:, impersonate: nil, &block)
|
195
|
+
args = {}
|
196
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
197
|
+
get(api_query: "account/projects/#{project_id}/collaborators", args: args, &block)
|
198
|
+
end
|
199
|
+
|
200
|
+
# Invite a new collaborators to the project
|
201
|
+
#
|
202
|
+
# @param project_id [Integer] Figshare id of the project_id
|
203
|
+
# @param role_name [String]
|
204
|
+
# @param user_id [Integer] Need user_id or email
|
205
|
+
# @param email [String] Used, if user_id is nil
|
206
|
+
# @param comment [String]
|
207
|
+
# @yield [String] { message }
|
208
|
+
def collaborator_invite(project_id:, role_name:, user_id: nil, email: nil, comment:, impersonate: nil, &block)
|
209
|
+
args = {
|
210
|
+
'role_name' => role_name,
|
211
|
+
'comment' => comment
|
212
|
+
}
|
213
|
+
if ! user_id.nil?
|
214
|
+
args['user_id'] = user_id
|
215
|
+
elsif ! email.nil?
|
216
|
+
args['email'] = email
|
217
|
+
else
|
218
|
+
raise "collaborator_invite(): Need a user_id or an email address"
|
219
|
+
end
|
220
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
221
|
+
collaborator = { "role_name" => role_name, "user_id" => user_id, "email" => email, "comment" => comment }
|
222
|
+
post(api_query: "account/project/#{project_id}/collaborators", args: args, data: collaborator, &block)
|
223
|
+
end
|
224
|
+
|
225
|
+
# Leave a project (Please note: project's owner cannot leave the project.)
|
226
|
+
#
|
227
|
+
# @param project_id [Integer] Figshare id of the project_id
|
228
|
+
# @param user_id [Integer] Figshare id of a user in the project
|
229
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
230
|
+
def collaborator_remove(project_id:, user_id:, impersonate: nil, &block)
|
231
|
+
args = {}
|
232
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
233
|
+
delete(api_query: "account/project/#{project_id}/collaborators/#{user_id}", args: args, &block)
|
234
|
+
end
|
235
|
+
|
236
|
+
# Return details of list of articles for a specific project
|
237
|
+
#
|
238
|
+
# @param project_id [Integer] Figshare id of the project
|
239
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
240
|
+
# @yield [Hash] See Figshare API Doc
|
241
|
+
def articles(project_id:, impersonate: nil, &block)
|
242
|
+
args = {}
|
243
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
244
|
+
get_paginate(api_query: "account/projects/#{project_id}/articles", args: args, &block)
|
245
|
+
end
|
246
|
+
|
247
|
+
# Create a new Article and associate it with this project
|
248
|
+
#
|
249
|
+
# @param project_id [Integer] Figshare id of the project
|
250
|
+
# @param article [Hash] See figshare API docs
|
251
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
252
|
+
# @yield [Hash] { location }
|
253
|
+
def article_create(project_id:, article:, impersonate: nil, &block)
|
254
|
+
args = {}
|
255
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
256
|
+
# Figshare Docs say this should be post_paginate, but that makes no sense. Will have to test
|
257
|
+
post_paginate(api_query: "account/projects/#{project_id}/articles", args: args, &block)
|
258
|
+
end
|
259
|
+
|
260
|
+
# delete an article from a project
|
261
|
+
#
|
262
|
+
# @param project_id [Integer] Figshare id of the project
|
263
|
+
# @param article_id [Integer] Figshare id of the article
|
264
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
265
|
+
def article_delete(project_id:, article_id:, impersonate: nil, &block)
|
266
|
+
args = {}
|
267
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
268
|
+
delete(api_query: "account/projects/#{project_id}/articles/#{article_id}", args: args, &block)
|
269
|
+
end
|
270
|
+
|
271
|
+
# Get the details of an artilcle in a project
|
272
|
+
#
|
273
|
+
# @param project_id [Integer] Figshare id of the project
|
274
|
+
# @param article_id [Integer] Figshare id of the article
|
275
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
276
|
+
# @yield [Hash] See Fishare API docs for article hash
|
277
|
+
def article_detail(project_id:, article_id:, impersonate: nil, &block)
|
278
|
+
args = {}
|
279
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
280
|
+
get(api_query: "account/projects/#{project_id}/articles/#{article_id}", args: args, &block)
|
281
|
+
end
|
282
|
+
|
283
|
+
# Get the files associated with an artilcle in a project
|
284
|
+
#
|
285
|
+
# @param project_id [Integer] Figshare id of the project
|
286
|
+
# @param article_id [Integer] Figshare id of the article
|
287
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
288
|
+
# @yield [Hash] See Fishare API docs for article hash
|
289
|
+
def artilce_files(project_id:, article_id:, impersonate: nil, &block)
|
290
|
+
args = {}
|
291
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
292
|
+
get(api_query: "account/projects/#{project_id}/articles/#{article_id}/files", args: args, &block)
|
293
|
+
end
|
294
|
+
|
295
|
+
# Get the files associated with an artilcle in a project
|
296
|
+
#
|
297
|
+
# @param project_id [Integer] Figshare id of the project
|
298
|
+
# @param article_id [Integer] Figshare id of the article
|
299
|
+
# @param file_id [Integer] Figshare id of the file
|
300
|
+
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
301
|
+
def artilce_file_detail(project_id:, article_id:, file_id:, impersonate: nil, &block)
|
302
|
+
args = {}
|
303
|
+
args["impersonate"] = impersonate if ! impersonate.nil?
|
304
|
+
delete(api_query: "account/projects/#{project_id}/articles/#{article_id}/files/#{file_id}", args: args, &block)
|
305
|
+
end
|
306
|
+
|
307
|
+
end # End of class
|
308
|
+
end # End of Module
|