fmrest-core 0.18.0.rc3 → 0.18.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: 9070ffa50e9886a1c1a46c91575c3252469ea22423bbc0658d0b4c86f325c1ac
4
- data.tar.gz: 29b2bfef12c6352492aa3fbb5f19031aaf263e39dacc3e334bf6470df07de7e7
3
+ metadata.gz: fdfc316e5474cc3abbf196051aa48846f6b04452e0864a320445079a09a3f449
4
+ data.tar.gz: d23a6c290f33ab9c43f149de58af85825859aae9f0bc781200395bc883f66009
5
5
  SHA512:
6
- metadata.gz: 65ea5b666e2debed130714df05a9275e991e8127d17d44dbee94a4651a05394472ab1381e1bbf35551648234a6d3c6c174fcc4fe8025ec45148bcc27a5aef495
7
- data.tar.gz: bfdc063f4701eb03ed3f8e2edc7c9b2131cb6cc82175c88462debdd67891050fd53dfa160f47f35323809d6860d4a89ec341d8116791cae6d4e69b900b7715af
6
+ metadata.gz: 48ddb1505f075011675b5bfbeb437d42e70dff62912a6c44b0ac454c205332e8e61da6a628c0ae0cda095214d54dded125f8f98fa0af711d2e8e34b1d24332e1
7
+ data.tar.gz: 16623334ee707adb60e479d6db8bff23f22aa23cac397e32b839d4dceaa7aed4a2e94558684d08b1eaaa1fb008093b9628014a73b8b7dbe93f3d2cd1bc3498fc
data/CHANGELOG.md CHANGED
@@ -7,6 +7,9 @@
7
7
  * Defining an attribute on a model that would collide with an existing method
8
8
  now raises an error
9
9
  * Cleared Faraday deprecation messages on authentication methods
10
+ * Handle FileMaker Cloud case where HTTP 401 Unauthorized with content-type
11
+ text/html is returned after token expiry
12
+ * Add retry option to Rescuable mixin
10
13
  * Added fmrest-ruby/VERSION to User-Agent headers
11
14
 
12
15
  ### 0.17.1
@@ -39,7 +39,7 @@ module FmRest
39
39
  yield conn, settings
40
40
  else
41
41
  conn.use TypeCoercer, settings
42
- conn.response :json
42
+ conn.response :json, content_type: /\bjson$/
43
43
  end
44
44
 
45
45
  if settings.log
@@ -70,7 +70,7 @@ module FmRest
70
70
  conn.response :logger, FmRest.logger, bodies: true, headers: true, log_level: settings.log_level
71
71
  end
72
72
 
73
- conn.response :json
73
+ conn.response :json, content_type: /\bjson$/
74
74
  conn.adapter Faraday.default_adapter
75
75
  end
76
76
  end
@@ -27,6 +27,17 @@ module FmRest
27
27
  }.freeze
28
28
 
29
29
  def on_complete(env)
30
+ # Sometimes, especially when using FileMaker Cloud, a failed
31
+ # authorization request will return a 401 (Unauthorized) with text/html
32
+ # content-type instead of the regular JSON, so we need to catch it
33
+ # manually here, emulating a regular account error
34
+ if !(/\bjson$/ === env.response_headers["content-type"]) && env.status == 401
35
+ raise FmRest::APIError::AccountError.new(212, "Authentication failed (HTTP 401: Unauthorized)")
36
+ end
37
+
38
+ # From this point on we want JSON
39
+ return unless env.body.is_a?(Hash)
40
+
30
41
  # Sniff for either straight JSON parsing or Spyke's format
31
42
  if env.body[:metadata] && env.body[:metadata][:messages]
32
43
  check_errors(env.body[:metadata][:messages])
@@ -132,7 +132,10 @@ module FmRest
132
132
  end
133
133
 
134
134
  def auth_connection
135
- @auth_connection ||= V1.auth_connection(@settings)
135
+ # NOTE: this is purposely not memoized so that settings can be
136
+ # refreshed (since proc-based settings will not be automatically
137
+ # re-eval'd, for example for fmid_token-based auth)
138
+ V1.auth_connection(@settings)
136
139
  end
137
140
  end
138
141
  end
@@ -21,7 +21,7 @@ module FmRest
21
21
 
22
22
  def on_complete(env)
23
23
  return unless enabled?
24
- return unless env.body.kind_of?(Hash)
24
+ return unless env.body.is_a?(Hash)
25
25
 
26
26
  data = env.body.dig("response", "data") || env.body.dig(:response, :data)
27
27
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FmRest
4
- VERSION = "0.18.0.rc3"
4
+ VERSION = "0.18.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fmrest-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0.rc3
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Carbajal
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-08 00:00:00.000000000 Z
11
+ date: 2021-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -104,9 +104,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
104
  version: '0'
105
105
  required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - ">"
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
- version: 1.3.1
109
+ version: '0'
110
110
  requirements: []
111
111
  rubygems_version: 3.2.3
112
112
  signing_key: