sdr-client 0.61.1 → 0.62.0

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: a05e0c0eaec02cd41abd26e460c2be48a5dd45890b2e4e3f42b5c6fcad143936
4
- data.tar.gz: 49a61ac42d58a64438d35f3f503cd690e4f3b560fad878929045d7152bde8724
3
+ metadata.gz: f26953315bf59c1c2485836f1b5485877bb58faa0375eca118016a3e1e3f5932
4
+ data.tar.gz: 9a00c929a3aa2da9a1698c97694dcd72d789289a83e4d6d9f330d404ad679d24
5
5
  SHA512:
6
- metadata.gz: 1a02843244adbe817cd84806a445a257cedad1e56e1be71f1c76bb72210bd2a76525dcabc22641fa4dad9da0352274fa46c8cf7957d24fd9422c801ac958c1e9
7
- data.tar.gz: d173d54a545ed1846f2418b502240e0141ab9dbe1b1d47663f8736f92317a982aa65b5d9c7b868814d09f0ff1b9d0542f5f740530526fe09fbd3792fc7b92b65
6
+ metadata.gz: f7a6daaa1c032403ba01e9ce45660fc8e71107d37fac3995af8ed73a9a1ff53e6e75a513326fc20c14e94129ec7cf4d7f711e1961ddfb82044da293fe508d46e
7
+ data.tar.gz: 9943f57b33e782840746d6208479aa4732d15d8dedafcd2a44bc58c153a31485bcf4663670e41d011592e727d7ba9b53732f1e4879e74a5895cdc002f41a0ab8
@@ -4,12 +4,21 @@ module SdrClient
4
4
  module Deposit
5
5
  # Handles unexpected responses when manipulating resources
6
6
  class UnexpectedResponse
7
+ # Raised when there is a request error (e.g.: a cocina-models version mismatch)
8
+ class BadRequest < StandardError; end
9
+ # Raised when there is a problem with the credentials
10
+ class Unauthorized < StandardError; end
11
+
7
12
  # @param [Faraday::Response] response
8
13
  def self.call(response)
9
- raise "There was an error with your request: #{response.body}" if response.status == 400
10
- raise 'There was an error with your credentials. Perhaps they have expired?' if response.status == 401
11
-
12
- raise "unexpected response: #{response.status} #{response.body}"
14
+ case response.status
15
+ when 400
16
+ raise BadRequest, "There was an error with your request: #{response.body}"
17
+ when 401
18
+ raise Unauthorized, 'There was an error with your credentials. Perhaps they have expired?'
19
+ else
20
+ raise "unexpected response: #{response.status} #{response.body}"
21
+ end
13
22
  end
14
23
  end
15
24
  end
@@ -38,6 +38,8 @@ module SdrClient
38
38
  Hash[file_metadata.map { |filename, metadata| [filename, direct_upload(metadata.to_json)] }]
39
39
  end
40
40
 
41
+ # This creates a signed token that we can use to upload the file. This token has an expiration set in sdr-api,
42
+ # so we have to use it before it expires.
41
43
  def direct_upload(metadata_json)
42
44
  logger.info("Starting an upload request: #{metadata_json}")
43
45
  response = connection.post(BLOB_PATH, metadata_json, 'Content-Type' => 'application/json')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SdrClient
4
- VERSION = '0.61.1'
4
+ VERSION = '0.62.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdr-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.61.1
4
+ version: 0.62.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-13 00:00:00.000000000 Z
11
+ date: 2022-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport