Class: Einvoicing::PPF::Client
- Inherits:
-
Object
- Object
- Einvoicing::PPF::Client
- Defined in:
- lib/einvoicing/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) ⇒ 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) ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 22 |
# File 'lib/einvoicing/ppf/client.rb', line 16 def initialize(client_id:, client_secret:, sandbox: true) @client_id = client_id @client_secret = client_secret @sandbox = sandbox @token = nil @token_expires_at = nil end |
Instance Attribute Details
#sandbox ⇒ Object (readonly)
Returns the value of attribute sandbox.
14 15 16 |
# File 'lib/einvoicing/ppf/client.rb', line 14 def sandbox @sandbox end |
Instance Method Details
#access_token ⇒ Object
Returns current access token, refreshing if expired.
25 26 27 28 |
# File 'lib/einvoicing/ppf/client.rb', line 25 def access_token refresh_token! if token_expired? @token end |
#find_structure(siret:) ⇒ Object
POST /v1/rechercher/structure — find structure by SIRET, returns idStructureCPP.
31 32 33 |
# File 'lib/einvoicing/ppf/client.rb', line 31 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).
36 37 38 |
# File 'lib/einvoicing/ppf/client.rb', line 36 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.
41 42 43 44 45 46 |
# File 'lib/einvoicing/ppf/client.rb', line 41 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.
50 51 52 |
# File 'lib/einvoicing/ppf/client.rb', line 50 def submit_invoice(invoice_hash) post("/v1/soumettre/factures", invoice_hash) end |