Skip to content

Instantly share code, notes, and snippets.

@hanakslr
Created January 26, 2023 17:24
Show Gist options
  • Save hanakslr/b611757f4e705b04f8dc7a24b9751ee5 to your computer and use it in GitHub Desktop.
Save hanakslr/b611757f4e705b04f8dc7a24b9751ee5 to your computer and use it in GitHub Desktop.
faraday-js sample
import { Configuration, FaradayClient } from "@faradayio/faraday-js";
const configuration = new Configuration({
basePath: window.location.origin,
accessToken: "Bearer abcd",
});
const faraday = new FaradayClient(configuration);
const sample = async () => {
await faraday.uploads.createUpload("orders", "order.csv", file);
const dataset = await faraday.datasets.createDataset({
identity_sets: {},
name: "orders",
options: {
type: "hosted_csv",
upload_directory: "orders",
},
output_to_streams: {
orders: {
data_map: {
value: "order_amt",
},
},
},
});
const cohort = await faraday.cohorts.createCohort({
stream_name: "orders",
});
const personaSet = await faraday.personaSets.createPersonaSet({
cohort_id: cohort.id,
});
const outcome = await faraday.outcomes.createOutcome({
attainment_cohort_id: cohort.id,
name: "outcome_name",
});
const scope = await faraday.scopes.createScope({
name: "scope_name",
population: {
cohort_ids: [cohort.id],
},
payload: {
persona_set_ids: [personaSet.id],
},
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment