figshare_api_v2 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +44 -0
- data/README.md +3 -2
- data/lib/authors.rb +16 -4
- data/lib/base.rb +58 -6
- data/lib/figshare_api_v2.rb +1 -1
- data/lib/institutions.rb +152 -28
- data/lib/other.rb +12 -4
- data/lib/private_articles.rb +140 -23
- data/lib/private_collections.rb +80 -18
- data/lib/private_projects.rb +109 -33
- data/lib/public_articles.rb +15 -3
- data/lib/public_collections.rb +29 -2
- data/lib/public_projects.rb +19 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a59303e131674b6b915f07bf0e0aa317a3d5d594c8e87586fe273d8ed83697d
|
4
|
+
data.tar.gz: b8bdb004509e69e295b110f60f98ac6da83ea2ea3c5d2bf72e9d46ec041d274a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebdcee71baa8b80d0c434c9c041255a8843c897574c00725c60c288670854c0d3bce3e404805f03201951b981148ea8bfc49acf465b686af75cabd2bd47655f9
|
7
|
+
data.tar.gz: 5cdd11942289e5cb75e4e09afd730ebd12209b161fc68221aa5dadc347a90fc04370d9af464c419b69ed7cb794097254d796cd318ffc9957402cd3736728328b
|
data/History.txt
CHANGED
@@ -1,3 +1,47 @@
|
|
1
|
+
robertburrowes Tue May 10 10:42:27 2022 +1200
|
2
|
+
Comment
|
3
|
+
robertburrowes Tue May 10 10:40:02 2022 +1200
|
4
|
+
Left out the pagination args
|
5
|
+
robertburrowes Tue May 10 10:27:57 2022 +1200
|
6
|
+
API changes
|
7
|
+
robertburrowes Tue May 10 10:21:39 2022 +1200
|
8
|
+
API changes
|
9
|
+
robertburrowes Tue May 10 10:11:50 2022 +1200
|
10
|
+
API changes Added missed &block
|
11
|
+
robertburrowes Tue May 10 09:27:50 2022 +1200
|
12
|
+
Api changes
|
13
|
+
robertburrowes Tue May 10 09:27:27 2022 +1200
|
14
|
+
Missed adding _paginate
|
15
|
+
robertburrowes Tue May 10 09:26:58 2022 +1200
|
16
|
+
Use offset for paginatioon, if only the offset is passed in.
|
17
|
+
robertburrowes Mon May 9 17:06:07 2022 +1200
|
18
|
+
Add an HTML PATCH wrapper
|
19
|
+
robertburrowes Mon May 9 16:57:06 2022 +1200
|
20
|
+
Readme update
|
21
|
+
robertburrowes Mon May 9 16:54:56 2022 +1200
|
22
|
+
Bump version for new Figshare APIs.
|
23
|
+
robertburrowes Mon May 9 16:53:27 2022 +1200
|
24
|
+
API changes Fixed URL collection article
|
25
|
+
robertburrowes Mon May 9 16:52:47 2022 +1200
|
26
|
+
fixed param type
|
27
|
+
robertburrowes Mon May 9 16:17:56 2022 +1200
|
28
|
+
API changes
|
29
|
+
robertburrowes Mon May 9 14:55:40 2022 +1200
|
30
|
+
Ignore test script
|
31
|
+
robertburrowes Mon May 9 14:54:41 2022 +1200
|
32
|
+
+x
|
33
|
+
robertburrowes Mon May 9 14:54:11 2022 +1200
|
34
|
+
Include tags pushing to github
|
35
|
+
robertburrowes Mon May 9 14:52:11 2022 +1200
|
36
|
+
API updates
|
37
|
+
robertburrowes Mon May 9 14:39:15 2022 +1200
|
38
|
+
API additions/response changes. Added page/page_size Fixed some string quotes Fixed URL mistypings
|
39
|
+
robertburrowes Mon May 9 12:36:08 2022 +1200
|
40
|
+
Added setting pagination params from the args
|
41
|
+
robertburrowes Mon May 9 11:46:21 2022 +1200
|
42
|
+
Search has pagination
|
43
|
+
robertburrowes Thu Dec 23 12:20:05 2021 +1300
|
44
|
+
Fixed Institutions::hr_upload
|
1
45
|
robertburrowes Tue Nov 2 14:49:47 2021 +1300
|
2
46
|
hr upload is post, not put
|
3
47
|
robertburrowes Tue Nov 2 13:12:30 2021 +1300
|
data/README.md
CHANGED
@@ -7,7 +7,9 @@
|
|
7
7
|
|
8
8
|
## DESCRIPTION:
|
9
9
|
|
10
|
-
Figshare version 2 API.
|
10
|
+
Figshare version 2 API.
|
11
|
+
|
12
|
+
Actually the second version of the version 2 APIs. Lots of changes have been made by Figshare, mostly expanding what is returned from the API calls, but they also added some fields. Looks mostly backwards compatible.
|
11
13
|
|
12
14
|
## FEATURES/PROBLEMS:
|
13
15
|
|
@@ -71,4 +73,3 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
71
73
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
72
74
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
73
75
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
74
|
-
|
data/lib/authors.rb
CHANGED
@@ -4,13 +4,17 @@ module Figshare
|
|
4
4
|
class Authors < Base
|
5
5
|
# Search authors
|
6
6
|
#
|
7
|
-
# @param institution [Boolean] Just our institution
|
8
|
-
# @param group_id [Integer] Only return this group's collections
|
7
|
+
# @param institution [Boolean] Just our institution. We have already stored the institute_id.
|
9
8
|
# @param orcid [String] Matches this orcid
|
9
|
+
# @param group_id [Integer] Only return this group's collections
|
10
10
|
# @param is_active [Boolean]
|
11
11
|
# @param is_public [Boolean]
|
12
12
|
# @param order [String] "published_date" Default, "modified_date", "views", "cites", "shares"
|
13
13
|
# @param order_direction [String] "desc" Default, "asc"
|
14
|
+
# @param page [Numeric] Pages start at 1. Page and Page size go together
|
15
|
+
# @param page_size [Numeric]
|
16
|
+
# @param offset [Numeric] offset is 0 based. Offset and Limit go together
|
17
|
+
# @param limit [Numeric]
|
14
18
|
# @yield [Hash] {id, first_name, last_name, full_name, url_name, is_active, is_public, orcid_id, institution_id, group_id, job_title}
|
15
19
|
def search( search_for:,
|
16
20
|
institute: false,
|
@@ -20,6 +24,10 @@ module Figshare
|
|
20
24
|
is_public: true,
|
21
25
|
order: 'published_date',
|
22
26
|
order_direction: 'desc',
|
27
|
+
page: nil,
|
28
|
+
page_size: nil,
|
29
|
+
offset: nil,
|
30
|
+
limit: nil,
|
23
31
|
&block
|
24
32
|
)
|
25
33
|
args = { 'search_for' => search_for }
|
@@ -30,7 +38,11 @@ module Figshare
|
|
30
38
|
args['orcid'] = orcid unless orcid.nil?
|
31
39
|
args['order'] = order unless order.nil?
|
32
40
|
args['order_direction'] = order_direction unless order_direction.nil?
|
33
|
-
|
41
|
+
args['page'] = page unless page.nil?
|
42
|
+
args['page_size'] = page_size unless page_size.nil?
|
43
|
+
args['offset'] = offset unless offset.nil?
|
44
|
+
args['limit'] = limit unless limit.nil?
|
45
|
+
post_paginate(api_query: 'account/authors/search', args: args, &block)
|
34
46
|
end
|
35
47
|
|
36
48
|
# Get an authors details
|
@@ -38,7 +50,7 @@ module Figshare
|
|
38
50
|
# @param author_id [Integer] Figshare Author ID
|
39
51
|
# @yield [Hash] {id, first_name, last_name, full_name, url_name, is_active, is_public, orcid_id, institution_id, group_id, job_title}
|
40
52
|
def detail(author_id:, &block)
|
41
|
-
get(api_query: "account/authors/#{author_id}",
|
53
|
+
get(api_query: "account/authors/#{author_id}", &block)
|
42
54
|
end
|
43
55
|
end
|
44
56
|
end
|
data/lib/base.rb
CHANGED
@@ -77,10 +77,19 @@ module Figshare
|
|
77
77
|
raise 'get_paginate(): Expecting args to be a Hash'
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
page = 1
|
82
|
-
|
80
|
+
# Loop variables, if we are using pages
|
81
|
+
page = args['page'].nil? ? 1 : args['page']
|
82
|
+
page_size = args['page_size'].nil? ? 100 : args['page_size']
|
83
|
+
|
84
|
+
# Loop variables, if we are using offsets
|
85
|
+
offset = args['offset'].nil? ? 0 : args['offset']
|
86
|
+
limit = args['limit'].nil? ? 100 : args['limit']
|
87
|
+
|
88
|
+
by_offset = true if args['page'].nil? && ! args['offset'].nil?
|
89
|
+
|
90
|
+
# How many results so far.
|
83
91
|
result_count = 0
|
92
|
+
|
84
93
|
loop do
|
85
94
|
content_type = response = nil
|
86
95
|
form_args = by_offset ? { 'limit' => limit, 'offset' => offset } : { 'page_size' => page_size, 'page' => page }
|
@@ -148,11 +157,19 @@ module Figshare
|
|
148
157
|
# @yield [String] if given a block, iterates through the result from figshare
|
149
158
|
# @return [Integer] number of results.
|
150
159
|
private def post_paginate(api_query:, args: {}, debug: false, by_offset: false, &block)
|
151
|
-
|
152
|
-
|
153
|
-
|
160
|
+
# Loop variables, if we are using pages
|
161
|
+
page = args['page'].nil? ? 1 : args['page']
|
162
|
+
page_size = args['page_size'].nil? ? 100 : args['page_size']
|
163
|
+
|
164
|
+
# Loop variables, if we are using offsets
|
165
|
+
offset = args['offset'].nil? ? 0 : args['offset']
|
166
|
+
limit = args['limit'].nil? ? 100 : args['limit']
|
167
|
+
|
168
|
+
# How many results so far.
|
154
169
|
result_count = 0
|
155
170
|
|
171
|
+
by_offset = true if args['page'].nil? && ! args['offset'].nil?
|
172
|
+
|
156
173
|
args = {} if args.nil?
|
157
174
|
if ! args.is_a?(Hash)
|
158
175
|
raise 'post_paginate(): Expecting args to be a Hash'
|
@@ -214,6 +231,41 @@ module Figshare
|
|
214
231
|
return iterate_json_response(response: response, content_type: content_type, debug: debug, &block)
|
215
232
|
end
|
216
233
|
|
234
|
+
# Patch iterates through the API response, yielding each value to the passed block
|
235
|
+
# When Figshare API usually has no paging option.
|
236
|
+
# If there is no block, then the results are printed (useful for debugging)
|
237
|
+
#
|
238
|
+
# @param api_query [String] base figshare api call, to which we add parameters defined in args
|
239
|
+
# @param args [Hash] Key, value pairs which get converted to ?key=arg&key=arg...
|
240
|
+
# @param debug [Boolean] print result to stdout
|
241
|
+
# @param content_type [String] Assuming Json, but might need binary ('application/octet-stream')
|
242
|
+
# @yield [String] if given a block, iterates through the result from figshare
|
243
|
+
# @return [Integer] number of results
|
244
|
+
private def patch(api_query:, args: {}, data: nil, debug: false, content_type: 'application/json; charset=UTF-8', &block)
|
245
|
+
body = nil
|
246
|
+
body = if data.is_a?(Hash)
|
247
|
+
# Convert hash to json, and merge in additional args
|
248
|
+
data.merge(args).to_j
|
249
|
+
elsif data.nil? && ! args.empty?
|
250
|
+
# No data, but args, so just use the args
|
251
|
+
args.to_j
|
252
|
+
else
|
253
|
+
# Data isn't a Hash, so just pass it through (might be nil)
|
254
|
+
data
|
255
|
+
end
|
256
|
+
|
257
|
+
response = nil
|
258
|
+
WIKK::WebBrowser.https_session( host: @hostname, verify_cert: false ) do |ws|
|
259
|
+
response = ws.patch_req( query: "#{@api_url}#{api_query}",
|
260
|
+
content_type: content_type,
|
261
|
+
authorization: "token #{@auth_token}",
|
262
|
+
data: body
|
263
|
+
)
|
264
|
+
content_type = ws.header_value(key: 'Content-Type')
|
265
|
+
end
|
266
|
+
return iterate_json_response(response: response, content_type: content_type, debug: debug, &block)
|
267
|
+
end
|
268
|
+
|
217
269
|
# delete sends an HTML DELETE request.
|
218
270
|
# We don't expect to get a response to this call.
|
219
271
|
#
|
data/lib/figshare_api_v2.rb
CHANGED
data/lib/institutions.rb
CHANGED
@@ -4,10 +4,14 @@ module Figshare
|
|
4
4
|
class Institutions < Base
|
5
5
|
# Upload hr file
|
6
6
|
#
|
7
|
-
# @param
|
7
|
+
# @param hr_xml_filename [String] Filename. See https://docs.figshare.com/#hr_feed_hr_feed_private_endpoint
|
8
8
|
# @yield [Hash] { message:, data: null, errcode:}
|
9
|
-
def hr_upload(
|
10
|
-
|
9
|
+
def hr_upload(hr_xml_filename:, &block)
|
10
|
+
File.open(@file_name, 'rb') do |fin|
|
11
|
+
hr_xml = fin.read
|
12
|
+
args = { 'name' => 'hrfeed', 'filename' => hr_xml_filename }
|
13
|
+
post(api_query: 'institution/hrfeed/upload', args: args, data: hr_xml, content_type: 'multipart/form-data', &block)
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
# Get the institional account details
|
@@ -17,6 +21,13 @@ module Figshare
|
|
17
21
|
get(api_query: 'account/institution', &block)
|
18
22
|
end
|
19
23
|
|
24
|
+
# Get the institional account embargo options (IP Ranges)
|
25
|
+
#
|
26
|
+
# @yield [Array] list of embargo ip ranges [ {id:, type: ip_range, ip_name: Figshare_IP_Range} ]
|
27
|
+
def account_embargo_options(&block)
|
28
|
+
get(api_query: 'account/institution/embargo_options', &block)
|
29
|
+
end
|
30
|
+
|
20
31
|
# Requests a list of private institute articles
|
21
32
|
#
|
22
33
|
# @param status [Integer] Only return items with this status
|
@@ -26,6 +37,10 @@ module Figshare
|
|
26
37
|
# @param item_type [String] Matches this item_type. See Figshare API docs for list (https://docs.figshare.com/#articles_list)
|
27
38
|
# @param order [String] "published_date" Default, "modified_date", "views", "cites", "shares"
|
28
39
|
# @param order_direction [String] "desc" Default, "asc"
|
40
|
+
# @param page [Numeric] Pages start at 1. Page and Page size go together
|
41
|
+
# @param page_size [Numeric]
|
42
|
+
# @param offset [Numeric] offset is 0 based. Offset and Limit go together
|
43
|
+
# @param limit [Numeric]
|
29
44
|
# @yield [Hash] {id, title, doi, handle, group_id, url, url_public_html, url_public_api, url_private_htm,
|
30
45
|
# url_private_api, published_date, timeline {...}, thumb, defined_type, defined_name }
|
31
46
|
def private_articles( status: nil,
|
@@ -35,6 +50,10 @@ module Figshare
|
|
35
50
|
resource_doi: nil,
|
36
51
|
order: 'published_date',
|
37
52
|
order_direction: 'desc',
|
53
|
+
page: nil,
|
54
|
+
page_size: nil,
|
55
|
+
offset: nil,
|
56
|
+
limit: nil,
|
38
57
|
&block
|
39
58
|
)
|
40
59
|
args = {}
|
@@ -45,6 +64,10 @@ module Figshare
|
|
45
64
|
args['modified_since'] = modified_since unless modified_since.nil?
|
46
65
|
args['order'] = order unless order.nil?
|
47
66
|
args['order_direction'] = order_direction unless order_direction.nil?
|
67
|
+
args['page'] = page unless page.nil?
|
68
|
+
args['page_size'] = page_size unless page_size.nil?
|
69
|
+
args['offset'] = offset unless offset.nil?
|
70
|
+
args['limit'] = limit unless limit.nil?
|
48
71
|
get_paginate(api_query: 'account/institution/articles', args: args, &block)
|
49
72
|
end
|
50
73
|
|
@@ -58,26 +81,57 @@ module Figshare
|
|
58
81
|
args = {}
|
59
82
|
args['resource_id'] = resource_id unless resource_id.nil?
|
60
83
|
args['filename'] = filename unless filename.nil?
|
61
|
-
get(api_query:
|
84
|
+
get(api_query: "institutions/#{@institute_id}/articles/filter-by", args: args, &block)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Get an institute group's custom fields
|
88
|
+
#
|
89
|
+
# @param group_id [Integer] Figshare group_id
|
90
|
+
# @yield [Array] [ {id:, name: field_name, field_type: text } ]
|
91
|
+
def group_custom_fields(group_id: nil, &block )
|
92
|
+
args = {}
|
93
|
+
args['group_id'] = group_id unless group_id.nil?
|
94
|
+
get(api_query: 'account/institution/custom_fields', args: args, &block)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Set institute group's custom fields, from a CSV file
|
98
|
+
#
|
99
|
+
# @param custom_field_id [Integer] Figshare group_id
|
100
|
+
# @param filename [Integer] Figshare group_id
|
101
|
+
# @yield [Hash] {code: 200, message: ok } ]
|
102
|
+
def group_set_custom_fields(custom_field_id:, filename: )
|
103
|
+
File.open(filename, 'rb') do |fin|
|
104
|
+
custom_fields_csv = fin.read
|
105
|
+
args = { 'name' => 'external_file', 'filename' => filename }
|
106
|
+
post(api_query: "account/institution/custom_fields/#{custom_field_id}/items/upload", args: args, data: custom_fields_csv, content_type: 'multipart/form-data', &block)
|
107
|
+
end
|
62
108
|
end
|
63
109
|
|
64
110
|
# Get institution categories (including parent Categories)
|
65
111
|
#
|
66
|
-
# @yield [
|
112
|
+
# @yield [Array] [ { parent_id: 1, id: 11, title: "Anatomy", path:"/450/1024/6532", source_id: "300204", taxonomy_id: 4 } ]
|
67
113
|
def categories(&block)
|
68
114
|
get(api_query: 'account/categories', &block)
|
69
115
|
end
|
70
116
|
|
71
117
|
# Get the groups for which the account has administrative privileges (assigned and inherited).
|
72
118
|
#
|
73
|
-
# @yield [
|
119
|
+
# @yield [Array] [ { id: 1, name: "Materials", resource_id: "string", parent_id: 0, association_criteria: "IT" } ]
|
74
120
|
def groups(&block)
|
75
121
|
get(api_query: 'account/groups', &block)
|
76
122
|
end
|
77
123
|
|
124
|
+
# Get the institional account group's embargo options (IP Ranges)
|
125
|
+
#
|
126
|
+
# @param group_id [Integer]
|
127
|
+
# @yield [Array] list of embargo ip ranges [ {id:, type: ip_range, ip_name: Figshare_IP_Range} ]
|
128
|
+
def group_embargo_options(group_id:, &block)
|
129
|
+
get(api_query: "account/institution/groups/#{group_id}/embargo_options", &block)
|
130
|
+
end
|
131
|
+
|
78
132
|
# Get the roles available for groups and the institution group.
|
79
133
|
#
|
80
|
-
# @yield [
|
134
|
+
# @yield [Array] [ { id:, name:, category:, description: } ]
|
81
135
|
def roles(&block)
|
82
136
|
get(api_query: 'account/roles', &block)
|
83
137
|
end
|
@@ -87,12 +141,34 @@ module Figshare
|
|
87
141
|
# @param is_active [Boolean] user account is active
|
88
142
|
# @param institution_user_id [String] As set in the HR upload
|
89
143
|
# @param email [String] as set in the HR upload
|
90
|
-
# @
|
91
|
-
|
144
|
+
# @param id_lte [Integer] ID is <=
|
145
|
+
# @param id_gte [Integer] ID is >=
|
146
|
+
# @param page [Numeric] Pages start at 1. Page and Page size go together
|
147
|
+
# @param page_size [Numeric]
|
148
|
+
# @param offset [Numeric] offset is 0 based. Offset and Limit go together
|
149
|
+
# @param limit [Numeric]
|
150
|
+
# @yield [Array] [{ id:, first_name:, last_name:, institution_id:, email:, active:, institution_user_id:, quota:, used_quota:, user_id:, orcid_id: }]
|
151
|
+
def accounts( is_active: nil,
|
152
|
+
institution_user_id: nil,
|
153
|
+
email: nil,
|
154
|
+
id_lte: nil,
|
155
|
+
id_gte: nil,
|
156
|
+
page: nil,
|
157
|
+
page_size: nil,
|
158
|
+
offset: nil,
|
159
|
+
limit: nil,
|
160
|
+
&block
|
161
|
+
)
|
92
162
|
args = {}
|
93
163
|
args['is_active'] = is_active unless is_active.nil?
|
94
164
|
args['institution_user_id'] = institution_user_id unless institution_user_id.nil?
|
95
165
|
args['email'] = email unless email.nil?
|
166
|
+
args['id_lte'] = id_lte unless id_lte.nil?
|
167
|
+
args['id_gte'] = id_gte unless id_gte.nil?
|
168
|
+
args['page'] = page unless page.nil?
|
169
|
+
args['page_size'] = page_size unless page_size.nil?
|
170
|
+
args['offset'] = offset unless offset.nil?
|
171
|
+
args['limit'] = limit unless limit.nil?
|
96
172
|
get_paginate(api_query: 'account/institution/accounts', args: args, &block)
|
97
173
|
end
|
98
174
|
|
@@ -106,7 +182,16 @@ module Figshare
|
|
106
182
|
# @param symplectic_user_id [string]
|
107
183
|
# @param quota [Integer] Figshare user quota
|
108
184
|
# @param is_active [Boolean]
|
109
|
-
def account_create(email:,
|
185
|
+
def account_create( email:,
|
186
|
+
first_name:,
|
187
|
+
last_name:,
|
188
|
+
group_id:,
|
189
|
+
institution_user_id: nil,
|
190
|
+
symplectic_user_id: nil,
|
191
|
+
quota: nil,
|
192
|
+
is_active: true,
|
193
|
+
&block
|
194
|
+
)
|
110
195
|
args = {}
|
111
196
|
args['email'] = email unless email.nil?
|
112
197
|
args['first_name'] = first_name unless first_name.nil?
|
@@ -116,11 +201,12 @@ module Figshare
|
|
116
201
|
args['symplectic_user_id'] = symplectic_user_id unless symplectic_user_id.nil?
|
117
202
|
args['quota'] = quota unless quota.nil?
|
118
203
|
args['is_active'] = is_active unless is_active.nil?
|
119
|
-
post(api_query:
|
204
|
+
post(api_query: 'account/institution/accounts', args: args, &block)
|
120
205
|
end
|
121
206
|
|
122
207
|
# Update Institution Account
|
123
208
|
#
|
209
|
+
# @param account_id [Integer] Whose account
|
124
210
|
# @param email [String]
|
125
211
|
# @param first_name [String]
|
126
212
|
# @param last_name [String]
|
@@ -129,7 +215,17 @@ module Figshare
|
|
129
215
|
# @param symplectic_user_id [string]
|
130
216
|
# @param quota [Integer] Figshare user quota
|
131
217
|
# @param is_active [Boolean]
|
132
|
-
def account_update(
|
218
|
+
def account_update( account_id:,
|
219
|
+
email: nil,
|
220
|
+
first_name: nil,
|
221
|
+
last_name: nil,
|
222
|
+
group_id: nil,
|
223
|
+
institution_user_id: nil,
|
224
|
+
symplectic_user_id: nil,
|
225
|
+
quota: nil,
|
226
|
+
is_active: true,
|
227
|
+
&block
|
228
|
+
)
|
133
229
|
args = {}
|
134
230
|
args['email'] = email unless email.nil?
|
135
231
|
args['first_name'] = first_name unless first_name.nil?
|
@@ -142,7 +238,7 @@ module Figshare
|
|
142
238
|
put(api_query: "account/institution/accounts/#{account_id}", args: args, &block)
|
143
239
|
end
|
144
240
|
|
145
|
-
# Get institution Account Group Roles
|
241
|
+
# Get institution Account Group Roles for an account
|
146
242
|
#
|
147
243
|
# @param account_id [Integer] Figshare user account id
|
148
244
|
# @yield [Hash] { role_id [ { category, id, name }, ... ], ... }
|
@@ -153,7 +249,7 @@ module Figshare
|
|
153
249
|
# Add Institution Account Group Roles
|
154
250
|
#
|
155
251
|
# @param account_id [Integer] Figshare user account id
|
156
|
-
# @param body [Hash] see figshare api docs
|
252
|
+
# @param body [Hash] see figshare api cryptic docs { "2": [ 2, 7], "3": [7,9] }. Array of roles, per group
|
157
253
|
def group_roles_add(account_id:, body:, &block)
|
158
254
|
post(api_query: "account/institution/roles/#{account_id}", args: body, &block)
|
159
255
|
end
|
@@ -163,12 +259,9 @@ module Figshare
|
|
163
259
|
# @param account_id [Integer] Figshare user account id
|
164
260
|
# @param role_id [Integer] Figshare role id
|
165
261
|
# @param group_id [Integer] Figshare group id
|
166
|
-
def group_role_delete( role_id
|
262
|
+
def group_role_delete( account_id:, role_id:, group_id:, &block)
|
167
263
|
args = {}
|
168
|
-
|
169
|
-
args['role_id'] = role_id unless role_id.nil?
|
170
|
-
args['group_id'] = group_id unless group_id.nil?
|
171
|
-
delete(api_query: 'account/institution/roles/{account_id}', args: args, &block)
|
264
|
+
delete(api_query: "account/institution/roles/#{account_id}/#{group_id}/#{role_id}", args: args, &block)
|
172
265
|
end
|
173
266
|
|
174
267
|
# Get the accounts for which the account has administrative privileges (assigned and inherited).
|
@@ -176,14 +269,31 @@ module Figshare
|
|
176
269
|
# @param is_active [Boolean] user account is active
|
177
270
|
# @param institution_user_id [String] As set in the HR upload
|
178
271
|
# @param email [String] as set in the HR upload
|
179
|
-
# @
|
180
|
-
|
272
|
+
# @param page [Numeric] Pages start at 1. Page and Page size go together
|
273
|
+
# @param page_size [Numeric]
|
274
|
+
# @param offset [Numeric] offset is 0 based. Offset and Limit go together
|
275
|
+
# @param limit [Numeric]
|
276
|
+
# @yield [Hash] {id, first_name, last_name, institution_id, email, active, institution_user_id, quota, used_quota, user_id, orcid_id}
|
277
|
+
def account_search( search_for: nil,
|
278
|
+
is_active: nil,
|
279
|
+
institution_user_id: nil,
|
280
|
+
email: nil,
|
281
|
+
page: nil,
|
282
|
+
page_size: nil,
|
283
|
+
offset: nil,
|
284
|
+
limit: nil,
|
285
|
+
&block
|
286
|
+
)
|
181
287
|
args = {}
|
182
288
|
args['search_for'] = search_for unless search_for.nil?
|
183
289
|
args['is_active'] = is_active unless is_active.nil?
|
184
290
|
args['institution_user_id'] = institution_user_id unless institution_user_id.nil?
|
185
291
|
args['email'] = email unless email.nil?
|
186
|
-
|
292
|
+
args['page'] = page unless page.nil?
|
293
|
+
args['page_size'] = page_size unless page_size.nil?
|
294
|
+
args['offset'] = offset unless offset.nil?
|
295
|
+
args['limit'] = limit unless limit.nil?
|
296
|
+
post_paginate(api_query: 'account/institution/accounts/search', args: args, &block)
|
187
297
|
end
|
188
298
|
|
189
299
|
# Get institution user information using the account_id
|
@@ -198,13 +308,23 @@ module Figshare
|
|
198
308
|
#
|
199
309
|
# @param group_id [Integer] Figshare group ID
|
200
310
|
# @param article_id [Integer] Figshare article ID
|
201
|
-
# @param status [String] pending, approved, rejected, closed
|
311
|
+
# @param status [String] One of: pending, approved, rejected, closed
|
312
|
+
# @param offset [Numeric] offset is 0 based. Offset and Limit go together
|
313
|
+
# @param limit [Numeric]
|
202
314
|
# @yield [Hash] {id, group_id, account_id, assigned_to, article_id, version, comment_count, status, created_date. modified_date }
|
203
|
-
def curation_review(group_id: nil,
|
315
|
+
def curation_review( group_id: nil,
|
316
|
+
article_id: nil,
|
317
|
+
status: nil,
|
318
|
+
offset: nil,
|
319
|
+
limit: nil,
|
320
|
+
&block
|
321
|
+
)
|
204
322
|
args = {}
|
205
323
|
args['group_id'] = group_id unless group_id.nil?
|
206
324
|
args['article_id'] = article_id unless article_id.nil?
|
207
325
|
args['status'] = status unless status.nil?
|
326
|
+
args['offset'] = offset unless offset.nil?
|
327
|
+
args['limit'] = limit unless limit.nil?
|
208
328
|
# Odd one, as has offset,limit not page,page_size
|
209
329
|
get_paginate(api_query: 'account/institution/reviews', args: args, by_offset: true, &block)
|
210
330
|
end
|
@@ -220,10 +340,15 @@ module Figshare
|
|
220
340
|
# Get a certain curation review's comments.
|
221
341
|
#
|
222
342
|
# @param curation_id [Integer] Figshare curation ID
|
343
|
+
# @param offset [Numeric] offset is 0 based. Offset and Limit go together
|
344
|
+
# @param limit [Numeric]
|
223
345
|
# @yield [Hash] { id, account_id, type, text}
|
224
|
-
def curation_review_comments(curation_id:, &block)
|
346
|
+
def curation_review_comments(curation_id:, offset: nil, limit: nil, &block)
|
225
347
|
# Odd one, as has offset,limit not page,page_size.
|
226
|
-
|
348
|
+
args = {}
|
349
|
+
args['offset'] = offset unless offset.nil?
|
350
|
+
args['limit'] = limit unless limit.nil?
|
351
|
+
get_paginate(api_query: "account/institution/review/#{curation_id}/comments", args: args, by_offset: true, &block)
|
227
352
|
end
|
228
353
|
|
229
354
|
# Add a new comment to the review.
|
@@ -231,8 +356,7 @@ module Figshare
|
|
231
356
|
# @param curation_id [Integer] Figshare curation ID
|
232
357
|
# @param comment [String] Comment text
|
233
358
|
def curation_review_comments_update(curation_id:, comment:, &block)
|
234
|
-
|
235
|
-
post(api_query: "account/institution/reviews/#{curation_id}/comments", args: { 'text' => comment }, &block)
|
359
|
+
post(api_query: "account/institution/review/#{curation_id}/comments", args: { 'text' => comment }, &block)
|
236
360
|
end
|
237
361
|
end
|
238
362
|
end
|
data/lib/other.rb
CHANGED
@@ -2,10 +2,18 @@ module Figshare
|
|
2
2
|
# Misc Figshare API calls that they have classified as Other.
|
3
3
|
#
|
4
4
|
class Other < Base
|
5
|
+
# Fetch item types
|
6
|
+
#
|
7
|
+
# @param group_id [Integer]
|
8
|
+
# @yield [Array] [{id: 0, name:, string_id:, icon:, public_description:, is_selectable: , url_name: } ]
|
9
|
+
def item_types(group_id:, &block)
|
10
|
+
get(api_query: 'item_types', args: { 'group_id' => group_id }, &block)
|
11
|
+
end
|
12
|
+
|
5
13
|
# Search from funding records
|
6
14
|
#
|
7
15
|
# @param search_for [String] string to search for
|
8
|
-
# @yield [
|
16
|
+
# @yield [Array] [{id, title, grant_code, funder_name, is_user_defined, url}]
|
9
17
|
def search_funding(search_for:, &block)
|
10
18
|
post(api_query: 'account/funding/search', args: { 'search_for' => search_for }, &block)
|
11
19
|
end
|
@@ -21,21 +29,21 @@ module Figshare
|
|
21
29
|
|
22
30
|
# Get public categories
|
23
31
|
#
|
24
|
-
# @yield [
|
32
|
+
# @yield [Array] [{parent_id:, id:, title:, path:, source_id:, taxonomy_id:}]
|
25
33
|
def public_categories
|
26
34
|
get(api_query: 'categories', &block)
|
27
35
|
end
|
28
36
|
|
29
37
|
# Get public licenses
|
30
38
|
#
|
31
|
-
# @yield [
|
39
|
+
# @yield [Array] [{value:, name:, url:}]
|
32
40
|
def public_licenses
|
33
41
|
get(api_query: 'licenses', &block)
|
34
42
|
end
|
35
43
|
|
36
44
|
# Get private licenses
|
37
45
|
#
|
38
|
-
# @yield [
|
46
|
+
# @yield [Array] [{value:, name:, url:}]
|
39
47
|
def private_account_licenses
|
40
48
|
get(api_query: 'account/licenses', &block)
|
41
49
|
end
|