marianoguerra/slack/typed does not have a README file

    TypedError

    pub(all) suberror TypedError {
    Slack(
    SlackError
    )
    ResponseShapeError(api_method~ : String, key~ : String)
    } derive(
    Debug
    )

    A typed call's failure.
    impl Show for TypedError

    TypedError::code

    fn TypedError::code(self : TypedError) -> String

    node-slack-sdk's ErrorCode for the wrapped case, and this package's own for the case node has no name for.

    TypedError::describe_error

    fn TypedError::describe_error(self : TypedError) -> String

    TypedError::slack

    The wrapped SlackError, for the cases that actually happen.

    ResponseShapeError is the rare one and the wrapping puts it in the way of the common ones, so this is the shortcut: if e.slack() is Some(err) gets back to a rate limit or a missing_scope in one step.

    Api

    pub struct Api {
    client :
    Client

    }

    A Client, and the extraction step that turns its answers into @model values.

    Holds the client rather than replacing it: Api::client is always there, and mixing the two levels in one function is the expected way to use this.

    Api::chat_post_message

    async fn Api::chat_post_message(self : Api, channel~ : String, text? : String, blocks? : Array[
    LayoutBlock
    ], attachments? : Json, thread_ts? : String, reply_broadcast? : Bool, unfurl_links? : Bool, unfurl_media? : Bool, mrkdwn? : Bool, parse? : String, link_names? : Bool, username? : String, icon_emoji? : String, icon_url? : String, metadata? : Json, markdown_text? : String) -> Posted raise TypedError

    chat.postMessage, as where it landed.

    Posted.channel is an id and not a Channel, because that is what Slack answers here -- even when the request named the channel by name.

    Api::chat_update

    async fn Api::chat_update(self : Api, channel~ : String, ts~ : String, text? : String, blocks? : Array[
    LayoutBlock
    ], attachments? : Json, link_names? : Bool, parse? : String, metadata? : Json, markdown_text? : String) -> Posted raise TypedError

    chat.update, as where the edited message is.

    Api::client

    The low-level client, for everything this package does not wrap.

    Not an escape hatch so much as the other half of the API: Client::call reaches every one of Slack's 326 methods, and ApiResponse.raw reaches every field of every response.

    Api::conversations_create

    async fn Api::conversations_create(self : Api, name~ : String, is_private? : Bool) ->
    Channel
    raise TypedError

    conversations.create, as the channel it created.

    Api::conversations_history

    async fn Api::conversations_history(self : Api, channel~ : String, cursor? : String, limit? : Int, latest? : String, oldest? : String, inclusive? : Bool, include_all_metadata? : Bool) -> Page[
    Message
    ] raise TypedError

    One page of conversations.history.

    Api::conversations_history_all

    async fn Api::conversations_history_all(self : Api, channel~ : String, latest? : String, oldest? : String, page_size? : Int, max_pages? : Int) -> Array[
    Message
    ] raise TypedError

    Every page of conversations.history.

    Api::conversations_info

    async fn Api::conversations_info(self : Api, channel~ : String, include_locale? : Bool, include_num_members? : Bool) ->
    Channel
    raise TypedError

    conversations.info, as a Channel.

    Api::conversations_list

    async fn Api::conversations_list(self : Api, types? : Array[String], exclude_archived? : Bool, limit? : Int, cursor? : String) -> Page[
    Channel
    ] raise TypedError

    One page of conversations.list.

    Api::conversations_list_all

    async fn Api::conversations_list_all(self : Api, types? : Array[String], exclude_archived? : Bool, page_size? : Int, max_pages? : Int) -> Array[
    Channel
    ] raise TypedError

    Every page of conversations.list.

    max_pages is worth setting: this is a Tier 2 method, and a big workspace will rate-limit a full walk.

    Api::conversations_members

    async fn Api::conversations_members(self : Api, channel~ : String, cursor? : String, limit? : Int) -> Page[String] raise TypedError

    One page of conversations.members, which is ids rather than users.

    The key is members, the same key users.list uses for whole user objects. Two methods, one key name, two types -- which is the argument against a generic extractor, in one line.

    Api::conversations_members_all

    async fn Api::conversations_members_all(self : Api, channel~ : String, page_size? : Int, max_pages? : Int) -> Array[String] raise TypedError

    Every page of conversations.members.

    Api::conversations_open

    async fn Api::conversations_open(self : Api, channel? : String, users? : Array[String], return_im? : Bool, prevent_creation? : Bool) ->
    Channel
    raise TypedError

    conversations.open, as the DM or MPIM it opened or found.

    Api::conversations_replies

    async fn Api::conversations_replies(self : Api, channel~ : String, ts~ : String, cursor? : String, limit? : Int, latest? : String, oldest? : String, inclusive? : Bool) -> Page[
    Message
    ] raise TypedError

    One page of conversations.replies: a thread's parent and its replies.

    The parent comes back first and carries thread_ts == ts, which Message::is_thread_reply is the way to tell apart.

    Api::conversations_set_purpose

    async fn Api::conversations_set_purpose(self : Api, channel~ : String, purpose~ : String) ->
    Channel
    raise TypedError

    conversations.setPurpose, as the channel with its new purpose.

    Api::conversations_set_topic

    async fn Api::conversations_set_topic(self : Api, channel~ : String, topic~ : String) ->
    Channel
    raise TypedError

    conversations.setTopic, as the channel with its new topic.

    Api::files_info

    async fn Api::files_info(self : Api, file~ : String, cursor? : String, limit? : Int) ->
    File
    raise TypedError

    files.info, as a File.

    Api::files_list

    async fn Api::files_list(self : Api, channel? : String, user? : String, types? : Array[String], ts_from? : String, ts_to? : String, count? : Int, page? : Int) -> Array[
    File
    ] raise TypedError

    files.list, which pages by number rather than by cursor.

    Hence an array and not a Page: the paging object it answers with is not the cursor scheme the rest of this file uses, and pretending otherwise would hand back a Page whose cursor was always None.

    Api::new

    fn Api::new(transport : &
    Transport
    , token : String, base_url? : String, bool_style? :
    BoolStyle
    , extra_headers? : Map[String, String], team_id? : String) -> Api

    Build the client and wrap it in one step, with Client::new's arguments.

    Api::of

    Wrap an existing client.

    The usual entry point, because a Client is where the transport, the token and the base URL are already configured.

    Api::team_info

    async fn Api::team_info(self : Api, team? : String, domain? : String) ->
    Team
    raise TypedError

    team.info, as a Team.

    Api::usergroups_create

    async fn Api::usergroups_create(self : Api, name~ : String, handle? : String, description? : String, channels? : Array[String], include_count? : Bool) ->
    Usergroup
    raise TypedError

    usergroups.create, as the group it created.

    Api::usergroups_list

    async fn Api::usergroups_list(self : Api, include_disabled? : Bool, include_count? : Bool, include_users? : Bool) -> Array[
    Usergroup
    ] raise TypedError

    usergroups.list, which is not paginated.

    Api::usergroups_users_list

    async fn Api::usergroups_users_list(self : Api, usergroup~ : String, include_disabled? : Bool) -> Array[String] raise TypedError

    usergroups.users.list, which is ids.

    Api::users_conversations

    async fn Api::users_conversations(self : Api, user? : String, types? : Array[String], exclude_archived? : Bool, cursor? : String, limit? : Int) -> Page[
    Channel
    ] raise TypedError

    One page of users.conversations.

    Api::users_info

    async fn Api::users_info(self : Api, user~ : String, include_locale? : Bool) ->
    User
    raise TypedError

    users.info, as a User.

    Api::users_list

    async fn Api::users_list(self : Api, cursor? : String, limit? : Int, include_locale? : Bool) -> Page[
    User
    ] raise TypedError

    One page of users.list.

    The members are objects here. On conversations.members the identically named key holds ids.

    Api::users_list_all

    async fn Api::users_list_all(self : Api, include_locale? : Bool, page_size? : Int, max_pages? : Int) -> Array[
    User
    ] raise TypedError

    Every page of users.list.

    Api::users_lookup_by_email

    async fn Api::users_lookup_by_email(self : Api, email~ : String) ->
    User
    raise TypedError

    users.lookupByEmail, as a User.

    Api::users_profile_get

    async fn Api::users_profile_get(self : Api, user? : String, include_labels? : Bool) ->
    Profile
    raise TypedError

    users.profile.get, as a Profile.

    Api::users_profile_set

    async fn Api::users_profile_set(self : Api, user? : String, profile? : Json, name? : String, value? : String) ->
    Profile
    raise TypedError

    users.profile.set, answering the profile as stored.

    Api::views_open

    async fn Api::views_open(self : Api, trigger_id~ : String, view~ : Json) ->
    View
    raise TypedError

    views.open, as the view Slack stored.

    Api::views_publish

    async fn Api::views_publish(self : Api, user_id~ : String, view~ : Json, hash? : String) ->
    View
    raise TypedError

    views.publish, as the App Home view Slack stored.

    Api::views_push

    async fn Api::views_push(self : Api, trigger_id~ : String, view~ : Json) ->
    View
    raise TypedError

    views.push, as the view it pushed onto the stack.

    Api::views_update

    async fn Api::views_update(self : Api, view~ : Json, view_id? : String, external_id? : String, hash? : String) ->
    View
    raise TypedError

    views.update, as the view after the update.

    Page

    pub(all) struct Page[T] {
    items : Array[T]
    cursor : String?
    response :
    ApiResponse

    }

    One page of a cursor-paginated call.

    Carries the whole response as well as the items, because the interesting fields of a page are not all items -- has_more on conversations.history, the warnings on a partial users.list.

    Page::has_more

    fn[T] Page::has_more(self : Page[T]) -> Bool

    Whether another page exists.

    Posted

    pub(all) struct Posted {
    channel : String
    ts : String
    message :
    Message
    ?
    } derive(Eq)

    What chat.postMessage and chat.update answer.

    Not a Channel: the channel here is an id, which is the clearest case in the whole API for why extraction cannot be generic.

    to_typed_error

    fn to_typed_error(e : Error) -> TypedError

    Narrow an arbitrary Error to a TypedError.

    Variant patterns are the only way to match an error value and they are only in scope in the package that declares them, so a caller outside this one cannot take a TypedError apart from an Error without this. The same shape as @api.to_slack_error, which it delegates to.