Struct helpscout::api::users::UsersBuilder [] [src]

pub struct UsersBuilder { /* fields omitted */ }

Methods

impl UsersBuilder
[src]

[src]

Set the page for list actions

[src]

Set the user type for list actions

[src]

List Users

API docs: https://developer.helpscout.com/help-desk-api/users/list/

Usage

extern crate helpscout;

use helpscout::{Client, Collection, HelpScoutError};
use helpscout::api::users::User;

fn main() {
    let users = list_users().expect("get list of users");
    println!("{:#?}", users);
    assert!(users.items.len() > 0);
}

fn list_users() -> Result<Collection<User>, HelpScoutError> {
    let client = helpscout::Client::example();
    helpscout::api::users().list(&client)
}

Output

Be careful when using this code, it's not being tested!
Collection {
    page: 1,
    pages: 1,
    count: 8,
    items: [
        User {
            id: 1,
            first_name: "John",
            last_name: "Smith",
            email: "john@test.com",
            role: "owner",
            timezone: "America/New_York",
            photo_url: Some(
                "https://example.com/users/123.1234.png"
            ),
            created_at: 2015-10-28T16:43:54Z,
            modified_at: 2018-01-31T19:06:48Z,
            user_type: User
        },
        // More
    ]
}

[src]

Get User

API docs: https://developer.helpscout.com/help-desk-api/users/get/

Usage

extern crate helpscout;

use helpscout::{Client, Item, HelpScoutError};
use helpscout::api::users::User;

fn main() {
    let user = get_user().expect("get user");
    println!("{:#?}", user);
    assert!(user.item.id > 0);
}

fn get_user() -> Result<Item<User>, HelpScoutError> {
    let client = helpscout::Client::example();
    let id = find_valid_user_from_list(&client)?;
    helpscout::api::users().get(&client, id)
}

// Get first user so get a valid id
fn find_valid_user_from_list(client: &Client) -> Result<i32, HelpScoutError> {
    let users = helpscout::api::users().list(&client)?;
    Ok(users.items[0].id)
}

Output

Be careful when using this code, it's not being tested!
Item {
    item: User {
        id: 1,
        first_name: "John",
        last_name: "Smith",
        email: "test@test.com",
        role: "owner",
        timezone: "America/New_York",
        photo_url: Some(
            "https://example.net/users/123.123.png"
        ),
        created_at: 2015-10-28T16:43:54Z,
        modified_at: 2018-01-31T19:06:48Z,
        user_type: User
    }
}

[src]

List Users by Mailbox

API docs: https://developer.helpscout.com/help-desk-api/users/mailbox-users/

Usage

extern crate helpscout;

use helpscout::{Client, Collection, HelpScoutError};
use helpscout::api::users::User;

fn main() {
    let users = list_users_by_mailbox().expect("list users by mailbox");
    println!("{:#?}", users);
    assert!(users.items.len() > 0);
}

fn list_users_by_mailbox() -> Result<Collection<User>, HelpScoutError> {
    let client = helpscout::Client::example();
    let id = find_valid_mailbox_id(&client)?;
    helpscout::api::users().list_by_mailbox(&client, id)
}

// Get first user so get a valid id
fn find_valid_mailbox_id(client: &Client) -> Result<i32, HelpScoutError> {
    let mailboxes = helpscout::api::mailboxes::list(&client)?;
    Ok(mailboxes.items[0].id)
}

Output is the same as list

Trait Implementations

impl Debug for UsersBuilder
[src]

[src]

Formats the value using the given formatter.

impl Default for UsersBuilder
[src]

[src]

Returns the "default value" for a type. Read more

impl Clone for UsersBuilder
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more