cpro-client 0.2.1 → 0.2.2

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: 40f1e1557770b6ee03af92e419c95e19071d2b4a53848db46cdd76e409802eb6
4
- data.tar.gz: 2f75110a47a4954f8151fe5d5cd85daa17e4d3e8b924512a96eab899865faf41
3
+ metadata.gz: dc05774f720962053cfcd6f9f11b4fd9521f704d9f40d4e5178a439c37b03ffd
4
+ data.tar.gz: 63dc3902ac1d84c6bb49f93a0d90b4f1e5035708c69c0a635deef4475bba63d1
5
5
  SHA512:
6
- metadata.gz: 7e479ee8731fcd352635ade84a00ffc1a22901ce9d986d4ee47b26a65bc4313a746fbc40b6e7917191aab6002d2b95e0409b230cebae81e9ff952253479ff0e4
7
- data.tar.gz: 9a75779dfefdd3a2b1e1ff5f156cc051969554cb7ac557bdc24c2c677ac0697d5f754f57274b38374ac27969b2af7011385d62f3a672f2cac518844c55fdf416
6
+ metadata.gz: e627c2faa3a057a63fc84c3fe37aca1fd3a2020175a05c0e40a0216958ff28686460d366eeae61476480a191a0f2bfcfb4eb3cf576aec3c8f0743e771f9143a7
7
+ data.tar.gz: 95a17ff0f1069454907f6e415b14fdecdf75acdfd959f5d5f30dfcdf8c7532d6f56f0586d7f7fe258234a7fe28de14f6813cfbbd612201579550cbdeae9a9b3b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cpro-client (0.2.1)
4
+ cpro-client (0.2.2)
5
5
  faraday (>= 0.9, < 3.0)
6
6
 
7
7
  GEM
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Cpro
6
+ module Middleware
7
+ # JSON middleware added for 0.9 Faraday compatibility
8
+ class EncodeJson < Faraday::Middleware
9
+ CONTENT_TYPE = "Content-Type"
10
+ MIME = "application/json"
11
+
12
+ def call(env)
13
+ encode(env) unless env.body.nil? || env.body.is_a?(String)
14
+ @app.call(env)
15
+ end
16
+
17
+ private
18
+
19
+ def encode(env)
20
+ env.request_headers[CONTENT_TYPE] ||= MIME
21
+ env.body = JSON.generate(env.body)
22
+ end
23
+ end
24
+
25
+ class ParseJson < Faraday::Middleware
26
+ def initialize(app, content_type: /\bjson$/)
27
+ super(app)
28
+ @content_type = content_type
29
+ end
30
+
31
+ def call(env)
32
+ @app.call(env).on_complete { |response| response.body = parse(response) }
33
+ end
34
+
35
+ private
36
+
37
+ def parse(env)
38
+ body = env.body
39
+ return body unless json?(env) && body.is_a?(String) && !body.strip.empty?
40
+
41
+ JSON.parse(body)
42
+ rescue JSON::ParserError
43
+ body
44
+ end
45
+
46
+ def json?(env)
47
+ type = env.response_headers && env.response_headers["content-type"]
48
+ type.to_s.split(";").first.to_s.strip.match?(@content_type)
49
+ end
50
+ end
51
+ end
52
+ end
data/lib/cpro/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cpro
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpro-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hôtentic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-08-28 00:00:00.000000000 Z
11
+ date: 2026-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -78,6 +78,7 @@ files:
78
78
  - lib/cpro/errors.rb
79
79
  - lib/cpro/facturx.rb
80
80
  - lib/cpro/middleware/authentication.rb
81
+ - lib/cpro/middleware/json.rb
81
82
  - lib/cpro/middleware/raise_error.rb
82
83
  - lib/cpro/resources/annuaire.rb
83
84
  - lib/cpro/resources/base.rb