pennylane-client 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a12edf1a99b16ac791ed08bab5a859674832996f5e272f04291dcd662f687a85
4
+ data.tar.gz: 7c3f8372674c76c721500494a96dab63b95feae0a405a13674f5c14280f8e4fb
5
+ SHA512:
6
+ metadata.gz: 874a9901d154747bf9bb0b2c4b4e155ca63f8d0f7336801802dc41ac712d1ccd81f8b392cba67f67ad22a674ccc54fe1de7eef7a6f5324016b9a094c418d7d69
7
+ data.tar.gz: bf570896b3893262744a3db6b8bce9b7beba5db8ac69c567a2ec2c4cd74232b8b66fc24c22d0da68a2b8f06a62d01c5097a9aa5e0dda76b0eff351778c765a61
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /.idea/
10
+ /local/
11
+ *.gem
data/.rubocop.yml ADDED
@@ -0,0 +1,47 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+ NewCops: enable
4
+ SuggestExtensions: false
5
+
6
+ Style/StringLiterals:
7
+ Enabled: true
8
+ EnforcedStyle: double_quotes
9
+
10
+ Style/StringLiteralsInInterpolation:
11
+ Enabled: true
12
+ EnforcedStyle: double_quotes
13
+
14
+ Style/Documentation:
15
+ Enabled: false
16
+
17
+ Layout/LineLength:
18
+ Max: 120
19
+
20
+ # Poser rubygems_mfa_required exigerait d'activer la MFA sur le compte RubyGems qui publie ;
21
+ # ce n'est pas le mode de publication retenu ici.
22
+ Gemspec/RequireMFA:
23
+ Enabled: false
24
+
25
+ # Le fichier doit porter le nom de la gem pour que `require "pennylane-client"` fonctionne.
26
+ Naming/FileName:
27
+ Exclude:
28
+ - "lib/pennylane-client.rb"
29
+
30
+ # Un test lisible enchaîne les assertions : ces métriques n'y ont pas de sens.
31
+ Metrics:
32
+ Exclude:
33
+ - "test/**/*"
34
+
35
+ Metrics/AbcSize:
36
+ Max: 20
37
+
38
+ # Les mots-clés sont auto-documentés : les compter revient à pénaliser une signature claire.
39
+ Metrics/ParameterLists:
40
+ CountKeywordArgs: false
41
+
42
+ # Une classe qui transpose une spécification champ à champ dépasse légitimement 100 lignes.
43
+ Metrics/ClassLength:
44
+ Max: 180
45
+
46
+ Metrics/MethodLength:
47
+ Max: 20
data/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ ## [Unreleased]
2
+
3
+ ### Ajouté
4
+ - `Pennylane.client(token:)` : un client par token, donc par société Pennylane.
5
+ - `CustomerInvoices#import` dépose une facture Factur-X, rattachée au client `customer_id`. Un
6
+ fichier déjà déposé lève une `Pennylane::DuplicateInvoiceError`, dont `invoice_id` désigne la
7
+ facture existante.
8
+ - `CustomerInvoices#find`, `#find_by_invoice_number`, `#find_many`, `#list` et `#all` lisent et
9
+ recherchent les factures clients ; filtres, tri et taille de page sont vérifiés avant l'appel.
10
+ `find_by_invoice_number` rend la plus ancienne facture quand plusieurs portent le même numéro.
11
+ - `CustomerInvoices#payments` et `#matched_transactions` détaillent les encaissements d'une facture.
12
+ - `CustomerInvoices#settlement` résume le règlement d'une facture : montant encaissé, reste à payer,
13
+ paiements datés, cohérence entre les deux, et facture marquée payée sans encaissement.
14
+ - `CustomerInvoices#changes` parcourt le journal des changements des quatre dernières semaines.
15
+ - `Customers#find_by_external_reference`, `#find_by_reg_no`, `#find`, `#list` et `#all` retrouvent
16
+ les clients ; `Customers#create` crée un client `company` ou `individual`, attributs vérifiés
17
+ avant l'appel.
18
+ - Les requêtes refusées en 429 sont rejouées après le délai annoncé, `rate_limit_retries` fois au
19
+ plus.
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at jbvilain@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in pennylane-client.gemspec
6
+ gemspec
7
+
8
+ gem "minitest", "~> 5.0"
9
+ gem "rake", "~> 13.0"
10
+ gem "rubocop", "~> 1.7"
11
+ gem "vcr", "~> 6.0"
12
+ gem "webmock", "~> 3.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pennylane-client (0.1.0)
5
+ faraday (>= 0.9, < 3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.9.0)
11
+ public_suffix (>= 2.0.2, < 8.0)
12
+ ast (2.4.3)
13
+ base64 (0.3.0)
14
+ bigdecimal (4.1.2)
15
+ crack (1.0.1)
16
+ bigdecimal
17
+ rexml
18
+ faraday (2.8.1)
19
+ base64
20
+ faraday-net_http (>= 2.0, < 3.1)
21
+ ruby2_keywords (>= 0.0.4)
22
+ faraday-net_http (3.0.2)
23
+ hashdiff (1.2.1)
24
+ json (2.21.2)
25
+ language_server-protocol (3.17.0.6)
26
+ lint_roller (1.1.0)
27
+ minitest (5.26.1)
28
+ parallel (1.28.0)
29
+ parser (3.3.12.0)
30
+ ast (~> 2.4.1)
31
+ racc
32
+ prism (1.9.0)
33
+ public_suffix (5.1.1)
34
+ racc (1.8.1)
35
+ rainbow (3.1.1)
36
+ rake (13.4.2)
37
+ regexp_parser (2.12.0)
38
+ rexml (3.4.4)
39
+ rubocop (1.89.0)
40
+ json (~> 2.3)
41
+ language_server-protocol (~> 3.17.0.2)
42
+ lint_roller (~> 1.1.0)
43
+ parallel (>= 1.10)
44
+ parser (>= 3.3.0.2)
45
+ rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 2.9.3, < 3.0)
47
+ rubocop-ast (>= 1.49.0, < 2.0)
48
+ ruby-progressbar (~> 1.7)
49
+ unicode-display_width (>= 2.4.0, < 4.0)
50
+ rubocop-ast (1.50.0)
51
+ parser (>= 3.3.7.2)
52
+ prism (~> 1.7)
53
+ ruby-progressbar (1.13.0)
54
+ ruby2_keywords (0.0.5)
55
+ unicode-display_width (3.2.0)
56
+ unicode-emoji (~> 4.1)
57
+ unicode-emoji (4.2.0)
58
+ vcr (6.4.0)
59
+ webmock (3.26.2)
60
+ addressable (>= 2.8.0)
61
+ crack (>= 0.3.2)
62
+ hashdiff (>= 0.4.0, < 2.0.0)
63
+
64
+ PLATFORMS
65
+ arm64-darwin-25
66
+ x86_64-darwin-21
67
+
68
+ DEPENDENCIES
69
+ minitest (~> 5.0)
70
+ pennylane-client!
71
+ rake (~> 13.0)
72
+ rubocop (~> 1.7)
73
+ vcr (~> 6.0)
74
+ webmock (~> 3.0)
75
+
76
+ BUNDLED WITH
77
+ 2.4.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Jean-Baptiste Vilain
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,224 @@
1
+ # pennylane-client
2
+
3
+ Client Ruby de l'[API Company v2](https://pennylane.readme.io/) de Pennylane, destiné à une
4
+ application hôte qui émet ses factures au format Factur-X.
5
+
6
+ La gem couvre le dépôt d'une facture Factur-X sur Pennylane et le suivi des factures déposées,
7
+ notamment la réception des paiements. L'application hôte met à jour ses propres données à partir
8
+ de ce suivi. L'envoi des factures à la plateforme agréée (PA) n'est pas couvert.
9
+
10
+ ## Installation
11
+
12
+ ```ruby
13
+ gem "pennylane-client"
14
+ ```
15
+
16
+ Faraday est la seule dépendance d'exécution, de la version 0.9 à la version 2 incluse. La suite est
17
+ vérifiée sur 0.9.2, 1.10.4 et 2.8.1 ; on teste un plancher avec `gem "faraday", "0.9.2"` ajouté au
18
+ `Gemfile` avant `bundle install`.
19
+
20
+ ## Configuration
21
+
22
+ Chaque société Pennylane a son propre token d'API, créé dans *Paramètres > Connectivité >
23
+ Développeurs*. Il lui faut le droit `customer_invoices:all` (*Gestion des factures clients*), et
24
+ `customers:all` (*Gestion des clients*) pour créer les clients. Les droits d'un token ne se modifient
25
+ plus après sa création. Le client se construit par token, c'est-à-dire par entité :
26
+
27
+ ```ruby
28
+ client = Pennylane.client(token: entite.pennylane_token)
29
+ ```
30
+
31
+ Les réglages communs sont tous facultatifs :
32
+
33
+ ```ruby
34
+ Pennylane.configure do |config|
35
+ config.timeout = 30 # secondes
36
+ config.open_timeout = 10
37
+ config.rate_limit_retries = 2 # rejeux après un 429, 0 pour les désactiver
38
+ end
39
+ ```
40
+
41
+ Pennylane accepte 25 requêtes par fenêtre de 5 secondes et par token. Une requête refusée en 429 est
42
+ rejouée après le délai annoncé par l'API, `rate_limit_retries` fois au plus.
43
+
44
+ ## Clients
45
+
46
+ Une facture se dépose au nom d'un client Pennylane. La référence externe, unique dans une société,
47
+ fait le lien avec le client de l'application hôte :
48
+
49
+ ```ruby
50
+ customer = client.customers.find_by_external_reference("client-812") ||
51
+ client.customers.create(
52
+ customer_type: :company,
53
+ name: "SARL COTEAUX ET COMPAGNIE",
54
+ reg_no: "812345676",
55
+ vat_number: "FR19812345676",
56
+ billing_address: { address: "123 avenue des Alpages", postal_code: "74000", city: "Annecy",
57
+ country_alpha2: "FR" },
58
+ external_reference: "client-812"
59
+ )
60
+ ```
61
+
62
+ Un client `individual` prend `first_name` et `last_name` au lieu de `name`, et n'a ni `reg_no` ni
63
+ `vat_number`. Les attributs sont vérifiés avant l'appel : l'API refuse un attribut inconnu ou
64
+ manquant sans dire lequel. Une référence externe déjà prise lève une `Pennylane::RequestError`
65
+ (422).
66
+
67
+ `find_by_reg_no` retrouve un client par son SIREN ; `find`, `list` et `all` fonctionnent comme pour
68
+ les factures, avec les filtres `id`, `customer_type`, `ledger_account_id`, `name`,
69
+ `external_reference`, `reg_no` et `emails`, et un tri sur `id`.
70
+
71
+ Pennylane rend les champs texte non renseignés en chaînes vides (`reg_no`, `vat_number`, `phone`,
72
+ adresse de livraison…), pas en `nil`.
73
+
74
+ ## Déposer une facture
75
+
76
+ ```ruby
77
+ invoices = client.customer_invoices
78
+
79
+ invoice_id = invoices.find_by_invoice_number("5-2026-0006")&.id
80
+ invoice_id ||= begin
81
+ invoices.import("factures/5-2026-0006.pdf", customer_id: customer.id).id
82
+ rescue Pennylane::DuplicateInvoiceError => e
83
+ e.invoice_id # ce fichier a déjà été déposé
84
+ end
85
+ ```
86
+
87
+ `import` accepte un chemin ou un IO ; un IO sans chemin demande `filename:`. `customer_id` est
88
+ l'identifiant du client dans Pennylane.
89
+
90
+ Pennylane refuse un fichier déjà déposé et donne l'identifiant de la facture existante : un dépôt
91
+ interrompu avant sa réponse peut donc être rejoué sans risque. Mais il ne reconnaît le doublon qu'au
92
+ fichier : un PDF régénéré pour une facture déjà déposée est accepté, et crée une seconde facture de
93
+ même numéro. D'où la recherche par numéro avant le dépôt ; si deux factures portent le même numéro,
94
+ `find_by_invoice_number` rend la plus ancienne.
95
+
96
+ Pennylane lit le fichier en différé, en une seconde environ d'après la mesure en sandbox. Juste
97
+ après `import`, la facture n'a encore ni numéro, ni montant, ni client, et `find_by_invoice_number`
98
+ ne la trouve pas. Enregistrez l'identifiant dès le retour de l'appel.
99
+
100
+ Une facture importée arrive au statut `incomplete`, son écriture comptable étant à valider dans
101
+ Pennylane. Le numéro, les dates et les montants sont repris du Factur-X.
102
+
103
+ ## Suivre les factures
104
+
105
+ ```ruby
106
+ invoice = invoices.find(imported.id)
107
+
108
+ invoice.paid? # facture acquittée
109
+ invoice.remaining_amount_with_tax # BigDecimal
110
+ invoice.schematron_validation_status # "pending", "valid" ou "invalid"
111
+ ```
112
+
113
+ `status` ne suit pas toujours : mesuré en sandbox, il est resté à `"paid"` sur une facture redevenue
114
+ partiellement payée. Lisez `paid?` et le reste à payer.
115
+
116
+ `find_many` relit plusieurs factures en groupant les appels par cent :
117
+
118
+ ```ruby
119
+ invoices.find_many(ids).each { |invoice| ... }
120
+ ```
121
+
122
+ Le journal des changements donne les factures créées, modifiées ou supprimées depuis un instant, du
123
+ plus ancien au plus récent. Pennylane ne le conserve que quatre semaines : au-delà, l'appel lève une
124
+ `Pennylane::RequestError` (422).
125
+
126
+ ```ruby
127
+ changes = invoices.changes(since: last_sync).to_a
128
+ updated = invoices.find_many(changes.reject(&:delete?).map(&:id))
129
+ last_sync = changes.last.processed_at if changes.any?
130
+ ```
131
+
132
+ Le journal couvre toutes les factures de la société, y compris celles que l'application hôte n'a
133
+ pas déposées.
134
+
135
+ ## Encaissements
136
+
137
+ ```ruby
138
+ settlement = invoices.settlement(invoice) # une facture déjà lue, ou son identifiant
139
+
140
+ settlement.paid? # facture acquittée
141
+ settlement.settled_amount # montant encaissé : total moins reste à payer
142
+ settlement.remaining_amount # reste à payer
143
+ settlement.payments.each do |payment|
144
+ payment.date # date de la transaction
145
+ payment.currency_amount # son montant
146
+ end
147
+ settlement.consistent? # les paiements expliquent-ils exactement le montant encaissé ?
148
+ settlement.marked_paid? # payée sans encaissement pour le reliquat
149
+ ```
150
+
151
+ Les paiements sont les transactions bancaires rapprochées de la facture dans Pennylane, virements
152
+ et chèques compris, du plus ancien au plus récent. Un paiement n'apparaît qu'une fois rapproché.
153
+
154
+ Deux cas méritent l'attention de l'application hôte :
155
+
156
+ - **`consistent?` faux.** Le montant d'une transaction rapprochée est celui de la transaction
157
+ entière : un virement qui règle plusieurs factures apparaît sur chacune pour son montant total. La
158
+ somme des paiements dépasse alors le montant encaissé, qui reste juste.
159
+ - **`marked_paid?` vrai.** « Marquer comme payée », dans Pennylane, déclare la facture payée sans
160
+ enregistrer de paiement ni toucher au reste à payer. Aucune date ni aucun montant n'existe pour ce
161
+ reliquat.
162
+
163
+ `settlement` lit la facture si on lui passe un identifiant, puis ses transactions : un ou deux
164
+ appels. Après `find_many`, passez-lui les factures déjà lues.
165
+
166
+ `invoices.payments(id)` liste à part les paiements passés par les moyens de paiement de Pennylane
167
+ (Qonto, Stripe, GoCardless, lien de paiement).
168
+
169
+ ## Rechercher
170
+
171
+ ```ruby
172
+ invoices.list(filters: { customer_id: 42, date: { gteq: Date.new(2026, 1, 1) } }, sort: "-date", limit: 50)
173
+ invoices.all(filters: { customer_id: 42, draft: false }).each { |invoice| ... }
174
+ ```
175
+
176
+ `list` rend une page ; `all` parcourt toutes les pages à la demande. Une valeur nue vaut `eq`, les
177
+ autres opérateurs se passent en hash. Champs, opérateurs, tri et taille de page sont vérifiés avant
178
+ l'appel :
179
+
180
+ | Champ | Opérateurs |
181
+ |---|---|
182
+ | `id`, `date`, `customer_id`, `billing_subscription_id`, `quote_id` | `lt` `lteq` `gt` `gteq` `eq` `not_eq` `in` `not_in` |
183
+ | `invoice_number`, `flow_id` | `eq` `not_eq` `in` `not_in` |
184
+ | `draft`, `credit_note`, `external_reference` | `eq` |
185
+ | `category_id` | `in` |
186
+
187
+ Le tri porte sur `id` ou `date`, préfixé de `-` pour l'ordre décroissant.
188
+
189
+ ## Erreurs
190
+
191
+ Toutes les erreurs de la gem descendent de `Pennylane::Error`. Un argument invalide lève une
192
+ `ArgumentError` avant tout appel.
193
+
194
+ | Erreur | Cas |
195
+ |---|---|
196
+ | `Pennylane::ConfigurationError` | token absent |
197
+ | `Pennylane::RequestError` | 400, 422 |
198
+ | `Pennylane::AuthenticationError` | 401 : token invalide ou expiré |
199
+ | `Pennylane::AuthorizationError` | 403 : droit manquant sur le token |
200
+ | `Pennylane::NotFoundError` | 404 |
201
+ | `Pennylane::ConflictError` | 409 |
202
+ | `Pennylane::DuplicateInvoiceError` | 409 sur `import` : fichier déjà déposé ; `invoice_id` désigne la facture existante |
203
+ | `Pennylane::RateLimitError` | 429 après épuisement des rejeux ; `retry_after` en secondes |
204
+ | `Pennylane::ServerError` | 5xx |
205
+ | `Pennylane::ApiError` | tout autre statut d'erreur, et parente des précédentes |
206
+
207
+ Une `ApiError` porte `status`, `body` et, sur les erreurs de validation des paramètres, `code` et
208
+ `field`.
209
+
210
+ ## Tests
211
+
212
+ ```bash
213
+ bundle exec rake # tests unitaires (WebMock) et rubocop
214
+ bundle exec rake test:sandbox # rejoue hors ligne les cassettes VCR de la sandbox
215
+ PENNYLANE_RECORD=1 bundle exec rake test:sandbox # ré-enregistre depuis la sandbox
216
+ ```
217
+
218
+ Le ré-enregistrement lit `PENNYLANE_API_TOKEN` dans `local/credentials.env`. Les cassettes sont
219
+ nettoyées à l'écriture : le token et les en-têtes `Authorization` et `Set-Cookie` en sont retirés.
220
+ Relisez toute nouvelle cassette avant de la commiter.
221
+
222
+ ## Licence
223
+
224
+ Disponible en open source sous les termes de la [licence MIT](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"].exclude("test/sandbox/**/*_test.rb")
10
+ end
11
+
12
+ namespace :test do
13
+ desc "Rejoue les cassettes VCR enregistrées sur la sandbox Pennylane"
14
+ Rake::TestTask.new(:sandbox) do |t|
15
+ t.libs << "test"
16
+ t.libs << "lib"
17
+ t.test_files = FileList["test/sandbox/**/*_test.rb"]
18
+ end
19
+ end
20
+
21
+ require "rubocop/rake_task"
22
+
23
+ RuboCop::RakeTask.new
24
+
25
+ task default: %i[test rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "pennylane"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pennylane
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "pennylane"
data/lib/pennylane.rb ADDED
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+
5
+ require_relative "pennylane/version"
6
+ require_relative "pennylane/errors"
7
+ require_relative "pennylane/configuration"
8
+ require_relative "pennylane/middleware/encode_json"
9
+ require_relative "pennylane/middleware/parse_json"
10
+ require_relative "pennylane/middleware/raise_error"
11
+ require_relative "pennylane/middleware/rate_limit"
12
+ require_relative "pennylane/connection"
13
+ require_relative "pennylane/filter"
14
+ require_relative "pennylane/multipart"
15
+ require_relative "pennylane/entities/base"
16
+ require_relative "pennylane/entities/page"
17
+ require_relative "pennylane/entities/customer_invoice"
18
+ require_relative "pennylane/entities/payment"
19
+ require_relative "pennylane/entities/matched_transaction"
20
+ require_relative "pennylane/entities/change"
21
+ require_relative "pennylane/entities/e_invoice_import"
22
+ require_relative "pennylane/entities/customer"
23
+ require_relative "pennylane/entities/settlement"
24
+ require_relative "pennylane/resources/base"
25
+ require_relative "pennylane/resources/customer_invoices"
26
+ require_relative "pennylane/resources/customers"
27
+ require_relative "pennylane/client"
28
+
29
+ module Pennylane
30
+ class << self
31
+ def configuration
32
+ @configuration ||= Configuration.new
33
+ end
34
+
35
+ def configure
36
+ yield configuration
37
+ configuration
38
+ end
39
+
40
+ def client(token:)
41
+ Client.new(token: token, configuration: configuration)
42
+ end
43
+
44
+ def reset!
45
+ @configuration = nil
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/pennylane/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "pennylane-client"
7
+ spec.version = Pennylane::VERSION
8
+ spec.authors = ["Hôtentic"]
9
+ spec.email = ["contact@hotentic.com"]
10
+
11
+ spec.summary = "A ruby client for the Pennylane API"
12
+ spec.description = "Client Ruby de l'API Company v2 de Pennylane : dépôt de factures Factur-X, " \
13
+ "suivi des factures déposées et des paiements reçus."
14
+ spec.homepage = "https://hotentic.com"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = ">= 2.7.0"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/hotentic/pennylane-client"
20
+ spec.metadata["changelog_uri"] = "https://github.com/hotentic/pennylane-client/releases"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "faraday", ">= 0.9", "< 3.0"
32
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pennylane-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hôtentic
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2026-10-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0.9'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
+ description: 'Client Ruby de l''API Company v2 de Pennylane : dépôt de factures Factur-X,
34
+ suivi des factures déposées et des paiements reçus.'
35
+ email:
36
+ - contact@hotentic.com
37
+ executables: []
38
+ extensions: []
39
+ extra_rdoc_files: []
40
+ files:
41
+ - ".gitignore"
42
+ - ".rubocop.yml"
43
+ - CHANGELOG.md
44
+ - CODE_OF_CONDUCT.md
45
+ - Gemfile
46
+ - Gemfile.lock
47
+ - LICENSE.txt
48
+ - README.md
49
+ - Rakefile
50
+ - bin/console
51
+ - bin/setup
52
+ - lib/pennylane-client.rb
53
+ - lib/pennylane.rb
54
+ - lib/pennylane/version.rb
55
+ - pennylane-client.gemspec
56
+ homepage: https://hotentic.com
57
+ licenses:
58
+ - MIT
59
+ metadata:
60
+ homepage_uri: https://hotentic.com
61
+ source_code_uri: https://github.com/hotentic/pennylane-client
62
+ changelog_uri: https://github.com/hotentic/pennylane-client/releases
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 2.7.0
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubygems_version: 3.1.6
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: A ruby client for the Pennylane API
82
+ test_files: []