### Get All Webhooks in Ruby Source: https://docs.fulcrumapp.com/reference/webhooks-get-all This Ruby example demonstrates how to fetch all webhooks using the Fulcrum gem. It initializes the client and iterates through the retrieved webhooks to print their names. ```ruby require 'fulcrum' client = Fulcrum::Client.new('{token}') webhooks = client.webhooks.all() for webhook in webhooks.objects do # puts webhook # entire webhook puts webhook['name'] # just the webhook name end ``` -------------------------------- ### Using ONCE with VERSIONINFO Source: https://docs.fulcrumapp.com/docs/calculations-ref-once This example demonstrates how to use the ONCE function to get version information only once. The result is a string containing device, OS, and app version details. ```javascript ONCE(VERSIONINFO()) // returns "Apple iPhone6,2, iOS 8.1, Fulcrum 2.7.0 2162" ``` -------------------------------- ### Get All Projects in JavaScript Source: https://docs.fulcrumapp.com/reference/projects-get-all Fetch all projects using the Fulcrum JavaScript client. This example demonstrates handling the promise and iterating through the project objects. ```JavaScript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); client.projects.all() .then((page) => { page.objects.forEach(project => { // console.log(project); // entire project console.log(project.name); // just the project name }); }) .catch((error) => { console.log(error.message); }); ``` -------------------------------- ### Get All Roles in Ruby Source: https://docs.fulcrumapp.com/reference/roles-get-all This Ruby example shows how to fetch all roles using the Fulcrum gem. It iterates through the roles and prints the ID of each role. ```ruby require 'fulcrum' client = Fulcrum::Client.new('{token}') roles = client.roles.all() for role in roles.objects do # puts role # entire role definition puts role['id'] # just the role id end ``` -------------------------------- ### Get All Projects in Python Source: https://docs.fulcrumapp.com/reference/projects-get-all Use the Fulcrum Python library to retrieve all projects. Ensure you have installed the library and provided your API token. ```Python from fulcrum import Fulcrum fulcrum = Fulcrum('{token}') projects = fulcrum.projects.search() for project in projects['projects']: # print(project) # entire project print(project['name']) # just the project name ``` -------------------------------- ### Ruby SDK Example Source: https://docs.fulcrumapp.com/reference/signatures-get-single-metadata Example of how to retrieve signature metadata using the Ruby SDK. ```APIDOC ## Get Single Signature Metadata ### Description Retrieve metadata for a single signature. ### Method `find` ### Endpoint N/A (SDK method) ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the signature. ### Request Example ```ruby require 'fulcrum' client = Fulcrum::Client.new('{token}') signature = client.signatures.find('{id}') puts signature ``` ### Response #### Success Response Returns the signature metadata. #### Response Example ```json { "signature": "..." } ``` ``` -------------------------------- ### Get All Roles in Python Source: https://docs.fulcrumapp.com/reference/roles-get-all Use the Fulcrum Python client to fetch all roles. Ensure you have your API token configured. This example iterates through the roles and prints each one. ```python from fulcrum import Fulcrum fulcrum = Fulcrum('{token}') roles = fulcrum.roles.search() for role in roles['roles']: print(role) # entire role # print(roles['name']) # just the role name ``` -------------------------------- ### Get Single Project in JavaScript Source: https://docs.fulcrumapp.com/reference/projects-get-single Utilize the Fulcrum JavaScript client to fetch project details. This example demonstrates handling both successful retrieval and potential errors. ```JavaScript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); client.projects.find('{id}') .then((project) => { console.log(projects); }) .catch((error) => { console.log(error.message); }); ``` -------------------------------- ### Python SDK Example Source: https://docs.fulcrumapp.com/reference/signatures-get-single-metadata Example of how to retrieve signature metadata using the Python SDK. ```APIDOC ## Get Single Signature Metadata ### Description Retrieve metadata for a single signature. ### Method `find` ### Endpoint N/A (SDK method) ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the signature. ### Request Example ```python from fulcrum import Fulcrum fulcrum = Fulcrum('{token}') signature = fulcrum.signatures.find('{id}') print(signature['signature']) ``` ### Response #### Success Response Returns a dictionary containing the signature metadata. #### Response Example ```json { "signature": "..." } ``` ``` -------------------------------- ### JavaScript SDK Example Source: https://docs.fulcrumapp.com/reference/signatures-get-single-metadata Example of how to retrieve signature metadata using the JavaScript SDK. ```APIDOC ## Get Single Signature Metadata ### Description Retrieve metadata for a single signature. ### Method `find` ### Endpoint N/A (SDK method) ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the signature. ### Request Example ```javascript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); client.signatures.find('{id}') .then((signature) => { console.log(signature); }) .catch((error) => { console.log(error.message); }); ``` ### Response #### Success Response Returns a promise that resolves with the signature metadata. #### Response Example ```json { "signature": "..." } ``` ``` -------------------------------- ### Get Video Track in GPX Format (JavaScript) Source: https://docs.fulcrumapp.com/reference/videos-get-single-track-gpx This JavaScript example shows how to fetch a video's GPS track in GPX format. It uses the 'fulcrum-app' library. Remember to replace '{token}' and '{id}' with your credentials and the video identifier. ```javascript const { Client } = require('fulcrum-app'); const fs = require('fs'); const client = new Client('{token}'); client.videos.track('{id}', 'gpx') .then(track => fs.writeFile('track.gpx', track, function () { console.log('track downloaded!'); })) .catch(err => console.log(err)); ``` -------------------------------- ### Get Video Track in GPX Format (Python) Source: https://docs.fulcrumapp.com/reference/videos-get-single-track-gpx Use this Python snippet to download a video's GPS track as a GPX file. Ensure you have the 'fulcrum' library installed and replace '{token}' and '{id}' with your API token and video ID. ```python from fulcrum import Fulcrum import json fulcrum = Fulcrum('{token}') tracks = fulcrum.videos.track('{id}', 'gpx') with open('track.gpx', 'w') as f: json.dump(tracks, f) ``` -------------------------------- ### Create Project with JavaScript Source: https://docs.fulcrumapp.com/reference/projects-create Create a project using the Fulcrum JavaScript client. This example demonstrates asynchronous creation and error handling. ```javascript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); const obj = { "name": "Pinellas County", "description": "For records in Pinellas County" }; client.projects.create(obj) .then((project) => { console.log(project.id + ' has been created!'); }) .catch((error) => { console.log(error.message); }); ``` -------------------------------- ### Get JSON Audio Track in JavaScript Source: https://docs.fulcrumapp.com/reference/audio-get-single-track-json Utilize the Fulcrum JavaScript client to retrieve an audio track's GPS data in JSON format and write it to a local file. This example uses Promises for asynchronous operations. Make sure to install the 'fulcrum-app' package. ```JavaScript const { Client } = require('fulcrum-app'); const fs = require('fs'); const client = new Client('{token}'); client.audio.track('{id}', 'json') .then(track => fs.writeFile('track.json', track, function () { console.log('track downloaded!'); })) .catch(err => console.log(err)) ``` -------------------------------- ### Get Chain Start Indices Source: https://docs.fulcrumapp.com/docs/create-buffer-from-point Calculates and returns the start indices for chains within a given set of points. ```javascript gp.prototype.getChainStartIndices=function(t){var e=0,n=new I;n.add(new gu(e));do{var r=this.findChainEnd(t,e)}while(n.add(new gu(r)),(e=r)"Pinellas County", "description"=>"For records in Pinellas County" } response = client.projects.create(project) puts response['id'] + ' has been created!' ``` -------------------------------- ### Get Precision of a Decimal Number Source: https://docs.fulcrumapp.com/docs/calculations-ref-precision Use the PRECISION function to determine the number of decimal places in a number with multiple decimal places. This example shows how to get the precision of 1.333. ```javascript PRECISION(1.333) // returns 3 ``` -------------------------------- ### Upload Audio using Ruby Source: https://docs.fulcrumapp.com/reference/audio-upload This Ruby example shows how to upload an audio file and its associated track data. Remember to substitute `{token}` with your API token and verify the file paths. ```ruby require 'fulcrum' client = Fulcrum::Client.new('{token}') audio = client.audio.create('/Users/bryan/Desktop/audio.m4a', 'audio/x-m4a', { track: File.read('/Users/bryan/Desktop/track.json') }) puts audio ``` -------------------------------- ### Get Precision of a Simple Decimal Number Source: https://docs.fulcrumapp.com/docs/calculations-ref-precision Use the PRECISION function to find the number of decimal places in a number with a single decimal place. This example demonstrates getting the precision of 1.3. ```javascript PRECISION(1.3) // returns 1 ``` -------------------------------- ### PostgreSQL Response Example Source: https://docs.fulcrumapp.com/reference/query-intro This snippet demonstrates how to set up and insert data into a PostgreSQL table for spatial queries. It requires the PostGIS extension and the `_geometry` column. ```sql CREATE EXTENSION IF NOT EXISTS postgis; CREATE TABLE IF NOT EXISTS query ( _geometry geometry(Geometry,4326), _latitude double precision, _longitude double precision, road text, cul_type text, cul_matl text ); INSERT INTO query (_geometry, _latitude, _longitude, road, cul_type, cul_matl) SELECT '0101000020e610000078bfe170ec3752c04bc0b702ed334640', '44.40567049', '-72.87380621', 'BOLTON VALLEY ACCESS RD', 'Round', 'Concrete Sectional'; INSERT INTO query (_geometry, _latitude, _longitude, road, cul_type, cul_matl) SELECT '0101000020e6100000a94ddef8013552c0f12c625429104640', '44.12626128', '-72.82824537', 'AIRPORT RD', 'Round', 'Steel Corrugated'; INSERT INTO query (_geometry, _latitude, _longitude, road, cul_type, cul_matl) SELECT '0101000020e6100000ad33df3d173552c0f3d58671d4114640', '44.13929576', '-72.82954356', 'AIRPORT RD', 'Round', 'Steel Corrugated'; INSERT INTO query (_geometry, _latitude, _longitude, road, cul_type, cul_matl) SELECT '0101000020e6100000613a4ab1253552c035f7a98dde114640', '44.13960429', '-72.83042557', 'AIRPORT RD', 'Round', 'Steel Corrugated'; INSERT INTO query (_geometry, _latitude, _longitude, road, cul_type, cul_matl) SELECT '0101000020e610000075dc5b576d3552c0b4abb100fd114640', '44.14053353', '-72.83479866', 'AIRPORT RD', 'Round', 'Plastic Corrugated'; ``` -------------------------------- ### Get Minimum X Coordinate Source: https://docs.fulcrumapp.com/docs/create-buffer-from-point Retrieves the minimum X coordinate from a segment defined by start and end indices. ```javascript dp.prototype.getMinX=function(t){var e=this.pts[this.startIndex[t]].x,t=this.pts[this.startIndex[t+1]].x;return e { // called when Fulcrum.finish(data) is called in your HTML } }); ``` -------------------------------- ### Get Maximum X Coordinate Source: https://docs.fulcrumapp.com/docs/create-buffer-from-point Retrieves the maximum X coordinate from a segment defined by start and end indices. ```javascript dp.prototype.getMaxX=function(t){var e=this.pts[this.startIndex[t]].x,t=this.pts[this.startIndex[t+1]].x;return t { page.objects.forEach(layer => { // console.log(layer); console.log(layer.name); }); }) .catch((error) => { console.log(error.message); }); ``` -------------------------------- ### JavaScript Buffer Example Source: https://docs.fulcrumapp.com/docs/create-buffer-from-point This example demonstrates how to create a buffer around a point using the FulcrumApp library. It requires a precision model and a geometry factory. ```javascript this._geomFact = t.getFactory(); var n = this._workingPrecisionModel, r = (null === n && (n = t.getPrecisionModel()), this._geomFact = t.getFactory(), new Hc(n, this._bufParams)), t = new Zc(t, e, r).getCurves(); if (t.size() <= 0) return this.createEmptyResultGeometry(); this.computeNodedEdges(t, n); this._graph = new ac(new sp); this._graph.addEdges(this._edgeList.getEdges()); e = this.createSubgraphs(this._graph); r = new uc(this._geomFact); this.buildSubgraphs(e, r); t = r.getPolygons(); return t.size() <= 0 ? this.createEmptyResultGeometry() : this._geomFact.buildGeometry(t); ``` -------------------------------- ### Get Single Webhook in JavaScript Source: https://docs.fulcrumapp.com/reference/webhooks-get-single Utilize the Fulcrum JavaScript client to fetch a webhook. This example demonstrates handling both successful retrieval and potential errors. ```javascript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); client.webhooks.find('{id}') .then((webhook) => { console.log(webhook); }) .catch((error) => { console.log(error.message); }); ``` -------------------------------- ### Download Original Audio File in Ruby Source: https://docs.fulcrumapp.com/reference/audio-get-original-file This Ruby example demonstrates downloading an original audio file using the Fulcrum gem. It opens a file in binary write mode and writes the audio content to it. Remember to substitute your token and the audio ID. ```Ruby require 'fulcrum' client = Fulcrum::Client.new('{token}') client.audio.original('{id}') do |input| File.open('{id}.m4a', 'wb') do |output| output.write(input.read) end end ``` -------------------------------- ### Get Classification Set (JavaScript) Source: https://docs.fulcrumapp.com/reference/classification-sets-get-single Utilize the fulcrum-app JavaScript client to fetch a classification set. This example shows how to handle successful responses and errors. ```JavaScript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); client.classificationSets.find('{id}') .then((classificationSet) => { console.log(classificationSet); }) .catch((error) => { console.log(error.message); }); ``` -------------------------------- ### Create Layer with JavaScript Source: https://docs.fulcrumapp.com/reference/layers-create This JavaScript example demonstrates how to create a layer using the Fulcrum client library. Provide the layer's name, type, and source. Handle potential errors during the API call. ```javascript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); const obj = { "name": "USGS Topo", "type": "xyz", "source": "http://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/{z}/{y}/{x}" }; client.layers.create(obj) .then((layer) => { console.log(layer.id + ' has been created!'); }) .catch((error) => { console.log(error.message); }); ``` -------------------------------- ### Sample Project Response Source: https://docs.fulcrumapp.com/reference/projects-intro This is a sample JSON response representing a successfully created or retrieved project object, including its name, description, ID, and timestamps. ```json { "project": { "name": "Pinellas County", "description": "For records in Pinellas County", "id": "60786571-46b4-43b8-8f49-7d8f0f45987e", "created_at": "2013-10-29T15:49:09Z", "updated_at": "2014-11-18T15:23:48Z" } } ``` -------------------------------- ### JavaScript API Library Example Source: https://docs.fulcrumapp.com/reference/authorizations-create Example of creating an authorization using the JavaScript fulcrum-app library. ```APIDOC ## createAuthorization ### Description Creates a new authorization token. ### Method Not explicitly defined, but implied to be a client-side library function. ### Parameters - **email** (string) - Required - The user's email address. - **password** (string) - Required - The user's password. - **organizationId** (string) - Required - The ID of the organization. - **note** (string) - Optional - A note for the authorization. - **timeout** (integer) - Optional - The timeout for the authorization in seconds. - **userId** (string) - Optional - The ID of the user to create the token for; defaults to the user creating the token. ### Request Example ```javascript const { createAuthorization } = require('fulcrum-app'); const email = '{email}'; const password = '{password}'; const organizationId = 'organization-id-from-getUser'; const note = 'My New API Token'; const timeout = 3600; // optional, defaults to None const userId = 'bc95fb63-f664-46ce-b440-de8de85e4494'; // optional, defaults to user creating token createAuthorization(email, password, organizationId, note, timeout, userId) .then((authorization) => { console.log(authorization); // authorization.token is your API token to use with the rest of the API. }) .catch((error) => { console.log(error.message); }); ``` ``` -------------------------------- ### Get All Signatures in JavaScript Source: https://docs.fulcrumapp.com/reference/signatures-get-all Utilize the Fulcrum JavaScript client to fetch all signatures for a given form ID. The example logs the access key of each signature to the console. ```JavaScript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); client.signatures.all({'form_id':'{id}'}) .then((page) => { page.objects.forEach(signature => { // console.log(signature); // entire signature metadata console.log(signature.access_key); // just the signature key }); }) .catch((error) => { console.log(error.message); }); ``` -------------------------------- ### Create Choice List in Ruby Source: https://docs.fulcrumapp.com/reference/choice-lists-create This Ruby example demonstrates creating a choice list using the Fulcrum gem. It includes the necessary require statement and client initialization. ```ruby require 'fulcrum' client = Fulcrum::Client.new('{token}') list = { "name"=>"Bridge Inspection Conditions", "choices"=>[{ "label"=>"Excellent", "value"=>"Excellent" }, { "label"=>"Good", "value"=>"Good" }, { "label"=>"Fair", "value"=>"Fair" }, { "label"=>"Poor", "value"=>"Poor" }, { "label"=>"Unrated", "value"=>"Unrated" }, { "label"=>"N/A", "value"=>"N/A" }] }; response = client.choice_lists.create(list) puts response['id'] + ' has been created!' ``` -------------------------------- ### Ruby API Library Example Source: https://docs.fulcrumapp.com/reference/signatures-get-all Example of how to retrieve signatures using the Ruby Fulcrum client library, demonstrating how to fetch signatures associated with a specific form ID and process each signature object to extract information such as the access key. ```APIDOC ## GET /signatures ### Description Retrieve metadata for a list of signatures, optionally filtered by form ID. ### Method GET ### Endpoint /signatures ### Parameters #### Query Parameters - **form_id** (string) - Required - The ID of the form to filter signatures by. ### Request Example ```ruby require 'fulcrum' client = Fulcrum::Client.new('{token}') signatures = client.signatures.all({'form_id':'{id}'}) ``` ### Response #### Success Response (200) - **objects** (array) - A list of signature objects. - **access_key** (string) - The unique access key for the signature. #### Response Example ```json { "objects": [ { "access_key": "{signature_access_key}", "other_metadata": "..." } ] } ``` ``` -------------------------------- ### Get Maximum Node Source: https://docs.fulcrumapp.com/docs/create-buffer-from-point Returns the node with the maximum key in the tree, starting from the provided node or the root if none is provided. Returns null if the tree is empty. ```javascript ga.prototype.maxNode=function(t){if(t=void 0===t?this._root:t)for(;t.right;)t=t.right;return t} ``` -------------------------------- ### Initialize Storage and Set Item Source: https://docs.fulcrumapp.com/docs/data-events-storage Initializes the storage object and demonstrates setting a string item in local storage. Items must be strings. ```javascript storage = STORAGE(); KEY = 'item_key'; storage.setItem(KEY, 'hello world'); // Sets an item in local storage, must be a string ``` -------------------------------- ### Get Minimum Node Source: https://docs.fulcrumapp.com/docs/create-buffer-from-point Returns the node with the minimum key in the tree, starting from the provided node or the root if none is provided. Returns null if the tree is empty. ```javascript ga.prototype.minNode=function(t){if(t=void 0===t?this._root:t)for(;t.left;)t=t.left;return t} ``` -------------------------------- ### Create Webhook in Ruby Source: https://docs.fulcrumapp.com/reference/webhooks-create This Ruby example shows how to create a webhook using the Fulcrum gem. It requires your API token and a hash containing the webhook's name and URL. ```Ruby require 'fulcrum' client = Fulcrum::Client.new('{token}') webhook = { "name"=>"Fire Hydrant Inventory Emails", "url"=>"https://my-webhook-processing-script.php" } response = client.webhooks.create(webhook) puts response['id'] + ' has been created!' ``` -------------------------------- ### Get All Photos Metadata Source: https://docs.fulcrumapp.com/reference/photos-get-all-metadata Retrieves metadata for a list of photos associated with a specific form ID. The examples demonstrate how to access individual photo metadata, such as the access key. ```APIDOC ## Get All Photos Metadata ### Description Retrieves metadata for a list of photos. ### Method GET (implied by client library calls) ### Endpoint Not explicitly defined, but client libraries interact with a photos endpoint. ### Parameters #### Query Parameters - **form_id** (string) - Required - The ID of the form to retrieve photos for. ### Request Example (See client library examples for specific language implementations) ### Response #### Success Response (200) - **photos** (array) - A list of photo metadata objects. - **access_key** (string) - The unique access key for the photo. #### Response Example (See client library examples for specific language implementations) ``` -------------------------------- ### Get Single Audit Log in JavaScript Source: https://docs.fulcrumapp.com/reference/audit-logs-get-single Utilize the fulcrum-app JavaScript client to fetch an audit log. This example demonstrates handling the promise and logging potential errors. ```JavaScript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); client.auditLogs.find('{id}') .then((log) => { console.log(log); }) .catch((error) => { // There was a problem with the request. Is the API token correct? console.log(error.message); }); ``` -------------------------------- ### Initialize Point and Buffer Source: https://docs.fulcrumapp.com/docs/create-buffer-from-point Initializes a point and creates a buffer around it. This is a basic setup for spatial operations. ```javascript const point = { x: 10, y: 20 }; const bufferDistance = 5; const buffer = createBufferFromPoint(point, bufferDistance); ``` -------------------------------- ### JavaScript API Library Example Source: https://docs.fulcrumapp.com/reference/signatures-get-all Example of how to retrieve signatures using the JavaScript Fulcrum client library, showing how to fetch signatures for a given form ID and iterate through the results to access properties like the access key. ```APIDOC ## GET /signatures ### Description Retrieve metadata for a list of signatures, optionally filtered by form ID. ### Method GET ### Endpoint /signatures ### Parameters #### Query Parameters - **form_id** (string) - Required - The ID of the form to filter signatures by. ### Request Example ```javascript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); client.signatures.all({'form_id':'{id}'}) ``` ### Response #### Success Response (200) - **objects** (array) - A list of signature objects. - **access_key** (string) - The unique access key for the signature. #### Response Example ```json { "objects": [ { "access_key": "{signature_access_key}", "other_metadata": "..." } ] } ``` ``` -------------------------------- ### Get Precision of an Integer Source: https://docs.fulcrumapp.com/docs/calculations-ref-precision Use the PRECISION function to determine the number of decimal places in an integer. This example shows that an integer like 1 has 0 decimal places. ```javascript PRECISION(1) // returns 0 ``` -------------------------------- ### Python API Library Example Source: https://docs.fulcrumapp.com/reference/signatures-get-all Example of how to retrieve signatures using the Python Fulcrum library, demonstrating how to search for signatures associated with a specific form ID and access individual signature details like the access key. ```APIDOC ## GET /signatures ### Description Retrieve metadata for a list of signatures, optionally filtered by form ID. ### Method GET ### Endpoint /signatures ### Parameters #### Query Parameters - **form_id** (string) - Required - The ID of the form to filter signatures by. ### Request Example ```python from fulcrum import Fulcrum fulcrum = Fulcrum('{token}') signatures = fulcrum.signatures.search(url_params={'form_id':'{id}'}) ``` ### Response #### Success Response (200) - **signatures** (array) - A list of signature objects. - **access_key** (string) - The unique access key for the signature. #### Response Example ```json { "signatures": [ { "access_key": "{signature_access_key}", "other_metadata": "..." } ] } ``` ``` -------------------------------- ### Get All Authorizations (Python) Source: https://docs.fulcrumapp.com/reference/authorizations-get-all Use the Fulcrum Python library to retrieve all authorizations and print their notes. Ensure you have installed the library and replaced '{token}' with your actual API token. ```Python from fulcrum import Fulcrum fulcrum = Fulcrum('{token}') authorizations = fulcrum.authorizations.search() for authorization in authorizations['authorizations']: # print(authorization) print(authorization['note']) ``` -------------------------------- ### Get All Records by Form ID (JavaScript) Source: https://docs.fulcrumapp.com/reference/records-get-all Utilize the `client.records.all` method to fetch records, filtering by `form_id`. The example demonstrates handling the promise and logging individual record IDs. ```JavaScript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); client.records.all({ form_id: '{id}' }) .then((page) => { page.objects.forEach(record => { // console.log(record); // entire record console.log(record.id); // just the record id }); }) .catch((error) => { console.log(error.message); }); ``` -------------------------------- ### Projection and Translation Setup Source: https://docs.fulcrumapp.com/docs/create-buffer-from-point This snippet sets up a projection and translation for rendering geographic data. It configures the scale and center point for the map. ```javascript function $g(r){return function(t){var e,n=new td;for(e in r)n[e]=r[e];return n.stream=t,n}}function td(){}function ed(t,e,n){var r=e[1][0]-e[0][0],i=e[1][1]-e[0][1],o=t.clipExtent&&t.clipExtent(),n=(t.scale(150).translate([0,0]),null!=o&&t.clipExtent(null),n=n,s=t.stream(Hg),n&&_g.hasOwnProperty(n.type)?_g[n.type](n,s):yg(n,s),Hg.result()),s=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),r=+e[0][0]+(r-s*(n[1][0]+n[0][0]))/2,e=+e[0][1]+(i-s*(n[1][1]+n[0][1]))/2;return null!=o&&t.clipExtent(o),t.scale(150*s).translate(} ``` -------------------------------- ### Upload Signature using Python Source: https://docs.fulcrumapp.com/reference/signatures-upload This Python snippet demonstrates how to upload a signature file using the Fulcrum SDK. Initialize the client with your API token and provide the local path to the signature file. ```python from fulcrum import Fulcrum fulcrum = Fulcrum('{token}') signature = fulcrum.signatures.create('/Users/bryan/Desktop/signature.jpg') print(signature['signature']) ``` -------------------------------- ### Get Record History in JavaScript Source: https://docs.fulcrumapp.com/reference/records-get-history Fetch a record's history using the Fulcrum JavaScript client. This example iterates through the versions and logs each one, or logs an error message. ```JavaScript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); client.records.history('{id}') .then((page) => { page.objects.forEach(version => { console.log(version); }); }) .catch((error) => { console.log(error.message); }); ``` -------------------------------- ### Upload Video using JavaScript Source: https://docs.fulcrumapp.com/reference/videos-upload This JavaScript example shows how to upload a video using the `fulcrum-app` client. It utilizes Node.js streams for file handling and requires your API token. ```javascript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); const fs = require('fs'); const video = fs.createReadStream('/Users/bryan/Desktop/video.mp4'); const track = fs.createReadStream('/Users/bryan/Desktop/track.json'); client.videos.create(video, { track: track }) .then(created => console.log(created)) .catch(error => console.log(error)); ``` -------------------------------- ### Get All Authorizations (JavaScript) Source: https://docs.fulcrumapp.com/reference/authorizations-get-all Utilize the fulcrum-app JavaScript client to fetch all authorizations. The example logs the ID of each authorization. Replace '{token}' with your API token and handle potential errors. ```JavaScript const { Client } = require('fulcrum-app'); const client = new Client('{token}'); client.authorizations.all() .then((page) => { page.objects.forEach(authorization => { // console.log(authorization); // entire authorization console.log(authorization.id); // just the authorization id }); }) .catch((error) => { console.log(error.message); }); ``` -------------------------------- ### Access Specific Sketch Field Source: https://docs.fulcrumapp.com/docs/sketches Display sketches from a specific field outside the main render loop. This example shows how to get the mediaID of the first sketch in a field and display it. ```html
<% // Using the data name of your sketch field var sketchField = $my_sketch_field; var sketchId = sketchField && sketchField[0] && sketchField[0].mediaID; %> <% if (sketchId) { %>
<% } %>

Site Sketches

<% if ($site_sketch && $site_sketch.items) { %> <% $site_sketch.items.forEach((item, index) => { %>
Sketch <%= index + 1 %>
<% }); %> <% } %>
``` -------------------------------- ### Create a buffer from a point with specific properties Source: https://docs.fulcrumapp.com/docs/create-buffer-from-point This snippet demonstrates creating a buffer around a point, similar to the previous example, but explicitly shows how to pass properties to the resulting geometry. This is useful for associating custom data with the buffer. ```javascript function ti(t,e,n,r,i){var o=(i=void 0===i?{}:i).steps||64,n=ei(n),r=ei(r),s=Array.isArray(t)||"Feature"!==t.type?{}:t.properties;if(n===r)return V(Cn(t,e,i).geometry.coordinates[0],s);for(var a=n,u=n