figshare_api_v2 0.9.12 → 0.9.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdacc011cb5878841de9954d291c86f59aaf164910ec3435a83e60358711e36f
4
- data.tar.gz: 18c20792bb04c21295fb32bfd71d512c6f3a5b35388980bbfd777cbb6b6e8995
3
+ metadata.gz: 11b25c0bb0934846555f86845975c0fd5f7c55db5313ec260324ec66ab77d476
4
+ data.tar.gz: 8391657d5ab14ba6220e842a23fbd844a9e04c97a4b0734008ba631f713d3a04
5
5
  SHA512:
6
- metadata.gz: 37a5583b512ca3379a78b826ef527f7e77822420c3d37a2eaa643b0674c029fa5305e4f347ef095e29757fb2d2e6294c52cf6c53fb4f2fe017420715d8e5508b
7
- data.tar.gz: 17080406e6798cd8c746017bbb13fd3c96d93aae932ae293ae847d6e23a92a8d646da1495fa945b51924dad2c2346c04f95cceabdcaf2ac95d3ea16799f853bb
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
@@ -1,7 +1,7 @@
1
1
  module Figshare # :nodoc:
2
2
  # Figshare module initialization
3
3
  #
4
- VERSION = '0.9.12'
4
+ VERSION = '0.9.13'
5
5
 
6
6
  require 'wikk_webbrowser'
7
7
  require 'wikk_json'
data/lib/other.rb CHANGED
@@ -30,7 +30,8 @@ module Figshare
30
30
  # Get public categories
31
31
  #
32
32
  # @yield [Array] [{parent_id:, id:, title:, path:, source_id:, taxonomy_id:}]
33
- def public_categories
33
+ def public_categories(&block)
34
+ args = {}
34
35
  get(api_query: 'categories', &block)
35
36
  end
36
37
 
@@ -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
- get(api_query: "account/collections/#{collection_id}/articles", args: args, &block)
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
- post( api_query: "account/collections/#{collection_id}/articles", args: args, data: { articles: articles }, &block)
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)
@@ -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.12
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-27 00:00:00.000000000 Z
11
+ date: 2022-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wikk_json