ebsco-eds 1.0.0 → 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3be68963a219aa4dd86acf2b408b432f2d8e9de7
4
- data.tar.gz: 859682c8f1051b9066d8ba2c3c8d3eb907d00327
3
+ metadata.gz: c0c34a0593ea537adc590f422fbbc06a4c465e9d
4
+ data.tar.gz: 06a8d582c1f568207565295eaf2c3d62a37ffae7
5
5
  SHA512:
6
- metadata.gz: 93a9aa9296c9319dbae1ca448ac70e0377b4b64c00a818cebd3193ddff229d94ed392d772d8123b0e472eeffc7351802a4001401e0132757c6423ed19ab066d5
7
- data.tar.gz: d943f5bb8b41edfe53f5ca5aa29c9d766bbfea8486a108918f37a0fdd62cb501ba2fb3834188342794e5b8f876257587d12f45d184eaa2cda7d5b31d607618db
6
+ metadata.gz: ec9f1aaf05490c9195125e2d89b52abec45e026bf7af43b02fe79edf2083a6294e0ed3c12783bc6413d2bf375b7ce567ef9f680f8773339540d829fe62ba8c0a
7
+ data.tar.gz: 76dde522d01b29aa103173627c67320f2b3173c8b4ad7c822707f963f9cb9fb8d136a1309db4b33180713a4c6372bfa782bd30986cf94c377a7b2b3beb6f9542
data/CHANGELOG.md ADDED
@@ -0,0 +1,72 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ### Added
10
+ ### Changed
11
+ ### Deprecated
12
+ ### Removed
13
+ ### Fixed
14
+ ### Security
15
+
16
+ ## [1.0.1] - 2018-10-10
17
+ ### Added
18
+ - Citation styles/exports are added to Records
19
+ - Retrieve citation styles/exports for a Record ID or list of Record IDs
20
+ - Retrieve a list of available citation styles/exports from Info
21
+ - Citation styles/exports available in guest mode
22
+ ### Fixed
23
+ - Double-unescapes data with an ephtml section (sul-dlss/SearchWorks #1504)
24
+ - Adds searchlinks to subject items when they don't exist #80 (sul-dlss/SearchWorks #1791)
25
+ ### Changed
26
+ - Updates test cassettes with new citation styles/exports API calls
27
+
28
+ ## [1.0.0] - 2018-03-05
29
+ ### Changed
30
+ - Increments version to reflect production ready status
31
+
32
+ ## [0.3.19.pre] - 2018-03-05
33
+ ### Added
34
+ - Optionally (default=off) include quick view images with Records
35
+ ### Changed
36
+ - Reorganizes VCR tests
37
+
38
+ ## [0.3.18.pre] - 2017-10-10
39
+ ### Fixed
40
+ - Fixes session config bug #84
41
+
42
+ ## [0.3.17.pre] - 2017-09-27
43
+ ### Changed
44
+ - Optionally (default=off) titleize facets via `titleize_facets` in config
45
+
46
+ ## [0.3.16.pre] - 2017-09-20
47
+ ### Added
48
+ - Titleize facets
49
+ - Autocorrect feature
50
+
51
+ ## [0.3.15.pre] - 2017-09-18
52
+ ### Added
53
+ - Optionally (default=off) converts all searchLink field codes to DE via `all_subjects_search_links` in config
54
+ - Optionally (default=off) decodes/sanitizes html in item data and fulltext html via `decode_sanitize_html` in config
55
+
56
+ ## [0.3.14.pre] - 2017-09-14
57
+ ### Fixed
58
+ - Fixes 250+ pagination issues with SourceType and ContentProvider facets
59
+
60
+ ## [0.3.13.pre] - 2017-09-13
61
+ ### Fixed
62
+ - Includes additional Subject and Geographic Subject metadata
63
+
64
+ ## [0.3.12.pre] - 2017-09-11
65
+ ### Fixed
66
+ - Fixes some 250+ pagination issues
67
+ ### Changed
68
+ - Updates tests
69
+
70
+ ## [0.3.11.pre] - 2017-09-06
71
+ ### Added
72
+ - Adds KW (keywords) and SH (subject heading) to solr search fields
data/README.md CHANGED
@@ -4,7 +4,6 @@ A Ruby interface to the EBSCO Discovery Services API.
4
4
 
5
5
  [![Build Status](https://travis-ci.org/ebsco/edsapi-ruby.svg)](https://travis-ci.org/ebsco/edsapi-ruby)
6
6
  [![codecov](https://codecov.io/gh/ebsco/edsapi-ruby/branch/master/graph/badge.svg)](https://codecov.io/gh/ebsco/edsapi-ruby/branch/master)
7
- [![Dependency Status](https://gemnasium.com/badges/github.com/ebsco/edsapi-ruby.svg)](https://gemnasium.com/github.com/ebsco/edsapi-ruby)
8
7
  [![Gem Version](https://img.shields.io/gem/v/ebsco-eds.svg?style=flat)](http://rubygems.org/gems/ebsco-eds)
9
8
 
10
9
  ## Dependencies
@@ -27,12 +26,19 @@ Or install it yourself as:
27
26
 
28
27
  $ gem install ebsco-eds
29
28
 
29
+ ## Feature Support
30
+
31
+ - Research Starters are included in results response, when available
32
+ - Configurable auto-suggest or 'Did you mean' support
33
+ - Configurable auto-correct support
34
+ - Quick-view images can be included in results, when available - [screencast](https://youtu.be/HxtWEq_Fhks)
35
+ - RIS citations are now included in the record response
36
+
30
37
  ## Documentation
31
38
 
32
39
  - [Configuration](https://github.com/ebsco/edsapi-ruby/wiki/Configuration)
33
40
  - [Quick Start](https://github.com/ebsco/edsapi-ruby/wiki/Quick-Start)
34
41
  - [Blacklight Support](https://github.com/ebsco/edsapi-ruby/wiki/Solr-and-Blacklight-Support)
35
- - [Citation Formats (Experimental)](https://github.com/ebsco/edsapi-ruby/wiki/Citation-Formats-(Experimental))
36
42
 
37
43
  ### Models
38
44
 
data/lib/ebsco/eds.rb CHANGED
@@ -3,6 +3,7 @@ require 'ebsco/eds/session'
3
3
  require 'ebsco/eds/info'
4
4
  require 'ebsco/eds/results'
5
5
  require 'ebsco/eds/record'
6
+ require 'ebsco/eds/citations'
6
7
  require 'ebsco/eds/error'
7
8
 
8
9
  module EBSCO
@@ -0,0 +1,80 @@
1
+ require 'ebsco/eds/jsonable'
2
+
3
+ module EBSCO
4
+ module EDS
5
+ class Citations
6
+ include JSONable
7
+
8
+ attr_accessor :eds_database_id, :eds_accession_number, :eds_record_id, :items
9
+
10
+ def initialize(dbid:, an:, citation_result:, eds_config: nil)
11
+
12
+ @eds_database_id = dbid
13
+ @eds_accession_number = an
14
+ @eds_record_id = @eds_database_id + '__' + @eds_accession_number
15
+
16
+ @items = []
17
+
18
+ if citation_result.key? 'Citations'
19
+
20
+ # citation styles
21
+ citation_result['Citations'].each do |style|
22
+ item = {}
23
+
24
+ if style.key? 'Id'
25
+ item['id'] = JSON.parse(style['Id'].to_json)
26
+ end
27
+
28
+ if style.key? 'Label'
29
+ item['label'] = JSON.parse(style['Label'].to_json)
30
+ end
31
+
32
+ if style.key? 'Data'
33
+ item['data'] = JSON.parse(style['Data'].to_json)
34
+ end
35
+
36
+ if style.key? 'Caption'
37
+ item['caption'] = JSON.parse(style['Caption'].to_json)
38
+ end
39
+
40
+ if style.key? 'SectionLabel'
41
+ item['section_label'] = JSON.parse(style['SectionLabel'].to_json)
42
+ end
43
+
44
+ if style.key? 'Error'
45
+ item['error'] = JSON.parse(style['Error'].to_json)
46
+ end
47
+
48
+ @items.push item
49
+
50
+ end
51
+
52
+ else
53
+
54
+ # citation exports
55
+ item = {}
56
+ if citation_result.key? 'Format'
57
+ item['id'] = JSON.parse(citation_result['Format'].to_json)
58
+ end
59
+
60
+ if citation_result.key? 'Label'
61
+ item['label'] = JSON.parse(citation_result['Label'].to_json)
62
+ end
63
+
64
+ if citation_result.key? 'Data'
65
+ item['data'] = JSON.parse(citation_result['Data'].to_json)
66
+ end
67
+
68
+ if citation_result.key? 'Error'
69
+ item['error'] = JSON.parse(citation_result['Error'].to_json)
70
+ end
71
+
72
+ @items.push item
73
+
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+ end
80
+ end
@@ -25,6 +25,10 @@ module EBSCO
25
25
  :info_url => '/edsapi/rest/Info',
26
26
  :search_url => '/edsapi/rest/Search',
27
27
  :retrieve_url => '/edsapi/rest/Retrieve',
28
+ :citation_exports_url => '/edsapi/rest/ExportFormat',
29
+ :citation_exports_formats => 'all',
30
+ :citation_styles_url => '/edsapi/rest/CitationStyles',
31
+ :citation_styles_formats => 'all',
28
32
  :user_agent => 'EBSCO EDS GEM v0.0.1',
29
33
  :interface_id => 'edsapi_ruby_gem',
30
34
  :log => 'faraday.log',
@@ -5,7 +5,7 @@ module EBSCO
5
5
  module EDS
6
6
  class Info
7
7
 
8
- attr_accessor :available_search_criteria, :view_result_settings, :application_settings, :api_settings
8
+ attr_accessor :available_search_criteria, :view_result_settings, :application_settings, :api_settings, :citation_style_settings, :export_format_settings
9
9
 
10
10
  def initialize(info, config = {})
11
11
  @results_per_page = config[:max_results_per_page] ? config[:max_results_per_page] : 100
@@ -13,6 +13,8 @@ module EBSCO
13
13
  @view_result_settings = info['ViewResultSettings']
14
14
  @application_settings = info['ApplicationSettings']
15
15
  @api_settings = info['ApiSettings']
16
+ @citation_style_settings = info['CitationStyleSettings']
17
+ @export_format_settings = info['ExportFormatSettings']
16
18
  end
17
19
 
18
20
  # ====================================================================================
@@ -143,6 +145,18 @@ module EBSCO
143
145
  @available_search_criteria.fetch('AvailableDidYouMeanOptions',{}).find{|item| item['Id'] == 'AutoCorrect'}['DefaultOn']
144
146
  end
145
147
 
148
+ # ====================================================================================
149
+ # CITATION STYLES AND EXPORT FORMATS
150
+ # ====================================================================================
151
+
152
+ def available_citation_styles (id = 'all')
153
+ @citation_style_settings.fetch('AvailableStyles',{}).select{|item| item['Id'] == id || id == 'all'}
154
+ end
155
+
156
+ def available_citation_exports (id = 'all')
157
+ @export_format_settings.fetch('AvailableFormats',{}).select{|item| item['Id'] == id || id == 'all'}
158
+ end
159
+
146
160
  # ====================================================================================
147
161
  # RESULTS VIEW SETTINGS
148
162
  # ====================================================================================
@@ -80,7 +80,9 @@ module EBSCO
80
80
  # publication record attributes
81
81
  :eds_publication_id,
82
82
  :eds_publication_is_searchable,
83
- :eds_publication_scope_note
83
+ :eds_publication_scope_note,
84
+ :eds_citation_exports,
85
+ :eds_citation_styles
84
86
  ]
85
87
 
86
88
  KNOWN_ITEM_NAMES = %w(
@@ -190,6 +192,7 @@ module EBSCO
190
192
  get_item_data({name: 'Subject', label: 'Subject Terms', group: 'Su'}) ||
191
193
  get_item_data({name: 'Subject', label: 'Subject Indexing', group: 'Su'}) ||
192
194
  get_item_data({name: 'Subject', label: 'Subject Category', group: 'Su'}) ||
195
+ get_item_data({name: 'Subject', label: 'KeyWords Plus', group: 'Su'}) ||
193
196
  bib_subjects
194
197
  @eds_subjects_geographic =
195
198
  get_item_data({name: 'SubjectGeographic', label: 'Geographic Terms', group: 'Su'}) ||
@@ -789,15 +792,26 @@ module EBSCO
789
792
  var != :@bib_entity &&
790
793
  var != :@bib_part &&
791
794
  var != :@bib_relationships &&
792
- var != :@image_quick_view_items
795
+ var != :@image_quick_view_items &&
796
+ var != :@eds_citation_exports &&
797
+ var != :@eds_citation_styles
793
798
  hash[var.to_s.sub(/^@/, '')] = instance_variable_get(var)
794
799
  end
795
800
  end
801
+
796
802
  if all_links
797
803
  hash['eds_fulltext_link'] = { 'id' => @eds_database_id + '__' + @eds_accession_number,
798
804
  'links' => all_links }
799
805
  end
800
806
 
807
+ # add citation styles and exports
808
+ unless @eds_citation_exports.nil?
809
+ hash['eds_citation_exports'] = @eds_citation_exports.items
810
+ end
811
+ unless @eds_citation_styles.nil?
812
+ hash['eds_citation_styles'] = @eds_citation_styles.items
813
+ end
814
+
801
815
  hash
802
816
  end
803
817
 
@@ -897,6 +911,7 @@ module EBSCO
897
911
  if item['Group']
898
912
  group = item['Group']
899
913
  if group == 'Su'
914
+ data = add_subject_searchlinks(data)
900
915
  # translate searchLink field codes to DE?
901
916
  if @all_subjects_search_links
902
917
  data = data.gsub(/(searchLink fieldCode=")([A-Z]+)/, '\1DE')
@@ -923,11 +938,20 @@ module EBSCO
923
938
  def html_decode_and_sanitize(data, config = nil)
924
939
  default_config = Sanitize::Config.merge(Sanitize::Config::RELAXED,
925
940
  :elements => Sanitize::Config::RELAXED[:elements] +
926
- %w[relatesto searchlink],
941
+ %w[relatesto searchlink ephtml],
927
942
  :attributes => Sanitize::Config::RELAXED[:attributes].merge(
928
943
  'searchlink' => %w[fieldcode term]))
929
944
  sanitize_config = config.nil? ? default_config : config
930
- Sanitize.fragment(CGI.unescapeHTML(data.to_s), sanitize_config)
945
+
946
+ html = CGI.unescapeHTML(data.to_s)
947
+ # need to double-unescape data with an ephtml section
948
+ if html =~ /<ephtml>/
949
+ html = CGI.unescapeHTML(html)
950
+ html = html.gsub!(/\\"/, '"')
951
+ html = html.gsub!(/\\n /, '')
952
+ end
953
+
954
+ Sanitize.fragment(html, sanitize_config)
931
955
  end
932
956
 
933
957
  # dynamically add item metadata as 'eds_extra_ItemNameOrLabel'
@@ -941,12 +965,31 @@ module EBSCO
941
965
  unless key.nil?
942
966
  key = "eds_extras_#{key}"
943
967
  unless value.nil?
944
- class_eval { attr_accessor key }
945
- instance_variable_set "@#{key}", CGI.unescapeHTML(value)
968
+ self.class.class_eval { attr_accessor key }
969
+ self.instance_variable_set "@#{key}", CGI.unescapeHTML(value)
946
970
  end
947
971
  end
948
972
  end
949
973
 
974
+ def set_citation_exports(val)
975
+ @eds_citation_exports = val
976
+ end
977
+
978
+ def set_citation_styles(val)
979
+ @eds_citation_styles = val
980
+ end
981
+
982
+ # add searchlinks when they don't exist
983
+ def add_subject_searchlinks(data)
984
+ subjects = data
985
+ unless data.include? 'searchLink'
986
+ subjects = subjects.split('&lt;br /&gt;').map do |su|
987
+ '&lt;searchLink fieldCode=&quot;DE&quot; term=&quot;%22' + su + '%22&quot;&gt;' + su + '&lt;/searchLink&gt;'
988
+ end.join('&lt;br /&gt;')
989
+ end
990
+ subjects
991
+ end
992
+
950
993
  end # Class Record
951
994
  end # Module EDS
952
995
  end # Module EBSCO
@@ -29,7 +29,7 @@ module EBSCO
29
29
 
30
30
  # Creates search results from the \EDS API search response. It includes information about the results and a list
31
31
  # of Record items.
32
- def initialize(search_results, eds_config = nil, additional_limiters = {}, options = {})
32
+ def initialize(search_results, eds_config = {}, additional_limiters = {}, options = {})
33
33
 
34
34
  @results = search_results
35
35
  @limiters = additional_limiters
@@ -28,6 +28,7 @@ module EBSCO
28
28
  attr_accessor :auth_token # :nodoc:
29
29
  # The session token. This is passed along in the x-sessionToken HTTP header.
30
30
  attr_accessor :session_token # :nodoc:
31
+ attr_accessor :citation_token # :nodoc:
31
32
  # The session configuration.
32
33
  attr_reader :config
33
34
 
@@ -67,6 +68,7 @@ module EBSCO
67
68
  def initialize(options = {})
68
69
 
69
70
  @session_token = ''
71
+ @citation_token = ''
70
72
  @auth_token = ''
71
73
  @config = {}
72
74
  @guest = true
@@ -161,17 +163,25 @@ module EBSCO
161
163
  else
162
164
  @session_token = create_session_token
163
165
  end
166
+
167
+ if options.key? :citation_token
168
+ @citation_token = options[:citation_token]
169
+ else
170
+ @citation_token = create_citation_token
171
+ end
172
+
164
173
  @info = EBSCO::EDS::Info.new(do_request(:get, path: @config[:info_url]), @config)
165
174
  @current_page = 0
166
175
  @search_options = nil
167
176
 
168
177
  if @debug
169
178
  if options.key? :caller
170
- puts 'CREATE SESSION CALLER: ' + options[:caller].inspect
171
- puts 'CALLER OPTIONS: ' + options.inspect
179
+ puts '*** CREATE SESSION CALLER: ' + options[:caller].inspect
180
+ puts '*** CALLER OPTIONS: ' + options.inspect
172
181
  end
173
- puts 'AUTH TOKEN: ' + @auth_token.inspect
174
- puts 'SESSION TOKEN: ' + @session_token.inspect
182
+ puts '*** AUTH TOKEN: ' + @auth_token.inspect
183
+ puts '*** SESSION TOKEN: ' + @session_token.inspect
184
+ puts '*** CITATION TOKEN: ' + @citation_token.inspect
175
185
  end
176
186
 
177
187
  end
@@ -265,7 +275,7 @@ module EBSCO
265
275
  end
266
276
  @search_results
267
277
  else
268
- @search_results = EBSCO::EDS::Results.new(empty_results)
278
+ @search_results = EBSCO::EDS::Results.new(empty_results, @config)
269
279
  end
270
280
  end
271
281
  end
@@ -303,13 +313,81 @@ module EBSCO
303
313
  def retrieve(dbid:, an:, highlight: nil, ebook: 'ebook-pdf')
304
314
  payload = { DbId: dbid, An: an, HighlightTerms: highlight, EbookPreferredFormat: ebook }
305
315
  retrieve_response = do_request(:post, path: @config[:retrieve_url], payload: payload)
306
- #retrieve_params = "?an=#{an}&dbid=#{dbid}&ebookpreferredformat=#{ebook}"
307
- #retrieve_response = do_request(:get, path: @config[:retrieve_url] + retrieve_params)
308
316
  record = EBSCO::EDS::Record.new(retrieve_response, @config)
309
- # puts 'RECORD: ' + record.inspect
317
+ record_citation_exports = get_citation_exports({dbid: dbid, an: an, format: @config[:citation_exports_formats]})
318
+ unless record_citation_exports.nil?
319
+ record.set_citation_exports(record_citation_exports)
320
+ end
321
+ record_citation_styles = get_citation_styles({dbid: dbid, an: an, format: @config[:citation_styles_formats]})
322
+ unless record_citation_styles.nil?
323
+ record.set_citation_styles(record_citation_styles)
324
+ end
310
325
  record
311
326
  end
312
327
 
328
+ # fetch the citation from the citation rest endpoint
329
+ def get_citation_exports(dbid:, an:, format: 'all')
330
+ begin
331
+ # only available as non-guest otherwise 148 error
332
+ citation_exports_params = "?an=#{an}&dbid=#{dbid}&format=#{format}"
333
+ citation_exports_response = do_request(:get, path: @config[:citation_exports_url] + citation_exports_params)
334
+ EBSCO::EDS::Citations.new(dbid: dbid, an: an, citation_result: citation_exports_response, eds_config: @config)
335
+ rescue EBSCO::EDS::BadRequest => e
336
+ custom_error_message = JSON.parse e.message.gsub('=>', ':')
337
+ # ErrorNumber 112 - Invalid Argument Value
338
+ # ErrorNumber 132 - Record not found
339
+ if custom_error_message['ErrorNumber'] == '112'
340
+ unknown_export_format = {"Format"=>format, "Label"=>"", "Data"=>"", "Error"=>"Invalid citation export format"}
341
+ EBSCO::EDS::Citations.new(dbid: dbid, an: an, citation_result: unknown_export_format, eds_config: @config)
342
+ elsif custom_error_message['ErrorNumber'] == '132'
343
+ record_not_found = {"Format"=>format, "Label"=>"", "Data"=>"", "Error"=>"Record not found"}
344
+ EBSCO::EDS::Citations.new(dbid: dbid, an: an, citation_result: record_not_found, eds_config: @config)
345
+ else
346
+ unknown_error = {"Format"=>format, "Label"=>"", "Data"=>"", "Error"=>custom_error_message['ErrorDescription']}
347
+ EBSCO::EDS::Citations.new(dbid: dbid, an: an, citation_result: unknown_error, eds_config: @config)
348
+ end
349
+ end
350
+ end
351
+
352
+ # fetch the citation from the citation rest endpoint
353
+ def get_citation_styles(dbid:, an:, format: 'all')
354
+ begin
355
+ citation_styles_params = "?an=#{an}&dbid=#{dbid}&styles=#{format}"
356
+ citation_styles_response = do_request(:get, path: @config[:citation_styles_url] + citation_styles_params)
357
+ EBSCO::EDS::Citations.new(dbid: dbid, an: an, citation_result: citation_styles_response, eds_config: @config)
358
+ rescue EBSCO::EDS::BadRequest => e
359
+ custom_error_message = JSON.parse e.message.gsub('=>', ':')
360
+ unknown_error = {"Id"=>format, "Label"=>"", "Data"=>"", "Error"=>custom_error_message['ErrorDescription']}
361
+ EBSCO::EDS::Citations.new(dbid: dbid, an: an, citation_result: unknown_error, eds_config: @config)
362
+ end
363
+ end
364
+
365
+ # get citation styles for a list of result ids
366
+ def get_citation_styles_list(id_list: [], format: 'all')
367
+ citations = []
368
+ if id_list.any?
369
+ id_list.each { |id|
370
+ dbid = id.split('__',2).first
371
+ accession = id.split('__',2).last
372
+ citations.push get_citation_styles(dbid: dbid, an: accession, format: format)
373
+ }
374
+ end
375
+ citations
376
+ end
377
+
378
+ # get citation exports for a list of result ids
379
+ def get_citation_exports_list(id_list: [], format: 'all')
380
+ citations = []
381
+ if id_list.any?
382
+ id_list.each { |id|
383
+ dbid = id.split('__',2).first
384
+ accession = id.split('__',2).last
385
+ citations.push get_citation_exports(dbid: dbid, an: accession, format: format)
386
+ }
387
+ end
388
+ citations
389
+ end
390
+
313
391
  # Create a result set with just the record before and after the current detailed record
314
392
  def solr_retrieve_previous_next(options = {})
315
393
 
@@ -714,11 +792,19 @@ module EBSCO
714
792
  raise EBSCO::EDS::ApiError, 'EBSCO API error: Multiple attempts to perform request failed.'
715
793
  end
716
794
  begin
717
- resp = connection.send(method) do |req|
795
+
796
+ conn = connection
797
+
798
+ # use a citation api connection?
799
+ if path.include?(@config[:citation_exports_url]) || path.include?(@config[:citation_styles_url])
800
+ conn = citation_connection
801
+ end
802
+
803
+ resp = conn.send(method) do |req|
718
804
  case method
719
805
  when :get
720
806
  unless payload.nil?
721
- qs = CGI.escape(payload.to_query_string)
807
+ qs = CGI.unescape(payload.to_query(nil))
722
808
  path << '?' + qs
723
809
  end
724
810
  req.url path
@@ -1009,6 +1095,26 @@ module EBSCO
1009
1095
  end
1010
1096
  end
1011
1097
 
1098
+ def citation_connection
1099
+ logger = Logger.new(@config[:log])
1100
+ logger.level = Logger.const_get(@log_level)
1101
+ Faraday.new(url: 'https://' + @api_hosts_list[@api_host_index]) do |conn|
1102
+ conn.headers['Content-Type'] = 'application/json;charset=UTF-8'
1103
+ conn.headers['Accept'] = 'application/json'
1104
+ conn.headers['x-sessionToken'] = @citation_token ? @citation_token : ''
1105
+ conn.headers['x-authenticationToken'] = @auth_token ? @auth_token : ''
1106
+ conn.headers['User-Agent'] = @config[:user_agent]
1107
+ conn.request :url_encoded
1108
+ conn.use :eds_caching_middleware, store: @cache_store, logger: @debug ? logger : nil if @use_cache
1109
+ conn.use :eds_exception_middleware
1110
+ conn.response :json, content_type: /\bjson$/
1111
+ conn.response :detailed_logger, logger if @debug
1112
+ conn.options[:open_timeout] = @config[:open_timeout]
1113
+ conn.options[:timeout] = @config[:timeout]
1114
+ conn.adapter :net_http_persistent
1115
+ end
1116
+ end
1117
+
1012
1118
  def create_auth_token
1013
1119
  if blank?(@auth_token)
1014
1120
  # ip auth
@@ -1032,6 +1138,12 @@ module EBSCO
1032
1138
  @session_token = resp['SessionToken']
1033
1139
  end
1034
1140
 
1141
+ def create_citation_token
1142
+ resp = do_request(:get, path: @config[:create_session_url] +
1143
+ '?profile=' + @profile + '&guest=n&displaydatabasename=y')
1144
+ @citation_token = resp['SessionToken']
1145
+ end
1146
+
1035
1147
  # helper methods
1036
1148
  def blank?(var)
1037
1149
  var.nil? || var.respond_to?(:length) && var.empty?
@@ -1,5 +1,5 @@
1
1
  module EBSCO
2
2
  module EDS
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
5
5
  end
@@ -19,7 +19,7 @@ module Faraday
19
19
 
20
20
  initialize_store
21
21
 
22
- @cacheable_paths = %w(/edsapi/rest/Info /authservice/rest/uidauth /authservice/rest/uidauth /edsapi/rest/Retrieve? /edsapi/rest/Search?)
22
+ @cacheable_paths = %w(/edsapi/rest/Info /authservice/rest/uidauth /authservice/rest/uidauth /edsapi/rest/Retrieve? /edsapi/rest/Search? /edsapi/rest/ExportFormat /edsapi/rest/CitationStyles)
23
23
 
24
24
  end
25
25
 
@@ -70,6 +70,16 @@ module Faraday
70
70
  info "#{uri} - Setting custom expires: #{custom_expires_in}"
71
71
  end
72
72
 
73
+ if uri.request_uri.include?('/edsapi/rest/ExportFormat')
74
+ custom_expires_in = 86400 # 24 hours
75
+ info "#{uri} - Setting custom expires: #{custom_expires_in}"
76
+ end
77
+
78
+ if uri.request_uri.include?('/edsapi/rest/CitationStyles')
79
+ custom_expires_in = 86400 # 24 hours
80
+ info "#{uri} - Setting custom expires: #{custom_expires_in}"
81
+ end
82
+
73
83
  @store.write(key(env), env, expires_in: custom_expires_in)
74
84
  end
75
85
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ebsco-eds
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill McKinney
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-03-05 00:00:00.000000000 Z
12
+ date: 2018-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -368,6 +368,7 @@ files:
368
368
  - ".gitignore"
369
369
  - ".rubocop.yml"
370
370
  - ".travis.yml"
371
+ - CHANGELOG.md
371
372
  - Gemfile
372
373
  - LICENSE.txt
373
374
  - README.md
@@ -376,6 +377,7 @@ files:
376
377
  - bin/setup
377
378
  - ebsco-eds.gemspec
378
379
  - lib/ebsco/eds.rb
380
+ - lib/ebsco/eds/citations.rb
379
381
  - lib/ebsco/eds/configuration.rb
380
382
  - lib/ebsco/eds/csl/styles/apa.csl
381
383
  - lib/ebsco/eds/csl/styles/chicago-author-date.csl
@@ -412,7 +414,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
412
414
  version: '0'
413
415
  requirements: []
414
416
  rubyforge_project:
415
- rubygems_version: 2.6.8
417
+ rubygems_version: 2.5.2.3
416
418
  signing_key:
417
419
  specification_version: 4
418
420
  summary: 'Summary: EBSCO EDS API'