Frameworks
Ruby on Rails — Intégration Scell.io
Pas de SDK Ruby — Faraday + service object
Scell.io ne publie PAS de SDK Ruby officiel. En Rails, créer un service object (`app/services/scell_client.rb`) qui encapsule `Faraday` (ou `HTTParty`) avec le header `X-API-Key`. Stocker la clé dans `Rails.application.credentials.scell.api_key` (chiffré). Pour async : ActiveJob + Sidekiq. Compatible Rails 7.1+ et Ruby 3.2+.
À retenir
- Pas de SDK Ruby officiel — `Faraday` ou `HTTParty`
- Service object dans `app/services/scell_client.rb`
- Clé via `Rails.application.credentials.scell`
- Async : ActiveJob + Sidekiq
- Compatible Rails 7.1+, Ruby 3.2+
Exemple de code
# app/services/scell_client.rb
require 'faraday'
class ScellClient
def initialize
@conn = Faraday.new(url: 'https://api.scell.io/api/v1') do |c|
c.headers['X-API-Key'] = Rails.application.credentials.scell.api_key
c.request :json
c.response :json
end
end
def create_invoice(buyer:, amount:)
@conn.post('/invoices', {
format: 'factur-x',
buyer: { name: buyer, is_individual: true },
lines: [{ description: 'Service', quantity: 1, unit_price: amount, vat_rate: 20.0 }]
}).body
end
end