Constructor
new FixleClient(config)
Example
const client = new FixleClient({
apiUrl: 'https://api.fixle.com',
apiKey: 'your-api-key'
});
// Create a property
const propertyId = await client.findOrCreateProperty('123 Main St, Portland, OR 97201');
// Create an inspection
await client.createInspection(propertyId, 12345);
// Add an appliance
await client.createAppliance(propertyId, {
item_name: 'Water Heater',
section_name: 'Basement',
brand: 'Rheem',
model: 'XE50M06ST45U1',
serial_number: 'ABC123',
manufacturer: 'Rheem Manufacturing',
year: '2020'
});
Parameters:
| Name | Type | Description |
|---|---|---|
config |
Configuration options including API URL and key |
Methods
(async) createAppliance(propertyId, appliance)
- Description:
Creates an appliance record for a property
The appliance is associated with a master appliance type (currently uses ID 1 as placeholder). In production, you should implement logic to find or create the appropriate master appliance.
- Source:
Example
await client.createAppliance(123, {
item_name: 'Water Heater',
section_name: 'Basement',
brand: 'Rheem',
model: 'XE50M06ST45U1',
serial_number: 'ABC123456',
manufacturer: 'Rheem Manufacturing',
year: '2020'
});
Parameters:
| Name | Type | Description |
|---|---|---|
propertyId |
ID of the property to add the appliance to |
|
appliance |
Appliance information including brand, model, serial number, etc. |
Throws:
Error if the API request fails or the property doesn't exist
Returns:
Promise that resolves when the appliance is created
(async) createInspection(propertyId, inspectionId)
Example
await client.createInspection(123, 45678);
console.log('Inspection created successfully');
Parameters:
| Name | Type | Description |
|---|---|---|
propertyId |
ID of the property to associate the inspection with |
|
inspectionId |
External inspection ID (from the source system) |
Throws:
Error if the API request fails or the property doesn't exist
Returns:
Promise that resolves when the inspection is created
(async) findOrCreateProperty(address)
- Description:
Finds an existing property or creates a new one based on the address
The address is parsed into street address, city, state, and zip code components. Currently always creates a new property; future versions may search for existing properties first.
- Source:
Example
const propertyId = await client.findOrCreateProperty('123 Main St, Portland, OR 97201');
console.log(`Created property with ID: ${propertyId}`);
Parameters:
| Name | Type | Description |
|---|---|---|
address |
Full address string (e.g., "123 Main St, Portland, OR 97201") |
Throws:
Error if the API request fails
Returns:
Promise resolving to the property ID