factpulse 2.0.13 → 2.0.14

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: 13f4495a8ee788cb3614bbbeb3c6b65c744f877b9abd114090c003b0230768f5
4
- data.tar.gz: 437f910edd71aec05f4a5429c129607b9062639833f80df08200d6eccbcc68e9
3
+ metadata.gz: d90e8924df4d27436352163dd3853a74d4c1bad90e590dd630cf630badf9ffb0
4
+ data.tar.gz: 6665e587c4be3a018c39e8ea4cd15c0e7f9c8dd854394503f6674218b63cf815
5
5
  SHA512:
6
- metadata.gz: 376bf0dd3b86dba80279206b3551167e78e1144244fa702799eb0b99f84e9c55b48d7c50d70cba10a7edf5bc9b8181470a95fe04b665f13e2b78640d52b63281
7
- data.tar.gz: 194e1316ca40a8e14ebab4998e2dd54a5e2157aeb040260e898d8cfe3d604ca5d728f644c1370179cd480a96801ceffafb761bd89f09d42f0a9233ed1829aedf
6
+ metadata.gz: 9aea5a50e588d5a0e09c4c1ee9dcb9eb54a4ec540f83478eb44351b39f58259effed82a748baf9cc608779ae3a2561d55a165f6fac1ad2a75698559377f33537
7
+ data.tar.gz: 481ddb35c466d369263b95452e6a868fd8771cbbb1400d7a19cfae50186fc12ddd11ee1f8d0cc13c9c0e5bb79fef8b18e393f6b2fd356397b67b0a2287e15588
data/CHANGELOG.md CHANGED
@@ -7,7 +7,7 @@ et ce projet adhère au [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ## [2.0.13] - 2025-11-26
10
+ ## [2.0.14] - 2025-11-26
11
11
 
12
12
  ### Added
13
13
  - Version initiale du SDK ruby
@@ -24,5 +24,5 @@ et ce projet adhère au [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
24
24
  - Guide d'authentification JWT
25
25
  - Configuration avancée (timeout, proxy, debug)
26
26
 
27
- [Unreleased]: https://github.com/factpulse/sdk-ruby/compare/v2.0.13...HEAD
28
- [2.0.13]: https://github.com/factpulse/sdk-ruby/releases/tag/v2.0.13
27
+ [Unreleased]: https://github.com/factpulse/sdk-ruby/compare/v2.0.14...HEAD
28
+ [2.0.14]: https://github.com/factpulse/sdk-ruby/releases/tag/v2.0.14
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- factpulse (2.0.13)
4
+ factpulse (2.0.14)
5
5
  typhoeus (~> 1.0, >= 1.0.1)
6
6
 
7
7
  GEM
@@ -3,13 +3,90 @@ require 'net/http'; require 'json'; require 'base64'; require 'uri'; require 'se
3
3
 
4
4
  module FactPulse
5
5
  module Helpers
6
+ # Credentials Chorus Pro pour le mode Zero-Trust.
7
+ # Ces credentials sont passés dans chaque requête et ne sont jamais stockés côté serveur.
8
+ class ChorusProCredentials
9
+ attr_reader :piste_client_id, :piste_client_secret, :chorus_pro_login, :chorus_pro_password, :sandbox
10
+ def initialize(piste_client_id:, piste_client_secret:, chorus_pro_login:, chorus_pro_password:, sandbox: true)
11
+ @piste_client_id, @piste_client_secret = piste_client_id, piste_client_secret
12
+ @chorus_pro_login, @chorus_pro_password, @sandbox = chorus_pro_login, chorus_pro_password, sandbox
13
+ end
14
+ def to_h
15
+ { 'piste_client_id' => @piste_client_id, 'piste_client_secret' => @piste_client_secret,
16
+ 'chorus_pro_login' => @chorus_pro_login, 'chorus_pro_password' => @chorus_pro_password, 'sandbox' => @sandbox }
17
+ end
18
+ end
19
+
20
+ # Credentials AFNOR PDP pour le mode Zero-Trust.
21
+ # Ces credentials sont passés dans chaque requête et ne sont jamais stockés côté serveur.
22
+ class AFNORCredentials
23
+ attr_reader :client_id, :client_secret, :flow_service_url
24
+ def initialize(client_id:, client_secret:, flow_service_url:)
25
+ @client_id, @client_secret, @flow_service_url = client_id, client_secret, flow_service_url
26
+ end
27
+ def to_h
28
+ { 'client_id' => @client_id, 'client_secret' => @client_secret, 'flow_service_url' => @flow_service_url }
29
+ end
30
+ end
31
+
32
+ # Helpers pour créer des montants totaux simplifiés.
33
+ module MontantHelpers
34
+ def self.montant(value)
35
+ return '0.00' if value.nil?
36
+ return format('%.2f', value) if value.is_a?(Numeric)
37
+ value.is_a?(String) ? value : '0.00'
38
+ end
39
+
40
+ def self.montant_total(ht, tva, ttc, a_payer, remise_ttc: nil, motif_remise: nil, acompte: nil)
41
+ result = {
42
+ 'montantHtTotal' => montant(ht), 'montantTva' => montant(tva),
43
+ 'montantTtcTotal' => montant(ttc), 'montantAPayer' => montant(a_payer)
44
+ }
45
+ result['montantRemiseGlobaleTtc'] = montant(remise_ttc) if remise_ttc
46
+ result['motifRemiseGlobaleTtc'] = motif_remise if motif_remise
47
+ result['acompte'] = montant(acompte) if acompte
48
+ result
49
+ end
50
+
51
+ def self.ligne_de_poste(numero, denomination, quantite, montant_unitaire_ht, montant_ligne_ht,
52
+ taux_tva: '20.00', unite: 'C62', **options)
53
+ result = {
54
+ 'numero' => numero, 'denomination' => denomination,
55
+ 'quantite' => montant(quantite), 'montantUnitaireHt' => montant(montant_unitaire_ht),
56
+ 'montantTotalLigneHt' => montant(montant_ligne_ht), 'tauxTva' => montant(taux_tva), 'unite' => unite
57
+ }
58
+ result['montantTvaLigne'] = montant(options[:montant_tva_ligne]) if options[:montant_tva_ligne]
59
+ result['montantRemiseHt'] = montant(options[:montant_remise_ht]) if options[:montant_remise_ht]
60
+ result['codeRaisonReduction'] = options[:code_raison_remise] if options[:code_raison_remise]
61
+ result['motifRemise'] = options[:motif_remise] if options[:motif_remise]
62
+ result['description'] = options[:description] if options[:description]
63
+ result
64
+ end
65
+
66
+ def self.ligne_de_tva(taux, base_ht, montant_tva, categorie: 'S', motif_exoneration: nil)
67
+ result = {
68
+ 'tauxTva' => montant(taux), 'montantBaseHt' => montant(base_ht),
69
+ 'montantTva' => montant(montant_tva), 'categorieTva' => categorie
70
+ }
71
+ result['motifExoneration'] = motif_exoneration if motif_exoneration
72
+ result
73
+ end
74
+ end
75
+
6
76
  class FactPulseClient
7
- def initialize(email:, password:, api_url: nil, client_uid: nil, polling_interval: nil, polling_timeout: nil, max_retries: nil)
77
+ attr_reader :chorus_credentials, :afnor_credentials
78
+
79
+ def initialize(email:, password:, api_url: nil, client_uid: nil, chorus_credentials: nil, afnor_credentials: nil,
80
+ polling_interval: nil, polling_timeout: nil, max_retries: nil)
8
81
  @email, @password = email, password; @api_url = (api_url || 'https://factpulse.fr').chomp('/')
9
82
  @client_uid, @polling_interval, @polling_timeout, @max_retries = client_uid, polling_interval || 2000, polling_timeout || 120000, max_retries || 1
83
+ @chorus_credentials, @afnor_credentials = chorus_credentials, afnor_credentials
10
84
  @access_token = @refresh_token = @token_expires_at = nil
11
85
  end
12
86
 
87
+ def chorus_credentials_for_api; @chorus_credentials&.to_h; end
88
+ def afnor_credentials_for_api; @afnor_credentials&.to_h; end
89
+
13
90
  def ensure_authenticated(force_refresh: false)
14
91
  now = (Time.now.to_f * 1000).to_i
15
92
  if force_refresh || @access_token.nil? || (@token_expires_at && now >= @token_expires_at)
@@ -40,7 +117,7 @@ module FactPulse
40
117
  end
41
118
  end
42
119
 
43
- def self.format_montant(m); m.nil? ? '0.00' : (m.is_a?(Numeric) ? format('%.2f', m) : (m.is_a?(String) ? m : '0.00')); end
120
+ def self.format_montant(m); MontantHelpers.montant(m); end
44
121
 
45
122
  private
46
123
  def http_post(uri, payload)
@@ -4,6 +4,10 @@ require_relative 'helpers/client'
4
4
  module FactPulse
5
5
  module Helpers
6
6
  def self.create_client(**opts); FactPulseClient.new(**opts); end
7
- def self.format_montant(m); FactPulseClient.format_montant(m); end
7
+ def self.format_montant(m); MontantHelpers.montant(m); end
8
+ def self.montant(m); MontantHelpers.montant(m); end
9
+ def self.montant_total(*args, **kwargs); MontantHelpers.montant_total(*args, **kwargs); end
10
+ def self.ligne_de_poste(*args, **kwargs); MontantHelpers.ligne_de_poste(*args, **kwargs); end
11
+ def self.ligne_de_tva(*args, **kwargs); MontantHelpers.ligne_de_tva(*args, **kwargs); end
8
12
  end
9
13
  end
@@ -11,5 +11,5 @@ Generator version: 7.18.0-SNAPSHOT
11
11
  =end
12
12
 
13
13
  module FactPulse
14
- VERSION = '2.0.13'
14
+ VERSION = '2.0.14'
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factpulse
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.13
4
+ version: 2.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenAPI-Generator