Class: Einvoicing::Connect::FR::PPF::Client
- Inherits:
-
Object
- Object
- Einvoicing::Connect::FR::PPF::Client
- Defined in:
- lib/einvoicing/connect/fr/ppf/client.rb
Constant Summary collapse
- SANDBOX_OAUTH_URL =
"https://sandbox-oauth.piste.gouv.fr"- SANDBOX_API_URL =
"https://sandbox-api.piste.gouv.fr/cpro/factures"- PROD_OAUTH_URL =
"https://oauth.piste.gouv.fr"- PROD_API_URL =
"https://api.piste.gouv.fr/cpro/factures"
Instance Attribute Summary collapse
-
#sandbox ⇒ Object
readonly
Returns the value of attribute sandbox.
Instance Method Summary collapse
-
#access_token ⇒ Object
Returns current access token, refreshing if expired.
-
#find_structure(siret:) ⇒ Object
POST /v1/rechercher/structure — find structure by SIRET, returns idStructureCPP.
-
#get_structure(id_structure_cpp:) ⇒ Object
POST /v1/consulter/structure — get mandatory params (engagement, service codes).
-
#initialize(client_id:, client_secret:, sandbox: true, technical_login: nil, technical_password: nil) ⇒ Client
constructor
A new instance of Client.
-
#list_services(id_structure_cpp:, page: 1) ⇒ Object
POST /v1/rechercher/service/structure — list active services for a structure.
-
#submit_invoice(invoice_hash) ⇒ Object
POST /v1/soumettre/factures — submit an invoice.
Constructor Details
#initialize(client_id:, client_secret:, sandbox: true, technical_login: nil, technical_password: nil) ⇒ Client
Returns a new instance of Client.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/einvoicing/connect/fr/ppf/client.rb', line 18 def initialize(client_id:, client_secret:, sandbox: true, technical_login: nil, technical_password: nil) @client_id = client_id @client_secret = client_secret @sandbox = sandbox @technical_login = technical_login @technical_password = technical_password @token = nil @token_expires_at = nil end |
Instance Attribute Details
#sandbox ⇒ Object (readonly)
Returns the value of attribute sandbox.
16 17 18 |
# File 'lib/einvoicing/connect/fr/ppf/client.rb', line 16 def sandbox @sandbox end |
Instance Method Details
#access_token ⇒ Object
Returns current access token, refreshing if expired.
30 31 32 33 |
# File 'lib/einvoicing/connect/fr/ppf/client.rb', line 30 def access_token refresh_token! if token_expired? @token end |
#find_structure(siret:) ⇒ Object
POST /v1/rechercher/structure — find structure by SIRET, returns idStructureCPP.
36 37 38 |
# File 'lib/einvoicing/connect/fr/ppf/client.rb', line 36 def find_structure(siret:) post("/v1/rechercher/structure", { siret: siret }) end |
#get_structure(id_structure_cpp:) ⇒ Object
POST /v1/consulter/structure — get mandatory params (engagement, service codes).
41 42 43 |
# File 'lib/einvoicing/connect/fr/ppf/client.rb', line 41 def get_structure(id_structure_cpp:) post("/v1/consulter/structure", { idStructureCPP: id_structure_cpp }) end |
#list_services(id_structure_cpp:, page: 1) ⇒ Object
POST /v1/rechercher/service/structure — list active services for a structure.
46 47 48 49 50 51 |
# File 'lib/einvoicing/connect/fr/ppf/client.rb', line 46 def list_services(id_structure_cpp:, page: 1) post("/v1/rechercher/service/structure", { idStructureCPP: id_structure_cpp, pageResultat: page }) end |
#submit_invoice(invoice_hash) ⇒ Object
POST /v1/soumettre/factures — submit an invoice. invoice_hash: Hash matching the Chorus Pro invoice schema.
55 56 57 |
# File 'lib/einvoicing/connect/fr/ppf/client.rb', line 55 def submit_invoice(invoice_hash) post("/v1/soumettre/factures", invoice_hash) end |