Created
August 28, 2023 22:49
-
-
Save ryanmjacobs/d02ea53f08d96c1bcaffa3a908a293d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: TOPHAP | |
description: '' | |
host: EXCEL | |
api_set: {} | |
script: | |
content: |- | |
/** | |
* Fetch property details for an address string. | |
* Example: `console.log(await address('265 eagle ct', 'alamo', 'ca'))` | |
* @customfunction | |
* @param address | |
* @param city | |
* @param state | |
* @returns {string[][]} | |
*/ | |
async function address(address: string, city: string, state: string) { | |
if (!address) throw Error('missing address'); | |
const url = new URL('https://api.tophap.vercel.app/v1/excel'); | |
const query = [address, city, state].filter((x) => x).join(' '); | |
url.searchParams.set('query', query); | |
const headers = { tophap: 're3ZuR9m' }; | |
const res = await fetch(url.toString(), { headers }); | |
const data = await res.json(); | |
if (!res.ok) { | |
const errmsg = (data ?.error ?? 'unknown error') | |
return [[errmsg]] | |
} | |
const keys = [ | |
'county', | |
'jurisdiction', | |
'parcel_number', | |
'property_type_use', | |
'square_footage', | |
'year_built', | |
'land_acreage', | |
'tax_year', | |
'land_assessed_value', | |
'improvements_assessed_value', | |
'total_av', | |
'land_market_value', | |
'improvements_market_value', | |
'total_market_value', | |
'current_taxes', | |
'owners', | |
'last_sale_date', | |
'last_sale_price', | |
'hazards', | |
'permit_count', | |
'permit_history' | |
]; | |
const format = (value: any) => { | |
if (value == null) return '' | |
if (typeof value === 'number') return value | |
if (typeof value === 'string') return value | |
return JSON.stringify(value) | |
} | |
return [keys.map(key => format(data[key]))] | |
} | |
language: typescript | |
libraries: | | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
[email protected]/dist/css/fabric.min.css | |
[email protected]/dist/css/fabric.components.min.css | |
[email protected]/client/core.min.js | |
@types/core-js | |
[email protected] | |
@types/[email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment