fireball

Types

Firestore collection type

pub type Collection {
  Collection(location: String, err: String)
}

Constructors

  • Collection(location: String, err: String)

Firestore document type

pub type FireballDocument {
  FireballDocument(data: String)
}

Constructors

  • FireballDocument(data: String)
pub type FireballError {
  FireballError(err: String)
}

Constructors

  • FireballError(err: String)
pub type FireballStorage {
  FireballStorage(path: String)
}

Constructors

  • FireballStorage(path: String)

A type representing the JSON returning when uploading an object to Google Firebase Storage

pub type UploadData {
  UploadData(
    name: String,
    bucket: String,
    generation: String,
    metageneration: String,
    content_type: String,
    time_created: String,
    updated: String,
    storage_class: String,
    size: String,
    md5_hash: String,
    content_encoding: String,
    content_disposition: String,
    crc32c: String,
    etag: String,
    download_tokens: String,
  )
}

Constructors

  • UploadData(
      name: String,
      bucket: String,
      generation: String,
      metageneration: String,
      content_type: String,
      time_created: String,
      updated: String,
      storage_class: String,
      size: String,
      md5_hash: String,
      content_encoding: String,
      content_disposition: String,
      crc32c: String,
      etag: String,
      download_tokens: String,
    )

Functions

pub fn doc_to_json(doc doc: FireballDocument) -> String

Function to transform a document into JSON

pub fn doc_to_list(doc doc: FireballDocument) -> List(String)

Function to transform a document into a list of strings

pub fn doc_to_string(doc doc: FireballDocument) -> String

Function to transform a document into a semi-colon string

pub fn doc_to_tuple(doc doc: FireballDocument) -> #(String)

Function to transform a document into a tuple of strings

pub fn get_doc(
  apikey apikey: String,
  apiver apiver: String,
  database database: String,
  doc doc: String,
  proj_id proj_id: String,
) -> Result(FireballDocument, FireballError)

get_doc function to retrieve a document from Google’s Firestore Database

pub fn get_file(
  apiver apiver: String,
  obj_path obj_path: String,
  proj_id proj_id: String,
  token token: String,
  content_type content_type: String,
) -> Result(FireballStorage, FireballError)

get_file function is used to retrieve a single file from Google’s Firestore Storage

pub fn json_to_upload_data(
  input input: Dynamic,
) -> Result(UploadData, List(DecodeError))

A function to turn JSON into UploadData - adapted from https://github.com/emergent/decode-json-examples/blob/main/test/decode_json_test.gleam

pub fn post_doc(
  apikey apikey: String,
  apiver apiver: String,
  database database: String,
  collection_path collection_path: String,
  doc_path doc_path: String,
  input_doc input_doc: FireballDocument,
  proj_id proj_id: String,
) -> Result(FireballDocument, FireballError)

put_file function to create a document in Google’s Firestore Database

pub fn post_doc_from_file(
  apikey apikey: String,
  apiver apiver: String,
  database database: String,
  collection_path collection_path: String,
  doc_path doc_path: String,
  input_doc input_doc: String,
  proj_id proj_id: String,
) -> Result(FireballDocument, FireballError)

put_file function to create a document in Google’s Firestore Database

pub fn post_doc_from_string(
  apikey apikey: String,
  apiver apiver: String,
  database database: String,
  collection_path collection_path: String,
  doc_path doc_path: String,
  input_data input_data: String,
  proj_id proj_id: String,
) -> Result(FireballDocument, FireballError)

put_file function to create a document in Google’s Firestore Database

pub fn post_file(
  apiver apiver: String,
  apikey apikey: String,
  infile infile: String,
  outfile outfile: String,
  proj_id proj_id: String,
) -> Result(String, FireballError)

This will change in the future if a native Multipart Form encoder is written for HTTPC

pub fn post_file_erl(
  url url: String,
  infile infile: String,
) -> Nil

post_file_erl function is used to call erlang’s inets and ssl funtions to send the request over httpc

pub fn post_file_external(
  apiver apiver: String,
  apikey apikey: String,
  infile infile: String,
  outfile outfile: String,
  proj_id proj_id: String,
  external_script external_script: String,
  wd wd: String,
) -> Result(String, FireballError)

post_file, but uses system cURL instead of native libaries

pub fn upload_data_to_json(
  upload_data upload_data: UploadData,
) -> String

A function to turn UploadData into JSON

Search Document