Class: Dolibarr::Resource
- Inherits:
-
Object
- Object
- Dolibarr::Resource
- Defined in:
- lib/dolibarr/resource.rb
Overview
Base class for every business domain (invoices, payments, thirdparties, …).
It owns the two things every domain shares: reaching the raw transport
connection, and funnelling every dolibarr-api failure through the single
Client::Error surface. Restler quirks are absorbed here:
- an empty list is HTTP 404 → #collection returns
[](never raises); - a genuinely missing object is HTTP 404 → #one raises Client::NotFound;
- 403 → Client::Forbidden with an actionable message;
- anything else → Client::Error, the transport error kept as
#cause.
Domains talk to connection.call(..., type: nil) directly rather than the typed
sub-client gets, because those pin type: Models::Obj — a placeholder model that
drops the real payload. type: nil returns the parsed JSON untouched.
Direct Known Subclasses
Documents, Invoices, Payments, RecurringInvoices, SupplierInvoices, Thirdparties
Instance Method Summary collapse
-
#initialize(client) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(client) ⇒ Resource
Returns a new instance of Resource.
19 20 21 |
# File 'lib/dolibarr/resource.rb', line 19 def initialize(client) @client = client end |