Struct kickstarter::Client [] [src]

pub struct Client {
    pub uri: String,
    pub schema: String,
    // some fields omitted
}

Interfaces with a Kickstarter application running on a PostgreSQL database.

Fields

uri

PostgreSQL connection URI.

schema

Database schema name for kickstarter data.

Methods

impl Client

fn new(uri: &str, schema: &str) -> Result<Client>

Creates a new Kickstarter client, connecting to the specified PostgreSQL uri and database schema.

fn with_config(filename: &str, bootstrap: bool, sync: bool) -> Result<Client>

Creates a new Kickstarter client using the provided .toml configuration filename. If bootstrap is true, the client will wipe and recreate the database using the sql_file specified in the configuration.

fn db(&self) -> &Database

Returns a reference to the encapsulated database.

fn table(&self, table: &str) -> String

Returns the full table namespace.

fn table_abbr(&self, table: &str) -> String

Returns the full table namespace, abbreviated with the first two letters.

fn sync(&self)

Syncs generated models in src/lib/gen with database tables.

fn create_project(&self, project_name: &str, amount: f64) -> Result<Project>

Creates a new Kickstarter project with the specified name and goal amount in US dollars.

fn back_project(&self, user: &str, project_name: &str, card: &str, amount: f64) -> Result<Pledge>

Backs an existing Kickstarter project with the specified user, credit card, and contribution amount.

fn list_backers(&self, project_name: &str) -> Result<(Vec<Pledge>, f64)>

Returns a a list of all pledges (and users) towards a project, along with the project's goal amount.

fn list_projects(&self) -> Result<Vec<Project>>

Returns a list of all projects on Kickstarter.

fn list_backed_projects(&self, user: &str) -> Result<Vec<Pledge>>

Returns a list of all pledges (and projects) made by a user.