grape-idempotency 0.1.1 → 0.1.2

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: 3141f3c611358f6110a6176beea8857d316b4f2ba859b630385f3287ba68811f
4
- data.tar.gz: c367aa96495a47ac03243a31c79b0de163ccd2411cdcc7a673663b310083bfe5
3
+ metadata.gz: 615bae812ada064af7880ab0553e2608a7f3386ce8c54f437d6b5048e565f256
4
+ data.tar.gz: 587cc1a7c3a679e347a26a6971c68ece90c836abdade401aa412abedcc5a0f0d
5
5
  SHA512:
6
- metadata.gz: c42121192159af6be351e82e2da316b549d1a7be17203ec146af5809dcc10df4ca058728b78de916913aaa02d8689317a69f3c365fa67ddd83cc06ebab5c7f29
7
- data.tar.gz: 305b32f988ecac6a209019fffd42a95b34be5f938d9eff4c749e74acc48c95ad51c8c1439b26d80fd0938d7b6854f82fe53e29d43f283b40f29d83d8c41e51ff
6
+ metadata.gz: 44b64241b9f09c5a252a91eba6747da4f77cc590163410ed0396f49ac64016f86e8225c2730ed2cf9545764f3fc3098585e49493fe712e241dda2b7ee674140e
7
+ data.tar.gz: 3bd18355c4d7053e1d77b283e45c41f670c8a06048f8a37e3f3b1344a51dec704b659e1170e4e2f3fc85c4afd5431993e7272109fe9ac1acca2d112850528ce4
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All changes to `grape-idempotency` will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.1.2] - 2023-01-06
8
+
9
+ ### Fix
10
+
11
+ - Return correct original response when the endpoint returns a hash in the body
12
+
13
+
7
14
  ## [0.1.1] - 2023-01-06
8
15
 
9
16
  ### Fix
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Grape
4
4
  module Idempotency
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
  end
@@ -41,13 +41,11 @@ module Grape
41
41
  block.call
42
42
  end
43
43
 
44
- if response.is_a?(Hash)
45
- response = response[:message].to_json
46
- end
44
+ response = response[:message].to_json if is_an_error?(response)
47
45
 
48
46
  original_request_id = get_request_id(grape.request.headers)
49
47
  grape.header(ORIGINAL_REQUEST_HEADER, original_request_id)
50
- response
48
+ grape.body response
51
49
  ensure
52
50
  validate_config!
53
51
  unless cached_request
@@ -107,6 +105,10 @@ module Grape
107
105
  end
108
106
  end
109
107
 
108
+ def is_an_error?(response)
109
+ response.is_a?(Hash) && response.has_key?(:message) && response.has_key?(:headers) && response.has_key?(:status)
110
+ end
111
+
110
112
  def key(idempotency_key)
111
113
  "grape:idempotency:#{idempotency_key}"
112
114
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-idempotency
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Carlos García