collectionspace-client 0.14.1 → 0.15.1

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.
@@ -4,17 +4,35 @@ module CollectionSpace
4
4
  # Helper methods for client requests
5
5
  module Helpers
6
6
  # add / update batch job
7
- def add_batch_job(name, template, data = {}, params = { pgSz: 100 })
8
- payload = Template.process(template, data)
9
- response = get('batch', { query: params })
10
- create_or_update(response, 'batch', 'name', name, payload)
7
+ def add_batch_job(name, template, data = {}, params = {pgSz: 100})
8
+ payload = Template.process(template, data)
9
+ response = get("batch", {query: params})
10
+ create_or_update(response, "batch", "name", name, payload)
11
+ end
12
+
13
+ # add / update batches and data updates
14
+ def add_batch(data = {}, params = {pgSz: 100})
15
+ payload = Template.process("batch", data)
16
+ response = get("batch", {query: params})
17
+ create_or_update(response, "batch", "name", data[:name], payload)
11
18
  end
12
19
 
13
20
  # add / update reports
14
- def add_report(data = {}, params = { pgSz: 100 })
15
- payload = Template.process('report', data)
16
- response = get('reports', { query: params })
17
- create_or_update(response, 'reports', 'name', data[:name], payload)
21
+ def add_report(data = {}, params = {pgSz: 100})
22
+ payload = Template.process("report", data)
23
+ response = get("reports", {query: params})
24
+ create_or_update(response, "reports", "name", data[:name], payload)
25
+ end
26
+
27
+ # returns Array of authority doctypes for use in setting up batches
28
+ def authority_doctypes
29
+ response = get("/servicegroups/authority")
30
+ unless response.result.success?
31
+ raise CollectionSpace::RequestError, response.result.body
32
+ end
33
+
34
+ result = response.result.parsed_response
35
+ result.dig("document", "servicegroups_common", "hasDocTypes", "hasDocType")
18
36
  end
19
37
 
20
38
  # get ALL records at path by paging through record set
@@ -24,10 +42,10 @@ module CollectionSpace
24
42
  return [] unless iterations.positive?
25
43
 
26
44
  Enumerator::Lazy.new(0...iterations) do |yielder, i|
27
- response = request('GET', path, options.merge(query: { pgNum: i }))
45
+ response = request("GET", path, options.merge(query: {pgNum: i}))
28
46
  raise CollectionSpace::RequestError, response.result.body unless response.result.success?
29
47
 
30
- items_in_page = response.parsed[list_type].fetch('itemsInPage', 0).to_i
48
+ items_in_page = response.parsed[list_type].fetch("itemsInPage", 0).to_i
31
49
  list_items = items_in_page.positive? ? response.parsed[list_type][list_item] : []
32
50
  list_items = [list_items] if items_in_page == 1
33
51
 
@@ -37,26 +55,25 @@ module CollectionSpace
37
55
 
38
56
  def count(path)
39
57
  list_type, = get_list_types(path)
40
- response = request('GET', path, query: { pgNum: 0, pgSz: 1 })
58
+ response = request("GET", path, query: {pgNum: 0, pgSz: 1})
41
59
  raise CollectionSpace::RequestError, response.result.body unless response.result.success?
42
60
 
43
- response.parsed[list_type]['totalItems'].to_i
61
+ response.parsed[list_type]["totalItems"].to_i
44
62
  end
45
63
 
46
64
  # get the tenant domain from a system required top level authority (person)
47
65
  def domain
48
- path = 'personauthorities'
49
- response = request('GET', path, query: { pgNum: 0, pgSz: 1 })
66
+ path = "personauthorities"
67
+ response = request("GET", path, query: {pgNum: 0, pgSz: 1})
50
68
  raise CollectionSpace::RequestError, response.result.body unless response.result.success?
51
69
 
52
- refname = response.parsed.dig(*get_list_types(path), 'refName')
70
+ refname = response.parsed.dig(*get_list_types(path), "refName")
53
71
  CollectionSpace::RefName.parse(refname)[:domain]
54
72
  end
55
73
 
56
74
  # find procedure or object by type and id
57
75
  # find authority/vocab term by type, subtype, and refname
58
- # rubocop:disable Metrics/ParameterLists
59
- def find(type:, value:, subtype: nil, field: nil, schema: 'common', sort: nil, operator: '=')
76
+ def find(type:, value:, subtype: nil, field: nil, schema: "common", sort: nil, operator: "=")
60
77
  service = CollectionSpace::Service.get(type: type, subtype: subtype)
61
78
  field ||= service[:term] # this will be set if it is an authority or vocabulary, otherwise nil
62
79
  field ||= service[:identifier]
@@ -64,7 +81,7 @@ module CollectionSpace
64
81
  path: service[:path],
65
82
  namespace: "#{service[:ns_prefix]}_#{schema}",
66
83
  field: field,
67
- expression: "#{operator} '#{value.gsub(/'/, '\\\\\'')}'"
84
+ expression: "#{operator} '#{value.gsub(/'/, "\\\\'")}'"
68
85
  )
69
86
  search(search_args, sortBy: CollectionSpace::Search::DEFAULT_SORT)
70
87
  end
@@ -75,74 +92,118 @@ module CollectionSpace
75
92
  # @param rel_type [String<'affects', 'hasBroader'>, nil] to be searched as `prd` value
76
93
  def find_relation(subject_csid:, object_csid:, rel_type: nil)
77
94
  if rel_type
78
- get('relations', query: { 'sbj' => subject_csid, 'obj' => object_csid, 'prd' => rel_type })
95
+ get("relations", query: {"sbj" => subject_csid, "obj" => object_csid, "prd" => rel_type})
79
96
  else
80
97
  warn(
81
98
  "No rel_type specified, so multiple types of relations between #{subject_csid} and #{object_csid} may be returned",
82
99
  uplevel: 1
83
100
  )
84
- get('relations', query: { 'sbj' => subject_csid, 'obj' => object_csid })
101
+ get("relations", query: {"sbj" => subject_csid, "obj" => object_csid})
85
102
  end
86
103
  end
87
104
 
88
105
  def get_list_types(path)
89
106
  {
90
- 'accounts' => %w[accounts_common_list account_list_item],
91
- 'relations' => %w[relations_common_list relation_list_item]
107
+ "accounts" => %w[accounts_common_list account_list_item],
108
+ "relations" => %w[relations_common_list relation_list_item]
92
109
  }.fetch(path, %w[abstract_common_list list_item])
93
110
  end
94
111
 
95
112
  def reindex_full_text(doctype, csids = [])
96
113
  if csids.any?
97
114
  run_job(
98
- 'Reindex Full Text', :reindex_full_text, :reindex_by_csids, { doctype: doctype, csids: csids }
115
+ "Reindex Full Text", :reindex_full_text, :reindex_by_csids, {doctype: doctype, csids: csids}
99
116
  )
100
117
  else
101
118
  run_job(
102
- 'Reindex Full Text', :reindex_full_text, :reindex_by_doctype, { doctype: doctype }
119
+ "Reindex Full Text", :reindex_full_text, :reindex_by_doctype, {doctype: doctype}
103
120
  )
104
121
  end
105
122
  end
106
123
 
107
- def reset_media_blob(id, url)
108
- raise CollectionSpace::ArgumentError, "Not a valid url #{url}" unless URI.parse(url).instance_of? URI::HTTPS
124
+ # @param id [String] media record's identificationNumber value
125
+ # @param url [String] blobUri value
126
+ # @param verbose [Boolean] whether to put brief report of outcome to STDOUT
127
+ # @param ensure_safe_url [Boolean] set to false if using FILE URIs or
128
+ # other non-HTTPS URIs
129
+ # @param delete_existing_blob [Boolean] set to false if you have already
130
+ # manually deleted blobs
131
+ def reset_media_blob(id:, url:, verbose: false,
132
+ ensure_safe_url: true,
133
+ delete_existing_blob: true)
134
+ if ensure_safe_url
135
+ unless URI.parse(url).instance_of? URI::HTTPS
136
+ raise CollectionSpace::ArgumentError, "Not a valid url #{url}"
137
+ end
138
+ end
109
139
 
110
- response = find(type: 'media', value: id, field: 'identificationNumber')
111
- raise CollectionSpace::RequestError, response.result.body unless response.result.success?
140
+ response = find(type: "media", value: id, field: "identificationNumber")
141
+ unless response.result.success?
142
+ if verbose
143
+ puts "#{id}\tfailure\tAPI request error: #{response.result.body}"
144
+ else
145
+ raise CollectionSpace::RequestError, response.result.body
146
+ end
147
+ end
112
148
 
113
149
  found = response.parsed
114
- total = found['abstract_common_list']['totalItems'].to_i
115
- raise CollectionSpace::NotFoundError, "Media #{id} not found" if total.zero?
116
- raise CollectionSpace::DuplicateIdFound, "Found multiple media records for #{id}" unless total == 1
150
+ total = found["abstract_common_list"]["totalItems"].to_i
151
+
152
+ if total.zero?
153
+ msg = "Media #{id} not found"
154
+ if verbose
155
+ puts "#{id}\tfailure\t#{msg}"
156
+ else
157
+ raise CollectionSpace::NotFoundError, msg
158
+ end
159
+ elsif total > 1
160
+ msg = "Found multiple media records for #{id}"
161
+ if verbose
162
+ puts "#{id}\tfailure\t#{msg}"
163
+ else
164
+ raise CollectionSpace::DuplicateIdFound, msg
165
+ end
166
+ end
117
167
 
118
- media_uri = found['abstract_common_list']['list_item']['uri']
119
- blob_csid = found['abstract_common_list']['list_item']['blobCsid']
168
+ media_uri = found["abstract_common_list"]["list_item"]["uri"]
120
169
 
121
- delete("/blobs/#{blob_csid}") if blob_csid
170
+ if delete_existing_blob
171
+ blob_csid = found["abstract_common_list"]["list_item"]["blobCsid"]
172
+ delete("/blobs/#{blob_csid}") if blob_csid
173
+ end
122
174
 
123
- payload = Template.process(:reset_media_blob, { id: id })
124
- put(media_uri, payload, query: { 'blobUri' => url })
175
+ payload = Template.process(:reset_media_blob, {id: id})
176
+ response = put(media_uri, payload, query: {"blobUri" => url})
177
+ if verbose
178
+ if response.result.success?
179
+ puts "#{id}\tsuccess\t"
180
+ else
181
+ puts "#{id}\tfailure\t#{response.parsed}"
182
+ end
183
+ else
184
+ response
185
+ end
125
186
  end
126
187
 
127
188
  def run_job(name, template, invoke_template, data = {})
128
189
  payload = Template.process(invoke_template, data)
129
- job = add_batch_job(name, template)
130
- path = job.parsed['document']['collectionspace_core']['uri']
190
+ job = add_batch_job(name, template)
191
+ path = job.parsed["document"]["collectionspace_core"]["uri"]
131
192
  post(path, payload)
132
193
  end
133
194
 
134
195
  def search(query, params = {})
135
196
  options = prepare_query(query, params)
136
- request 'GET', query.path, options
197
+ request "GET", query.path, options
137
198
  end
138
199
 
139
200
  def keyword_search(type:, value:, subtype: nil, sort: nil)
140
201
  service = CollectionSpace::Service.get(type: type, subtype: subtype)
141
- options = prepare_keyword_query(value, { sortBy: CollectionSpace::Search::DEFAULT_SORT })
142
- request 'GET', service[:path], options
202
+ options = prepare_keyword_query(value, {sortBy: CollectionSpace::Search::DEFAULT_SORT})
203
+ request "GET", service[:path], options
143
204
  end
144
205
 
145
- def service(type:, subtype: '')
206
+ def service(type:, subtype: "")
146
207
  CollectionSpace::Service.get(type: type, subtype: subtype)
147
208
  end
148
209
 
@@ -151,18 +212,18 @@ module CollectionSpace
151
212
  def create_or_update(response, path, property, value, payload)
152
213
  list_type, item_type = get_list_types(path)
153
214
  item = response.find(list_type, item_type, property, value)
154
- path = item ? "#{path}/#{item['csid']}" : path
215
+ path = item ? "#{path}/#{item["csid"]}" : path
155
216
  item ? put(path, payload) : post(path, payload)
156
217
  end
157
218
 
158
219
  def prepare_query(query, params = {})
159
220
  query_string = "#{query.namespace}:#{query.field} #{query.expression}"
160
- { query: { as: query_string }.merge(params) }
221
+ {query: {as: query_string}.merge(params)}
161
222
  end
162
223
 
163
224
  def prepare_keyword_query(query, sort = {})
164
- query_string = query.downcase.gsub(' ', '+')
165
- { query: { kw: query_string }.merge(sort) }
225
+ query_string = query.downcase.tr(" ", "+")
226
+ {query: {kw: query_string}.merge(sort)}
166
227
  end
167
228
  end
168
229
  end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'strscan'
3
+ require "strscan"
4
4
 
5
5
  module CollectionSpace
6
6
  # CollectionSpace RefName
7
7
  #
8
8
  # There are four patterns we need to handle:
9
- #
9
+ #
10
10
  # - urn:cspace:domain:type:name(subtype)'label' : Top level authority/vocabulary
11
11
  # - urn:cspace:domain:type:name(subtype):item:name(identifier)'label' : Authority/vocabulary term
12
12
  # - urn:cspace:domain:type:id(identifier)'label' : Collectionobject
@@ -15,38 +15,38 @@ module CollectionSpace
15
15
  attr_reader :domain, :type, :subtype, :identifier, :label
16
16
 
17
17
  def initialize(refname)
18
- @refname = refname
19
- @domain = nil
20
- @type = nil
21
- @subtype = nil
18
+ @refname = refname
19
+ @domain = nil
20
+ @type = nil
21
+ @subtype = nil
22
22
  @identifier = nil
23
- @label = nil
23
+ @label = nil
24
24
  parse
25
25
  end
26
26
 
27
27
  def parse
28
28
  scanner = StringScanner.new(@refname)
29
- scanner.skip('urn:cspace:')
30
- @domain = to_next_colon(scanner)
29
+ scanner.skip("urn:cspace:")
30
+ @domain = to_next_colon(scanner)
31
31
  @type = to_next_colon(scanner)
32
32
 
33
33
  case next_segment(scanner)
34
- when 'name'
34
+ when "name"
35
35
  set_subtype(scanner)
36
- when 'id'
36
+ when "id"
37
37
  set_identifier(scanner)
38
38
  end
39
39
 
40
40
  self
41
41
  end
42
-
42
+
43
43
  # Convenience class method, so new instance of RefName does not have to be instantiated in order to parse
44
44
  #
45
45
  # As of v0.13.1, return_class is added and defaults to nil for backward compatibility
46
46
  # Eventually this default will be deprecated, and a parsed RefName object will be returned as the default.
47
47
  # Any new code written using this method should set the return_class parameter to :refname_obj
48
48
  def self.parse(refname, return_class = nil)
49
- return_class == :refname_obj ? new(refname) : new(refname).to_h
49
+ (return_class == :refname_obj) ? new(refname) : new(refname).to_h
50
50
  end
51
51
 
52
52
  # Returns a parsed RefName object as a hash.
@@ -67,12 +67,12 @@ module CollectionSpace
67
67
  def next_segment(scanner)
68
68
  segment = scanner.check_until(/\(/)
69
69
  return nil unless segment
70
-
71
- segment.delete_suffix('(')
70
+
71
+ segment.delete_suffix("(")
72
72
  end
73
73
 
74
74
  def set_identifier(scanner)
75
- scanner.skip('id(')
75
+ scanner.skip("id(")
76
76
  @identifier = to_end_paren(scanner)
77
77
  return if scanner.eos?
78
78
 
@@ -85,30 +85,30 @@ module CollectionSpace
85
85
  end
86
86
 
87
87
  def set_subtype(scanner)
88
- scanner.skip('name(')
88
+ scanner.skip("name(")
89
89
  @subtype = to_end_paren(scanner)
90
90
 
91
91
  case next_segment(scanner)
92
92
  when nil
93
93
  set_label(scanner)
94
- when ':item:name'
94
+ when ":item:name"
95
95
  set_term_identifier(scanner)
96
96
  end
97
97
  end
98
98
 
99
99
  def set_term_identifier(scanner)
100
- scanner.skip(':item:name(')
100
+ scanner.skip(":item:name(")
101
101
  @identifier = to_end_paren(scanner)
102
102
  scanner.skip("'")
103
103
  set_label(scanner)
104
104
  end
105
-
105
+
106
106
  def to_end_paren(scanner)
107
- scanner.scan_until(/\)/).delete_suffix(')')
107
+ scanner.scan_until(/\)/).delete_suffix(")")
108
108
  end
109
109
 
110
110
  def to_next_colon(scanner)
111
- scanner.scan_until(/:/).delete_suffix(':')
111
+ scanner.scan_until(/:/).delete_suffix(":")
112
112
  end
113
113
  end
114
114
  end
@@ -0,0 +1,180 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CollectionSpace
4
+ # CollectionSpace report
5
+ class Report
6
+ def self.all
7
+ [
8
+ {
9
+ name: "Acquisition Summary",
10
+ notes: "An acquisition summary report. Runs on a single record only.",
11
+ doctype: "Acquisition",
12
+ supports_single_doc: "true",
13
+ supports_doc_list: "false",
14
+ supports_group: "false",
15
+ supports_no_context: "false",
16
+ filename: "acq_basic.jrxml",
17
+ mimetype: "application/pdf"
18
+ },
19
+ {
20
+ name: "Acquisition Basic List",
21
+ notes: "Catalog info for objects related to an acquisition record. Runs on a single record only.",
22
+ doctype: "Acquisition",
23
+ supports_single_doc: "true",
24
+ supports_doc_list: "false",
25
+ supports_group: "false",
26
+ supports_no_context: "false",
27
+ filename: "Acq_List_Basic.jrxml",
28
+ mimetype: "application/pdf"
29
+ },
30
+ {
31
+ name: "Condition Check Basic List",
32
+ notes: "Catalog info for objects related to a condition check record. Runs on a single record only.",
33
+ doctype: "Conditioncheck",
34
+ supports_single_doc: "true",
35
+ supports_doc_list: "false",
36
+ supports_group: "false",
37
+ supports_no_context: "false",
38
+ filename: "CC_List_Basic.jrxml",
39
+ mimetype: "application/pdf"
40
+ },
41
+ {
42
+ name: "Exhibition Basic List",
43
+ notes: "Catalog info for objects related to a exhibition record. Runs on a single record only.",
44
+ doctype: "Exhibition",
45
+ supports_single_doc: "true",
46
+ supports_doc_list: "false",
47
+ supports_group: "false",
48
+ supports_no_context: "false",
49
+ filename: "Exhibition_List_Basic.jrxml",
50
+ mimetype: "application/pdf"
51
+ },
52
+ {
53
+ name: "Group Basic List",
54
+ notes: "Catalog info for objects related to a group record. Runs on a single record only.",
55
+ doctype: "Group",
56
+ supports_single_doc: "true",
57
+ supports_doc_list: "false",
58
+ supports_group: "false",
59
+ supports_no_context: "false",
60
+ filename: "Group_List_Basic.jrxml",
61
+ mimetype: "application/pdf"
62
+ },
63
+ {
64
+ name: "Loan In Basic List",
65
+ notes: "Catalog info for objects related to a loan in record. Runs on a single record only.",
66
+ doctype: "Loanin",
67
+ supports_single_doc: "true",
68
+ supports_doc_list: "false",
69
+ supports_group: "false",
70
+ supports_no_context: "false",
71
+ filename: "LoansIn_List_Basic.jrxml",
72
+ mimetype: "application/pdf"
73
+ },
74
+ {
75
+ name: "Loan Out Basic List",
76
+ notes: "Catalog info for objects related to a loan out record. Runs on a single record only.",
77
+ doctype: "Loanout",
78
+ supports_single_doc: "true",
79
+ supports_doc_list: "false",
80
+ supports_group: "false",
81
+ supports_no_context: "false",
82
+ filename: "LoansOut_List_Basic.jrxml",
83
+ mimetype: "application/pdf"
84
+ },
85
+ {
86
+ name: "Acquisition Ethnographic Object List",
87
+ notes: "Core acquisition report. Runs on a single record only.",
88
+ doctype: "Acquisition",
89
+ supports_single_doc: "true",
90
+ supports_doc_list: "false",
91
+ supports_group: "false",
92
+ supports_no_context: "false",
93
+ filename: "coreAcquisition.jrxml",
94
+ mimetype: "application/pdf"
95
+ },
96
+ {
97
+ name: "Group Object Ethnographic Object List",
98
+ notes: "Core group object report. Runs on a single record only.",
99
+ doctype: "Group",
100
+ supports_single_doc: "true",
101
+ supports_doc_list: "false",
102
+ supports_group: "false",
103
+ supports_no_context: "false",
104
+ filename: "coreGroupObject.jrxml",
105
+ mimetype: "application/pdf"
106
+ },
107
+ {
108
+ name: "Intake Ethnographic Object List",
109
+ notes: "Core intake report. Runs on a single record only.",
110
+ doctype: "Intake",
111
+ supports_single_doc: "true",
112
+ supports_doc_list: "false",
113
+ supports_group: "false",
114
+ supports_no_context: "false",
115
+ filename: "coreIntake.jrxml",
116
+ mimetype: "application/pdf"
117
+ },
118
+ {
119
+ name: "Loan In Ethnographic Object List",
120
+ notes: "Core loan in report. Runs on a single record only.",
121
+ doctype: "Loanin",
122
+ supports_single_doc: "true",
123
+ supports_doc_list: "false",
124
+ supports_group: "false",
125
+ supports_no_context: "false",
126
+ filename: "coreLoanIn.jrxml",
127
+ mimetype: "application/pdf"
128
+ },
129
+ {
130
+ name: "Loan Out Ethnographic Object List",
131
+ notes: "Core loan out report. Runs on a single record only.",
132
+ doctype: "Loanout",
133
+ supports_single_doc: "true",
134
+ supports_doc_list: "false",
135
+ supports_group: "false",
136
+ supports_no_context: "false",
137
+ filename: "coreLoanOut.jrxml",
138
+ mimetype: "application/pdf"
139
+ },
140
+ {
141
+ name: "Object Exit Ethnographic Object List",
142
+ notes: "Core object exit report. Runs on a single record only.",
143
+ doctype: "ObjectExit",
144
+ supports_single_doc: "true",
145
+ supports_doc_list: "false",
146
+ supports_group: "false",
147
+ supports_no_context: "false",
148
+ filename: "coreObjectExit.jrxml",
149
+ mimetype: "application/pdf"
150
+ },
151
+ {
152
+ name: "Object Valuation",
153
+ notes: "Returns latest valuation information for selected objects",
154
+ doctype: "CollectionObject",
155
+ supports_single_doc: "false",
156
+ supports_doc_list: "true",
157
+ supports_group: "false",
158
+ supports_no_context: "true",
159
+ filename: "object_valuation.jrxml",
160
+ mimetype: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
161
+ },
162
+ {
163
+ name: "Systematic Inventory",
164
+ notes: "Generate a checklist for performing an inventory on a range of storage locations. Runs on all records, using the provided start and end locations.",
165
+ doctype: "Locationitem",
166
+ supports_single_doc: "false",
167
+ supports_doc_list: "false",
168
+ supports_group: "false",
169
+ supports_no_context: "true",
170
+ filename: "systematicInventory.jrxml",
171
+ mimetype: "application/pdf"
172
+ }
173
+ ]
174
+ end
175
+
176
+ def self.find(key, value)
177
+ all.find { |report| report[key] == value }
178
+ end
179
+ end
180
+ end
@@ -11,21 +11,21 @@ module CollectionSpace
11
11
  delete: {},
12
12
  get: {},
13
13
  post: {
14
- 'Content-Type' => 'application/xml',
15
- 'Content-Length' => 'nnnn'
14
+ "Content-Type" => "application/xml",
15
+ "Content-Length" => "nnnn"
16
16
  },
17
17
  put: {
18
- 'Content-Type' => 'application/xml',
19
- 'Content-Length' => 'nnnn'
18
+ "Content-Type" => "application/xml",
19
+ "Content-Length" => "nnnn"
20
20
  }
21
21
  }
22
22
  headers[method]
23
23
  end
24
24
 
25
- def initialize(config, method = 'GET', path = '', options = {})
25
+ def initialize(config, method = "GET", path = "", options = {})
26
26
  @config = config
27
27
  @method = method.downcase.to_sym
28
- @path = path.gsub(%r{^/}, '')
28
+ @path = path.gsub(%r{^/}, "")
29
29
 
30
30
  @auth = {
31
31
  username: config.username,
@@ -35,11 +35,12 @@ module CollectionSpace
35
35
  headers = default_headers(@method).merge(options.fetch(:headers, {}))
36
36
  @options = options
37
37
  @options[:basic_auth] = @auth
38
- @options[:headers] = headers
39
- @options[:verify] = config.verify_ssl
40
- @options[:query] = options.fetch(:query, {})
38
+ @options[:headers] = headers
39
+ @options[:verify] = config.verify_ssl
40
+ @options[:query] = options.fetch(:query, {})
41
41
 
42
42
  self.class.base_uri config.base_uri
43
+ self.class.debug_output $stdout if config.verbose
43
44
  self.class.default_params(
44
45
  wf_deleted: config.include_deleted,
45
46
  pgSz: config.page_size
@@ -6,19 +6,19 @@ module CollectionSpace
6
6
  attr_reader :result, :parsed, :status_code, :xml
7
7
 
8
8
  def initialize(result)
9
- @result = result
10
- @parsed = result.parsed_response
9
+ @result = result
10
+ @parsed = result.parsed_response
11
11
  @status_code = result.code.to_i
12
12
  body = result.body
13
- @xml = @result.success? && body =~ /<?xml/ ? Nokogiri::XML(body) : nil
13
+ @xml = (@result.success? && body =~ /<?xml/) ? Nokogiri::XML(body) : nil
14
14
  end
15
15
 
16
16
  def find(list_type, item_type, property, value)
17
- total = parsed[list_type]['totalItems'].to_i
17
+ total = parsed[list_type]["totalItems"].to_i
18
18
  return unless total.positive?
19
19
 
20
- list = parsed[list_type][item_type]
21
- list = [list] if total == 1 # wrap if single item
20
+ list = parsed[list_type][item_type]
21
+ list = [list] if total == 1 # wrap if single item
22
22
  list.find { |i| i[property] == value }
23
23
  end
24
24
  end
@@ -5,12 +5,12 @@ module CollectionSpace
5
5
  class Search
6
6
  attr_accessor :path, :namespace, :field, :expression
7
7
 
8
- DEFAULT_SORT = 'collectionspace_core:updatedAt DESC'
8
+ DEFAULT_SORT = "collectionspace_core:updatedAt DESC"
9
9
 
10
10
  def initialize(path: nil, namespace: nil, field: nil, expression: nil)
11
- @path = path
12
- @namespace = namespace
13
- @field = field
11
+ @path = path
12
+ @namespace = namespace
13
+ @field = field
14
14
  @expression = expression
15
15
  end
16
16