figshare_api_v2 0.9.10 → 0.9.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +16 -0
- data/lib/authors.rb +1 -1
- data/lib/figshare_api_v2.rb +1 -1
- data/lib/private_articles.rb +12 -2
- data/lib/private_collections.rb +85 -2
- data/lib/private_projects.rb +1 -1
- data/lib/public_articles.rb +2 -2
- data/lib/public_collections.rb +4 -4
- data/lib/public_projects.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dc7e3baa60bb192090e8237e1439c3ad7100450ce253707f61b13a1fae0f3cf
|
4
|
+
data.tar.gz: d1890373d6110f860a42ea2f21c2cd2a698df7bcc0aa9d9de60f813768745d09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c920fbae1eae2d5a84c072c2ff1e4eaa0e7b480314bc6333e2e3e5ebd34bdc5d8bc4b793284a8564ba410cdbe5d989324202e29857d93b85b673bceff4d51a8
|
7
|
+
data.tar.gz: 60ac5fdf5584a90966d8512701b61a2baace0d23f6889ee21213f6d6428d65f3120cf66589818b336693cc6a1f33f898c80af06e8b770c37d47cedf5d3148a35
|
data/History.txt
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
robertburrowes Tue Sep 27 15:24:24 2022 +1300
|
2
|
+
Added in collection handling. Shifted author processing to figshare library
|
3
|
+
robertburrowes Tue Sep 27 14:39:31 2022 +1300
|
4
|
+
Authors shoud be an array of Hash records.
|
5
|
+
robertburrowes Tue Sep 27 14:39:06 2022 +1300
|
6
|
+
Added body() for creating the body Hash needed for creating a new Collection
|
7
|
+
robertburrowes Tue Sep 27 14:38:25 2022 +1300
|
8
|
+
typo in name
|
9
|
+
robertburrowes Tue Sep 27 12:11:20 2022 +1300
|
10
|
+
Bumped version for 'institute' needing to be an Integer in json
|
11
|
+
robertburrowes Tue Sep 27 12:09:20 2022 +1300
|
12
|
+
institute has to be an Integer. A string now generates an exception
|
13
|
+
robertburrowes Tue Sep 27 09:04:43 2022 +1300
|
14
|
+
Debugging bulk user info request. Still getting inconsistent numbers of users being returned.
|
15
|
+
robertburrowes Tue Sep 27 09:03:55 2022 +1300
|
16
|
+
Testing what comes back
|
1
17
|
robertburrowes Fri May 13 08:40:05 2022 +1200
|
2
18
|
Bumped minor version
|
3
19
|
robertburrowes Thu May 12 17:25:07 2022 +1200
|
data/lib/authors.rb
CHANGED
@@ -31,7 +31,7 @@ module Figshare
|
|
31
31
|
&block
|
32
32
|
)
|
33
33
|
args = { 'search_for' => search_for }
|
34
|
-
args['institution'] = @institute_id
|
34
|
+
args['institution'] = @institute_id.to_i if institute
|
35
35
|
args['group_id'] = group_id unless group_id.nil?
|
36
36
|
args['is_active'] = is_active unless is_active.nil?
|
37
37
|
args['is_public'] = is_public unless is_public.nil?
|
data/lib/figshare_api_v2.rb
CHANGED
data/lib/private_articles.rb
CHANGED
@@ -67,7 +67,7 @@ module Figshare
|
|
67
67
|
)
|
68
68
|
args = { 'search_for' => search_for }
|
69
69
|
args['impersonate'] = impersonate unless impersonate.nil?
|
70
|
-
args['institution'] = @institute_id
|
70
|
+
args['institution'] = @institute_id.to_i if institute # Inconsistent use. Other calls use institute_id
|
71
71
|
args['group'] = group_id unless group_id.nil? # Not sure if this changed from group_id to group
|
72
72
|
args['item_type'] = item_type unless item_type.nil?
|
73
73
|
args['resource_id'] = resource_id unless resource_id.nil?
|
@@ -138,7 +138,17 @@ module Figshare
|
|
138
138
|
body_['references'] = references unless references.nil?
|
139
139
|
body_['categories'] = categories unless categories.nil?
|
140
140
|
body_['categories_by_source_id'] = categories_by_source_id unless categories_by_source_id.nil?
|
141
|
-
|
141
|
+
authors_array = []
|
142
|
+
if authors.instance_of?(Array)
|
143
|
+
authors.each do |author|
|
144
|
+
authors_array << if author.instance_of?(Hash)
|
145
|
+
author
|
146
|
+
else
|
147
|
+
{ 'name' => author }
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
body_['authors'] = authors_array
|
142
152
|
body_['custom_fields'] = custom_fields unless custom_fields.nil?
|
143
153
|
body_['custom_fields_list'] = custom_fields_list unless custom_fields_list.nil?
|
144
154
|
body_['defined_type'] = defined_type unless defined_type.nil?
|
data/lib/private_collections.rb
CHANGED
@@ -70,7 +70,7 @@ module Figshare
|
|
70
70
|
)
|
71
71
|
args = { 'search_for' => search_for }
|
72
72
|
args['impersonate'] = impersonate unless impersonate.nil?
|
73
|
-
args['institution'] = @institute_id
|
73
|
+
args['institution'] = @institute_id.to_i if institute
|
74
74
|
args['group'] = group_id unless group_id.nil?
|
75
75
|
args['resource_id'] = resource_id unless resource_id.nil?
|
76
76
|
args['resource_doi'] = resource_doi unless resource_doi.nil?
|
@@ -87,6 +87,89 @@ module Figshare
|
|
87
87
|
post_paginate(api_query: 'account/collections/search', args: args, &block)
|
88
88
|
end
|
89
89
|
|
90
|
+
# Create a body for use with create and update methods
|
91
|
+
#
|
92
|
+
# @param title [String] Required
|
93
|
+
# @param description [String] The article description. In a publisher case, usually this is the remote article description
|
94
|
+
# @param tags [Array] List of tags (strings) to be associated with the article. Tags can be used instead
|
95
|
+
# @param keywords [Array] List of tags (strings) to be associated with the article. Tags can be used instead
|
96
|
+
# @param references [Array] List of links to be associated with the article (e.g ["http://link1", "http://link2", "http://link3"])
|
97
|
+
# @param categories [Array] List of category ids to be associated with the article(e.g [1, 23, 33, 66])
|
98
|
+
# @param categories_by_source_id [Array] List of category ids to be associated with the article(e.g ["300204", "400207"])
|
99
|
+
# @param authors [Array] List of authors to be associated with the article. The list can contain the following fields: id, name, first_name, last_name, email, orcid_id. If an id is supplied, it will take priority and everything else will be ignored. No more than 10 authors. For adding more authors use the specific authors endpoint. e.g. { "name" => "Joe X"} and or { "id" => 123 }
|
100
|
+
# @param custom_fields [Hash] List of key, values pairs to be associated with the article. eg. { "key" => "value"}
|
101
|
+
# @param custom_fields_list [Array] List of key, values pairs to be associated with the article. eg. [{ "key" => "value"}]
|
102
|
+
# @param defined_type [String] one of "figshare","media","dataset","poster","journal contribution", "presentation", "thesis", "software", "online resource", "preprint", "book", "conference contribution", "chapter", "peer review", "educational resource", "report", "standard", "composition", "funding", "physical object", "data management plan", "workflow", "monograph", "performance", "event", "service", "model", "registration"
|
103
|
+
# @param funding [String] Grant number or funding authority
|
104
|
+
# @param funding_list [Array] Funding creation / update items. eg {"id" => 0, "title" => "string"}
|
105
|
+
# @param license [Integer] License id for this article.
|
106
|
+
# @param doi [String] Not applicable for regular users. In an institutional case, make sure your group supports setting DOIs. This setting is applied by figshare via opening a ticket through our support/helpdesk system.
|
107
|
+
# @param handle [String] Not applicable for regular users. In an institutional case, make sure your group supports setting Handles. This setting is applied by figshare via opening a ticket through our support/helpdesk system.
|
108
|
+
# @param resource_doi [String] Not applicable to regular users. In a publisher case, this is the publisher article DOI.
|
109
|
+
# @param resource_title [String] Not applicable to regular users. In a publisher case, this is the publisher article title.
|
110
|
+
# @param timeline [Hash] Various timeline dates ie. { "firstOnline" => "date_string", "publisherPublication" => "date_string", "publisherAcceptance" => "date_string"},
|
111
|
+
# @param group_id [Integer] Not applicable to regular users. This field is reserved to institutions/publishers with access to assign to specific groups
|
112
|
+
def body( title:,
|
113
|
+
description: nil,
|
114
|
+
is_metadata_record: nil,
|
115
|
+
metadata_reason: nil,
|
116
|
+
tags: nil,
|
117
|
+
keywords: nil,
|
118
|
+
references: nil,
|
119
|
+
categories: nil,
|
120
|
+
categories_by_source_id: nil,
|
121
|
+
authors: nil,
|
122
|
+
custom_fields: nil,
|
123
|
+
custom_fields_list: nil,
|
124
|
+
defined_type: nil,
|
125
|
+
funding: nil,
|
126
|
+
funding_list: nil,
|
127
|
+
license: nil,
|
128
|
+
doi: nil,
|
129
|
+
handle: nil,
|
130
|
+
resource_doi: nil,
|
131
|
+
resource_title: nil,
|
132
|
+
timeline: nil,
|
133
|
+
group_id: nil
|
134
|
+
)
|
135
|
+
body_ = {
|
136
|
+
'title' => title
|
137
|
+
}
|
138
|
+
body_['description'] = description unless description.nil?
|
139
|
+
body_['is_metadata_record'] = is_metadata_record unless is_metadata_record.nil?
|
140
|
+
body_['metadata_reason'] = metadata_reason unless metadata_reason.nil?
|
141
|
+
body_['tags'] = tags unless tags.nil?
|
142
|
+
body_['keywords'] = keywords unless keywords.nil?
|
143
|
+
body_['references'] = references unless references.nil?
|
144
|
+
body_['categories'] = categories unless categories.nil?
|
145
|
+
body_['categories_by_source_id'] = categories_by_source_id unless categories_by_source_id.nil?
|
146
|
+
authors_array = []
|
147
|
+
if authors.instance_of?(Array)
|
148
|
+
authors.each do |author|
|
149
|
+
authors_array << if author.instance_of?(Hash)
|
150
|
+
author
|
151
|
+
else
|
152
|
+
{ 'name' => author }
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
body_['authors'] = authors_array
|
157
|
+
body_['custom_fields'] = custom_fields unless custom_fields.nil?
|
158
|
+
body_['custom_fields_list'] = custom_fields_list unless custom_fields_list.nil?
|
159
|
+
body_['defined_type'] = defined_type unless defined_type.nil?
|
160
|
+
body_['funding'] = funding unless funding.nil?
|
161
|
+
body_['funding_list'] = funding_list unless funding_list.nil?
|
162
|
+
body_['license'] = license unless license.nil?
|
163
|
+
body_['doi'] = doi unless doi.nil?
|
164
|
+
body_['handle'] = handle unless handle.nil?
|
165
|
+
body_['resource_doi'] = resource_doi unless resource_doi.nil?
|
166
|
+
body_['resource_title'] = resource_title unless resource_title.nil?
|
167
|
+
body_['timeline'] = timeline unless timeline.nil?
|
168
|
+
body_['group_id'] = group_id unless group_id.nil?
|
169
|
+
|
170
|
+
return body_
|
171
|
+
end
|
172
|
+
|
90
173
|
# Create a new private Collection by sending collection information
|
91
174
|
#
|
92
175
|
# @param body [Hash] See Figshare API docs
|
@@ -133,7 +216,7 @@ module Figshare
|
|
133
216
|
#
|
134
217
|
# @param collection_id [Integer] Figshare id of the collection
|
135
218
|
# @param impersonate [Integer] Figshare account_id of the user we are making this call on behalf of
|
136
|
-
# @yield [Hash] { doi }
|
219
|
+
# @yield [Hash] { "doi" => "the_doi" }
|
137
220
|
def reserve_doi(collection_id:, impersonate: nil, &block)
|
138
221
|
args = {}
|
139
222
|
args['impersonate'] = impersonate unless impersonate.nil?
|
data/lib/private_projects.rb
CHANGED
@@ -63,7 +63,7 @@ module Figshare
|
|
63
63
|
&block
|
64
64
|
)
|
65
65
|
args = { 'search_for' => search_for }
|
66
|
-
args['institution'] = @institute_id
|
66
|
+
args['institution'] = @institute_id.to_i if institute
|
67
67
|
args['group'] = group_id unless group_id.nil?
|
68
68
|
args['impersonate'] = impersonate unless impersonate.nil?
|
69
69
|
args['published_since'] = published_since unless published_since.nil?
|
data/lib/public_articles.rb
CHANGED
@@ -36,7 +36,7 @@ module Figshare
|
|
36
36
|
&block
|
37
37
|
)
|
38
38
|
args = {}
|
39
|
-
args['institution'] = @institute_id
|
39
|
+
args['institution'] = @institute_id.to_i if institute
|
40
40
|
args['group_id'] = group_id unless group_id.nil? # Not sure if this should be 'group' or 'group_id'. API has conflicting info
|
41
41
|
args['item_type'] = item_type unless item_type.nil?
|
42
42
|
args['resource_doi'] = resource_doi unless resource_doi.nil?
|
@@ -80,7 +80,7 @@ module Figshare
|
|
80
80
|
&block
|
81
81
|
)
|
82
82
|
args = { 'search_for' => search_for }
|
83
|
-
args['institution'] = @institute_id
|
83
|
+
args['institution'] = @institute_id.to_i if institute
|
84
84
|
args['group_id'] = group_id unless group_id.nil?
|
85
85
|
args['item_type'] = item_type unless item_type.nil?
|
86
86
|
args['resource_doi'] = resource_doi unless resource_doi.nil?
|
data/lib/public_collections.rb
CHANGED
@@ -4,7 +4,7 @@ module Figshare
|
|
4
4
|
class PublicCollections < Base
|
5
5
|
# Requests a list of public collections
|
6
6
|
#
|
7
|
-
# @param
|
7
|
+
# @param institute [Boolean] Just our institution
|
8
8
|
# @param group_id [Integer] Only return this group's collections
|
9
9
|
# @param published_since [Time] Return results if published after this time
|
10
10
|
# @param modified_since [Time] Return results if modified after this time
|
@@ -18,7 +18,7 @@ module Figshare
|
|
18
18
|
# @param offset [Numeric] offset is 0 based. Offset and Limit go together
|
19
19
|
# @param limit [Numeric]
|
20
20
|
# @yield [Hash] {id, title, doi, handle, url, published_date}
|
21
|
-
def list(
|
21
|
+
def list( institute: false,
|
22
22
|
group_id: nil,
|
23
23
|
published_since: nil,
|
24
24
|
modified_since: nil,
|
@@ -34,7 +34,7 @@ module Figshare
|
|
34
34
|
&block
|
35
35
|
)
|
36
36
|
args = {}
|
37
|
-
args['institution'] = @institute_id
|
37
|
+
args['institution'] = @institute_id.to_i if institute
|
38
38
|
args['group'] = group_id unless group_id.nil?
|
39
39
|
args['resource_doi'] = resource_doi unless resource_doi.nil?
|
40
40
|
args['doi'] = doi unless doi.nil?
|
@@ -76,7 +76,7 @@ module Figshare
|
|
76
76
|
&block
|
77
77
|
)
|
78
78
|
args = { 'search_for' => search_for }
|
79
|
-
args['institution'] = @institute_id
|
79
|
+
args['institution'] = @institute_id.to_i if institute
|
80
80
|
args['group_id'] = group_id unless group_id.nil?
|
81
81
|
args['item_type'] = item_type unless item_type.nil?
|
82
82
|
args['resource_doi'] = resource_doi unless resource_doi.nil?
|
data/lib/public_projects.rb
CHANGED
@@ -26,7 +26,7 @@ module Figshare
|
|
26
26
|
&block
|
27
27
|
)
|
28
28
|
args = {}
|
29
|
-
args['institution'] = @institute_id
|
29
|
+
args['institution'] = @institute_id.to_i if institute
|
30
30
|
args['group'] = group_id unless group_id.nil?
|
31
31
|
args['published_since'] = published_since unless published_since.nil?
|
32
32
|
args['order'] = order unless order.nil?
|
@@ -57,7 +57,7 @@ module Figshare
|
|
57
57
|
&block
|
58
58
|
)
|
59
59
|
args = { 'search_for' => search_for }
|
60
|
-
args['institution'] = @institute_id
|
60
|
+
args['institution'] = @institute_id.to_i if institute
|
61
61
|
args['group'] = group_id unless group_id.nil?
|
62
62
|
args['published_since'] = published_since unless published_since.nil?
|
63
63
|
args['modified_since'] = modified_since unless modified_since.nil?
|
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.11
|
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-
|
11
|
+
date: 2022-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: wikk_json
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.25'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
82
|
+
version: '3.25'
|
83
83
|
description: |-
|
84
84
|
Figshare version 2 API.
|
85
85
|
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
139
|
+
rubygems_version: 3.3.7
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Figshare version 2 API
|