figshare_api_v2 0.9.12 → 0.9.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +10 -0
- data/lib/figshare_api_v2.rb +1 -1
- data/lib/other.rb +2 -1
- data/lib/private_collections.rb +15 -2
- data/lib/public_articles.rb +1 -1
- 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: 11b25c0bb0934846555f86845975c0fd5f7c55db5313ec260324ec66ab77d476
|
4
|
+
data.tar.gz: 8391657d5ab14ba6220e842a23fbd844a9e04c97a4b0734008ba631f713d3a04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5e2b07cf5169b4ba5576ef9d26e64ef31f156d72509a4ef008cdaa2be59e8b1b2ff9b673416fdf9b340c3939847c8cc7991370174f5105ca8c031e3ea13bf66
|
7
|
+
data.tar.gz: 06a9dcbf5756ac282afb02d3eb6505a3fb9bb3710a5ee3678dd65034802b6fcc23a57e95ddcf8f4766ffeb01ef5f4b6d31f99cce357f68cbdfa8731ce4191e53
|
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
robertburrowes Wed Sep 28 16:01:03 2022 +1300
|
2
|
+
New version number, after several bug fixes
|
3
|
+
robertburrowes Wed Sep 28 15:59:22 2022 +1300
|
4
|
+
Need to add in blocks of 10 articles, or we get an exception.
|
5
|
+
robertburrowes Wed Sep 28 14:45:16 2022 +1300
|
6
|
+
missed block param
|
7
|
+
robertburrowes Wed Sep 28 14:42:14 2022 +1300
|
8
|
+
missed block param
|
9
|
+
robertburrowes Wed Sep 28 11:33:57 2022 +1300
|
10
|
+
added pagination to GET articles. This isn't documented in the API, but is needed when there are more than 10 results.
|
1
11
|
robertburrowes Tue Sep 27 15:40:52 2022 +1300
|
2
12
|
Files all g+r,o+r
|
3
13
|
robertburrowes Tue Sep 27 15:24:24 2022 +1300
|
data/lib/figshare_api_v2.rb
CHANGED
data/lib/other.rb
CHANGED
data/lib/private_collections.rb
CHANGED
@@ -369,7 +369,9 @@ module Figshare
|
|
369
369
|
def articles(collection_id:, impersonate: nil, &block)
|
370
370
|
args = {}
|
371
371
|
args['impersonate'] = impersonate unless impersonate.nil?
|
372
|
-
|
372
|
+
args['offset'] = 0
|
373
|
+
args['limit'] = 100 # Looks to respect this. The default is 10!
|
374
|
+
get_paginate(api_query: "account/collections/#{collection_id}/articles", args: args, &block)
|
373
375
|
end
|
374
376
|
|
375
377
|
# Get a private article's details (Not a figshare API call. Duplicates PrivateArticles:article_detail)
|
@@ -389,9 +391,20 @@ module Figshare
|
|
389
391
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
390
392
|
# @yield [Hash] { location }
|
391
393
|
def articles_add(collection_id:, articles:, impersonate: nil, &block)
|
394
|
+
# Adding articles that are already in the collection causes an error, so we remove the duplicates
|
395
|
+
existing_articles = []
|
396
|
+
self.articles(collection_id: collection_id, impersonate: impersonate) { |a| existing_articles << a['id'] }
|
397
|
+
insert_list = []
|
398
|
+
articles.each { |article| insert_list << article unless existing_articles.include?(article) }
|
399
|
+
|
392
400
|
args = {}
|
393
401
|
args['impersonate'] = impersonate unless impersonate.nil?
|
394
|
-
|
402
|
+
# There is a 10 article limit, for one add. No idea why
|
403
|
+
(0...insert_list.length).step(10) do |offset|
|
404
|
+
eor = offset + 10 # end of range
|
405
|
+
eor = articles.length if eor > articles.length # Truncate range, if beyond end of the array
|
406
|
+
post( api_query: "account/collections/#{collection_id}/articles", args: args, data: { articles: insert_list[offset...eor] }, &block)
|
407
|
+
end
|
395
408
|
end
|
396
409
|
|
397
410
|
# Get a private article's details (Not a figshare API call. Duplicates PrivateArticles:article_detail)
|
data/lib/public_articles.rb
CHANGED
@@ -130,7 +130,7 @@ module Figshare
|
|
130
130
|
#
|
131
131
|
# @param article_id [Integer] Figshare id of the article
|
132
132
|
# @yield [Hash] {id, title, doi, handle, url, published_date}
|
133
|
-
def files(article_id
|
133
|
+
def files(article_id:, &block)
|
134
134
|
get(api_query: "articles/#{article_id}/files", &block)
|
135
135
|
end
|
136
136
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: figshare_api_v2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Burrowes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: wikk_json
|