Usage examples

Uranium usage examples.

Usage examples

GET /vocabulary

import { HTTP } from 'uranium'

// Make JSON requests to Skedulo's API
const http = HTTP.Request()

const vocabularyP = http.get('/vocabulary')

vocabularyP.then(res => res.data)

200 Response:

{
    "Resources": {
        "Category": [
            {
                "value": "Customer Service",
                "label": "Customer Service",
                "controller": null,
                "validFor": []
            },
            {
                "value": "Installation Technician",
                "label": "Installation Technician",
                "controller": null,
                "validFor": []
            },
            {
                "value": "Electrician",
                "label": "Electrician",
                "controller": null,
                "validFor": []
            }
        ]
    },
    "Regions": {
        "CountryCode": [
            {
                "value": "AC",
                "label": "AC",
                "controller": null,
                "validFor": []
            },
            {
                "value": "AD",
                "label": "AD",
                "controller": null,
                "validFor": []
            },
            {
                "value": "AE",
                "label": "AE",
                "controller": null,
                "validFor": []
            },
            {
                "value": "AF",
                "label": "AF",
                "controller": null,
                "validFor": []
            },
            {
                "value": "AG",
                "label": "AG",
                "controller": null,
                "validFor": []
            },
            {
                "value": "AI",
                "label": "AI",
                "controller": null,
                "validFor": []
            },
            {
                "value": "AL",
                "label": "AL",
                "controller": null,
                "validFor": []
            },
            {
                "value": "AM",
                "label": "AM",
                "controller": null,
                "validFor": []
            }
        ]
    }
}

GET /api/Job

import { HTTP } from 'uranium'

// Make JSON requests to Skedulo's API
const httpAPI = HTTP.APIRequest()

// Fetching from `Jobs` salesforce object 
// @returns: Promise<Jobs>
const query = new Query()
  .filter("UID == $1", ["a0E9000001B4etxEAB"])

return query.makeRequest(httpAPI, "Jobs")
.then(res => res.records)

200 Response:

[
    {
        "NotifyBy": null,
        "CreatedById": "005900000032dtpAAA",
        "Locked": false,
        "NotesComments": null,
        "AbortReason": null,
        "RecurringScheduleId": null,
        "Timezone": "Australia/Brisbane",
        "Name": "JOB-0413",
        "JobTasks": [],
        "LastModifiedDate": "2016-04-27T05:02:02.000Z",
        "Duration": 15,
        "CreatedDate": "2015-12-01T04:29:56.000Z",
        "Address": "re",
        "LocationId": null,
        "JobTags": [],
        "ContactId": "0039000001G446VAAR",
        "Description": "Test Description",
        "JobStatus": "Pending Dispatch",
        "Followups": [],
        "Start": "2016-04-13T04:45:00.000Z",
        "GeoLongitude": 9.749998244000437,
        "ParentId": null,
        "ActualEnd": null,
        "RegionId": "a0J9000000X8mX3EAJ",
        "UID": "a0E9000001B4etxEAB",
        "GeoLatitude": 63.016666337000515,
        "CompletionNotes": null,
        "EstimatedEnd": "2016-04-13T05:00:00.000Z",
        "End": "2016-04-13T05:00:00.000Z",
        "AccountId": "00190000018u4rmAAA",
        "FollowupReason": null,
        "ActualStart": null,
        "Urgency": null,
        "EstimatedStart": "2016-04-13T04:45:00.000Z",
        "JobAllocationCount": 2,
        "CanBeDeclined": true,
        "AutoSchedule": false,
        "Type": "Break Fix",
        "NotifyPeriod": null
    }
]

POST /api/PatientForms

import { HTTP } from 'uranium'

// Make JSON requests to Skedulo's API
const httpAPI = HTTP.APIRequest()

return httpAPI
  .post("PatientForms", jobIds.map(id => ({ JobId: id })))

200 Response:

[{"UID":"a0S9000000jEPOREA4","success":true}]

PUT /api/PatientForms

import { HTTP } from 'uranium'

// Make JSON requests to Skedulo's API
const httpAPI = HTTP.APIRequest()

// The "diffs" array could potentially have more than just one item
const diffs = [{
	UID: "a0S9000000jEPOREA4",
  Name: "Sample Name",
  Description: "Sample Description"
}]

httpAPI.put("PatientForms", diffs).then(res => res.data)

200 Response:

[{"UID":"a0S9000000jEPOREA4","success":true}]

Last modified August 2, 2019: Updated fonts and finished guide 1:1 (fe87bc2)