alma_api 2.0.1 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b21e33c3c303e5ea01c584595be071a745c0c1738004bf5c3d5c040e653e93ed
4
- data.tar.gz: fcd35e87137dac29d4aabe35e17f5aad838cc90c27d652e05013f66fe731cecc
3
+ metadata.gz: 9328376057698e1e53b97d5cc4897eeb0ab35d3ef7d6603d69f4bda3e5af00bd
4
+ data.tar.gz: c18349fff8cbd76c1df631bbaa821f6436d4a4b28997aa95107336b01e274924
5
5
  SHA512:
6
- metadata.gz: 8dab34fccec10fcb9c26e40782ada02fc5c511c0c3120730b4ff807055eca514cab07ed193a9f8ae8d04455a37da997dd50d4c0d16cdd60ec018bd7b23c241b8
7
- data.tar.gz: 62a5f0cad8b8303c17cb014942268d3382e6cb3f5ad951aedf74d0aa5a12fb1b7656bccdeb205ffe37ab45a6f899775dd7e8dc3f2150ae85f1a2fe3a064bf7ff
6
+ metadata.gz: 782f0d60d358d2ff1b7f2edb8fa8ffc83f5ef7f33028e160ac85a912a14696fee98f8652d97e65548dea4ec4bb034952621e7dea508721e13c399bf499c1869f
7
+ data.tar.gz: 460a34451a8080644726d6ecb43c0318263fc6a6416561381d7f1c416996164aa447639a938edf7512c64f5dc29ab58c518f401dcfc290c2891b3dda753d6f80
data/README.md CHANGED
@@ -28,7 +28,7 @@ and run the `bundle install` command in your terminal.
28
28
 
29
29
  > You need an API key for your Alma Instance in order to use this client. Please consult the [Ex Libris developer documentation on how to use the Alma REST APIs](https://developers.exlibrisgroup.com/alma/apis/#using) for more information how to get and setup your API keys.
30
30
 
31
- __Note: There a some breaking changes when upgrading from 1.x to 2.x. [Please read the section on upgrading below](#upgrading).__
31
+ __Note: There a some changes when upgrading from 1.x to 2.x. [Please read the section on upgrading below](#upgrading).__
32
32
 
33
33
  ### Quick example
34
34
 
@@ -60,14 +60,14 @@ configuration = AlmaApi::Configuration.new do |config|
60
60
  config.api_key = "YOUR API KEY"
61
61
  end
62
62
  ```
63
- The API key is the only required option to get a functional configuration. There are sensible default values for all other options.
63
+ The `api_key` is the only required option to get a functional configuration. There are sensible default values for all other options.
64
64
 
65
65
  The following options are available:
66
66
 
67
67
  1. `api_key`
68
68
  Set your Alma API key. This is the only option that can be passed to the constructor as a shortcut. All other options must be set using setters.
69
69
  2. `base_url`
70
- Set the base URL to be used for each request. Ex Libris provides different API gateways for different geographical locations. See [the documentation here](https://developers.exlibrisgroup.com/alma/apis/#calling) for more information. This parameter is optional and defaults to the Alma API Gateway for Europe: `https://api-eu.hosted.exlibrisgroup.com/almaws/v1`.
70
+ Set the base URL to be used for each request. Ex Libris provides different API gateways for different geographical locations. See [the documentation here](https://developers.exlibrisgroup.com/alma/apis/#calling) for more information. This parameter is optional and defaults to the Alma API Gateway for Europe.
71
71
 
72
72
  This expects a `String` with a valid URL. However, you can use a `Symbol` as a shortcut to set the `base_url` for one of the preconfigured gateways `:na` (North America), `:eu` (Europe), `:ap` (Asia-Pacific), `:ca` (Canada), `:cn` (China).
73
73
 
@@ -94,7 +94,7 @@ With the configuration ready, you can create the client.
94
94
  ```ruby
95
95
  client = AlmaApi::Client.new(configuration)
96
96
  ```
97
- As a shortcut, you can call `AlmaApi.configure` with a block to get the client instance. Note that each call to `AlmaApi.configure` returns a new `AlmaApi::Client` instance.
97
+ As a shortcut, you can call `AlmaApi::Client.configure` with a block to get the client instance. Note that each call to `AlmaApi::Client.configure` returns a new `AlmaApi::Client` instance.
98
98
 
99
99
  ```ruby
100
100
  client = AlmaApi::Client.configure do |config|
@@ -110,11 +110,11 @@ The client provides the following methods: `#get`, `#post`, `#put` and `#delete`
110
110
 
111
111
  Each method expects a URL path to the resource relative to the configured `base_url` as it's first parameter. Parameters that the Alma API expects as part of the URL path must be included here.
112
112
 
113
- To set query string parameters, set the `params:` option and provide a Ruby `hash`. To override the `default_format` for an individual request, you can set the `format:` option to `"json"` or `"xml"`, depending on your needs. Setting the format to `"xml"` is preferable for Alma APIs that work with MARCXML data.
113
+ To set query string parameters, set the `params:` option and provide a Ruby `Hash`. To override the `default_format` for an individual request, you can set the `format:` option to `"json"` or `"xml"`, depending on your needs. Setting the format to `"xml"` is preferable for Alma APIs that work with MARCXML data.
114
114
 
115
115
  To set the body of a `#post` or `#put` request, you can set the `body:` option. If the request format is `"json"`, the `body:` option should contain a valid json string. Otherwise, if the request format is `"xml"`, the option should be a valid XML string.
116
116
 
117
- In the case of a JSON request, the result of the call is a Ruby `hash`. For a XML request, the result is a `Nokogiri::XML::Document` instance, as this library uses [`nokogiri`](https://github.com/sparklemotion/nokogiri) under the hood for XML processing.
117
+ In the case of a JSON request, the result of the call is a Ruby `Hash`. For a XML request, the result is a `Nokogiri::XML::Document` instance, as this library uses [`nokogiri`](https://github.com/sparklemotion/nokogiri) under the hood for XML processing.
118
118
 
119
119
  #### Get remaining API calls
120
120
 
@@ -199,22 +199,23 @@ Each error exposes `#message` and `#code` methods for further inspection.
199
199
  Messages that are generated by Alma are returned in the language set in the configuration (default is English).
200
200
 
201
201
  The code is generated by Alma. For gateway errors, the code is a string token (e.g. REQUEST_TOO_LARGE). For logical errors, the code is usually a number (e.g. 401850). See the "Possible Error Codes" section for each resource in the [documentation](https://developers.exlibrisgroup.com/alma/apis/) for details.
202
+ For some errors, code may be `nil`.
202
203
 
203
204
  ### 2. `AlmaApi::GatewayError`
204
205
 
205
- If the Alma API responds with a `4xx` OR `5xx` HTTP status AND one of the following error codes, an `AlmaApi::GatewayError` is thrown.
206
+ If the Alma API responds with a `4xx` OR `5xx` HTTP status AND one of the following error codes, an `AlmaApi::GatewayError` is raised.
206
207
 
207
208
  `GENERAL_ERROR`, `UNAUTHORIZED`, `INVALID_REQUEST`, `PER_SECOND_THRESHOLD`, `DAILY_THRESHOLD`, `REQUEST_TOO_LARGE`, `FORBIDDEN`, `ROUTING_ERROR`
208
209
 
209
210
  Check the [the documentation here](https://developers.exlibrisgroup.com/alma/apis/#error) for more information about gateway errors.
210
211
 
211
- ### 2. `AlmaApi::ServerError`
212
+ ### 3. `AlmaApi::ServerError`
212
213
 
213
- Any `5xx` HTTP status that does not result in an `AlmaApi::GatewayError` will be thrown as an `AlmaApi::ServerError`.
214
+ Any `5xx` HTTP status that does not result in an `AlmaApi::GatewayError` will be raised as an `AlmaApi::ServerError`.
214
215
 
215
- ### 3. `AlmaApi::LogicalError`
216
+ ### 4. `AlmaApi::LogicalError`
216
217
 
217
- Any `4xx` HTTP status that does not result in an `AlmaApi::GatewayError` will be thrown as an `AlmaApi::LogicalError`.
218
+ Any `4xx` HTTP status that does not result in an `AlmaApi::GatewayError` will be raised as an `AlmaApi::LogicalError`.
218
219
 
219
220
  This is the most common error you will encounter and can be used to manage the control flow in your application.
220
221
 
@@ -247,7 +248,7 @@ As stated before this library uses [`faraday`](https://github.com/lostisland/far
247
248
 
248
249
  Therefore there should be no need to tweak a request before sending it to Alma. This should be considered as a bug and we are happy to receive feature requests.
249
250
 
250
- However, there is a way to tweak a request. For `#get`, `#post`, `#put` and `#delete` you can open a block that gives you access to the [`Faraday::Request`](https://www.rubydoc.info/github/lostisland/faraday/Faraday/Request) instance.
251
+ However, there is still a way to tweak a request. For `#get`, `#post`, `#put` and `#delete`, you can open a block that gives you access to the [`Faraday::Request`](https://www.rubydoc.info/github/lostisland/faraday/Faraday/Request) instance, which you can use to manipulate the request before it is sent to Alma.
251
252
 
252
253
  ```ruby
253
254
  client.get("some/path") do |req|
data/alma_api.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.files = `git ls-files lib README.md LICENSE alma_api.gemspec`.split($INPUT_RECORD_SEPARATOR)
15
15
  spec.require_paths = ["lib"]
16
16
 
17
- spec.add_dependency "activesupport", "> 6", "< 8"
17
+ spec.add_dependency "activesupport", "> 6"
18
18
  spec.add_dependency "faraday", "~> 2.7"
19
19
  spec.add_dependency "hashie", "~> 5.0"
20
20
  spec.add_dependency "nokogiri", "~> 1.11"
@@ -89,10 +89,15 @@ module AlmaApi
89
89
 
90
90
  # If the params contains a password parameter, delete that from the params
91
91
  # and add it to the headers. This is a special case for the Alma API when
92
- # authenticating a user. The password must be url-encoded.
92
+ # authenticating a user.
93
+ #
94
+ # The password must be url-encoded. As there are different ways to encode
95
+ # spaces (%20 vs +), makre sure to use a method that encodes spaces as %20
96
+ # as this is what Alma seems to expect.
97
+ #
93
98
  # @see https://developers.exlibrisgroup.com/alma/apis/docs/users/UE9TVCAvYWxtYXdzL3YxL3VzZXJzL3t1c2VyX2lkfQ==/
94
99
  if (password = params.delete(:password) || params.delete("password")).present?
95
- headers["Exl-User-Pw"] = CGI.escape(password)
100
+ headers["Exl-User-Pw"] = URI.encode_uri_component(password)
96
101
  end
97
102
 
98
103
  # Finally create and return the Faraday connection object.
@@ -1,3 +1,3 @@
1
1
  module AlmaApi
2
- VERSION = "2.0.1".freeze
2
+ VERSION = "2.0.3".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alma_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Sprotte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-02 00:00:00.000000000 Z
11
+ date: 2024-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '6'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '8'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +24,6 @@ dependencies:
27
24
  - - ">"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '6'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '8'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: faraday
35
29
  requirement: !ruby/object:Gem::Requirement