jalc 1.2.0 → 2.0.0

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
  SHA256:
3
- metadata.gz: 96ec63df2a4d939e8eb433fff06fe70d84536174ab759755314dbf67fd21c900
4
- data.tar.gz: 25288558d0cfb086f73d72634051892d48bf9a21e64de7aa9bb06a72b44dc153
3
+ metadata.gz: 6906443971313b98068ef7816cfde731a473da34698637fafdaeeb99c2409150
4
+ data.tar.gz: 35272d82457609a1cb8238bbceb7b69b0b5bcfddb9b1d92a8cbc145459ca3ada
5
5
  SHA512:
6
- metadata.gz: 286ab06114bd1b84518239c7b4e801f67a1a275d9e8b9f11e379df59dd66aaa319743849735495c5420f2811f8d5dba879ed162a00a15f805403ab26fd71ca05
7
- data.tar.gz: b1fbb0ebed28715ea7dfaee774652eef36ccef399c2bc89c2fbe1d260e9a08d84937720fc144665afca3d8799ce325491ede9ce835701b27241e24623fdeec71
6
+ metadata.gz: 2b50fda5332b2cca03aeb53954f45cd734ed6122377b5fe363370948729e5023133203178e63b5f37723b352a778af5c5e302a3e487c668e37c77edf30a3156f
7
+ data.tar.gz: c87b1536b93b0766312f228425da6c97339a86f8b90eea24ea38ee7118bb796c40872bf22f67d738f9503187ec35634a64f70dcac9c4a01dcfef06e6c8d7a865
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [2.0.0] - 2022-01-10
4
+
5
+ - Change the return values from `Faraday::Response` to its `#body`
6
+
3
7
  ## [1.2.0] - 2022-01-10
4
8
 
5
9
  - Filter password on logs
data/README.md CHANGED
@@ -31,15 +31,15 @@ JaLC::REST.config.logger = MyLogger.new
31
31
 
32
32
  # GET /prefixes
33
33
  prefixes_res = JaLC::REST.prefixes(ra: 'JaLC', sort: 'siteId', order: 'desc')
34
- prefix = prefixes_res.body['data']['items'].first['prefix'] #=> "10.123"
34
+ prefix = prefixes_res['data']['items'].first['prefix'] #=> "10.123"
35
35
 
36
36
  # GET /doilist/:prefix
37
37
  doilist_res = JaLC::REST.doilist(prefix, rows: 100)
38
- doi = doilist_res.body['data']['items'].last['dois']['doi'] #=> "10.123/abc"
38
+ doi = doilist_res['data']['items'].last['dois']['doi'] #=> "10.123/abc"
39
39
 
40
40
  # GET /dois/:doi
41
41
  doi_res = JaLC::REST.doi(doi)
42
- doi_res.body['data']
42
+ doi_res['data']
43
43
  ```
44
44
 
45
45
  ### JaLC Registration API
@@ -55,10 +55,8 @@ JaLC::Registration.configure do |config|
55
55
  config.logger = nil
56
56
  end
57
57
 
58
- res = JaLC::Registration.post(File.open('/path/to/xml'))
59
-
60
- # body is an REXML::Document
61
- res.body.root.elements['head/okcnt'].text #=> "1"
58
+ res = JaLC::Registration.post(File.open('/path/to/xml')) # returns a REXML::Document
59
+ res.root.elements['head/okcnt'].text #=> "1"
62
60
 
63
61
  # async registration (result_method=2)
64
62
  async_res = JaLC::Registration.post(StringIO.new(<<~XML))
@@ -73,10 +71,10 @@ async_res = JaLC::Registration.post(StringIO.new(<<~XML))
73
71
  </body
74
72
  </root>
75
73
  XML
76
- exec_id = async_res.body.root.elements['head/exec_id'].text #=> "12345"
74
+ exec_id = async_res.root.elements['head/exec_id'].text #=> "12345"
77
75
 
78
76
  result_res = JaLC::Registration.get_result(exec_id)
79
- result_res.body.root.elements['head/status'].text #=> "2"
77
+ result_res.root.elements['head/status'].text #=> "2"
80
78
  ```
81
79
 
82
80
  ## Development
@@ -20,7 +20,7 @@ module JaLC
20
20
  end
21
21
 
22
22
  def post(xml_file)
23
- conn.post(
23
+ response = conn.post(
24
24
  '/jalc/infoRegistry/registDataReceive/index',
25
25
  {
26
26
  login_id: Faraday::Multipart::ParamPart.new(@id, 'text/plain'),
@@ -28,10 +28,11 @@ module JaLC
28
28
  fname: Faraday::Multipart::FilePart.new(xml_file, 'text/xml'),
29
29
  },
30
30
  )
31
+ response.body
31
32
  end
32
33
 
33
34
  def get_result(exec_id)
34
- conn.get(
35
+ response = conn.get(
35
36
  '/jalc/infoRegistry/registDataResult/index',
36
37
  {
37
38
  login_id: @id,
@@ -39,6 +40,7 @@ module JaLC
39
40
  exec_id: exec_id,
40
41
  },
41
42
  )
43
+ response.body
42
44
  end
43
45
 
44
46
  private
@@ -18,7 +18,7 @@ module JaLC
18
18
  end
19
19
 
20
20
  def prefixes(ra: nil, sort: nil, order: nil)
21
- conn.get(
21
+ response = conn.get(
22
22
  '/prefixes',
23
23
  {
24
24
  ra: ra,
@@ -26,10 +26,11 @@ module JaLC
26
26
  order: order,
27
27
  }.compact,
28
28
  )
29
+ response.body
29
30
  end
30
31
 
31
32
  def doilist(prefix, from: nil, to: nil, rows: nil, page: nil, sort: nil, order: nil)
32
- conn.get(
33
+ response = conn.get(
33
34
  "/doilist/#{prefix}",
34
35
  {
35
36
  from: from,
@@ -40,11 +41,13 @@ module JaLC
40
41
  order: order,
41
42
  }.compact,
42
43
  )
44
+ response.body
43
45
  end
44
46
 
45
47
  def doi(doi)
46
48
  encoded_doi = URI.encode_www_form_component(URI.encode_www_form_component(doi))
47
- conn.get("/dois/#{encoded_doi}")
49
+ response = conn.get("/dois/#{encoded_doi}")
50
+ response.body
48
51
  end
49
52
 
50
53
  private
data/lib/jalc/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JaLC
4
- VERSION = '1.2.0'
4
+ VERSION = '2.0.0'
5
5
  end
data/sig/jalc.rbs CHANGED
@@ -1,6 +1,7 @@
1
- type faraday_response = untyped
2
-
3
1
  module JaLC
2
+ interface _Logger
3
+ end
4
+
4
5
  VERSION: String
5
6
 
6
7
  module Registration
@@ -24,22 +25,25 @@ module JaLC
24
25
  class Client
25
26
  interface _IO
26
27
  end
28
+ type rexml_document = untyped
27
29
 
28
- def initialize: (id: String, password: String, ?logger: Logger?, ?base_url: String) -> void
29
- def post: (_IO xml_file) -> faraday_response
30
- def get_result: (Integer | String exec_id) -> faraday_response
30
+ def initialize: (id: String, password: String, ?logger: _Logger?, ?base_url: String) -> void
31
+ def post: (_IO xml_file) -> rexml_document
32
+ def get_result: (Integer | String exec_id) -> rexml_document
31
33
  end
32
34
 
33
35
  class Config
34
36
  attr_accessor id: String?
35
37
  attr_accessor password: String?
36
- attr_accessor logger: Logger?
38
+ attr_accessor logger: _Logger?
37
39
 
38
40
  def initialize: -> void
39
41
  end
40
42
  end
41
43
 
42
44
  module REST
45
+ type response_body = Hash[String, untyped] | String | nil
46
+
43
47
  BASE_URL: String
44
48
 
45
49
  def self.configure: { (Config) -> void } -> void
@@ -49,8 +53,7 @@ module JaLC
49
53
  end
50
54
 
51
55
  class HTTPError < Error
52
- type faraday_header = untyped
53
- type response_hash = {status: Integer, headers: faraday_header, body: untyped, request: {method: Symbol, url: URI, headers: faraday_header, body: String?}}
56
+ type response_hash = {status: Integer, headers: Hash[String, String], body: response_body, request: {method: Symbol, url: URI, headers: Hash[String, String], body: String?}}
54
57
 
55
58
  attr_reader response: response_hash?
56
59
 
@@ -71,14 +74,14 @@ module JaLC
71
74
  end
72
75
 
73
76
  class Client
74
- def initialize: (?logger: Logger?, ?base_url: String) -> void
75
- def prefixes: (?ra: String?, ?sort: String?, ?order: String?) -> faraday_response
76
- def doilist: (String, ?from: String?, ?to: String?, ?rows: Integer? | String?, ?page: Integer? | String?, ?sort: String?, ?order: String?) -> faraday_response
77
- def doi: (String) -> faraday_response
77
+ def initialize: (?logger: _Logger?, ?base_url: String) -> void
78
+ def prefixes: (?ra: String?, ?sort: String?, ?order: String?) -> response_body
79
+ def doilist: (String, ?from: String?, ?to: String?, ?rows: Integer? | String?, ?page: Integer? | String?, ?sort: String?, ?order: String?) -> response_body
80
+ def doi: (String) -> response_body
78
81
  end
79
82
 
80
83
  class Config
81
- attr_accessor logger: Logger?
84
+ attr_accessor logger: _Logger?
82
85
 
83
86
  def initialize: -> void
84
87
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jalc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiro Miyoshi