Created
January 26, 2023 17:24
-
-
Save hanakslr/b611757f4e705b04f8dc7a24b9751ee5 to your computer and use it in GitHub Desktop.
faraday-js sample
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
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