figshare_api_v2 0.9.4 → 0.9.8

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.
data/lib/institutions.rb CHANGED
@@ -1,24 +1,22 @@
1
1
  module Figshare
2
-
3
2
  # Figshare Institutions API
4
3
  #
5
4
  class Institutions < Base
6
-
7
5
  # Upload hr file
8
6
  #
9
7
  # @param hr_xml [String] See https://docs.figshare.com/#hr_feed_hr_feed_private_endpoint
10
8
  # @yield [Hash] { message:, data: null, errcode:}
11
9
  def hr_upload(hr_xml:, &block)
12
- put(api_query: "institution/hrfeed/upload", data: hr_xml, content_type: 'multipart/form-data' &block)
10
+ post(api_query: 'institution/hrfeed/upload', data: hr_xml, content_type: 'multipart/form-data', &block)
13
11
  end
14
12
 
15
13
  # Get the institional account details
16
14
  #
17
- # @yield [Hash]
15
+ # @yield [Hash]
18
16
  def account(&block)
19
- get(api_query: "account/institution", &block)
17
+ get(api_query: 'account/institution', &block)
20
18
  end
21
-
19
+
22
20
  # Requests a list of private institute articles
23
21
  #
24
22
  # @param status [Integer] Only return items with this status
@@ -28,22 +26,25 @@ module Figshare
28
26
  # @param item_type [String] Matches this item_type. See Figshare API docs for list (https://docs.figshare.com/#articles_list)
29
27
  # @param order [String] "published_date" Default, "modified_date", "views", "cites", "shares"
30
28
  # @param order_direction [String] "desc" Default, "asc"
31
- # @yield [Hash] {id, title, doi, handle, group_id, url, url_public_html, url_public_api, url_private_htm,
29
+ # @yield [Hash] {id, title, doi, handle, group_id, url, url_public_html, url_public_api, url_private_htm,
32
30
  # url_private_api, published_date, timeline {...}, thumb, defined_type, defined_name }
33
- def private_articles(status: nil,
34
- published_since: nil, modified_since: nil,
35
- item_type: nil, resource_doi: nil,
36
- order: 'published_date', order_direction: 'desc',
37
- &block
31
+ def private_articles( status: nil,
32
+ published_since: nil,
33
+ modified_since: nil,
34
+ item_type: nil,
35
+ resource_doi: nil,
36
+ order: 'published_date',
37
+ order_direction: 'desc',
38
+ &block
38
39
  )
39
40
  args = {}
40
- args['status'] = status if ! status.nil?
41
- args['item_type'] = item_type if ! item_type.nil?
42
- args['resource_doi'] = resource_doi if ! resource_doi.nil?
43
- args['published_since'] = published_since if ! published_since.nil?
44
- args['modified_since'] = modified_since if ! modified_since.nil?
45
- args['order'] = order if ! order.nil?
46
- args['order_direction'] = order_direction if ! order_direction.nil?
41
+ args['status'] = status unless status.nil?
42
+ args['item_type'] = item_type unless item_type.nil?
43
+ args['resource_doi'] = resource_doi unless resource_doi.nil?
44
+ args['published_since'] = published_since unless published_since.nil?
45
+ args['modified_since'] = modified_since unless modified_since.nil?
46
+ args['order'] = order unless order.nil?
47
+ args['order_direction'] = order_direction unless order_direction.nil?
47
48
  get_paginate(api_query: 'account/institution/articles', args: args, &block)
48
49
  end
49
50
 
@@ -51,36 +52,36 @@ module Figshare
51
52
  #
52
53
  # @param resource_id [Integer] Figshare resource_id (publisher ID?)
53
54
  # @param filename [String] Figshare file name
54
- # @yield [Hash] {id, title, doi, handle, group_id, url, url_public_html, url_public_api, url_private_htm,
55
+ # @yield [Hash] {id, title, doi, handle, group_id, url, url_public_html, url_public_api, url_private_htm,
55
56
  # url_private_api, published_date, timeline {...}, thumb, defined_type, defined_name }
56
57
  def articles_filter_by(resource_id: nil, filename: nil, &block )
57
58
  args = {}
58
- args['resource_id'] = resource_id if ! resource_id.nil?
59
- args['filename'] = filename if ! filename.nil?
60
- get(api_query: "institutions/{@institute_id}/articles/filter-by", args: args, &block)
59
+ args['resource_id'] = resource_id unless resource_id.nil?
60
+ args['filename'] = filename unless filename.nil?
61
+ get(api_query: 'institutions/{@institute_id}/articles/filter-by', args: args, &block)
61
62
  end
62
63
 
63
64
  # Get institution categories (including parent Categories)
64
65
  #
65
66
  # @yield [Hash] { parent_id, id, title }
66
67
  def categories(&block)
67
- get(api_query: "account/categories", &block)
68
+ get(api_query: 'account/categories', &block)
68
69
  end
69
70
 
70
71
  # Get the groups for which the account has administrative privileges (assigned and inherited).
71
72
  #
72
73
  # @yield [Hash] { id, name, resource_id, parent_id, association_criteria }
73
74
  def groups(&block)
74
- get(api_query: "account/groups", &block)
75
+ get(api_query: 'account/groups', &block)
75
76
  end
76
77
 
77
78
  # Get the roles available for groups and the institution group.
78
79
  #
79
80
  # @yield [Hash] { id, name, category, description }
80
81
  def roles(&block)
81
- get(api_query: "account/roles", &block)
82
+ get(api_query: 'account/roles', &block)
82
83
  end
83
-
84
+
84
85
  # Get the accounts for which the account has administrative privileges (assigned and inherited).
85
86
  #
86
87
  # @param is_active [Boolean] user account is active
@@ -89,15 +90,15 @@ module Figshare
89
90
  # @yield [Hash] { id, first_name, last_name, institution_id, email, active, institution_user_id }
90
91
  def accounts(is_active: nil, institution_user_id: nil, email: nil, &block)
91
92
  args = {}
92
- args['is_active'] = is_active if ! is_active.nil?
93
- args['institution_user_id'] = institution_user_id if ! institution_user_id.nil?
94
- args['email'] = email if ! email.nil?
95
- get_paginate(api_query: "account/institution/accounts", args: args, &block)
93
+ args['is_active'] = is_active unless is_active.nil?
94
+ args['institution_user_id'] = institution_user_id unless institution_user_id.nil?
95
+ args['email'] = email unless email.nil?
96
+ get_paginate(api_query: 'account/institution/accounts', args: args, &block)
96
97
  end
97
-
98
+
98
99
  # Create new Institution Account
99
100
  #
100
- # @param email [String]
101
+ # @param email [String]
101
102
  # @param first_name [String]
102
103
  # @param last_name [String]
103
104
  # @param group_id [Integer] Figshare group ID
@@ -107,20 +108,20 @@ module Figshare
107
108
  # @param is_active [Boolean]
108
109
  def account_create(email:, first_name:, last_name:, group_id:, institution_user_id: nil, symplectic_user_id: nil, quota: nil, is_active: true, &block)
109
110
  args = {}
110
- args['email'] = email if ! email.nil?
111
- args['first_name'] = first_name if ! first_name.nil?
112
- args['last_name'] = last_name if ! last_name.nil?
113
- args['group_id'] = group_id if ! group_id.nil?
114
- args['institution_user_id'] = institution_user_id if ! institution_user_id.nil?
115
- args['symplectic_user_id'] = symplectic_user_id if ! symplectic_user_id.nil?
116
- args['quota'] = quota if ! quota.nil?
117
- args['is_active'] = is_active if ! is_active.nil?
111
+ args['email'] = email unless email.nil?
112
+ args['first_name'] = first_name unless first_name.nil?
113
+ args['last_name'] = last_name unless last_name.nil?
114
+ args['group_id'] = group_id unless group_id.nil?
115
+ args['institution_user_id'] = institution_user_id unless institution_user_id.nil?
116
+ args['symplectic_user_id'] = symplectic_user_id unless symplectic_user_id.nil?
117
+ args['quota'] = quota unless quota.nil?
118
+ args['is_active'] = is_active unless is_active.nil?
118
119
  post(api_query: "account/institution/accounts/#{account_id}", args: args, &block)
119
120
  end
120
121
 
121
122
  # Update Institution Account
122
123
  #
123
- # @param email [String]
124
+ # @param email [String]
124
125
  # @param first_name [String]
125
126
  # @param last_name [String]
126
127
  # @param group_id [Integer] Figshare group ID
@@ -130,33 +131,33 @@ module Figshare
130
131
  # @param is_active [Boolean]
131
132
  def account_update(email:, first_name:, last_name:, group_id:, institution_user_id: nil, symplectic_user_id: nil, quota: nil, is_active: true, &block)
132
133
  args = {}
133
- args['email'] = email if ! email.nil?
134
- args['first_name'] = first_name if ! first_name.nil?
135
- args['last_name'] = last_name if ! last_name.nil?
136
- args['group_id'] = group_id if ! group_id.nil?
137
- args['institution_user_id'] = institution_user_id if ! institution_user_id.nil?
138
- args['symplectic_user_id'] = symplectic_user_id if ! symplectic_user_id.nil?
139
- args['quota'] = quota if ! quota.nil?
140
- args['is_active'] = is_active if ! is_active.nil?
134
+ args['email'] = email unless email.nil?
135
+ args['first_name'] = first_name unless first_name.nil?
136
+ args['last_name'] = last_name unless last_name.nil?
137
+ args['group_id'] = group_id unless group_id.nil?
138
+ args['institution_user_id'] = institution_user_id unless institution_user_id.nil?
139
+ args['symplectic_user_id'] = symplectic_user_id unless symplectic_user_id.nil?
140
+ args['quota'] = quota unless quota.nil?
141
+ args['is_active'] = is_active unless is_active.nil?
141
142
  put(api_query: "account/institution/accounts/#{account_id}", args: args, &block)
142
143
  end
143
-
144
+
144
145
  # Get institution Account Group Roles
145
146
  #
146
147
  # @param account_id [Integer] Figshare user account id
147
148
  # @yield [Hash] { role_id [ { category, id, name }, ... ], ... }
148
149
  def group_roles(account_id:, &block)
149
- get(api_query: "account/institution/roles/{account_id}", &block)
150
+ get(api_query: "account/institution/roles/#{account_id}", &block)
150
151
  end
151
-
152
+
152
153
  # Add Institution Account Group Roles
153
154
  #
154
155
  # @param account_id [Integer] Figshare user account id
155
156
  # @param body [Hash] see figshare api docs
156
157
  def group_roles_add(account_id:, body:, &block)
157
- post(api_query: "account/institution/roles/{account_id}", args: body, &block)
158
+ post(api_query: "account/institution/roles/#{account_id}", args: body, &block)
158
159
  end
159
-
160
+
160
161
  # Delete Institution Account Group Role
161
162
  #
162
163
  # @param account_id [Integer] Figshare user account id
@@ -164,10 +165,10 @@ module Figshare
164
165
  # @param group_id [Integer] Figshare group id
165
166
  def group_role_delete( role_id, group_id, account_id:, &block)
166
167
  args = {}
167
- args['account_id'] = account_id if ! account_id.nil?
168
- args['role_id'] = role_id if ! role_id.nil?
169
- args['group_id'] = group_id if ! group_id.nil?
170
- delete(api_query: "account/institution/roles/{account_id}", args: args, &block)
168
+ args['account_id'] = account_id unless account_id.nil?
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)
171
172
  end
172
173
 
173
174
  # Get the accounts for which the account has administrative privileges (assigned and inherited).
@@ -176,15 +177,15 @@ module Figshare
176
177
  # @param institution_user_id [String] As set in the HR upload
177
178
  # @param email [String] as set in the HR upload
178
179
  # @yield [Hash] {id, first_name, last_name, institution_id, email, active, institution_user_id}
179
- def account_search(search_for:, is_active: nil, institution_user_id: nil, email: nil, &block)
180
+ def account_search(search_for: nil, is_active: nil, institution_user_id: nil, email: nil, &block)
180
181
  args = {}
181
- args['search_for'] = search_for
182
- args['is_active'] = is_active if ! is_active.nil?
183
- args['institution_user_id'] = institution_user_id if ! institution_user_id.nil?
184
- args['email'] = email if ! email.nil?
185
- post(api_query: "account/institution/accounts/search", args: args, &block)
182
+ args['search_for'] = search_for unless search_for.nil?
183
+ args['is_active'] = is_active unless is_active.nil?
184
+ args['institution_user_id'] = institution_user_id unless institution_user_id.nil?
185
+ args['email'] = email unless email.nil?
186
+ post(api_query: 'account/institution/accounts/search', args: args, &block)
186
187
  end
187
-
188
+
188
189
  # Get institution user information using the account_id
189
190
  #
190
191
  # @param account_id [Integer] Figshare user account id
@@ -192,7 +193,7 @@ module Figshare
192
193
  def user(account_id:, &block)
193
194
  get(api_query: "account/institution/users/#{account_id}", &block)
194
195
  end
195
-
196
+
196
197
  # Get a list of curation reviews for this institution
197
198
  #
198
199
  # @param group_id [Integer] Figshare group ID
@@ -201,18 +202,18 @@ module Figshare
201
202
  # @yield [Hash] {id, group_id, account_id, assigned_to, article_id, version, comment_count, status, created_date. modified_date }
202
203
  def curation_review(group_id: nil, article_id: nil, status: nil, &block)
203
204
  args = {}
204
- args['group_id'] = group_id if ! group_id.nil?
205
- args['article_id'] = article_id if ! article_id.nil?
206
- args['status'] = status if ! status.nil?
207
- #Odd one, as has offset,limit not page,page_size
208
- get_paginate(api_query: "account/institution/reviews", args: args, by_offset: true, &block)
205
+ args['group_id'] = group_id unless group_id.nil?
206
+ args['article_id'] = article_id unless article_id.nil?
207
+ args['status'] = status unless status.nil?
208
+ # Odd one, as has offset,limit not page,page_size
209
+ get_paginate(api_query: 'account/institution/reviews', args: args, by_offset: true, &block)
209
210
  end
210
-
211
+
211
212
  # Get a curation review record
212
213
  #
213
214
  # @param curation_id [Integer] Figshare curation ID
214
215
  # @yield [Hash] see Figshare API docs for response sample
215
- def curation_detail(curation_id: , &block)
216
+ def curation_review_detail(curation_id:, &block)
216
217
  get(api_query: "account/institution/review/#{curation_id}", &block)
217
218
  end
218
219
 
@@ -220,8 +221,8 @@ module Figshare
220
221
  #
221
222
  # @param curation_id [Integer] Figshare curation ID
222
223
  # @yield [Hash] { id, account_id, type, text}
223
- def curation_comments(curation_id: , &block)
224
- #Odd one, as has offset,limit not page,page_size.
224
+ def curation_review_comments(curation_id:, &block)
225
+ # Odd one, as has offset,limit not page,page_size.
225
226
  get_paginate(api_query: "account/institution/reviews/#{curation_id}/comments", by_offset: true, &block)
226
227
  end
227
228
 
@@ -229,10 +230,9 @@ module Figshare
229
230
  #
230
231
  # @param curation_id [Integer] Figshare curation ID
231
232
  # @param comment [String] Comment text
232
- def curation_comments(curation_id: , &block)
233
- #Odd one, as has offset,limit not page,page_size.
234
- post(api_query: "account/institution/reviews/#{curation_id}/comments", args: { "text" => comment }, &block)
233
+ def curation_review_comments_update(curation_id:, comment:, &block)
234
+ # Odd one, as has offset,limit not page,page_size.
235
+ post(api_query: "account/institution/reviews/#{curation_id}/comments", args: { 'text' => comment }, &block)
235
236
  end
236
-
237
- end #of class
238
- end #of module
237
+ end
238
+ end
data/lib/oai_pmh.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  module Figshare
2
2
  # OAI PMH API (not implemented yet)
3
3
  #
4
+ # rubocop:disable Lint/EmptyClass
4
5
  class OAI_PMH
5
- end #class
6
- end # module
6
+ end
7
+ # rubocop:enable Lint/EmptyClass
8
+ end
data/lib/other.rb CHANGED
@@ -1,45 +1,45 @@
1
1
  module Figshare
2
-
3
2
  # Misc Figshare API calls that they have classified as Other.
4
3
  #
5
4
  class Other < Base
6
-
7
5
  # Search from funding records
8
6
  #
9
7
  # @param search_for [String] string to search for
10
8
  # @yield [Hash] {id, title, grant_code, funder_name, is_user_defined, url}
11
9
  def search_funding(search_for:, &block)
12
- post(api_query: "account/funding/search", args: { "search_for" => search_for }, &block)
10
+ post(api_query: 'account/funding/search', args: { 'search_for' => search_for }, &block)
13
11
  end
14
-
12
+
15
13
  # Get Account information for current user
16
14
  #
17
15
  # @yield [Hash] {id, first_name, ...} see figshare API docs
18
- def private_account_info
19
- get(api_query: "account", &block)
16
+ def private_account_info(impersonate: nil, &block)
17
+ args = {}
18
+ args['impersonate'] = impersonate unless impersonate.nil?
19
+ get(api_query: 'account', args: args, &block)
20
20
  end
21
-
21
+
22
22
  # Get public categories
23
23
  #
24
24
  # @yield [Hash] {parent_id, id, title}
25
25
  def public_categories
26
- get(api_query: "categories", &block)
26
+ get(api_query: 'categories', &block)
27
27
  end
28
-
28
+
29
29
  # Get public licenses
30
30
  #
31
31
  # @yield [Hash] {value, name, url}
32
32
  def public_licenses
33
- get(api_query: "licenses", &block)
33
+ get(api_query: 'licenses', &block)
34
34
  end
35
-
35
+
36
36
  # Get private licenses
37
37
  #
38
38
  # @yield [Hash] {value, name, url}
39
39
  def private_account_licenses
40
- get(api_query: "account/licenses", &block)
40
+ get(api_query: 'account/licenses', &block)
41
41
  end
42
-
42
+
43
43
  # Download a file
44
44
  #
45
45
  # @param file_id [Integer] Figshare file id