pify
[WIP – Not ready for production]
gleam add pify@1
import pify
pub fn main() -> Nil {
/// Place your keys and secrets in a .env file
let assert Ok(key) = envoy.get("SHOPIFY_ANON_KEY")
let assert Ok(domain) = envoy.get("SHOPIFY_URL")
let assert Ok(api_version) = envoy.get("SHOPIFY_API_VERSION")
/// Pass them to your Shopify Client
let assert Ok(client) = pify.client(key: key, domain: domain, api_version: Some(api_version))
/// Use your client to fetch products
let assert Ok(products) = pify.fetch_products(client)
/// Or create your own fetcher passing the arguments from fetch().
let get_collections = pify.fetch(client: client,
query: "
query getCollections {
collections(first: 100, sortKey: TITLE) {
edges {
node {
...collection
}
}
}
}" <> collection_fragment(),
variables: None, decoder: collections_decoder())
/// This will return a `Result(ShopifyResult(Collections), ShopifyError)` that you can decode later.
}
Further documentation can be found at https://hexdocs.pm/pify.
Development
gleam run # Run the project
gleam test # Run the tests