diff --git a/codegen/Cargo.lock b/codegen/Cargo.lock index a1a413af..62c7ac8b 100644 --- a/codegen/Cargo.lock +++ b/codegen/Cargo.lock @@ -2,16 +2,24 @@ # It is not intended for manual editing. [[package]] name = "Inflector" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "aho-corasick" -version = "0.6.9" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aho-corasick" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -25,16 +33,26 @@ dependencies = [ "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "anyhow" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "atty" -version = "0.2.11" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "hermit-abi 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)", - "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "autocfg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "autocfg" version = "1.0.1" @@ -77,16 +95,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clap" -version = "2.32.0" +version = "2.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -105,7 +131,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "diff" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -132,14 +158,14 @@ dependencies = [ [[package]] name = "extprim" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -160,6 +186,11 @@ name = "foreign-types-shared" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -221,10 +252,10 @@ dependencies = [ [[package]] name = "getopts" -version = "0.2.18" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -276,7 +307,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -312,7 +343,7 @@ dependencies = [ "http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "httpdate 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "socket2 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -367,7 +398,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "itoa" -version = "0.4.3" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -402,12 +433,12 @@ name = "log" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "log" -version = "0.4.6" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -448,7 +479,7 @@ dependencies = [ "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -473,7 +504,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.30 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.58 (registry+https://github.com/rust-lang/crates.io-index)", @@ -495,8 +526,11 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.6" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "num_cpus" @@ -570,7 +604,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -580,7 +614,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -603,14 +637,6 @@ name = "ppv-lite86" version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "proc-macro2" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "proc-macro2" version = "1.0.24" @@ -619,14 +645,6 @@ dependencies = [ "unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "quote" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "quote" version = "1.0.7" @@ -637,11 +655,19 @@ dependencies = [ [[package]] name = "rand" -version = "0.4.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -657,6 +683,15 @@ dependencies = [ "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -666,6 +701,19 @@ dependencies = [ "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rand_core" version = "0.5.1" @@ -674,6 +722,14 @@ dependencies = [ "getrandom 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_hc" version = "0.2.0" @@ -683,40 +739,87 @@ dependencies = [ ] [[package]] -name = "redox_syscall" -version = "0.1.40" +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] -name = "redox_termios" +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_xorshift" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "regex" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" -version = "1.0.6" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.20 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -724,16 +827,13 @@ name = "regex-syntax" version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ucd-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ucd-util 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.3" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ucd-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "remove_dir_all" @@ -760,14 +860,14 @@ dependencies = [ "ipnet 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project-lite 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.59 (registry+https://github.com/rust-lang/crates.io-index)", "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tls 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -791,28 +891,28 @@ name = "rustfmt" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "diff 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.59 (registry+https://github.com/rust-lang/crates.io-index)", "strings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_errors 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_syntax 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ryu" -version = "0.2.6" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -860,30 +960,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.80" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.80" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "1.0.32" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -892,8 +992,8 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -906,13 +1006,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "slack_api_codegen" version = "0.1.0" dependencies = [ - "Inflector 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.10.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustfmt 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.59 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -922,7 +1023,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -936,22 +1037,12 @@ dependencies = [ [[package]] name = "strsim" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "syn" -version = "0.15.18" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "syn" -version = "1.0.46" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -965,8 +1056,8 @@ version = "0.59.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -977,8 +1068,8 @@ name = "syntex_pos" version = "0.59.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -987,11 +1078,11 @@ version = "0.59.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "extprim 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "extprim 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.59 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_errors 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1005,7 +1096,7 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1020,26 +1111,24 @@ dependencies = [ ] [[package]] -name = "termion" -version = "1.5.1" +name = "textwrap" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "textwrap" -version = "0.10.0" +name = "thread_local" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thread_local" -version = "0.3.6" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1084,17 +1173,17 @@ dependencies = [ "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures-core 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "futures-sink 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project-lite 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "toml" -version = "0.4.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1108,7 +1197,7 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project-lite 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "tracing-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1137,7 +1226,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ucd-util" -version = "0.1.2" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1166,12 +1255,12 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.2.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-width" -version = "0.1.5" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1196,7 +1285,7 @@ dependencies = [ [[package]] name = "utf8-ranges" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1206,7 +1295,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "vec_map" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1219,7 +1308,7 @@ name = "want" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "try-lock 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1234,8 +1323,8 @@ version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.59 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-macro 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1246,10 +1335,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1280,7 +1369,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1346,10 +1435,13 @@ dependencies = [ ] [metadata] -"checksum Inflector 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4467f98bb61f615f8273359bf1c989453dfc1ea4a45ae9298f1dcd0672febe5d" -"checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e" +"checksum Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)" = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5" +"checksum aho-corasick 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b476ce7103678b0c6d3d395dbbae31d48ff910bd28be979ba5d48c6351131d0d" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" +"checksum anyhow 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c" +"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" "checksum base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" @@ -1358,17 +1450,19 @@ dependencies = [ "checksum bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" "checksum cc 1.0.61 (registry+https://github.com/rust-lang/crates.io-index)" = "ed67cbde08356238e75fc4656be4749481eeffb09e19f320a25237d5221c985d" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" +"checksum clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)" = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" "checksum core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" -"checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a" +"checksum diff 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" "checksum dtoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" "checksum encoding_rs 0.8.24 (registry+https://github.com/rust-lang/crates.io-index)" = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" -"checksum extprim 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "054bc2552b3f66fa8097e29e47255bfff583c08e737a67cbbb54b817ddaa5206" +"checksum extprim 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b1a357c911c352439b460d7b375b5c85977b9db395b703dfee5a94dfb4d66a2" "checksum fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures-channel 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0448174b01148032eed37ac4aed28963aaaa8cfa93569a08e5b479bbc6c2c151" @@ -1377,7 +1471,7 @@ dependencies = [ "checksum futures-sink 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0e3ca3f17d6e8804ae5d3df7a7d35b2b3a6fe89dac84b31872720fc3060a0b11" "checksum futures-task 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "96d502af37186c4fef99453df03e374683f8a1eec9dcc1e66b3b82dc8278ce3c" "checksum futures-util 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "abcb44342f62e6f3e8ac427b8aa815f724fd705dfad060b18ac7866c15bb8e34" -"checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797" +"checksum getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" "checksum getrandom 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" "checksum h2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" "checksum hashbrown 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" @@ -1392,13 +1486,13 @@ dependencies = [ "checksum indexmap 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" "checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" "checksum ipnet 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" +"checksum itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" "checksum js-sys 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)" = "ca059e81d9486668f12d455a4ea6daa600bd408134cd17e3d3fb5a32d1f016f8" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.79 (registry+https://github.com/rust-lang/crates.io-index)" = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" +"checksum log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" "checksum mime 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" @@ -1407,7 +1501,7 @@ dependencies = [ "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" "checksum net2 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)" = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" -"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" +"checksum num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" "checksum num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" "checksum once_cell 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" "checksum openssl 0.10.30 (registry+https://github.com/rust-lang/crates.io-index)" = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4" @@ -1422,71 +1516,77 @@ dependencies = [ "checksum pin-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" "checksum pkg-config 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" "checksum ppv-lite86 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" -"checksum proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "3d7b7eaaa90b4a90a932a9ea6666c95a389e424eff347f0f793979289429feee" "checksum proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" -"checksum quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "63b5829244f52738cfee93b3a165c1911388675be000c888d2fae620dee8fa5b" "checksum quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" -"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" +"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" -"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +"checksum redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)" = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" "checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" -"checksum regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee84f70c8c08744ea9641a731c7fadb475bf2ecc52d7f627feb833e0b3990467" +"checksum regex 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8963b85b8ce3074fecffde43b4b0dded83ce2f367dc8d363afc56679f3ee820b" "checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" -"checksum regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fbc557aac2b708fe84121caf261346cc2eed71978024337e42eb46b8a252ac6e" +"checksum regex-syntax 0.6.20 (registry+https://github.com/rust-lang/crates.io-index)" = "8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11c" "checksum remove_dir_all 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" "checksum reqwest 0.10.8 (registry+https://github.com/rust-lang/crates.io-index)" = "e9eaa17ac5d7b838b7503d118fa16ad88f440498bf9ffe5424e621f93190d61e" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustfmt 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec940eed814db0fb7ab928c5f5025f97dc55d1c0e345e39dda2ce9f945557500" -"checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" +"checksum ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" "checksum schannel 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" "checksum security-framework 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" "checksum security-framework-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "15c141fc7027dd265a47c090bf864cf62b42c4d228bbcf4e51a0c9e2b0d3f7ef" -"checksum serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "225de307c6302bec3898c51ca302fc94a7a1697ef0845fcee6448f33c032249c" -"checksum serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "43344e7ce05d0d8280c5940cabb4964bea626aa58b1ec0e8c73fa2a8512a38ce" +"checksum serde 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)" = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" +"checksum serde_derive 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)" = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" +"checksum serde_json 1.0.59 (registry+https://github.com/rust-lang/crates.io-index)" = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95" "checksum serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum socket2 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" "checksum strings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa481ee1bc42fc3df8195f91f7cb43cf8f2b71b48bac40bf5381cfaf7e481f3c" -"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)" = "90c39a061e2f412a9f869540471ab679e85e50c6b05604daf28bc3060f75c430" -"checksum syn 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)" = "5ad5de3220ea04da322618ded2c42233d02baca219d6f160a3e9c87cda16c942" +"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +"checksum syn 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" "checksum syntex_errors 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3133289179676c9f5c5b2845bf5a2e127769f4889fcbada43035ef6bd662605e" "checksum syntex_pos 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "30ab669fa003d208c681f874bbc76d91cc3d32550d16b5d9d2087cf477316470" "checksum syntex_syntax 0.59.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03815b9f04d95828770d9c974aa39c6e1f6ef3114eb77a3ce09008a0d15dd142" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" -"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" -"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" +"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" "checksum tinyvec 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" "checksum tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" "checksum tokio-tls 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" "checksum tokio-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" -"checksum toml 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "4a2ecc31b0351ea18b3fe11274b8db6e4d82bce861bbb22e6dbed40417902c65" +"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" "checksum tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" "checksum tracing 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" "checksum tracing-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" "checksum tracing-futures 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" "checksum try-lock 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" -"checksum ucd-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d0f8bfa9ff0cadcd210129ad9d2c5f145c13e9ced3d3e5d948a6213487d52444" +"checksum ucd-util 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c85f514e095d348c279b1e5cd76795082cf15bd59b93207832abe0b1d8fed236" "checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" -"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" -"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" +"checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +"checksum unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" "checksum url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" -"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" +"checksum utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba" "checksum vcpkg 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" -"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +"checksum vec_map 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" "checksum version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" "checksum want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" "checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 49f79eef..0ae9f109 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -9,10 +9,11 @@ version = "0.1.0" edition = "2018" [dependencies] -Inflector = "~0.11.0" -clap = "~2.32.0" -reqwest = { version = "0.10.8", features = ["blocking", "json"] } -rustfmt = "=0.10.0" -serde = "~1.0.0" -serde_derive = "~1.0.0" -serde_json = "~1.0.0" +anyhow = "1.0" +Inflector = "0.11" +clap = "2.32" +reqwest = { version = "0.10", features = ["blocking", "json"] } +rustfmt = "0.10" +serde = "1.0" +serde_derive = "1.0" +serde_json = "1.0" diff --git a/codegen/src/generator.rs b/codegen/src/generator.rs deleted file mode 100644 index 0763e85a..00000000 --- a/codegen/src/generator.rs +++ /dev/null @@ -1,835 +0,0 @@ -use inflector::Inflector; - -use crate::json_schema::*; - -pub static AUTOGEN_HEADER: &str = " -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -"; - -#[derive(Deserialize, Clone, Debug)] -pub struct Module { - pub name: String, - pub description: Option, - pub methods: Vec, -} - -impl Module { - pub fn generate(&self, gen_mode: GenMode) -> String { - let type_imports = format!( - " - #[allow(unused_imports)] - use std::collections::HashMap; - use std::convert::From; - use std::error::Error; - use std::fmt; - " - ); - - let imports = match gen_mode { - GenMode::Types => vec![type_imports], - GenMode::Sync => vec![ - format!("use crate::sync::requests::SlackWebRequestSender;"), - format!( - "pub use crate::mod_types::{}_types::*;", - self.get_safe_name() - ), - ], - GenMode::Async => vec![ - format!("use crate::requests::SlackWebRequestSender;"), - format!( - "pub use crate::mod_types::{}_types::*;", - self.get_safe_name() - ), - ], - }; - - format!( - "{header} - - {docs} - - {imports} - - {methods}", - header = AUTOGEN_HEADER, - docs = self - .description - .as_ref() - .map(|d| format_docs("//!", d)) - .unwrap_or_default(), - methods = self - .methods - .iter() - .map(|p| p.generate(gen_mode)) - .collect::>() - .join("\n"), - imports = imports.join("\n"), - ) - } - - pub fn get_safe_name(&self) -> String { - self.name.replace('.', "_") - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum GenMode { - Async, - Sync, - Types, -} - -impl GenMode { - fn dot_await(self) -> &'static str { - match self { - GenMode::Async => ".await", - GenMode::Sync => "", - _ => unreachable!(), - } - } - fn fn_type(self) -> &'static str { - match self { - GenMode::Async => "async fn", - GenMode::Sync => "fn", - _ => unreachable!(), - } - } -} - -#[derive(Deserialize, Clone, Debug)] -pub struct Method { - pub name: String, - pub description: String, - #[serde(rename = "documentationUrl")] - pub documentation_url: String, - pub params: Vec, - pub response: Response, -} - -impl Method { - pub fn generate(&self, gen_mode: GenMode) -> String { - // HACK: these methods requires multipart support, which is not yet supported by this library - if self.name == "files.upload" || self.name == "users.setPhoto" { - return String::new(); - } - - let fn_name = self.name.split('.').last().unwrap().to_snake_case(); - let type_prefix = self.name.split('.').last().unwrap().to_pascal_case(); - let request_struct_name = type_prefix.clone() + "Request"; - let response_struct_name = type_prefix.clone() + "Response"; - let error_enum_name = type_prefix.clone() + "Error"; - let response = self - .response - .generate(&response_struct_name, &error_enum_name); - let response_type = self.response.get_response_type(&response_struct_name); - - let send_call = || { - let mut base_call = format!( - "\ - let url = crate::get_slack_url_for_method(\"{name}\"); - client.send(&url, ¶ms[..]) - {dot_await} - .map_err({error_type}::Client) - .and_then(|result| {{ - serde_json::from_str::<{response_type}>(&result) - .map_err(|e| {error_type}::MalformedResponse(result, e)) - }})", - name = self.name, - response_type = response_struct_name, - error_type = error_enum_name, - dot_await = gen_mode.dot_await(), - ); - - match response_type { - PropType::Obj(ref o) => { - if o.has_ok() { - base_call.push_str(".and_then(|o| o.into())") - } - } - PropType::Enum(ref e) => { - if e.has_ok() { - base_call.push_str(".and_then(|o| o.into())") - } - } - _ => panic!( - "Top-level response for {} is not an object or enum.", - fn_name - ), - } - - base_call - }; - - if self.params.is_empty() { - if gen_mode == GenMode::Types { - return format!( - "\ - - {response} - ", - response = response, - ); - } - - format!("\ - {documentation} - pub {fn_type} {method_name}(client: &R) -> Result<{response_type}, {error_type}> - where R: SlackWebRequestSender - {{ - let params = &[]; - {send_call} - }} - ", - documentation = format_docs("///", &[ - &self.description, - "", - &format!("Wraps {}", self.documentation_url) - ].join("\n")), - method_name = fn_name, - response_type = response_struct_name, - error_type = error_enum_name, - send_call = send_call(), - fn_type = gen_mode.fn_type(), - ) - } else if self.params.len() == 1 && self.params[0].ty == "auth_token" { - if gen_mode == GenMode::Types { - return format!( - "\ - - {response} - ", - response = response, - ); - } - format!("\ - {documentation} - pub {fn_type} {method_name}(client: &R, token: &str) -> Result<{response_type}, {error_type}> - where R: SlackWebRequestSender - {{ - let params = &[(\"token\", token)]; - {send_call} - }} - ", - documentation = format_docs("///", &[ - &self.description, - "", - &format!("Wraps {}", self.documentation_url) - ].join("\n")), - method_name = fn_name, - response_type = response_struct_name, - error_type = error_enum_name, - send_call = send_call(), - fn_type = gen_mode.fn_type(), - ) - } else { - let has_token = self.params.iter().any(|p| p.ty == "auth_token"); - let lifetime = if self.has_lifetime() { "<'_>" } else { "" }; - let method_params = if has_token { - format!( - "client: &R, token: &str, request: &{}{}", - request_struct_name, lifetime - ) - } else { - format!("client: &R, request: &{}{}", request_struct_name, lifetime) - }; - if gen_mode == GenMode::Types { - return format!( - "\ - - {request} - - {response} - ", - response = response, - request = self.get_request_struct(&request_struct_name, gen_mode), - ); - } - format!("\ - {documentation} - pub {fn_type} {method_name}({method_params}) -> Result<{response_type}, {error_type}> - where R: SlackWebRequestSender - {{ - {local_vars} - let params = vec![ - {token} - {param_pairs} - ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); - {send_call} - }} - ", - documentation = format_docs("///", &[ - &self.description, - "", - &format!("Wraps {}", self.documentation_url) - ].join("\n")), - method_name = fn_name, - response_type = response_struct_name, - error_type = error_enum_name, - method_params = method_params, - token = if has_token { "Some((\"token\", token))," } else { "" }, - local_vars = self.params.iter() - .filter(|p| p.ty != "auth_token") // passed in method params instead - .filter(|p| p.name != "simple_latest") // HACK: simple_latest breaks deserialization - .filter_map(|p| p.lifted()) - .collect::>() - .join("\n"), - param_pairs = self.params.iter() - .filter(|p| p.ty != "auth_token") // passed in method params instead - .filter(|p| p.name != "simple_latest") // HACK: simple_latest breaks deserialization - .map(Param::get_pair) - .collect::>() - .join(",\n"), - send_call = send_call(), - fn_type = gen_mode.fn_type(), - ) - } - } - - fn has_lifetime(&self) -> bool { - !self - .params - .iter() - .filter(|p| p.ty != "auth_token") - .all(|p| p.ty == "integer" || p.ty == "boolean") - } - - fn get_request_struct(&self, ty_name: &str, gen_mode: GenMode) -> String { - format!( - "\ - #[derive(Clone, Default, Debug)] - pub struct {request_type}{lifetime} {{ - {request_params} - }}", - request_type = ty_name, - request_params = self - .params - .iter() - .filter(|p| p.ty != "auth_token") // passed in method params instead - .filter(|p| p.name != "simple_latest") // HACK: simple_latest breaks deserialization - .map(|p| p.generate(gen_mode)) - .collect::>() - .join("\n"), - lifetime = if self.has_lifetime() { "<'a>" } else { "" } - ) - } -} - -pub trait Okable { - fn has_ok(&self) -> bool; -} - -impl Okable for JsonObject { - fn has_ok(&self) -> bool { - self.fields.iter().any(|f| f.name == "ok") - } -} - -impl Okable for JsonEnum { - fn has_ok(&self) -> bool { - self.variants.iter().all(|v| match v.inner { - PropType::Obj(ref o) => o.has_ok(), - PropType::Enum(ref e) => e.has_ok(), - _ => false, - }) - } -} - -fn generate_matches(enm: &JsonEnum, var_name: &str, f: F) -> Vec -where - F: Fn(&JsonEnumVariant) -> String, -{ - enm.variants - .iter() - .map(|v| { - format!( - "{variant}({var_name}) => {body},", - variant = v.qualified_name, - var_name = var_name, - body = f(v) - ) - }) - .collect() -} - -fn get_obj_to_response_impl(obj: &JsonObject, error_type: &str) -> Option { - if obj.has_ok() { - Some(format!( - "\ - impl Into>> for {name} {{ - fn into(self) -> Result<{name}, {error_ty}> {{ - if self.ok {{ - Ok(self) - }} else {{ - Err(self.error.as_ref().map(String::as_ref).unwrap_or(\"\").into()) - }} - }} - }}", - error_ty = error_type, - name = obj.name - )) - } else { - None - } -} - -fn get_enum_to_response_impl(enm: &JsonEnum, error_type: &str) -> Option { - if enm.has_ok() { - Some(format!( - "\ - impl Into>> for {name} {{ - fn into(self) -> Result<{name}, {error_ty}> {{ - match self {{ - {matches} - }} - }} - }} - - {inner_impls}", - error_ty = error_type, - name = enm.name, - matches = generate_matches(enm, "inner", |v| { - format!( - "{{ let x: Result<{}, {}> = inner.into(); x.map({}) }}", - enm.name.clone() + &v.name, - error_type, - v.qualified_name - ) - }) - .join("\n"), - inner_impls = enm - .variants - .iter() - .map(|v| match v.inner { - PropType::Obj(ref o) => get_obj_to_response_impl(o, error_type) - .expect("Top-level enum inner object did not have \"ok\" field."), - PropType::Enum(ref e) => get_enum_to_response_impl(e, error_type) - .expect("Top-level enum inner variant did not have \"ok\" field."), - _ => panic!( - "Top-level enum is does not contain a type that can have an \"ok\" field." - ), - }) - .collect::>() - .join("\n") - )) - } else { - None - } -} - -#[derive(Deserialize, Clone, Debug)] -pub struct Response { - pub sample: String, - pub schema: JsonSchema, - pub errors: Vec, -} - -impl Response { - pub fn generate(&self, ty_name: &str, error_ty: &str) -> String { - let (objs, to_result) = match PropType::from_schema(&self.schema, ty_name) { - PropType::Obj(ref o) => { - let to_result = get_obj_to_response_impl(o, error_ty); - (o.to_code(), to_result) - } - PropType::Enum(ref e) => { - let to_result = get_enum_to_response_impl(e, error_ty); - (e.to_code(), to_result) - } - _ => panic!( - "Top level response schema for {} is not an object or enum. {:?}", - ty_name, self.schema - ), - }; - format!( - "\ - {objs} - {slack_result} - {errors}", - objs = objs, - slack_result = to_result.unwrap_or_default(), - errors = self.get_error_enum(error_ty), - ) - } - - pub fn get_response_type(&self, ty_name: &str) -> PropType { - PropType::from_schema(&self.schema, ty_name) - } - - fn get_error_enum(&self, error_ty: &str) -> String { - format!( - "\ - #[derive(Debug)] - pub enum {error_type} {{ - {variants} - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E) - }} - - impl<'a, E: Error> From<&'a str> for {error_type} {{ - fn from(s: &'a str) -> Self {{ - match s {{ - {matches} - _ => {error_type}::Unknown(s.to_owned()) - }} - }} - }} - - impl fmt::Display for {error_type} {{ - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {{ - let d = match *self {{ - {description_matches} - {error_type}::MalformedResponse(_, ref e) => return write!(f, \"{{}}\", e), - {error_type}::Unknown(ref s) => return write!(f, \"{{}}\", s), - {error_type}::Client(ref inner) => return write!(f, \"{{}}\", inner), - }}; - write!(f, \"{{}}\", d) - }} - }} - - impl Error for {error_type} {{ - fn source(&self) -> Option<&(dyn Error + 'static)> {{ - match *self {{ - {error_type}::MalformedResponse(_, ref e) => Some(e), - {error_type}::Client(ref inner) => Some(inner), - _ => None, - }} - }} - }}", - error_type = error_ty, - variants = self - .errors - .iter() - .map(|e| { - format!( - "{docs}\n{name},", - docs = format_docs("///", &e.description), - name = e.name.to_pascal_case() - ) - }) - .collect::>() - .join("\n"), - matches = self - .errors - .iter() - .map(|e| { - format!( - "\"{str_name}\" => {error_ty}::{ty_name},", - error_ty = error_ty, - str_name = e.name, - ty_name = e.name.to_pascal_case() - ) - }) - .collect::>() - .join("\n"), - description_matches = self - .errors - .iter() - .map(|e| { - format!( - "{error_ty}::{ty_name} => \"{str_name}: {description}\",", - error_ty = error_ty, - str_name = e.name, - description = e.description, - ty_name = e.name.to_pascal_case() - ) - }) - .collect::>() - .join("\n") - ) - } -} - -#[derive(Deserialize, Clone, Debug)] -pub struct Param { - pub name: String, - pub description: String, - #[serde(rename = "type")] - pub ty: String, - pub optional: bool, -} - -impl Param { - fn generate(&self, _gen_mode: GenMode) -> String { - format!( - "{documentation}\npub {name}: {ty},", - documentation = format_docs("///", &self.description), - name = self.name, - ty = self.get_rust_type() - ) - } - - pub fn lifted(&self) -> Option { - match (&self.ty[..], self.optional) { - ("timestamp", true) => Some(format!( - "let {name} = request.{name}.as_ref().map(|t| t.to_param_value());", - name = self.name - )), - ("timestamp", false) => Some(format!( - "let {name} = request.{name}.to_param_value();", - name = self.name - )), - ("integer", true) => Some(format!( - "let {name} = request.{name}.map(|{name}| {name}.to_string());", - name = self.name - )), - ("integer", false) => Some(format!( - "let {name} = request.{name}.to_string();", - name = self.name - )), - _ => None, - } - } - - pub fn get_pair(&self) -> String { - match (&self.ty[..], self.optional) { - ("boolean", true) => format!( - "request.{name}.map(|{name}| (\"{name}\", if {name} {{ \"1\" }} else {{ \"0\" }}))", - name = self.name - ), - ("boolean", false) => format!( - "Some((\"{name}\", if request.{name} {{ \"1\" }} else {{ \"0\" }}))", - name = self.name - ), - ("integer", true) => { - // lifted into local variable, using {name} instead of request.{name} - format!( - "{name}.as_ref().map(|{name}| (\"{name}\", &{name}[..]))", - name = self.name - ) - } - ("integer", false) => { - // lifted into local variable, using {name} instead of request.{name} - format!("Some((\"{name}\", &{name}[..]))", name = self.name) - } - ("timestamp", true) => { - // lifted into local variable, using {name} instead of request.{name} - format!( - "{name}.as_ref().map(|{name}| (\"{name}\", &{name}[..]))", - name = self.name - ) - } - ("timestamp", false) => { - // lifted into local variable, using {name} instead of request.{name} - format!("Some((\"{name}\", &{name}[..]))", name = self.name) - } - (_, true) => format!( - "request.{name}.map(|{name}| (\"{name}\", {name}))", - name = self.name - ), - (_, false) => format!("Some((\"{name}\", request.{name}))", name = self.name), - } - } - - fn get_rust_type(&self) -> String { - let ty = match &self.ty[..] { - "timestamp" => "crate::Timestamp", - "boolean" => "bool", - "integer" => "u32", - _ => "&'a str", - }; - if self.optional { - format!("Option<{}>", ty) - } else { - ty.to_owned() - } - } -} - -impl JsonObjectFieldInfo { - pub fn to_code(&self) -> String { - let mut prefix = String::new(); - - if let Some(path) = self.deserialize_with { - prefix.push_str(&format!("#[serde(deserialize_with = \"{}\")]\n", path)); - } - - if self.default { - prefix.push_str("#[serde(default)]\n"); - } - - if self.name == "ok" { - prefix.push_str("#[serde(default)]"); - } else if self.name != "error" && self.name != "ok" { - prefix.push_str("pub"); - }; - - if let Some(ref rename) = self.rename { - format!( - "#[serde(rename = \"{}\")]\n{} {}: {},", - rename, - prefix, - self.name, - self.ty.to_rs_type() - ) - } else { - format!("{} {}: {},", prefix, self.name, self.ty.to_rs_type()) - } - } -} - -impl JsonEnumVariant { - pub fn to_code(&self) -> String { - format!( - "{name}({inner}),", - name = self.name, - inner = self.inner.to_rs_type() - ) - } -} - -impl JsonEnum { - pub fn to_code(&self) -> String { - if self.name == "Timestamp" { - return String::new(); - } - - // Hack to work around message having a different identifier here - let (variant_field, on_missing_field) = if self.name == "Message" { - ( - "subtype", - "::serde_json::from_value::(value.clone()) - .map(Message::Standard) - .map_err(|e| D::Error::custom(&format!(\"{}\", e)))", - ) - } else { - ("type", "Err(D::Error::missing_field(\"type\"))") - }; - - let mut subobjs = self.variants.clone(); - - subobjs.sort_by_key(|v| v.name.clone()); - - let subobjs = subobjs - .iter() - .flat_map(|v| obj_recur(&v.inner)) - .collect::>() - .join("\n"); - - format!("\ - #[derive(Clone, Debug)] - pub enum {name} {{ - {variants} - }} - - impl<'de> ::serde::Deserialize<'de> for {name} {{ - fn deserialize(deserializer: D) -> Result - where D: ::serde::Deserializer<'de> - {{ - use ::serde::de::Error as SerdeError; - - const VARIANTS: &[&str] = &[{variant_names}]; - - let value = ::serde_json::Value::deserialize(deserializer)?; - if let Some(ty_val) = value.get(\"{variant_field}\") {{ - if let Some(ty) = ty_val.as_str() {{ - match ty {{ - {variant_matches} - _ => Err(D::Error::unknown_variant(ty, VARIANTS)) - }} - }} else {{ - Err(D::Error::invalid_type(::serde::de::Unexpected::Unit, &\"a string\")) - }} - }} else {{ - {on_missing_field} - }} - }} - }} - - {subobjs}", - name = self.name, - variants = self.variants - .iter() - .map(|v| v.to_code()) - .collect::>() - .join("\n"), - variant_names = self.variants - .iter() - .map(|v| format!("\"{}\"", v.name.to_snake_case())) - .collect::>() - .join(","), - variant_matches = self.variants - .iter() - .map(|v| format!("\ - \"{type_name}\" => {{ - ::serde_json::from_value::<{variant_type}>(value.clone()) - .map({variant_name}) - .map_err(|e| D::Error::custom(&format!(\"{{}}\", e))) - }}", - type_name = v.name.to_snake_case(), - variant_type = v.inner.to_rs_type(), - variant_name = v.qualified_name - )) - .collect::>() - .join("\n"), - subobjs = subobjs, - variant_field = variant_field, - on_missing_field = on_missing_field - ) - } -} - -fn obj_recur(prop: &PropType) -> Vec { - match *prop { - PropType::Obj(ref o) => vec![o.to_code()], - PropType::Arr(ref prop) | PropType::Map(ref prop) | PropType::Optional(ref prop) => { - obj_recur(prop) - } - PropType::Enum(ref e) => vec![e.to_code()], - _ => vec![], - } -} - -impl JsonObject { - pub fn to_code(&self) -> String { - let subobjs = self - .fields - .iter() - .flat_map(|f| obj_recur(&f.ty)) - .collect::>(); - - let mut fields = self.fields.clone(); - fields.sort_by_key(|f| f.name.clone()); - - let fields = fields.iter().map(|f| f.to_code()).collect::>(); - - format!( - "\ - #[derive(Clone, Debug, Deserialize)] - pub struct {name} {{ - {fields} - }} - - {subobjs}", - name = self.name, - fields = fields.join("\n"), - subobjs = subobjs.join("\n") - ) - } -} - -#[derive(Deserialize, Clone, Debug)] -pub struct ApiError { - pub name: String, - pub description: String, -} - -fn format_docs(prefix: &str, s: &str) -> String { - s.lines().map(|l| format!("{} {}\n", prefix, l)).collect() -} diff --git a/codegen/src/json_schema.rs b/codegen/src/json_schema.rs deleted file mode 100644 index c7dc2ed6..00000000 --- a/codegen/src/json_schema.rs +++ /dev/null @@ -1,224 +0,0 @@ -use std::collections::BTreeMap; -use std::path::Path; - -use inflector::Inflector; - -#[derive(Deserialize, Clone, Debug)] -pub struct JsonSchema { - pub id: Option, - pub title: Option, - #[serde(rename = "$schema")] - pub schema_ref: Option, - pub description: Option, - #[serde(rename = "type")] - pub ty: Option, - pub properties: Option>, - pub required: Option>, - pub definitions: Option>, - pub items: Option>, - #[serde(rename = "patternProperties")] - pub pattern_properties: Option>, - #[serde(default, rename = "additionalProperties")] - pub additional_properties: bool, - #[serde(rename = "$ref")] - pub definition_ref: Option, - #[serde(rename = "oneOf")] - pub one_of: Option>, -} - -#[derive(Clone, Debug)] -pub struct JsonObject { - pub name: String, - pub fields: Vec, -} - -#[derive(Clone, Debug)] -pub struct JsonObjectFieldInfo { - pub name: String, - pub ty: PropType, - pub rename: Option, - pub deserialize_with: Option<&'static str>, - pub default: bool, -} - -#[derive(Clone, Debug)] -pub struct JsonEnum { - pub name: String, - pub variants: Vec, -} - -#[derive(Clone, Debug)] -pub struct JsonEnumVariant { - pub name: String, - pub qualified_name: String, - // TODO: this should be able to support non-containing variants - pub inner: PropType, -} - -#[derive(Clone, Debug)] -pub enum PropType { - Str, - Int, - Num, - Bool, - Ref(String), - Obj(JsonObject), - Arr(Box), - Map(Box), - Optional(Box), - Enum(JsonEnum), - Null, -} - -impl PropType { - pub fn from_schema(schema: &JsonSchema, name: &str) -> Self { - if let Some(ref def) = schema.definition_ref { - // TODO: This ignores `#/` and assumes filenames refer to an existing struct with that - // name. - return PropType::Ref( - Path::new(def) - .file_stem() - .unwrap() - .to_str() - .unwrap() - .to_owned() - .to_pascal_case(), - ); - } - - if let Some(ref one_of) = schema.one_of { - return PropType::Enum(JsonEnum { - name: name.to_owned(), - variants: one_of - .iter() - .map(|o| { - // TODO: Have this just check title. id is not reliable - let variant_name = o - .title - .as_ref() - .or_else(|| o.id.as_ref()) - .or_else(|| o.ty.as_ref()) - .expect("variant name") - .to_pascal_case(); - let obj_name = name.to_owned() + &variant_name; - JsonEnumVariant { - name: variant_name.clone(), - qualified_name: format!("{}::{}", name.to_owned(), variant_name), - inner: Self::from_schema(o, &obj_name), - } - }) - .collect(), - }); - } - - match schema.ty.as_ref().map(String::as_ref) { - Some("boolean") => PropType::Bool, - Some("string") => PropType::Str, - Some("integer") => PropType::Int, - Some("number") => PropType::Num, - Some("null") => PropType::Null, - Some("array") => { - // HACK: to_singular is broken in current Inflector release - let item_name = if name.ends_with("ies") { - name[..name.len() - 3].to_owned() + "y" - } else { - name.to_singular() - }; - let item_schema = schema.items.as_ref().expect(&format!( - "{} is an array but no schema is set for items", - item_name - )); - let subobj = Self::from_schema(&item_schema.clone(), &item_name); - PropType::Arr(Box::new(subobj)) - } - Some("object") => { - if let Some(ref pp) = schema.pattern_properties { - let subobj_schema = pp.iter().next().unwrap().1; - let subobj = Self::from_schema(subobj_schema, name); - PropType::Map(Box::new(subobj)) - } else { - PropType::Obj( - schema - .properties - .clone() - .map(|p| { - if p.is_empty() { - println!( - "{} is an object but has no properties. Likely an error.", - &name - ); - } - let fields = p - .iter() - .map(|(orig_name, p)| { - let (field_name, rename) = match &orig_name[..] { - "type" => ("ty", Some("type".into())), - "self" => ("slf", Some("self".into())), - name => (name, None), - }; - let field_ty_name = - name.to_owned() + &orig_name.to_pascal_case(); - let mut ty = Self::from_schema(p, &field_ty_name); - if let Some(ref req) = schema.required { - if !req.contains(orig_name) { - ty = PropType::Optional(Box::new(ty)); - } - } else { - ty = PropType::Optional(Box::new(ty)); - } - // Hack for slack bug which writes empty map as empty array - let default; - let deserialize_with; - if name == "UserProfile" && field_name == "fields" { - deserialize_with = - Some("crate::optional_struct_or_empty_array"); - default = true; - } else if name == "MessageBotMessage" - && field_name == "icons" - { - deserialize_with = - Some("crate::optional_struct_or_empty_array"); - default = true; - } else { - deserialize_with = None; - default = false; - } - JsonObjectFieldInfo { - name: field_name.into(), - ty: ty, - rename: rename, - deserialize_with: deserialize_with, - default: default, - } - }) - .collect(); - - JsonObject { - name: name.to_owned(), - fields: fields, - } - }) - .expect("Failed to get sub object for object"), - ) - } - } - ty => panic!("Unknown JSON type: {:?} for {}", ty, name), - } - } - - pub fn to_rs_type(&self) -> String { - match *self { - PropType::Str => "String".into(), - PropType::Int => "i32".into(), - PropType::Num => "f32".into(), - PropType::Bool => "bool".into(), - PropType::Null => "()".into(), - PropType::Obj(ref obj) => obj.name.clone(), - PropType::Ref(ref name) => format!("crate::{}", name), - PropType::Arr(ref prop) => format!("Vec<{}>", prop.to_rs_type()), - PropType::Map(ref prop) => format!("HashMap", prop.to_rs_type()), - PropType::Optional(ref prop) => format!("Option<{}>", prop.to_rs_type()), - PropType::Enum(ref e) => e.name.clone(), - } - } -} diff --git a/codegen/src/main.rs b/codegen/src/main.rs index 4edb5fb5..355ccc13 100644 --- a/codegen/src/main.rs +++ b/codegen/src/main.rs @@ -1,146 +1,46 @@ -#[macro_use] -extern crate serde_derive; - -use serde_json; - -use std::fs::{self, File, OpenOptions}; -use std::io::{self, Read, Write}; -use std::path::Path; -use std::process::Command; - +#![allow(dead_code)] +#![allow(unused_variables)] + +use std::collections::HashMap; +use std::convert::TryFrom; +use std::fmt; +use std::fs; +use std::io::Write; +use std::iter::Peekable; +use std::path::{Path, PathBuf}; + +use anyhow::{bail, Context, Result}; use clap::{App, Arg}; -use inflector::Inflector; use reqwest::blocking::Client; +use serde::Serialize; -mod json_schema; -use crate::json_schema::{JsonSchema, PropType}; - -mod generator; -use crate::generator::*; +mod rust; +use rust::{GenMode, HttpMethod, Method, Module, ModuleBuilder, Parameter, Response}; mod schema; -use schema::Spec; +use schema::{Operation, PathItem, Spec}; mod vec_or_single; -const SCHEMA_DIR: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/slack-api-schemas"); -const DEFAULT_OUT_DIR: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/../src"); -const SLACK_API_SCHEMA: &'static str = "https://api.slack.com/specs/openapi/v2/slack_web.json"; - -fn generate_types(output_path: &Path) -> io::Result<()> { - let codegen_filepath = output_path.join("types.rs"); - - let mut types_file = OpenOptions::new() - .write(true) - .truncate(true) - .create(true) - .open(&codegen_filepath)?; - - types_file.write_all(generator::AUTOGEN_HEADER.as_bytes())?; - types_file.write_all(b"use std::collections::HashMap;\n\n")?; - - let schema_path = Path::new(SCHEMA_DIR); - - for entry in fs::read_dir(schema_path.join("objects"))? { - if let Ok(e) = entry { - let path = e.path(); - if path.is_file() { - let mut schema_file = File::open(&path)?; - let mut schema_contents = String::new(); - schema_file.read_to_string(&mut schema_contents)?; +const DEFAULT_OUT_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../src"); +const SLACK_API_SCHEMA: &str = "https://api.slack.com/specs/openapi/v2/slack_web.json"; - let schema = serde_json::from_str::(&schema_contents).expect(&format!( - "Could not parse object schema for {}", - path.display() - )); - - let ty_name = path.file_stem().unwrap().to_str().unwrap().to_pascal_case(); - - let ty = match PropType::from_schema(&schema, &ty_name) { - PropType::Obj(ref o) => o.to_code(), - PropType::Enum(ref e) => e.to_code(), - _ => panic!("Object schema is not an object."), - }; - - types_file.write_all(ty.as_bytes())?; - } - } - } - - Command::new("rustfmt") - .args(&["--edition", "2018"]) - .arg(codegen_filepath) - .output()?; - - Ok(()) +struct Arguments { + outdir: PathBuf, } -fn generate_modules(output_path: &Path, gen_mode: GenMode) -> io::Result<()> { - let mut mods = vec![]; - - let schema_path = Path::new(SCHEMA_DIR); - - let postfix = if gen_mode == GenMode::Types { - "_types" - } else { - "" - }; - - for entry in fs::read_dir(schema_path.join("web"))? { - if let Ok(e) = entry { - let path = e.path(); - if path.is_file() { - let mut schema_file = File::open(&path)?; - let mut schema_contents = String::new(); - schema_file.read_to_string(&mut schema_contents)?; - - let module = serde_json::from_str::(&schema_contents).expect(&format!( - "Could not parse module schema for {}", - path.display() - )); - - let mod_name = format!("{}{}", module.get_safe_name(), postfix); - - mods.push(mod_name.clone()); - - let out_filepath = output_path.join(format!("{}.rs", mod_name)); - - { - let mut out_file = OpenOptions::new() - .write(true) - .truncate(true) - .create(true) - .open(&out_filepath)?; - - out_file.write_all(module.generate(gen_mode).as_bytes())?; - } - - Command::new("rustfmt") - .args(&["--edition", "2018"]) - .arg(out_filepath) - .output()?; - } - } - } - - let mut mod_file = OpenOptions::new() - .write(true) - .truncate(true) - .create(true) - .open(output_path.join("mod.rs"))?; - - mod_file.write_all( - mods.iter() - .map(|modname| format!("pub mod {};", modname)) - .collect::>() - .join("\n") - .as_bytes(), - )?; - +fn main() -> Result<()> { + let arguments = handle_arguments()?; + let mut spec = fetch_slack_api_spec()?; + spec.replace_refs()?; + let modules = transform_to_modules(&spec)?; + debug(&modules); + debug_json(&spec.paths); + generate(&arguments.outdir, &modules)?; Ok(()) } -fn main() { +fn handle_arguments() -> Result { let matches = App::new("slack-rs API Code Generator") .arg( Arg::with_name("out_dir") @@ -159,47 +59,183 @@ fn main() { ) .get_matches(); - let outdir = Path::new(matches.value_of_os("out_dir").unwrap()); - if !outdir.exists() { - let _ = fs::create_dir(outdir); - } + let outdir = PathBuf::from( + matches + .value_of_os("out_dir") + .context("argument `out_dir missing`")?, + ); + Ok(Arguments { outdir }) +} - let schema: Spec = Client::new() +fn fetch_slack_api_spec() -> Result { + Client::new() .get(SLACK_API_SCHEMA) .send() - .expect("Unable to send request to slack api") + .context("Unable to send request to slack api")? .error_for_status() - .expect("Slack Server send failure code") + .context("Slack Server send failure code")? .json() - .expect("Unable to deserialize slack server response"); + .context("Unable to deserialize slack server response") +} + +fn debug(data: D) { + std::fs::File::create("/tmp_crypt/slack.debug") + .unwrap() + .write_all(format!("{:#?}", data).as_bytes()) + .unwrap(); +} + +fn debug_json(data: D) { + let data = serde_json::to_string_pretty(&data).expect("Unable to serialize debug data"); + std::fs::File::create("/tmp_crypt/slack.json") + .unwrap() + .write_all(data.as_bytes()) + .unwrap(); +} + +fn transform_to_modules(spec: &Spec) -> Result> { + let mut modules: HashMap<&str, ModuleBuilder> = HashMap::new(); + for (full_name, path) in &spec.paths { + let mut module_names = module_iterator(full_name); + let top_path = first_path_from_iterator(&mut module_names, full_name)?; + let mut module = add_module_if_not_exists(&mut modules, top_path); + add_submodules(&mut module_names, &mut module, path)?; + } + Ok(modules.into_iter().map(|(_, v)| v.build()).collect()) +} +fn module_iterator<'a>(full_name: &'a str) -> Peekable> { + full_name.trim_start_matches('/').split('.').peekable() +} + +fn first_path_from_iterator<'a>( + i: &mut impl Iterator, + full_name: &str, +) -> Result<&'a str> { + i.next() + .with_context(|| format!("Path does not have a top name: {}", full_name)) +} - // { - // let moddir = outdir.join("mod_types"); - // if !moddir.exists() { - // let _ = fs::create_dir(&moddir); - // } +fn add_module_if_not_exists<'a, 'b>( + modules: &'b mut HashMap<&'a str, ModuleBuilder<'a>>, + name: &'a str, +) -> &'b mut ModuleBuilder<'a> { + modules + .entry(name) + .or_insert_with(|| ModuleBuilder::new(name)) +} + +fn add_submodules<'a>( + module_names: &mut Peekable>, + mut module: &mut ModuleBuilder<'a>, + path: &PathItem, +) -> Result<()> { + while let Some(name) = module_names.next() { + if module_names.peek().is_some() { + module = add_module_if_not_exists(&mut module.submodules, name); + } else { + if let Some(op) = &path.get { + add_method_if_not_exists(module, name, op, HttpMethod::Get)?; + } + if let Some(op) = &path.post { + add_method_if_not_exists(module, name, op, HttpMethod::Post)?; + } + } + } + Ok(()) +} - // generate_modules(&moddir, GenMode::Types).unwrap(); - // } +fn add_method_if_not_exists<'a>( + module: &mut ModuleBuilder<'a>, + name: &'a str, + op: &Operation, + http_method: HttpMethod, +) -> Result<()> { + let method = create_method(module, name, op, http_method)?; + if let Some(cur) = module.methods.get(name) { + bail!(format!( + "Method with the name {} already exists for module {}. \nOld: {:#?}\nNew: {:#?}", + name, module.name, cur, method, + )); + } else { + module.methods.insert(name, method); + } + Ok(()) +} - // { - // let moddir = outdir.join("async_impl").join("mods"); - // if !moddir.exists() { - // let _ = fs::create_dir(&moddir); - // } +fn create_method( + module: &mut ModuleBuilder<'_>, + name: &str, + op: &Operation, + http_method: HttpMethod, +) -> Result { + let response: schema::Schema = op + .responses + .get("200") + .with_context(|| { + format!( + "Method {} in module {} is missing the 200 response", + name, module.name + ) + })? + .schema + .clone(); + let response = op.responses.values().fold(response, |mut acc, res| { + acc.merge(&res.schema); + acc + }); + let response = Response::try_from(&response).with_context(|| { + format!( + "Unable to convert type in method {} in module {}", + name, module.name + ) + })?; + let mut method = Method { + name: name.into(), + description: op.description.clone(), + documentation_url: op.external_docs.url.clone(), + parameters: Vec::new(), + response, + http_method, + }; + for parameter in &op.parameters { + let parameter = match parameter.location.as_ref() { + "header" if parameter.name == "token" => continue, + "query" if parameter.name == "token" => continue, + "formData" | "query" => Parameter::try_from(parameter)?, + loc => bail!(format!( + "Unsupported paramter location {} for {}", + loc, parameter.name + )), + }; + method.parameters.push(parameter); + } + Ok(method) +} - // generate_modules(&moddir, GenMode::Async).unwrap(); - // } +fn generate(outdir: &Path, modules: &[Module]) -> Result<()> { + if !outdir.exists() { + fs::create_dir_all(outdir) + .with_context(|| format!("Unable to create directory at: {:?}", outdir))?; + } - // { - // let moddir = outdir.join("sync").join("mods"); - // if !moddir.exists() { - // let _ = fs::create_dir(&moddir); - // } + let moddir = outdir.join("mod_types"); + if !moddir.exists() { + fs::create_dir_all(&moddir) + .with_context(|| format!("Unable to create directory at: {:?}", moddir))?; + } + Module::generate(&modules, &moddir, GenMode::Types)?; - // generate_modules(&moddir, GenMode::Sync).unwrap(); - // } + let moddir = outdir.join("async_impl").join("mods"); + if !moddir.exists() { + fs::create_dir_all(&moddir) + .with_context(|| format!("Unable to create directory at: {:?}", moddir))?; + } - // generate_types(outdir).unwrap(); + let moddir = outdir.join("sync").join("mods"); + if !moddir.exists() { + fs::create_dir_all(&moddir) + .with_context(|| format!("Unable to create directory at: {:?}", moddir))?; + } + Ok(()) } diff --git a/codegen/src/rust.rs b/codegen/src/rust.rs new file mode 100644 index 00000000..b2794734 --- /dev/null +++ b/codegen/src/rust.rs @@ -0,0 +1,550 @@ +use std::collections::{HashMap, HashSet}; +use std::convert::TryFrom; +use std::fs::{self, OpenOptions}; +use std::io::Write; +use std::path::Path; +use std::process::Command; +use std::str::FromStr; + +use anyhow::{bail, Context, Result}; +use inflector::Inflector; + +use crate::schema; + +pub static AUTOGEN_HEADER: &str = " +//============================================================================= +// +// WARNING: This file is AUTO-GENERATED +// +// Do not make changes directly to this file. +// +// If you would like to make a change to the library, please update the schema +// definitions at https://github.com/slack-rs/slack-api-schemas +// +// If you would like to make a change how the library was generated, +// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen +// +//============================================================================= + +"; + +#[derive(Clone, Debug)] +pub struct ModuleBuilder<'a> { + pub name: String, + pub submodules: HashMap<&'a str, ModuleBuilder<'a>>, + pub methods: HashMap<&'a str, Method>, +} + +impl ModuleBuilder<'_> { + pub fn new(name: &str) -> Self { + Self { + name: name.into(), + submodules: HashMap::new(), + methods: HashMap::new(), + } + } + + pub fn build(self) -> Module { + Module { + name: self.name, + submodules: self + .submodules + .into_iter() + .map(|(_, v)| v.build()) + .collect(), + methods: self.methods.into_iter().map(|(_, v)| v).collect(), + } + } +} + +#[derive(Clone, Debug)] +pub struct Module { + pub name: String, + pub submodules: Vec, + pub methods: Vec, +} + +impl Module { + pub fn generate(modules: &[Self], moddir: &Path, gen_mode: GenMode) -> Result<()> { + Self::generate_modrs(modules, moddir, gen_mode)?; + for module in modules { + Self::generate_mod(module, moddir, gen_mode)?; + } + Ok(()) + } + + fn generate_modrs(modules: &[Self], moddir: &Path, gen_mode: GenMode) -> Result<()> { + let data = format!("{}\n", Self::build_module_include(modules, gen_mode)); + + let mod_file_path = moddir.join("mod.rs"); + let mut mod_file = OpenOptions::new() + .write(true) + .truncate(true) + .create(true) + .open(&mod_file_path) + .with_context(|| format!("Unable to create file at: {:?}", mod_file_path))?; + + mod_file + .write_all(data.as_bytes()) + .with_context(|| format!("Failed to write to file: {:?}", mod_file_path))?; + Ok(()) + } + + fn generate_mod(module: &Self, moddir: &Path, gen_mode: GenMode) -> Result<()> { + let data = module.generate_mod_data(gen_mode)?; + let mod_file_path = if module.submodules.is_empty() { + let postfix = if gen_mode == GenMode::Types { + "_types" + } else { + "" + }; + moddir.join(format!("{}{}.rs", module.name, postfix)) + } else { + let moddir = moddir.join(&module.name); + if !moddir.exists() { + fs::create_dir_all(&moddir) + .with_context(|| format!("Unable to create directory at: {:?}", moddir))?; + } + for submodule in &module.submodules { + Self::generate_mod(submodule, &moddir, gen_mode)?; + } + moddir.join("mod.rs") + }; + let mut mod_file = OpenOptions::new() + .write(true) + .truncate(true) + .create(true) + .open(&mod_file_path) + .with_context(|| format!("Unable to create file at: {:?}", mod_file_path))?; + + mod_file + .write_all(data.as_bytes()) + .with_context(|| format!("Failed to write to file: {:?}", mod_file_path))?; + + let out = Command::new("rustfmt") + .args(&["--edition", "2018"]) + .arg(&mod_file_path) + .output() + .context("Unable to run rustfmt")?; + if !out.status.success() { + bail!("rustfmt failed for {:?}", mod_file_path); + } + + Ok(()) + } + + fn generate_mod_data(&self, gen_mode: GenMode) -> Result { + let modules = if self.submodules.is_empty() { + String::new() + } else { + format!( + "{modules}\n\n", + modules = Self::build_module_include(&self.submodules, gen_mode) + ) + }; + let body = if gen_mode == GenMode::Types { + self.build_types()? + } else { + String::new() + }; + let data = format!("{modules}{body}", modules = modules, body = body); + Ok(data) + } + + fn build_module_include(modules: &[Self], gen_mode: GenMode) -> String { + let mut modules = modules + .iter() + .map(|r#mod| { + if gen_mode == GenMode::Types && r#mod.submodules.is_empty() { + let postfix = "_types"; + format!("pub mod {}{};", r#mod.name, postfix) + } else { + format!("pub mod {};", r#mod.name) + } + }) + .collect::>(); + modules.sort_unstable(); + modules.join("\n") + } + + fn build_types(&self) -> Result { + let mut methods: Vec = Vec::with_capacity(self.methods.len()); + for method in &self.methods { + let method = format!( + "{request} + + {response} + + {error} + ", + request = method.build_request_type()?, + response = method.build_response_type()?, + error = method.build_error_type()? + ); + methods.push(method); + } + Ok(methods.join("\n")) + } +} + +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum GenMode { + Async, + Sync, + Types, +} + +impl GenMode { + fn dot_await(self) -> &'static str { + match self { + GenMode::Async => ".await", + GenMode::Sync => "", + _ => unreachable!(), + } + } + fn fn_type(self) -> &'static str { + match self { + GenMode::Async => "async fn", + GenMode::Sync => "fn", + _ => unreachable!(), + } + } +} + +#[derive(Clone, Debug)] +pub struct Method { + pub name: String, + pub description: String, + pub documentation_url: String, + pub parameters: Vec, + pub response: Response, + pub http_method: HttpMethod, +} + +impl Method { + fn build_request_type(&self) -> Result { + let type_prefix = self.name.to_pascal_case(); + let struct_name = format!("{}Request", type_prefix); + let parameters = self + .parameters + .iter() + .map(Parameter::to_rust) + .collect::>() + .join("\n"); + let out = format!( + "pub struct {name} {{ + {parameters} + }}", + name = struct_name, + parameters = parameters + ); + Ok(out) + } + + fn build_response_type(&self) -> Result { + let type_prefix = self.name.to_pascal_case(); + let struct_name = format!("{}Response", type_prefix); + let (_, r#types) = self.response.to_rust( + &self.name.to_pascal_case(), + Some(&struct_name), + true, + &mut HashSet::new(), + )?; + let out = r#types.join("\n\n"); + Ok(out) + } + + fn build_error_type(&self) -> Result { + let type_prefix = self.name.to_pascal_case(); + let struct_name = format!("{}Error", type_prefix); + let out = format!("pub struct {} {{}}", struct_name); + Ok(out) + } +} + +#[derive(Clone, Debug)] +pub struct Parameter { + description: Option, + name: String, + required: bool, + param_type: ParameterDataType, +} + +impl Parameter { + fn to_rust(&self) -> String { + let description = self.description_to_rust(); + let r#type = self.param_type.to_rust(self.required); + format!("{description}pub {name}: {type},", description = description, name=self.name, type=r#type) + } + + fn description_to_rust(&self) -> String { + self.description + .as_ref() + .map(|p| { + let p = p.trim(); + format!("/// {}\n", p) + }) + .unwrap_or_else(String::new) + } +} + +impl TryFrom<&schema::Parameter> for Parameter { + type Error = anyhow::Error; + + fn try_from(value: &schema::Parameter) -> Result { + Ok(Parameter { + description: value.description.clone(), + name: value.name.clone(), + required: value.required.unwrap_or(false), + param_type: ParameterDataType::from_str(&value.param_type)?, + }) + } +} + +#[derive(Clone, Debug)] +pub enum ParameterDataType { + Bool, + Int, + String, +} + +impl ParameterDataType { + pub fn to_rust(&self, required: bool) -> String { + let r#type = match self { + Self::Bool => "bool", + Self::Int => "u64", + Self::String => "String", + }; + if required { + format!("Option<{}>", r#type) + } else { + r#type.to_string() + } + } +} + +impl FromStr for ParameterDataType { + type Err = anyhow::Error; + + fn from_str(s: &str) -> Result { + let r#type = match s { + "boolean" => Self::Bool, + "integer" | "number" => Self::Int, + "string" => Self::String, + t => bail!(format!("Type {} currently not supported", t)), + }; + Ok(r#type) + } +} + +#[derive(Clone, Debug)] +pub struct Response { + pub description: Option, + pub r#type: ResponseType, + pub required: bool, +} + +impl Response { + pub fn to_rust( + &self, + method_name: &str, + name: Option<&str>, + top: bool, + names: &mut HashSet, + ) -> Result<(String, Vec)> { + let res = match &self.r#type { + // Inner + ResponseType::Bool if !top => ("bool".into(), Vec::new()), + ResponseType::Int if !top => ("u64".into(), Vec::new()), + ResponseType::String if !top => ("String".into(), Vec::new()), + ResponseType::RawJson if !top => ("serde_json::Value".into(), Vec::new()), + ResponseType::Vec(res) if !top => { + let (r#type, types) = res.to_rust(method_name, name, false, names)?; + (format!("Vec<{}>", r#type), types) + } + + // Top + ResponseType::Vec(res) => Response { + description: None, + r#type: ResponseType::Object(vec![Member { + name: "result".into(), + r#type: *res.clone(), + }]), + required: true, + } + .to_rust(method_name, name, true, names)?, + ResponseType::Object(mem) => { + let mut members: Vec = Vec::with_capacity(mem.len()); + let mut types = Vec::new(); + for member in mem { + let (name, types_mem) = member.to_rust(method_name, names)?; + types.extend_from_slice(&types_mem); + members.push(name) + } + let name = name.map_or_else(|| format!("{}List", method_name), |s| s.into()); + let mut struct_name = if !top { + format!("{}Inner", name) + } else { + name.clone() + }; + let mut i = 1; + while names.contains(&struct_name) { + struct_name = format!("{}{}Inner", name, i); + i += 1; + } + names.insert(struct_name.clone()); + + let out = format!( + "pub struct {name} {{ + {members} + }}", + name = struct_name, + members = members.join("\n") + ); + types.push(out); + (struct_name, types) + } + t => bail!("Object {:?}, is not supported at position top = {}", t, top), + }; + Ok(res) + } +} + +impl TryFrom<&schema::Schema> for Response { + type Error = anyhow::Error; + + fn try_from(s: &schema::Schema) -> Result { + Ok(Self { + description: s + .title + .as_ref() + .or_else(|| s.description.as_ref()) + .map(Clone::clone), + r#type: ResponseType::try_from(s)?, + required: false, + }) + } +} + +#[derive(Clone, Debug)] +pub struct Member { + pub name: String, + pub r#type: Response, +} + +impl Member { + pub fn to_rust( + &self, + method_name: &str, + names: &mut HashSet, + ) -> Result<(String, Vec)> { + let name = format!("{}{}", method_name, self.name.to_pascal_case()); + let (mut r#type, types) = self + .r#type + .to_rust(method_name, Some(&name), false, names)?; + if self.r#type.required { + r#type = format!("Option<{}>", r#type); + } + let name = match self.name.as_ref() { + "self" => "r#_self", + "type" => "r#type", + v => v, + }; + Ok(( + format!("pub {name}: {type},", name=name, type=r#type), + types, + )) + } +} + +impl TryFrom<(&str, &schema::Schema)> for Member { + type Error = anyhow::Error; + + fn try_from(s: (&str, &schema::Schema)) -> Result { + Ok(Self { + name: s.0.into(), + r#type: Response::try_from(s.1) + .with_context(|| format!("Unable to convert type in object {}", s.0))?, + }) + } +} + +#[derive(Clone, Debug)] +pub enum ResponseType { + Bool, + Int, + String, + Object(Vec), + RawJson, + Vec(Box), +} + +impl TryFrom<&schema::Schema> for ResponseType { + type Error = anyhow::Error; + + fn try_from(s: &schema::Schema) -> Result { + let schema: Option> = s + .schema_type + .as_ref() + .map(|v| v.iter().map(AsRef::as_ref).collect()); + let items = s.items.as_ref().and_then(|s| { + s.iter().find(|s| { + s.schema_type + .as_ref() + .map_or(true, |s| s.iter().any(|s| s != "null")) + }) + }); + let properties = s.properties.as_ref(); + + let r#type = match (schema, items, properties) { + // Primitives + (Some(schema), _, _) if schema.contains(&"boolean") => Self::Bool, + (Some(schema), _, _) if schema.contains(&"integer") => Self::Int, + (Some(schema), _, _) if schema.contains(&"number") => Self::Int, + (Some(schema), _, _) if schema.contains(&"string") => Self::String, + + // Object + (Some(schema), _, Some(properties)) if schema.contains(&"object") => { + let mut members = Vec::with_capacity(properties.len()); + for (name, sub_schema) in properties { + let mut member = Member::try_from((name.as_ref(), sub_schema))?; + if s.required + .as_ref() + .map_or(false, |v| v.contains(&member.name)) + { + member.r#type.required = true; + } + members.push(member); + } + ResponseType::Object(members) + } + + // Array + (Some(schema), Some(item), _) if schema.contains(&"array") => { + let mut res = Response::try_from(item)?; + res.required = true; + ResponseType::Vec(Box::new(res)) + } + (None, Some(item), _) => { + let mut res = Response::try_from(item)?; + res.required = true; + ResponseType::Vec(Box::new(res)) + } + + // RawJson + (Some(schema), None, None) if schema.contains(&"object") => Self::RawJson, + (Some(schema), None, None) if schema.contains(&"null") => Self::RawJson, + (None, None, None) => Self::RawJson, + + // Other + t => bail!(format!("Type {:?} currently not supported", t)), + }; + Ok(r#type) + } +} + +#[derive(Clone, Debug, Copy)] +pub enum HttpMethod { + Get, + Post, +} diff --git a/codegen/src/schema.rs b/codegen/src/schema.rs index ab5cccba..9e96dd37 100644 --- a/codegen/src/schema.rs +++ b/codegen/src/schema.rs @@ -1,4 +1,5 @@ use crate::vec_or_single::VecOrSingle; +use anyhow::{Context, Result}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; @@ -18,6 +19,45 @@ pub struct Spec { pub tags: Vec, } +impl Spec { + pub fn replace_refs(&mut self) -> Result<()> { + for path in self.paths.values_mut() { + for mut operation in &mut [&mut path.get, &mut path.post] { + if let Some(ref mut op) = &mut operation { + for response in op.responses.values_mut() { + Self::replace_refs_schema(&mut response.schema, &self.definitions)?; + } + } + } + } + Ok(()) + } + + fn replace_refs_schema( + schema: &mut Schema, + definitions: &BTreeMap, + ) -> Result<()> { + if let Some(ref_path) = &schema.ref_path { + let def_name = ref_path.trim_start_matches("#/definitions/"); + let def = definitions + .get(def_name) + .with_context(|| format!("Definition for {} is missing", def_name))?; + *schema = def.clone(); + } + if let Some(items) = &mut schema.items { + for item in &mut items.0 { + Self::replace_refs_schema(item, definitions)?; + } + } + if let Some(properties) = &mut schema.properties { + for property in properties.values_mut() { + Self::replace_refs_schema(property, definitions)?; + } + } + Ok(()) + } +} + #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub struct Schema { #[serde( @@ -59,6 +99,30 @@ pub struct Schema { pub ref_path: Option, } +impl Schema { + pub fn merge(&mut self, other: &Schema) { + match (&mut self.items, &other.items) { + (_, None) => {} + (None, o) => self.items = o.clone(), + (Some(ref mut s), Some(ref o)) => s.extend_from_slice(&o), + } + match (&mut self.enum_values, &other.enum_values) { + (_, None) => {} + (None, o) => self.enum_values = o.clone(), + (Some(ref mut s), Some(ref o)) => s.extend_from_slice(&o), + } + match (&mut self.properties, &other.properties) { + (_, None) => {} + (None, o) => self.properties = o.clone(), + (Some(ref mut s), Some(ref o)) => { + for (key, value) in o { + let _ = s.entry(key.to_string()).or_insert_with(|| value.clone()); + } + } + } + } +} + #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] #[serde(untagged)] pub enum AdditionalProperties { @@ -66,7 +130,7 @@ pub enum AdditionalProperties { Type { #[serde(rename = "type")] param_type: String, - } + }, } #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] @@ -114,7 +178,7 @@ pub struct Operation { pub external_docs: ExternalDoc, #[serde(rename = "operationId")] pub operation_id: String, - pub parameters: Vec, + pub parameters: Vec, pub produces: Vec, pub responses: BTreeMap, pub security: Vec, @@ -122,23 +186,16 @@ pub struct Operation { } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] -#[serde(untagged)] -pub enum ParameterOrRef { - Parameter { - #[serde(skip_serializing_if = "Option::is_none")] - description: Option, - #[serde(rename = "in")] - location: String, - name: String, - #[serde(skip_serializing_if = "Option::is_none")] - required: Option, - #[serde(rename = "type")] - param_type: String, - }, - Ref { - #[serde(rename = "$ref")] - ref_path: String, - }, +pub struct Parameter { + #[serde(skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(rename = "in")] + pub location: String, + pub name: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub required: Option, + #[serde(rename = "type")] + pub param_type: String, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] diff --git a/codegen/src/vec_or_single.rs b/codegen/src/vec_or_single.rs index 7d757364..e723991a 100644 --- a/codegen/src/vec_or_single.rs +++ b/codegen/src/vec_or_single.rs @@ -1,13 +1,13 @@ use serde::{ de::{DeserializeOwned, Deserializer}, - ser::{SerializeMap, SerializeSeq, Serializer}, + ser::{SerializeSeq, Serializer}, Deserialize, Serialize, }; use std::{fmt, marker::PhantomData}; #[derive(Debug, Clone, PartialEq)] #[allow(missing_docs)] -pub struct VecOrSingle(Vec); +pub struct VecOrSingle(pub Vec); impl std::ops::Deref for VecOrSingle { type Target = Vec; @@ -18,14 +18,17 @@ impl std::ops::Deref for VecOrSingle { } } -impl Serialize for VecOrSingle -{ - fn serialize(&self, serializer: S) -> Result - { +impl std::ops::DerefMut for VecOrSingle { + #[inline] + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +impl Serialize for VecOrSingle { + fn serialize(&self, serializer: S) -> Result { match self.split_first() { - Some((first, rest)) if rest.is_empty() => { - first.serialize(serializer) - } + Some((first, rest)) if rest.is_empty() => first.serialize(serializer), _ => { let mut seq = serializer.serialize_seq(Some(self.len()))?; for e in &self.0 { @@ -33,13 +36,12 @@ impl Serialize for VecOrSingle } seq.end() } - } + } } } impl<'de, T: DeserializeOwned> Deserialize<'de> for VecOrSingle { - fn deserialize>(deserializer: D) -> Result, D::Error> - { + fn deserialize>(deserializer: D) -> Result, D::Error> { struct VecOrSingleVisit(PhantomData); impl VecOrSingleVisit { @@ -139,6 +141,8 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for VecOrSingle { } } - deserializer.deserialize_any(VecOrSingleVisit(PhantomData {})).map(|v| VecOrSingle(v)) + deserializer + .deserialize_any(VecOrSingleVisit(PhantomData {})) + .map(VecOrSingle) } } diff --git a/src/mod_types/admin/apps/approved_types.rs b/src/mod_types/admin/apps/approved_types.rs new file mode 100644 index 00000000..b64d6db0 --- /dev/null +++ b/src/mod_types/admin/apps/approved_types.rs @@ -0,0 +1,14 @@ +pub struct ListRequest { + /// The maximum number of items to return. Must be between 1 - 1000 both inclusive. + pub limit: u64, + /// Set `cursor` to `next_cursor` returned by the previous call to list items in the next page + pub cursor: String, + pub team_id: String, + pub enterprise_id: String, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} diff --git a/src/mod_types/admin/apps/mod.rs b/src/mod_types/admin/apps/mod.rs new file mode 100644 index 00000000..a268b350 --- /dev/null +++ b/src/mod_types/admin/apps/mod.rs @@ -0,0 +1,31 @@ +pub mod approved_types; +pub mod requests_types; +pub mod restricted_types; + +pub struct RestrictRequest { + /// The id of the app to restrict. + pub app_id: String, + /// The id of the request to restrict. + pub request_id: String, + pub team_id: String, +} + +pub struct RestrictResponse { + pub ok: Option, +} + +pub struct RestrictError {} + +pub struct ApproveRequest { + /// The id of the app to approve. + pub app_id: String, + /// The id of the request to approve. + pub request_id: String, + pub team_id: String, +} + +pub struct ApproveResponse { + pub ok: Option, +} + +pub struct ApproveError {} diff --git a/src/mod_types/admin/apps/requests_types.rs b/src/mod_types/admin/apps/requests_types.rs new file mode 100644 index 00000000..e36b200d --- /dev/null +++ b/src/mod_types/admin/apps/requests_types.rs @@ -0,0 +1,13 @@ +pub struct ListRequest { + /// The maximum number of items to return. Must be between 1 - 1000 both inclusive. + pub limit: u64, + /// Set `cursor` to `next_cursor` returned by the previous call to list items in the next page + pub cursor: String, + pub team_id: String, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} diff --git a/src/mod_types/admin/apps/restricted_types.rs b/src/mod_types/admin/apps/restricted_types.rs new file mode 100644 index 00000000..b64d6db0 --- /dev/null +++ b/src/mod_types/admin/apps/restricted_types.rs @@ -0,0 +1,14 @@ +pub struct ListRequest { + /// The maximum number of items to return. Must be between 1 - 1000 both inclusive. + pub limit: u64, + /// Set `cursor` to `next_cursor` returned by the previous call to list items in the next page + pub cursor: String, + pub team_id: String, + pub enterprise_id: String, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} diff --git a/src/mod_types/admin/conversations/ekm_types.rs b/src/mod_types/admin/conversations/ekm_types.rs new file mode 100644 index 00000000..9db55dd5 --- /dev/null +++ b/src/mod_types/admin/conversations/ekm_types.rs @@ -0,0 +1,16 @@ +pub struct ListOriginalConnectedChannelInfoRequest { + /// A comma-separated list of channels to filter to. + pub channel_ids: String, + /// A comma-separated list of the workspaces to which the channels you would like returned belong. + pub team_ids: String, + /// The maximum number of items to return. Must be between 1 - 1000 both inclusive. + pub limit: u64, + /// Set `cursor` to `next_cursor` returned by the previous call to list items in the next page. + pub cursor: String, +} + +pub struct ListOriginalConnectedChannelInfoResponse { + pub ok: Option, +} + +pub struct ListOriginalConnectedChannelInfoError {} diff --git a/src/mod_types/admin/conversations/mod.rs b/src/mod_types/admin/conversations/mod.rs new file mode 100644 index 00000000..040bde66 --- /dev/null +++ b/src/mod_types/admin/conversations/mod.rs @@ -0,0 +1,552 @@ +pub mod ekm_types; +pub mod restrictAccess_types; + +pub struct RenameRequest { + /// The channel to rename. + pub channel_id: Option, + pub name: Option, +} + +pub struct RenameResponse { + pub error: String, + pub ok: Option, +} + +pub struct RenameError {} + +pub struct DeleteRequest { + /// The channel to delete. + pub channel_id: Option, +} + +pub struct DeleteResponse { + pub error: String, + pub ok: Option, +} + +pub struct DeleteError {} + +pub struct GetConversationPrefsRequest { + /// The channel to get preferences for. + pub channel_id: Option, +} + +pub struct GetConversationPrefsCanThreadInner { + pub r#type: Vec, + pub user: Vec, +} + +pub struct GetConversationPrefsWhoCanPostInner { + pub r#type: Vec, + pub user: Vec, +} + +pub struct GetConversationPrefsPrefsInner { + pub can_thread: GetConversationPrefsCanThreadInner, + pub who_can_post: GetConversationPrefsWhoCanPostInner, +} + +pub struct GetConversationPrefsResponse { + pub error: String, + pub ok: Option, + pub prefs: GetConversationPrefsPrefsInner, +} + +pub struct GetConversationPrefsError {} + +pub struct GetTeamsRequest { + /// The channel to determine connected workspaces within the organization for. + pub channel_id: Option, + /// Set `cursor` to `next_cursor` returned by the previous call to list items in the next page + pub cursor: String, + /// The maximum number of items to return. Must be between 1 - 1000 both inclusive. + pub limit: u64, +} + +pub struct GetTeamsResponseMetadataInner { + pub next_cursor: Option, +} + +pub struct GetTeamsResponse { + pub error: String, + pub ok: Option, + pub response_metadata: GetTeamsResponseMetadataInner, + pub team_ids: Option>, +} + +pub struct GetTeamsError {} + +pub struct UnarchiveRequest { + /// The channel to unarchive. + pub channel_id: Option, +} + +pub struct UnarchiveResponse { + pub error: String, + pub ok: Option, +} + +pub struct UnarchiveError {} + +pub struct InviteRequest { + /// The users to invite. + pub user_ids: Option, + /// The channel that the users will be invited to. + pub channel_id: Option, +} + +pub struct InviteResponse { + pub error: String, + pub ok: Option, +} + +pub struct InviteError {} + +pub struct ConvertToPrivateRequest { + /// The channel to convert to private. + pub channel_id: Option, +} + +pub struct ConvertToPrivateResponse { + pub error: String, + pub ok: Option, +} + +pub struct ConvertToPrivateError {} + +pub struct SetConversationPrefsRequest { + /// The channel to set the prefs for + pub channel_id: Option, + /// The prefs for this channel in a stringified JSON format. + pub prefs: Option, +} + +pub struct SetConversationPrefsResponse { + pub error: String, + pub ok: Option, +} + +pub struct SetConversationPrefsError {} + +pub struct CreateRequest { + /// Name of the public or private channel to create. + pub name: Option, + /// Description of the public or private channel to create. + pub description: String, + /// When `true`, creates a private channel instead of a public channel + pub is_private: Option, + /// When `true`, the channel will be available org-wide. Note: if the channel is not `org_wide=true`, you must specify a `team_id` for this channel + pub org_wide: bool, + /// The workspace to create the channel in. Note: this argument is required unless you set `org_wide=true`. + pub team_id: String, +} + +pub struct CreateResponse { + pub channel_id: String, + pub error: String, + pub ok: Option, +} + +pub struct CreateError {} + +pub struct ArchiveRequest { + /// The channel to archive. + pub channel_id: Option, +} + +pub struct ArchiveResponse { + pub error: String, + pub ok: Option, +} + +pub struct ArchiveError {} + +pub struct DisconnectSharedRequest { + /// The channel to be disconnected from some workspaces. + pub channel_id: Option, + /// The team to be removed from the channel. Currently only a single team id can be specified. + pub leaving_team_ids: String, +} + +pub struct DisconnectSharedResponse { + pub error: String, + pub ok: Option, +} + +pub struct DisconnectSharedError {} + +pub struct SetTeamsRequest { + /// The encoded `channel_id` to add or remove to workspaces. + pub channel_id: Option, + /// The workspace to which the channel belongs. Omit this argument if the channel is a cross-workspace shared channel. + pub team_id: String, + /// A comma-separated list of workspaces to which the channel should be shared. Not required if the channel is being shared org-wide. + pub target_team_ids: String, + /// True if channel has to be converted to an org channel + pub org_channel: bool, +} + +pub struct SetTeamsResponse { + pub ok: Option, +} + +pub struct SetTeamsError {} + +pub struct SearchRequest { + /// Comma separated string of team IDs, signifying the workspaces to search through. + pub team_ids: String, + /// Name of the the channel to query by. + pub query: String, + /// Maximum number of items to be returned. Must be between 1 - 20 both inclusive. Default is 10. + pub limit: u64, + /// Set `cursor` to `next_cursor` returned by the previous call to list items in the next page. + pub cursor: String, + /// The type of channel to include or exclude in the search. For example `private` will search private channels, while `private_exclude` will exclude them. For a full list of types, check the [Types section](#types). + pub search_channel_types: String, + /// Possible values are `relevant` (search ranking based on what we think is closest), `name` (alphabetical), `member_count` (number of users in the channel), and `created` (date channel was created). You can optionally pair this with the `sort_dir` arg to change how it is sorted + pub sort: String, + /// Sort direction. Possible values are `asc` for ascending order like (1, 2, 3) or (a, b, c), and `desc` for descending order like (3, 2, 1) or (c, b, a) + pub sort_dir: String, +} + +pub struct SearchAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct SearchBlocksInner { + pub r#type: Option, +} + +pub struct SearchIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct SearchBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct SearchReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct SearchCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct SearchReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct SearchSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct SearchFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: SearchSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct SearchReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct SearchShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct SearchFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: SearchShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct SearchIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct SearchReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct SearchUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct SearchLatestInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: SearchBotProfileInner, + pub client_msg_id: String, + pub comment: SearchCommentInner, + pub display_as_bot: bool, + pub file: SearchFileInner, + pub files: Vec, + pub icons: SearchIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: SearchUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct SearchPurposeInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct SearchTopicInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct SearchChannelsInner { + pub accepted_user: String, + pub created: Option, + pub creator: Option, + pub id: Option, + pub is_archived: bool, + pub is_channel: Option, + pub is_frozen: bool, + pub is_general: bool, + pub is_member: bool, + pub is_moved: u64, + pub is_mpim: Option, + pub is_non_threadable: bool, + pub is_org_shared: Option, + pub is_pending_ext_shared: bool, + pub is_private: Option, + pub is_read_only: bool, + pub is_shared: Option, + pub is_thread_only: bool, + pub last_read: String, + pub latest: Vec, + pub members: Option>, + pub name: Option, + pub name_normalized: Option, + pub num_members: u64, + pub pending_shared: Vec, + pub previous_names: Vec, + pub priority: u64, + pub purpose: Option, + pub topic: Option, + pub unlinked: u64, + pub unread_count: u64, + pub unread_count_display: u64, +} + +pub struct SearchResponse { + pub channels: Option>, + pub error: String, + pub next_cursor: Option, + pub ok: bool, +} + +pub struct SearchError {} diff --git a/src/mod_types/admin/conversations/restrictAccess_types.rs b/src/mod_types/admin/conversations/restrictAccess_types.rs new file mode 100644 index 00000000..1881cc5a --- /dev/null +++ b/src/mod_types/admin/conversations/restrictAccess_types.rs @@ -0,0 +1,45 @@ +pub struct RemoveGroupRequest { + /// Authentication token. Requires scope: `admin.conversations:write` + pub token: Option, + /// The workspace where the channel exists. This argument is required for channels only tied to one workspace, and optional for channels that are shared across an organization. + pub team_id: Option, + /// The [IDP Group](https://slack.com/help/articles/115001435788-Connect-identity-provider-groups-to-your-Enterprise-Grid-org) ID to remove from the private channel. + pub group_id: Option, + /// The channel to remove the linked group from. + pub channel_id: Option, +} + +pub struct RemoveGroupResponse { + pub ok: Option, +} + +pub struct RemoveGroupError {} + +pub struct AddGroupRequest { + /// Authentication token. Requires scope: `admin.conversations:write` + pub token: Option, + /// The workspace where the channel exists. This argument is required for channels only tied to one workspace, and optional for channels that are shared across an organization. + pub team_id: String, + /// The [IDP Group](https://slack.com/help/articles/115001435788-Connect-identity-provider-groups-to-your-Enterprise-Grid-org) ID to be an allowlist for the private channel. + pub group_id: Option, + /// The channel to link this group to. + pub channel_id: Option, +} + +pub struct AddGroupResponse { + pub ok: Option, +} + +pub struct AddGroupError {} + +pub struct ListGroupsRequest { + pub channel_id: Option, + /// The workspace where the channel exists. This argument is required for channels only tied to one workspace, and optional for channels that are shared across an organization. + pub team_id: String, +} + +pub struct ListGroupsResponse { + pub ok: Option, +} + +pub struct ListGroupsError {} diff --git a/src/mod_types/admin/emoji_types.rs b/src/mod_types/admin/emoji_types.rs new file mode 100644 index 00000000..b9c916b0 --- /dev/null +++ b/src/mod_types/admin/emoji_types.rs @@ -0,0 +1,70 @@ +pub struct RemoveRequest { + /// Authentication token. Requires scope: `admin.teams:write` + pub token: Option, + /// The name of the emoji to be removed. Colons (`:myemoji:`) around the value are not required, although they may be included. + pub name: Option, +} + +pub struct RemoveResponse { + pub ok: Option, +} + +pub struct RemoveError {} + +pub struct RenameRequest { + /// Authentication token. Requires scope: `admin.teams:write` + pub token: Option, + /// The name of the emoji to be renamed. Colons (`:myemoji:`) around the value are not required, although they may be included. + pub name: Option, + /// The new name of the emoji. + pub new_name: Option, +} + +pub struct RenameResponse { + pub ok: Option, +} + +pub struct RenameError {} + +pub struct AddAliasRequest { + /// Authentication token. Requires scope: `admin.teams:write` + pub token: Option, + /// The name of the emoji to be aliased. Colons (`:myemoji:`) around the value are not required, although they may be included. + pub name: Option, + /// The alias of the emoji. + pub alias_for: Option, +} + +pub struct AddAliasResponse { + pub ok: Option, +} + +pub struct AddAliasError {} + +pub struct ListRequest { + /// Set `cursor` to `next_cursor` returned by the previous call to list items in the next page + pub cursor: String, + /// The maximum number of items to return. Must be between 1 - 1000 both inclusive. + pub limit: u64, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} + +pub struct AddRequest { + /// Authentication token. Requires scope: `admin.teams:write` + pub token: Option, + /// The name of the emoji to be removed. Colons (`:myemoji:`) around the value are not required, although they may be included. + pub name: Option, + /// The URL of a file to use as an image for the emoji. Square images under 128KB and with transparent backgrounds work best. + pub url: Option, +} + +pub struct AddResponse { + pub ok: Option, +} + +pub struct AddError {} diff --git a/src/mod_types/admin/inviteRequests/approved_types.rs b/src/mod_types/admin/inviteRequests/approved_types.rs new file mode 100644 index 00000000..1b537e9a --- /dev/null +++ b/src/mod_types/admin/inviteRequests/approved_types.rs @@ -0,0 +1,14 @@ +pub struct ListRequest { + /// ID for the workspace where the invite requests were made. + pub team_id: String, + /// Value of the `next_cursor` field sent as part of the previous API response + pub cursor: String, + /// The number of results that will be returned by the API on each invocation. Must be between 1 - 1000, both inclusive + pub limit: u64, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} diff --git a/src/mod_types/admin/inviteRequests/denied_types.rs b/src/mod_types/admin/inviteRequests/denied_types.rs new file mode 100644 index 00000000..1351a593 --- /dev/null +++ b/src/mod_types/admin/inviteRequests/denied_types.rs @@ -0,0 +1,14 @@ +pub struct ListRequest { + /// ID for the workspace where the invite requests were made. + pub team_id: String, + /// Value of the `next_cursor` field sent as part of the previous api response + pub cursor: String, + /// The number of results that will be returned by the API on each invocation. Must be between 1 - 1000 both inclusive + pub limit: u64, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} diff --git a/src/mod_types/admin/inviteRequests/mod.rs b/src/mod_types/admin/inviteRequests/mod.rs new file mode 100644 index 00000000..27951614 --- /dev/null +++ b/src/mod_types/admin/inviteRequests/mod.rs @@ -0,0 +1,43 @@ +pub mod approved_types; +pub mod denied_types; + +pub struct ListRequest { + /// ID for the workspace where the invite requests were made. + pub team_id: String, + /// Value of the `next_cursor` field sent as part of the previous API response + pub cursor: String, + /// The number of results that will be returned by the API on each invocation. Must be between 1 - 1000, both inclusive + pub limit: u64, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} + +pub struct DenyRequest { + /// ID for the workspace where the invite request was made. + pub team_id: String, + /// ID of the request to invite. + pub invite_request_id: Option, +} + +pub struct DenyResponse { + pub ok: Option, +} + +pub struct DenyError {} + +pub struct ApproveRequest { + /// ID for the workspace where the invite request was made. + pub team_id: String, + /// ID of the request to invite. + pub invite_request_id: Option, +} + +pub struct ApproveResponse { + pub ok: Option, +} + +pub struct ApproveError {} diff --git a/src/mod_types/admin/mod.rs b/src/mod_types/admin/mod.rs new file mode 100644 index 00000000..6bcde5bb --- /dev/null +++ b/src/mod_types/admin/mod.rs @@ -0,0 +1,7 @@ +pub mod apps; +pub mod conversations; +pub mod emoji_types; +pub mod inviteRequests; +pub mod teams; +pub mod usergroups_types; +pub mod users; diff --git a/src/mod_types/admin/teams/admins_types.rs b/src/mod_types/admin/teams/admins_types.rs new file mode 100644 index 00000000..672c6ff9 --- /dev/null +++ b/src/mod_types/admin/teams/admins_types.rs @@ -0,0 +1,13 @@ +pub struct ListRequest { + /// The maximum number of items to return. + pub limit: u64, + /// Set `cursor` to `next_cursor` returned by the previous call to list items in the next page. + pub cursor: String, + pub team_id: Option, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} diff --git a/src/mod_types/admin/teams/mod.rs b/src/mod_types/admin/teams/mod.rs new file mode 100644 index 00000000..e35b06ce --- /dev/null +++ b/src/mod_types/admin/teams/mod.rs @@ -0,0 +1,33 @@ +pub mod admins_types; +pub mod owners_types; +pub mod settings_types; + +pub struct ListRequest { + /// The maximum number of items to return. Must be between 1 - 100 both inclusive. + pub limit: u64, + /// Set `cursor` to `next_cursor` returned by the previous call to list items in the next page. + pub cursor: String, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} + +pub struct CreateRequest { + /// Team domain (for example, slacksoftballteam). + pub team_domain: Option, + /// Team name (for example, Slack Softball Team). + pub team_name: Option, + /// Description for the team. + pub team_description: String, + /// Who can join the team. A team's discoverability can be `open`, `closed`, `invite_only`, or `unlisted`. + pub team_discoverability: String, +} + +pub struct CreateResponse { + pub ok: Option, +} + +pub struct CreateError {} diff --git a/src/mod_types/admin/teams/owners_types.rs b/src/mod_types/admin/teams/owners_types.rs new file mode 100644 index 00000000..b9e73b2b --- /dev/null +++ b/src/mod_types/admin/teams/owners_types.rs @@ -0,0 +1,13 @@ +pub struct ListRequest { + pub team_id: Option, + /// The maximum number of items to return. Must be between 1 - 1000 both inclusive. + pub limit: u64, + /// Set `cursor` to `next_cursor` returned by the previous call to list items in the next page. + pub cursor: String, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} diff --git a/src/mod_types/admin/teams/settings_types.rs b/src/mod_types/admin/teams/settings_types.rs new file mode 100644 index 00000000..0b9fe10b --- /dev/null +++ b/src/mod_types/admin/teams/settings_types.rs @@ -0,0 +1,78 @@ +pub struct InfoRequest { + pub team_id: Option, +} + +pub struct InfoResponse { + pub ok: Option, +} + +pub struct InfoError {} + +pub struct SetDescriptionRequest { + /// ID for the workspace to set the description for. + pub team_id: Option, + /// The new description for the workspace. + pub description: Option, +} + +pub struct SetDescriptionResponse { + pub ok: Option, +} + +pub struct SetDescriptionError {} + +pub struct SetDefaultChannelsRequest { + /// Authentication token. Requires scope: `admin.teams:write` + pub token: Option, + /// ID for the workspace to set the default channel for. + pub team_id: Option, + /// An array of channel IDs. + pub channel_ids: Option, +} + +pub struct SetDefaultChannelsResponse { + pub ok: Option, +} + +pub struct SetDefaultChannelsError {} + +pub struct SetNameRequest { + /// ID for the workspace to set the name for. + pub team_id: Option, + /// The new name of the workspace. + pub name: Option, +} + +pub struct SetNameResponse { + pub ok: Option, +} + +pub struct SetNameError {} + +pub struct SetIconRequest { + /// Authentication token. Requires scope: `admin.teams:write` + pub token: Option, + /// Image URL for the icon + pub image_url: Option, + /// ID for the workspace to set the icon for. + pub team_id: Option, +} + +pub struct SetIconResponse { + pub ok: Option, +} + +pub struct SetIconError {} + +pub struct SetDiscoverabilityRequest { + /// The ID of the workspace to set discoverability on. + pub team_id: Option, + /// This workspace's discovery setting. It must be set to one of `open`, `invite_only`, `closed`, or `unlisted`. + pub discoverability: Option, +} + +pub struct SetDiscoverabilityResponse { + pub ok: Option, +} + +pub struct SetDiscoverabilityError {} diff --git a/src/mod_types/admin/usergroups_types.rs b/src/mod_types/admin/usergroups_types.rs new file mode 100644 index 00000000..7c38f04f --- /dev/null +++ b/src/mod_types/admin/usergroups_types.rs @@ -0,0 +1,57 @@ +pub struct AddTeamsRequest { + /// An encoded usergroup (IDP Group) ID. + pub usergroup_id: Option, + /// A comma separated list of encoded team (workspace) IDs. Each workspace *MUST* belong to the organization associated with the token. + pub team_ids: Option, + /// When `true`, this method automatically creates new workspace accounts for the IDP group members. + pub auto_provision: bool, +} + +pub struct AddTeamsResponse { + pub ok: Option, +} + +pub struct AddTeamsError {} + +pub struct AddChannelsRequest { + /// ID of the IDP group to add default channels for. + pub usergroup_id: Option, + /// The workspace to add default channels in. + pub team_id: String, + /// Comma separated string of channel IDs. + pub channel_ids: Option, +} + +pub struct AddChannelsResponse { + pub ok: Option, +} + +pub struct AddChannelsError {} + +pub struct ListChannelsRequest { + /// ID of the IDP group to list default channels for. + pub usergroup_id: Option, + /// ID of the the workspace. + pub team_id: String, + /// Flag to include or exclude the count of members per channel. + pub include_num_members: bool, +} + +pub struct ListChannelsResponse { + pub ok: Option, +} + +pub struct ListChannelsError {} + +pub struct RemoveChannelsRequest { + /// ID of the IDP Group + pub usergroup_id: Option, + /// Comma-separated string of channel IDs + pub channel_ids: Option, +} + +pub struct RemoveChannelsResponse { + pub ok: Option, +} + +pub struct RemoveChannelsError {} diff --git a/src/mod_types/admin/users/mod.rs b/src/mod_types/admin/users/mod.rs new file mode 100644 index 00000000..a154e7df --- /dev/null +++ b/src/mod_types/admin/users/mod.rs @@ -0,0 +1,129 @@ +pub mod session_types; + +pub struct AssignRequest { + /// The ID (`T1234`) of the workspace. + pub team_id: Option, + /// The ID of the user to add to the workspace. + pub user_id: Option, + /// True if user should be added to the workspace as a guest. + pub is_restricted: bool, + /// True if user should be added to the workspace as a single-channel guest. + pub is_ultra_restricted: bool, + /// Comma separated values of channel IDs to add user in the new workspace. + pub channel_ids: String, +} + +pub struct AssignResponse { + pub ok: Option, +} + +pub struct AssignError {} + +pub struct InviteRequest { + /// The ID (`T1234`) of the workspace. + pub team_id: Option, + /// The email address of the person to invite. + pub email: Option, + /// A comma-separated list of `channel_id`s for this user to join. At least one channel is required. + pub channel_ids: Option, + /// An optional message to send to the user in the invite email. + pub custom_message: String, + /// Full name of the user. + pub real_name: String, + /// Allow this invite to be resent in the future if a user has not signed up yet. (default: false) + pub resend: bool, + /// Is this user a multi-channel guest user? (default: false) + pub is_restricted: bool, + /// Is this user a single channel guest user? (default: false) + pub is_ultra_restricted: bool, + /// Timestamp when guest account should be disabled. Only include this timestamp if you are inviting a guest user and you want their account to expire on a certain date. + pub guest_expiration_ts: String, +} + +pub struct InviteResponse { + pub ok: Option, +} + +pub struct InviteError {} + +pub struct SetRegularRequest { + /// The ID (`T1234`) of the workspace. + pub team_id: Option, + /// The ID of the user to designate as a regular user. + pub user_id: Option, +} + +pub struct SetRegularResponse { + pub ok: Option, +} + +pub struct SetRegularError {} + +pub struct SetOwnerRequest { + /// The ID (`T1234`) of the workspace. + pub team_id: Option, + /// Id of the user to promote to owner. + pub user_id: Option, +} + +pub struct SetOwnerResponse { + pub ok: Option, +} + +pub struct SetOwnerError {} + +pub struct SetAdminRequest { + /// The ID (`T1234`) of the workspace. + pub team_id: Option, + /// The ID of the user to designate as an admin. + pub user_id: Option, +} + +pub struct SetAdminResponse { + pub ok: Option, +} + +pub struct SetAdminError {} + +pub struct SetExpirationRequest { + /// The ID (`T1234`) of the workspace. + pub team_id: Option, + /// The ID of the user to set an expiration for. + pub user_id: Option, + /// Timestamp when guest account should be disabled. + pub expiration_ts: Option, +} + +pub struct SetExpirationResponse { + pub ok: Option, +} + +pub struct SetExpirationError {} + +pub struct ListRequest { + /// The ID (`T1234`) of the workspace. + pub team_id: Option, + /// Set `cursor` to `next_cursor` returned by the previous call to list items in the next page. + pub cursor: String, + /// Limit for how many users to be retrieved per page + pub limit: u64, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} + +pub struct RemoveRequest { + /// The ID (`T1234`) of the workspace. + pub team_id: Option, + /// The ID of the user to remove. + pub user_id: Option, +} + +pub struct RemoveResponse { + pub ok: Option, +} + +pub struct RemoveError {} diff --git a/src/mod_types/admin/users/session_types.rs b/src/mod_types/admin/users/session_types.rs new file mode 100644 index 00000000..a1922f97 --- /dev/null +++ b/src/mod_types/admin/users/session_types.rs @@ -0,0 +1,26 @@ +pub struct ResetRequest { + /// The ID of the user to wipe sessions for + pub user_id: Option, + /// Only expire mobile sessions (default: false) + pub mobile_only: bool, + /// Only expire web sessions (default: false) + pub web_only: bool, +} + +pub struct ResetResponse { + pub ok: Option, +} + +pub struct ResetError {} + +pub struct InvalidateRequest { + /// ID of the team that the session belongs to + pub team_id: Option, + pub session_id: Option, +} + +pub struct InvalidateResponse { + pub ok: Option, +} + +pub struct InvalidateError {} diff --git a/src/mod_types/api_types.rs b/src/mod_types/api_types.rs index f0366b1a..c9e7532a 100644 --- a/src/mod_types/api_types.rs +++ b/src/mod_types/api_types.rs @@ -1,115 +1,13 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct TestRequest<'a> { +pub struct TestRequest { /// Error response to return - pub error: Option<&'a str>, + pub error: String, /// example property to return - pub foo: Option<&'a str>, + pub foo: String, } -#[derive(Clone, Debug, Deserialize)] pub struct TestResponse { - pub args: Option>, - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for TestResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum TestError { - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), + pub error: String, + pub ok: Option, } -impl<'a, E: Error> From<&'a str> for TestError { - fn from(s: &'a str) -> Self { - match s { - "invalid_arg_name" => TestError::InvalidArgName, - "invalid_array_arg" => TestError::InvalidArrayArg, - "invalid_charset" => TestError::InvalidCharset, - "invalid_form_data" => TestError::InvalidFormData, - "invalid_post_type" => TestError::InvalidPostType, - "missing_post_type" => TestError::MissingPostType, - "team_added_to_org" => TestError::TeamAddedToOrg, - "request_timeout" => TestError::RequestTimeout, - _ => TestError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for TestError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - TestError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -TestError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -TestError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -TestError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -TestError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -TestError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -TestError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -TestError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - TestError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - TestError::Unknown(ref s) => return write!(f, "{}", s), - TestError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for TestError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - TestError::MalformedResponse(_, ref e) => Some(e), - TestError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct TestError {} diff --git a/src/mod_types/apps/event/authorizations_types.rs b/src/mod_types/apps/event/authorizations_types.rs new file mode 100644 index 00000000..f7a52077 --- /dev/null +++ b/src/mod_types/apps/event/authorizations_types.rs @@ -0,0 +1,11 @@ +pub struct ListRequest { + pub event_context: Option, + pub cursor: String, + pub limit: u64, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} diff --git a/src/mod_types/apps/event/mod.rs b/src/mod_types/apps/event/mod.rs new file mode 100644 index 00000000..5f34b386 --- /dev/null +++ b/src/mod_types/apps/event/mod.rs @@ -0,0 +1 @@ +pub mod authorizations_types; diff --git a/src/mod_types/apps/mod.rs b/src/mod_types/apps/mod.rs new file mode 100644 index 00000000..b3c88e87 --- /dev/null +++ b/src/mod_types/apps/mod.rs @@ -0,0 +1,17 @@ +pub mod event; +pub mod permissions; + +pub struct UninstallRequest { + /// Issued when you created your application. + pub client_id: String, + /// Issued when you created your application. + pub client_secret: String, +} + +pub struct UninstallResponse { + pub callstack: String, + pub error: String, + pub ok: Option, +} + +pub struct UninstallError {} diff --git a/src/mod_types/apps/permissions/mod.rs b/src/mod_types/apps/permissions/mod.rs new file mode 100644 index 00000000..43bbbf24 --- /dev/null +++ b/src/mod_types/apps/permissions/mod.rs @@ -0,0 +1,104 @@ +pub mod resources_types; +pub mod scopes_types; +pub mod users_types; + +pub struct RequestRequest { + /// A comma separated list of scopes to request for + pub scopes: Option, + /// Token used to trigger the permissions API + pub trigger_id: Option, +} + +pub struct RequestResponse { + pub callstack: String, + pub error: String, + pub ok: Option, +} + +pub struct RequestError {} + +pub struct InfoRequest {} + +pub struct InfoResourcesInner { + pub excluded_ids: Vec>, + pub ids: Option>>, + pub wildcard: bool, +} + +pub struct InfoAppHomeInner { + pub resources: InfoResourcesInner, + pub scopes: Vec, +} + +pub struct InfoResources1Inner { + pub excluded_ids: Vec>, + pub ids: Option>>, + pub wildcard: bool, +} + +pub struct InfoChannelInner { + pub resources: InfoResources1Inner, + pub scopes: Vec, +} + +pub struct InfoResources2Inner { + pub excluded_ids: Vec>, + pub ids: Option>>, + pub wildcard: bool, +} + +pub struct InfoGroupInner { + pub resources: InfoResources2Inner, + pub scopes: Vec, +} + +pub struct InfoResources3Inner { + pub excluded_ids: Vec>, + pub ids: Option>>, + pub wildcard: bool, +} + +pub struct InfoImInner { + pub resources: InfoResources3Inner, + pub scopes: Vec, +} + +pub struct InfoResources4Inner { + pub excluded_ids: Vec>, + pub ids: Option>>, + pub wildcard: bool, +} + +pub struct InfoMpimInner { + pub resources: InfoResources4Inner, + pub scopes: Vec, +} + +pub struct InfoResources5Inner { + pub excluded_ids: Vec>, + pub ids: Option>>, + pub wildcard: bool, +} + +pub struct InfoTeamInner { + pub resources: Option, + pub scopes: Option>, +} + +pub struct InfoInfoInner { + pub app_home: Option, + pub channel: Option, + pub group: Option, + pub im: Option, + pub mpim: Option, + pub team: Option, +} + +pub struct InfoResponse { + pub callstack: String, + pub error: String, + pub info: Option, + pub ok: Option, +} + +pub struct InfoError {} diff --git a/src/mod_types/apps/permissions/resources_types.rs b/src/mod_types/apps/permissions/resources_types.rs new file mode 100644 index 00000000..ae2bfa0b --- /dev/null +++ b/src/mod_types/apps/permissions/resources_types.rs @@ -0,0 +1,25 @@ +pub struct ListRequest { + /// Paginate through collections of data by setting the `cursor` parameter to a `next_cursor` attribute returned by a previous request's `response_metadata`. Default value fetches the first "page" of the collection. See [pagination](/docs/pagination) for more detail. + pub cursor: String, + /// The maximum number of items to return. + pub limit: u64, +} + +pub struct ListResourcesInner { + pub id: String, + pub r#type: String, +} + +pub struct ListResponseMetadataInner { + pub next_cursor: Option, +} + +pub struct ListResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub resources: Option>, + pub response_metadata: ListResponseMetadataInner, +} + +pub struct ListError {} diff --git a/src/mod_types/apps/permissions/scopes_types.rs b/src/mod_types/apps/permissions/scopes_types.rs new file mode 100644 index 00000000..0d144c6e --- /dev/null +++ b/src/mod_types/apps/permissions/scopes_types.rs @@ -0,0 +1,20 @@ +pub struct ListRequest {} + +pub struct ListScopesInner { + pub app_home: Vec, + pub channel: Vec, + pub group: Vec, + pub im: Vec, + pub mpim: Vec, + pub team: Vec, + pub user: Vec, +} + +pub struct ListResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub scopes: Option, +} + +pub struct ListError {} diff --git a/src/mod_types/apps/permissions/users_types.rs b/src/mod_types/apps/permissions/users_types.rs new file mode 100644 index 00000000..545cf212 --- /dev/null +++ b/src/mod_types/apps/permissions/users_types.rs @@ -0,0 +1,27 @@ +pub struct ListRequest { + /// Paginate through collections of data by setting the `cursor` parameter to a `next_cursor` attribute returned by a previous request's `response_metadata`. Default value fetches the first "page" of the collection. See [pagination](/docs/pagination) for more detail. + pub cursor: String, + /// The maximum number of items to return. + pub limit: u64, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} + +pub struct RequestRequest { + /// A comma separated list of user scopes to request for + pub scopes: Option, + /// Token used to trigger the request + pub trigger_id: Option, + /// The user this scope is being requested for + pub user: Option, +} + +pub struct RequestResponse { + pub ok: Option, +} + +pub struct RequestError {} diff --git a/src/mod_types/auth_types.rs b/src/mod_types/auth_types.rs index e475315c..41a8dab9 100644 --- a/src/mod_types/auth_types.rs +++ b/src/mod_types/auth_types.rs @@ -1,134 +1,11 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= +pub struct TestRequest {} -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct RevokeRequest { - /// Setting this parameter to 1 triggers a testing mode where the specified token will not actually be revoked. - pub test: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct RevokeResponse { - error: Option, - #[serde(default)] - ok: bool, - pub revoked: Option, -} - -impl Into>> for RevokeResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum RevokeError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for RevokeError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => RevokeError::NotAuthed, - "invalid_auth" => RevokeError::InvalidAuth, - "account_inactive" => RevokeError::AccountInactive, - "invalid_arg_name" => RevokeError::InvalidArgName, - "invalid_array_arg" => RevokeError::InvalidArrayArg, - "invalid_charset" => RevokeError::InvalidCharset, - "invalid_form_data" => RevokeError::InvalidFormData, - "invalid_post_type" => RevokeError::InvalidPostType, - "missing_post_type" => RevokeError::MissingPostType, - "team_added_to_org" => RevokeError::TeamAddedToOrg, - "request_timeout" => RevokeError::RequestTimeout, - _ => RevokeError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for RevokeError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - RevokeError::NotAuthed => "not_authed: No authentication token provided.", -RevokeError::InvalidAuth => "invalid_auth: Invalid authentication token.", -RevokeError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -RevokeError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -RevokeError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -RevokeError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -RevokeError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -RevokeError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -RevokeError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -RevokeError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -RevokeError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - RevokeError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - RevokeError::Unknown(ref s) => return write!(f, "{}", s), - RevokeError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for RevokeError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - RevokeError::MalformedResponse(_, ref e) => Some(e), - RevokeError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Debug, Deserialize)] pub struct TestResponse { - error: Option, - #[serde(default)] - ok: bool, + pub bot_id: String, + pub callstack: String, + pub error: String, + pub is_enterprise_install: bool, + pub ok: Option, pub team: Option, pub team_id: Option, pub url: Option, @@ -136,94 +13,18 @@ pub struct TestResponse { pub user_id: Option, } -impl Into>> for TestResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum TestError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} +pub struct TestError {} -impl<'a, E: Error> From<&'a str> for TestError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => TestError::NotAuthed, - "invalid_auth" => TestError::InvalidAuth, - "account_inactive" => TestError::AccountInactive, - "invalid_arg_name" => TestError::InvalidArgName, - "invalid_array_arg" => TestError::InvalidArrayArg, - "invalid_charset" => TestError::InvalidCharset, - "invalid_form_data" => TestError::InvalidFormData, - "invalid_post_type" => TestError::InvalidPostType, - "missing_post_type" => TestError::MissingPostType, - "team_added_to_org" => TestError::TeamAddedToOrg, - "request_timeout" => TestError::RequestTimeout, - _ => TestError::Unknown(s.to_owned()), - } - } +pub struct RevokeRequest { + /// Setting this parameter to `1` triggers a _testing mode_ where the specified token will not actually be revoked. + pub test: bool, } -impl fmt::Display for TestError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - TestError::NotAuthed => "not_authed: No authentication token provided.", -TestError::InvalidAuth => "invalid_auth: Invalid authentication token.", -TestError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -TestError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -TestError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -TestError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -TestError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -TestError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -TestError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -TestError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -TestError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - TestError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - TestError::Unknown(ref s) => return write!(f, "{}", s), - TestError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } +pub struct RevokeResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub revoked: Option, } -impl Error for TestError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - TestError::MalformedResponse(_, ref e) => Some(e), - TestError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct RevokeError {} diff --git a/src/mod_types/bots_types.rs b/src/mod_types/bots_types.rs index 5532f442..4affdc2f 100644 --- a/src/mod_types/bots_types.rs +++ b/src/mod_types/bots_types.rs @@ -1,149 +1,29 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct InfoRequest<'a> { +pub struct InfoRequest { /// Bot user to get info on - pub bot: Option<&'a str>, + pub bot: String, } -#[derive(Clone, Debug, Deserialize)] -pub struct InfoResponse { - pub bot: Option, - error: Option, - #[serde(default)] - ok: bool, +pub struct InfoIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, } -#[derive(Clone, Debug, Deserialize)] -pub struct InfoResponseBot { +pub struct InfoBotInner { pub app_id: Option, pub deleted: Option, - pub icons: Option, + pub icons: Option, pub id: Option, pub name: Option, + pub updated: Option, + pub user_id: String, } -#[derive(Clone, Debug, Deserialize)] -pub struct InfoResponseBotIcons { - pub image_36: Option, - pub image_48: Option, - pub image_72: Option, -} - -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum InfoError { - /// Value passed for bot was invalid. - BotNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for InfoError { - fn from(s: &'a str) -> Self { - match s { - "bot_not_found" => InfoError::BotNotFound, - "not_authed" => InfoError::NotAuthed, - "invalid_auth" => InfoError::InvalidAuth, - "account_inactive" => InfoError::AccountInactive, - "user_is_bot" => InfoError::UserIsBot, - "invalid_arg_name" => InfoError::InvalidArgName, - "invalid_array_arg" => InfoError::InvalidArrayArg, - "invalid_charset" => InfoError::InvalidCharset, - "invalid_form_data" => InfoError::InvalidFormData, - "invalid_post_type" => InfoError::InvalidPostType, - "missing_post_type" => InfoError::MissingPostType, - "team_added_to_org" => InfoError::TeamAddedToOrg, - "request_timeout" => InfoError::RequestTimeout, - _ => InfoError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for InfoError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - InfoError::BotNotFound => "bot_not_found: Value passed for bot was invalid.", -InfoError::NotAuthed => "not_authed: No authentication token provided.", -InfoError::InvalidAuth => "invalid_auth: Invalid authentication token.", -InfoError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -InfoError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -InfoError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -InfoError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -InfoError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -InfoError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -InfoError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -InfoError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -InfoError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -InfoError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - InfoError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - InfoError::Unknown(ref s) => return write!(f, "{}", s), - InfoError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } +pub struct InfoResponse { + pub bot: Option, + pub callstack: String, + pub error: String, + pub ok: Option, } -impl Error for InfoError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - InfoError::MalformedResponse(_, ref e) => Some(e), - InfoError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct InfoError {} diff --git a/src/mod_types/calls/mod.rs b/src/mod_types/calls/mod.rs new file mode 100644 index 00000000..3833570d --- /dev/null +++ b/src/mod_types/calls/mod.rs @@ -0,0 +1,67 @@ +pub mod participants_types; + +pub struct EndRequest { + /// `id` returned when registering the call using the [`calls.add`](/methods/calls.add) method. + pub id: Option, + /// Call duration in seconds + pub duration: u64, +} + +pub struct EndResponse { + pub ok: Option, +} + +pub struct EndError {} + +pub struct UpdateRequest { + /// `id` returned by the [`calls.add`](/methods/calls.add) method. + pub id: Option, + /// The name of the Call. + pub title: String, + /// The URL required for a client to join the Call. + pub join_url: String, + /// When supplied, available Slack clients will attempt to directly launch the 3rd-party Call with this URL. + pub desktop_app_join_url: String, +} + +pub struct UpdateResponse { + pub ok: Option, +} + +pub struct UpdateError {} + +pub struct AddRequest { + /// An ID supplied by the 3rd-party Call provider. It must be unique across all Calls from that service. + pub external_unique_id: Option, + /// An optional, human-readable ID supplied by the 3rd-party Call provider. If supplied, this ID will be displayed in the Call object. + pub external_display_id: String, + /// The URL required for a client to join the Call. + pub join_url: Option, + /// When supplied, available Slack clients will attempt to directly launch the 3rd-party Call with this URL. + pub desktop_app_join_url: String, + /// Call start time in UTC UNIX timestamp format + pub date_start: u64, + /// The name of the Call. + pub title: String, + /// The valid Slack user ID of the user who created this Call. When this method is called with a user token, the `created_by` field is optional and defaults to the authed user of the token. Otherwise, the field is required. + pub created_by: String, + /// The list of users to register as participants in the Call. [Read more on how to specify users here](/apis/calls#users). + pub users: String, +} + +pub struct AddResponse { + pub ok: Option, +} + +pub struct AddError {} + +pub struct InfoRequest { + /// `id` of the Call returned by the [`calls.add`](/methods/calls.add) method. + pub id: Option, +} + +pub struct InfoResponse { + pub ok: Option, +} + +pub struct InfoError {} diff --git a/src/mod_types/calls/participants_types.rs b/src/mod_types/calls/participants_types.rs new file mode 100644 index 00000000..1646305f --- /dev/null +++ b/src/mod_types/calls/participants_types.rs @@ -0,0 +1,25 @@ +pub struct RemoveRequest { + /// `id` returned by the [`calls.add`](/methods/calls.add) method. + pub id: Option, + /// The list of users to remove as participants in the Call. [Read more on how to specify users here](/apis/calls#users). + pub users: Option, +} + +pub struct RemoveResponse { + pub ok: Option, +} + +pub struct RemoveError {} + +pub struct AddRequest { + /// `id` returned by the [`calls.add`](/methods/calls.add) method. + pub id: Option, + /// The list of users to add as participants in the Call. [Read more on how to specify users here](/apis/calls#users). + pub users: Option, +} + +pub struct AddResponse { + pub ok: Option, +} + +pub struct AddError {} diff --git a/src/mod_types/channels_types.rs b/src/mod_types/channels_types.rs deleted file mode 100644 index 3ca88dc3..00000000 --- a/src/mod_types/channels_types.rs +++ /dev/null @@ -1,1989 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -//! Get info on your team's Slack channels, create or archive channels, invite users, set the topic and purpose, and mark a channel as read. - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct ArchiveRequest<'a> { - /// Channel to archive - pub channel: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct ArchiveResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for ArchiveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ArchiveError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Channel has already been archived. - AlreadyArchived, - /// You cannot archive the general channel - CantArchiveGeneral, - /// A team preference prevents the authenticated user from archiving. - RestrictedAction, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ArchiveError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => ArchiveError::ChannelNotFound, - "already_archived" => ArchiveError::AlreadyArchived, - "cant_archive_general" => ArchiveError::CantArchiveGeneral, - "restricted_action" => ArchiveError::RestrictedAction, - "not_authed" => ArchiveError::NotAuthed, - "invalid_auth" => ArchiveError::InvalidAuth, - "account_inactive" => ArchiveError::AccountInactive, - "user_is_bot" => ArchiveError::UserIsBot, - "user_is_restricted" => ArchiveError::UserIsRestricted, - "invalid_arg_name" => ArchiveError::InvalidArgName, - "invalid_array_arg" => ArchiveError::InvalidArrayArg, - "invalid_charset" => ArchiveError::InvalidCharset, - "invalid_form_data" => ArchiveError::InvalidFormData, - "invalid_post_type" => ArchiveError::InvalidPostType, - "missing_post_type" => ArchiveError::MissingPostType, - "team_added_to_org" => ArchiveError::TeamAddedToOrg, - "request_timeout" => ArchiveError::RequestTimeout, - _ => ArchiveError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for ArchiveError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ArchiveError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -ArchiveError::AlreadyArchived => "already_archived: Channel has already been archived.", -ArchiveError::CantArchiveGeneral => "cant_archive_general: You cannot archive the general channel", -ArchiveError::RestrictedAction => "restricted_action: A team preference prevents the authenticated user from archiving.", -ArchiveError::NotAuthed => "not_authed: No authentication token provided.", -ArchiveError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ArchiveError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ArchiveError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -ArchiveError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -ArchiveError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ArchiveError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ArchiveError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ArchiveError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ArchiveError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ArchiveError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ArchiveError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ArchiveError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ArchiveError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ArchiveError::Unknown(ref s) => return write!(f, "{}", s), - ArchiveError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for ArchiveError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ArchiveError::MalformedResponse(_, ref e) => Some(e), - ArchiveError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct CreateRequest<'a> { - /// Name of channel to create - pub name: &'a str, - /// Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. - pub validate: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct CreateResponse { - pub channel: Option, - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for CreateResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum CreateError { - /// A channel cannot be created with the given name. - NameTaken, - /// A team preference prevents the authenticated user from creating channels. - RestrictedAction, - /// Value passed for name was empty. - NoChannel, - /// Value passed for name was empty. - InvalidNameRequired, - /// Value passed for name contained only punctuation. - InvalidNamePunctuation, - /// Value passed for name exceeded max length. - InvalidNameMaxlength, - /// Value passed for name contained unallowed special characters or upper case characters. - InvalidNameSpecials, - /// Value passed for name was invalid. - InvalidName, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for CreateError { - fn from(s: &'a str) -> Self { - match s { - "name_taken" => CreateError::NameTaken, - "restricted_action" => CreateError::RestrictedAction, - "no_channel" => CreateError::NoChannel, - "invalid_name_required" => CreateError::InvalidNameRequired, - "invalid_name_punctuation" => CreateError::InvalidNamePunctuation, - "invalid_name_maxlength" => CreateError::InvalidNameMaxlength, - "invalid_name_specials" => CreateError::InvalidNameSpecials, - "invalid_name" => CreateError::InvalidName, - "not_authed" => CreateError::NotAuthed, - "invalid_auth" => CreateError::InvalidAuth, - "account_inactive" => CreateError::AccountInactive, - "user_is_bot" => CreateError::UserIsBot, - "user_is_restricted" => CreateError::UserIsRestricted, - "invalid_arg_name" => CreateError::InvalidArgName, - "invalid_array_arg" => CreateError::InvalidArrayArg, - "invalid_charset" => CreateError::InvalidCharset, - "invalid_form_data" => CreateError::InvalidFormData, - "invalid_post_type" => CreateError::InvalidPostType, - "missing_post_type" => CreateError::MissingPostType, - "team_added_to_org" => CreateError::TeamAddedToOrg, - "request_timeout" => CreateError::RequestTimeout, - _ => CreateError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for CreateError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - CreateError::NameTaken => "name_taken: A channel cannot be created with the given name.", -CreateError::RestrictedAction => "restricted_action: A team preference prevents the authenticated user from creating channels.", -CreateError::NoChannel => "no_channel: Value passed for name was empty.", -CreateError::InvalidNameRequired => "invalid_name_required: Value passed for name was empty.", -CreateError::InvalidNamePunctuation => "invalid_name_punctuation: Value passed for name contained only punctuation.", -CreateError::InvalidNameMaxlength => "invalid_name_maxlength: Value passed for name exceeded max length.", -CreateError::InvalidNameSpecials => "invalid_name_specials: Value passed for name contained unallowed special characters or upper case characters.", -CreateError::InvalidName => "invalid_name: Value passed for name was invalid.", -CreateError::NotAuthed => "not_authed: No authentication token provided.", -CreateError::InvalidAuth => "invalid_auth: Invalid authentication token.", -CreateError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -CreateError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -CreateError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -CreateError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -CreateError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -CreateError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -CreateError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -CreateError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -CreateError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -CreateError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -CreateError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - CreateError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - CreateError::Unknown(ref s) => return write!(f, "{}", s), - CreateError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for CreateError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - CreateError::MalformedResponse(_, ref e) => Some(e), - CreateError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct HistoryRequest<'a> { - /// Channel to fetch history for. - pub channel: &'a str, - /// End of time range of messages to include in results. - pub latest: Option, - /// Start of time range of messages to include in results. - pub oldest: Option, - /// Include messages with latest or oldest timestamp in results. - pub inclusive: Option, - /// Number of messages to return, between 1 and 1000. - pub count: Option, - /// Include unread_count_display in the output? - pub unreads: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct HistoryResponse { - error: Option, - pub has_more: Option, - pub latest: Option, - pub messages: Option>, - #[serde(default)] - ok: bool, -} - -impl Into>> for HistoryResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum HistoryError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Value passed for latest was invalid - InvalidTsLatest, - /// Value passed for oldest was invalid - InvalidTsOldest, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for HistoryError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => HistoryError::ChannelNotFound, - "invalid_ts_latest" => HistoryError::InvalidTsLatest, - "invalid_ts_oldest" => HistoryError::InvalidTsOldest, - "not_authed" => HistoryError::NotAuthed, - "invalid_auth" => HistoryError::InvalidAuth, - "account_inactive" => HistoryError::AccountInactive, - "invalid_arg_name" => HistoryError::InvalidArgName, - "invalid_array_arg" => HistoryError::InvalidArrayArg, - "invalid_charset" => HistoryError::InvalidCharset, - "invalid_form_data" => HistoryError::InvalidFormData, - "invalid_post_type" => HistoryError::InvalidPostType, - "missing_post_type" => HistoryError::MissingPostType, - "team_added_to_org" => HistoryError::TeamAddedToOrg, - "request_timeout" => HistoryError::RequestTimeout, - _ => HistoryError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for HistoryError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - HistoryError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -HistoryError::InvalidTsLatest => "invalid_ts_latest: Value passed for latest was invalid", -HistoryError::InvalidTsOldest => "invalid_ts_oldest: Value passed for oldest was invalid", -HistoryError::NotAuthed => "not_authed: No authentication token provided.", -HistoryError::InvalidAuth => "invalid_auth: Invalid authentication token.", -HistoryError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -HistoryError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -HistoryError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -HistoryError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -HistoryError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -HistoryError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -HistoryError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -HistoryError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -HistoryError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - HistoryError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - HistoryError::Unknown(ref s) => return write!(f, "{}", s), - HistoryError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for HistoryError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - HistoryError::MalformedResponse(_, ref e) => Some(e), - HistoryError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct InfoRequest<'a> { - /// Channel to get info on - pub channel: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct InfoResponse { - pub channel: Option, - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum InfoError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for InfoError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => InfoError::ChannelNotFound, - "not_authed" => InfoError::NotAuthed, - "invalid_auth" => InfoError::InvalidAuth, - "account_inactive" => InfoError::AccountInactive, - "invalid_arg_name" => InfoError::InvalidArgName, - "invalid_array_arg" => InfoError::InvalidArrayArg, - "invalid_charset" => InfoError::InvalidCharset, - "invalid_form_data" => InfoError::InvalidFormData, - "invalid_post_type" => InfoError::InvalidPostType, - "missing_post_type" => InfoError::MissingPostType, - "team_added_to_org" => InfoError::TeamAddedToOrg, - "request_timeout" => InfoError::RequestTimeout, - _ => InfoError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for InfoError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - InfoError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -InfoError::NotAuthed => "not_authed: No authentication token provided.", -InfoError::InvalidAuth => "invalid_auth: Invalid authentication token.", -InfoError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -InfoError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -InfoError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -InfoError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -InfoError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -InfoError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -InfoError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -InfoError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -InfoError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - InfoError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - InfoError::Unknown(ref s) => return write!(f, "{}", s), - InfoError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for InfoError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - InfoError::MalformedResponse(_, ref e) => Some(e), - InfoError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct InviteRequest<'a> { - /// Channel to invite user to. - pub channel: &'a str, - /// User to invite to channel. - pub user: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct InviteResponse { - pub channel: Option, - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for InviteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum InviteError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Value passed for user was invalid. - UserNotFound, - /// Authenticated user cannot invite themselves to a channel. - CantInviteSelf, - /// Authenticated user is not in the channel. - NotInChannel, - /// Invited user is already in the channel. - AlreadyInChannel, - /// Channel has been archived. - IsArchived, - /// User cannot be invited to this channel. - CantInvite, - /// URA is already in the maximum number of channels. - UraMaxChannels, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a single channel guest. - UserIsUltraRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for InviteError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => InviteError::ChannelNotFound, - "user_not_found" => InviteError::UserNotFound, - "cant_invite_self" => InviteError::CantInviteSelf, - "not_in_channel" => InviteError::NotInChannel, - "already_in_channel" => InviteError::AlreadyInChannel, - "is_archived" => InviteError::IsArchived, - "cant_invite" => InviteError::CantInvite, - "ura_max_channels" => InviteError::UraMaxChannels, - "not_authed" => InviteError::NotAuthed, - "invalid_auth" => InviteError::InvalidAuth, - "account_inactive" => InviteError::AccountInactive, - "user_is_bot" => InviteError::UserIsBot, - "user_is_ultra_restricted" => InviteError::UserIsUltraRestricted, - "invalid_arg_name" => InviteError::InvalidArgName, - "invalid_array_arg" => InviteError::InvalidArrayArg, - "invalid_charset" => InviteError::InvalidCharset, - "invalid_form_data" => InviteError::InvalidFormData, - "invalid_post_type" => InviteError::InvalidPostType, - "missing_post_type" => InviteError::MissingPostType, - "team_added_to_org" => InviteError::TeamAddedToOrg, - "request_timeout" => InviteError::RequestTimeout, - _ => InviteError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for InviteError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - InviteError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -InviteError::UserNotFound => "user_not_found: Value passed for user was invalid.", -InviteError::CantInviteSelf => "cant_invite_self: Authenticated user cannot invite themselves to a channel.", -InviteError::NotInChannel => "not_in_channel: Authenticated user is not in the channel.", -InviteError::AlreadyInChannel => "already_in_channel: Invited user is already in the channel.", -InviteError::IsArchived => "is_archived: Channel has been archived.", -InviteError::CantInvite => "cant_invite: User cannot be invited to this channel.", -InviteError::UraMaxChannels => "ura_max_channels: URA is already in the maximum number of channels.", -InviteError::NotAuthed => "not_authed: No authentication token provided.", -InviteError::InvalidAuth => "invalid_auth: Invalid authentication token.", -InviteError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -InviteError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -InviteError::UserIsUltraRestricted => "user_is_ultra_restricted: This method cannot be called by a single channel guest.", -InviteError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -InviteError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -InviteError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -InviteError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -InviteError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -InviteError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -InviteError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -InviteError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - InviteError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - InviteError::Unknown(ref s) => return write!(f, "{}", s), - InviteError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for InviteError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - InviteError::MalformedResponse(_, ref e) => Some(e), - InviteError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct JoinRequest<'a> { - /// Name of channel to join - pub name: &'a str, - /// Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. - pub validate: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct JoinResponse { - pub channel: Option, - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for JoinResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum JoinError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// A channel cannot be created with the given name. - NameTaken, - /// A team preference prevents the authenticated user from creating channels. - RestrictedAction, - /// Value passed for name was empty. - NoChannel, - /// Channel has been archived. - IsArchived, - /// Value passed for name was empty. - InvalidNameRequired, - /// Value passed for name contained only punctuation. - InvalidNamePunctuation, - /// Value passed for name exceeded max length. - InvalidNameMaxlength, - /// Value passed for name contained unallowed special characters or upper case characters. - InvalidNameSpecials, - /// Value passed for name was invalid. - InvalidName, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for JoinError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => JoinError::ChannelNotFound, - "name_taken" => JoinError::NameTaken, - "restricted_action" => JoinError::RestrictedAction, - "no_channel" => JoinError::NoChannel, - "is_archived" => JoinError::IsArchived, - "invalid_name_required" => JoinError::InvalidNameRequired, - "invalid_name_punctuation" => JoinError::InvalidNamePunctuation, - "invalid_name_maxlength" => JoinError::InvalidNameMaxlength, - "invalid_name_specials" => JoinError::InvalidNameSpecials, - "invalid_name" => JoinError::InvalidName, - "not_authed" => JoinError::NotAuthed, - "invalid_auth" => JoinError::InvalidAuth, - "account_inactive" => JoinError::AccountInactive, - "user_is_bot" => JoinError::UserIsBot, - "user_is_restricted" => JoinError::UserIsRestricted, - "invalid_arg_name" => JoinError::InvalidArgName, - "invalid_array_arg" => JoinError::InvalidArrayArg, - "invalid_charset" => JoinError::InvalidCharset, - "invalid_form_data" => JoinError::InvalidFormData, - "invalid_post_type" => JoinError::InvalidPostType, - "missing_post_type" => JoinError::MissingPostType, - "team_added_to_org" => JoinError::TeamAddedToOrg, - "request_timeout" => JoinError::RequestTimeout, - _ => JoinError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for JoinError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - JoinError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -JoinError::NameTaken => "name_taken: A channel cannot be created with the given name.", -JoinError::RestrictedAction => "restricted_action: A team preference prevents the authenticated user from creating channels.", -JoinError::NoChannel => "no_channel: Value passed for name was empty.", -JoinError::IsArchived => "is_archived: Channel has been archived.", -JoinError::InvalidNameRequired => "invalid_name_required: Value passed for name was empty.", -JoinError::InvalidNamePunctuation => "invalid_name_punctuation: Value passed for name contained only punctuation.", -JoinError::InvalidNameMaxlength => "invalid_name_maxlength: Value passed for name exceeded max length.", -JoinError::InvalidNameSpecials => "invalid_name_specials: Value passed for name contained unallowed special characters or upper case characters.", -JoinError::InvalidName => "invalid_name: Value passed for name was invalid.", -JoinError::NotAuthed => "not_authed: No authentication token provided.", -JoinError::InvalidAuth => "invalid_auth: Invalid authentication token.", -JoinError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -JoinError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -JoinError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -JoinError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -JoinError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -JoinError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -JoinError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -JoinError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -JoinError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -JoinError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -JoinError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - JoinError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - JoinError::Unknown(ref s) => return write!(f, "{}", s), - JoinError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for JoinError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - JoinError::MalformedResponse(_, ref e) => Some(e), - JoinError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct KickRequest<'a> { - /// Channel to remove user from. - pub channel: &'a str, - /// User to remove from channel. - pub user: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct KickResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for KickResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum KickError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Value passed for user was invalid. - UserNotFound, - /// Authenticated user can't kick themselves from a channel. - CantKickSelf, - /// User was not in the channel. - NotInChannel, - /// User cannot be removed from #general. - CantKickFromGeneral, - /// A team preference prevents the authenticated user from kicking. - RestrictedAction, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for KickError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => KickError::ChannelNotFound, - "user_not_found" => KickError::UserNotFound, - "cant_kick_self" => KickError::CantKickSelf, - "not_in_channel" => KickError::NotInChannel, - "cant_kick_from_general" => KickError::CantKickFromGeneral, - "restricted_action" => KickError::RestrictedAction, - "not_authed" => KickError::NotAuthed, - "invalid_auth" => KickError::InvalidAuth, - "account_inactive" => KickError::AccountInactive, - "user_is_bot" => KickError::UserIsBot, - "user_is_restricted" => KickError::UserIsRestricted, - "invalid_arg_name" => KickError::InvalidArgName, - "invalid_array_arg" => KickError::InvalidArrayArg, - "invalid_charset" => KickError::InvalidCharset, - "invalid_form_data" => KickError::InvalidFormData, - "invalid_post_type" => KickError::InvalidPostType, - "missing_post_type" => KickError::MissingPostType, - "team_added_to_org" => KickError::TeamAddedToOrg, - "request_timeout" => KickError::RequestTimeout, - _ => KickError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for KickError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - KickError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -KickError::UserNotFound => "user_not_found: Value passed for user was invalid.", -KickError::CantKickSelf => "cant_kick_self: Authenticated user can't kick themselves from a channel.", -KickError::NotInChannel => "not_in_channel: User was not in the channel.", -KickError::CantKickFromGeneral => "cant_kick_from_general: User cannot be removed from #general.", -KickError::RestrictedAction => "restricted_action: A team preference prevents the authenticated user from kicking.", -KickError::NotAuthed => "not_authed: No authentication token provided.", -KickError::InvalidAuth => "invalid_auth: Invalid authentication token.", -KickError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -KickError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -KickError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -KickError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -KickError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -KickError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -KickError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -KickError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -KickError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -KickError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -KickError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - KickError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - KickError::Unknown(ref s) => return write!(f, "{}", s), - KickError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for KickError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - KickError::MalformedResponse(_, ref e) => Some(e), - KickError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct LeaveRequest<'a> { - /// Channel to leave - pub channel: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct LeaveResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for LeaveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum LeaveError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Channel has been archived. - IsArchived, - /// Authenticated user cannot leave the general channel - CantLeaveGeneral, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for LeaveError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => LeaveError::ChannelNotFound, - "is_archived" => LeaveError::IsArchived, - "cant_leave_general" => LeaveError::CantLeaveGeneral, - "not_authed" => LeaveError::NotAuthed, - "invalid_auth" => LeaveError::InvalidAuth, - "account_inactive" => LeaveError::AccountInactive, - "user_is_bot" => LeaveError::UserIsBot, - "user_is_restricted" => LeaveError::UserIsRestricted, - "invalid_arg_name" => LeaveError::InvalidArgName, - "invalid_array_arg" => LeaveError::InvalidArrayArg, - "invalid_charset" => LeaveError::InvalidCharset, - "invalid_form_data" => LeaveError::InvalidFormData, - "invalid_post_type" => LeaveError::InvalidPostType, - "missing_post_type" => LeaveError::MissingPostType, - "team_added_to_org" => LeaveError::TeamAddedToOrg, - "request_timeout" => LeaveError::RequestTimeout, - _ => LeaveError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for LeaveError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - LeaveError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -LeaveError::IsArchived => "is_archived: Channel has been archived.", -LeaveError::CantLeaveGeneral => "cant_leave_general: Authenticated user cannot leave the general channel", -LeaveError::NotAuthed => "not_authed: No authentication token provided.", -LeaveError::InvalidAuth => "invalid_auth: Invalid authentication token.", -LeaveError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -LeaveError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -LeaveError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -LeaveError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -LeaveError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -LeaveError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -LeaveError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -LeaveError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -LeaveError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -LeaveError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -LeaveError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - LeaveError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - LeaveError::Unknown(ref s) => return write!(f, "{}", s), - LeaveError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for LeaveError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - LeaveError::MalformedResponse(_, ref e) => Some(e), - LeaveError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct ListRequest { - /// Exclude archived channels from the list - pub exclude_archived: Option, - /// Exclude the members collection from each channel - pub exclude_members: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponse { - pub channels: Option>, - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ListError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ListError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => ListError::NotAuthed, - "invalid_auth" => ListError::InvalidAuth, - "account_inactive" => ListError::AccountInactive, - "invalid_arg_name" => ListError::InvalidArgName, - "invalid_array_arg" => ListError::InvalidArrayArg, - "invalid_charset" => ListError::InvalidCharset, - "invalid_form_data" => ListError::InvalidFormData, - "invalid_post_type" => ListError::InvalidPostType, - "missing_post_type" => ListError::MissingPostType, - "team_added_to_org" => ListError::TeamAddedToOrg, - "request_timeout" => ListError::RequestTimeout, - _ => ListError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for ListError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ListError::NotAuthed => "not_authed: No authentication token provided.", -ListError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ListError::Unknown(ref s) => return write!(f, "{}", s), - ListError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for ListError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ListError::MalformedResponse(_, ref e) => Some(e), - ListError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct MarkRequest<'a> { - /// Channel to set reading cursor in. - pub channel: &'a str, - /// Timestamp of the most recently seen message. - pub ts: crate::Timestamp, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct MarkResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for MarkResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum MarkError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Value passed for timestamp was invalid. - InvalidTimestamp, - /// Caller is not a member of the channel. - NotInChannel, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for MarkError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => MarkError::ChannelNotFound, - "invalid_timestamp" => MarkError::InvalidTimestamp, - "not_in_channel" => MarkError::NotInChannel, - "not_authed" => MarkError::NotAuthed, - "invalid_auth" => MarkError::InvalidAuth, - "account_inactive" => MarkError::AccountInactive, - "invalid_arg_name" => MarkError::InvalidArgName, - "invalid_array_arg" => MarkError::InvalidArrayArg, - "invalid_charset" => MarkError::InvalidCharset, - "invalid_form_data" => MarkError::InvalidFormData, - "invalid_post_type" => MarkError::InvalidPostType, - "missing_post_type" => MarkError::MissingPostType, - "team_added_to_org" => MarkError::TeamAddedToOrg, - "request_timeout" => MarkError::RequestTimeout, - _ => MarkError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for MarkError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - MarkError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -MarkError::InvalidTimestamp => "invalid_timestamp: Value passed for timestamp was invalid.", -MarkError::NotInChannel => "not_in_channel: Caller is not a member of the channel.", -MarkError::NotAuthed => "not_authed: No authentication token provided.", -MarkError::InvalidAuth => "invalid_auth: Invalid authentication token.", -MarkError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -MarkError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -MarkError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -MarkError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -MarkError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -MarkError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -MarkError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -MarkError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -MarkError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - MarkError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - MarkError::Unknown(ref s) => return write!(f, "{}", s), - MarkError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for MarkError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - MarkError::MalformedResponse(_, ref e) => Some(e), - MarkError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct RenameRequest<'a> { - /// Channel to rename - pub channel: &'a str, - /// New name for channel. - pub name: &'a str, - /// Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. - pub validate: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct RenameResponse { - pub channel: Option, - error: Option, - #[serde(default)] - ok: bool, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct RenameResponseChannel { - pub created: Option, - pub id: Option, - pub is_channel: Option, - pub name: Option, -} - -impl Into>> for RenameResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum RenameError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Caller is not a member of the channel. - NotInChannel, - /// Caller cannot rename this channel - NotAuthorized, - /// Value passed for name was invalid. - InvalidName, - /// New channel name is taken - NameTaken, - /// Value passed for name was empty. - InvalidNameRequired, - /// Value passed for name contained only punctuation. - InvalidNamePunctuation, - /// Value passed for name exceeded max length. - InvalidNameMaxlength, - /// Value passed for name contained unallowed special characters or upper case characters. - InvalidNameSpecials, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for RenameError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => RenameError::ChannelNotFound, - "not_in_channel" => RenameError::NotInChannel, - "not_authorized" => RenameError::NotAuthorized, - "invalid_name" => RenameError::InvalidName, - "name_taken" => RenameError::NameTaken, - "invalid_name_required" => RenameError::InvalidNameRequired, - "invalid_name_punctuation" => RenameError::InvalidNamePunctuation, - "invalid_name_maxlength" => RenameError::InvalidNameMaxlength, - "invalid_name_specials" => RenameError::InvalidNameSpecials, - "not_authed" => RenameError::NotAuthed, - "invalid_auth" => RenameError::InvalidAuth, - "account_inactive" => RenameError::AccountInactive, - "user_is_bot" => RenameError::UserIsBot, - "user_is_restricted" => RenameError::UserIsRestricted, - "invalid_arg_name" => RenameError::InvalidArgName, - "invalid_array_arg" => RenameError::InvalidArrayArg, - "invalid_charset" => RenameError::InvalidCharset, - "invalid_form_data" => RenameError::InvalidFormData, - "invalid_post_type" => RenameError::InvalidPostType, - "missing_post_type" => RenameError::MissingPostType, - "team_added_to_org" => RenameError::TeamAddedToOrg, - "request_timeout" => RenameError::RequestTimeout, - _ => RenameError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for RenameError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - RenameError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -RenameError::NotInChannel => "not_in_channel: Caller is not a member of the channel.", -RenameError::NotAuthorized => "not_authorized: Caller cannot rename this channel", -RenameError::InvalidName => "invalid_name: Value passed for name was invalid.", -RenameError::NameTaken => "name_taken: New channel name is taken", -RenameError::InvalidNameRequired => "invalid_name_required: Value passed for name was empty.", -RenameError::InvalidNamePunctuation => "invalid_name_punctuation: Value passed for name contained only punctuation.", -RenameError::InvalidNameMaxlength => "invalid_name_maxlength: Value passed for name exceeded max length.", -RenameError::InvalidNameSpecials => "invalid_name_specials: Value passed for name contained unallowed special characters or upper case characters.", -RenameError::NotAuthed => "not_authed: No authentication token provided.", -RenameError::InvalidAuth => "invalid_auth: Invalid authentication token.", -RenameError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -RenameError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -RenameError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -RenameError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -RenameError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -RenameError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -RenameError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -RenameError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -RenameError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -RenameError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -RenameError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - RenameError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - RenameError::Unknown(ref s) => return write!(f, "{}", s), - RenameError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for RenameError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - RenameError::MalformedResponse(_, ref e) => Some(e), - RenameError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct RepliesRequest<'a> { - /// Channel to fetch thread from - pub channel: &'a str, - /// Unique identifier of a thread's parent message - pub thread_ts: crate::Timestamp, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct RepliesResponse { - error: Option, - pub messages: Option>, - #[serde(default)] - ok: bool, - pub thread_info: Option, -} - -impl Into>> for RepliesResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum RepliesError { - /// Value for channel was missing or invalid. - ChannelNotFound, - /// Value for thread_ts was missing or invalid. - ThreadNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for RepliesError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => RepliesError::ChannelNotFound, - "thread_not_found" => RepliesError::ThreadNotFound, - "not_authed" => RepliesError::NotAuthed, - "invalid_auth" => RepliesError::InvalidAuth, - "account_inactive" => RepliesError::AccountInactive, - "invalid_arg_name" => RepliesError::InvalidArgName, - "invalid_array_arg" => RepliesError::InvalidArrayArg, - "invalid_charset" => RepliesError::InvalidCharset, - "invalid_form_data" => RepliesError::InvalidFormData, - "invalid_post_type" => RepliesError::InvalidPostType, - "missing_post_type" => RepliesError::MissingPostType, - "team_added_to_org" => RepliesError::TeamAddedToOrg, - "request_timeout" => RepliesError::RequestTimeout, - _ => RepliesError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for RepliesError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - RepliesError::ChannelNotFound => "channel_not_found: Value for channel was missing or invalid.", -RepliesError::ThreadNotFound => "thread_not_found: Value for thread_ts was missing or invalid.", -RepliesError::NotAuthed => "not_authed: No authentication token provided.", -RepliesError::InvalidAuth => "invalid_auth: Invalid authentication token.", -RepliesError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -RepliesError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -RepliesError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -RepliesError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -RepliesError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -RepliesError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -RepliesError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -RepliesError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -RepliesError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - RepliesError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - RepliesError::Unknown(ref s) => return write!(f, "{}", s), - RepliesError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for RepliesError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - RepliesError::MalformedResponse(_, ref e) => Some(e), - RepliesError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct SetPurposeRequest<'a> { - /// Channel to set the purpose of - pub channel: &'a str, - /// The new purpose - pub purpose: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct SetPurposeResponse { - error: Option, - #[serde(default)] - ok: bool, - pub purpose: Option, -} - -impl Into>> for SetPurposeResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum SetPurposeError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Authenticated user is not in the channel. - NotInChannel, - /// Channel has been archived. - IsArchived, - /// Purpose was longer than 250 characters. - TooLong, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for SetPurposeError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => SetPurposeError::ChannelNotFound, - "not_in_channel" => SetPurposeError::NotInChannel, - "is_archived" => SetPurposeError::IsArchived, - "too_long" => SetPurposeError::TooLong, - "user_is_restricted" => SetPurposeError::UserIsRestricted, - "not_authed" => SetPurposeError::NotAuthed, - "invalid_auth" => SetPurposeError::InvalidAuth, - "account_inactive" => SetPurposeError::AccountInactive, - "invalid_arg_name" => SetPurposeError::InvalidArgName, - "invalid_array_arg" => SetPurposeError::InvalidArrayArg, - "invalid_charset" => SetPurposeError::InvalidCharset, - "invalid_form_data" => SetPurposeError::InvalidFormData, - "invalid_post_type" => SetPurposeError::InvalidPostType, - "missing_post_type" => SetPurposeError::MissingPostType, - "team_added_to_org" => SetPurposeError::TeamAddedToOrg, - "request_timeout" => SetPurposeError::RequestTimeout, - _ => SetPurposeError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for SetPurposeError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - SetPurposeError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -SetPurposeError::NotInChannel => "not_in_channel: Authenticated user is not in the channel.", -SetPurposeError::IsArchived => "is_archived: Channel has been archived.", -SetPurposeError::TooLong => "too_long: Purpose was longer than 250 characters.", -SetPurposeError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -SetPurposeError::NotAuthed => "not_authed: No authentication token provided.", -SetPurposeError::InvalidAuth => "invalid_auth: Invalid authentication token.", -SetPurposeError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -SetPurposeError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -SetPurposeError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -SetPurposeError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -SetPurposeError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -SetPurposeError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -SetPurposeError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -SetPurposeError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -SetPurposeError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - SetPurposeError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - SetPurposeError::Unknown(ref s) => return write!(f, "{}", s), - SetPurposeError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for SetPurposeError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - SetPurposeError::MalformedResponse(_, ref e) => Some(e), - SetPurposeError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct SetTopicRequest<'a> { - /// Channel to set the topic of - pub channel: &'a str, - /// The new topic - pub topic: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct SetTopicResponse { - error: Option, - #[serde(default)] - ok: bool, - pub topic: Option, -} - -impl Into>> for SetTopicResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum SetTopicError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Authenticated user is not in the channel. - NotInChannel, - /// Channel has been archived. - IsArchived, - /// Topic was longer than 250 characters. - TooLong, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for SetTopicError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => SetTopicError::ChannelNotFound, - "not_in_channel" => SetTopicError::NotInChannel, - "is_archived" => SetTopicError::IsArchived, - "too_long" => SetTopicError::TooLong, - "user_is_restricted" => SetTopicError::UserIsRestricted, - "not_authed" => SetTopicError::NotAuthed, - "invalid_auth" => SetTopicError::InvalidAuth, - "account_inactive" => SetTopicError::AccountInactive, - "invalid_arg_name" => SetTopicError::InvalidArgName, - "invalid_array_arg" => SetTopicError::InvalidArrayArg, - "invalid_charset" => SetTopicError::InvalidCharset, - "invalid_form_data" => SetTopicError::InvalidFormData, - "invalid_post_type" => SetTopicError::InvalidPostType, - "missing_post_type" => SetTopicError::MissingPostType, - "team_added_to_org" => SetTopicError::TeamAddedToOrg, - "request_timeout" => SetTopicError::RequestTimeout, - _ => SetTopicError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for SetTopicError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - SetTopicError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -SetTopicError::NotInChannel => "not_in_channel: Authenticated user is not in the channel.", -SetTopicError::IsArchived => "is_archived: Channel has been archived.", -SetTopicError::TooLong => "too_long: Topic was longer than 250 characters.", -SetTopicError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -SetTopicError::NotAuthed => "not_authed: No authentication token provided.", -SetTopicError::InvalidAuth => "invalid_auth: Invalid authentication token.", -SetTopicError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -SetTopicError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -SetTopicError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -SetTopicError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -SetTopicError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -SetTopicError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -SetTopicError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -SetTopicError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -SetTopicError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - SetTopicError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - SetTopicError::Unknown(ref s) => return write!(f, "{}", s), - SetTopicError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for SetTopicError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - SetTopicError::MalformedResponse(_, ref e) => Some(e), - SetTopicError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct UnarchiveRequest<'a> { - /// Channel to unarchive - pub channel: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct UnarchiveResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for UnarchiveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum UnarchiveError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Channel is not archived. - NotArchived, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for UnarchiveError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => UnarchiveError::ChannelNotFound, - "not_archived" => UnarchiveError::NotArchived, - "not_authed" => UnarchiveError::NotAuthed, - "invalid_auth" => UnarchiveError::InvalidAuth, - "account_inactive" => UnarchiveError::AccountInactive, - "user_is_bot" => UnarchiveError::UserIsBot, - "user_is_restricted" => UnarchiveError::UserIsRestricted, - "invalid_arg_name" => UnarchiveError::InvalidArgName, - "invalid_array_arg" => UnarchiveError::InvalidArrayArg, - "invalid_charset" => UnarchiveError::InvalidCharset, - "invalid_form_data" => UnarchiveError::InvalidFormData, - "invalid_post_type" => UnarchiveError::InvalidPostType, - "missing_post_type" => UnarchiveError::MissingPostType, - "team_added_to_org" => UnarchiveError::TeamAddedToOrg, - "request_timeout" => UnarchiveError::RequestTimeout, - _ => UnarchiveError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for UnarchiveError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - UnarchiveError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -UnarchiveError::NotArchived => "not_archived: Channel is not archived.", -UnarchiveError::NotAuthed => "not_authed: No authentication token provided.", -UnarchiveError::InvalidAuth => "invalid_auth: Invalid authentication token.", -UnarchiveError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -UnarchiveError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -UnarchiveError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -UnarchiveError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -UnarchiveError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -UnarchiveError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -UnarchiveError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -UnarchiveError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -UnarchiveError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -UnarchiveError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -UnarchiveError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - UnarchiveError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - UnarchiveError::Unknown(ref s) => return write!(f, "{}", s), - UnarchiveError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for UnarchiveError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - UnarchiveError::MalformedResponse(_, ref e) => Some(e), - UnarchiveError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/chat/mod.rs b/src/mod_types/chat/mod.rs new file mode 100644 index 00000000..bf46984b --- /dev/null +++ b/src/mod_types/chat/mod.rs @@ -0,0 +1,562 @@ +pub mod scheduledMessages_types; + +pub struct PostMessageRequest { + /// Pass true to post the message as the authed user, instead of as a bot. Defaults to false. See [authorship](#authorship) below. + pub as_user: String, + /// A JSON-based array of structured attachments, presented as a URL-encoded string. + pub attachments: String, + /// A JSON-based array of structured blocks, presented as a URL-encoded string. + pub blocks: String, + /// Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See [below](#channels) for more details. + pub channel: Option, + /// Emoji to use as the icon for this message. Overrides `icon_url`. Must be used in conjunction with `as_user` set to `false`, otherwise ignored. See [authorship](#authorship) below. + pub icon_emoji: String, + /// URL to an image to use as the icon for this message. Must be used in conjunction with `as_user` set to false, otherwise ignored. See [authorship](#authorship) below. + pub icon_url: String, + /// Find and link channel names and usernames. + pub link_names: bool, + /// Disable Slack markup parsing by setting to `false`. Enabled by default. + pub mrkdwn: bool, + /// Change how messages are treated. Defaults to `none`. See [below](#formatting). + pub parse: String, + /// Used in conjunction with `thread_ts` and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to `false`. + pub reply_broadcast: bool, + /// How this field works and whether it is required depends on other fields you use in your API call. [See below](#text_usage) for more detail. + pub text: String, + /// Provide another message's `ts` value to make this message a reply. Avoid using a reply's `ts` value; use its parent instead. + pub thread_ts: String, + /// Pass true to enable unfurling of primarily text-based content. + pub unfurl_links: bool, + /// Pass false to disable unfurling of media content. + pub unfurl_media: bool, + /// Set your bot's user name. Must be used in conjunction with `as_user` set to false, otherwise ignored. See [authorship](#authorship) below. + pub username: String, +} + +pub struct PostMessageAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct PostMessageBlocksInner { + pub r#type: Option, +} + +pub struct PostMessageIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct PostMessageBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct PostMessageReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct PostMessageCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct PostMessageReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct PostMessageSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct PostMessageFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: PostMessageSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct PostMessageReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct PostMessageShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct PostMessageFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: PostMessageShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct PostMessageIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct PostMessageReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct PostMessageUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct PostMessageMessageInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: PostMessageBotProfileInner, + pub client_msg_id: String, + pub comment: PostMessageCommentInner, + pub display_as_bot: bool, + pub file: PostMessageFileInner, + pub files: Vec, + pub icons: PostMessageIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: PostMessageUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct PostMessageResponse { + pub callstack: String, + pub channel: Option, + pub error: String, + pub message: Option, + pub ok: Option, + pub ts: Option, +} + +pub struct PostMessageError {} + +pub struct DeleteScheduledMessageRequest { + /// Pass true to delete the message as the authed user with `chat:write:user` scope. [Bot users](/bot-users) in this context are considered authed users. If unused or false, the message will be deleted with `chat:write:bot` scope. + pub as_user: bool, + /// The channel the scheduled_message is posting to + pub channel: Option, + /// `scheduled_message_id` returned from call to chat.scheduleMessage + pub scheduled_message_id: Option, +} + +pub struct DeleteScheduledMessageResponse { + pub callstack: String, + pub error: String, + pub ok: Option, +} + +pub struct DeleteScheduledMessageError {} + +pub struct UpdateRequest { + /// Pass true to update the message as the authed user. [Bot users](/bot-users) in this context are considered authed users. + pub as_user: String, + /// A JSON-based array of structured attachments, presented as a URL-encoded string. This field is required when not presenting `text`. If you don't include this field, the message's previous `attachments` will be retained. To remove previous `attachments`, include an empty array for this field. + pub attachments: String, + /// A JSON-based array of [structured blocks](/block-kit/building), presented as a URL-encoded string. If you don't include this field, the message's previous `blocks` will be retained. To remove previous `blocks`, include an empty array for this field. + pub blocks: String, + /// Channel containing the message to be updated. + pub channel: Option, + /// Find and link channel names and usernames. Defaults to `none`. If you do not specify a value for this field, the original value set for the message will be overwritten with the default, `none`. + pub link_names: String, + /// Change how messages are treated. Defaults to `client`, unlike `chat.postMessage`. Accepts either `none` or `full`. If you do not specify a value for this field, the original value set for the message will be overwritten with the default, `client`. + pub parse: String, + /// New text for the message, using the [default formatting rules](/reference/surfaces/formatting). It's not required when presenting `blocks` or `attachments`. + pub text: String, + /// Timestamp of the message to be updated. + pub ts: Option, +} + +pub struct UpdateMessageInner { + pub attachments: Vec, + pub blocks: serde_json::Value, + pub text: Option, +} + +pub struct UpdateResponse { + pub callstack: String, + pub channel: Option, + pub error: String, + pub message: Option, + pub ok: Option, + pub text: Option, + pub ts: Option, +} + +pub struct UpdateError {} + +pub struct DeleteRequest { + /// Timestamp of the message to be deleted. + pub ts: u64, + /// Channel containing the message to be deleted. + pub channel: String, + /// Pass true to delete the message as the authed user with `chat:write:user` scope. [Bot users](/bot-users) in this context are considered authed users. If unused or false, the message will be deleted with `chat:write:bot` scope. + pub as_user: bool, +} + +pub struct DeleteResponse { + pub callstack: String, + pub channel: Option, + pub error: String, + pub ok: Option, + pub ts: Option, +} + +pub struct DeleteError {} + +pub struct PostEphemeralRequest { + /// Pass true to post the message as the authed user. Defaults to true if the chat:write:bot scope is not included. Otherwise, defaults to false. + pub as_user: bool, + /// A JSON-based array of structured attachments, presented as a URL-encoded string. + pub attachments: String, + /// A JSON-based array of structured blocks, presented as a URL-encoded string. + pub blocks: String, + /// Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. + pub channel: Option, + /// Emoji to use as the icon for this message. Overrides `icon_url`. Must be used in conjunction with `as_user` set to `false`, otherwise ignored. See [authorship](#authorship) below. + pub icon_emoji: String, + /// URL to an image to use as the icon for this message. Must be used in conjunction with `as_user` set to false, otherwise ignored. See [authorship](#authorship) below. + pub icon_url: String, + /// Find and link channel names and usernames. + pub link_names: bool, + /// Change how messages are treated. Defaults to `none`. See [below](#formatting). + pub parse: String, + /// How this field works and whether it is required depends on other fields you use in your API call. [See below](#text_usage) for more detail. + pub text: String, + /// Provide another message's `ts` value to post this message in a thread. Avoid using a reply's `ts` value; use its parent's value instead. Ephemeral messages in threads are only shown if there is already an active thread. + pub thread_ts: String, + /// `id` of the user who will receive the ephemeral message. The user should be in the channel specified by the `channel` argument. + pub user: Option, + /// Set your bot's user name. Must be used in conjunction with `as_user` set to false, otherwise ignored. See [authorship](#authorship) below. + pub username: String, +} + +pub struct PostEphemeralResponse { + pub callstack: String, + pub error: String, + pub message_ts: Option, + pub ok: Option, +} + +pub struct PostEphemeralError {} + +pub struct MeMessageRequest { + /// Channel to send message to. Can be a public channel, private group or IM channel. Can be an encoded ID, or a name. + pub channel: String, + /// Text of the message to send. + pub text: String, +} + +pub struct MeMessageResponse { + pub callstack: String, + pub channel: String, + pub error: String, + pub ok: Option, + pub ts: String, +} + +pub struct MeMessageError {} + +pub struct ScheduleMessageRequest { + /// Channel, private group, or DM channel to send message to. Can be an encoded ID, or a name. See [below](#channels) for more details. + pub channel: String, + /// How this field works and whether it is required depends on other fields you use in your API call. [See below](#text_usage) for more detail. + pub text: String, + /// Unix EPOCH timestamp of time in future to send the message. + pub post_at: String, + /// Change how messages are treated. Defaults to `none`. See [chat.postMessage](chat.postMessage#formatting). + pub parse: String, + /// Pass true to post the message as the authed user, instead of as a bot. Defaults to false. See [chat.postMessage](chat.postMessage#authorship). + pub as_user: bool, + /// Find and link channel names and usernames. + pub link_names: bool, + /// A JSON-based array of structured attachments, presented as a URL-encoded string. + pub attachments: String, + /// A JSON-based array of structured blocks, presented as a URL-encoded string. + pub blocks: String, + /// Pass true to enable unfurling of primarily text-based content. + pub unfurl_links: bool, + /// Pass false to disable unfurling of media content. + pub unfurl_media: bool, + /// Provide another message's `ts` value to make this message a reply. Avoid using a reply's `ts` value; use its parent instead. + pub thread_ts: u64, + /// Used in conjunction with `thread_ts` and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to `false`. + pub reply_broadcast: bool, +} + +pub struct ScheduleMessageIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct ScheduleMessageBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct ScheduleMessageMessageInner { + pub bot_id: Option, + pub bot_profile: ScheduleMessageBotProfileInner, + pub team: Option, + pub text: Option, + pub r#type: Option, + pub user: Option, + pub username: String, +} + +pub struct ScheduleMessageResponse { + pub callstack: String, + pub channel: Option, + pub error: String, + pub message: Option, + pub ok: Option, + pub post_at: Option, + pub scheduled_message_id: Option, +} + +pub struct ScheduleMessageError {} + +pub struct GetPermalinkRequest { + /// The ID of the conversation or channel containing the message + pub channel: Option, + /// A message's `ts` value, uniquely identifying it within a channel + pub message_ts: Option, +} + +pub struct GetPermalinkResponse { + pub callstack: String, + pub channel: Option, + pub error: String, + pub ok: Option, + pub permalink: Option, +} + +pub struct GetPermalinkError {} + +pub struct UnfurlRequest { + /// Channel ID of the message + pub channel: Option, + /// Timestamp of the message to add unfurl behavior to. + pub ts: Option, + /// URL-encoded JSON map with keys set to URLs featured in the the message, pointing to their unfurl blocks or message attachments. + pub unfurls: String, + /// Provide a simply-formatted string to send as an ephemeral message to the user as invitation to authenticate further and enable full unfurling behavior + pub user_auth_message: String, + /// Set to `true` or `1` to indicate the user must install your Slack app to trigger unfurls for this domain + pub user_auth_required: bool, + /// Send users to this custom URL where they will complete authentication in your app to fully trigger unfurling. Value should be properly URL-encoded. + pub user_auth_url: String, +} + +pub struct UnfurlResponse { + pub callstack: String, + pub error: String, + pub ok: Option, +} + +pub struct UnfurlError {} diff --git a/src/mod_types/chat/scheduledMessages_types.rs b/src/mod_types/chat/scheduledMessages_types.rs new file mode 100644 index 00000000..a1424a08 --- /dev/null +++ b/src/mod_types/chat/scheduledMessages_types.rs @@ -0,0 +1,34 @@ +pub struct ListRequest { + /// The channel of the scheduled messages + pub channel: String, + /// A UNIX timestamp of the latest value in the time range + pub latest: u64, + /// A UNIX timestamp of the oldest value in the time range + pub oldest: u64, + /// Maximum number of original entries to return. + pub limit: u64, + /// For pagination purposes, this is the `cursor` value returned from a previous call to `chat.scheduledmessages.list` indicating where you want to start this call from. + pub cursor: String, +} + +pub struct ListResponseMetadataInner { + pub next_cursor: Option, +} + +pub struct ListScheduledMessagesInner { + pub channel_id: Option, + pub date_created: Option, + pub id: Option, + pub post_at: Option, + pub text: String, +} + +pub struct ListResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub response_metadata: Option, + pub scheduled_messages: Option>, +} + +pub struct ListError {} diff --git a/src/mod_types/chat_types.rs b/src/mod_types/chat_types.rs deleted file mode 100644 index 3fa4a705..00000000 --- a/src/mod_types/chat_types.rs +++ /dev/null @@ -1,704 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -//! Post chat messages to Slack. - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct DeleteRequest<'a> { - /// Timestamp of the message to be deleted. - pub ts: crate::Timestamp, - /// Channel containing the message to be deleted. - pub channel: &'a str, - /// Pass true to delete the message as the authed user. Bot users in this context are considered authed users. - pub as_user: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct DeleteResponse { - pub channel: Option, - error: Option, - #[serde(default)] - ok: bool, - pub ts: Option, -} - -impl Into>> for DeleteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum DeleteError { - /// No message exists with the requested timestamp. - MessageNotFound, - /// Value passed for channel was invalid. - ChannelNotFound, - /// Authenticated user does not have permission to delete this message. - CantDeleteMessage, - /// Compliance exports are on, messages can not be deleted - ComplianceExportsPreventDeletion, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for DeleteError { - fn from(s: &'a str) -> Self { - match s { - "message_not_found" => DeleteError::MessageNotFound, - "channel_not_found" => DeleteError::ChannelNotFound, - "cant_delete_message" => DeleteError::CantDeleteMessage, - "compliance_exports_prevent_deletion" => DeleteError::ComplianceExportsPreventDeletion, - "not_authed" => DeleteError::NotAuthed, - "invalid_auth" => DeleteError::InvalidAuth, - "account_inactive" => DeleteError::AccountInactive, - "invalid_arg_name" => DeleteError::InvalidArgName, - "invalid_array_arg" => DeleteError::InvalidArrayArg, - "invalid_charset" => DeleteError::InvalidCharset, - "invalid_form_data" => DeleteError::InvalidFormData, - "invalid_post_type" => DeleteError::InvalidPostType, - "missing_post_type" => DeleteError::MissingPostType, - "team_added_to_org" => DeleteError::TeamAddedToOrg, - "request_timeout" => DeleteError::RequestTimeout, - _ => DeleteError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for DeleteError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - DeleteError::MessageNotFound => "message_not_found: No message exists with the requested timestamp.", -DeleteError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -DeleteError::CantDeleteMessage => "cant_delete_message: Authenticated user does not have permission to delete this message.", -DeleteError::ComplianceExportsPreventDeletion => "compliance_exports_prevent_deletion: Compliance exports are on, messages can not be deleted", -DeleteError::NotAuthed => "not_authed: No authentication token provided.", -DeleteError::InvalidAuth => "invalid_auth: Invalid authentication token.", -DeleteError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -DeleteError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -DeleteError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -DeleteError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -DeleteError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -DeleteError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -DeleteError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -DeleteError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -DeleteError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - DeleteError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - DeleteError::Unknown(ref s) => return write!(f, "{}", s), - DeleteError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for DeleteError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - DeleteError::MalformedResponse(_, ref e) => Some(e), - DeleteError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct MeMessageRequest<'a> { - /// Channel to send message to. Can be a public channel, private group or IM channel. Can be an encoded ID, or a name. - pub channel: &'a str, - /// Text of the message to send. - pub text: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct MeMessageResponse { - pub channel: Option, - error: Option, - #[serde(default)] - ok: bool, - pub ts: Option, -} - -impl Into>> for MeMessageResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum MeMessageError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Cannot post user messages to a channel they are not in. - NotInChannel, - /// Channel has been archived. - IsArchived, - /// Message text is too long - MsgTooLong, - /// No message text provided - NoText, - /// Application has posted too many messages, read the Rate Limit documentation for more information - RateLimited, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for MeMessageError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => MeMessageError::ChannelNotFound, - "not_in_channel" => MeMessageError::NotInChannel, - "is_archived" => MeMessageError::IsArchived, - "msg_too_long" => MeMessageError::MsgTooLong, - "no_text" => MeMessageError::NoText, - "rate_limited" => MeMessageError::RateLimited, - "not_authed" => MeMessageError::NotAuthed, - "invalid_auth" => MeMessageError::InvalidAuth, - "account_inactive" => MeMessageError::AccountInactive, - "invalid_arg_name" => MeMessageError::InvalidArgName, - "invalid_array_arg" => MeMessageError::InvalidArrayArg, - "invalid_charset" => MeMessageError::InvalidCharset, - "invalid_form_data" => MeMessageError::InvalidFormData, - "invalid_post_type" => MeMessageError::InvalidPostType, - "missing_post_type" => MeMessageError::MissingPostType, - "team_added_to_org" => MeMessageError::TeamAddedToOrg, - "request_timeout" => MeMessageError::RequestTimeout, - _ => MeMessageError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for MeMessageError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - MeMessageError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -MeMessageError::NotInChannel => "not_in_channel: Cannot post user messages to a channel they are not in.", -MeMessageError::IsArchived => "is_archived: Channel has been archived.", -MeMessageError::MsgTooLong => "msg_too_long: Message text is too long", -MeMessageError::NoText => "no_text: No message text provided", -MeMessageError::RateLimited => "rate_limited: Application has posted too many messages, read the Rate Limit documentation for more information", -MeMessageError::NotAuthed => "not_authed: No authentication token provided.", -MeMessageError::InvalidAuth => "invalid_auth: Invalid authentication token.", -MeMessageError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -MeMessageError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -MeMessageError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -MeMessageError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -MeMessageError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -MeMessageError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -MeMessageError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -MeMessageError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -MeMessageError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - MeMessageError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - MeMessageError::Unknown(ref s) => return write!(f, "{}", s), - MeMessageError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for MeMessageError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - MeMessageError::MalformedResponse(_, ref e) => Some(e), - MeMessageError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct PostMessageRequest<'a> { - /// Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See below for more details. - pub channel: &'a str, - /// Text of the message to send. See below for an explanation of formatting. This field is usually required, unless you're providing only attachments instead. - pub text: &'a str, - /// Change how messages are treated. Defaults to none. See below. - pub parse: Option<&'a str>, - /// Find and link channel names and usernames. - pub link_names: Option, - /// Structured message attachments. - pub attachments: Option<&'a str>, - /// Pass true to enable unfurling of primarily text-based content. - pub unfurl_links: Option, - /// Pass false to disable unfurling of media content. - pub unfurl_media: Option, - /// Set your bot's user name. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below. - pub username: Option<&'a str>, - /// Pass true to post the message as the authed user, instead of as a bot. Defaults to false. See authorship below. - pub as_user: Option, - /// URL to an image to use as the icon for this message. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below. - pub icon_url: Option<&'a str>, - /// Emoji to use as the icon for this message. Overrides icon_url. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below. - pub icon_emoji: Option<&'a str>, - /// Provide another message's ts value to make this message a reply. Avoid using a reply's ts value; use its parent instead. - pub thread_ts: Option, - /// Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to false. - pub reply_broadcast: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct PostMessageResponse { - pub channel: Option, - error: Option, - pub message: Option, - #[serde(default)] - ok: bool, - pub ts: Option, -} - -impl Into>> for PostMessageResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum PostMessageError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Cannot post user messages to a channel they are not in. - NotInChannel, - /// Channel has been archived. - IsArchived, - /// Message text is too long - MsgTooLong, - /// No message text provided - NoText, - /// Too many attachments were provided with this message. A maximum of 100 attachments are allowed on a message. - TooManyAttachments, - /// Application has posted too many messages, read the Rate Limit documentation for more information - RateLimited, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for PostMessageError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => PostMessageError::ChannelNotFound, - "not_in_channel" => PostMessageError::NotInChannel, - "is_archived" => PostMessageError::IsArchived, - "msg_too_long" => PostMessageError::MsgTooLong, - "no_text" => PostMessageError::NoText, - "too_many_attachments" => PostMessageError::TooManyAttachments, - "rate_limited" => PostMessageError::RateLimited, - "not_authed" => PostMessageError::NotAuthed, - "invalid_auth" => PostMessageError::InvalidAuth, - "account_inactive" => PostMessageError::AccountInactive, - "invalid_arg_name" => PostMessageError::InvalidArgName, - "invalid_array_arg" => PostMessageError::InvalidArrayArg, - "invalid_charset" => PostMessageError::InvalidCharset, - "invalid_form_data" => PostMessageError::InvalidFormData, - "invalid_post_type" => PostMessageError::InvalidPostType, - "missing_post_type" => PostMessageError::MissingPostType, - "team_added_to_org" => PostMessageError::TeamAddedToOrg, - "request_timeout" => PostMessageError::RequestTimeout, - _ => PostMessageError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for PostMessageError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - PostMessageError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -PostMessageError::NotInChannel => "not_in_channel: Cannot post user messages to a channel they are not in.", -PostMessageError::IsArchived => "is_archived: Channel has been archived.", -PostMessageError::MsgTooLong => "msg_too_long: Message text is too long", -PostMessageError::NoText => "no_text: No message text provided", -PostMessageError::TooManyAttachments => "too_many_attachments: Too many attachments were provided with this message. A maximum of 100 attachments are allowed on a message.", -PostMessageError::RateLimited => "rate_limited: Application has posted too many messages, read the Rate Limit documentation for more information", -PostMessageError::NotAuthed => "not_authed: No authentication token provided.", -PostMessageError::InvalidAuth => "invalid_auth: Invalid authentication token.", -PostMessageError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -PostMessageError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -PostMessageError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -PostMessageError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -PostMessageError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -PostMessageError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -PostMessageError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -PostMessageError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -PostMessageError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - PostMessageError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - PostMessageError::Unknown(ref s) => return write!(f, "{}", s), - PostMessageError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for PostMessageError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - PostMessageError::MalformedResponse(_, ref e) => Some(e), - PostMessageError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct UnfurlRequest<'a> { - /// Channel ID of the message - pub channel: &'a str, - /// Timestamp of the message to add unfurl behavior to - pub ts: &'a str, - /// JSON mapping a set of URLs from the message to their unfurl attachments - pub unfurls: &'a str, - /// Set to true or 1 to indicate the user must install your Slack app to trigger unfurls for this domain - pub user_auth_required: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct UnfurlResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for UnfurlResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum UnfurlError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for UnfurlError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => UnfurlError::NotAuthed, - "invalid_auth" => UnfurlError::InvalidAuth, - "account_inactive" => UnfurlError::AccountInactive, - "user_is_bot" => UnfurlError::UserIsBot, - "invalid_arg_name" => UnfurlError::InvalidArgName, - "invalid_array_arg" => UnfurlError::InvalidArrayArg, - "invalid_charset" => UnfurlError::InvalidCharset, - "invalid_form_data" => UnfurlError::InvalidFormData, - "invalid_post_type" => UnfurlError::InvalidPostType, - "missing_post_type" => UnfurlError::MissingPostType, - "team_added_to_org" => UnfurlError::TeamAddedToOrg, - "request_timeout" => UnfurlError::RequestTimeout, - _ => UnfurlError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for UnfurlError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - UnfurlError::NotAuthed => "not_authed: No authentication token provided.", -UnfurlError::InvalidAuth => "invalid_auth: Invalid authentication token.", -UnfurlError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -UnfurlError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -UnfurlError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -UnfurlError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -UnfurlError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -UnfurlError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -UnfurlError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -UnfurlError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -UnfurlError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -UnfurlError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - UnfurlError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - UnfurlError::Unknown(ref s) => return write!(f, "{}", s), - UnfurlError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for UnfurlError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - UnfurlError::MalformedResponse(_, ref e) => Some(e), - UnfurlError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct UpdateRequest<'a> { - /// Timestamp of the message to be updated. - pub ts: crate::Timestamp, - /// Channel containing the message to be updated. - pub channel: &'a str, - /// New text for the message, using the default formatting rules. - pub text: &'a str, - /// Structured message attachments. - pub attachments: Option<&'a str>, - /// Change how messages are treated. Defaults to client, unlike chat.postMessage. See below. - pub parse: Option<&'a str>, - /// Find and link channel names and usernames. Defaults to none. This parameter should be used in conjunction with parse. To set link_names to 1, specify a parse mode of full. - pub link_names: Option, - /// Pass true to update the message as the authed user. Bot users in this context are considered authed users. - pub as_user: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct UpdateResponse { - pub channel: Option, - error: Option, - #[serde(default)] - ok: bool, - pub text: Option, - pub ts: Option, -} - -impl Into>> for UpdateResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum UpdateError { - /// No message exists with the requested timestamp. - MessageNotFound, - /// Authenticated user does not have permission to update this message. - CantUpdateMessage, - /// Value passed for channel was invalid. - ChannelNotFound, - /// The message cannot be edited due to the team message edit settings - EditWindowClosed, - /// Message text is too long - MsgTooLong, - /// Too many attachments were provided with this message. A maximum of 100 attachments are allowed on a message. - TooManyAttachments, - /// No message text provided - NoText, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for UpdateError { - fn from(s: &'a str) -> Self { - match s { - "message_not_found" => UpdateError::MessageNotFound, - "cant_update_message" => UpdateError::CantUpdateMessage, - "channel_not_found" => UpdateError::ChannelNotFound, - "edit_window_closed" => UpdateError::EditWindowClosed, - "msg_too_long" => UpdateError::MsgTooLong, - "too_many_attachments" => UpdateError::TooManyAttachments, - "no_text" => UpdateError::NoText, - "not_authed" => UpdateError::NotAuthed, - "invalid_auth" => UpdateError::InvalidAuth, - "account_inactive" => UpdateError::AccountInactive, - "invalid_arg_name" => UpdateError::InvalidArgName, - "invalid_array_arg" => UpdateError::InvalidArrayArg, - "invalid_charset" => UpdateError::InvalidCharset, - "invalid_form_data" => UpdateError::InvalidFormData, - "invalid_post_type" => UpdateError::InvalidPostType, - "missing_post_type" => UpdateError::MissingPostType, - "team_added_to_org" => UpdateError::TeamAddedToOrg, - "request_timeout" => UpdateError::RequestTimeout, - _ => UpdateError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for UpdateError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - UpdateError::MessageNotFound => "message_not_found: No message exists with the requested timestamp.", -UpdateError::CantUpdateMessage => "cant_update_message: Authenticated user does not have permission to update this message.", -UpdateError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -UpdateError::EditWindowClosed => "edit_window_closed: The message cannot be edited due to the team message edit settings", -UpdateError::MsgTooLong => "msg_too_long: Message text is too long", -UpdateError::TooManyAttachments => "too_many_attachments: Too many attachments were provided with this message. A maximum of 100 attachments are allowed on a message.", -UpdateError::NoText => "no_text: No message text provided", -UpdateError::NotAuthed => "not_authed: No authentication token provided.", -UpdateError::InvalidAuth => "invalid_auth: Invalid authentication token.", -UpdateError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -UpdateError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -UpdateError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -UpdateError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -UpdateError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -UpdateError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -UpdateError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -UpdateError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -UpdateError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - UpdateError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - UpdateError::Unknown(ref s) => return write!(f, "{}", s), - UpdateError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for UpdateError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - UpdateError::MalformedResponse(_, ref e) => Some(e), - UpdateError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/conversations_types.rs b/src/mod_types/conversations_types.rs new file mode 100644 index 00000000..0992a4f1 --- /dev/null +++ b/src/mod_types/conversations_types.rs @@ -0,0 +1,4572 @@ +pub struct ListRequest { + /// Set to `true` to exclude archived channels from the list + pub exclude_archived: bool, + /// Mix and match channel types by providing a comma-separated list of any combination of `public_channel`, `private_channel`, `mpim`, `im` + pub types: String, + /// The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. Must be an integer no larger than 1000. + pub limit: u64, + /// Paginate through collections of data by setting the `cursor` parameter to a `next_cursor` attribute returned by a previous request's `response_metadata`. Default value fetches the first "page" of the collection. See [pagination](/docs/pagination) for more detail. + pub cursor: String, +} + +pub struct ListDisplayCountsInner { + pub display_counts: Option, + pub guest_counts: Option, +} + +pub struct ListAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct ListBlocksInner { + pub r#type: Option, +} + +pub struct ListIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct ListBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct ListReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ListCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct ListReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ListSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct ListFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: ListSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct ListReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ListShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct ListFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: ListShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct ListIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct ListReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ListUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct ListLatestInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: ListBotProfileInner, + pub client_msg_id: String, + pub comment: ListCommentInner, + pub display_as_bot: bool, + pub file: ListFileInner, + pub files: Vec, + pub icons: ListIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: ListUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct ListPurposeInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct ListCurrentInner { + pub date_started: Option, + pub team_id: Option, +} + +pub struct ListExternalOrgMigrationsInner { + pub current: Option>, + pub date_updated: Option, +} + +pub struct ListIconInner { + pub image_102: String, + pub image_132: String, + pub image_230: String, + pub image_34: String, + pub image_44: String, + pub image_68: String, + pub image_88: String, + pub image_default: bool, +} + +pub struct ListPrimaryOwnerInner { + pub email: Option, + pub id: Option, +} + +pub struct ListSsoProviderInner { + pub label: String, + pub name: String, + pub r#type: String, +} + +pub struct ListTeamInner { + pub archived: bool, + pub avatar_base_url: String, + pub created: u64, + pub date_create: u64, + pub deleted: bool, + pub description: String, + pub discoverable: Vec, + pub domain: Option, + pub email_domain: Option, + pub enterprise_id: String, + pub enterprise_name: String, + pub external_org_migrations: ListExternalOrgMigrationsInner, + pub has_compliance_export: bool, + pub icon: Option, + pub id: Option, + pub is_assigned: bool, + pub is_enterprise: u64, + pub is_over_storage_limit: bool, + pub limit_ts: u64, + pub locale: String, + pub messages_count: u64, + pub msg_edit_window_mins: u64, + pub name: Option, + pub over_integrations_limit: bool, + pub over_storage_limit: bool, + pub pay_prod_cur: String, + pub plan: String, + pub primary_owner: ListPrimaryOwnerInner, + pub sso_provider: ListSsoProviderInner, +} + +pub struct ListShares2Inner { + pub accepted_user: String, + pub is_active: Option, + pub team: Option, + pub user: Option, +} + +pub struct ListTopicInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct ListChannelsInner { + pub accepted_user: String, + pub connected_team_ids: Vec, + pub conversation_host_id: String, + pub created: Option, + pub creator: Option, + pub display_counts: ListDisplayCountsInner, + pub enterprise_id: String, + pub has_pins: bool, + pub id: Option, + pub internal_team_ids: Vec, + pub is_archived: Option, + pub is_channel: Option, + pub is_ext_shared: bool, + pub is_frozen: bool, + pub is_general: Option, + pub is_global_shared: bool, + pub is_group: Option, + pub is_im: Option, + pub is_member: bool, + pub is_moved: u64, + pub is_mpim: Option, + pub is_non_threadable: bool, + pub is_open: bool, + pub is_org_default: bool, + pub is_org_mandatory: bool, + pub is_org_shared: Option, + pub is_pending_ext_shared: bool, + pub is_private: Option, + pub is_read_only: bool, + pub is_shared: Option, + pub is_starred: bool, + pub is_thread_only: bool, + pub last_read: String, + pub latest: Vec, + pub members: Vec, + pub name: Option, + pub name_normalized: Option, + pub num_members: u64, + pub parent_conversation: Vec, + pub pending_connected_team_ids: Vec, + pub pending_shared: Vec, + pub pin_count: u64, + pub previous_names: Vec, + pub priority: u64, + pub purpose: Option, + pub shared_team_ids: Vec, + pub shares: Vec, + pub timezone_count: u64, + pub topic: Option, + pub unlinked: u64, + pub unread_count: u64, + pub unread_count_display: u64, + pub use_case: String, + pub user: String, + pub version: u64, +} + +pub struct ListResponseMetadataInner { + pub next_cursor: Option, +} + +pub struct ListResponse { + pub callstack: String, + pub channels: Option>>, + pub error: String, + pub needed: String, + pub ok: Option, + pub provided: String, + pub response_metadata: ListResponseMetadataInner, +} + +pub struct ListError {} + +pub struct HistoryRequest { + /// Conversation ID to fetch history for. + pub channel: String, + /// End of time range of messages to include in results. + pub latest: u64, + /// Start of time range of messages to include in results. + pub oldest: u64, + /// Include messages with latest or oldest timestamp in results only when either timestamp is specified. + pub inclusive: bool, + /// The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached. + pub limit: u64, + /// Paginate through collections of data by setting the `cursor` parameter to a `next_cursor` attribute returned by a previous request's `response_metadata`. Default value fetches the first "page" of the collection. See [pagination](/docs/pagination) for more detail. + pub cursor: String, +} + +pub struct HistoryAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct HistoryBlocksInner { + pub r#type: Option, +} + +pub struct HistoryIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct HistoryBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct HistoryReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct HistoryCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct HistoryReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct HistorySharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct HistoryFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: HistorySharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct HistoryReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct HistoryShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct HistoryFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: HistoryShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct HistoryIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct HistoryReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct HistoryUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct HistoryMessagesInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: HistoryBotProfileInner, + pub client_msg_id: String, + pub comment: HistoryCommentInner, + pub display_as_bot: bool, + pub file: HistoryFileInner, + pub files: Vec, + pub icons: HistoryIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: HistoryUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct HistoryResponse { + pub callstack: String, + pub channel_actions_count: Option, + pub channel_actions_ts: Option>, + pub error: String, + pub has_more: Option, + pub messages: Option>, + pub needed: String, + pub ok: Option, + pub pin_count: Option, + pub provided: String, +} + +pub struct HistoryError {} + +pub struct CloseRequest { + /// Conversation to close. + pub channel: String, +} + +pub struct CloseResponse { + pub already_closed: bool, + pub callstack: String, + pub error: String, + pub needed: String, + pub no_op: bool, + pub ok: Option, + pub provided: String, +} + +pub struct CloseError {} + +pub struct RepliesRequest { + /// Conversation ID to fetch thread from. + pub channel: String, + /// Unique identifier of a thread's parent message. `ts` must be the timestamp of an existing message with 0 or more replies. If there are no replies then just the single message referenced by `ts` will return - it is just an ordinary, unthreaded message. + pub ts: u64, + /// End of time range of messages to include in results. + pub latest: u64, + /// Start of time range of messages to include in results. + pub oldest: u64, + /// Include messages with latest or oldest timestamp in results only when either timestamp is specified. + pub inclusive: bool, + /// The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached. + pub limit: u64, + /// Paginate through collections of data by setting the `cursor` parameter to a `next_cursor` attribute returned by a previous request's `response_metadata`. Default value fetches the first "page" of the collection. See [pagination](/docs/pagination) for more detail. + pub cursor: String, +} + +pub struct RepliesUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct RepliesMessagesInner { + pub last_read: String, + pub latest_reply: String, + pub reply_count: Option, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: Option, + pub team: String, + pub text: Option, + pub thread_ts: Option, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub user: Option, + pub user_profile: RepliesUserProfileInner, + pub user_team: String, +} + +pub struct RepliesResponse { + pub callstack: String, + pub error: String, + pub has_more: bool, + pub messages: Option>>, + pub needed: String, + pub ok: Option, + pub provided: String, +} + +pub struct RepliesError {} + +pub struct MarkRequest { + /// Channel or conversation to set the read cursor for. + pub channel: String, + /// Unique identifier of message you want marked as most recently seen in this conversation. + pub ts: u64, +} + +pub struct MarkResponse { + pub callstack: String, + pub error: String, + pub needed: String, + pub ok: Option, + pub provided: String, +} + +pub struct MarkError {} + +pub struct OpenRequest { + /// Resume a conversation by supplying an `im` or `mpim`'s ID. Or provide the `users` field instead. + pub channel: String, + /// Comma separated lists of users. If only one user is included, this creates a 1:1 DM. The ordering of the users is preserved whenever a multi-person direct message is returned. Supply a `channel` when not supplying `users`. + pub users: String, + /// Boolean, indicates you want the full IM channel definition in the response. + pub return_im: bool, +} + +pub struct OpenDisplayCountsInner { + pub display_counts: Option, + pub guest_counts: Option, +} + +pub struct OpenAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct OpenBlocksInner { + pub r#type: Option, +} + +pub struct OpenIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct OpenBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct OpenReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct OpenCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct OpenReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct OpenSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct OpenFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: OpenSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct OpenReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct OpenShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct OpenFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: OpenShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct OpenIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct OpenReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct OpenUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct OpenLatestInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: OpenBotProfileInner, + pub client_msg_id: String, + pub comment: OpenCommentInner, + pub display_as_bot: bool, + pub file: OpenFileInner, + pub files: Vec, + pub icons: OpenIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: OpenUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct OpenPurposeInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct OpenCurrentInner { + pub date_started: Option, + pub team_id: Option, +} + +pub struct OpenExternalOrgMigrationsInner { + pub current: Option>, + pub date_updated: Option, +} + +pub struct OpenIconInner { + pub image_102: String, + pub image_132: String, + pub image_230: String, + pub image_34: String, + pub image_44: String, + pub image_68: String, + pub image_88: String, + pub image_default: bool, +} + +pub struct OpenPrimaryOwnerInner { + pub email: Option, + pub id: Option, +} + +pub struct OpenSsoProviderInner { + pub label: String, + pub name: String, + pub r#type: String, +} + +pub struct OpenTeamInner { + pub archived: bool, + pub avatar_base_url: String, + pub created: u64, + pub date_create: u64, + pub deleted: bool, + pub description: String, + pub discoverable: Vec, + pub domain: Option, + pub email_domain: Option, + pub enterprise_id: String, + pub enterprise_name: String, + pub external_org_migrations: OpenExternalOrgMigrationsInner, + pub has_compliance_export: bool, + pub icon: Option, + pub id: Option, + pub is_assigned: bool, + pub is_enterprise: u64, + pub is_over_storage_limit: bool, + pub limit_ts: u64, + pub locale: String, + pub messages_count: u64, + pub msg_edit_window_mins: u64, + pub name: Option, + pub over_integrations_limit: bool, + pub over_storage_limit: bool, + pub pay_prod_cur: String, + pub plan: String, + pub primary_owner: OpenPrimaryOwnerInner, + pub sso_provider: OpenSsoProviderInner, +} + +pub struct OpenShares2Inner { + pub accepted_user: String, + pub is_active: Option, + pub team: Option, + pub user: Option, +} + +pub struct OpenTopicInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct OpenChannelInner { + pub accepted_user: String, + pub connected_team_ids: Vec, + pub conversation_host_id: String, + pub created: Option, + pub creator: Option, + pub display_counts: OpenDisplayCountsInner, + pub enterprise_id: String, + pub has_pins: bool, + pub id: Option, + pub internal_team_ids: Vec, + pub is_archived: Option, + pub is_channel: Option, + pub is_ext_shared: bool, + pub is_frozen: bool, + pub is_general: Option, + pub is_global_shared: bool, + pub is_group: Option, + pub is_im: Option, + pub is_member: bool, + pub is_moved: u64, + pub is_mpim: Option, + pub is_non_threadable: bool, + pub is_open: bool, + pub is_org_default: bool, + pub is_org_mandatory: bool, + pub is_org_shared: Option, + pub is_pending_ext_shared: bool, + pub is_private: Option, + pub is_read_only: bool, + pub is_shared: Option, + pub is_starred: bool, + pub is_thread_only: bool, + pub last_read: String, + pub latest: Vec, + pub members: Vec, + pub name: Option, + pub name_normalized: Option, + pub num_members: u64, + pub parent_conversation: Vec, + pub pending_connected_team_ids: Vec, + pub pending_shared: Vec, + pub pin_count: u64, + pub previous_names: Vec, + pub priority: u64, + pub purpose: Option, + pub shared_team_ids: Vec, + pub shares: Vec, + pub timezone_count: u64, + pub topic: Option, + pub unlinked: u64, + pub unread_count: u64, + pub unread_count_display: u64, + pub use_case: String, + pub user: String, + pub version: u64, +} + +pub struct OpenResponse { + pub already_open: bool, + pub callstack: String, + pub channel: Option>>, + pub error: String, + pub no_op: bool, + pub ok: Option, +} + +pub struct OpenError {} + +pub struct InviteRequest { + /// The ID of the public or private channel to invite user(s) to. + pub channel: String, + /// A comma separated list of user IDs. Up to 1000 users may be listed. + pub users: String, +} + +pub struct InviteDisplayCountsInner { + pub display_counts: Option, + pub guest_counts: Option, +} + +pub struct InviteAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct InviteBlocksInner { + pub r#type: Option, +} + +pub struct InviteIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct InviteBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct InviteReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct InviteCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct InviteReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct InviteSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct InviteFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: InviteSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct InviteReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct InviteShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct InviteFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: InviteShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct InviteIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct InviteReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct InviteUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct InviteLatestInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: InviteBotProfileInner, + pub client_msg_id: String, + pub comment: InviteCommentInner, + pub display_as_bot: bool, + pub file: InviteFileInner, + pub files: Vec, + pub icons: InviteIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: InviteUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct InvitePurposeInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct InviteCurrentInner { + pub date_started: Option, + pub team_id: Option, +} + +pub struct InviteExternalOrgMigrationsInner { + pub current: Option>, + pub date_updated: Option, +} + +pub struct InviteIconInner { + pub image_102: String, + pub image_132: String, + pub image_230: String, + pub image_34: String, + pub image_44: String, + pub image_68: String, + pub image_88: String, + pub image_default: bool, +} + +pub struct InvitePrimaryOwnerInner { + pub email: Option, + pub id: Option, +} + +pub struct InviteSsoProviderInner { + pub label: String, + pub name: String, + pub r#type: String, +} + +pub struct InviteTeamInner { + pub archived: bool, + pub avatar_base_url: String, + pub created: u64, + pub date_create: u64, + pub deleted: bool, + pub description: String, + pub discoverable: Vec, + pub domain: Option, + pub email_domain: Option, + pub enterprise_id: String, + pub enterprise_name: String, + pub external_org_migrations: InviteExternalOrgMigrationsInner, + pub has_compliance_export: bool, + pub icon: Option, + pub id: Option, + pub is_assigned: bool, + pub is_enterprise: u64, + pub is_over_storage_limit: bool, + pub limit_ts: u64, + pub locale: String, + pub messages_count: u64, + pub msg_edit_window_mins: u64, + pub name: Option, + pub over_integrations_limit: bool, + pub over_storage_limit: bool, + pub pay_prod_cur: String, + pub plan: String, + pub primary_owner: InvitePrimaryOwnerInner, + pub sso_provider: InviteSsoProviderInner, +} + +pub struct InviteShares2Inner { + pub accepted_user: String, + pub is_active: Option, + pub team: Option, + pub user: Option, +} + +pub struct InviteTopicInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct InviteChannelInner { + pub accepted_user: String, + pub connected_team_ids: Vec, + pub conversation_host_id: String, + pub created: Option, + pub creator: Option, + pub display_counts: InviteDisplayCountsInner, + pub enterprise_id: String, + pub has_pins: bool, + pub id: Option, + pub internal_team_ids: Vec, + pub is_archived: Option, + pub is_channel: Option, + pub is_ext_shared: bool, + pub is_frozen: bool, + pub is_general: Option, + pub is_global_shared: bool, + pub is_group: Option, + pub is_im: Option, + pub is_member: bool, + pub is_moved: u64, + pub is_mpim: Option, + pub is_non_threadable: bool, + pub is_open: bool, + pub is_org_default: bool, + pub is_org_mandatory: bool, + pub is_org_shared: Option, + pub is_pending_ext_shared: bool, + pub is_private: Option, + pub is_read_only: bool, + pub is_shared: Option, + pub is_starred: bool, + pub is_thread_only: bool, + pub last_read: String, + pub latest: Vec, + pub members: Vec, + pub name: Option, + pub name_normalized: Option, + pub num_members: u64, + pub parent_conversation: Vec, + pub pending_connected_team_ids: Vec, + pub pending_shared: Vec, + pub pin_count: u64, + pub previous_names: Vec, + pub priority: u64, + pub purpose: Option, + pub shared_team_ids: Vec, + pub shares: Vec, + pub timezone_count: u64, + pub topic: Option, + pub unlinked: u64, + pub unread_count: u64, + pub unread_count_display: u64, + pub use_case: String, + pub user: String, + pub version: u64, +} + +pub struct InviteErrorsInner { + pub error: Option, + pub ok: Option, + pub user: String, +} + +pub struct InviteResponse { + pub callstack: String, + pub channel: Option>, + pub error: String, + pub errors: Vec, + pub needed: String, + pub ok: Option, + pub provided: String, +} + +pub struct InviteError {} + +pub struct MembersRequest { + /// ID of the conversation to retrieve members for + pub channel: String, + /// The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached. + pub limit: u64, + /// Paginate through collections of data by setting the `cursor` parameter to a `next_cursor` attribute returned by a previous request's `response_metadata`. Default value fetches the first "page" of the collection. See [pagination](/docs/pagination) for more detail. + pub cursor: String, +} + +pub struct MembersResponseMetadataInner { + pub next_cursor: Option, +} + +pub struct MembersResponse { + pub callstack: String, + pub error: String, + pub members: Option>, + pub ok: Option, + pub response_metadata: Option, +} + +pub struct MembersError {} + +pub struct ArchiveRequest { + /// ID of conversation to archive + pub channel: String, +} + +pub struct ArchiveResponse { + pub callstack: String, + pub error: String, + pub needed: String, + pub ok: Option, + pub provided: String, +} + +pub struct ArchiveError {} + +pub struct SetPurposeRequest { + /// Conversation to set the purpose of + pub channel: String, + /// A new, specialer purpose + pub purpose: String, +} + +pub struct SetPurposeDisplayCountsInner { + pub display_counts: Option, + pub guest_counts: Option, +} + +pub struct SetPurposeAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct SetPurposeBlocksInner { + pub r#type: Option, +} + +pub struct SetPurposeIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct SetPurposeBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct SetPurposeReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct SetPurposeCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct SetPurposeReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct SetPurposeSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct SetPurposeFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: SetPurposeSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct SetPurposeReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct SetPurposeShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct SetPurposeFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: SetPurposeShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct SetPurposeIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct SetPurposeReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct SetPurposeUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct SetPurposeLatestInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: SetPurposeBotProfileInner, + pub client_msg_id: String, + pub comment: SetPurposeCommentInner, + pub display_as_bot: bool, + pub file: SetPurposeFileInner, + pub files: Vec, + pub icons: SetPurposeIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: SetPurposeUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct SetPurposePurposeInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct SetPurposeCurrentInner { + pub date_started: Option, + pub team_id: Option, +} + +pub struct SetPurposeExternalOrgMigrationsInner { + pub current: Option>, + pub date_updated: Option, +} + +pub struct SetPurposeIconInner { + pub image_102: String, + pub image_132: String, + pub image_230: String, + pub image_34: String, + pub image_44: String, + pub image_68: String, + pub image_88: String, + pub image_default: bool, +} + +pub struct SetPurposePrimaryOwnerInner { + pub email: Option, + pub id: Option, +} + +pub struct SetPurposeSsoProviderInner { + pub label: String, + pub name: String, + pub r#type: String, +} + +pub struct SetPurposeTeamInner { + pub archived: bool, + pub avatar_base_url: String, + pub created: u64, + pub date_create: u64, + pub deleted: bool, + pub description: String, + pub discoverable: Vec, + pub domain: Option, + pub email_domain: Option, + pub enterprise_id: String, + pub enterprise_name: String, + pub external_org_migrations: SetPurposeExternalOrgMigrationsInner, + pub has_compliance_export: bool, + pub icon: Option, + pub id: Option, + pub is_assigned: bool, + pub is_enterprise: u64, + pub is_over_storage_limit: bool, + pub limit_ts: u64, + pub locale: String, + pub messages_count: u64, + pub msg_edit_window_mins: u64, + pub name: Option, + pub over_integrations_limit: bool, + pub over_storage_limit: bool, + pub pay_prod_cur: String, + pub plan: String, + pub primary_owner: SetPurposePrimaryOwnerInner, + pub sso_provider: SetPurposeSsoProviderInner, +} + +pub struct SetPurposeShares2Inner { + pub accepted_user: String, + pub is_active: Option, + pub team: Option, + pub user: Option, +} + +pub struct SetPurposeTopicInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct SetPurposeChannelInner { + pub accepted_user: String, + pub connected_team_ids: Vec, + pub conversation_host_id: String, + pub created: Option, + pub creator: Option, + pub display_counts: SetPurposeDisplayCountsInner, + pub enterprise_id: String, + pub has_pins: bool, + pub id: Option, + pub internal_team_ids: Vec, + pub is_archived: Option, + pub is_channel: Option, + pub is_ext_shared: bool, + pub is_frozen: bool, + pub is_general: Option, + pub is_global_shared: bool, + pub is_group: Option, + pub is_im: Option, + pub is_member: bool, + pub is_moved: u64, + pub is_mpim: Option, + pub is_non_threadable: bool, + pub is_open: bool, + pub is_org_default: bool, + pub is_org_mandatory: bool, + pub is_org_shared: Option, + pub is_pending_ext_shared: bool, + pub is_private: Option, + pub is_read_only: bool, + pub is_shared: Option, + pub is_starred: bool, + pub is_thread_only: bool, + pub last_read: String, + pub latest: Vec, + pub members: Vec, + pub name: Option, + pub name_normalized: Option, + pub num_members: u64, + pub parent_conversation: Vec, + pub pending_connected_team_ids: Vec, + pub pending_shared: Vec, + pub pin_count: u64, + pub previous_names: Vec, + pub priority: u64, + pub purpose: Option, + pub shared_team_ids: Vec, + pub shares: Vec, + pub timezone_count: u64, + pub topic: Option, + pub unlinked: u64, + pub unread_count: u64, + pub unread_count_display: u64, + pub use_case: String, + pub user: String, + pub version: u64, +} + +pub struct SetPurposeResponse { + pub callstack: String, + pub channel: Option>, + pub error: String, + pub needed: String, + pub ok: Option, + pub provided: String, +} + +pub struct SetPurposeError {} + +pub struct UnarchiveRequest { + /// ID of conversation to unarchive + pub channel: String, +} + +pub struct UnarchiveResponse { + pub callstack: String, + pub error: String, + pub needed: String, + pub ok: Option, + pub provided: String, +} + +pub struct UnarchiveError {} + +pub struct LeaveRequest { + /// Conversation to leave + pub channel: String, +} + +pub struct LeaveResponse { + pub callstack: String, + pub error: String, + pub needed: String, + pub not_in_channel: bool, + pub ok: Option, + pub provided: String, +} + +pub struct LeaveError {} + +pub struct RenameRequest { + /// ID of conversation to rename + pub channel: String, + /// New name for conversation. + pub name: String, +} + +pub struct RenameDisplayCountsInner { + pub display_counts: Option, + pub guest_counts: Option, +} + +pub struct RenameAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct RenameBlocksInner { + pub r#type: Option, +} + +pub struct RenameIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct RenameBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct RenameReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct RenameCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct RenameReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct RenameSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct RenameFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: RenameSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct RenameReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct RenameShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct RenameFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: RenameShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct RenameIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct RenameReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct RenameUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct RenameLatestInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: RenameBotProfileInner, + pub client_msg_id: String, + pub comment: RenameCommentInner, + pub display_as_bot: bool, + pub file: RenameFileInner, + pub files: Vec, + pub icons: RenameIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: RenameUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct RenamePurposeInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct RenameCurrentInner { + pub date_started: Option, + pub team_id: Option, +} + +pub struct RenameExternalOrgMigrationsInner { + pub current: Option>, + pub date_updated: Option, +} + +pub struct RenameIconInner { + pub image_102: String, + pub image_132: String, + pub image_230: String, + pub image_34: String, + pub image_44: String, + pub image_68: String, + pub image_88: String, + pub image_default: bool, +} + +pub struct RenamePrimaryOwnerInner { + pub email: Option, + pub id: Option, +} + +pub struct RenameSsoProviderInner { + pub label: String, + pub name: String, + pub r#type: String, +} + +pub struct RenameTeamInner { + pub archived: bool, + pub avatar_base_url: String, + pub created: u64, + pub date_create: u64, + pub deleted: bool, + pub description: String, + pub discoverable: Vec, + pub domain: Option, + pub email_domain: Option, + pub enterprise_id: String, + pub enterprise_name: String, + pub external_org_migrations: RenameExternalOrgMigrationsInner, + pub has_compliance_export: bool, + pub icon: Option, + pub id: Option, + pub is_assigned: bool, + pub is_enterprise: u64, + pub is_over_storage_limit: bool, + pub limit_ts: u64, + pub locale: String, + pub messages_count: u64, + pub msg_edit_window_mins: u64, + pub name: Option, + pub over_integrations_limit: bool, + pub over_storage_limit: bool, + pub pay_prod_cur: String, + pub plan: String, + pub primary_owner: RenamePrimaryOwnerInner, + pub sso_provider: RenameSsoProviderInner, +} + +pub struct RenameShares2Inner { + pub accepted_user: String, + pub is_active: Option, + pub team: Option, + pub user: Option, +} + +pub struct RenameTopicInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct RenameChannelInner { + pub accepted_user: String, + pub connected_team_ids: Vec, + pub conversation_host_id: String, + pub created: Option, + pub creator: Option, + pub display_counts: RenameDisplayCountsInner, + pub enterprise_id: String, + pub has_pins: bool, + pub id: Option, + pub internal_team_ids: Vec, + pub is_archived: Option, + pub is_channel: Option, + pub is_ext_shared: bool, + pub is_frozen: bool, + pub is_general: Option, + pub is_global_shared: bool, + pub is_group: Option, + pub is_im: Option, + pub is_member: bool, + pub is_moved: u64, + pub is_mpim: Option, + pub is_non_threadable: bool, + pub is_open: bool, + pub is_org_default: bool, + pub is_org_mandatory: bool, + pub is_org_shared: Option, + pub is_pending_ext_shared: bool, + pub is_private: Option, + pub is_read_only: bool, + pub is_shared: Option, + pub is_starred: bool, + pub is_thread_only: bool, + pub last_read: String, + pub latest: Vec, + pub members: Vec, + pub name: Option, + pub name_normalized: Option, + pub num_members: u64, + pub parent_conversation: Vec, + pub pending_connected_team_ids: Vec, + pub pending_shared: Vec, + pub pin_count: u64, + pub previous_names: Vec, + pub priority: u64, + pub purpose: Option, + pub shared_team_ids: Vec, + pub shares: Vec, + pub timezone_count: u64, + pub topic: Option, + pub unlinked: u64, + pub unread_count: u64, + pub unread_count_display: u64, + pub use_case: String, + pub user: String, + pub version: u64, +} + +pub struct RenameResponse { + pub callstack: String, + pub channel: Option>, + pub error: String, + pub needed: String, + pub ok: Option, + pub provided: String, +} + +pub struct RenameError {} + +pub struct JoinRequest { + /// ID of conversation to join + pub channel: String, +} + +pub struct JoinDisplayCountsInner { + pub display_counts: Option, + pub guest_counts: Option, +} + +pub struct JoinAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct JoinBlocksInner { + pub r#type: Option, +} + +pub struct JoinIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct JoinBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct JoinReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct JoinCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct JoinReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct JoinSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct JoinFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: JoinSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct JoinReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct JoinShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct JoinFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: JoinShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct JoinIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct JoinReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct JoinUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct JoinLatestInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: JoinBotProfileInner, + pub client_msg_id: String, + pub comment: JoinCommentInner, + pub display_as_bot: bool, + pub file: JoinFileInner, + pub files: Vec, + pub icons: JoinIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: JoinUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct JoinPurposeInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct JoinCurrentInner { + pub date_started: Option, + pub team_id: Option, +} + +pub struct JoinExternalOrgMigrationsInner { + pub current: Option>, + pub date_updated: Option, +} + +pub struct JoinIconInner { + pub image_102: String, + pub image_132: String, + pub image_230: String, + pub image_34: String, + pub image_44: String, + pub image_68: String, + pub image_88: String, + pub image_default: bool, +} + +pub struct JoinPrimaryOwnerInner { + pub email: Option, + pub id: Option, +} + +pub struct JoinSsoProviderInner { + pub label: String, + pub name: String, + pub r#type: String, +} + +pub struct JoinTeamInner { + pub archived: bool, + pub avatar_base_url: String, + pub created: u64, + pub date_create: u64, + pub deleted: bool, + pub description: String, + pub discoverable: Vec, + pub domain: Option, + pub email_domain: Option, + pub enterprise_id: String, + pub enterprise_name: String, + pub external_org_migrations: JoinExternalOrgMigrationsInner, + pub has_compliance_export: bool, + pub icon: Option, + pub id: Option, + pub is_assigned: bool, + pub is_enterprise: u64, + pub is_over_storage_limit: bool, + pub limit_ts: u64, + pub locale: String, + pub messages_count: u64, + pub msg_edit_window_mins: u64, + pub name: Option, + pub over_integrations_limit: bool, + pub over_storage_limit: bool, + pub pay_prod_cur: String, + pub plan: String, + pub primary_owner: JoinPrimaryOwnerInner, + pub sso_provider: JoinSsoProviderInner, +} + +pub struct JoinShares2Inner { + pub accepted_user: String, + pub is_active: Option, + pub team: Option, + pub user: Option, +} + +pub struct JoinTopicInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct JoinChannelInner { + pub accepted_user: String, + pub connected_team_ids: Vec, + pub conversation_host_id: String, + pub created: Option, + pub creator: Option, + pub display_counts: JoinDisplayCountsInner, + pub enterprise_id: String, + pub has_pins: bool, + pub id: Option, + pub internal_team_ids: Vec, + pub is_archived: Option, + pub is_channel: Option, + pub is_ext_shared: bool, + pub is_frozen: bool, + pub is_general: Option, + pub is_global_shared: bool, + pub is_group: Option, + pub is_im: Option, + pub is_member: bool, + pub is_moved: u64, + pub is_mpim: Option, + pub is_non_threadable: bool, + pub is_open: bool, + pub is_org_default: bool, + pub is_org_mandatory: bool, + pub is_org_shared: Option, + pub is_pending_ext_shared: bool, + pub is_private: Option, + pub is_read_only: bool, + pub is_shared: Option, + pub is_starred: bool, + pub is_thread_only: bool, + pub last_read: String, + pub latest: Vec, + pub members: Vec, + pub name: Option, + pub name_normalized: Option, + pub num_members: u64, + pub parent_conversation: Vec, + pub pending_connected_team_ids: Vec, + pub pending_shared: Vec, + pub pin_count: u64, + pub previous_names: Vec, + pub priority: u64, + pub purpose: Option, + pub shared_team_ids: Vec, + pub shares: Vec, + pub timezone_count: u64, + pub topic: Option, + pub unlinked: u64, + pub unread_count: u64, + pub unread_count_display: u64, + pub use_case: String, + pub user: String, + pub version: u64, +} + +pub struct JoinResponseMetadataInner { + pub warnings: Vec, +} + +pub struct JoinResponse { + pub callstack: String, + pub channel: Option>, + pub error: String, + pub needed: String, + pub ok: Option, + pub provided: String, + pub response_metadata: JoinResponseMetadataInner, + pub warning: String, +} + +pub struct JoinError {} + +pub struct SetTopicRequest { + /// Conversation to set the topic of + pub channel: String, + /// The new topic string. Does not support formatting or linkification. + pub topic: String, +} + +pub struct SetTopicDisplayCountsInner { + pub display_counts: Option, + pub guest_counts: Option, +} + +pub struct SetTopicAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct SetTopicBlocksInner { + pub r#type: Option, +} + +pub struct SetTopicIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct SetTopicBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct SetTopicReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct SetTopicCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct SetTopicReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct SetTopicSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct SetTopicFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: SetTopicSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct SetTopicReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct SetTopicShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct SetTopicFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: SetTopicShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct SetTopicIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct SetTopicReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct SetTopicUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct SetTopicLatestInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: SetTopicBotProfileInner, + pub client_msg_id: String, + pub comment: SetTopicCommentInner, + pub display_as_bot: bool, + pub file: SetTopicFileInner, + pub files: Vec, + pub icons: SetTopicIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: SetTopicUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct SetTopicPurposeInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct SetTopicCurrentInner { + pub date_started: Option, + pub team_id: Option, +} + +pub struct SetTopicExternalOrgMigrationsInner { + pub current: Option>, + pub date_updated: Option, +} + +pub struct SetTopicIconInner { + pub image_102: String, + pub image_132: String, + pub image_230: String, + pub image_34: String, + pub image_44: String, + pub image_68: String, + pub image_88: String, + pub image_default: bool, +} + +pub struct SetTopicPrimaryOwnerInner { + pub email: Option, + pub id: Option, +} + +pub struct SetTopicSsoProviderInner { + pub label: String, + pub name: String, + pub r#type: String, +} + +pub struct SetTopicTeamInner { + pub archived: bool, + pub avatar_base_url: String, + pub created: u64, + pub date_create: u64, + pub deleted: bool, + pub description: String, + pub discoverable: Vec, + pub domain: Option, + pub email_domain: Option, + pub enterprise_id: String, + pub enterprise_name: String, + pub external_org_migrations: SetTopicExternalOrgMigrationsInner, + pub has_compliance_export: bool, + pub icon: Option, + pub id: Option, + pub is_assigned: bool, + pub is_enterprise: u64, + pub is_over_storage_limit: bool, + pub limit_ts: u64, + pub locale: String, + pub messages_count: u64, + pub msg_edit_window_mins: u64, + pub name: Option, + pub over_integrations_limit: bool, + pub over_storage_limit: bool, + pub pay_prod_cur: String, + pub plan: String, + pub primary_owner: SetTopicPrimaryOwnerInner, + pub sso_provider: SetTopicSsoProviderInner, +} + +pub struct SetTopicShares2Inner { + pub accepted_user: String, + pub is_active: Option, + pub team: Option, + pub user: Option, +} + +pub struct SetTopicTopicInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct SetTopicChannelInner { + pub accepted_user: String, + pub connected_team_ids: Vec, + pub conversation_host_id: String, + pub created: Option, + pub creator: Option, + pub display_counts: SetTopicDisplayCountsInner, + pub enterprise_id: String, + pub has_pins: bool, + pub id: Option, + pub internal_team_ids: Vec, + pub is_archived: Option, + pub is_channel: Option, + pub is_ext_shared: bool, + pub is_frozen: bool, + pub is_general: Option, + pub is_global_shared: bool, + pub is_group: Option, + pub is_im: Option, + pub is_member: bool, + pub is_moved: u64, + pub is_mpim: Option, + pub is_non_threadable: bool, + pub is_open: bool, + pub is_org_default: bool, + pub is_org_mandatory: bool, + pub is_org_shared: Option, + pub is_pending_ext_shared: bool, + pub is_private: Option, + pub is_read_only: bool, + pub is_shared: Option, + pub is_starred: bool, + pub is_thread_only: bool, + pub last_read: String, + pub latest: Vec, + pub members: Vec, + pub name: Option, + pub name_normalized: Option, + pub num_members: u64, + pub parent_conversation: Vec, + pub pending_connected_team_ids: Vec, + pub pending_shared: Vec, + pub pin_count: u64, + pub previous_names: Vec, + pub priority: u64, + pub purpose: Option, + pub shared_team_ids: Vec, + pub shares: Vec, + pub timezone_count: u64, + pub topic: Option, + pub unlinked: u64, + pub unread_count: u64, + pub unread_count_display: u64, + pub use_case: String, + pub user: String, + pub version: u64, +} + +pub struct SetTopicResponse { + pub callstack: String, + pub channel: Option>, + pub error: String, + pub needed: String, + pub ok: Option, + pub provided: String, +} + +pub struct SetTopicError {} + +pub struct CreateRequest { + /// Name of the public or private channel to create + pub name: String, + /// Create a private channel instead of a public one + pub is_private: bool, +} + +pub struct CreateDisplayCountsInner { + pub display_counts: Option, + pub guest_counts: Option, +} + +pub struct CreateAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct CreateBlocksInner { + pub r#type: Option, +} + +pub struct CreateIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct CreateBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct CreateReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct CreateCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct CreateReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct CreateSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct CreateFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: CreateSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct CreateReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct CreateShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct CreateFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: CreateShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct CreateIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct CreateReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct CreateUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct CreateLatestInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: CreateBotProfileInner, + pub client_msg_id: String, + pub comment: CreateCommentInner, + pub display_as_bot: bool, + pub file: CreateFileInner, + pub files: Vec, + pub icons: CreateIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: CreateUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct CreatePurposeInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct CreateCurrentInner { + pub date_started: Option, + pub team_id: Option, +} + +pub struct CreateExternalOrgMigrationsInner { + pub current: Option>, + pub date_updated: Option, +} + +pub struct CreateIconInner { + pub image_102: String, + pub image_132: String, + pub image_230: String, + pub image_34: String, + pub image_44: String, + pub image_68: String, + pub image_88: String, + pub image_default: bool, +} + +pub struct CreatePrimaryOwnerInner { + pub email: Option, + pub id: Option, +} + +pub struct CreateSsoProviderInner { + pub label: String, + pub name: String, + pub r#type: String, +} + +pub struct CreateTeamInner { + pub archived: bool, + pub avatar_base_url: String, + pub created: u64, + pub date_create: u64, + pub deleted: bool, + pub description: String, + pub discoverable: Vec, + pub domain: Option, + pub email_domain: Option, + pub enterprise_id: String, + pub enterprise_name: String, + pub external_org_migrations: CreateExternalOrgMigrationsInner, + pub has_compliance_export: bool, + pub icon: Option, + pub id: Option, + pub is_assigned: bool, + pub is_enterprise: u64, + pub is_over_storage_limit: bool, + pub limit_ts: u64, + pub locale: String, + pub messages_count: u64, + pub msg_edit_window_mins: u64, + pub name: Option, + pub over_integrations_limit: bool, + pub over_storage_limit: bool, + pub pay_prod_cur: String, + pub plan: String, + pub primary_owner: CreatePrimaryOwnerInner, + pub sso_provider: CreateSsoProviderInner, +} + +pub struct CreateShares2Inner { + pub accepted_user: String, + pub is_active: Option, + pub team: Option, + pub user: Option, +} + +pub struct CreateTopicInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct CreateChannelInner { + pub accepted_user: String, + pub connected_team_ids: Vec, + pub conversation_host_id: String, + pub created: Option, + pub creator: Option, + pub display_counts: CreateDisplayCountsInner, + pub enterprise_id: String, + pub has_pins: bool, + pub id: Option, + pub internal_team_ids: Vec, + pub is_archived: Option, + pub is_channel: Option, + pub is_ext_shared: bool, + pub is_frozen: bool, + pub is_general: Option, + pub is_global_shared: bool, + pub is_group: Option, + pub is_im: Option, + pub is_member: bool, + pub is_moved: u64, + pub is_mpim: Option, + pub is_non_threadable: bool, + pub is_open: bool, + pub is_org_default: bool, + pub is_org_mandatory: bool, + pub is_org_shared: Option, + pub is_pending_ext_shared: bool, + pub is_private: Option, + pub is_read_only: bool, + pub is_shared: Option, + pub is_starred: bool, + pub is_thread_only: bool, + pub last_read: String, + pub latest: Vec, + pub members: Vec, + pub name: Option, + pub name_normalized: Option, + pub num_members: u64, + pub parent_conversation: Vec, + pub pending_connected_team_ids: Vec, + pub pending_shared: Vec, + pub pin_count: u64, + pub previous_names: Vec, + pub priority: u64, + pub purpose: Option, + pub shared_team_ids: Vec, + pub shares: Vec, + pub timezone_count: u64, + pub topic: Option, + pub unlinked: u64, + pub unread_count: u64, + pub unread_count_display: u64, + pub use_case: String, + pub user: String, + pub version: u64, +} + +pub struct CreateResponse { + pub callstack: String, + pub channel: Option>, + pub detail: String, + pub error: String, + pub needed: String, + pub ok: Option, + pub provided: String, +} + +pub struct CreateError {} + +pub struct InfoRequest { + /// Conversation ID to learn more about + pub channel: String, + /// Set this to `true` to receive the locale for this conversation. Defaults to `false` + pub include_locale: bool, + /// Set to `true` to include the member count for the specified conversation. Defaults to `false` + pub include_num_members: bool, +} + +pub struct InfoDisplayCountsInner { + pub display_counts: Option, + pub guest_counts: Option, +} + +pub struct InfoAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct InfoBlocksInner { + pub r#type: Option, +} + +pub struct InfoIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct InfoBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct InfoReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct InfoCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct InfoReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct InfoSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct InfoFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: InfoSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct InfoReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct InfoShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct InfoFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: InfoShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct InfoIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct InfoReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct InfoUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct InfoLatestInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: InfoBotProfileInner, + pub client_msg_id: String, + pub comment: InfoCommentInner, + pub display_as_bot: bool, + pub file: InfoFileInner, + pub files: Vec, + pub icons: InfoIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: InfoUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct InfoPurposeInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct InfoCurrentInner { + pub date_started: Option, + pub team_id: Option, +} + +pub struct InfoExternalOrgMigrationsInner { + pub current: Option>, + pub date_updated: Option, +} + +pub struct InfoIconInner { + pub image_102: String, + pub image_132: String, + pub image_230: String, + pub image_34: String, + pub image_44: String, + pub image_68: String, + pub image_88: String, + pub image_default: bool, +} + +pub struct InfoPrimaryOwnerInner { + pub email: Option, + pub id: Option, +} + +pub struct InfoSsoProviderInner { + pub label: String, + pub name: String, + pub r#type: String, +} + +pub struct InfoTeamInner { + pub archived: bool, + pub avatar_base_url: String, + pub created: u64, + pub date_create: u64, + pub deleted: bool, + pub description: String, + pub discoverable: Vec, + pub domain: Option, + pub email_domain: Option, + pub enterprise_id: String, + pub enterprise_name: String, + pub external_org_migrations: InfoExternalOrgMigrationsInner, + pub has_compliance_export: bool, + pub icon: Option, + pub id: Option, + pub is_assigned: bool, + pub is_enterprise: u64, + pub is_over_storage_limit: bool, + pub limit_ts: u64, + pub locale: String, + pub messages_count: u64, + pub msg_edit_window_mins: u64, + pub name: Option, + pub over_integrations_limit: bool, + pub over_storage_limit: bool, + pub pay_prod_cur: String, + pub plan: String, + pub primary_owner: InfoPrimaryOwnerInner, + pub sso_provider: InfoSsoProviderInner, +} + +pub struct InfoShares2Inner { + pub accepted_user: String, + pub is_active: Option, + pub team: Option, + pub user: Option, +} + +pub struct InfoTopicInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct InfoChannelInner { + pub accepted_user: String, + pub connected_team_ids: Vec, + pub conversation_host_id: String, + pub created: Option, + pub creator: Option, + pub display_counts: InfoDisplayCountsInner, + pub enterprise_id: String, + pub has_pins: bool, + pub id: Option, + pub internal_team_ids: Vec, + pub is_archived: Option, + pub is_channel: Option, + pub is_ext_shared: bool, + pub is_frozen: bool, + pub is_general: Option, + pub is_global_shared: bool, + pub is_group: Option, + pub is_im: Option, + pub is_member: bool, + pub is_moved: u64, + pub is_mpim: Option, + pub is_non_threadable: bool, + pub is_open: bool, + pub is_org_default: bool, + pub is_org_mandatory: bool, + pub is_org_shared: Option, + pub is_pending_ext_shared: bool, + pub is_private: Option, + pub is_read_only: bool, + pub is_shared: Option, + pub is_starred: bool, + pub is_thread_only: bool, + pub last_read: String, + pub latest: Vec, + pub members: Vec, + pub name: Option, + pub name_normalized: Option, + pub num_members: u64, + pub parent_conversation: Vec, + pub pending_connected_team_ids: Vec, + pub pending_shared: Vec, + pub pin_count: u64, + pub previous_names: Vec, + pub priority: u64, + pub purpose: Option, + pub shared_team_ids: Vec, + pub shares: Vec, + pub timezone_count: u64, + pub topic: Option, + pub unlinked: u64, + pub unread_count: u64, + pub unread_count_display: u64, + pub use_case: String, + pub user: String, + pub version: u64, +} + +pub struct InfoResponse { + pub callstack: String, + pub channel: Option>, + pub error: String, + pub needed: String, + pub ok: Option, + pub provided: String, +} + +pub struct InfoError {} + +pub struct KickRequest { + /// ID of conversation to remove user from. + pub channel: String, + /// User ID to be removed. + pub user: String, +} + +pub struct KickResponse { + pub callstack: String, + pub error: String, + pub needed: String, + pub ok: Option, + pub provided: String, +} + +pub struct KickError {} diff --git a/src/mod_types/dialog_types.rs b/src/mod_types/dialog_types.rs new file mode 100644 index 00000000..788964c9 --- /dev/null +++ b/src/mod_types/dialog_types.rs @@ -0,0 +1,14 @@ +pub struct OpenRequest { + /// The dialog definition. This must be a JSON-encoded string. + pub dialog: Option, + /// Exchange a trigger to post to the user. + pub trigger_id: Option, +} + +pub struct OpenResponse { + pub callstack: String, + pub error: String, + pub ok: Option, +} + +pub struct OpenError {} diff --git a/src/mod_types/dnd_types.rs b/src/mod_types/dnd_types.rs index d608ae4d..0d39212f 100644 --- a/src/mod_types/dnd_types.rs +++ b/src/mod_types/dnd_types.rs @@ -1,584 +1,71 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -//! Adjust and view Do Not Disturb settings for team members. - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Debug, Deserialize)] -pub struct EndDndResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for EndDndResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum EndDndError { - /// There was a mysterious problem ending the user's Do Not Disturb session - UnknownError, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for EndDndError { - fn from(s: &'a str) -> Self { - match s { - "unknown_error" => EndDndError::UnknownError, - "not_authed" => EndDndError::NotAuthed, - "invalid_auth" => EndDndError::InvalidAuth, - "account_inactive" => EndDndError::AccountInactive, - "user_is_bot" => EndDndError::UserIsBot, - "invalid_arg_name" => EndDndError::InvalidArgName, - "invalid_array_arg" => EndDndError::InvalidArrayArg, - "invalid_charset" => EndDndError::InvalidCharset, - "invalid_form_data" => EndDndError::InvalidFormData, - "invalid_post_type" => EndDndError::InvalidPostType, - "missing_post_type" => EndDndError::MissingPostType, - "team_added_to_org" => EndDndError::TeamAddedToOrg, - "request_timeout" => EndDndError::RequestTimeout, - _ => EndDndError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for EndDndError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - EndDndError::UnknownError => "unknown_error: There was a mysterious problem ending the user's Do Not Disturb session", -EndDndError::NotAuthed => "not_authed: No authentication token provided.", -EndDndError::InvalidAuth => "invalid_auth: Invalid authentication token.", -EndDndError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -EndDndError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -EndDndError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -EndDndError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -EndDndError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -EndDndError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -EndDndError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -EndDndError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -EndDndError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -EndDndError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - EndDndError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - EndDndError::Unknown(ref s) => return write!(f, "{}", s), - EndDndError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for EndDndError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - EndDndError::MalformedResponse(_, ref e) => Some(e), - EndDndError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Debug, Deserialize)] -pub struct EndSnoozeResponse { - pub dnd_enabled: Option, - error: Option, - pub next_dnd_end_ts: Option, - pub next_dnd_start_ts: Option, - #[serde(default)] - ok: bool, - pub snooze_enabled: Option, -} - -impl Into>> for EndSnoozeResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum EndSnoozeError { - /// Snooze is not active for this user and cannot be ended - SnoozeNotActive, - /// There was a problem setting the user's Do Not Disturb status - SnoozeEndFailed, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for EndSnoozeError { - fn from(s: &'a str) -> Self { - match s { - "snooze_not_active" => EndSnoozeError::SnoozeNotActive, - "snooze_end_failed" => EndSnoozeError::SnoozeEndFailed, - "not_authed" => EndSnoozeError::NotAuthed, - "invalid_auth" => EndSnoozeError::InvalidAuth, - "account_inactive" => EndSnoozeError::AccountInactive, - "user_is_bot" => EndSnoozeError::UserIsBot, - "invalid_arg_name" => EndSnoozeError::InvalidArgName, - "invalid_array_arg" => EndSnoozeError::InvalidArrayArg, - "invalid_charset" => EndSnoozeError::InvalidCharset, - "invalid_form_data" => EndSnoozeError::InvalidFormData, - "invalid_post_type" => EndSnoozeError::InvalidPostType, - "missing_post_type" => EndSnoozeError::MissingPostType, - "team_added_to_org" => EndSnoozeError::TeamAddedToOrg, - "request_timeout" => EndSnoozeError::RequestTimeout, - _ => EndSnoozeError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for EndSnoozeError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - EndSnoozeError::SnoozeNotActive => "snooze_not_active: Snooze is not active for this user and cannot be ended", -EndSnoozeError::SnoozeEndFailed => "snooze_end_failed: There was a problem setting the user's Do Not Disturb status", -EndSnoozeError::NotAuthed => "not_authed: No authentication token provided.", -EndSnoozeError::InvalidAuth => "invalid_auth: Invalid authentication token.", -EndSnoozeError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -EndSnoozeError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -EndSnoozeError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -EndSnoozeError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -EndSnoozeError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -EndSnoozeError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -EndSnoozeError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -EndSnoozeError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -EndSnoozeError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -EndSnoozeError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - EndSnoozeError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - EndSnoozeError::Unknown(ref s) => return write!(f, "{}", s), - EndSnoozeError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for EndSnoozeError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - EndSnoozeError::MalformedResponse(_, ref e) => Some(e), - EndSnoozeError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct InfoRequest<'a> { +pub struct InfoRequest { /// User to fetch status for (defaults to current user) - pub user: Option<&'a str>, + pub user: String, } -#[derive(Clone, Debug, Deserialize)] pub struct InfoResponse { + pub callstack: String, pub dnd_enabled: Option, - error: Option, - pub next_dnd_end_ts: Option, - pub next_dnd_start_ts: Option, - #[serde(default)] - ok: bool, - pub snooze_enabled: Option, - pub snooze_endtime: Option, - pub snooze_remaining: Option, + pub error: String, + pub next_dnd_end_ts: Option, + pub next_dnd_start_ts: Option, + pub ok: Option, + pub snooze_enabled: bool, + pub snooze_endtime: u64, + pub snooze_remaining: u64, } -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum InfoError { - /// Value passed for user was invalid. - UserNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} +pub struct InfoError {} -impl<'a, E: Error> From<&'a str> for InfoError { - fn from(s: &'a str) -> Self { - match s { - "user_not_found" => InfoError::UserNotFound, - "not_authed" => InfoError::NotAuthed, - "invalid_auth" => InfoError::InvalidAuth, - "account_inactive" => InfoError::AccountInactive, - "invalid_arg_name" => InfoError::InvalidArgName, - "invalid_array_arg" => InfoError::InvalidArrayArg, - "invalid_charset" => InfoError::InvalidCharset, - "invalid_form_data" => InfoError::InvalidFormData, - "invalid_post_type" => InfoError::InvalidPostType, - "missing_post_type" => InfoError::MissingPostType, - "team_added_to_org" => InfoError::TeamAddedToOrg, - "request_timeout" => InfoError::RequestTimeout, - _ => InfoError::Unknown(s.to_owned()), - } - } -} +pub struct EndDndRequest {} -impl fmt::Display for InfoError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - InfoError::UserNotFound => "user_not_found: Value passed for user was invalid.", -InfoError::NotAuthed => "not_authed: No authentication token provided.", -InfoError::InvalidAuth => "invalid_auth: Invalid authentication token.", -InfoError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -InfoError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -InfoError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -InfoError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -InfoError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -InfoError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -InfoError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -InfoError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -InfoError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - InfoError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - InfoError::Unknown(ref s) => return write!(f, "{}", s), - InfoError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } +pub struct EndDndResponse { + pub callstack: String, + pub error: String, + pub ok: Option, } -impl Error for InfoError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - InfoError::MalformedResponse(_, ref e) => Some(e), - InfoError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct EndDndError {} -#[derive(Clone, Default, Debug)] pub struct SetSnoozeRequest { + /// Authentication token. Requires scope: `dnd:write` + pub token: Option, /// Number of minutes, from now, to snooze until. - pub num_minutes: u32, + pub num_minutes: Option, } -#[derive(Clone, Debug, Deserialize)] pub struct SetSnoozeResponse { - error: Option, - #[serde(default)] - ok: bool, + pub callstack: String, + pub error: String, + pub ok: Option, pub snooze_enabled: Option, - pub snooze_endtime: Option, - pub snooze_remaining: Option, + pub snooze_endtime: Option, + pub snooze_remaining: Option, } -impl Into>> for SetSnoozeResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum SetSnoozeError { - /// No value provided for num_minutes - MissingDuration, - /// There was a problem setting the user's Do Not Disturb status - SnoozeFailed, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} +pub struct SetSnoozeError {} -impl<'a, E: Error> From<&'a str> for SetSnoozeError { - fn from(s: &'a str) -> Self { - match s { - "missing_duration" => SetSnoozeError::MissingDuration, - "snooze_failed" => SetSnoozeError::SnoozeFailed, - "not_authed" => SetSnoozeError::NotAuthed, - "invalid_auth" => SetSnoozeError::InvalidAuth, - "account_inactive" => SetSnoozeError::AccountInactive, - "user_is_bot" => SetSnoozeError::UserIsBot, - "invalid_arg_name" => SetSnoozeError::InvalidArgName, - "invalid_array_arg" => SetSnoozeError::InvalidArrayArg, - "invalid_charset" => SetSnoozeError::InvalidCharset, - "invalid_form_data" => SetSnoozeError::InvalidFormData, - "invalid_post_type" => SetSnoozeError::InvalidPostType, - "missing_post_type" => SetSnoozeError::MissingPostType, - "team_added_to_org" => SetSnoozeError::TeamAddedToOrg, - "request_timeout" => SetSnoozeError::RequestTimeout, - _ => SetSnoozeError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for SetSnoozeError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - SetSnoozeError::MissingDuration => "missing_duration: No value provided for num_minutes", -SetSnoozeError::SnoozeFailed => "snooze_failed: There was a problem setting the user's Do Not Disturb status", -SetSnoozeError::NotAuthed => "not_authed: No authentication token provided.", -SetSnoozeError::InvalidAuth => "invalid_auth: Invalid authentication token.", -SetSnoozeError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -SetSnoozeError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -SetSnoozeError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -SetSnoozeError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -SetSnoozeError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -SetSnoozeError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -SetSnoozeError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -SetSnoozeError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -SetSnoozeError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -SetSnoozeError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - SetSnoozeError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - SetSnoozeError::Unknown(ref s) => return write!(f, "{}", s), - SetSnoozeError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for SetSnoozeError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - SetSnoozeError::MalformedResponse(_, ref e) => Some(e), - SetSnoozeError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct TeamInfoRequest<'a> { +pub struct TeamInfoRequest { /// Comma-separated list of users to fetch Do Not Disturb status for - pub users: Option<&'a str>, + pub users: String, } -#[derive(Clone, Debug, Deserialize)] pub struct TeamInfoResponse { - error: Option, - #[serde(default)] - ok: bool, - pub users: Option>, + pub ok: Option, } -impl Into>> for TeamInfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum TeamInfoError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} +pub struct TeamInfoError {} -impl<'a, E: Error> From<&'a str> for TeamInfoError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => TeamInfoError::NotAuthed, - "invalid_auth" => TeamInfoError::InvalidAuth, - "account_inactive" => TeamInfoError::AccountInactive, - "invalid_arg_name" => TeamInfoError::InvalidArgName, - "invalid_array_arg" => TeamInfoError::InvalidArrayArg, - "invalid_charset" => TeamInfoError::InvalidCharset, - "invalid_form_data" => TeamInfoError::InvalidFormData, - "invalid_post_type" => TeamInfoError::InvalidPostType, - "missing_post_type" => TeamInfoError::MissingPostType, - "team_added_to_org" => TeamInfoError::TeamAddedToOrg, - "request_timeout" => TeamInfoError::RequestTimeout, - _ => TeamInfoError::Unknown(s.to_owned()), - } - } -} +pub struct EndSnoozeRequest {} -impl fmt::Display for TeamInfoError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - TeamInfoError::NotAuthed => "not_authed: No authentication token provided.", -TeamInfoError::InvalidAuth => "invalid_auth: Invalid authentication token.", -TeamInfoError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -TeamInfoError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -TeamInfoError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -TeamInfoError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -TeamInfoError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -TeamInfoError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -TeamInfoError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -TeamInfoError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -TeamInfoError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - TeamInfoError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - TeamInfoError::Unknown(ref s) => return write!(f, "{}", s), - TeamInfoError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } +pub struct EndSnoozeResponse { + pub callstack: String, + pub dnd_enabled: Option, + pub error: String, + pub next_dnd_end_ts: Option, + pub next_dnd_start_ts: Option, + pub ok: Option, + pub snooze_enabled: Option, } -impl Error for TeamInfoError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - TeamInfoError::MalformedResponse(_, ref e) => Some(e), - TeamInfoError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct EndSnoozeError {} diff --git a/src/mod_types/emoji_types.rs b/src/mod_types/emoji_types.rs index 81f4db1e..fec275c7 100644 --- a/src/mod_types/emoji_types.rs +++ b/src/mod_types/emoji_types.rs @@ -1,119 +1,7 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= +pub struct ListRequest {} -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Debug, Deserialize)] pub struct ListResponse { - pub emoji: Option>, - error: Option, - #[serde(default)] - ok: bool, + pub ok: Option, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ListError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ListError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => ListError::NotAuthed, - "invalid_auth" => ListError::InvalidAuth, - "account_inactive" => ListError::AccountInactive, - "invalid_arg_name" => ListError::InvalidArgName, - "invalid_array_arg" => ListError::InvalidArrayArg, - "invalid_charset" => ListError::InvalidCharset, - "invalid_form_data" => ListError::InvalidFormData, - "invalid_post_type" => ListError::InvalidPostType, - "missing_post_type" => ListError::MissingPostType, - "team_added_to_org" => ListError::TeamAddedToOrg, - "request_timeout" => ListError::RequestTimeout, - _ => ListError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for ListError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ListError::NotAuthed => "not_authed: No authentication token provided.", -ListError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ListError::Unknown(ref s) => return write!(f, "{}", s), - ListError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for ListError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ListError::MalformedResponse(_, ref e) => Some(e), - ListError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct ListError {} diff --git a/src/mod_types/files/comments_types.rs b/src/mod_types/files/comments_types.rs new file mode 100644 index 00000000..334dc378 --- /dev/null +++ b/src/mod_types/files/comments_types.rs @@ -0,0 +1,14 @@ +pub struct DeleteRequest { + /// File to delete a comment from. + pub file: String, + /// The comment to delete. + pub id: String, +} + +pub struct DeleteResponse { + pub callstack: String, + pub error: String, + pub ok: Option, +} + +pub struct DeleteError {} diff --git a/src/mod_types/files/mod.rs b/src/mod_types/files/mod.rs new file mode 100644 index 00000000..e28f9812 --- /dev/null +++ b/src/mod_types/files/mod.rs @@ -0,0 +1,567 @@ +pub mod comments_types; +pub mod remote_types; + +pub struct InfoRequest { + /// Specify a file by providing its ID. + pub file: String, + pub count: String, + pub page: String, + /// The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. + pub limit: u64, + /// Parameter for pagination. File comments are paginated for a single file. Set `cursor` equal to the `next_cursor` attribute returned by the previous request's `response_metadata`. This parameter is optional, but pagination is mandatory: the default value simply fetches the first "page" of the collection of comments. See [pagination](/docs/pagination) for more details. + pub cursor: String, +} + +pub struct InfoReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct InfoSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct InfoFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: InfoSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct InfoPagingInner { + pub count: u64, + pub page: Option, + pub pages: u64, + pub per_page: u64, + pub spill: u64, + pub total: Option, +} + +pub struct InfoResponseMetadataInner { + pub next_cursor: Option, +} + +pub struct InfoResponse { + pub callstack: String, + pub comments: Option>, + pub content_html: serde_json::Value, + pub editor: String, + pub error: String, + pub file: Option, + pub ok: Option, + pub paging: InfoPagingInner, + pub response_metadata: Vec, +} + +pub struct InfoError {} + +pub struct RevokePublicURLRequest { + /// File to revoke + pub file: String, +} + +pub struct RevokePublicURLReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct RevokePublicURLSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct RevokePublicURLFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: RevokePublicURLSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct RevokePublicURLResponse { + pub callstack: String, + pub error: String, + pub file: Option, + pub ok: Option, +} + +pub struct RevokePublicURLError {} + +pub struct UploadRequest { + /// Authentication token. Requires scope: `files:write:user` + pub token: String, + /// File contents via `multipart/form-data`. If omitting this parameter, you must submit `content`. + pub file: String, + /// File contents via a POST variable. If omitting this parameter, you must provide a `file`. + pub content: String, + /// A [file type](/types/file#file_types) identifier. + pub filetype: String, + /// Filename of file. + pub filename: String, + /// Title of file. + pub title: String, + /// The message text introducing the file in specified `channels`. + pub initial_comment: String, + /// Comma-separated list of channel names or IDs where the file will be shared. + pub channels: String, + /// Provide another message's `ts` value to upload this file as a reply. Never use a reply's `ts` value; use its parent instead. + pub thread_ts: u64, +} + +pub struct UploadReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct UploadSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct UploadFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: UploadSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct UploadResponse { + pub callstack: String, + pub error: String, + pub file: Option, + pub ok: Option, +} + +pub struct UploadError {} + +pub struct SharedPublicURLRequest { + /// File to share + pub file: String, +} + +pub struct SharedPublicURLReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct SharedPublicURLSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct SharedPublicURLFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: SharedPublicURLSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct SharedPublicURLResponse { + pub callstack: String, + pub error: String, + pub file: Option, + pub ok: Option, +} + +pub struct SharedPublicURLError {} + +pub struct ListRequest { + /// Filter files created by a single user. + pub user: String, + /// Filter files appearing in a specific channel, indicated by its ID. + pub channel: String, + /// Filter files created after this timestamp (inclusive). + pub ts_from: u64, + /// Filter files created before this timestamp (inclusive). + pub ts_to: u64, + /// Filter files by type ([see below](#file_types)). You can pass multiple values in the types argument, like `types=spaces,snippets`.The default value is `all`, which does not filter the list. + pub types: String, + pub count: String, + pub page: String, + /// Show truncated file info for files hidden due to being too old, and the team who owns the file being over the file limit. + pub show_files_hidden_by_limit: bool, +} + +pub struct ListReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ListSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct ListFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: ListSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct ListPagingInner { + pub count: u64, + pub page: Option, + pub pages: u64, + pub per_page: u64, + pub spill: u64, + pub total: Option, +} + +pub struct ListResponse { + pub callstack: String, + pub error: String, + pub files: Option>, + pub ok: Option, + pub paging: Option, +} + +pub struct ListError {} + +pub struct DeleteRequest { + /// ID of file to delete. + pub file: String, +} + +pub struct DeleteResponse { + pub callstack: String, + pub error: String, + pub ok: Option, +} + +pub struct DeleteError {} diff --git a/src/mod_types/files/remote_types.rs b/src/mod_types/files/remote_types.rs new file mode 100644 index 00000000..14304966 --- /dev/null +++ b/src/mod_types/files/remote_types.rs @@ -0,0 +1,109 @@ +pub struct ListRequest { + /// Filter files appearing in a specific channel, indicated by its ID. + pub channel: String, + /// Filter files created after this timestamp (inclusive). + pub ts_from: u64, + /// Filter files created before this timestamp (inclusive). + pub ts_to: u64, + /// The maximum number of items to return. + pub limit: u64, + /// Paginate through collections of data by setting the `cursor` parameter to a `next_cursor` attribute returned by a previous request's `response_metadata`. Default value fetches the first "page" of the collection. See [pagination](/docs/pagination) for more detail. + pub cursor: String, +} + +pub struct ListResponse { + pub ok: Option, +} + +pub struct ListError {} + +pub struct InfoRequest { + /// Specify a file by providing its ID. + pub file: String, + /// Creator defined GUID for the file. + pub external_id: String, +} + +pub struct InfoResponse { + pub ok: Option, +} + +pub struct InfoError {} + +pub struct RemoveRequest { + /// Authentication token. Requires scope: `remote_files:write` + pub token: String, + /// Specify a file by providing its ID. + pub file: String, + /// Creator defined GUID for the file. + pub external_id: String, +} + +pub struct RemoveResponse { + pub ok: Option, +} + +pub struct RemoveError {} + +pub struct ShareRequest { + /// Specify a file registered with Slack by providing its ID. Either this field or `external_id` or both are required. + pub file: String, + /// The globally unique identifier (GUID) for the file, as set by the app registering the file with Slack. Either this field or `file` or both are required. + pub external_id: String, + /// Comma-separated list of channel IDs where the file will be shared. + pub channels: String, +} + +pub struct ShareResponse { + pub ok: Option, +} + +pub struct ShareError {} + +pub struct AddRequest { + /// Authentication token. Requires scope: `remote_files:write` + pub token: String, + /// Creator defined GUID for the file. + pub external_id: String, + /// Title of the file being shared. + pub title: String, + /// type of file + pub filetype: String, + /// URL of the remote file. + pub external_url: String, + /// Preview of the document via `multipart/form-data`. + pub preview_image: String, + /// A text file (txt, pdf, doc, etc.) containing textual search terms that are used to improve discovery of the remote file. + pub indexable_file_contents: String, +} + +pub struct AddResponse { + pub ok: Option, +} + +pub struct AddError {} + +pub struct UpdateRequest { + /// Authentication token. Requires scope: `remote_files:write` + pub token: String, + /// Specify a file by providing its ID. + pub file: String, + /// Creator defined GUID for the file. + pub external_id: String, + /// Title of the file being shared. + pub title: String, + /// type of file + pub filetype: String, + /// URL of the remote file. + pub external_url: String, + /// Preview of the document via `multipart/form-data`. + pub preview_image: String, + /// File containing contents that can be used to improve searchability for the remote file. + pub indexable_file_contents: String, +} + +pub struct UpdateResponse { + pub ok: Option, +} + +pub struct UpdateError {} diff --git a/src/mod_types/files_comments_types.rs b/src/mod_types/files_comments_types.rs deleted file mode 100644 index 3fa85a3a..00000000 --- a/src/mod_types/files_comments_types.rs +++ /dev/null @@ -1,388 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct AddRequest<'a> { - /// File to add a comment to. - pub file: &'a str, - /// Text of the comment to add. - pub comment: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct AddResponse { - pub comment: Option, - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for AddResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum AddError { - /// The requested file could not be found. - FileNotFound, - /// The requested file was previously deleted. - FileDeleted, - /// The comment field was empty. - NoComment, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for AddError { - fn from(s: &'a str) -> Self { - match s { - "file_not_found" => AddError::FileNotFound, - "file_deleted" => AddError::FileDeleted, - "no_comment" => AddError::NoComment, - "not_authed" => AddError::NotAuthed, - "invalid_auth" => AddError::InvalidAuth, - "account_inactive" => AddError::AccountInactive, - "invalid_arg_name" => AddError::InvalidArgName, - "invalid_array_arg" => AddError::InvalidArrayArg, - "invalid_charset" => AddError::InvalidCharset, - "invalid_form_data" => AddError::InvalidFormData, - "invalid_post_type" => AddError::InvalidPostType, - "missing_post_type" => AddError::MissingPostType, - "team_added_to_org" => AddError::TeamAddedToOrg, - "request_timeout" => AddError::RequestTimeout, - _ => AddError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for AddError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - AddError::FileNotFound => "file_not_found: The requested file could not be found.", -AddError::FileDeleted => "file_deleted: The requested file was previously deleted.", -AddError::NoComment => "no_comment: The comment field was empty.", -AddError::NotAuthed => "not_authed: No authentication token provided.", -AddError::InvalidAuth => "invalid_auth: Invalid authentication token.", -AddError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -AddError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -AddError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -AddError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -AddError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -AddError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -AddError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -AddError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -AddError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - AddError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - AddError::Unknown(ref s) => return write!(f, "{}", s), - AddError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for AddError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - AddError::MalformedResponse(_, ref e) => Some(e), - AddError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct DeleteRequest<'a> { - /// File to delete a comment from. - pub file: &'a str, - /// The comment to delete. - pub id: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct DeleteResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for DeleteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum DeleteError { - /// The requested file could not be found. - FileNotFound, - /// The requested file was previously deleted. - FileDeleted, - /// The requested comment could not be deleted. - CantDelete, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for DeleteError { - fn from(s: &'a str) -> Self { - match s { - "file_not_found" => DeleteError::FileNotFound, - "file_deleted" => DeleteError::FileDeleted, - "cant_delete" => DeleteError::CantDelete, - "not_authed" => DeleteError::NotAuthed, - "invalid_auth" => DeleteError::InvalidAuth, - "account_inactive" => DeleteError::AccountInactive, - "invalid_arg_name" => DeleteError::InvalidArgName, - "invalid_array_arg" => DeleteError::InvalidArrayArg, - "invalid_charset" => DeleteError::InvalidCharset, - "invalid_form_data" => DeleteError::InvalidFormData, - "invalid_post_type" => DeleteError::InvalidPostType, - "missing_post_type" => DeleteError::MissingPostType, - "team_added_to_org" => DeleteError::TeamAddedToOrg, - "request_timeout" => DeleteError::RequestTimeout, - _ => DeleteError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for DeleteError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - DeleteError::FileNotFound => "file_not_found: The requested file could not be found.", -DeleteError::FileDeleted => "file_deleted: The requested file was previously deleted.", -DeleteError::CantDelete => "cant_delete: The requested comment could not be deleted.", -DeleteError::NotAuthed => "not_authed: No authentication token provided.", -DeleteError::InvalidAuth => "invalid_auth: Invalid authentication token.", -DeleteError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -DeleteError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -DeleteError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -DeleteError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -DeleteError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -DeleteError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -DeleteError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -DeleteError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -DeleteError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - DeleteError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - DeleteError::Unknown(ref s) => return write!(f, "{}", s), - DeleteError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for DeleteError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - DeleteError::MalformedResponse(_, ref e) => Some(e), - DeleteError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct EditRequest<'a> { - /// File containing the comment to edit. - pub file: &'a str, - /// The comment to edit. - pub id: &'a str, - /// Text of the comment to edit. - pub comment: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct EditResponse { - pub comment: Option, - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for EditResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum EditError { - /// The requested file could not be found. - FileNotFound, - /// The requested file was previously deleted. - FileDeleted, - /// The comment field was empty. - NoComment, - /// The timeframe for editing the comment has expired. - EditWindowClosed, - /// The requested file could not be found. - CantEdit, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for EditError { - fn from(s: &'a str) -> Self { - match s { - "file_not_found" => EditError::FileNotFound, - "file_deleted" => EditError::FileDeleted, - "no_comment" => EditError::NoComment, - "edit_window_closed" => EditError::EditWindowClosed, - "cant_edit" => EditError::CantEdit, - "not_authed" => EditError::NotAuthed, - "invalid_auth" => EditError::InvalidAuth, - "account_inactive" => EditError::AccountInactive, - "invalid_arg_name" => EditError::InvalidArgName, - "invalid_array_arg" => EditError::InvalidArrayArg, - "invalid_charset" => EditError::InvalidCharset, - "invalid_form_data" => EditError::InvalidFormData, - "invalid_post_type" => EditError::InvalidPostType, - "missing_post_type" => EditError::MissingPostType, - "team_added_to_org" => EditError::TeamAddedToOrg, - "request_timeout" => EditError::RequestTimeout, - _ => EditError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for EditError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - EditError::FileNotFound => "file_not_found: The requested file could not be found.", -EditError::FileDeleted => "file_deleted: The requested file was previously deleted.", -EditError::NoComment => "no_comment: The comment field was empty.", -EditError::EditWindowClosed => "edit_window_closed: The timeframe for editing the comment has expired.", -EditError::CantEdit => "cant_edit: The requested file could not be found.", -EditError::NotAuthed => "not_authed: No authentication token provided.", -EditError::InvalidAuth => "invalid_auth: Invalid authentication token.", -EditError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -EditError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -EditError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -EditError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -EditError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -EditError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -EditError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -EditError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -EditError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - EditError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - EditError::Unknown(ref s) => return write!(f, "{}", s), - EditError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for EditError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - EditError::MalformedResponse(_, ref e) => Some(e), - EditError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/files_types.rs b/src/mod_types/files_types.rs deleted file mode 100644 index d9b1b2a2..00000000 --- a/src/mod_types/files_types.rs +++ /dev/null @@ -1,645 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -//! Get info on files uploaded to Slack, upload new files to Slack. - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct DeleteRequest<'a> { - /// ID of file to delete. - pub file: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct DeleteResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for DeleteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum DeleteError { - /// The file does not exist, or is not visible to the calling user. - FileNotFound, - /// The file has already been deleted. - FileDeleted, - /// Authenticated user does not have permission to delete this file. - CantDeleteFile, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for DeleteError { - fn from(s: &'a str) -> Self { - match s { - "file_not_found" => DeleteError::FileNotFound, - "file_deleted" => DeleteError::FileDeleted, - "cant_delete_file" => DeleteError::CantDeleteFile, - "not_authed" => DeleteError::NotAuthed, - "invalid_auth" => DeleteError::InvalidAuth, - "account_inactive" => DeleteError::AccountInactive, - "invalid_arg_name" => DeleteError::InvalidArgName, - "invalid_array_arg" => DeleteError::InvalidArrayArg, - "invalid_charset" => DeleteError::InvalidCharset, - "invalid_form_data" => DeleteError::InvalidFormData, - "invalid_post_type" => DeleteError::InvalidPostType, - "missing_post_type" => DeleteError::MissingPostType, - "team_added_to_org" => DeleteError::TeamAddedToOrg, - "request_timeout" => DeleteError::RequestTimeout, - _ => DeleteError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for DeleteError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - DeleteError::FileNotFound => "file_not_found: The file does not exist, or is not visible to the calling user.", -DeleteError::FileDeleted => "file_deleted: The file has already been deleted.", -DeleteError::CantDeleteFile => "cant_delete_file: Authenticated user does not have permission to delete this file.", -DeleteError::NotAuthed => "not_authed: No authentication token provided.", -DeleteError::InvalidAuth => "invalid_auth: Invalid authentication token.", -DeleteError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -DeleteError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -DeleteError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -DeleteError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -DeleteError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -DeleteError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -DeleteError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -DeleteError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -DeleteError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - DeleteError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - DeleteError::Unknown(ref s) => return write!(f, "{}", s), - DeleteError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for DeleteError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - DeleteError::MalformedResponse(_, ref e) => Some(e), - DeleteError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct InfoRequest<'a> { - /// Specify a file by providing its ID. - pub file: &'a str, - /// Number of items to return per page. - pub count: Option, - /// Page number of results to return. - pub page: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct InfoResponse { - pub comments: Option>, - error: Option, - pub file: Option, - #[serde(default)] - ok: bool, - pub paging: Option, -} - -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum InfoError { - /// Value passed for file was invalid - FileNotFound, - /// The requested file has been deleted - FileDeleted, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for InfoError { - fn from(s: &'a str) -> Self { - match s { - "file_not_found" => InfoError::FileNotFound, - "file_deleted" => InfoError::FileDeleted, - "not_authed" => InfoError::NotAuthed, - "invalid_auth" => InfoError::InvalidAuth, - "account_inactive" => InfoError::AccountInactive, - "invalid_arg_name" => InfoError::InvalidArgName, - "invalid_array_arg" => InfoError::InvalidArrayArg, - "invalid_charset" => InfoError::InvalidCharset, - "invalid_form_data" => InfoError::InvalidFormData, - "invalid_post_type" => InfoError::InvalidPostType, - "missing_post_type" => InfoError::MissingPostType, - "team_added_to_org" => InfoError::TeamAddedToOrg, - "request_timeout" => InfoError::RequestTimeout, - _ => InfoError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for InfoError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - InfoError::FileNotFound => "file_not_found: Value passed for file was invalid", -InfoError::FileDeleted => "file_deleted: The requested file has been deleted", -InfoError::NotAuthed => "not_authed: No authentication token provided.", -InfoError::InvalidAuth => "invalid_auth: Invalid authentication token.", -InfoError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -InfoError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -InfoError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -InfoError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -InfoError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -InfoError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -InfoError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -InfoError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -InfoError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - InfoError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - InfoError::Unknown(ref s) => return write!(f, "{}", s), - InfoError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for InfoError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - InfoError::MalformedResponse(_, ref e) => Some(e), - InfoError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct ListRequest<'a> { - /// Filter files created by a single user. - pub user: Option<&'a str>, - /// Filter files appearing in a specific channel, indicated by its ID. - pub channel: Option<&'a str>, - /// Filter files created after this timestamp (inclusive). - pub ts_from: Option, - /// Filter files created before this timestamp (inclusive). - pub ts_to: Option, - /// Filter files by type: - /// - /// - /// all - All files - /// spaces - Posts - /// snippets - Snippets - /// images - Image files - /// gdocs - Google docs - /// zips - Zip files - /// pdfs - PDF files - /// - /// - /// You can pass multiple values in the types argument, like types=spaces,snippets.The default value is all, which does not filter the list. - pub types: Option<&'a str>, - /// Number of items to return per page. - pub count: Option, - /// Page number of results to return. - pub page: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponse { - error: Option, - pub files: Option>, - #[serde(default)] - ok: bool, - pub paging: Option, -} - -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ListError { - /// Value passed for user was invalid - UserNotFound, - /// Value passed for types was invalid - UnknownType, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ListError { - fn from(s: &'a str) -> Self { - match s { - "user_not_found" => ListError::UserNotFound, - "unknown_type" => ListError::UnknownType, - "not_authed" => ListError::NotAuthed, - "invalid_auth" => ListError::InvalidAuth, - "account_inactive" => ListError::AccountInactive, - "user_is_bot" => ListError::UserIsBot, - "invalid_arg_name" => ListError::InvalidArgName, - "invalid_array_arg" => ListError::InvalidArrayArg, - "invalid_charset" => ListError::InvalidCharset, - "invalid_form_data" => ListError::InvalidFormData, - "invalid_post_type" => ListError::InvalidPostType, - "missing_post_type" => ListError::MissingPostType, - "team_added_to_org" => ListError::TeamAddedToOrg, - "request_timeout" => ListError::RequestTimeout, - _ => ListError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for ListError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ListError::UserNotFound => "user_not_found: Value passed for user was invalid", -ListError::UnknownType => "unknown_type: Value passed for types was invalid", -ListError::NotAuthed => "not_authed: No authentication token provided.", -ListError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ListError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ListError::Unknown(ref s) => return write!(f, "{}", s), - ListError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for ListError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ListError::MalformedResponse(_, ref e) => Some(e), - ListError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct RevokePublicURLRequest<'a> { - /// File to revoke - pub file: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct RevokePublicURLResponse { - error: Option, - pub file: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> - for RevokePublicURLResponse -{ - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum RevokePublicURLError { - /// Value passed for file was invalid - FileNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for RevokePublicURLError { - fn from(s: &'a str) -> Self { - match s { - "file_not_found" => RevokePublicURLError::FileNotFound, - "not_authed" => RevokePublicURLError::NotAuthed, - "invalid_auth" => RevokePublicURLError::InvalidAuth, - "account_inactive" => RevokePublicURLError::AccountInactive, - "user_is_bot" => RevokePublicURLError::UserIsBot, - "user_is_restricted" => RevokePublicURLError::UserIsRestricted, - "invalid_arg_name" => RevokePublicURLError::InvalidArgName, - "invalid_array_arg" => RevokePublicURLError::InvalidArrayArg, - "invalid_charset" => RevokePublicURLError::InvalidCharset, - "invalid_form_data" => RevokePublicURLError::InvalidFormData, - "invalid_post_type" => RevokePublicURLError::InvalidPostType, - "missing_post_type" => RevokePublicURLError::MissingPostType, - "team_added_to_org" => RevokePublicURLError::TeamAddedToOrg, - "request_timeout" => RevokePublicURLError::RequestTimeout, - _ => RevokePublicURLError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for RevokePublicURLError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - RevokePublicURLError::FileNotFound => "file_not_found: Value passed for file was invalid", -RevokePublicURLError::NotAuthed => "not_authed: No authentication token provided.", -RevokePublicURLError::InvalidAuth => "invalid_auth: Invalid authentication token.", -RevokePublicURLError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -RevokePublicURLError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -RevokePublicURLError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -RevokePublicURLError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -RevokePublicURLError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -RevokePublicURLError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -RevokePublicURLError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -RevokePublicURLError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -RevokePublicURLError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -RevokePublicURLError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -RevokePublicURLError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - RevokePublicURLError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - RevokePublicURLError::Unknown(ref s) => return write!(f, "{}", s), - RevokePublicURLError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for RevokePublicURLError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - RevokePublicURLError::MalformedResponse(_, ref e) => Some(e), - RevokePublicURLError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct SharedPublicURLRequest<'a> { - /// File to share - pub file: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct SharedPublicURLResponse { - error: Option, - pub file: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> - for SharedPublicURLResponse -{ - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum SharedPublicURLError { - /// Value passed for file was invalid - FileNotFound, - /// Public sharing has been disabled for this team - NotAllowed, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for SharedPublicURLError { - fn from(s: &'a str) -> Self { - match s { - "file_not_found" => SharedPublicURLError::FileNotFound, - "not_allowed" => SharedPublicURLError::NotAllowed, - "not_authed" => SharedPublicURLError::NotAuthed, - "invalid_auth" => SharedPublicURLError::InvalidAuth, - "account_inactive" => SharedPublicURLError::AccountInactive, - "user_is_bot" => SharedPublicURLError::UserIsBot, - "user_is_restricted" => SharedPublicURLError::UserIsRestricted, - "invalid_arg_name" => SharedPublicURLError::InvalidArgName, - "invalid_array_arg" => SharedPublicURLError::InvalidArrayArg, - "invalid_charset" => SharedPublicURLError::InvalidCharset, - "invalid_form_data" => SharedPublicURLError::InvalidFormData, - "invalid_post_type" => SharedPublicURLError::InvalidPostType, - "missing_post_type" => SharedPublicURLError::MissingPostType, - "team_added_to_org" => SharedPublicURLError::TeamAddedToOrg, - "request_timeout" => SharedPublicURLError::RequestTimeout, - _ => SharedPublicURLError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for SharedPublicURLError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - SharedPublicURLError::FileNotFound => "file_not_found: Value passed for file was invalid", -SharedPublicURLError::NotAllowed => "not_allowed: Public sharing has been disabled for this team", -SharedPublicURLError::NotAuthed => "not_authed: No authentication token provided.", -SharedPublicURLError::InvalidAuth => "invalid_auth: Invalid authentication token.", -SharedPublicURLError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -SharedPublicURLError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -SharedPublicURLError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -SharedPublicURLError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -SharedPublicURLError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -SharedPublicURLError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -SharedPublicURLError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -SharedPublicURLError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -SharedPublicURLError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -SharedPublicURLError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -SharedPublicURLError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - SharedPublicURLError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - SharedPublicURLError::Unknown(ref s) => return write!(f, "{}", s), - SharedPublicURLError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for SharedPublicURLError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - SharedPublicURLError::MalformedResponse(_, ref e) => Some(e), - SharedPublicURLError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/groups_types.rs b/src/mod_types/groups_types.rs deleted file mode 100644 index 2ee4de1e..00000000 --- a/src/mod_types/groups_types.rs +++ /dev/null @@ -1,2143 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -//! Get info on your team's private channels. - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct ArchiveRequest<'a> { - /// Private channel to archive - pub channel: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct ArchiveResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for ArchiveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ArchiveError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Group has already been archived. - AlreadyArchived, - /// Multi-channel guests cannot archive groups containing others. - GroupContainsOthers, - /// A team preference prevents the authenticated user from archiving. - RestrictedAction, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a single channel guest. - UserIsUltraRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ArchiveError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => ArchiveError::ChannelNotFound, - "already_archived" => ArchiveError::AlreadyArchived, - "group_contains_others" => ArchiveError::GroupContainsOthers, - "restricted_action" => ArchiveError::RestrictedAction, - "not_authed" => ArchiveError::NotAuthed, - "invalid_auth" => ArchiveError::InvalidAuth, - "account_inactive" => ArchiveError::AccountInactive, - "user_is_bot" => ArchiveError::UserIsBot, - "user_is_ultra_restricted" => ArchiveError::UserIsUltraRestricted, - "invalid_arg_name" => ArchiveError::InvalidArgName, - "invalid_array_arg" => ArchiveError::InvalidArrayArg, - "invalid_charset" => ArchiveError::InvalidCharset, - "invalid_form_data" => ArchiveError::InvalidFormData, - "invalid_post_type" => ArchiveError::InvalidPostType, - "missing_post_type" => ArchiveError::MissingPostType, - "team_added_to_org" => ArchiveError::TeamAddedToOrg, - "request_timeout" => ArchiveError::RequestTimeout, - _ => ArchiveError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for ArchiveError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ArchiveError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -ArchiveError::AlreadyArchived => "already_archived: Group has already been archived.", -ArchiveError::GroupContainsOthers => "group_contains_others: Multi-channel guests cannot archive groups containing others.", -ArchiveError::RestrictedAction => "restricted_action: A team preference prevents the authenticated user from archiving.", -ArchiveError::NotAuthed => "not_authed: No authentication token provided.", -ArchiveError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ArchiveError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ArchiveError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -ArchiveError::UserIsUltraRestricted => "user_is_ultra_restricted: This method cannot be called by a single channel guest.", -ArchiveError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ArchiveError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ArchiveError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ArchiveError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ArchiveError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ArchiveError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ArchiveError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ArchiveError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ArchiveError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ArchiveError::Unknown(ref s) => return write!(f, "{}", s), - ArchiveError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for ArchiveError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ArchiveError::MalformedResponse(_, ref e) => Some(e), - ArchiveError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct CloseRequest<'a> { - /// Private channel to close. - pub channel: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct CloseResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for CloseResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum CloseError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for CloseError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => CloseError::ChannelNotFound, - "not_authed" => CloseError::NotAuthed, - "invalid_auth" => CloseError::InvalidAuth, - "account_inactive" => CloseError::AccountInactive, - "invalid_arg_name" => CloseError::InvalidArgName, - "invalid_array_arg" => CloseError::InvalidArrayArg, - "invalid_charset" => CloseError::InvalidCharset, - "invalid_form_data" => CloseError::InvalidFormData, - "invalid_post_type" => CloseError::InvalidPostType, - "missing_post_type" => CloseError::MissingPostType, - "team_added_to_org" => CloseError::TeamAddedToOrg, - "request_timeout" => CloseError::RequestTimeout, - _ => CloseError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for CloseError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - CloseError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -CloseError::NotAuthed => "not_authed: No authentication token provided.", -CloseError::InvalidAuth => "invalid_auth: Invalid authentication token.", -CloseError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -CloseError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -CloseError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -CloseError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -CloseError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -CloseError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -CloseError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -CloseError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -CloseError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - CloseError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - CloseError::Unknown(ref s) => return write!(f, "{}", s), - CloseError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for CloseError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - CloseError::MalformedResponse(_, ref e) => Some(e), - CloseError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct CreateRequest<'a> { - /// Name of private channel to create - pub name: &'a str, - /// Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. - pub validate: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct CreateResponse { - error: Option, - pub group: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for CreateResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum CreateError { - /// No group name was passed. - NoChannel, - /// A team preference prevents the authenticated user from creating groups. - RestrictedAction, - /// A group cannot be created with the given name. - NameTaken, - /// Value passed for name was empty. - InvalidNameRequired, - /// Value passed for name contained only punctuation. - InvalidNamePunctuation, - /// Value passed for name exceeded max length. - InvalidNameMaxlength, - /// Value passed for name contained unallowed special characters or upper case characters. - InvalidNameSpecials, - /// Value passed for name was invalid. - InvalidName, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a single channel guest. - UserIsUltraRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for CreateError { - fn from(s: &'a str) -> Self { - match s { - "no_channel" => CreateError::NoChannel, - "restricted_action" => CreateError::RestrictedAction, - "name_taken" => CreateError::NameTaken, - "invalid_name_required" => CreateError::InvalidNameRequired, - "invalid_name_punctuation" => CreateError::InvalidNamePunctuation, - "invalid_name_maxlength" => CreateError::InvalidNameMaxlength, - "invalid_name_specials" => CreateError::InvalidNameSpecials, - "invalid_name" => CreateError::InvalidName, - "not_authed" => CreateError::NotAuthed, - "invalid_auth" => CreateError::InvalidAuth, - "account_inactive" => CreateError::AccountInactive, - "user_is_bot" => CreateError::UserIsBot, - "user_is_ultra_restricted" => CreateError::UserIsUltraRestricted, - "invalid_arg_name" => CreateError::InvalidArgName, - "invalid_array_arg" => CreateError::InvalidArrayArg, - "invalid_charset" => CreateError::InvalidCharset, - "invalid_form_data" => CreateError::InvalidFormData, - "invalid_post_type" => CreateError::InvalidPostType, - "missing_post_type" => CreateError::MissingPostType, - "team_added_to_org" => CreateError::TeamAddedToOrg, - "request_timeout" => CreateError::RequestTimeout, - _ => CreateError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for CreateError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - CreateError::NoChannel => "no_channel: No group name was passed.", -CreateError::RestrictedAction => "restricted_action: A team preference prevents the authenticated user from creating groups.", -CreateError::NameTaken => "name_taken: A group cannot be created with the given name.", -CreateError::InvalidNameRequired => "invalid_name_required: Value passed for name was empty.", -CreateError::InvalidNamePunctuation => "invalid_name_punctuation: Value passed for name contained only punctuation.", -CreateError::InvalidNameMaxlength => "invalid_name_maxlength: Value passed for name exceeded max length.", -CreateError::InvalidNameSpecials => "invalid_name_specials: Value passed for name contained unallowed special characters or upper case characters.", -CreateError::InvalidName => "invalid_name: Value passed for name was invalid.", -CreateError::NotAuthed => "not_authed: No authentication token provided.", -CreateError::InvalidAuth => "invalid_auth: Invalid authentication token.", -CreateError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -CreateError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -CreateError::UserIsUltraRestricted => "user_is_ultra_restricted: This method cannot be called by a single channel guest.", -CreateError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -CreateError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -CreateError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -CreateError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -CreateError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -CreateError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -CreateError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -CreateError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - CreateError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - CreateError::Unknown(ref s) => return write!(f, "{}", s), - CreateError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for CreateError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - CreateError::MalformedResponse(_, ref e) => Some(e), - CreateError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct CreateChildRequest<'a> { - /// Private channel to clone and archive. - pub channel: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct CreateChildResponse { - error: Option, - pub group: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for CreateChildResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum CreateChildError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// An archived group cannot be cloned - AlreadyArchived, - /// A team preference prevents the authenticated user from creating groups. - RestrictedAction, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a single channel guest. - UserIsUltraRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for CreateChildError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => CreateChildError::ChannelNotFound, - "already_archived" => CreateChildError::AlreadyArchived, - "restricted_action" => CreateChildError::RestrictedAction, - "not_authed" => CreateChildError::NotAuthed, - "invalid_auth" => CreateChildError::InvalidAuth, - "account_inactive" => CreateChildError::AccountInactive, - "user_is_bot" => CreateChildError::UserIsBot, - "user_is_ultra_restricted" => CreateChildError::UserIsUltraRestricted, - "invalid_arg_name" => CreateChildError::InvalidArgName, - "invalid_array_arg" => CreateChildError::InvalidArrayArg, - "invalid_charset" => CreateChildError::InvalidCharset, - "invalid_form_data" => CreateChildError::InvalidFormData, - "invalid_post_type" => CreateChildError::InvalidPostType, - "missing_post_type" => CreateChildError::MissingPostType, - "team_added_to_org" => CreateChildError::TeamAddedToOrg, - "request_timeout" => CreateChildError::RequestTimeout, - _ => CreateChildError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for CreateChildError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - CreateChildError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -CreateChildError::AlreadyArchived => "already_archived: An archived group cannot be cloned", -CreateChildError::RestrictedAction => "restricted_action: A team preference prevents the authenticated user from creating groups.", -CreateChildError::NotAuthed => "not_authed: No authentication token provided.", -CreateChildError::InvalidAuth => "invalid_auth: Invalid authentication token.", -CreateChildError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -CreateChildError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -CreateChildError::UserIsUltraRestricted => "user_is_ultra_restricted: This method cannot be called by a single channel guest.", -CreateChildError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -CreateChildError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -CreateChildError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -CreateChildError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -CreateChildError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -CreateChildError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -CreateChildError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -CreateChildError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - CreateChildError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - CreateChildError::Unknown(ref s) => return write!(f, "{}", s), - CreateChildError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for CreateChildError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - CreateChildError::MalformedResponse(_, ref e) => Some(e), - CreateChildError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct HistoryRequest<'a> { - /// Private channel to fetch history for. - pub channel: &'a str, - /// End of time range of messages to include in results. - pub latest: Option, - /// Start of time range of messages to include in results. - pub oldest: Option, - /// Include messages with latest or oldest timestamp in results. - pub inclusive: Option, - /// Number of messages to return, between 1 and 1000. - pub count: Option, - /// Include unread_count_display in the output? - pub unreads: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct HistoryResponse { - error: Option, - pub has_more: Option, - pub latest: Option, - pub messages: Option>, - #[serde(default)] - ok: bool, -} - -impl Into>> for HistoryResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum HistoryError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Value passed for latest was invalid - InvalidTsLatest, - /// Value passed for oldest was invalid - InvalidTsOldest, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for HistoryError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => HistoryError::ChannelNotFound, - "invalid_ts_latest" => HistoryError::InvalidTsLatest, - "invalid_ts_oldest" => HistoryError::InvalidTsOldest, - "not_authed" => HistoryError::NotAuthed, - "invalid_auth" => HistoryError::InvalidAuth, - "account_inactive" => HistoryError::AccountInactive, - "invalid_arg_name" => HistoryError::InvalidArgName, - "invalid_array_arg" => HistoryError::InvalidArrayArg, - "invalid_charset" => HistoryError::InvalidCharset, - "invalid_form_data" => HistoryError::InvalidFormData, - "invalid_post_type" => HistoryError::InvalidPostType, - "missing_post_type" => HistoryError::MissingPostType, - "team_added_to_org" => HistoryError::TeamAddedToOrg, - "request_timeout" => HistoryError::RequestTimeout, - _ => HistoryError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for HistoryError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - HistoryError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -HistoryError::InvalidTsLatest => "invalid_ts_latest: Value passed for latest was invalid", -HistoryError::InvalidTsOldest => "invalid_ts_oldest: Value passed for oldest was invalid", -HistoryError::NotAuthed => "not_authed: No authentication token provided.", -HistoryError::InvalidAuth => "invalid_auth: Invalid authentication token.", -HistoryError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -HistoryError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -HistoryError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -HistoryError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -HistoryError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -HistoryError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -HistoryError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -HistoryError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -HistoryError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - HistoryError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - HistoryError::Unknown(ref s) => return write!(f, "{}", s), - HistoryError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for HistoryError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - HistoryError::MalformedResponse(_, ref e) => Some(e), - HistoryError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct InfoRequest<'a> { - /// Private channel to get info on - pub channel: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct InfoResponse { - error: Option, - pub group: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum InfoError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for InfoError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => InfoError::ChannelNotFound, - "not_authed" => InfoError::NotAuthed, - "invalid_auth" => InfoError::InvalidAuth, - "account_inactive" => InfoError::AccountInactive, - "invalid_arg_name" => InfoError::InvalidArgName, - "invalid_array_arg" => InfoError::InvalidArrayArg, - "invalid_charset" => InfoError::InvalidCharset, - "invalid_form_data" => InfoError::InvalidFormData, - "invalid_post_type" => InfoError::InvalidPostType, - "missing_post_type" => InfoError::MissingPostType, - "team_added_to_org" => InfoError::TeamAddedToOrg, - "request_timeout" => InfoError::RequestTimeout, - _ => InfoError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for InfoError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - InfoError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -InfoError::NotAuthed => "not_authed: No authentication token provided.", -InfoError::InvalidAuth => "invalid_auth: Invalid authentication token.", -InfoError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -InfoError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -InfoError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -InfoError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -InfoError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -InfoError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -InfoError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -InfoError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -InfoError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - InfoError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - InfoError::Unknown(ref s) => return write!(f, "{}", s), - InfoError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for InfoError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - InfoError::MalformedResponse(_, ref e) => Some(e), - InfoError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct InviteRequest<'a> { - /// Private channel to invite user to. - pub channel: &'a str, - /// User to invite. - pub user: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct InviteResponse { - error: Option, - pub group: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for InviteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum InviteError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Value passed for user was invalid. - UserNotFound, - /// Authenticated user cannot invite themselves to a group. - CantInviteSelf, - /// Group has been archived. - IsArchived, - /// User cannot be invited to this group. - CantInvite, - /// URA is already in the maximum number of channels. - UraMaxChannels, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a single channel guest. - UserIsUltraRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for InviteError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => InviteError::ChannelNotFound, - "user_not_found" => InviteError::UserNotFound, - "cant_invite_self" => InviteError::CantInviteSelf, - "is_archived" => InviteError::IsArchived, - "cant_invite" => InviteError::CantInvite, - "ura_max_channels" => InviteError::UraMaxChannels, - "not_authed" => InviteError::NotAuthed, - "invalid_auth" => InviteError::InvalidAuth, - "account_inactive" => InviteError::AccountInactive, - "user_is_bot" => InviteError::UserIsBot, - "user_is_ultra_restricted" => InviteError::UserIsUltraRestricted, - "invalid_arg_name" => InviteError::InvalidArgName, - "invalid_array_arg" => InviteError::InvalidArrayArg, - "invalid_charset" => InviteError::InvalidCharset, - "invalid_form_data" => InviteError::InvalidFormData, - "invalid_post_type" => InviteError::InvalidPostType, - "missing_post_type" => InviteError::MissingPostType, - "team_added_to_org" => InviteError::TeamAddedToOrg, - "request_timeout" => InviteError::RequestTimeout, - _ => InviteError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for InviteError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - InviteError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -InviteError::UserNotFound => "user_not_found: Value passed for user was invalid.", -InviteError::CantInviteSelf => "cant_invite_self: Authenticated user cannot invite themselves to a group.", -InviteError::IsArchived => "is_archived: Group has been archived.", -InviteError::CantInvite => "cant_invite: User cannot be invited to this group.", -InviteError::UraMaxChannels => "ura_max_channels: URA is already in the maximum number of channels.", -InviteError::NotAuthed => "not_authed: No authentication token provided.", -InviteError::InvalidAuth => "invalid_auth: Invalid authentication token.", -InviteError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -InviteError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -InviteError::UserIsUltraRestricted => "user_is_ultra_restricted: This method cannot be called by a single channel guest.", -InviteError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -InviteError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -InviteError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -InviteError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -InviteError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -InviteError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -InviteError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -InviteError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - InviteError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - InviteError::Unknown(ref s) => return write!(f, "{}", s), - InviteError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for InviteError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - InviteError::MalformedResponse(_, ref e) => Some(e), - InviteError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct KickRequest<'a> { - /// Private channel to remove user from. - pub channel: &'a str, - /// User to remove from private channel. - pub user: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct KickResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for KickResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum KickError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Value passed for user was invalid. - UserNotFound, - /// You can't remove yourself from a group - CantKickSelf, - /// User or caller were are not in the group - NotInGroup, - /// A team preference prevents the authenticated user from kicking. - RestrictedAction, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for KickError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => KickError::ChannelNotFound, - "user_not_found" => KickError::UserNotFound, - "cant_kick_self" => KickError::CantKickSelf, - "not_in_group" => KickError::NotInGroup, - "restricted_action" => KickError::RestrictedAction, - "not_authed" => KickError::NotAuthed, - "invalid_auth" => KickError::InvalidAuth, - "account_inactive" => KickError::AccountInactive, - "user_is_bot" => KickError::UserIsBot, - "user_is_restricted" => KickError::UserIsRestricted, - "invalid_arg_name" => KickError::InvalidArgName, - "invalid_array_arg" => KickError::InvalidArrayArg, - "invalid_charset" => KickError::InvalidCharset, - "invalid_form_data" => KickError::InvalidFormData, - "invalid_post_type" => KickError::InvalidPostType, - "missing_post_type" => KickError::MissingPostType, - "team_added_to_org" => KickError::TeamAddedToOrg, - "request_timeout" => KickError::RequestTimeout, - _ => KickError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for KickError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - KickError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -KickError::UserNotFound => "user_not_found: Value passed for user was invalid.", -KickError::CantKickSelf => "cant_kick_self: You can't remove yourself from a group", -KickError::NotInGroup => "not_in_group: User or caller were are not in the group", -KickError::RestrictedAction => "restricted_action: A team preference prevents the authenticated user from kicking.", -KickError::NotAuthed => "not_authed: No authentication token provided.", -KickError::InvalidAuth => "invalid_auth: Invalid authentication token.", -KickError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -KickError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -KickError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -KickError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -KickError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -KickError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -KickError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -KickError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -KickError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -KickError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -KickError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - KickError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - KickError::Unknown(ref s) => return write!(f, "{}", s), - KickError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for KickError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - KickError::MalformedResponse(_, ref e) => Some(e), - KickError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct LeaveRequest<'a> { - /// Private channel to leave - pub channel: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct LeaveResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for LeaveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum LeaveError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Group has been archived. - IsArchived, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a single channel guest. - UserIsUltraRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for LeaveError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => LeaveError::ChannelNotFound, - "is_archived" => LeaveError::IsArchived, - "not_authed" => LeaveError::NotAuthed, - "invalid_auth" => LeaveError::InvalidAuth, - "account_inactive" => LeaveError::AccountInactive, - "user_is_bot" => LeaveError::UserIsBot, - "user_is_ultra_restricted" => LeaveError::UserIsUltraRestricted, - "invalid_arg_name" => LeaveError::InvalidArgName, - "invalid_array_arg" => LeaveError::InvalidArrayArg, - "invalid_charset" => LeaveError::InvalidCharset, - "invalid_form_data" => LeaveError::InvalidFormData, - "invalid_post_type" => LeaveError::InvalidPostType, - "missing_post_type" => LeaveError::MissingPostType, - "team_added_to_org" => LeaveError::TeamAddedToOrg, - "request_timeout" => LeaveError::RequestTimeout, - _ => LeaveError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for LeaveError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - LeaveError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -LeaveError::IsArchived => "is_archived: Group has been archived.", -LeaveError::NotAuthed => "not_authed: No authentication token provided.", -LeaveError::InvalidAuth => "invalid_auth: Invalid authentication token.", -LeaveError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -LeaveError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -LeaveError::UserIsUltraRestricted => "user_is_ultra_restricted: This method cannot be called by a single channel guest.", -LeaveError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -LeaveError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -LeaveError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -LeaveError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -LeaveError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -LeaveError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -LeaveError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -LeaveError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - LeaveError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - LeaveError::Unknown(ref s) => return write!(f, "{}", s), - LeaveError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for LeaveError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - LeaveError::MalformedResponse(_, ref e) => Some(e), - LeaveError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct ListRequest { - /// Don't return archived private channels. - pub exclude_archived: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponse { - error: Option, - pub groups: Option>, - #[serde(default)] - ok: bool, -} - -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ListError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ListError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => ListError::NotAuthed, - "invalid_auth" => ListError::InvalidAuth, - "account_inactive" => ListError::AccountInactive, - "invalid_arg_name" => ListError::InvalidArgName, - "invalid_array_arg" => ListError::InvalidArrayArg, - "invalid_charset" => ListError::InvalidCharset, - "invalid_form_data" => ListError::InvalidFormData, - "invalid_post_type" => ListError::InvalidPostType, - "missing_post_type" => ListError::MissingPostType, - "team_added_to_org" => ListError::TeamAddedToOrg, - "request_timeout" => ListError::RequestTimeout, - _ => ListError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for ListError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ListError::NotAuthed => "not_authed: No authentication token provided.", -ListError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ListError::Unknown(ref s) => return write!(f, "{}", s), - ListError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for ListError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ListError::MalformedResponse(_, ref e) => Some(e), - ListError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct MarkRequest<'a> { - /// Private channel to set reading cursor in. - pub channel: &'a str, - /// Timestamp of the most recently seen message. - pub ts: crate::Timestamp, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct MarkResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for MarkResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum MarkError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Value passed for timestamp was invalid. - InvalidTimestamp, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for MarkError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => MarkError::ChannelNotFound, - "invalid_timestamp" => MarkError::InvalidTimestamp, - "not_authed" => MarkError::NotAuthed, - "invalid_auth" => MarkError::InvalidAuth, - "account_inactive" => MarkError::AccountInactive, - "invalid_arg_name" => MarkError::InvalidArgName, - "invalid_array_arg" => MarkError::InvalidArrayArg, - "invalid_charset" => MarkError::InvalidCharset, - "invalid_form_data" => MarkError::InvalidFormData, - "invalid_post_type" => MarkError::InvalidPostType, - "missing_post_type" => MarkError::MissingPostType, - "team_added_to_org" => MarkError::TeamAddedToOrg, - "request_timeout" => MarkError::RequestTimeout, - _ => MarkError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for MarkError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - MarkError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -MarkError::InvalidTimestamp => "invalid_timestamp: Value passed for timestamp was invalid.", -MarkError::NotAuthed => "not_authed: No authentication token provided.", -MarkError::InvalidAuth => "invalid_auth: Invalid authentication token.", -MarkError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -MarkError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -MarkError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -MarkError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -MarkError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -MarkError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -MarkError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -MarkError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -MarkError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - MarkError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - MarkError::Unknown(ref s) => return write!(f, "{}", s), - MarkError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for MarkError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - MarkError::MalformedResponse(_, ref e) => Some(e), - MarkError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct OpenRequest<'a> { - /// Private channel to open. - pub channel: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct OpenResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for OpenResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum OpenError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for OpenError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => OpenError::ChannelNotFound, - "not_authed" => OpenError::NotAuthed, - "invalid_auth" => OpenError::InvalidAuth, - "account_inactive" => OpenError::AccountInactive, - "invalid_arg_name" => OpenError::InvalidArgName, - "invalid_array_arg" => OpenError::InvalidArrayArg, - "invalid_charset" => OpenError::InvalidCharset, - "invalid_form_data" => OpenError::InvalidFormData, - "invalid_post_type" => OpenError::InvalidPostType, - "missing_post_type" => OpenError::MissingPostType, - "team_added_to_org" => OpenError::TeamAddedToOrg, - "request_timeout" => OpenError::RequestTimeout, - _ => OpenError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for OpenError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - OpenError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -OpenError::NotAuthed => "not_authed: No authentication token provided.", -OpenError::InvalidAuth => "invalid_auth: Invalid authentication token.", -OpenError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -OpenError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -OpenError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -OpenError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -OpenError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -OpenError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -OpenError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -OpenError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -OpenError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - OpenError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - OpenError::Unknown(ref s) => return write!(f, "{}", s), - OpenError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for OpenError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - OpenError::MalformedResponse(_, ref e) => Some(e), - OpenError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct RenameRequest<'a> { - /// Private channel to rename - pub channel: &'a str, - /// New name for private channel. - pub name: &'a str, - /// Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria. - pub validate: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct RenameResponse { - pub channel: Option, - error: Option, - #[serde(default)] - ok: bool, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct RenameResponseChannel { - pub created: Option, - pub id: Option, - pub is_group: Option, - pub name: Option, -} - -impl Into>> for RenameResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum RenameError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Value passed for name was invalid. - InvalidName, - /// New channel name is taken - NameTaken, - /// Value passed for name was empty. - InvalidNameRequired, - /// Value passed for name contained only punctuation. - InvalidNamePunctuation, - /// Value passed for name exceeded max length. - InvalidNameMaxlength, - /// Value passed for name contained unallowed special characters or upper case characters. - InvalidNameSpecials, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for RenameError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => RenameError::ChannelNotFound, - "invalid_name" => RenameError::InvalidName, - "name_taken" => RenameError::NameTaken, - "invalid_name_required" => RenameError::InvalidNameRequired, - "invalid_name_punctuation" => RenameError::InvalidNamePunctuation, - "invalid_name_maxlength" => RenameError::InvalidNameMaxlength, - "invalid_name_specials" => RenameError::InvalidNameSpecials, - "not_authed" => RenameError::NotAuthed, - "invalid_auth" => RenameError::InvalidAuth, - "account_inactive" => RenameError::AccountInactive, - "user_is_bot" => RenameError::UserIsBot, - "user_is_restricted" => RenameError::UserIsRestricted, - "invalid_arg_name" => RenameError::InvalidArgName, - "invalid_array_arg" => RenameError::InvalidArrayArg, - "invalid_charset" => RenameError::InvalidCharset, - "invalid_form_data" => RenameError::InvalidFormData, - "invalid_post_type" => RenameError::InvalidPostType, - "missing_post_type" => RenameError::MissingPostType, - "team_added_to_org" => RenameError::TeamAddedToOrg, - "request_timeout" => RenameError::RequestTimeout, - _ => RenameError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for RenameError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - RenameError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -RenameError::InvalidName => "invalid_name: Value passed for name was invalid.", -RenameError::NameTaken => "name_taken: New channel name is taken", -RenameError::InvalidNameRequired => "invalid_name_required: Value passed for name was empty.", -RenameError::InvalidNamePunctuation => "invalid_name_punctuation: Value passed for name contained only punctuation.", -RenameError::InvalidNameMaxlength => "invalid_name_maxlength: Value passed for name exceeded max length.", -RenameError::InvalidNameSpecials => "invalid_name_specials: Value passed for name contained unallowed special characters or upper case characters.", -RenameError::NotAuthed => "not_authed: No authentication token provided.", -RenameError::InvalidAuth => "invalid_auth: Invalid authentication token.", -RenameError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -RenameError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -RenameError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -RenameError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -RenameError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -RenameError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -RenameError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -RenameError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -RenameError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -RenameError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -RenameError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - RenameError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - RenameError::Unknown(ref s) => return write!(f, "{}", s), - RenameError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for RenameError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - RenameError::MalformedResponse(_, ref e) => Some(e), - RenameError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct RepliesRequest<'a> { - /// Private channel to fetch thread from - pub channel: &'a str, - /// Unique identifier of a thread's parent message - pub thread_ts: crate::Timestamp, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct RepliesResponse { - error: Option, - pub messages: Option>, - #[serde(default)] - ok: bool, - pub thread_info: Option, -} - -impl Into>> for RepliesResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum RepliesError { - /// Value for channel was missing or invalid. - ChannelNotFound, - /// Value for thread_ts was missing or invalid. - ThreadNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for RepliesError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => RepliesError::ChannelNotFound, - "thread_not_found" => RepliesError::ThreadNotFound, - "not_authed" => RepliesError::NotAuthed, - "invalid_auth" => RepliesError::InvalidAuth, - "account_inactive" => RepliesError::AccountInactive, - "user_is_bot" => RepliesError::UserIsBot, - "invalid_arg_name" => RepliesError::InvalidArgName, - "invalid_array_arg" => RepliesError::InvalidArrayArg, - "invalid_charset" => RepliesError::InvalidCharset, - "invalid_form_data" => RepliesError::InvalidFormData, - "invalid_post_type" => RepliesError::InvalidPostType, - "missing_post_type" => RepliesError::MissingPostType, - "team_added_to_org" => RepliesError::TeamAddedToOrg, - "request_timeout" => RepliesError::RequestTimeout, - _ => RepliesError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for RepliesError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - RepliesError::ChannelNotFound => "channel_not_found: Value for channel was missing or invalid.", -RepliesError::ThreadNotFound => "thread_not_found: Value for thread_ts was missing or invalid.", -RepliesError::NotAuthed => "not_authed: No authentication token provided.", -RepliesError::InvalidAuth => "invalid_auth: Invalid authentication token.", -RepliesError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -RepliesError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -RepliesError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -RepliesError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -RepliesError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -RepliesError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -RepliesError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -RepliesError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -RepliesError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -RepliesError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - RepliesError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - RepliesError::Unknown(ref s) => return write!(f, "{}", s), - RepliesError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for RepliesError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - RepliesError::MalformedResponse(_, ref e) => Some(e), - RepliesError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct SetPurposeRequest<'a> { - /// Private channel to set the purpose of - pub channel: &'a str, - /// The new purpose - pub purpose: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct SetPurposeResponse { - error: Option, - #[serde(default)] - ok: bool, - pub purpose: Option, -} - -impl Into>> for SetPurposeResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum SetPurposeError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Private group has been archived - IsArchived, - /// Purpose was longer than 250 characters. - TooLong, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for SetPurposeError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => SetPurposeError::ChannelNotFound, - "is_archived" => SetPurposeError::IsArchived, - "too_long" => SetPurposeError::TooLong, - "user_is_restricted" => SetPurposeError::UserIsRestricted, - "not_authed" => SetPurposeError::NotAuthed, - "invalid_auth" => SetPurposeError::InvalidAuth, - "account_inactive" => SetPurposeError::AccountInactive, - "invalid_arg_name" => SetPurposeError::InvalidArgName, - "invalid_array_arg" => SetPurposeError::InvalidArrayArg, - "invalid_charset" => SetPurposeError::InvalidCharset, - "invalid_form_data" => SetPurposeError::InvalidFormData, - "invalid_post_type" => SetPurposeError::InvalidPostType, - "missing_post_type" => SetPurposeError::MissingPostType, - "team_added_to_org" => SetPurposeError::TeamAddedToOrg, - "request_timeout" => SetPurposeError::RequestTimeout, - _ => SetPurposeError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for SetPurposeError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - SetPurposeError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -SetPurposeError::IsArchived => "is_archived: Private group has been archived", -SetPurposeError::TooLong => "too_long: Purpose was longer than 250 characters.", -SetPurposeError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -SetPurposeError::NotAuthed => "not_authed: No authentication token provided.", -SetPurposeError::InvalidAuth => "invalid_auth: Invalid authentication token.", -SetPurposeError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -SetPurposeError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -SetPurposeError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -SetPurposeError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -SetPurposeError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -SetPurposeError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -SetPurposeError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -SetPurposeError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -SetPurposeError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - SetPurposeError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - SetPurposeError::Unknown(ref s) => return write!(f, "{}", s), - SetPurposeError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for SetPurposeError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - SetPurposeError::MalformedResponse(_, ref e) => Some(e), - SetPurposeError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct SetTopicRequest<'a> { - /// Private channel to set the topic of - pub channel: &'a str, - /// The new topic - pub topic: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct SetTopicResponse { - error: Option, - #[serde(default)] - ok: bool, - pub topic: Option, -} - -impl Into>> for SetTopicResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum SetTopicError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Private group has been archived - IsArchived, - /// Topic was longer than 250 characters. - TooLong, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for SetTopicError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => SetTopicError::ChannelNotFound, - "is_archived" => SetTopicError::IsArchived, - "too_long" => SetTopicError::TooLong, - "user_is_restricted" => SetTopicError::UserIsRestricted, - "not_authed" => SetTopicError::NotAuthed, - "invalid_auth" => SetTopicError::InvalidAuth, - "account_inactive" => SetTopicError::AccountInactive, - "invalid_arg_name" => SetTopicError::InvalidArgName, - "invalid_array_arg" => SetTopicError::InvalidArrayArg, - "invalid_charset" => SetTopicError::InvalidCharset, - "invalid_form_data" => SetTopicError::InvalidFormData, - "invalid_post_type" => SetTopicError::InvalidPostType, - "missing_post_type" => SetTopicError::MissingPostType, - "team_added_to_org" => SetTopicError::TeamAddedToOrg, - "request_timeout" => SetTopicError::RequestTimeout, - _ => SetTopicError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for SetTopicError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - SetTopicError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -SetTopicError::IsArchived => "is_archived: Private group has been archived", -SetTopicError::TooLong => "too_long: Topic was longer than 250 characters.", -SetTopicError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -SetTopicError::NotAuthed => "not_authed: No authentication token provided.", -SetTopicError::InvalidAuth => "invalid_auth: Invalid authentication token.", -SetTopicError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -SetTopicError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -SetTopicError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -SetTopicError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -SetTopicError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -SetTopicError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -SetTopicError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -SetTopicError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -SetTopicError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - SetTopicError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - SetTopicError::Unknown(ref s) => return write!(f, "{}", s), - SetTopicError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for SetTopicError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - SetTopicError::MalformedResponse(_, ref e) => Some(e), - SetTopicError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct UnarchiveRequest<'a> { - /// Private channel to unarchive - pub channel: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct UnarchiveResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for UnarchiveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum UnarchiveError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Group is not archived. - NotArchived, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for UnarchiveError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => UnarchiveError::ChannelNotFound, - "not_archived" => UnarchiveError::NotArchived, - "not_authed" => UnarchiveError::NotAuthed, - "invalid_auth" => UnarchiveError::InvalidAuth, - "account_inactive" => UnarchiveError::AccountInactive, - "user_is_bot" => UnarchiveError::UserIsBot, - "user_is_restricted" => UnarchiveError::UserIsRestricted, - "invalid_arg_name" => UnarchiveError::InvalidArgName, - "invalid_array_arg" => UnarchiveError::InvalidArrayArg, - "invalid_charset" => UnarchiveError::InvalidCharset, - "invalid_form_data" => UnarchiveError::InvalidFormData, - "invalid_post_type" => UnarchiveError::InvalidPostType, - "missing_post_type" => UnarchiveError::MissingPostType, - "team_added_to_org" => UnarchiveError::TeamAddedToOrg, - "request_timeout" => UnarchiveError::RequestTimeout, - _ => UnarchiveError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for UnarchiveError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - UnarchiveError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -UnarchiveError::NotArchived => "not_archived: Group is not archived.", -UnarchiveError::NotAuthed => "not_authed: No authentication token provided.", -UnarchiveError::InvalidAuth => "invalid_auth: Invalid authentication token.", -UnarchiveError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -UnarchiveError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -UnarchiveError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -UnarchiveError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -UnarchiveError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -UnarchiveError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -UnarchiveError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -UnarchiveError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -UnarchiveError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -UnarchiveError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -UnarchiveError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - UnarchiveError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - UnarchiveError::Unknown(ref s) => return write!(f, "{}", s), - UnarchiveError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for UnarchiveError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - UnarchiveError::MalformedResponse(_, ref e) => Some(e), - UnarchiveError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/im_types.rs b/src/mod_types/im_types.rs deleted file mode 100644 index 6aec8bf6..00000000 --- a/src/mod_types/im_types.rs +++ /dev/null @@ -1,732 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -//! Get info on your direct messages. - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct CloseRequest<'a> { - /// Direct message channel to close. - pub channel: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct CloseResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for CloseResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum CloseError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Calling user does not own this DM channel. - UserDoesNotOwnChannel, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for CloseError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => CloseError::ChannelNotFound, - "user_does_not_own_channel" => CloseError::UserDoesNotOwnChannel, - "not_authed" => CloseError::NotAuthed, - "invalid_auth" => CloseError::InvalidAuth, - "account_inactive" => CloseError::AccountInactive, - "invalid_arg_name" => CloseError::InvalidArgName, - "invalid_array_arg" => CloseError::InvalidArrayArg, - "invalid_charset" => CloseError::InvalidCharset, - "invalid_form_data" => CloseError::InvalidFormData, - "invalid_post_type" => CloseError::InvalidPostType, - "missing_post_type" => CloseError::MissingPostType, - "team_added_to_org" => CloseError::TeamAddedToOrg, - "request_timeout" => CloseError::RequestTimeout, - _ => CloseError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for CloseError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - CloseError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -CloseError::UserDoesNotOwnChannel => "user_does_not_own_channel: Calling user does not own this DM channel.", -CloseError::NotAuthed => "not_authed: No authentication token provided.", -CloseError::InvalidAuth => "invalid_auth: Invalid authentication token.", -CloseError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -CloseError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -CloseError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -CloseError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -CloseError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -CloseError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -CloseError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -CloseError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -CloseError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - CloseError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - CloseError::Unknown(ref s) => return write!(f, "{}", s), - CloseError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for CloseError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - CloseError::MalformedResponse(_, ref e) => Some(e), - CloseError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct HistoryRequest<'a> { - /// Direct message channel to fetch history for. - pub channel: &'a str, - /// End of time range of messages to include in results. - pub latest: Option, - /// Start of time range of messages to include in results. - pub oldest: Option, - /// Include messages with latest or oldest timestamp in results. - pub inclusive: Option, - /// Number of messages to return, between 1 and 1000. - pub count: Option, - /// Include unread_count_display in the output? - pub unreads: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct HistoryResponse { - error: Option, - pub has_more: Option, - pub latest: Option, - pub messages: Option>, - #[serde(default)] - ok: bool, -} - -impl Into>> for HistoryResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum HistoryError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Value passed for latest was invalid - InvalidTsLatest, - /// Value passed for oldest was invalid - InvalidTsOldest, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for HistoryError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => HistoryError::ChannelNotFound, - "invalid_ts_latest" => HistoryError::InvalidTsLatest, - "invalid_ts_oldest" => HistoryError::InvalidTsOldest, - "not_authed" => HistoryError::NotAuthed, - "invalid_auth" => HistoryError::InvalidAuth, - "account_inactive" => HistoryError::AccountInactive, - "invalid_arg_name" => HistoryError::InvalidArgName, - "invalid_array_arg" => HistoryError::InvalidArrayArg, - "invalid_charset" => HistoryError::InvalidCharset, - "invalid_form_data" => HistoryError::InvalidFormData, - "invalid_post_type" => HistoryError::InvalidPostType, - "missing_post_type" => HistoryError::MissingPostType, - "team_added_to_org" => HistoryError::TeamAddedToOrg, - "request_timeout" => HistoryError::RequestTimeout, - _ => HistoryError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for HistoryError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - HistoryError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -HistoryError::InvalidTsLatest => "invalid_ts_latest: Value passed for latest was invalid", -HistoryError::InvalidTsOldest => "invalid_ts_oldest: Value passed for oldest was invalid", -HistoryError::NotAuthed => "not_authed: No authentication token provided.", -HistoryError::InvalidAuth => "invalid_auth: Invalid authentication token.", -HistoryError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -HistoryError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -HistoryError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -HistoryError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -HistoryError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -HistoryError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -HistoryError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -HistoryError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -HistoryError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - HistoryError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - HistoryError::Unknown(ref s) => return write!(f, "{}", s), - HistoryError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for HistoryError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - HistoryError::MalformedResponse(_, ref e) => Some(e), - HistoryError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct ListRequest<'a> { - /// Paginate through collections of data by setting the `cursor` parameter to a `next_cursor` attribute returned by a previous request's `response_metadata`. Default value fetches the first "page" of the collection. See pagination for more detail. - pub cursor: Option<&'a str>, - /// The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached. - pub limit: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponse { - error: Option, - pub ims: Option>, - #[serde(default)] - ok: bool, -} - -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ListError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ListError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => ListError::NotAuthed, - "invalid_auth" => ListError::InvalidAuth, - "account_inactive" => ListError::AccountInactive, - "invalid_arg_name" => ListError::InvalidArgName, - "invalid_array_arg" => ListError::InvalidArrayArg, - "invalid_charset" => ListError::InvalidCharset, - "invalid_form_data" => ListError::InvalidFormData, - "invalid_post_type" => ListError::InvalidPostType, - "missing_post_type" => ListError::MissingPostType, - "team_added_to_org" => ListError::TeamAddedToOrg, - "request_timeout" => ListError::RequestTimeout, - _ => ListError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for ListError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ListError::NotAuthed => "not_authed: No authentication token provided.", -ListError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ListError::Unknown(ref s) => return write!(f, "{}", s), - ListError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for ListError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ListError::MalformedResponse(_, ref e) => Some(e), - ListError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct MarkRequest<'a> { - /// Direct message channel to set reading cursor in. - pub channel: &'a str, - /// Timestamp of the most recently seen message. - pub ts: crate::Timestamp, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct MarkResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for MarkResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum MarkError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Value passed for timestamp was invalid. - InvalidTimestamp, - /// Caller is not a member of the channel. - NotInChannel, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for MarkError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => MarkError::ChannelNotFound, - "invalid_timestamp" => MarkError::InvalidTimestamp, - "not_in_channel" => MarkError::NotInChannel, - "not_authed" => MarkError::NotAuthed, - "invalid_auth" => MarkError::InvalidAuth, - "account_inactive" => MarkError::AccountInactive, - "invalid_arg_name" => MarkError::InvalidArgName, - "invalid_array_arg" => MarkError::InvalidArrayArg, - "invalid_charset" => MarkError::InvalidCharset, - "invalid_form_data" => MarkError::InvalidFormData, - "invalid_post_type" => MarkError::InvalidPostType, - "missing_post_type" => MarkError::MissingPostType, - "team_added_to_org" => MarkError::TeamAddedToOrg, - "request_timeout" => MarkError::RequestTimeout, - _ => MarkError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for MarkError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - MarkError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -MarkError::InvalidTimestamp => "invalid_timestamp: Value passed for timestamp was invalid.", -MarkError::NotInChannel => "not_in_channel: Caller is not a member of the channel.", -MarkError::NotAuthed => "not_authed: No authentication token provided.", -MarkError::InvalidAuth => "invalid_auth: Invalid authentication token.", -MarkError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -MarkError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -MarkError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -MarkError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -MarkError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -MarkError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -MarkError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -MarkError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -MarkError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - MarkError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - MarkError::Unknown(ref s) => return write!(f, "{}", s), - MarkError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for MarkError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - MarkError::MalformedResponse(_, ref e) => Some(e), - MarkError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct OpenRequest<'a> { - /// User to open a direct message channel with. - pub user: &'a str, - /// Boolean, indicates you want the full IM channel definition in the response. - pub return_im: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct OpenResponse { - pub channel: Option, - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for OpenResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum OpenError { - /// Value passed for user was invalid. - UserNotFound, - /// The calling user is restricted from seeing the requested user. - UserNotVisible, - /// The user has been disabled. - UserDisabled, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for OpenError { - fn from(s: &'a str) -> Self { - match s { - "user_not_found" => OpenError::UserNotFound, - "user_not_visible" => OpenError::UserNotVisible, - "user_disabled" => OpenError::UserDisabled, - "not_authed" => OpenError::NotAuthed, - "invalid_auth" => OpenError::InvalidAuth, - "account_inactive" => OpenError::AccountInactive, - "invalid_arg_name" => OpenError::InvalidArgName, - "invalid_array_arg" => OpenError::InvalidArrayArg, - "invalid_charset" => OpenError::InvalidCharset, - "invalid_form_data" => OpenError::InvalidFormData, - "invalid_post_type" => OpenError::InvalidPostType, - "missing_post_type" => OpenError::MissingPostType, - "team_added_to_org" => OpenError::TeamAddedToOrg, - "request_timeout" => OpenError::RequestTimeout, - _ => OpenError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for OpenError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - OpenError::UserNotFound => "user_not_found: Value passed for user was invalid.", -OpenError::UserNotVisible => "user_not_visible: The calling user is restricted from seeing the requested user.", -OpenError::UserDisabled => "user_disabled: The user has been disabled.", -OpenError::NotAuthed => "not_authed: No authentication token provided.", -OpenError::InvalidAuth => "invalid_auth: Invalid authentication token.", -OpenError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -OpenError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -OpenError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -OpenError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -OpenError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -OpenError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -OpenError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -OpenError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -OpenError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - OpenError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - OpenError::Unknown(ref s) => return write!(f, "{}", s), - OpenError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for OpenError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - OpenError::MalformedResponse(_, ref e) => Some(e), - OpenError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct RepliesRequest<'a> { - /// Direct message channel to fetch thread from - pub channel: &'a str, - /// Unique identifier of a thread's parent message - pub thread_ts: crate::Timestamp, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct RepliesResponse { - error: Option, - pub messages: Option>, - #[serde(default)] - ok: bool, - pub thread_info: Option, -} - -impl Into>> for RepliesResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum RepliesError { - /// Value for channel was missing or invalid. - ChannelNotFound, - /// Value for thread_ts was missing or invalid. - ThreadNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for RepliesError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => RepliesError::ChannelNotFound, - "thread_not_found" => RepliesError::ThreadNotFound, - "not_authed" => RepliesError::NotAuthed, - "invalid_auth" => RepliesError::InvalidAuth, - "account_inactive" => RepliesError::AccountInactive, - "user_is_bot" => RepliesError::UserIsBot, - "invalid_arg_name" => RepliesError::InvalidArgName, - "invalid_array_arg" => RepliesError::InvalidArrayArg, - "invalid_charset" => RepliesError::InvalidCharset, - "invalid_form_data" => RepliesError::InvalidFormData, - "invalid_post_type" => RepliesError::InvalidPostType, - "missing_post_type" => RepliesError::MissingPostType, - "team_added_to_org" => RepliesError::TeamAddedToOrg, - "request_timeout" => RepliesError::RequestTimeout, - _ => RepliesError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for RepliesError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - RepliesError::ChannelNotFound => "channel_not_found: Value for channel was missing or invalid.", -RepliesError::ThreadNotFound => "thread_not_found: Value for thread_ts was missing or invalid.", -RepliesError::NotAuthed => "not_authed: No authentication token provided.", -RepliesError::InvalidAuth => "invalid_auth: Invalid authentication token.", -RepliesError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -RepliesError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -RepliesError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -RepliesError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -RepliesError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -RepliesError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -RepliesError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -RepliesError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -RepliesError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -RepliesError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - RepliesError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - RepliesError::Unknown(ref s) => return write!(f, "{}", s), - RepliesError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for RepliesError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - RepliesError::MalformedResponse(_, ref e) => Some(e), - RepliesError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/migration_types.rs b/src/mod_types/migration_types.rs new file mode 100644 index 00000000..792cfd55 --- /dev/null +++ b/src/mod_types/migration_types.rs @@ -0,0 +1,20 @@ +pub struct ExchangeRequest { + /// A comma-separated list of user ids, up to 400 per request + pub users: Option, + /// Specify team_id starts with `T` in case of Org Token + pub team_id: String, + /// Specify `true` to convert `W` global user IDs to workspace-specific `U` IDs. Defaults to `false`. + pub to_old: bool, +} + +pub struct ExchangeResponse { + pub callstack: String, + pub enterprise_id: Option, + pub error: String, + pub invalid_user_ids: Vec, + pub ok: Option, + pub team_id: Option, + pub user_id_map: serde_json::Value, +} + +pub struct ExchangeError {} diff --git a/src/mod_types/mod.rs b/src/mod_types/mod.rs index bf58ead8..a5d59b27 100644 --- a/src/mod_types/mod.rs +++ b/src/mod_types/mod.rs @@ -1,25 +1,25 @@ +pub mod admin; pub mod api_types; +pub mod apps; pub mod auth_types; pub mod bots_types; -pub mod channels_types; -pub mod chat_types; +pub mod calls; +pub mod chat; +pub mod conversations_types; +pub mod dialog_types; pub mod dnd_types; pub mod emoji_types; -pub mod files_comments_types; -pub mod files_types; -pub mod groups_types; -pub mod im_types; -pub mod mpim_types; -pub mod oauth_types; +pub mod files; +pub mod migration_types; +pub mod oauth; pub mod pins_types; pub mod reactions_types; pub mod reminders_types; pub mod rtm_types; pub mod search_types; pub mod stars_types; -pub mod team_types; -pub mod team_profile_types; -pub mod usergroups_types; -pub mod usergroups_users_types; -pub mod users_types; -pub mod users_profile_types; \ No newline at end of file +pub mod team; +pub mod usergroups; +pub mod users; +pub mod views_types; +pub mod workflows_types; diff --git a/src/mod_types/mpim_types.rs b/src/mod_types/mpim_types.rs deleted file mode 100644 index e85ae0bf..00000000 --- a/src/mod_types/mpim_types.rs +++ /dev/null @@ -1,714 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -//! Get info on your multiparty direct messages. - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct CloseRequest<'a> { - /// MPIM to close. - pub channel: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct CloseResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for CloseResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum CloseError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for CloseError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => CloseError::ChannelNotFound, - "not_authed" => CloseError::NotAuthed, - "invalid_auth" => CloseError::InvalidAuth, - "account_inactive" => CloseError::AccountInactive, - "invalid_arg_name" => CloseError::InvalidArgName, - "invalid_array_arg" => CloseError::InvalidArrayArg, - "invalid_charset" => CloseError::InvalidCharset, - "invalid_form_data" => CloseError::InvalidFormData, - "invalid_post_type" => CloseError::InvalidPostType, - "missing_post_type" => CloseError::MissingPostType, - "team_added_to_org" => CloseError::TeamAddedToOrg, - "request_timeout" => CloseError::RequestTimeout, - _ => CloseError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for CloseError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - CloseError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -CloseError::NotAuthed => "not_authed: No authentication token provided.", -CloseError::InvalidAuth => "invalid_auth: Invalid authentication token.", -CloseError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -CloseError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -CloseError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -CloseError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -CloseError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -CloseError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -CloseError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -CloseError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -CloseError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - CloseError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - CloseError::Unknown(ref s) => return write!(f, "{}", s), - CloseError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for CloseError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - CloseError::MalformedResponse(_, ref e) => Some(e), - CloseError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct HistoryRequest<'a> { - /// Multiparty direct message to fetch history for. - pub channel: &'a str, - /// End of time range of messages to include in results. - pub latest: Option, - /// Start of time range of messages to include in results. - pub oldest: Option, - /// Include messages with latest or oldest timestamp in results. - pub inclusive: Option, - /// Number of messages to return, between 1 and 1000. - pub count: Option, - /// Include unread_count_display in the output? - pub unreads: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct HistoryResponse { - error: Option, - pub has_more: Option, - pub latest: Option, - pub messages: Option>, - #[serde(default)] - ok: bool, -} - -impl Into>> for HistoryResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum HistoryError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Value passed for latest was invalid - InvalidTsLatest, - /// Value passed for oldest was invalid - InvalidTsOldest, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for HistoryError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => HistoryError::ChannelNotFound, - "invalid_ts_latest" => HistoryError::InvalidTsLatest, - "invalid_ts_oldest" => HistoryError::InvalidTsOldest, - "not_authed" => HistoryError::NotAuthed, - "invalid_auth" => HistoryError::InvalidAuth, - "account_inactive" => HistoryError::AccountInactive, - "invalid_arg_name" => HistoryError::InvalidArgName, - "invalid_array_arg" => HistoryError::InvalidArrayArg, - "invalid_charset" => HistoryError::InvalidCharset, - "invalid_form_data" => HistoryError::InvalidFormData, - "invalid_post_type" => HistoryError::InvalidPostType, - "missing_post_type" => HistoryError::MissingPostType, - "team_added_to_org" => HistoryError::TeamAddedToOrg, - "request_timeout" => HistoryError::RequestTimeout, - _ => HistoryError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for HistoryError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - HistoryError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -HistoryError::InvalidTsLatest => "invalid_ts_latest: Value passed for latest was invalid", -HistoryError::InvalidTsOldest => "invalid_ts_oldest: Value passed for oldest was invalid", -HistoryError::NotAuthed => "not_authed: No authentication token provided.", -HistoryError::InvalidAuth => "invalid_auth: Invalid authentication token.", -HistoryError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -HistoryError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -HistoryError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -HistoryError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -HistoryError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -HistoryError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -HistoryError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -HistoryError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -HistoryError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - HistoryError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - HistoryError::Unknown(ref s) => return write!(f, "{}", s), - HistoryError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for HistoryError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - HistoryError::MalformedResponse(_, ref e) => Some(e), - HistoryError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponse { - error: Option, - pub groups: Option>, - #[serde(default)] - ok: bool, -} - -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ListError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ListError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => ListError::NotAuthed, - "invalid_auth" => ListError::InvalidAuth, - "account_inactive" => ListError::AccountInactive, - "invalid_arg_name" => ListError::InvalidArgName, - "invalid_array_arg" => ListError::InvalidArrayArg, - "invalid_charset" => ListError::InvalidCharset, - "invalid_form_data" => ListError::InvalidFormData, - "invalid_post_type" => ListError::InvalidPostType, - "missing_post_type" => ListError::MissingPostType, - "team_added_to_org" => ListError::TeamAddedToOrg, - "request_timeout" => ListError::RequestTimeout, - _ => ListError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for ListError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ListError::NotAuthed => "not_authed: No authentication token provided.", -ListError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ListError::Unknown(ref s) => return write!(f, "{}", s), - ListError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for ListError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ListError::MalformedResponse(_, ref e) => Some(e), - ListError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct MarkRequest<'a> { - /// multiparty direct message channel to set reading cursor in. - pub channel: &'a str, - /// Timestamp of the most recently seen message. - pub ts: crate::Timestamp, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct MarkResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for MarkResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum MarkError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// Value passed for timestamp was invalid. - InvalidTimestamp, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for MarkError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => MarkError::ChannelNotFound, - "invalid_timestamp" => MarkError::InvalidTimestamp, - "not_authed" => MarkError::NotAuthed, - "invalid_auth" => MarkError::InvalidAuth, - "account_inactive" => MarkError::AccountInactive, - "invalid_arg_name" => MarkError::InvalidArgName, - "invalid_array_arg" => MarkError::InvalidArrayArg, - "invalid_charset" => MarkError::InvalidCharset, - "invalid_form_data" => MarkError::InvalidFormData, - "invalid_post_type" => MarkError::InvalidPostType, - "missing_post_type" => MarkError::MissingPostType, - "team_added_to_org" => MarkError::TeamAddedToOrg, - "request_timeout" => MarkError::RequestTimeout, - _ => MarkError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for MarkError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - MarkError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -MarkError::InvalidTimestamp => "invalid_timestamp: Value passed for timestamp was invalid.", -MarkError::NotAuthed => "not_authed: No authentication token provided.", -MarkError::InvalidAuth => "invalid_auth: Invalid authentication token.", -MarkError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -MarkError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -MarkError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -MarkError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -MarkError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -MarkError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -MarkError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -MarkError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -MarkError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - MarkError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - MarkError::Unknown(ref s) => return write!(f, "{}", s), - MarkError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for MarkError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - MarkError::MalformedResponse(_, ref e) => Some(e), - MarkError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct OpenRequest<'a> { - /// Comma separated lists of users. The ordering of the users is preserved whenever a MPIM group is returned. - pub users: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct OpenResponse { - error: Option, - pub group: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for OpenResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum OpenError { - /// Missing users in request - UsersListNotSupplied, - /// Needs at least 2 users to open - NotEnoughUsers, - /// Needs at most 8 users to open - TooManyUsers, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for OpenError { - fn from(s: &'a str) -> Self { - match s { - "users_list_not_supplied" => OpenError::UsersListNotSupplied, - "not_enough_users" => OpenError::NotEnoughUsers, - "too_many_users" => OpenError::TooManyUsers, - "not_authed" => OpenError::NotAuthed, - "invalid_auth" => OpenError::InvalidAuth, - "account_inactive" => OpenError::AccountInactive, - "invalid_arg_name" => OpenError::InvalidArgName, - "invalid_array_arg" => OpenError::InvalidArrayArg, - "invalid_charset" => OpenError::InvalidCharset, - "invalid_form_data" => OpenError::InvalidFormData, - "invalid_post_type" => OpenError::InvalidPostType, - "missing_post_type" => OpenError::MissingPostType, - "team_added_to_org" => OpenError::TeamAddedToOrg, - "request_timeout" => OpenError::RequestTimeout, - _ => OpenError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for OpenError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - OpenError::UsersListNotSupplied => "users_list_not_supplied: Missing users in request", -OpenError::NotEnoughUsers => "not_enough_users: Needs at least 2 users to open", -OpenError::TooManyUsers => "too_many_users: Needs at most 8 users to open", -OpenError::NotAuthed => "not_authed: No authentication token provided.", -OpenError::InvalidAuth => "invalid_auth: Invalid authentication token.", -OpenError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -OpenError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -OpenError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -OpenError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -OpenError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -OpenError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -OpenError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -OpenError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -OpenError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - OpenError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - OpenError::Unknown(ref s) => return write!(f, "{}", s), - OpenError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for OpenError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - OpenError::MalformedResponse(_, ref e) => Some(e), - OpenError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct RepliesRequest<'a> { - /// Multiparty direct message channel to fetch thread from. - pub channel: &'a str, - /// Unique identifier of a thread's parent message. - pub thread_ts: crate::Timestamp, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct RepliesResponse { - error: Option, - pub messages: Option>, - #[serde(default)] - ok: bool, - pub thread_info: Option, -} - -impl Into>> for RepliesResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum RepliesError { - /// Value for channel was missing or invalid. - ChannelNotFound, - /// Value for thread_ts was missing or invalid. - ThreadNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for RepliesError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => RepliesError::ChannelNotFound, - "thread_not_found" => RepliesError::ThreadNotFound, - "not_authed" => RepliesError::NotAuthed, - "invalid_auth" => RepliesError::InvalidAuth, - "account_inactive" => RepliesError::AccountInactive, - "user_is_bot" => RepliesError::UserIsBot, - "invalid_arg_name" => RepliesError::InvalidArgName, - "invalid_array_arg" => RepliesError::InvalidArrayArg, - "invalid_charset" => RepliesError::InvalidCharset, - "invalid_form_data" => RepliesError::InvalidFormData, - "invalid_post_type" => RepliesError::InvalidPostType, - "missing_post_type" => RepliesError::MissingPostType, - "team_added_to_org" => RepliesError::TeamAddedToOrg, - "request_timeout" => RepliesError::RequestTimeout, - _ => RepliesError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for RepliesError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - RepliesError::ChannelNotFound => "channel_not_found: Value for channel was missing or invalid.", -RepliesError::ThreadNotFound => "thread_not_found: Value for thread_ts was missing or invalid.", -RepliesError::NotAuthed => "not_authed: No authentication token provided.", -RepliesError::InvalidAuth => "invalid_auth: Invalid authentication token.", -RepliesError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -RepliesError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -RepliesError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -RepliesError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -RepliesError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -RepliesError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -RepliesError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -RepliesError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -RepliesError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -RepliesError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - RepliesError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - RepliesError::Unknown(ref s) => return write!(f, "{}", s), - RepliesError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for RepliesError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - RepliesError::MalformedResponse(_, ref e) => Some(e), - RepliesError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/oauth/mod.rs b/src/mod_types/oauth/mod.rs new file mode 100644 index 00000000..62675f90 --- /dev/null +++ b/src/mod_types/oauth/mod.rs @@ -0,0 +1,39 @@ +pub mod v2_types; + +pub struct AccessRequest { + /// Issued when you created your application. + pub client_id: String, + /// Issued when you created your application. + pub client_secret: String, + /// The `code` param returned via the OAuth callback. + pub code: String, + /// This must match the originally submitted URI (if one was sent). + pub redirect_uri: String, + /// Request the user to add your app only to a single channel. Only valid with a [legacy workspace app](https://api.slack.com/legacy-workspace-apps). + pub single_channel: bool, +} + +pub struct AccessResponse { + pub ok: Option, +} + +pub struct AccessError {} + +pub struct TokenRequest { + /// Issued when you created your application. + pub client_id: String, + /// Issued when you created your application. + pub client_secret: String, + /// The `code` param returned via the OAuth callback. + pub code: String, + /// This must match the originally submitted URI (if one was sent). + pub redirect_uri: String, + /// Request the user to add your app only to a single channel. + pub single_channel: bool, +} + +pub struct TokenResponse { + pub ok: Option, +} + +pub struct TokenError {} diff --git a/src/mod_types/oauth/v2_types.rs b/src/mod_types/oauth/v2_types.rs new file mode 100644 index 00000000..e6f2d9a7 --- /dev/null +++ b/src/mod_types/oauth/v2_types.rs @@ -0,0 +1,16 @@ +pub struct AccessRequest { + /// Issued when you created your application. + pub client_id: String, + /// Issued when you created your application. + pub client_secret: String, + /// The `code` param returned via the OAuth callback. + pub code: Option, + /// This must match the originally submitted URI (if one was sent). + pub redirect_uri: String, +} + +pub struct AccessResponse { + pub ok: Option, +} + +pub struct AccessError {} diff --git a/src/mod_types/oauth_types.rs b/src/mod_types/oauth_types.rs deleted file mode 100644 index 04490e80..00000000 --- a/src/mod_types/oauth_types.rs +++ /dev/null @@ -1,124 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct AccessRequest<'a> { - /// Issued when you created your application. - pub client_id: &'a str, - /// Issued when you created your application. - pub client_secret: &'a str, - /// The code param returned via the OAuth callback. - pub code: &'a str, - /// This must match the originally submitted URI (if one was sent). - pub redirect_uri: Option<&'a str>, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct AccessResponse { - pub access_token: Option, - pub scope: Option, -} - -#[derive(Debug)] -pub enum AccessError { - /// Value passed for client_id was invalid. - InvalidClientId, - /// Value passed for client_secret was invalid. - BadClientSecret, - /// Value passed for code was invalid. - InvalidCode, - /// Value passed for redirect_uri did not match the redirect_uri in the original request. - BadRedirectUri, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for AccessError { - fn from(s: &'a str) -> Self { - match s { - "invalid_client_id" => AccessError::InvalidClientId, - "bad_client_secret" => AccessError::BadClientSecret, - "invalid_code" => AccessError::InvalidCode, - "bad_redirect_uri" => AccessError::BadRedirectUri, - "invalid_arg_name" => AccessError::InvalidArgName, - "invalid_array_arg" => AccessError::InvalidArrayArg, - "invalid_charset" => AccessError::InvalidCharset, - "invalid_form_data" => AccessError::InvalidFormData, - "invalid_post_type" => AccessError::InvalidPostType, - "missing_post_type" => AccessError::MissingPostType, - "team_added_to_org" => AccessError::TeamAddedToOrg, - "request_timeout" => AccessError::RequestTimeout, - _ => AccessError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for AccessError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - AccessError::InvalidClientId => "invalid_client_id: Value passed for client_id was invalid.", -AccessError::BadClientSecret => "bad_client_secret: Value passed for client_secret was invalid.", -AccessError::InvalidCode => "invalid_code: Value passed for code was invalid.", -AccessError::BadRedirectUri => "bad_redirect_uri: Value passed for redirect_uri did not match the redirect_uri in the original request.", -AccessError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -AccessError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -AccessError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -AccessError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -AccessError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -AccessError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -AccessError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -AccessError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - AccessError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - AccessError::Unknown(ref s) => return write!(f, "{}", s), - AccessError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for AccessError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - AccessError::MalformedResponse(_, ref e) => Some(e), - AccessError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/pins_types.rs b/src/mod_types/pins_types.rs index 52bb0b93..e70a6fee 100644 --- a/src/mod_types/pins_types.rs +++ b/src/mod_types/pins_types.rs @@ -1,489 +1,136 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct AddRequest<'a> { - /// Channel to pin the item in. - pub channel: &'a str, - /// File to pin. - pub file: Option<&'a str>, - /// File comment to pin. - pub file_comment: Option<&'a str>, - /// Timestamp of the message to pin. - pub timestamp: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct AddResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for AddResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum AddError { - /// Value passed for timestamp was invalid. - BadTimestamp, - /// File specified by file does not exist. - FileNotFound, - /// File comment specified by file_comment does not exist. - FileCommentNotFound, - /// Message specified by channel and timestamp does not exist. - MessageNotFound, - /// The channel argument was not specified or was invalid - ChannelNotFound, - /// One of file, file_comment, or timestamp was not specified. - NoItemSpecified, - /// The specified item is already pinned to the channel. - AlreadyPinned, - /// The user does not have permission to add pins to the channel. - PermissionDenied, - /// File specified by file is not public nor shared to the channel. - FileNotShared, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for AddError { - fn from(s: &'a str) -> Self { - match s { - "bad_timestamp" => AddError::BadTimestamp, - "file_not_found" => AddError::FileNotFound, - "file_comment_not_found" => AddError::FileCommentNotFound, - "message_not_found" => AddError::MessageNotFound, - "channel_not_found" => AddError::ChannelNotFound, - "no_item_specified" => AddError::NoItemSpecified, - "already_pinned" => AddError::AlreadyPinned, - "permission_denied" => AddError::PermissionDenied, - "file_not_shared" => AddError::FileNotShared, - "not_authed" => AddError::NotAuthed, - "invalid_auth" => AddError::InvalidAuth, - "account_inactive" => AddError::AccountInactive, - "invalid_arg_name" => AddError::InvalidArgName, - "invalid_array_arg" => AddError::InvalidArrayArg, - "invalid_charset" => AddError::InvalidCharset, - "invalid_form_data" => AddError::InvalidFormData, - "invalid_post_type" => AddError::InvalidPostType, - "missing_post_type" => AddError::MissingPostType, - "team_added_to_org" => AddError::TeamAddedToOrg, - "request_timeout" => AddError::RequestTimeout, - _ => AddError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for AddError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - AddError::BadTimestamp => "bad_timestamp: Value passed for timestamp was invalid.", -AddError::FileNotFound => "file_not_found: File specified by file does not exist.", -AddError::FileCommentNotFound => "file_comment_not_found: File comment specified by file_comment does not exist.", -AddError::MessageNotFound => "message_not_found: Message specified by channel and timestamp does not exist.", -AddError::ChannelNotFound => "channel_not_found: The channel argument was not specified or was invalid", -AddError::NoItemSpecified => "no_item_specified: One of file, file_comment, or timestamp was not specified.", -AddError::AlreadyPinned => "already_pinned: The specified item is already pinned to the channel.", -AddError::PermissionDenied => "permission_denied: The user does not have permission to add pins to the channel.", -AddError::FileNotShared => "file_not_shared: File specified by file is not public nor shared to the channel.", -AddError::NotAuthed => "not_authed: No authentication token provided.", -AddError::InvalidAuth => "invalid_auth: Invalid authentication token.", -AddError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -AddError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -AddError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -AddError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -AddError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -AddError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -AddError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -AddError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -AddError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - AddError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - AddError::Unknown(ref s) => return write!(f, "{}", s), - AddError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for AddError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - AddError::MalformedResponse(_, ref e) => Some(e), - AddError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct ListRequest<'a> { +pub struct ListRequest { /// Channel to get pinned items for. - pub channel: &'a str, + pub channel: Option, +} + +pub struct ListReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ListSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct ListFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: ListSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct ListItemsInner { + pub created: u64, + pub created_by: String, + pub file: ListFileInner, + pub r#type: String, +} + +pub struct ListResultInner { + pub items: Option>, + pub ok: Option, } -#[derive(Clone, Debug, Deserialize)] pub struct ListResponse { - error: Option, - pub items: Option>, - #[serde(default)] - ok: bool, -} - -#[derive(Clone, Debug)] -pub enum ListResponseItem { - Message(ListResponseItemMessage), - File(ListResponseItemFile), - FileComment(ListResponseItemFileComment), -} - -impl<'de> ::serde::Deserialize<'de> for ListResponseItem { - fn deserialize(deserializer: D) -> Result - where - D: ::serde::Deserializer<'de>, - { - use ::serde::de::Error as SerdeError; - - const VARIANTS: &[&str] = &["message", "file", "file_comment"]; - - let value = ::serde_json::Value::deserialize(deserializer)?; - if let Some(ty_val) = value.get("type") { - if let Some(ty) = ty_val.as_str() { - match ty { - "message" => ::serde_json::from_value::(value.clone()) - .map(ListResponseItem::Message) - .map_err(|e| D::Error::custom(&format!("{}", e))), - "file" => ::serde_json::from_value::(value.clone()) - .map(ListResponseItem::File) - .map_err(|e| D::Error::custom(&format!("{}", e))), - "file_comment" => { - ::serde_json::from_value::(value.clone()) - .map(ListResponseItem::FileComment) - .map_err(|e| D::Error::custom(&format!("{}", e))) - } - _ => Err(D::Error::unknown_variant(ty, VARIANTS)), - } - } else { - Err(D::Error::invalid_type( - ::serde::de::Unexpected::Unit, - &"a string", - )) - } - } else { - Err(D::Error::missing_field("type")) - } - } -} - -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponseItemFile { - pub created: Option, - pub created_by: Option, - pub file: crate::File, - #[serde(rename = "type")] - pub ty: String, + pub result: Option, } -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponseItemFileComment { - pub comment: crate::FileComment, - pub created: Option, - pub created_by: Option, - pub file: crate::File, - #[serde(rename = "type")] - pub ty: String, -} +pub struct ListError {} -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponseItemMessage { - pub channel: String, - pub created: Option, - pub created_by: Option, - pub message: crate::Message, - #[serde(rename = "type")] - pub ty: String, -} - -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ListError { - /// Value passed for channel was invalid. - ChannelNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ListError { - fn from(s: &'a str) -> Self { - match s { - "channel_not_found" => ListError::ChannelNotFound, - "not_authed" => ListError::NotAuthed, - "invalid_auth" => ListError::InvalidAuth, - "account_inactive" => ListError::AccountInactive, - "invalid_arg_name" => ListError::InvalidArgName, - "invalid_array_arg" => ListError::InvalidArrayArg, - "invalid_charset" => ListError::InvalidCharset, - "invalid_form_data" => ListError::InvalidFormData, - "invalid_post_type" => ListError::InvalidPostType, - "missing_post_type" => ListError::MissingPostType, - "team_added_to_org" => ListError::TeamAddedToOrg, - "request_timeout" => ListError::RequestTimeout, - _ => ListError::Unknown(s.to_owned()), - } - } +pub struct AddRequest { + /// Channel to pin the item in. + pub channel: Option, + /// Timestamp of the message to pin. + pub timestamp: String, } -impl fmt::Display for ListError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ListError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.", -ListError::NotAuthed => "not_authed: No authentication token provided.", -ListError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ListError::Unknown(ref s) => return write!(f, "{}", s), - ListError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } +pub struct AddResponse { + pub callstack: String, + pub error: String, + pub ok: Option, } -impl Error for ListError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ListError::MalformedResponse(_, ref e) => Some(e), - ListError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct AddError {} -#[derive(Clone, Default, Debug)] -pub struct RemoveRequest<'a> { +pub struct RemoveRequest { /// Channel where the item is pinned to. - pub channel: &'a str, - /// File to un-pin. - pub file: Option<&'a str>, - /// File comment to un-pin. - pub file_comment: Option<&'a str>, + pub channel: Option, /// Timestamp of the message to un-pin. - pub timestamp: Option, + pub timestamp: String, } -#[derive(Clone, Debug, Deserialize)] pub struct RemoveResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for RemoveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum RemoveError { - /// Value passed for timestamp was invalid. - BadTimestamp, - /// File specified by file does not exist. - FileNotFound, - /// File comment specified by file_comment does not exist. - FileCommentNotFound, - /// Message specified by channel and timestamp does not exist. - MessageNotFound, - /// One of file, file_comment, or timestamp was not specified. - NoItemSpecified, - /// The specified item is not pinned to the channel. - NotPinned, - /// The user does not have permission to remove pins from the channel. - PermissionDenied, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), + pub callstack: String, + pub error: String, + pub ok: Option, } -impl<'a, E: Error> From<&'a str> for RemoveError { - fn from(s: &'a str) -> Self { - match s { - "bad_timestamp" => RemoveError::BadTimestamp, - "file_not_found" => RemoveError::FileNotFound, - "file_comment_not_found" => RemoveError::FileCommentNotFound, - "message_not_found" => RemoveError::MessageNotFound, - "no_item_specified" => RemoveError::NoItemSpecified, - "not_pinned" => RemoveError::NotPinned, - "permission_denied" => RemoveError::PermissionDenied, - "not_authed" => RemoveError::NotAuthed, - "invalid_auth" => RemoveError::InvalidAuth, - "account_inactive" => RemoveError::AccountInactive, - "invalid_arg_name" => RemoveError::InvalidArgName, - "invalid_array_arg" => RemoveError::InvalidArrayArg, - "invalid_charset" => RemoveError::InvalidCharset, - "invalid_form_data" => RemoveError::InvalidFormData, - "invalid_post_type" => RemoveError::InvalidPostType, - "missing_post_type" => RemoveError::MissingPostType, - "team_added_to_org" => RemoveError::TeamAddedToOrg, - "request_timeout" => RemoveError::RequestTimeout, - _ => RemoveError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for RemoveError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - RemoveError::BadTimestamp => "bad_timestamp: Value passed for timestamp was invalid.", -RemoveError::FileNotFound => "file_not_found: File specified by file does not exist.", -RemoveError::FileCommentNotFound => "file_comment_not_found: File comment specified by file_comment does not exist.", -RemoveError::MessageNotFound => "message_not_found: Message specified by channel and timestamp does not exist.", -RemoveError::NoItemSpecified => "no_item_specified: One of file, file_comment, or timestamp was not specified.", -RemoveError::NotPinned => "not_pinned: The specified item is not pinned to the channel.", -RemoveError::PermissionDenied => "permission_denied: The user does not have permission to remove pins from the channel.", -RemoveError::NotAuthed => "not_authed: No authentication token provided.", -RemoveError::InvalidAuth => "invalid_auth: Invalid authentication token.", -RemoveError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -RemoveError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -RemoveError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -RemoveError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -RemoveError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -RemoveError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -RemoveError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -RemoveError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -RemoveError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - RemoveError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - RemoveError::Unknown(ref s) => return write!(f, "{}", s), - RemoveError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for RemoveError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - RemoveError::MalformedResponse(_, ref e) => Some(e), - RemoveError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct RemoveError {} diff --git a/src/mod_types/reactions_types.rs b/src/mod_types/reactions_types.rs index 23d1bcf1..3edd3604 100644 --- a/src/mod_types/reactions_types.rs +++ b/src/mod_types/reactions_types.rs @@ -1,734 +1,387 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct AddRequest<'a> { - /// Reaction (emoji) name. - pub name: &'a str, - /// File to add reaction to. - pub file: Option<&'a str>, - /// File comment to add reaction to. - pub file_comment: Option<&'a str>, - /// Channel where the message to add reaction to was posted. - pub channel: Option<&'a str>, - /// Timestamp of the message to add reaction to. - pub timestamp: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct AddResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for AddResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum AddError { - /// Value passed for timestamp was invalid. - BadTimestamp, - /// File specified by file does not exist. - FileNotFound, - /// File comment specified by file_comment does not exist. - FileCommentNotFound, - /// Message specified by channel and timestamp does not exist. - MessageNotFound, - /// file, file_comment, or combination of channel and timestamp was not specified. - NoItemSpecified, - /// Value passed for name was invalid. - InvalidName, - /// The specified item already has the user/reaction combination. - AlreadyReacted, - /// The limit for distinct reactions (i.e emoji) on the item has been reached. - TooManyEmoji, - /// The limit for reactions a person may add to the item has been reached. - TooManyReactions, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for AddError { - fn from(s: &'a str) -> Self { - match s { - "bad_timestamp" => AddError::BadTimestamp, - "file_not_found" => AddError::FileNotFound, - "file_comment_not_found" => AddError::FileCommentNotFound, - "message_not_found" => AddError::MessageNotFound, - "no_item_specified" => AddError::NoItemSpecified, - "invalid_name" => AddError::InvalidName, - "already_reacted" => AddError::AlreadyReacted, - "too_many_emoji" => AddError::TooManyEmoji, - "too_many_reactions" => AddError::TooManyReactions, - "not_authed" => AddError::NotAuthed, - "invalid_auth" => AddError::InvalidAuth, - "account_inactive" => AddError::AccountInactive, - "invalid_arg_name" => AddError::InvalidArgName, - "invalid_array_arg" => AddError::InvalidArrayArg, - "invalid_charset" => AddError::InvalidCharset, - "invalid_form_data" => AddError::InvalidFormData, - "invalid_post_type" => AddError::InvalidPostType, - "missing_post_type" => AddError::MissingPostType, - "team_added_to_org" => AddError::TeamAddedToOrg, - "request_timeout" => AddError::RequestTimeout, - _ => AddError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for AddError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - AddError::BadTimestamp => "bad_timestamp: Value passed for timestamp was invalid.", -AddError::FileNotFound => "file_not_found: File specified by file does not exist.", -AddError::FileCommentNotFound => "file_comment_not_found: File comment specified by file_comment does not exist.", -AddError::MessageNotFound => "message_not_found: Message specified by channel and timestamp does not exist.", -AddError::NoItemSpecified => "no_item_specified: file, file_comment, or combination of channel and timestamp was not specified.", -AddError::InvalidName => "invalid_name: Value passed for name was invalid.", -AddError::AlreadyReacted => "already_reacted: The specified item already has the user/reaction combination.", -AddError::TooManyEmoji => "too_many_emoji: The limit for distinct reactions (i.e emoji) on the item has been reached.", -AddError::TooManyReactions => "too_many_reactions: The limit for reactions a person may add to the item has been reached.", -AddError::NotAuthed => "not_authed: No authentication token provided.", -AddError::InvalidAuth => "invalid_auth: Invalid authentication token.", -AddError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -AddError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -AddError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -AddError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -AddError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -AddError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -AddError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -AddError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -AddError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - AddError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - AddError::Unknown(ref s) => return write!(f, "{}", s), - AddError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for AddError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - AddError::MalformedResponse(_, ref e) => Some(e), - AddError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct GetRequest<'a> { - /// File to get reactions for. - pub file: Option<&'a str>, - /// File comment to get reactions for. - pub file_comment: Option<&'a str>, - /// Channel where the message to get reactions for was posted. - pub channel: Option<&'a str>, - /// Timestamp of the message to get reactions for. - pub timestamp: Option, - /// If true always return the complete reaction list. - pub full: Option, -} - -#[derive(Clone, Debug)] -pub enum GetResponse { - Message(GetResponseMessage), - File(GetResponseFile), - FileComment(GetResponseFileComment), -} - -impl<'de> ::serde::Deserialize<'de> for GetResponse { - fn deserialize(deserializer: D) -> Result - where - D: ::serde::Deserializer<'de>, - { - use ::serde::de::Error as SerdeError; - - const VARIANTS: &[&str] = &["message", "file", "file_comment"]; - - let value = ::serde_json::Value::deserialize(deserializer)?; - if let Some(ty_val) = value.get("type") { - if let Some(ty) = ty_val.as_str() { - match ty { - "message" => ::serde_json::from_value::(value.clone()) - .map(GetResponse::Message) - .map_err(|e| D::Error::custom(&format!("{}", e))), - "file" => ::serde_json::from_value::(value.clone()) - .map(GetResponse::File) - .map_err(|e| D::Error::custom(&format!("{}", e))), - "file_comment" => { - ::serde_json::from_value::(value.clone()) - .map(GetResponse::FileComment) - .map_err(|e| D::Error::custom(&format!("{}", e))) - } - _ => Err(D::Error::unknown_variant(ty, VARIANTS)), - } - } else { - Err(D::Error::invalid_type( - ::serde::de::Unexpected::Unit, - &"a string", - )) - } - } else { - Err(D::Error::missing_field("type")) - } - } -} - -#[derive(Clone, Debug, Deserialize)] -pub struct GetResponseFile { - error: Option, - pub file: crate::File, - #[serde(default)] - ok: bool, - #[serde(rename = "type")] - pub ty: String, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct GetResponseFileComment { - pub comment: crate::FileComment, - error: Option, - pub file: crate::File, - #[serde(default)] - ok: bool, - #[serde(rename = "type")] - pub ty: String, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct GetResponseMessage { - pub channel: String, - error: Option, - pub message: crate::Message, - #[serde(default)] - ok: bool, - #[serde(rename = "type")] - pub ty: String, -} - -impl Into>> for GetResponse { - fn into(self) -> Result> { - match self { - GetResponse::Message(inner) => { - let x: Result> = inner.into(); - x.map(GetResponse::Message) - } - GetResponse::File(inner) => { - let x: Result> = inner.into(); - x.map(GetResponse::File) - } - GetResponse::FileComment(inner) => { - let x: Result> = inner.into(); - x.map(GetResponse::FileComment) - } - } - } -} - -impl Into>> for GetResponseMessage { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -impl Into>> for GetResponseFile { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -impl Into>> for GetResponseFileComment { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum GetError { - /// Value passed for timestamp was invalid. - BadTimestamp, - /// File specified by file does not exist. - FileNotFound, - /// File comment specified by file_comment does not exist. - FileCommentNotFound, - /// Message specified by channel and timestamp does not exist. - MessageNotFound, - /// file, file_comment, or combination of channel and timestamp was not specified. - NoItemSpecified, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for GetError { - fn from(s: &'a str) -> Self { - match s { - "bad_timestamp" => GetError::BadTimestamp, - "file_not_found" => GetError::FileNotFound, - "file_comment_not_found" => GetError::FileCommentNotFound, - "message_not_found" => GetError::MessageNotFound, - "no_item_specified" => GetError::NoItemSpecified, - "not_authed" => GetError::NotAuthed, - "invalid_auth" => GetError::InvalidAuth, - "account_inactive" => GetError::AccountInactive, - "invalid_arg_name" => GetError::InvalidArgName, - "invalid_array_arg" => GetError::InvalidArrayArg, - "invalid_charset" => GetError::InvalidCharset, - "invalid_form_data" => GetError::InvalidFormData, - "invalid_post_type" => GetError::InvalidPostType, - "missing_post_type" => GetError::MissingPostType, - "team_added_to_org" => GetError::TeamAddedToOrg, - "request_timeout" => GetError::RequestTimeout, - _ => GetError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for GetError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - GetError::BadTimestamp => "bad_timestamp: Value passed for timestamp was invalid.", -GetError::FileNotFound => "file_not_found: File specified by file does not exist.", -GetError::FileCommentNotFound => "file_comment_not_found: File comment specified by file_comment does not exist.", -GetError::MessageNotFound => "message_not_found: Message specified by channel and timestamp does not exist.", -GetError::NoItemSpecified => "no_item_specified: file, file_comment, or combination of channel and timestamp was not specified.", -GetError::NotAuthed => "not_authed: No authentication token provided.", -GetError::InvalidAuth => "invalid_auth: Invalid authentication token.", -GetError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -GetError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -GetError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -GetError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -GetError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -GetError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -GetError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -GetError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -GetError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - GetError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - GetError::Unknown(ref s) => return write!(f, "{}", s), - GetError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for GetError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - GetError::MalformedResponse(_, ref e) => Some(e), - GetError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct ListRequest<'a> { +pub struct ListRequest { /// Show reactions made by this user. Defaults to the authed user. - pub user: Option<&'a str>, + pub user: String, /// If true always return the complete reaction list. - pub full: Option, - /// Number of items to return per page. - pub count: Option, - /// Page number of results to return. - pub page: Option, + pub full: bool, + pub count: u64, + pub page: u64, + /// Parameter for pagination. Set `cursor` equal to the `next_cursor` attribute returned by the previous request's `response_metadata`. This parameter is optional, but pagination is mandatory: the default value simply fetches the first "page" of the collection. See [pagination](/docs/pagination) for more details. + pub cursor: String, + /// The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. + pub limit: u64, +} + +pub struct ListAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct ListBlocksInner { + pub r#type: Option, +} + +pub struct ListIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct ListBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct ListReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ListCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct ListReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ListSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct ListFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: ListSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct ListReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ListShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct ListFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: ListShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct ListIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct ListReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ListUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct ListMessageInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: ListBotProfileInner, + pub client_msg_id: String, + pub comment: ListCommentInner, + pub display_as_bot: bool, + pub file: ListFileInner, + pub files: Vec, + pub icons: ListIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: ListUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct ListItemsInner { + pub channel: Option, + pub message: Option, + pub r#type: Option, +} + +pub struct ListPagingInner { + pub count: u64, + pub page: Option, + pub pages: u64, + pub per_page: u64, + pub spill: u64, + pub total: Option, +} + +pub struct ListResponseMetadataInner { + pub next_cursor: Option, } -#[derive(Clone, Debug, Deserialize)] pub struct ListResponse { - error: Option, - pub items: Option>, - #[serde(default)] - ok: bool, - pub paging: Option, + pub callstack: String, + pub error: String, + pub items: Option>>, + pub ok: Option, + pub paging: ListPagingInner, + pub response_metadata: Vec, } -#[derive(Clone, Debug)] -pub enum ListResponseItem { - Message(ListResponseItemMessage), - File(ListResponseItemFile), - FileComment(ListResponseItemFileComment), -} - -impl<'de> ::serde::Deserialize<'de> for ListResponseItem { - fn deserialize(deserializer: D) -> Result - where - D: ::serde::Deserializer<'de>, - { - use ::serde::de::Error as SerdeError; - - const VARIANTS: &[&str] = &["message", "file", "file_comment"]; - - let value = ::serde_json::Value::deserialize(deserializer)?; - if let Some(ty_val) = value.get("type") { - if let Some(ty) = ty_val.as_str() { - match ty { - "message" => ::serde_json::from_value::(value.clone()) - .map(ListResponseItem::Message) - .map_err(|e| D::Error::custom(&format!("{}", e))), - "file" => ::serde_json::from_value::(value.clone()) - .map(ListResponseItem::File) - .map_err(|e| D::Error::custom(&format!("{}", e))), - "file_comment" => { - ::serde_json::from_value::(value.clone()) - .map(ListResponseItem::FileComment) - .map_err(|e| D::Error::custom(&format!("{}", e))) - } - _ => Err(D::Error::unknown_variant(ty, VARIANTS)), - } - } else { - Err(D::Error::invalid_type( - ::serde::de::Unexpected::Unit, - &"a string", - )) - } - } else { - Err(D::Error::missing_field("type")) - } - } -} +pub struct ListError {} -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponseItemFile { - pub file: crate::File, - #[serde(rename = "type")] - pub ty: String, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponseItemFileComment { - pub comment: crate::FileComment, - pub file: crate::File, - #[serde(rename = "type")] - pub ty: String, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponseItemMessage { - pub channel: String, - pub message: crate::Message, - #[serde(rename = "type")] - pub ty: String, -} - -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ListError { - /// Value passed for user was invalid. - UserNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ListError { - fn from(s: &'a str) -> Self { - match s { - "user_not_found" => ListError::UserNotFound, - "not_authed" => ListError::NotAuthed, - "invalid_auth" => ListError::InvalidAuth, - "account_inactive" => ListError::AccountInactive, - "invalid_arg_name" => ListError::InvalidArgName, - "invalid_array_arg" => ListError::InvalidArrayArg, - "invalid_charset" => ListError::InvalidCharset, - "invalid_form_data" => ListError::InvalidFormData, - "invalid_post_type" => ListError::InvalidPostType, - "missing_post_type" => ListError::MissingPostType, - "team_added_to_org" => ListError::TeamAddedToOrg, - "request_timeout" => ListError::RequestTimeout, - _ => ListError::Unknown(s.to_owned()), - } - } +pub struct AddRequest { + /// Channel where the message to add reaction to was posted. + pub channel: Option, + /// Reaction (emoji) name. + pub name: Option, + /// Timestamp of the message to add reaction to. + pub timestamp: Option, } -impl fmt::Display for ListError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ListError::UserNotFound => "user_not_found: Value passed for user was invalid.", -ListError::NotAuthed => "not_authed: No authentication token provided.", -ListError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ListError::Unknown(ref s) => return write!(f, "{}", s), - ListError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } +pub struct AddResponse { + pub callstack: String, + pub error: String, + pub ok: Option, } -impl Error for ListError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ListError::MalformedResponse(_, ref e) => Some(e), - ListError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct AddError {} -#[derive(Clone, Default, Debug)] -pub struct RemoveRequest<'a> { +pub struct RemoveRequest { /// Reaction (emoji) name. - pub name: &'a str, + pub name: Option, /// File to remove reaction from. - pub file: Option<&'a str>, + pub file: String, /// File comment to remove reaction from. - pub file_comment: Option<&'a str>, + pub file_comment: String, /// Channel where the message to remove reaction from was posted. - pub channel: Option<&'a str>, + pub channel: String, /// Timestamp of the message to remove reaction from. - pub timestamp: Option, + pub timestamp: String, } -#[derive(Clone, Debug, Deserialize)] pub struct RemoveResponse { - error: Option, - #[serde(default)] - ok: bool, + pub callstack: String, + pub error: String, + pub ok: Option, } -impl Into>> for RemoveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum RemoveError { - /// Value passed for timestamp was invalid. - BadTimestamp, - /// File specified by file does not exist. - FileNotFound, - /// File comment specified by file_comment does not exist. - FileCommentNotFound, - /// Message specified by channel and timestamp does not exist. - MessageNotFound, - /// file, file_comment, or combination of channel and timestamp was not specified. - NoItemSpecified, - /// Value passed for name was invalid. - InvalidName, - /// The specified item does not have the user/reaction combination. - NoReaction, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} +pub struct RemoveError {} -impl<'a, E: Error> From<&'a str> for RemoveError { - fn from(s: &'a str) -> Self { - match s { - "bad_timestamp" => RemoveError::BadTimestamp, - "file_not_found" => RemoveError::FileNotFound, - "file_comment_not_found" => RemoveError::FileCommentNotFound, - "message_not_found" => RemoveError::MessageNotFound, - "no_item_specified" => RemoveError::NoItemSpecified, - "invalid_name" => RemoveError::InvalidName, - "no_reaction" => RemoveError::NoReaction, - "not_authed" => RemoveError::NotAuthed, - "invalid_auth" => RemoveError::InvalidAuth, - "account_inactive" => RemoveError::AccountInactive, - "invalid_arg_name" => RemoveError::InvalidArgName, - "invalid_array_arg" => RemoveError::InvalidArrayArg, - "invalid_charset" => RemoveError::InvalidCharset, - "invalid_form_data" => RemoveError::InvalidFormData, - "invalid_post_type" => RemoveError::InvalidPostType, - "missing_post_type" => RemoveError::MissingPostType, - "team_added_to_org" => RemoveError::TeamAddedToOrg, - "request_timeout" => RemoveError::RequestTimeout, - _ => RemoveError::Unknown(s.to_owned()), - } - } +pub struct GetRequest { + /// Channel where the message to get reactions for was posted. + pub channel: String, + /// File to get reactions for. + pub file: String, + /// File comment to get reactions for. + pub file_comment: String, + /// If true always return the complete reaction list. + pub full: bool, + /// Timestamp of the message to get reactions for. + pub timestamp: String, } -impl fmt::Display for RemoveError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - RemoveError::BadTimestamp => "bad_timestamp: Value passed for timestamp was invalid.", -RemoveError::FileNotFound => "file_not_found: File specified by file does not exist.", -RemoveError::FileCommentNotFound => "file_comment_not_found: File comment specified by file_comment does not exist.", -RemoveError::MessageNotFound => "message_not_found: Message specified by channel and timestamp does not exist.", -RemoveError::NoItemSpecified => "no_item_specified: file, file_comment, or combination of channel and timestamp was not specified.", -RemoveError::InvalidName => "invalid_name: Value passed for name was invalid.", -RemoveError::NoReaction => "no_reaction: The specified item does not have the user/reaction combination.", -RemoveError::NotAuthed => "not_authed: No authentication token provided.", -RemoveError::InvalidAuth => "invalid_auth: Invalid authentication token.", -RemoveError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -RemoveError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -RemoveError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -RemoveError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -RemoveError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -RemoveError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -RemoveError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -RemoveError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -RemoveError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - RemoveError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - RemoveError::Unknown(ref s) => return write!(f, "{}", s), - RemoveError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } +pub struct GetResponse { + pub callstack: String, + pub error: String, + pub ok: bool, } -impl Error for RemoveError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - RemoveError::MalformedResponse(_, ref e) => Some(e), - RemoveError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct GetError {} diff --git a/src/mod_types/reminders_types.rs b/src/mod_types/reminders_types.rs index dc22fccf..3e7fadf9 100644 --- a/src/mod_types/reminders_types.rs +++ b/src/mod_types/reminders_types.rs @@ -1,609 +1,98 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct AddRequest<'a> { - /// The content of the reminder - pub text: &'a str, - /// When this reminder should happen: the Unix timestamp (up to five years from now), the number of seconds until the reminder (if within 24 hours), or a natural language description (Ex. "in 15 minutes," or "every Thursday") - pub time: u32, - /// The user who will receive the reminder. If no user is specified, the reminder will go to user who created it. - pub user: Option<&'a str>, +pub struct DeleteRequest { + /// The ID of the reminder + pub reminder: String, } -#[derive(Clone, Debug, Deserialize)] -pub struct AddResponse { - error: Option, - #[serde(default)] - ok: bool, - pub reminder: Option, +pub struct DeleteResponse { + pub callstack: String, + pub error: String, + pub ok: Option, } -impl Into>> for AddResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum AddError { - /// The phrasing of the timing for this reminder is unclear. You must include a complete time description. Some examples that work: 1458678068, 20, in 5 minutes, tomorrow, at 3:30pm, on Tuesday, or next week. - CannotParse, - /// That user can't be found. - UserNotFound, - /// Reminders can't be sent to bots. - CannotAddBot, - /// Reminders can't be sent to Slackbot. - CannotAddSlackbot, - /// Guests can't set reminders for other team members. - CannotAddOthers, - /// Recurring reminders can't be set for other team members. - CannotAddOthersRecurring, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} +pub struct DeleteError {} -impl<'a, E: Error> From<&'a str> for AddError { - fn from(s: &'a str) -> Self { - match s { - "cannot_parse" => AddError::CannotParse, - "user_not_found" => AddError::UserNotFound, - "cannot_add_bot" => AddError::CannotAddBot, - "cannot_add_slackbot" => AddError::CannotAddSlackbot, - "cannot_add_others" => AddError::CannotAddOthers, - "cannot_add_others_recurring" => AddError::CannotAddOthersRecurring, - "not_authed" => AddError::NotAuthed, - "invalid_auth" => AddError::InvalidAuth, - "account_inactive" => AddError::AccountInactive, - "user_is_bot" => AddError::UserIsBot, - "invalid_arg_name" => AddError::InvalidArgName, - "invalid_array_arg" => AddError::InvalidArrayArg, - "invalid_charset" => AddError::InvalidCharset, - "invalid_form_data" => AddError::InvalidFormData, - "invalid_post_type" => AddError::InvalidPostType, - "missing_post_type" => AddError::MissingPostType, - "team_added_to_org" => AddError::TeamAddedToOrg, - "request_timeout" => AddError::RequestTimeout, - _ => AddError::Unknown(s.to_owned()), - } - } +pub struct InfoRequest { + /// The ID of the reminder + pub reminder: String, } -impl fmt::Display for AddError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - AddError::CannotParse => "cannot_parse: The phrasing of the timing for this reminder is unclear. You must include a complete time description. Some examples that work: 1458678068, 20, in 5 minutes, tomorrow, at 3:30pm, on Tuesday, or next week.", -AddError::UserNotFound => "user_not_found: That user can't be found.", -AddError::CannotAddBot => "cannot_add_bot: Reminders can't be sent to bots.", -AddError::CannotAddSlackbot => "cannot_add_slackbot: Reminders can't be sent to Slackbot.", -AddError::CannotAddOthers => "cannot_add_others: Guests can't set reminders for other team members.", -AddError::CannotAddOthersRecurring => "cannot_add_others_recurring: Recurring reminders can't be set for other team members.", -AddError::NotAuthed => "not_authed: No authentication token provided.", -AddError::InvalidAuth => "invalid_auth: Invalid authentication token.", -AddError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -AddError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -AddError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -AddError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -AddError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -AddError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -AddError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -AddError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -AddError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -AddError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - AddError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - AddError::Unknown(ref s) => return write!(f, "{}", s), - AddError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } +pub struct InfoReminderInner { + pub complete_ts: u64, + pub creator: Option, + pub id: Option, + pub recurring: Option, + pub text: Option, + pub time: u64, + pub user: Option, } -impl Error for AddError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - AddError::MalformedResponse(_, ref e) => Some(e), - AddError::Client(ref inner) => Some(inner), - _ => None, - } - } +pub struct InfoResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub reminder: Option, } -#[derive(Clone, Default, Debug)] -pub struct CompleteRequest<'a> { +pub struct InfoError {} + +pub struct CompleteRequest { /// The ID of the reminder to be marked as complete - pub reminder: &'a str, + pub reminder: String, } -#[derive(Clone, Debug, Deserialize)] pub struct CompleteResponse { - error: Option, - #[serde(default)] - ok: bool, + pub callstack: String, + pub error: String, + pub ok: Option, } -impl Into>> for CompleteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum CompleteError { - /// That reminder can't be found. - NotFound, - /// Recurring reminders can't be marked complete. - CannotCompleteRecurring, - /// Reminders for other team members can't be marked complete. - CannotCompleteOthers, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for CompleteError { - fn from(s: &'a str) -> Self { - match s { - "not_found" => CompleteError::NotFound, - "cannot_complete_recurring" => CompleteError::CannotCompleteRecurring, - "cannot_complete_others" => CompleteError::CannotCompleteOthers, - "not_authed" => CompleteError::NotAuthed, - "invalid_auth" => CompleteError::InvalidAuth, - "account_inactive" => CompleteError::AccountInactive, - "user_is_bot" => CompleteError::UserIsBot, - "invalid_arg_name" => CompleteError::InvalidArgName, - "invalid_array_arg" => CompleteError::InvalidArrayArg, - "invalid_charset" => CompleteError::InvalidCharset, - "invalid_form_data" => CompleteError::InvalidFormData, - "invalid_post_type" => CompleteError::InvalidPostType, - "missing_post_type" => CompleteError::MissingPostType, - "team_added_to_org" => CompleteError::TeamAddedToOrg, - "request_timeout" => CompleteError::RequestTimeout, - _ => CompleteError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for CompleteError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - CompleteError::NotFound => "not_found: That reminder can't be found.", -CompleteError::CannotCompleteRecurring => "cannot_complete_recurring: Recurring reminders can't be marked complete.", -CompleteError::CannotCompleteOthers => "cannot_complete_others: Reminders for other team members can't be marked complete.", -CompleteError::NotAuthed => "not_authed: No authentication token provided.", -CompleteError::InvalidAuth => "invalid_auth: Invalid authentication token.", -CompleteError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -CompleteError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -CompleteError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -CompleteError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -CompleteError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -CompleteError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -CompleteError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -CompleteError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -CompleteError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -CompleteError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - CompleteError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - CompleteError::Unknown(ref s) => return write!(f, "{}", s), - CompleteError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for CompleteError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - CompleteError::MalformedResponse(_, ref e) => Some(e), - CompleteError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct DeleteRequest<'a> { - /// The ID of the reminder - pub reminder: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct DeleteResponse { - error: Option, - #[serde(default)] - ok: bool, -} +pub struct CompleteError {} -impl Into>> for DeleteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum DeleteError { - /// That reminder can't be found. - NotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for DeleteError { - fn from(s: &'a str) -> Self { - match s { - "not_found" => DeleteError::NotFound, - "not_authed" => DeleteError::NotAuthed, - "invalid_auth" => DeleteError::InvalidAuth, - "account_inactive" => DeleteError::AccountInactive, - "user_is_bot" => DeleteError::UserIsBot, - "invalid_arg_name" => DeleteError::InvalidArgName, - "invalid_array_arg" => DeleteError::InvalidArrayArg, - "invalid_charset" => DeleteError::InvalidCharset, - "invalid_form_data" => DeleteError::InvalidFormData, - "invalid_post_type" => DeleteError::InvalidPostType, - "missing_post_type" => DeleteError::MissingPostType, - "team_added_to_org" => DeleteError::TeamAddedToOrg, - "request_timeout" => DeleteError::RequestTimeout, - _ => DeleteError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for DeleteError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - DeleteError::NotFound => "not_found: That reminder can't be found.", -DeleteError::NotAuthed => "not_authed: No authentication token provided.", -DeleteError::InvalidAuth => "invalid_auth: Invalid authentication token.", -DeleteError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -DeleteError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -DeleteError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -DeleteError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -DeleteError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -DeleteError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -DeleteError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -DeleteError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -DeleteError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -DeleteError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - DeleteError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - DeleteError::Unknown(ref s) => return write!(f, "{}", s), - DeleteError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for DeleteError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - DeleteError::MalformedResponse(_, ref e) => Some(e), - DeleteError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct InfoRequest<'a> { - /// The ID of the reminder - pub reminder: &'a str, +pub struct AddRequest { + /// The content of the reminder + pub text: Option, + /// When this reminder should happen: the Unix timestamp (up to five years from now), the number of seconds until the reminder (if within 24 hours), or a natural language description (Ex. "in 15 minutes," or "every Thursday") + pub time: Option, + /// The user who will receive the reminder. If no user is specified, the reminder will go to user who created it. + pub user: String, } -#[derive(Clone, Debug, Deserialize)] -pub struct InfoResponse { - error: Option, - #[serde(default)] - ok: bool, - pub reminder: Option, +pub struct AddReminderInner { + pub complete_ts: u64, + pub creator: Option, + pub id: Option, + pub recurring: Option, + pub text: Option, + pub time: u64, + pub user: Option, } -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum InfoError { - /// That reminder can't be found. - NotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), +pub struct AddResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub reminder: Option, } -impl<'a, E: Error> From<&'a str> for InfoError { - fn from(s: &'a str) -> Self { - match s { - "not_found" => InfoError::NotFound, - "not_authed" => InfoError::NotAuthed, - "invalid_auth" => InfoError::InvalidAuth, - "account_inactive" => InfoError::AccountInactive, - "user_is_bot" => InfoError::UserIsBot, - "invalid_arg_name" => InfoError::InvalidArgName, - "invalid_array_arg" => InfoError::InvalidArrayArg, - "invalid_charset" => InfoError::InvalidCharset, - "invalid_form_data" => InfoError::InvalidFormData, - "invalid_post_type" => InfoError::InvalidPostType, - "missing_post_type" => InfoError::MissingPostType, - "team_added_to_org" => InfoError::TeamAddedToOrg, - "request_timeout" => InfoError::RequestTimeout, - _ => InfoError::Unknown(s.to_owned()), - } - } -} +pub struct AddError {} -impl fmt::Display for InfoError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - InfoError::NotFound => "not_found: That reminder can't be found.", -InfoError::NotAuthed => "not_authed: No authentication token provided.", -InfoError::InvalidAuth => "invalid_auth: Invalid authentication token.", -InfoError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -InfoError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -InfoError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -InfoError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -InfoError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -InfoError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -InfoError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -InfoError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -InfoError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -InfoError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - InfoError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - InfoError::Unknown(ref s) => return write!(f, "{}", s), - InfoError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} +pub struct ListRequest {} -impl Error for InfoError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - InfoError::MalformedResponse(_, ref e) => Some(e), - InfoError::Client(ref inner) => Some(inner), - _ => None, - } - } +pub struct ListRemindersInner { + pub complete_ts: u64, + pub creator: Option, + pub id: Option, + pub recurring: Option, + pub text: Option, + pub time: u64, + pub user: Option, } -#[derive(Clone, Debug, Deserialize)] pub struct ListResponse { - error: Option, - #[serde(default)] - ok: bool, - pub reminders: Option>, + pub callstack: String, + pub error: String, + pub ok: Option, + pub reminders: Option>, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ListError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ListError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => ListError::NotAuthed, - "invalid_auth" => ListError::InvalidAuth, - "account_inactive" => ListError::AccountInactive, - "user_is_bot" => ListError::UserIsBot, - "invalid_arg_name" => ListError::InvalidArgName, - "invalid_array_arg" => ListError::InvalidArrayArg, - "invalid_charset" => ListError::InvalidCharset, - "invalid_form_data" => ListError::InvalidFormData, - "invalid_post_type" => ListError::InvalidPostType, - "missing_post_type" => ListError::MissingPostType, - "team_added_to_org" => ListError::TeamAddedToOrg, - "request_timeout" => ListError::RequestTimeout, - _ => ListError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for ListError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ListError::NotAuthed => "not_authed: No authentication token provided.", -ListError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ListError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ListError::Unknown(ref s) => return write!(f, "{}", s), - ListError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for ListError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ListError::MalformedResponse(_, ref e) => Some(e), - ListError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct ListError {} diff --git a/src/mod_types/rtm_types.rs b/src/mod_types/rtm_types.rs index f1e8ce0d..b5bae298 100644 --- a/src/mod_types/rtm_types.rs +++ b/src/mod_types/rtm_types.rs @@ -1,264 +1,28 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Debug, Deserialize)] -pub struct ConnectResponse { - error: Option, - #[serde(default)] - ok: bool, - #[serde(rename = "self")] - pub slf: Option, - pub team: Option, - pub url: Option, +pub struct ConnectRequest { + /// Batch presence deliveries via subscription. Enabling changes the shape of `presence_change` events. See [batch presence](/docs/presence-and-status#batching). + pub batch_presence_aware: bool, + /// Only deliver presence events when requested by subscription. See [presence subscriptions](/docs/presence-and-status#subscriptions). + pub presence_sub: bool, } -#[derive(Clone, Debug, Deserialize)] -pub struct ConnectResponseSelf { +pub struct ConnectSelfInner { pub id: Option, pub name: Option, } -#[derive(Clone, Debug, Deserialize)] -pub struct ConnectResponseTeam { +pub struct ConnectTeamInner { pub domain: Option, - pub enterprise_id: Option, - pub enterprise_name: Option, pub id: Option, pub name: Option, } -impl Into>> for ConnectResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ConnectError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ConnectError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => ConnectError::NotAuthed, - "invalid_auth" => ConnectError::InvalidAuth, - "account_inactive" => ConnectError::AccountInactive, - "invalid_arg_name" => ConnectError::InvalidArgName, - "invalid_array_arg" => ConnectError::InvalidArrayArg, - "invalid_charset" => ConnectError::InvalidCharset, - "invalid_form_data" => ConnectError::InvalidFormData, - "invalid_post_type" => ConnectError::InvalidPostType, - "missing_post_type" => ConnectError::MissingPostType, - "team_added_to_org" => ConnectError::TeamAddedToOrg, - "request_timeout" => ConnectError::RequestTimeout, - _ => ConnectError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for ConnectError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ConnectError::NotAuthed => "not_authed: No authentication token provided.", -ConnectError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ConnectError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ConnectError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ConnectError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ConnectError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ConnectError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ConnectError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ConnectError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ConnectError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ConnectError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ConnectError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ConnectError::Unknown(ref s) => return write!(f, "{}", s), - ConnectError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for ConnectError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ConnectError::MalformedResponse(_, ref e) => Some(e), - ConnectError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct StartRequest { - /// Skip unread counts for each channel (improves performance). - pub no_unreads: Option, - /// Returns MPIMs to the client in the API response. - pub mpim_aware: Option, - /// Exclude latest timestamps for channels, groups, mpims, and ims. Automatically sets no_unreads to 1 - pub no_latest: Option, - /// Only deliver presence events when requested by subscription. See [presence subscriptions](/docs/presence-and-status#subscriptions). - pub batch_presence_aware: Option, - /// Set this to `true` to receive the locale for users and channels. Defaults to `false` - pub include_locale: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct StartResponse { - pub bots: Option>, - pub channels: Option>, - error: Option, - pub groups: Option>, - pub ims: Option>, - pub mpims: Option>, - #[serde(default)] - ok: bool, - #[serde(rename = "self")] - pub slf: Option, - pub team: Option, +pub struct ConnectResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub r#_self: Option, + pub team: Option, pub url: Option, - pub users: Option>, } -impl Into>> for StartResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum StartError { - /// Team is being migrated between servers. See the team_migration_started event documentation for details. - MigrationInProgress, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for StartError { - fn from(s: &'a str) -> Self { - match s { - "migration_in_progress" => StartError::MigrationInProgress, - "not_authed" => StartError::NotAuthed, - "invalid_auth" => StartError::InvalidAuth, - "account_inactive" => StartError::AccountInactive, - "invalid_arg_name" => StartError::InvalidArgName, - "invalid_array_arg" => StartError::InvalidArrayArg, - "invalid_charset" => StartError::InvalidCharset, - "invalid_form_data" => StartError::InvalidFormData, - "invalid_post_type" => StartError::InvalidPostType, - "missing_post_type" => StartError::MissingPostType, - "team_added_to_org" => StartError::TeamAddedToOrg, - "request_timeout" => StartError::RequestTimeout, - _ => StartError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for StartError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - StartError::MigrationInProgress => "migration_in_progress: Team is being migrated between servers. See the team_migration_started event documentation for details.", -StartError::NotAuthed => "not_authed: No authentication token provided.", -StartError::InvalidAuth => "invalid_auth: Invalid authentication token.", -StartError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -StartError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -StartError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -StartError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -StartError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -StartError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -StartError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -StartError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -StartError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - StartError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - StartError::Unknown(ref s) => return write!(f, "{}", s), - StartError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for StartError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - StartError::MalformedResponse(_, ref e) => Some(e), - StartError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct ConnectError {} diff --git a/src/mod_types/search_types.rs b/src/mod_types/search_types.rs index 383379a5..9ee86342 100644 --- a/src/mod_types/search_types.rs +++ b/src/mod_types/search_types.rs @@ -1,411 +1,19 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -//! Search your team's files and messages. - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct AllRequest<'a> { - /// Search query. May contains booleans, etc. - pub query: &'a str, - /// Return matches sorted by either score or timestamp. - pub sort: Option<&'a str>, - /// Change sort direction to ascending (asc) or descending (desc). - pub sort_dir: Option<&'a str>, - /// Pass a value of true to enable query highlight markers (see below). - pub highlight: Option, - /// Number of items to return per page. - pub count: Option, - /// Page number of results to return. - pub page: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct AllResponse { - error: Option, - pub files: Option, - pub messages: Option, - #[serde(default)] - ok: bool, - pub query: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct AllResponseFiles { - pub matches: Vec, - pub paging: crate::Paging, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct AllResponseMessages { - pub matches: Vec, - pub paging: crate::Paging, -} - -impl Into>> for AllResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum AllError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for AllError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => AllError::NotAuthed, - "invalid_auth" => AllError::InvalidAuth, - "account_inactive" => AllError::AccountInactive, - "user_is_bot" => AllError::UserIsBot, - "invalid_arg_name" => AllError::InvalidArgName, - "invalid_array_arg" => AllError::InvalidArrayArg, - "invalid_charset" => AllError::InvalidCharset, - "invalid_form_data" => AllError::InvalidFormData, - "invalid_post_type" => AllError::InvalidPostType, - "missing_post_type" => AllError::MissingPostType, - "team_added_to_org" => AllError::TeamAddedToOrg, - "request_timeout" => AllError::RequestTimeout, - _ => AllError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for AllError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - AllError::NotAuthed => "not_authed: No authentication token provided.", -AllError::InvalidAuth => "invalid_auth: Invalid authentication token.", -AllError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -AllError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -AllError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -AllError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -AllError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -AllError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -AllError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -AllError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -AllError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -AllError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - AllError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - AllError::Unknown(ref s) => return write!(f, "{}", s), - AllError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for AllError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - AllError::MalformedResponse(_, ref e) => Some(e), - AllError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct FilesRequest<'a> { - /// Search query. May contain booleans, etc. - pub query: &'a str, - /// Return matches sorted by either score or timestamp. - pub sort: Option<&'a str>, - /// Change sort direction to ascending (asc) or descending (desc). - pub sort_dir: Option<&'a str>, - /// Pass a value of true to enable query highlight markers (see below). - pub highlight: Option, - /// Number of items to return per page. - pub count: Option, - /// Page number of results to return. - pub page: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct FilesResponse { - error: Option, - pub files: Option, - #[serde(default)] - ok: bool, +pub struct MessagesRequest { + /// Pass the number of results you want per "page". Maximum of `100`. + pub count: u64, + /// Pass a value of `true` to enable query highlight markers (see below). + pub highlight: bool, + pub page: u64, + /// Search query. pub query: Option, + /// Return matches sorted by either `score` or `timestamp`. + pub sort: String, + /// Change sort direction to ascending (`asc`) or descending (`desc`). + pub sort_dir: String, } -#[derive(Clone, Debug, Deserialize)] -pub struct FilesResponseFiles { - pub matches: Option>, - pub paging: Option, - pub total: Option, -} - -impl Into>> for FilesResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum FilesError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for FilesError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => FilesError::NotAuthed, - "invalid_auth" => FilesError::InvalidAuth, - "account_inactive" => FilesError::AccountInactive, - "user_is_bot" => FilesError::UserIsBot, - "invalid_arg_name" => FilesError::InvalidArgName, - "invalid_array_arg" => FilesError::InvalidArrayArg, - "invalid_charset" => FilesError::InvalidCharset, - "invalid_form_data" => FilesError::InvalidFormData, - "invalid_post_type" => FilesError::InvalidPostType, - "missing_post_type" => FilesError::MissingPostType, - "team_added_to_org" => FilesError::TeamAddedToOrg, - "request_timeout" => FilesError::RequestTimeout, - _ => FilesError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for FilesError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - FilesError::NotAuthed => "not_authed: No authentication token provided.", -FilesError::InvalidAuth => "invalid_auth: Invalid authentication token.", -FilesError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -FilesError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -FilesError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -FilesError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -FilesError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -FilesError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -FilesError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -FilesError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -FilesError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -FilesError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - FilesError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - FilesError::Unknown(ref s) => return write!(f, "{}", s), - FilesError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for FilesError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - FilesError::MalformedResponse(_, ref e) => Some(e), - FilesError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct MessagesRequest<'a> { - /// Search query. May contains booleans, etc. - pub query: &'a str, - /// Return matches sorted by either score or timestamp. - pub sort: Option<&'a str>, - /// Change sort direction to ascending (asc) or descending (desc). - pub sort_dir: Option<&'a str>, - /// Pass a value of true to enable query highlight markers (see below). - pub highlight: Option, - /// Number of items to return per page. - pub count: Option, - /// Page number of results to return. - pub page: Option, -} - -#[derive(Clone, Debug, Deserialize)] pub struct MessagesResponse { - error: Option, - pub messages: Option, - #[serde(default)] - ok: bool, - pub query: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct MessagesResponseMessages { - pub matches: Option>, - pub paging: Option, - pub total: Option, -} - -impl Into>> for MessagesResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum MessagesError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), + pub ok: Option, } -impl<'a, E: Error> From<&'a str> for MessagesError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => MessagesError::NotAuthed, - "invalid_auth" => MessagesError::InvalidAuth, - "account_inactive" => MessagesError::AccountInactive, - "user_is_bot" => MessagesError::UserIsBot, - "invalid_arg_name" => MessagesError::InvalidArgName, - "invalid_array_arg" => MessagesError::InvalidArrayArg, - "invalid_charset" => MessagesError::InvalidCharset, - "invalid_form_data" => MessagesError::InvalidFormData, - "invalid_post_type" => MessagesError::InvalidPostType, - "missing_post_type" => MessagesError::MissingPostType, - "team_added_to_org" => MessagesError::TeamAddedToOrg, - "request_timeout" => MessagesError::RequestTimeout, - _ => MessagesError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for MessagesError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - MessagesError::NotAuthed => "not_authed: No authentication token provided.", -MessagesError::InvalidAuth => "invalid_auth: Invalid authentication token.", -MessagesError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -MessagesError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -MessagesError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -MessagesError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -MessagesError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -MessagesError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -MessagesError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -MessagesError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -MessagesError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -MessagesError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - MessagesError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - MessagesError::Unknown(ref s) => return write!(f, "{}", s), - MessagesError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for MessagesError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - MessagesError::MalformedResponse(_, ref e) => Some(e), - MessagesError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct MessagesError {} diff --git a/src/mod_types/stars_types.rs b/src/mod_types/stars_types.rs index 35eca4d4..881f17f5 100644 --- a/src/mod_types/stars_types.rs +++ b/src/mod_types/stars_types.rs @@ -1,519 +1,358 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct AddRequest<'a> { - /// File to add star to. - pub file: Option<&'a str>, - /// File comment to add star to. - pub file_comment: Option<&'a str>, - /// Channel to add star to, or channel where the message to add star to was posted (used with timestamp). - pub channel: Option<&'a str>, - /// Timestamp of the message to add star to. - pub timestamp: Option, +pub struct ListRequest { + pub count: String, + pub page: String, + /// Parameter for pagination. Set `cursor` equal to the `next_cursor` attribute returned by the previous request's `response_metadata`. This parameter is optional, but pagination is mandatory: the default value simply fetches the first "page" of the collection. See [pagination](/docs/pagination) for more details. + pub cursor: String, + /// The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. + pub limit: u64, } -#[derive(Clone, Debug, Deserialize)] -pub struct AddResponse { - error: Option, - #[serde(default)] - ok: bool, +pub struct ListAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, } -impl Into>> for AddResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum AddError { - /// Value passed for timestamp was invalid. - BadTimestamp, - /// Message specified by channel and timestamp does not exist. - MessageNotFound, - /// File specified by file does not exist. - FileNotFound, - /// File comment specified by file_comment does not exist. - FileCommentNotFound, - /// Channel, private group, or DM specified by channel does not exist - ChannelNotFound, - /// file, file_comment, channel and timestamp was not specified. - NoItemSpecified, - /// The specified item has already been starred by the authenticated user. - AlreadyStarred, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), +pub struct ListBlocksInner { + pub r#type: Option, } -impl<'a, E: Error> From<&'a str> for AddError { - fn from(s: &'a str) -> Self { - match s { - "bad_timestamp" => AddError::BadTimestamp, - "message_not_found" => AddError::MessageNotFound, - "file_not_found" => AddError::FileNotFound, - "file_comment_not_found" => AddError::FileCommentNotFound, - "channel_not_found" => AddError::ChannelNotFound, - "no_item_specified" => AddError::NoItemSpecified, - "already_starred" => AddError::AlreadyStarred, - "not_authed" => AddError::NotAuthed, - "invalid_auth" => AddError::InvalidAuth, - "account_inactive" => AddError::AccountInactive, - "invalid_arg_name" => AddError::InvalidArgName, - "invalid_array_arg" => AddError::InvalidArrayArg, - "invalid_charset" => AddError::InvalidCharset, - "invalid_form_data" => AddError::InvalidFormData, - "invalid_post_type" => AddError::InvalidPostType, - "missing_post_type" => AddError::MissingPostType, - "team_added_to_org" => AddError::TeamAddedToOrg, - "request_timeout" => AddError::RequestTimeout, - _ => AddError::Unknown(s.to_owned()), - } - } +pub struct ListIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, } -impl fmt::Display for AddError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - AddError::BadTimestamp => "bad_timestamp: Value passed for timestamp was invalid.", -AddError::MessageNotFound => "message_not_found: Message specified by channel and timestamp does not exist.", -AddError::FileNotFound => "file_not_found: File specified by file does not exist.", -AddError::FileCommentNotFound => "file_comment_not_found: File comment specified by file_comment does not exist.", -AddError::ChannelNotFound => "channel_not_found: Channel, private group, or DM specified by channel does not exist", -AddError::NoItemSpecified => "no_item_specified: file, file_comment, channel and timestamp was not specified.", -AddError::AlreadyStarred => "already_starred: The specified item has already been starred by the authenticated user.", -AddError::NotAuthed => "not_authed: No authentication token provided.", -AddError::InvalidAuth => "invalid_auth: Invalid authentication token.", -AddError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -AddError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -AddError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -AddError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -AddError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -AddError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -AddError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -AddError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -AddError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - AddError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - AddError::Unknown(ref s) => return write!(f, "{}", s), - AddError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } +pub struct ListBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, } -impl Error for AddError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - AddError::MalformedResponse(_, ref e) => Some(e), - AddError::Client(ref inner) => Some(inner), - _ => None, - } - } +pub struct ListReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, } -#[derive(Clone, Default, Debug)] -pub struct ListRequest { - /// Number of items to return per page. - pub count: Option, - /// Page number of results to return. - pub page: Option, +pub struct ListCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, } -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponse { - error: Option, - pub items: Option>, - #[serde(default)] - ok: bool, - pub paging: Option, +pub struct ListReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, } -#[derive(Clone, Debug)] -pub enum ListResponseItem { - Message(ListResponseItemMessage), - File(ListResponseItemFile), - FileComment(ListResponseItemFileComment), - Channel(ListResponseItemChannel), - Im(ListResponseItemIm), - Group(ListResponseItemGroup), +pub struct ListSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, } -impl<'de> ::serde::Deserialize<'de> for ListResponseItem { - fn deserialize(deserializer: D) -> Result - where - D: ::serde::Deserializer<'de>, - { - use ::serde::de::Error as SerdeError; - - const VARIANTS: &[&str] = &["message", "file", "file_comment", "channel", "im", "group"]; +pub struct ListFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: ListSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} - let value = ::serde_json::Value::deserialize(deserializer)?; - if let Some(ty_val) = value.get("type") { - if let Some(ty) = ty_val.as_str() { - match ty { - "message" => ::serde_json::from_value::(value.clone()) - .map(ListResponseItem::Message) - .map_err(|e| D::Error::custom(&format!("{}", e))), - "file" => ::serde_json::from_value::(value.clone()) - .map(ListResponseItem::File) - .map_err(|e| D::Error::custom(&format!("{}", e))), - "file_comment" => { - ::serde_json::from_value::(value.clone()) - .map(ListResponseItem::FileComment) - .map_err(|e| D::Error::custom(&format!("{}", e))) - } - "channel" => ::serde_json::from_value::(value.clone()) - .map(ListResponseItem::Channel) - .map_err(|e| D::Error::custom(&format!("{}", e))), - "im" => ::serde_json::from_value::(value.clone()) - .map(ListResponseItem::Im) - .map_err(|e| D::Error::custom(&format!("{}", e))), - "group" => ::serde_json::from_value::(value.clone()) - .map(ListResponseItem::Group) - .map_err(|e| D::Error::custom(&format!("{}", e))), - _ => Err(D::Error::unknown_variant(ty, VARIANTS)), - } - } else { - Err(D::Error::invalid_type( - ::serde::de::Unexpected::Unit, - &"a string", - )) - } - } else { - Err(D::Error::missing_field("type")) - } - } +pub struct ListReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, } -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponseItemChannel { - pub channel: String, - #[serde(rename = "type")] - pub ty: String, +pub struct ListShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, } -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponseItemFile { - pub file: crate::File, - #[serde(rename = "type")] - pub ty: String, +pub struct ListFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: ListShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, } -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponseItemFileComment { - pub comment: crate::FileComment, - pub file: crate::File, - #[serde(rename = "type")] - pub ty: String, +pub struct ListIcons1Inner { + pub emoji: String, + pub image_64: String, } -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponseItemGroup { - pub group: String, - #[serde(rename = "type")] - pub ty: String, +pub struct ListReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, } -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponseItemIm { - pub channel: String, - #[serde(rename = "type")] - pub ty: String, +pub struct ListUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, } -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponseItemMessage { - pub channel: String, - pub message: crate::Message, - #[serde(rename = "type")] - pub ty: String, +pub struct ListMessageInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: ListBotProfileInner, + pub client_msg_id: String, + pub comment: ListCommentInner, + pub display_as_bot: bool, + pub file: ListFileInner, + pub files: Vec, + pub icons: ListIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: ListUserProfileInner, + pub user_team: String, + pub username: String, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } +pub struct ListItemsInner { + pub channel: Option, + pub date_create: Option, + pub message: Option, + pub r#type: Option, } -#[derive(Debug)] -pub enum ListError { - /// Value passed for user was invalid - UserNotFound, - /// The requested user is not visible to the calling user - UserNotVisible, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), + +pub struct ListPagingInner { + pub count: u64, + pub page: Option, + pub pages: u64, + pub per_page: u64, + pub spill: u64, + pub total: Option, } -impl<'a, E: Error> From<&'a str> for ListError { - fn from(s: &'a str) -> Self { - match s { - "user_not_found" => ListError::UserNotFound, - "user_not_visible" => ListError::UserNotVisible, - "not_authed" => ListError::NotAuthed, - "invalid_auth" => ListError::InvalidAuth, - "account_inactive" => ListError::AccountInactive, - "user_is_bot" => ListError::UserIsBot, - "invalid_arg_name" => ListError::InvalidArgName, - "invalid_array_arg" => ListError::InvalidArrayArg, - "invalid_charset" => ListError::InvalidCharset, - "invalid_form_data" => ListError::InvalidFormData, - "invalid_post_type" => ListError::InvalidPostType, - "missing_post_type" => ListError::MissingPostType, - "team_added_to_org" => ListError::TeamAddedToOrg, - "request_timeout" => ListError::RequestTimeout, - _ => ListError::Unknown(s.to_owned()), - } - } +pub struct ListResponse { + pub callstack: String, + pub error: String, + pub items: Option>>, + pub ok: Option, + pub paging: ListPagingInner, } -impl fmt::Display for ListError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ListError::UserNotFound => "user_not_found: Value passed for user was invalid", -ListError::UserNotVisible => "user_not_visible: The requested user is not visible to the calling user", -ListError::NotAuthed => "not_authed: No authentication token provided.", -ListError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ListError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ListError::Unknown(ref s) => return write!(f, "{}", s), - ListError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } +pub struct ListError {} + +pub struct AddRequest { + /// Channel to add star to, or channel where the message to add star to was posted (used with `timestamp`). + pub channel: String, + /// File to add star to. + pub file: String, + /// File comment to add star to. + pub file_comment: String, + /// Timestamp of the message to add star to. + pub timestamp: String, } -impl Error for ListError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ListError::MalformedResponse(_, ref e) => Some(e), - ListError::Client(ref inner) => Some(inner), - _ => None, - } - } +pub struct AddResponse { + pub callstack: String, + pub error: String, + pub ok: Option, } -#[derive(Clone, Default, Debug)] -pub struct RemoveRequest<'a> { +pub struct AddError {} + +pub struct RemoveRequest { + /// Channel to remove star from, or channel where the message to remove star from was posted (used with `timestamp`). + pub channel: String, /// File to remove star from. - pub file: Option<&'a str>, + pub file: String, /// File comment to remove star from. - pub file_comment: Option<&'a str>, - /// Channel to remove star from, or channel where the message to remove star from was posted (used with timestamp). - pub channel: Option<&'a str>, + pub file_comment: String, /// Timestamp of the message to remove star from. - pub timestamp: Option, + pub timestamp: String, } -#[derive(Clone, Debug, Deserialize)] pub struct RemoveResponse { - error: Option, - #[serde(default)] - ok: bool, + pub callstack: String, + pub error: String, + pub ok: Option, } -impl Into>> for RemoveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum RemoveError { - /// Value passed for timestamp was invalid. - BadTimestamp, - /// Message specified by channel and timestamp does not exist. - MessageNotFound, - /// File specified by file does not exist. - FileNotFound, - /// File comment specified by file_comment does not exist. - FileCommentNotFound, - /// Channel, private group, or DM specified by channel does not exist - ChannelNotFound, - /// file, file_comment, channel and timestamp was not specified. - NoItemSpecified, - /// The specified item is not currently starred by the authenticated user. - NotStarred, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for RemoveError { - fn from(s: &'a str) -> Self { - match s { - "bad_timestamp" => RemoveError::BadTimestamp, - "message_not_found" => RemoveError::MessageNotFound, - "file_not_found" => RemoveError::FileNotFound, - "file_comment_not_found" => RemoveError::FileCommentNotFound, - "channel_not_found" => RemoveError::ChannelNotFound, - "no_item_specified" => RemoveError::NoItemSpecified, - "not_starred" => RemoveError::NotStarred, - "not_authed" => RemoveError::NotAuthed, - "invalid_auth" => RemoveError::InvalidAuth, - "account_inactive" => RemoveError::AccountInactive, - "invalid_arg_name" => RemoveError::InvalidArgName, - "invalid_array_arg" => RemoveError::InvalidArrayArg, - "invalid_charset" => RemoveError::InvalidCharset, - "invalid_form_data" => RemoveError::InvalidFormData, - "invalid_post_type" => RemoveError::InvalidPostType, - "missing_post_type" => RemoveError::MissingPostType, - "team_added_to_org" => RemoveError::TeamAddedToOrg, - "request_timeout" => RemoveError::RequestTimeout, - _ => RemoveError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for RemoveError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - RemoveError::BadTimestamp => "bad_timestamp: Value passed for timestamp was invalid.", -RemoveError::MessageNotFound => "message_not_found: Message specified by channel and timestamp does not exist.", -RemoveError::FileNotFound => "file_not_found: File specified by file does not exist.", -RemoveError::FileCommentNotFound => "file_comment_not_found: File comment specified by file_comment does not exist.", -RemoveError::ChannelNotFound => "channel_not_found: Channel, private group, or DM specified by channel does not exist", -RemoveError::NoItemSpecified => "no_item_specified: file, file_comment, channel and timestamp was not specified.", -RemoveError::NotStarred => "not_starred: The specified item is not currently starred by the authenticated user.", -RemoveError::NotAuthed => "not_authed: No authentication token provided.", -RemoveError::InvalidAuth => "invalid_auth: Invalid authentication token.", -RemoveError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -RemoveError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -RemoveError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -RemoveError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -RemoveError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -RemoveError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -RemoveError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -RemoveError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -RemoveError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - RemoveError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - RemoveError::Unknown(ref s) => return write!(f, "{}", s), - RemoveError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for RemoveError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - RemoveError::MalformedResponse(_, ref e) => Some(e), - RemoveError::Client(ref inner) => Some(inner), - _ => None, - } - } -} +pub struct RemoveError {} diff --git a/src/mod_types/team/mod.rs b/src/mod_types/team/mod.rs new file mode 100644 index 00000000..e2918f66 --- /dev/null +++ b/src/mod_types/team/mod.rs @@ -0,0 +1,175 @@ +pub mod profile_types; + +pub struct IntegrationLogsRequest { + /// Filter logs to this Slack app. Defaults to all logs. + pub app_id: String, + /// Filter logs with this change type. Defaults to all logs. + pub change_type: String, + pub count: String, + pub page: String, + /// Filter logs to this service. Defaults to all logs. + pub service_id: String, + /// Filter logs generated by this user’s actions. Defaults to all logs. + pub user: String, +} + +pub struct IntegrationLogsLogsInner { + pub admin_app_id: String, + pub app_id: Option, + pub app_type: Option, + pub change_type: Option, + pub channel: String, + pub date: Option, + pub scope: Option, + pub service_id: String, + pub service_type: String, + pub user_id: Option, + pub user_name: Option, +} + +pub struct IntegrationLogsPagingInner { + pub count: u64, + pub page: Option, + pub pages: u64, + pub per_page: u64, + pub spill: u64, + pub total: Option, +} + +pub struct IntegrationLogsResponse { + pub callstack: String, + pub error: String, + pub logs: Option>, + pub ok: Option, + pub paging: Option, +} + +pub struct IntegrationLogsError {} + +pub struct AccessLogsRequest { + /// End of time range of logs to include in results (inclusive). + pub before: String, + pub count: String, + pub page: String, +} + +pub struct AccessLogsLoginsInner { + pub count: Option, + pub country: Option, + pub date_first: Option, + pub date_last: Option, + pub ip: Option, + pub isp: Option, + pub region: Option, + pub user_agent: Option, + pub user_id: Option, + pub username: Option, +} + +pub struct AccessLogsPagingInner { + pub count: u64, + pub page: Option, + pub pages: u64, + pub per_page: u64, + pub spill: u64, + pub total: Option, +} + +pub struct AccessLogsResponse { + pub callstack: String, + pub error: String, + pub logins: Option>, + pub ok: Option, + pub paging: Option, +} + +pub struct AccessLogsError {} + +pub struct InfoRequest { + /// Team to get info on, if omitted, will return information about the current team. Will only return team that the authenticated token is allowed to see through external shared channels + pub team: String, +} + +pub struct InfoCurrentInner { + pub date_started: Option, + pub team_id: Option, +} + +pub struct InfoExternalOrgMigrationsInner { + pub current: Option>, + pub date_updated: Option, +} + +pub struct InfoIconInner { + pub image_102: String, + pub image_132: String, + pub image_230: String, + pub image_34: String, + pub image_44: String, + pub image_68: String, + pub image_88: String, + pub image_default: bool, +} + +pub struct InfoPrimaryOwnerInner { + pub email: Option, + pub id: Option, +} + +pub struct InfoSsoProviderInner { + pub label: String, + pub name: String, + pub r#type: String, +} + +pub struct InfoTeamInner { + pub archived: bool, + pub avatar_base_url: String, + pub created: u64, + pub date_create: u64, + pub deleted: bool, + pub description: String, + pub discoverable: Vec, + pub domain: Option, + pub email_domain: Option, + pub enterprise_id: String, + pub enterprise_name: String, + pub external_org_migrations: InfoExternalOrgMigrationsInner, + pub has_compliance_export: bool, + pub icon: Option, + pub id: Option, + pub is_assigned: bool, + pub is_enterprise: u64, + pub is_over_storage_limit: bool, + pub limit_ts: u64, + pub locale: String, + pub messages_count: u64, + pub msg_edit_window_mins: u64, + pub name: Option, + pub over_integrations_limit: bool, + pub over_storage_limit: bool, + pub pay_prod_cur: String, + pub plan: String, + pub primary_owner: InfoPrimaryOwnerInner, + pub sso_provider: InfoSsoProviderInner, +} + +pub struct InfoResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub team: Option, +} + +pub struct InfoError {} + +pub struct BillableInfoRequest { + /// A user to retrieve the billable information for. Defaults to all users. + pub user: String, +} + +pub struct BillableInfoResponse { + pub ok: Option, +} + +pub struct BillableInfoError {} diff --git a/src/mod_types/team/profile_types.rs b/src/mod_types/team/profile_types.rs new file mode 100644 index 00000000..6e37727d --- /dev/null +++ b/src/mod_types/team/profile_types.rs @@ -0,0 +1,36 @@ +pub struct GetRequest { + /// Filter by visibility. + pub visibility: String, +} + +pub struct GetOptionsInner { + pub is_custom: bool, + pub is_multiple_entry: bool, + pub is_protected: bool, + pub is_scim: bool, +} + +pub struct GetFieldsInner { + pub field_name: String, + pub hint: Option, + pub id: Option, + pub is_hidden: bool, + pub label: Option, + pub options: Vec, + pub ordering: Option, + pub possible_values: Vec, + pub r#type: Option, +} + +pub struct GetProfileInner { + pub fields: Option>, +} + +pub struct GetResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub profile: Option, +} + +pub struct GetError {} diff --git a/src/mod_types/team_profile_types.rs b/src/mod_types/team_profile_types.rs deleted file mode 100644 index fe32733b..00000000 --- a/src/mod_types/team_profile_types.rs +++ /dev/null @@ -1,147 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct GetRequest<'a> { - /// Filter by visibility. - pub visibility: Option<&'a str>, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct GetResponse { - error: Option, - #[serde(default)] - ok: bool, - pub profile: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct GetResponseProfile { - pub fields: Option>, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct GetResponseProfileField { - pub hint: Option, - pub id: Option, - pub is_hidden: Option, - pub label: Option, - pub options: Option>, - pub ordering: Option, - pub possible_values: Option>, - #[serde(rename = "type")] - pub ty: Option, -} - -impl Into>> for GetResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum GetError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for GetError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => GetError::NotAuthed, - "invalid_auth" => GetError::InvalidAuth, - "account_inactive" => GetError::AccountInactive, - "user_is_bot" => GetError::UserIsBot, - "invalid_arg_name" => GetError::InvalidArgName, - "invalid_array_arg" => GetError::InvalidArrayArg, - "invalid_charset" => GetError::InvalidCharset, - "invalid_form_data" => GetError::InvalidFormData, - "invalid_post_type" => GetError::InvalidPostType, - "missing_post_type" => GetError::MissingPostType, - "team_added_to_org" => GetError::TeamAddedToOrg, - "request_timeout" => GetError::RequestTimeout, - _ => GetError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for GetError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - GetError::NotAuthed => "not_authed: No authentication token provided.", -GetError::InvalidAuth => "invalid_auth: Invalid authentication token.", -GetError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -GetError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -GetError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -GetError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -GetError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -GetError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -GetError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -GetError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -GetError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -GetError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - GetError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - GetError::Unknown(ref s) => return write!(f, "{}", s), - GetError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for GetError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - GetError::MalformedResponse(_, ref e) => Some(e), - GetError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/team_types.rs b/src/mod_types/team_types.rs deleted file mode 100644 index 6a59dd36..00000000 --- a/src/mod_types/team_types.rs +++ /dev/null @@ -1,508 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct AccessLogsRequest { - /// Number of items to return per page. - pub count: Option, - /// Page number of results to return. - pub page: Option, - /// End of time range of logs to include in results (inclusive). - pub before: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct AccessLogsResponse { - error: Option, - pub logins: Option>, - #[serde(default)] - ok: bool, - pub paging: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct AccessLogsResponseLogin { - pub count: Option, - pub country: Option, - pub date_first: Option, - pub date_last: Option, - pub ip: Option, - pub isp: Option, - pub region: Option, - pub user_agent: Option, - pub user_id: Option, - pub username: Option, -} - -impl Into>> for AccessLogsResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum AccessLogsError { - /// This is only available to paid teams. - PaidOnly, - /// It is not possible to request more than 1000 items per page or more than 100 pages. - OverPaginationLimit, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for AccessLogsError { - fn from(s: &'a str) -> Self { - match s { - "paid_only" => AccessLogsError::PaidOnly, - "over_pagination_limit" => AccessLogsError::OverPaginationLimit, - "not_authed" => AccessLogsError::NotAuthed, - "invalid_auth" => AccessLogsError::InvalidAuth, - "account_inactive" => AccessLogsError::AccountInactive, - "user_is_bot" => AccessLogsError::UserIsBot, - "invalid_arg_name" => AccessLogsError::InvalidArgName, - "invalid_array_arg" => AccessLogsError::InvalidArrayArg, - "invalid_charset" => AccessLogsError::InvalidCharset, - "invalid_form_data" => AccessLogsError::InvalidFormData, - "invalid_post_type" => AccessLogsError::InvalidPostType, - "missing_post_type" => AccessLogsError::MissingPostType, - "team_added_to_org" => AccessLogsError::TeamAddedToOrg, - "request_timeout" => AccessLogsError::RequestTimeout, - _ => AccessLogsError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for AccessLogsError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - AccessLogsError::PaidOnly => "paid_only: This is only available to paid teams.", -AccessLogsError::OverPaginationLimit => "over_pagination_limit: It is not possible to request more than 1000 items per page or more than 100 pages.", -AccessLogsError::NotAuthed => "not_authed: No authentication token provided.", -AccessLogsError::InvalidAuth => "invalid_auth: Invalid authentication token.", -AccessLogsError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -AccessLogsError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -AccessLogsError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -AccessLogsError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -AccessLogsError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -AccessLogsError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -AccessLogsError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -AccessLogsError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -AccessLogsError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -AccessLogsError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - AccessLogsError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - AccessLogsError::Unknown(ref s) => return write!(f, "{}", s), - AccessLogsError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for AccessLogsError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - AccessLogsError::MalformedResponse(_, ref e) => Some(e), - AccessLogsError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct BillableInfoRequest<'a> { - /// A user to retrieve the billable information for. Defaults to all users. - pub user: Option<&'a str>, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct BillableInfoResponse { - pub billable_info: Option>, - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for BillableInfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum BillableInfoError { - /// Unable to find the requested user. - UserNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for BillableInfoError { - fn from(s: &'a str) -> Self { - match s { - "user_not_found" => BillableInfoError::UserNotFound, - "not_authed" => BillableInfoError::NotAuthed, - "invalid_auth" => BillableInfoError::InvalidAuth, - "account_inactive" => BillableInfoError::AccountInactive, - "user_is_bot" => BillableInfoError::UserIsBot, - "invalid_arg_name" => BillableInfoError::InvalidArgName, - "invalid_array_arg" => BillableInfoError::InvalidArrayArg, - "invalid_charset" => BillableInfoError::InvalidCharset, - "invalid_form_data" => BillableInfoError::InvalidFormData, - "invalid_post_type" => BillableInfoError::InvalidPostType, - "missing_post_type" => BillableInfoError::MissingPostType, - "team_added_to_org" => BillableInfoError::TeamAddedToOrg, - "request_timeout" => BillableInfoError::RequestTimeout, - _ => BillableInfoError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for BillableInfoError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - BillableInfoError::UserNotFound => "user_not_found: Unable to find the requested user.", -BillableInfoError::NotAuthed => "not_authed: No authentication token provided.", -BillableInfoError::InvalidAuth => "invalid_auth: Invalid authentication token.", -BillableInfoError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -BillableInfoError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -BillableInfoError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -BillableInfoError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -BillableInfoError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -BillableInfoError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -BillableInfoError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -BillableInfoError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -BillableInfoError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -BillableInfoError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - BillableInfoError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - BillableInfoError::Unknown(ref s) => return write!(f, "{}", s), - BillableInfoError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for BillableInfoError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - BillableInfoError::MalformedResponse(_, ref e) => Some(e), - BillableInfoError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Debug, Deserialize)] -pub struct InfoResponse { - error: Option, - #[serde(default)] - ok: bool, - pub team: Option, -} - -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum InfoError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for InfoError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => InfoError::NotAuthed, - "invalid_auth" => InfoError::InvalidAuth, - "account_inactive" => InfoError::AccountInactive, - "invalid_arg_name" => InfoError::InvalidArgName, - "invalid_array_arg" => InfoError::InvalidArrayArg, - "invalid_charset" => InfoError::InvalidCharset, - "invalid_form_data" => InfoError::InvalidFormData, - "invalid_post_type" => InfoError::InvalidPostType, - "missing_post_type" => InfoError::MissingPostType, - "team_added_to_org" => InfoError::TeamAddedToOrg, - "request_timeout" => InfoError::RequestTimeout, - _ => InfoError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for InfoError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - InfoError::NotAuthed => "not_authed: No authentication token provided.", -InfoError::InvalidAuth => "invalid_auth: Invalid authentication token.", -InfoError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -InfoError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -InfoError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -InfoError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -InfoError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -InfoError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -InfoError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -InfoError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -InfoError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - InfoError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - InfoError::Unknown(ref s) => return write!(f, "{}", s), - InfoError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for InfoError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - InfoError::MalformedResponse(_, ref e) => Some(e), - InfoError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct IntegrationLogsRequest<'a> { - /// Filter logs to this service. Defaults to all logs. - pub service_id: Option<&'a str>, - /// Filter logs to this Slack app. Defaults to all logs. - pub app_id: Option<&'a str>, - /// Filter logs generated by this user’s actions. Defaults to all logs. - pub user: Option<&'a str>, - /// Filter logs with this change type. Defaults to all logs. - pub change_type: Option<&'a str>, - /// Number of items to return per page. - pub count: Option, - /// Page number of results to return. - pub page: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct IntegrationLogsResponse { - error: Option, - pub logs: Option>, - #[serde(default)] - ok: bool, - pub paging: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct IntegrationLogsResponseLog { - pub app_id: Option, - pub app_type: Option, - pub change_type: Option, - pub channel: Option, - pub date: Option, - pub reason: Option, - pub scope: Option, - pub service_id: Option, - pub service_type: Option, - pub user_id: Option, - pub user_name: Option, -} - -impl Into>> - for IntegrationLogsResponse -{ - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum IntegrationLogsError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for IntegrationLogsError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => IntegrationLogsError::NotAuthed, - "invalid_auth" => IntegrationLogsError::InvalidAuth, - "account_inactive" => IntegrationLogsError::AccountInactive, - "user_is_bot" => IntegrationLogsError::UserIsBot, - "invalid_arg_name" => IntegrationLogsError::InvalidArgName, - "invalid_array_arg" => IntegrationLogsError::InvalidArrayArg, - "invalid_charset" => IntegrationLogsError::InvalidCharset, - "invalid_form_data" => IntegrationLogsError::InvalidFormData, - "invalid_post_type" => IntegrationLogsError::InvalidPostType, - "missing_post_type" => IntegrationLogsError::MissingPostType, - "team_added_to_org" => IntegrationLogsError::TeamAddedToOrg, - "request_timeout" => IntegrationLogsError::RequestTimeout, - _ => IntegrationLogsError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for IntegrationLogsError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - IntegrationLogsError::NotAuthed => "not_authed: No authentication token provided.", -IntegrationLogsError::InvalidAuth => "invalid_auth: Invalid authentication token.", -IntegrationLogsError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -IntegrationLogsError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -IntegrationLogsError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -IntegrationLogsError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -IntegrationLogsError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -IntegrationLogsError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -IntegrationLogsError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -IntegrationLogsError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -IntegrationLogsError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -IntegrationLogsError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - IntegrationLogsError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - IntegrationLogsError::Unknown(ref s) => return write!(f, "{}", s), - IntegrationLogsError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for IntegrationLogsError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - IntegrationLogsError::MalformedResponse(_, ref e) => Some(e), - IntegrationLogsError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/usergroups/mod.rs b/src/mod_types/usergroups/mod.rs new file mode 100644 index 00000000..57f60e6b --- /dev/null +++ b/src/mod_types/usergroups/mod.rs @@ -0,0 +1,242 @@ +pub mod users_types; + +pub struct CreateRequest { + /// A comma separated string of encoded channel IDs for which the User Group uses as a default. + pub channels: String, + /// A short description of the User Group. + pub description: String, + /// A mention handle. Must be unique among channels, users and User Groups. + pub handle: String, + /// Include the number of users in each User Group. + pub include_count: bool, + /// A name for the User Group. Must be unique among User Groups. + pub name: Option, +} + +pub struct CreatePrefsInner { + pub channels: Option>, + pub groups: Option>, +} + +pub struct CreateUsergroupInner { + pub auto_provision: Option, + pub auto_type: Option>, + pub channel_count: u64, + pub created_by: Option, + pub date_create: Option, + pub date_delete: Option, + pub date_update: Option, + pub deleted_by: Option>, + pub description: Option, + pub enterprise_subteam_id: Option, + pub handle: Option, + pub id: Option, + pub is_external: Option, + pub is_subteam: Option, + pub is_usergroup: Option, + pub name: Option, + pub prefs: Option, + pub team_id: Option, + pub updated_by: Option, + pub user_count: u64, + pub users: Vec, +} + +pub struct CreateResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub usergroup: Option, +} + +pub struct CreateError {} + +pub struct UpdateRequest { + /// A mention handle. Must be unique among channels, users and User Groups. + pub handle: String, + /// A short description of the User Group. + pub description: String, + /// A comma separated string of encoded channel IDs for which the User Group uses as a default. + pub channels: String, + /// Include the number of users in the User Group. + pub include_count: bool, + /// The encoded ID of the User Group to update. + pub usergroup: Option, + /// A name for the User Group. Must be unique among User Groups. + pub name: String, +} + +pub struct UpdatePrefsInner { + pub channels: Option>, + pub groups: Option>, +} + +pub struct UpdateUsergroupInner { + pub auto_provision: Option, + pub auto_type: Option>, + pub channel_count: u64, + pub created_by: Option, + pub date_create: Option, + pub date_delete: Option, + pub date_update: Option, + pub deleted_by: Option>, + pub description: Option, + pub enterprise_subteam_id: Option, + pub handle: Option, + pub id: Option, + pub is_external: Option, + pub is_subteam: Option, + pub is_usergroup: Option, + pub name: Option, + pub prefs: Option, + pub team_id: Option, + pub updated_by: Option, + pub user_count: u64, + pub users: Vec, +} + +pub struct UpdateResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub usergroup: Option, +} + +pub struct UpdateError {} + +pub struct EnableRequest { + /// Include the number of users in the User Group. + pub include_count: bool, + /// The encoded ID of the User Group to enable. + pub usergroup: Option, +} + +pub struct EnablePrefsInner { + pub channels: Option>, + pub groups: Option>, +} + +pub struct EnableUsergroupInner { + pub auto_provision: Option, + pub auto_type: Option>, + pub channel_count: u64, + pub created_by: Option, + pub date_create: Option, + pub date_delete: Option, + pub date_update: Option, + pub deleted_by: Option>, + pub description: Option, + pub enterprise_subteam_id: Option, + pub handle: Option, + pub id: Option, + pub is_external: Option, + pub is_subteam: Option, + pub is_usergroup: Option, + pub name: Option, + pub prefs: Option, + pub team_id: Option, + pub updated_by: Option, + pub user_count: u64, + pub users: Vec, +} + +pub struct EnableResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub usergroup: Option, +} + +pub struct EnableError {} + +pub struct DisableRequest { + /// Include the number of users in the User Group. + pub include_count: bool, + /// The encoded ID of the User Group to disable. + pub usergroup: Option, +} + +pub struct DisablePrefsInner { + pub channels: Option>, + pub groups: Option>, +} + +pub struct DisableUsergroupInner { + pub auto_provision: Option, + pub auto_type: Option>, + pub channel_count: u64, + pub created_by: Option, + pub date_create: Option, + pub date_delete: Option, + pub date_update: Option, + pub deleted_by: Option>, + pub description: Option, + pub enterprise_subteam_id: Option, + pub handle: Option, + pub id: Option, + pub is_external: Option, + pub is_subteam: Option, + pub is_usergroup: Option, + pub name: Option, + pub prefs: Option, + pub team_id: Option, + pub updated_by: Option, + pub user_count: u64, + pub users: Vec, +} + +pub struct DisableResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub usergroup: Option, +} + +pub struct DisableError {} + +pub struct ListRequest { + /// Include the list of users for each User Group. + pub include_users: bool, + /// Include the number of users in each User Group. + pub include_count: bool, + /// Include disabled User Groups. + pub include_disabled: bool, +} + +pub struct ListPrefsInner { + pub channels: Option>, + pub groups: Option>, +} + +pub struct ListUsergroupsInner { + pub auto_provision: Option, + pub auto_type: Option>, + pub channel_count: u64, + pub created_by: Option, + pub date_create: Option, + pub date_delete: Option, + pub date_update: Option, + pub deleted_by: Option>, + pub description: Option, + pub enterprise_subteam_id: Option, + pub handle: Option, + pub id: Option, + pub is_external: Option, + pub is_subteam: Option, + pub is_usergroup: Option, + pub name: Option, + pub prefs: Option, + pub team_id: Option, + pub updated_by: Option, + pub user_count: u64, + pub users: Vec, +} + +pub struct ListResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub usergroups: Option>, +} + +pub struct ListError {} diff --git a/src/mod_types/usergroups/users_types.rs b/src/mod_types/usergroups/users_types.rs new file mode 100644 index 00000000..7e948f49 --- /dev/null +++ b/src/mod_types/usergroups/users_types.rs @@ -0,0 +1,62 @@ +pub struct UpdateRequest { + /// Include the number of users in the User Group. + pub include_count: bool, + /// The encoded ID of the User Group to update. + pub usergroup: Option, + /// A comma separated string of encoded user IDs that represent the entire list of users for the User Group. + pub users: Option, +} + +pub struct UpdatePrefsInner { + pub channels: Option>, + pub groups: Option>, +} + +pub struct UpdateUsergroupInner { + pub auto_provision: Option, + pub auto_type: Option>, + pub channel_count: u64, + pub created_by: Option, + pub date_create: Option, + pub date_delete: Option, + pub date_update: Option, + pub deleted_by: Option>, + pub description: Option, + pub enterprise_subteam_id: Option, + pub handle: Option, + pub id: Option, + pub is_external: Option, + pub is_subteam: Option, + pub is_usergroup: Option, + pub name: Option, + pub prefs: Option, + pub team_id: Option, + pub updated_by: Option, + pub user_count: u64, + pub users: Vec, +} + +pub struct UpdateResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub usergroup: Option, +} + +pub struct UpdateError {} + +pub struct ListRequest { + /// Allow results that involve disabled User Groups. + pub include_disabled: bool, + /// The encoded ID of the User Group to update. + pub usergroup: Option, +} + +pub struct ListResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub users: Option>, +} + +pub struct ListError {} diff --git a/src/mod_types/usergroups_types.rs b/src/mod_types/usergroups_types.rs deleted file mode 100644 index c56d3f30..00000000 --- a/src/mod_types/usergroups_types.rs +++ /dev/null @@ -1,617 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -//! Get info on your team's User Groups. - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct CreateRequest<'a> { - /// A name for the User Group. Must be unique among User Groups. - pub name: &'a str, - /// A mention handle. Must be unique among channels, users and User Groups. - pub handle: Option<&'a str>, - /// A short description of the User Group. - pub description: Option<&'a str>, - /// A comma separated string of encoded channel IDs for which the User Group uses as a default. - pub channels: Option<&'a str>, - /// Include the number of users in each User Group. - pub include_count: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct CreateResponse { - error: Option, - #[serde(default)] - ok: bool, - pub usergroup: Option, -} - -impl Into>> for CreateResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum CreateError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for CreateError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => CreateError::NotAuthed, - "invalid_auth" => CreateError::InvalidAuth, - "account_inactive" => CreateError::AccountInactive, - "user_is_bot" => CreateError::UserIsBot, - "user_is_restricted" => CreateError::UserIsRestricted, - "invalid_arg_name" => CreateError::InvalidArgName, - "invalid_array_arg" => CreateError::InvalidArrayArg, - "invalid_charset" => CreateError::InvalidCharset, - "invalid_form_data" => CreateError::InvalidFormData, - "invalid_post_type" => CreateError::InvalidPostType, - "missing_post_type" => CreateError::MissingPostType, - "team_added_to_org" => CreateError::TeamAddedToOrg, - "request_timeout" => CreateError::RequestTimeout, - _ => CreateError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for CreateError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - CreateError::NotAuthed => "not_authed: No authentication token provided.", -CreateError::InvalidAuth => "invalid_auth: Invalid authentication token.", -CreateError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -CreateError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -CreateError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -CreateError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -CreateError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -CreateError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -CreateError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -CreateError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -CreateError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -CreateError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -CreateError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - CreateError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - CreateError::Unknown(ref s) => return write!(f, "{}", s), - CreateError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for CreateError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - CreateError::MalformedResponse(_, ref e) => Some(e), - CreateError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct DisableRequest<'a> { - /// The encoded ID of the User Group to disable. - pub usergroup: &'a str, - /// Include the number of users in the User Group. - pub include_count: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct DisableResponse { - error: Option, - #[serde(default)] - ok: bool, - pub usergroup: Option, -} - -impl Into>> for DisableResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum DisableError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for DisableError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => DisableError::NotAuthed, - "invalid_auth" => DisableError::InvalidAuth, - "account_inactive" => DisableError::AccountInactive, - "user_is_bot" => DisableError::UserIsBot, - "user_is_restricted" => DisableError::UserIsRestricted, - "invalid_arg_name" => DisableError::InvalidArgName, - "invalid_array_arg" => DisableError::InvalidArrayArg, - "invalid_charset" => DisableError::InvalidCharset, - "invalid_form_data" => DisableError::InvalidFormData, - "invalid_post_type" => DisableError::InvalidPostType, - "missing_post_type" => DisableError::MissingPostType, - "team_added_to_org" => DisableError::TeamAddedToOrg, - "request_timeout" => DisableError::RequestTimeout, - _ => DisableError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for DisableError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - DisableError::NotAuthed => "not_authed: No authentication token provided.", -DisableError::InvalidAuth => "invalid_auth: Invalid authentication token.", -DisableError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -DisableError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -DisableError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -DisableError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -DisableError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -DisableError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -DisableError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -DisableError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -DisableError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -DisableError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -DisableError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - DisableError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - DisableError::Unknown(ref s) => return write!(f, "{}", s), - DisableError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for DisableError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - DisableError::MalformedResponse(_, ref e) => Some(e), - DisableError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct EnableRequest<'a> { - /// The encoded ID of the User Group to enable. - pub usergroup: &'a str, - /// Include the number of users in the User Group. - pub include_count: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct EnableResponse { - error: Option, - #[serde(default)] - ok: bool, - pub usergroup: Option, -} - -impl Into>> for EnableResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum EnableError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for EnableError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => EnableError::NotAuthed, - "invalid_auth" => EnableError::InvalidAuth, - "account_inactive" => EnableError::AccountInactive, - "user_is_bot" => EnableError::UserIsBot, - "user_is_restricted" => EnableError::UserIsRestricted, - "invalid_arg_name" => EnableError::InvalidArgName, - "invalid_array_arg" => EnableError::InvalidArrayArg, - "invalid_charset" => EnableError::InvalidCharset, - "invalid_form_data" => EnableError::InvalidFormData, - "invalid_post_type" => EnableError::InvalidPostType, - "missing_post_type" => EnableError::MissingPostType, - "team_added_to_org" => EnableError::TeamAddedToOrg, - "request_timeout" => EnableError::RequestTimeout, - _ => EnableError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for EnableError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - EnableError::NotAuthed => "not_authed: No authentication token provided.", -EnableError::InvalidAuth => "invalid_auth: Invalid authentication token.", -EnableError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -EnableError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -EnableError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -EnableError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -EnableError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -EnableError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -EnableError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -EnableError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -EnableError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -EnableError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -EnableError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - EnableError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - EnableError::Unknown(ref s) => return write!(f, "{}", s), - EnableError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for EnableError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - EnableError::MalformedResponse(_, ref e) => Some(e), - EnableError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct ListRequest { - /// Include disabled User Groups. - pub include_disabled: Option, - /// Include the number of users in each User Group. - pub include_count: Option, - /// Include the list of users for each User Group. - pub include_users: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponse { - error: Option, - #[serde(default)] - ok: bool, - pub usergroups: Option>, -} - -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ListError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ListError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => ListError::NotAuthed, - "invalid_auth" => ListError::InvalidAuth, - "account_inactive" => ListError::AccountInactive, - "user_is_bot" => ListError::UserIsBot, - "user_is_restricted" => ListError::UserIsRestricted, - "invalid_arg_name" => ListError::InvalidArgName, - "invalid_array_arg" => ListError::InvalidArrayArg, - "invalid_charset" => ListError::InvalidCharset, - "invalid_form_data" => ListError::InvalidFormData, - "invalid_post_type" => ListError::InvalidPostType, - "missing_post_type" => ListError::MissingPostType, - "team_added_to_org" => ListError::TeamAddedToOrg, - "request_timeout" => ListError::RequestTimeout, - _ => ListError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for ListError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ListError::NotAuthed => "not_authed: No authentication token provided.", -ListError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ListError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -ListError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ListError::Unknown(ref s) => return write!(f, "{}", s), - ListError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for ListError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ListError::MalformedResponse(_, ref e) => Some(e), - ListError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct UpdateRequest<'a> { - /// The encoded ID of the User Group to update. - pub usergroup: &'a str, - /// A name for the User Group. Must be unique among User Groups. - pub name: Option<&'a str>, - /// A mention handle. Must be unique among channels, users and User Groups. - pub handle: Option<&'a str>, - /// A short description of the User Group. - pub description: Option<&'a str>, - /// A comma separated string of encoded channel IDs for which the User Group uses as a default. - pub channels: Option<&'a str>, - /// Include the number of users in the User Group. - pub include_count: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct UpdateResponse { - error: Option, - #[serde(default)] - ok: bool, - pub usergroup: Option, -} - -impl Into>> for UpdateResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum UpdateError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for UpdateError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => UpdateError::NotAuthed, - "invalid_auth" => UpdateError::InvalidAuth, - "account_inactive" => UpdateError::AccountInactive, - "user_is_bot" => UpdateError::UserIsBot, - "user_is_restricted" => UpdateError::UserIsRestricted, - "invalid_arg_name" => UpdateError::InvalidArgName, - "invalid_array_arg" => UpdateError::InvalidArrayArg, - "invalid_charset" => UpdateError::InvalidCharset, - "invalid_form_data" => UpdateError::InvalidFormData, - "invalid_post_type" => UpdateError::InvalidPostType, - "missing_post_type" => UpdateError::MissingPostType, - "team_added_to_org" => UpdateError::TeamAddedToOrg, - "request_timeout" => UpdateError::RequestTimeout, - _ => UpdateError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for UpdateError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - UpdateError::NotAuthed => "not_authed: No authentication token provided.", -UpdateError::InvalidAuth => "invalid_auth: Invalid authentication token.", -UpdateError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -UpdateError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -UpdateError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -UpdateError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -UpdateError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -UpdateError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -UpdateError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -UpdateError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -UpdateError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -UpdateError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -UpdateError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - UpdateError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - UpdateError::Unknown(ref s) => return write!(f, "{}", s), - UpdateError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for UpdateError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - UpdateError::MalformedResponse(_, ref e) => Some(e), - UpdateError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/usergroups_users_types.rs b/src/mod_types/usergroups_users_types.rs deleted file mode 100644 index 97425c07..00000000 --- a/src/mod_types/usergroups_users_types.rs +++ /dev/null @@ -1,253 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct ListRequest<'a> { - /// The encoded ID of the User Group to update. - pub usergroup: &'a str, - /// Allow results that involve disabled User Groups. - pub include_disabled: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponse { - error: Option, - #[serde(default)] - ok: bool, - pub users: Option>, -} - -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ListError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ListError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => ListError::NotAuthed, - "invalid_auth" => ListError::InvalidAuth, - "account_inactive" => ListError::AccountInactive, - "user_is_bot" => ListError::UserIsBot, - "user_is_restricted" => ListError::UserIsRestricted, - "invalid_arg_name" => ListError::InvalidArgName, - "invalid_array_arg" => ListError::InvalidArrayArg, - "invalid_charset" => ListError::InvalidCharset, - "invalid_form_data" => ListError::InvalidFormData, - "invalid_post_type" => ListError::InvalidPostType, - "missing_post_type" => ListError::MissingPostType, - "team_added_to_org" => ListError::TeamAddedToOrg, - "request_timeout" => ListError::RequestTimeout, - _ => ListError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for ListError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ListError::NotAuthed => "not_authed: No authentication token provided.", -ListError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ListError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -ListError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ListError::Unknown(ref s) => return write!(f, "{}", s), - ListError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for ListError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ListError::MalformedResponse(_, ref e) => Some(e), - ListError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct UpdateRequest<'a> { - /// The encoded ID of the User Group to update. - pub usergroup: &'a str, - /// A comma separated string of encoded user IDs that represent the entire list of users for the User Group. - pub users: &'a str, - /// Include the number of users in the User Group. - pub include_count: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct UpdateResponse { - error: Option, - #[serde(default)] - ok: bool, - pub usergroup: Option, -} - -impl Into>> for UpdateResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum UpdateError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// This method cannot be called by a restricted user or single channel guest. - UserIsRestricted, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for UpdateError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => UpdateError::NotAuthed, - "invalid_auth" => UpdateError::InvalidAuth, - "account_inactive" => UpdateError::AccountInactive, - "user_is_bot" => UpdateError::UserIsBot, - "user_is_restricted" => UpdateError::UserIsRestricted, - "invalid_arg_name" => UpdateError::InvalidArgName, - "invalid_array_arg" => UpdateError::InvalidArrayArg, - "invalid_charset" => UpdateError::InvalidCharset, - "invalid_form_data" => UpdateError::InvalidFormData, - "invalid_post_type" => UpdateError::InvalidPostType, - "missing_post_type" => UpdateError::MissingPostType, - "team_added_to_org" => UpdateError::TeamAddedToOrg, - "request_timeout" => UpdateError::RequestTimeout, - _ => UpdateError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for UpdateError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - UpdateError::NotAuthed => "not_authed: No authentication token provided.", -UpdateError::InvalidAuth => "invalid_auth: Invalid authentication token.", -UpdateError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -UpdateError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -UpdateError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.", -UpdateError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -UpdateError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -UpdateError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -UpdateError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -UpdateError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -UpdateError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -UpdateError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -UpdateError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - UpdateError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - UpdateError::Unknown(ref s) => return write!(f, "{}", s), - UpdateError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for UpdateError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - UpdateError::MalformedResponse(_, ref e) => Some(e), - UpdateError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/users/mod.rs b/src/mod_types/users/mod.rs new file mode 100644 index 00000000..15d42560 --- /dev/null +++ b/src/mod_types/users/mod.rs @@ -0,0 +1,961 @@ +pub mod profile_types; + +pub struct SetPhotoRequest { + /// Authentication token. Requires scope: `users.profile:write` + pub token: Option, + /// Width/height of crop box (always square) + pub crop_w: String, + /// X coordinate of top-left corner of crop box + pub crop_x: String, + /// Y coordinate of top-left corner of crop box + pub crop_y: String, + /// File contents via `multipart/form-data`. + pub image: String, +} + +pub struct SetPhotoProfileInner { + pub avatar_hash: Option, + pub image_1024: Option, + pub image_192: Option, + pub image_24: Option, + pub image_32: Option, + pub image_48: Option, + pub image_512: Option, + pub image_72: Option, + pub image_original: Option, +} + +pub struct SetPhotoResponse { + pub callstack: String, + pub debug_step: String, + pub dims: String, + pub error: String, + pub ok: Option, + pub profile: Option, + pub time_ident: u64, +} + +pub struct SetPhotoError {} + +pub struct SetActiveRequest {} + +pub struct SetActiveResponse { + pub callstack: String, + pub error: String, + pub ok: Option, +} + +pub struct SetActiveError {} + +pub struct ListRequest { + /// The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached. Providing no `limit` value will result in Slack attempting to deliver you the entire result set. If the collection is too large you may experience `limit_required` or HTTP 500 errors. + pub limit: u64, + /// Paginate through collections of data by setting the `cursor` parameter to a `next_cursor` attribute returned by a previous request's `response_metadata`. Default value fetches the first "page" of the collection. See [pagination](/docs/pagination) for more detail. + pub cursor: String, + /// Set this to `true` to receive the locale for users. Defaults to `false` + pub include_locale: bool, +} + +pub struct ListEnterpriseUserInner { + pub enterprise_id: Option, + pub enterprise_name: Option, + pub id: Option, + pub is_admin: Option, + pub is_owner: Option, + pub teams: Option>, +} + +pub struct ListProfileInner { + pub always_active: bool, + pub api_app_id: String, + pub avatar_hash: Option, + pub bot_id: String, + pub display_name: Option, + pub display_name_normalized: Option, + pub email: String, + pub fields: Option>, + pub first_name: String, + pub guest_expiration_ts: u64, + pub guest_invited_by: String, + pub image_1024: String, + pub image_192: String, + pub image_24: String, + pub image_32: String, + pub image_48: String, + pub image_512: String, + pub image_72: String, + pub image_original: String, + pub is_app_user: bool, + pub is_custom_image: bool, + pub is_restricted: bool, + pub is_ultra_restricted: bool, + pub last_avatar_image_hash: String, + pub last_name: String, + pub memberships_count: u64, + pub name: String, + pub phone: Option, + pub pronouns: String, + pub real_name: Option, + pub real_name_normalized: Option, + pub skype: Option, + pub status_default_emoji: String, + pub status_default_text: String, + pub status_default_text_canonical: String, + pub status_emoji: Option, + pub status_expiration: u64, + pub status_text: Option, + pub status_text_canonical: String, + pub team: String, + pub title: Option, + pub updated: u64, + pub user_id: String, + pub username: String, +} + +pub struct ListOptionsInner { + pub is_custom: bool, + pub is_multiple_entry: bool, + pub is_protected: bool, + pub is_scim: bool, +} + +pub struct ListFieldsInner { + pub field_name: String, + pub hint: Option, + pub id: Option, + pub is_hidden: bool, + pub label: Option, + pub options: Vec, + pub ordering: Option, + pub possible_values: Vec, + pub r#type: Option, +} + +pub struct ListTeamProfileInner { + pub fields: Option>, +} + +pub struct ListMembersInner { + pub color: String, + pub deleted: bool, + pub enterprise_user: ListEnterpriseUserInner, + pub has_2fa: bool, + pub id: Option, + pub is_admin: bool, + pub is_app_user: Option, + pub is_bot: Option, + pub is_external: bool, + pub is_forgotten: bool, + pub is_invited_user: bool, + pub is_owner: bool, + pub is_primary_owner: bool, + pub is_restricted: bool, + pub is_stranger: bool, + pub is_ultra_restricted: bool, + pub locale: String, + pub name: Option, + pub presence: String, + pub profile: Option, + pub real_name: String, + pub team: String, + pub team_id: String, + pub team_profile: ListTeamProfileInner, + pub two_factor_type: String, + pub tz: Vec, + pub tz_label: String, + pub tz_offset: u64, + pub updated: Option, +} + +pub struct ListResponseMetadataInner { + pub next_cursor: Option, +} + +pub struct ListResponse { + pub cache_ts: Option, + pub callstack: String, + pub error: String, + pub members: Option>>, + pub ok: Option, + pub response_metadata: Vec, +} + +pub struct ListError {} + +pub struct LookupByEmailRequest { + /// An email address belonging to a user in the workspace + pub email: Option, +} + +pub struct LookupByEmailEnterpriseUserInner { + pub enterprise_id: Option, + pub enterprise_name: Option, + pub id: Option, + pub is_admin: Option, + pub is_owner: Option, + pub teams: Option>, +} + +pub struct LookupByEmailProfileInner { + pub always_active: bool, + pub api_app_id: String, + pub avatar_hash: Option, + pub bot_id: String, + pub display_name: Option, + pub display_name_normalized: Option, + pub email: String, + pub fields: Option>, + pub first_name: String, + pub guest_expiration_ts: u64, + pub guest_invited_by: String, + pub image_1024: String, + pub image_192: String, + pub image_24: String, + pub image_32: String, + pub image_48: String, + pub image_512: String, + pub image_72: String, + pub image_original: String, + pub is_app_user: bool, + pub is_custom_image: bool, + pub is_restricted: bool, + pub is_ultra_restricted: bool, + pub last_avatar_image_hash: String, + pub last_name: String, + pub memberships_count: u64, + pub name: String, + pub phone: Option, + pub pronouns: String, + pub real_name: Option, + pub real_name_normalized: Option, + pub skype: Option, + pub status_default_emoji: String, + pub status_default_text: String, + pub status_default_text_canonical: String, + pub status_emoji: Option, + pub status_expiration: u64, + pub status_text: Option, + pub status_text_canonical: String, + pub team: String, + pub title: Option, + pub updated: u64, + pub user_id: String, + pub username: String, +} + +pub struct LookupByEmailOptionsInner { + pub is_custom: bool, + pub is_multiple_entry: bool, + pub is_protected: bool, + pub is_scim: bool, +} + +pub struct LookupByEmailFieldsInner { + pub field_name: String, + pub hint: Option, + pub id: Option, + pub is_hidden: bool, + pub label: Option, + pub options: Vec, + pub ordering: Option, + pub possible_values: Vec, + pub r#type: Option, +} + +pub struct LookupByEmailTeamProfileInner { + pub fields: Option>, +} + +pub struct LookupByEmailUserInner { + pub color: String, + pub deleted: bool, + pub enterprise_user: LookupByEmailEnterpriseUserInner, + pub has_2fa: bool, + pub id: Option, + pub is_admin: bool, + pub is_app_user: Option, + pub is_bot: Option, + pub is_external: bool, + pub is_forgotten: bool, + pub is_invited_user: bool, + pub is_owner: bool, + pub is_primary_owner: bool, + pub is_restricted: bool, + pub is_stranger: bool, + pub is_ultra_restricted: bool, + pub locale: String, + pub name: Option, + pub presence: String, + pub profile: Option, + pub real_name: String, + pub team: String, + pub team_id: String, + pub team_profile: LookupByEmailTeamProfileInner, + pub two_factor_type: String, + pub tz: Vec, + pub tz_label: String, + pub tz_offset: u64, + pub updated: Option, +} + +pub struct LookupByEmailResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub user: Option>, +} + +pub struct LookupByEmailError {} + +pub struct ConversationsRequest { + /// Browse conversations by a specific user ID's membership. Non-public channels are restricted to those where the calling user shares membership. + pub user: String, + /// Mix and match channel types by providing a comma-separated list of any combination of `public_channel`, `private_channel`, `mpim`, `im` + pub types: String, + /// Set to `true` to exclude archived channels from the list + pub exclude_archived: bool, + /// The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. Must be an integer no larger than 1000. + pub limit: u64, + /// Paginate through collections of data by setting the `cursor` parameter to a `next_cursor` attribute returned by a previous request's `response_metadata`. Default value fetches the first "page" of the collection. See [pagination](/docs/pagination) for more detail. + pub cursor: String, +} + +pub struct ConversationsDisplayCountsInner { + pub display_counts: Option, + pub guest_counts: Option, +} + +pub struct ConversationsAttachmentsInner { + pub fallback: String, + pub id: Option, + pub image_bytes: u64, + pub image_height: u64, + pub image_url: String, + pub image_width: u64, +} + +pub struct ConversationsBlocksInner { + pub r#type: Option, +} + +pub struct ConversationsIconsInner { + pub image_36: Option, + pub image_48: Option, + pub image_72: Option, +} + +pub struct ConversationsBotProfileInner { + pub app_id: Option, + pub deleted: Option, + pub icons: Option, + pub id: Option, + pub name: Option, + pub team_id: Option, + pub updated: Option, +} + +pub struct ConversationsReactionsInner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ConversationsCommentInner { + pub comment: Option, + pub created: Option, + pub id: Option, + pub is_intro: Option, + pub is_starred: bool, + pub num_stars: u64, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub reactions: Vec, + pub timestamp: Option, + pub user: Option, +} + +pub struct ConversationsReactions1Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ConversationsSharesInner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct ConversationsFileInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: ConversationsSharesInner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct ConversationsReactions2Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ConversationsShares1Inner { + pub private: serde_json::Value, + pub public: serde_json::Value, +} + +pub struct ConversationsFilesInner { + pub channels: Vec, + pub comments_count: u64, + pub created: u64, + pub date_delete: u64, + pub display_as_bot: bool, + pub editable: bool, + pub editor: String, + pub external_id: String, + pub external_type: String, + pub external_url: String, + pub filetype: String, + pub groups: Vec, + pub has_rich_preview: bool, + pub id: String, + pub image_exif_rotation: u64, + pub ims: Vec, + pub is_external: bool, + pub is_public: bool, + pub is_starred: bool, + pub is_tombstoned: bool, + pub last_editor: String, + pub mimetype: String, + pub mode: String, + pub name: String, + pub non_owner_editable: bool, + pub num_stars: u64, + pub original_h: u64, + pub original_w: u64, + pub permalink: String, + pub permalink_public: String, + pub pinned_info: serde_json::Value, + pub pinned_to: Vec, + pub pretty_type: String, + pub preview: String, + pub public_url_shared: bool, + pub reactions: Vec, + pub shares: ConversationsShares1Inner, + pub size: u64, + pub source_team: String, + pub state: String, + pub thumb_1024: String, + pub thumb_1024_h: u64, + pub thumb_1024_w: u64, + pub thumb_160: String, + pub thumb_360: String, + pub thumb_360_h: u64, + pub thumb_360_w: u64, + pub thumb_480: String, + pub thumb_480_h: u64, + pub thumb_480_w: u64, + pub thumb_64: String, + pub thumb_720: String, + pub thumb_720_h: u64, + pub thumb_720_w: u64, + pub thumb_80: String, + pub thumb_800: String, + pub thumb_800_h: u64, + pub thumb_800_w: u64, + pub thumb_960: String, + pub thumb_960_h: u64, + pub thumb_960_w: u64, + pub thumb_tiny: String, + pub timestamp: u64, + pub title: String, + pub updated: u64, + pub url_private: String, + pub url_private_download: String, + pub user: String, + pub user_team: String, + pub username: String, +} + +pub struct ConversationsIcons1Inner { + pub emoji: String, + pub image_64: String, +} + +pub struct ConversationsReactions3Inner { + pub count: Option, + pub name: Option, + pub users: Option>, +} + +pub struct ConversationsUserProfileInner { + pub avatar_hash: Option, + pub display_name: Option, + pub display_name_normalized: String, + pub first_name: Option, + pub image_72: Option, + pub is_restricted: Option, + pub is_ultra_restricted: Option, + pub name: Option, + pub real_name: Option, + pub real_name_normalized: String, + pub team: Option, +} + +pub struct ConversationsLatestInner { + pub attachments: Vec, + pub blocks: Vec, + pub bot_id: Vec, + pub bot_profile: ConversationsBotProfileInner, + pub client_msg_id: String, + pub comment: ConversationsCommentInner, + pub display_as_bot: bool, + pub file: ConversationsFileInner, + pub files: Vec, + pub icons: ConversationsIcons1Inner, + pub inviter: String, + pub is_delayed_message: bool, + pub is_intro: bool, + pub is_starred: bool, + pub last_read: String, + pub latest_reply: String, + pub name: String, + pub old_name: String, + pub parent_user_id: String, + pub permalink: String, + pub pinned_to: Vec, + pub purpose: String, + pub reactions: Vec, + pub reply_count: u64, + pub reply_users: Vec, + pub reply_users_count: u64, + pub source_team: String, + pub subscribed: bool, + pub subtype: String, + pub team: String, + pub text: Option, + pub thread_ts: String, + pub topic: String, + pub ts: Option, + pub r#type: Option, + pub unread_count: u64, + pub upload: bool, + pub user: String, + pub user_profile: ConversationsUserProfileInner, + pub user_team: String, + pub username: String, +} + +pub struct ConversationsPurposeInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct ConversationsCurrentInner { + pub date_started: Option, + pub team_id: Option, +} + +pub struct ConversationsExternalOrgMigrationsInner { + pub current: Option>, + pub date_updated: Option, +} + +pub struct ConversationsIconInner { + pub image_102: String, + pub image_132: String, + pub image_230: String, + pub image_34: String, + pub image_44: String, + pub image_68: String, + pub image_88: String, + pub image_default: bool, +} + +pub struct ConversationsPrimaryOwnerInner { + pub email: Option, + pub id: Option, +} + +pub struct ConversationsSsoProviderInner { + pub label: String, + pub name: String, + pub r#type: String, +} + +pub struct ConversationsTeamInner { + pub archived: bool, + pub avatar_base_url: String, + pub created: u64, + pub date_create: u64, + pub deleted: bool, + pub description: String, + pub discoverable: Vec, + pub domain: Option, + pub email_domain: Option, + pub enterprise_id: String, + pub enterprise_name: String, + pub external_org_migrations: ConversationsExternalOrgMigrationsInner, + pub has_compliance_export: bool, + pub icon: Option, + pub id: Option, + pub is_assigned: bool, + pub is_enterprise: u64, + pub is_over_storage_limit: bool, + pub limit_ts: u64, + pub locale: String, + pub messages_count: u64, + pub msg_edit_window_mins: u64, + pub name: Option, + pub over_integrations_limit: bool, + pub over_storage_limit: bool, + pub pay_prod_cur: String, + pub plan: String, + pub primary_owner: ConversationsPrimaryOwnerInner, + pub sso_provider: ConversationsSsoProviderInner, +} + +pub struct ConversationsShares2Inner { + pub accepted_user: String, + pub is_active: Option, + pub team: Option, + pub user: Option, +} + +pub struct ConversationsTopicInner { + pub creator: Option, + pub last_set: Option, + pub value: Option, +} + +pub struct ConversationsChannelsInner { + pub accepted_user: String, + pub connected_team_ids: Vec, + pub conversation_host_id: String, + pub created: Option, + pub creator: Option, + pub display_counts: ConversationsDisplayCountsInner, + pub enterprise_id: String, + pub has_pins: bool, + pub id: Option, + pub internal_team_ids: Vec, + pub is_archived: Option, + pub is_channel: Option, + pub is_ext_shared: bool, + pub is_frozen: bool, + pub is_general: Option, + pub is_global_shared: bool, + pub is_group: Option, + pub is_im: Option, + pub is_member: bool, + pub is_moved: u64, + pub is_mpim: Option, + pub is_non_threadable: bool, + pub is_open: bool, + pub is_org_default: bool, + pub is_org_mandatory: bool, + pub is_org_shared: Option, + pub is_pending_ext_shared: bool, + pub is_private: Option, + pub is_read_only: bool, + pub is_shared: Option, + pub is_starred: bool, + pub is_thread_only: bool, + pub last_read: String, + pub latest: Vec, + pub members: Vec, + pub name: Option, + pub name_normalized: Option, + pub num_members: u64, + pub parent_conversation: Vec, + pub pending_connected_team_ids: Vec, + pub pending_shared: Vec, + pub pin_count: u64, + pub previous_names: Vec, + pub priority: u64, + pub purpose: Option, + pub shared_team_ids: Vec, + pub shares: Vec, + pub timezone_count: u64, + pub topic: Option, + pub unlinked: u64, + pub unread_count: u64, + pub unread_count_display: u64, + pub use_case: String, + pub user: String, + pub version: u64, +} + +pub struct ConversationsResponseMetadataInner { + pub next_cursor: Option, +} + +pub struct ConversationsResponse { + pub callstack: String, + pub channels: Option>>, + pub error: String, + pub ok: Option, + pub response_metadata: ConversationsResponseMetadataInner, +} + +pub struct ConversationsError {} + +pub struct DeletePhotoRequest { + /// Authentication token. Requires scope: `users.profile:write` + pub token: Option, +} + +pub struct DeletePhotoResponse { + pub callstack: String, + pub error: String, + pub ok: Option, +} + +pub struct DeletePhotoError {} + +pub struct SetPresenceRequest { + /// Either `auto` or `away` + pub presence: Option, +} + +pub struct SetPresenceResponse { + pub callstack: String, + pub error: String, + pub ok: Option, +} + +pub struct SetPresenceError {} + +pub struct GetPresenceRequest { + /// User to get presence info on. Defaults to the authed user. + pub user: String, +} + +pub struct GetPresenceResponse { + pub auto_away: bool, + pub connection_count: u64, + pub error: String, + pub last_activity: u64, + pub manual_away: bool, + pub ok: Option, + pub online: bool, + pub presence: Option, +} + +pub struct GetPresenceError {} + +pub struct IdentityRequest {} + +pub struct IdentityTeamInner { + pub id: Option, +} + +pub struct IdentityUserInner { + pub id: Option, + pub name: Option, +} + +pub struct IdentityResultInner { + pub ok: Option, + pub team: Option, + pub user: Option, +} + +pub struct IdentityResponse { + pub result: Option, +} + +pub struct IdentityError {} + +pub struct InfoRequest { + /// Set this to `true` to receive the locale for this user. Defaults to `false` + pub include_locale: bool, + /// User to get info on + pub user: String, +} + +pub struct InfoEnterpriseUserInner { + pub enterprise_id: Option, + pub enterprise_name: Option, + pub id: Option, + pub is_admin: Option, + pub is_owner: Option, + pub teams: Option>, +} + +pub struct InfoProfileInner { + pub always_active: bool, + pub api_app_id: String, + pub avatar_hash: Option, + pub bot_id: String, + pub display_name: Option, + pub display_name_normalized: Option, + pub email: String, + pub fields: Option>, + pub first_name: String, + pub guest_expiration_ts: u64, + pub guest_invited_by: String, + pub image_1024: String, + pub image_192: String, + pub image_24: String, + pub image_32: String, + pub image_48: String, + pub image_512: String, + pub image_72: String, + pub image_original: String, + pub is_app_user: bool, + pub is_custom_image: bool, + pub is_restricted: bool, + pub is_ultra_restricted: bool, + pub last_avatar_image_hash: String, + pub last_name: String, + pub memberships_count: u64, + pub name: String, + pub phone: Option, + pub pronouns: String, + pub real_name: Option, + pub real_name_normalized: Option, + pub skype: Option, + pub status_default_emoji: String, + pub status_default_text: String, + pub status_default_text_canonical: String, + pub status_emoji: Option, + pub status_expiration: u64, + pub status_text: Option, + pub status_text_canonical: String, + pub team: String, + pub title: Option, + pub updated: u64, + pub user_id: String, + pub username: String, +} + +pub struct InfoOptionsInner { + pub is_custom: bool, + pub is_multiple_entry: bool, + pub is_protected: bool, + pub is_scim: bool, +} + +pub struct InfoFieldsInner { + pub field_name: String, + pub hint: Option, + pub id: Option, + pub is_hidden: bool, + pub label: Option, + pub options: Vec, + pub ordering: Option, + pub possible_values: Vec, + pub r#type: Option, +} + +pub struct InfoTeamProfileInner { + pub fields: Option>, +} + +pub struct InfoUserInner { + pub color: String, + pub deleted: bool, + pub enterprise_user: InfoEnterpriseUserInner, + pub has_2fa: bool, + pub id: Option, + pub is_admin: bool, + pub is_app_user: Option, + pub is_bot: Option, + pub is_external: bool, + pub is_forgotten: bool, + pub is_invited_user: bool, + pub is_owner: bool, + pub is_primary_owner: bool, + pub is_restricted: bool, + pub is_stranger: bool, + pub is_ultra_restricted: bool, + pub locale: String, + pub name: Option, + pub presence: String, + pub profile: Option, + pub real_name: String, + pub team: String, + pub team_id: String, + pub team_profile: InfoTeamProfileInner, + pub two_factor_type: String, + pub tz: Vec, + pub tz_label: String, + pub tz_offset: u64, + pub updated: Option, +} + +pub struct InfoResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub user: Option>, +} + +pub struct InfoError {} diff --git a/src/mod_types/users/profile_types.rs b/src/mod_types/users/profile_types.rs new file mode 100644 index 00000000..6296cf6d --- /dev/null +++ b/src/mod_types/users/profile_types.rs @@ -0,0 +1,131 @@ +pub struct GetRequest { + /// Include labels for each ID in custom profile fields + pub include_labels: bool, + /// User to retrieve profile info for + pub user: String, +} + +pub struct GetProfileInner { + pub always_active: bool, + pub api_app_id: String, + pub avatar_hash: Option, + pub bot_id: String, + pub display_name: Option, + pub display_name_normalized: Option, + pub email: String, + pub fields: Option>, + pub first_name: String, + pub guest_expiration_ts: u64, + pub guest_invited_by: String, + pub image_1024: String, + pub image_192: String, + pub image_24: String, + pub image_32: String, + pub image_48: String, + pub image_512: String, + pub image_72: String, + pub image_original: String, + pub is_app_user: bool, + pub is_custom_image: bool, + pub is_restricted: bool, + pub is_ultra_restricted: bool, + pub last_avatar_image_hash: String, + pub last_name: String, + pub memberships_count: u64, + pub name: String, + pub phone: Option, + pub pronouns: String, + pub real_name: Option, + pub real_name_normalized: Option, + pub skype: Option, + pub status_default_emoji: String, + pub status_default_text: String, + pub status_default_text_canonical: String, + pub status_emoji: Option, + pub status_expiration: u64, + pub status_text: Option, + pub status_text_canonical: String, + pub team: String, + pub title: Option, + pub updated: u64, + pub user_id: String, + pub username: String, +} + +pub struct GetResponse { + pub callstack: String, + pub error: String, + pub ok: Option, + pub profile: Option, +} + +pub struct GetError {} + +pub struct SetRequest { + /// Name of a single key to set. Usable only if `profile` is not passed. + pub name: String, + /// Collection of key:value pairs presented as a URL-encoded JSON hash. At most 50 fields may be set. Each field name is limited to 255 characters. + pub profile: String, + /// ID of user to change. This argument may only be specified by team admins on paid teams. + pub user: String, + /// Value to set a single key to. Usable only if `profile` is not passed. + pub value: String, +} + +pub struct SetProfileInner { + pub always_active: bool, + pub api_app_id: String, + pub avatar_hash: Option, + pub bot_id: String, + pub display_name: Option, + pub display_name_normalized: Option, + pub email: String, + pub fields: Option>, + pub first_name: String, + pub guest_expiration_ts: u64, + pub guest_invited_by: String, + pub image_1024: String, + pub image_192: String, + pub image_24: String, + pub image_32: String, + pub image_48: String, + pub image_512: String, + pub image_72: String, + pub image_original: String, + pub is_app_user: bool, + pub is_custom_image: bool, + pub is_restricted: bool, + pub is_ultra_restricted: bool, + pub last_avatar_image_hash: String, + pub last_name: String, + pub memberships_count: u64, + pub name: String, + pub phone: Option, + pub pronouns: String, + pub real_name: Option, + pub real_name_normalized: Option, + pub skype: Option, + pub status_default_emoji: String, + pub status_default_text: String, + pub status_default_text_canonical: String, + pub status_emoji: Option, + pub status_expiration: u64, + pub status_text: Option, + pub status_text_canonical: String, + pub team: String, + pub title: Option, + pub updated: u64, + pub user_id: String, + pub username: String, +} + +pub struct SetResponse { + pub callstack: String, + pub email_pending: String, + pub error: String, + pub ok: Option, + pub profile: Option, + pub username: Option, +} + +pub struct SetError {} diff --git a/src/mod_types/users_profile_types.rs b/src/mod_types/users_profile_types.rs deleted file mode 100644 index 94fcdfe1..00000000 --- a/src/mod_types/users_profile_types.rs +++ /dev/null @@ -1,275 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Default, Debug)] -pub struct GetRequest<'a> { - /// User to retrieve profile info for - pub user: Option<&'a str>, - /// Include labels for each ID in custom profile fields - pub include_labels: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct GetResponse { - error: Option, - #[serde(default)] - ok: bool, - pub profile: Option, -} - -impl Into>> for GetResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum GetError { - /// Value passed for user was invalid. - UserNotFound, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for GetError { - fn from(s: &'a str) -> Self { - match s { - "user_not_found" => GetError::UserNotFound, - "not_authed" => GetError::NotAuthed, - "invalid_auth" => GetError::InvalidAuth, - "account_inactive" => GetError::AccountInactive, - "user_is_bot" => GetError::UserIsBot, - "invalid_arg_name" => GetError::InvalidArgName, - "invalid_array_arg" => GetError::InvalidArrayArg, - "invalid_charset" => GetError::InvalidCharset, - "invalid_form_data" => GetError::InvalidFormData, - "invalid_post_type" => GetError::InvalidPostType, - "missing_post_type" => GetError::MissingPostType, - "team_added_to_org" => GetError::TeamAddedToOrg, - "request_timeout" => GetError::RequestTimeout, - _ => GetError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for GetError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - GetError::UserNotFound => "user_not_found: Value passed for user was invalid.", -GetError::NotAuthed => "not_authed: No authentication token provided.", -GetError::InvalidAuth => "invalid_auth: Invalid authentication token.", -GetError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -GetError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -GetError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -GetError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -GetError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -GetError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -GetError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -GetError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -GetError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -GetError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - GetError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - GetError::Unknown(ref s) => return write!(f, "{}", s), - GetError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for GetError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - GetError::MalformedResponse(_, ref e) => Some(e), - GetError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct SetRequest<'a> { - /// ID of user to change. This argument may only be specified by team admins on paid teams. - pub user: Option<&'a str>, - /// Collection of key:value pairs presented as a URL-encoded JSON hash. - pub profile: Option<&'a str>, - /// Name of a single key to set. Usable only if profile is not passed. - pub name: Option<&'a str>, - /// Value to set a single key to. Usable only if profile is not passed. - pub value: Option<&'a str>, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct SetResponse { - error: Option, - #[serde(default)] - ok: bool, - pub profile: Option, -} - -impl Into>> for SetResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum SetError { - /// First or last name are reserved. - ReservedName, - /// Profile object passed in is not valid JSON (make sure it is URL encoded!). - InvalidProfile, - /// Failed to set user profile. - ProfileSetFailed, - /// Only admins can update the profile of another user. - NotAdmin, - /// Only team owners and selected members can update the profile of a bot user. - NotAppAdmin, - /// Only a primary owner can update the profile of an admin. - CannotUpdateAdminUser, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for SetError { - fn from(s: &'a str) -> Self { - match s { - "reserved_name" => SetError::ReservedName, - "invalid_profile" => SetError::InvalidProfile, - "profile_set_failed" => SetError::ProfileSetFailed, - "not_admin" => SetError::NotAdmin, - "not_app_admin" => SetError::NotAppAdmin, - "cannot_update_admin_user" => SetError::CannotUpdateAdminUser, - "not_authed" => SetError::NotAuthed, - "invalid_auth" => SetError::InvalidAuth, - "account_inactive" => SetError::AccountInactive, - "user_is_bot" => SetError::UserIsBot, - "invalid_arg_name" => SetError::InvalidArgName, - "invalid_array_arg" => SetError::InvalidArrayArg, - "invalid_charset" => SetError::InvalidCharset, - "invalid_form_data" => SetError::InvalidFormData, - "invalid_post_type" => SetError::InvalidPostType, - "missing_post_type" => SetError::MissingPostType, - "team_added_to_org" => SetError::TeamAddedToOrg, - "request_timeout" => SetError::RequestTimeout, - _ => SetError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for SetError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - SetError::ReservedName => "reserved_name: First or last name are reserved.", -SetError::InvalidProfile => "invalid_profile: Profile object passed in is not valid JSON (make sure it is URL encoded!).", -SetError::ProfileSetFailed => "profile_set_failed: Failed to set user profile.", -SetError::NotAdmin => "not_admin: Only admins can update the profile of another user.", -SetError::NotAppAdmin => "not_app_admin: Only team owners and selected members can update the profile of a bot user.", -SetError::CannotUpdateAdminUser => "cannot_update_admin_user: Only a primary owner can update the profile of an admin.", -SetError::NotAuthed => "not_authed: No authentication token provided.", -SetError::InvalidAuth => "invalid_auth: Invalid authentication token.", -SetError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -SetError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -SetError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -SetError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -SetError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -SetError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -SetError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -SetError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -SetError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -SetError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - SetError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - SetError::Unknown(ref s) => return write!(f, "{}", s), - SetError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for SetError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - SetError::MalformedResponse(_, ref e) => Some(e), - SetError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/users_types.rs b/src/mod_types/users_types.rs deleted file mode 100644 index ef8d5f57..00000000 --- a/src/mod_types/users_types.rs +++ /dev/null @@ -1,763 +0,0 @@ -//============================================================================= -// -// WARNING: This file is AUTO-GENERATED -// -// Do not make changes directly to this file. -// -// If you would like to make a change to the library, please update the schema -// definitions at https://github.com/slack-rs/slack-api-schemas -// -// If you would like to make a change how the library was generated, -// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen -// -//============================================================================= - -//! Get info on members of your Slack team. - -#[allow(unused_imports)] -use std::collections::HashMap; -use std::convert::From; -use std::error::Error; -use std::fmt; - -#[derive(Clone, Debug, Deserialize)] -pub struct DeletePhotoResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for DeletePhotoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum DeletePhotoError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for DeletePhotoError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => DeletePhotoError::NotAuthed, - "invalid_auth" => DeletePhotoError::InvalidAuth, - "account_inactive" => DeletePhotoError::AccountInactive, - "user_is_bot" => DeletePhotoError::UserIsBot, - "invalid_arg_name" => DeletePhotoError::InvalidArgName, - "invalid_array_arg" => DeletePhotoError::InvalidArrayArg, - "invalid_charset" => DeletePhotoError::InvalidCharset, - "invalid_form_data" => DeletePhotoError::InvalidFormData, - "invalid_post_type" => DeletePhotoError::InvalidPostType, - "missing_post_type" => DeletePhotoError::MissingPostType, - "team_added_to_org" => DeletePhotoError::TeamAddedToOrg, - "request_timeout" => DeletePhotoError::RequestTimeout, - _ => DeletePhotoError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for DeletePhotoError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - DeletePhotoError::NotAuthed => "not_authed: No authentication token provided.", -DeletePhotoError::InvalidAuth => "invalid_auth: Invalid authentication token.", -DeletePhotoError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -DeletePhotoError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -DeletePhotoError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -DeletePhotoError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -DeletePhotoError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -DeletePhotoError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -DeletePhotoError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -DeletePhotoError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -DeletePhotoError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -DeletePhotoError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - DeletePhotoError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - DeletePhotoError::Unknown(ref s) => return write!(f, "{}", s), - DeletePhotoError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for DeletePhotoError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - DeletePhotoError::MalformedResponse(_, ref e) => Some(e), - DeletePhotoError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct GetPresenceRequest<'a> { - /// User to get presence info on. Defaults to the authed user. - pub user: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct GetPresenceResponse { - error: Option, - #[serde(default)] - ok: bool, - pub presence: Option, -} - -impl Into>> for GetPresenceResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum GetPresenceError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for GetPresenceError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => GetPresenceError::NotAuthed, - "invalid_auth" => GetPresenceError::InvalidAuth, - "account_inactive" => GetPresenceError::AccountInactive, - "invalid_arg_name" => GetPresenceError::InvalidArgName, - "invalid_array_arg" => GetPresenceError::InvalidArrayArg, - "invalid_charset" => GetPresenceError::InvalidCharset, - "invalid_form_data" => GetPresenceError::InvalidFormData, - "invalid_post_type" => GetPresenceError::InvalidPostType, - "missing_post_type" => GetPresenceError::MissingPostType, - "team_added_to_org" => GetPresenceError::TeamAddedToOrg, - "request_timeout" => GetPresenceError::RequestTimeout, - _ => GetPresenceError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for GetPresenceError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - GetPresenceError::NotAuthed => "not_authed: No authentication token provided.", -GetPresenceError::InvalidAuth => "invalid_auth: Invalid authentication token.", -GetPresenceError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -GetPresenceError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -GetPresenceError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -GetPresenceError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -GetPresenceError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -GetPresenceError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -GetPresenceError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -GetPresenceError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -GetPresenceError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - GetPresenceError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - GetPresenceError::Unknown(ref s) => return write!(f, "{}", s), - GetPresenceError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for GetPresenceError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - GetPresenceError::MalformedResponse(_, ref e) => Some(e), - GetPresenceError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Debug, Deserialize)] -pub struct IdentityResponse { - error: Option, - #[serde(default)] - ok: bool, - pub team: Option, - pub user: Option, -} - -impl Into>> for IdentityResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum IdentityError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// This method cannot be called by a bot user. - UserIsBot, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for IdentityError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => IdentityError::NotAuthed, - "invalid_auth" => IdentityError::InvalidAuth, - "account_inactive" => IdentityError::AccountInactive, - "user_is_bot" => IdentityError::UserIsBot, - "invalid_arg_name" => IdentityError::InvalidArgName, - "invalid_array_arg" => IdentityError::InvalidArrayArg, - "invalid_charset" => IdentityError::InvalidCharset, - "invalid_form_data" => IdentityError::InvalidFormData, - "invalid_post_type" => IdentityError::InvalidPostType, - "missing_post_type" => IdentityError::MissingPostType, - "team_added_to_org" => IdentityError::TeamAddedToOrg, - "request_timeout" => IdentityError::RequestTimeout, - _ => IdentityError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for IdentityError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - IdentityError::NotAuthed => "not_authed: No authentication token provided.", -IdentityError::InvalidAuth => "invalid_auth: Invalid authentication token.", -IdentityError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -IdentityError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.", -IdentityError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -IdentityError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -IdentityError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -IdentityError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -IdentityError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -IdentityError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -IdentityError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -IdentityError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - IdentityError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - IdentityError::Unknown(ref s) => return write!(f, "{}", s), - IdentityError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for IdentityError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - IdentityError::MalformedResponse(_, ref e) => Some(e), - IdentityError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct InfoRequest<'a> { - /// User to get info on - pub user: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct InfoResponse { - error: Option, - #[serde(default)] - ok: bool, - pub user: Option, -} - -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum InfoError { - /// Value passed for user was invalid. - UserNotFound, - /// The requested user is not visible to the calling user - UserNotVisible, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for InfoError { - fn from(s: &'a str) -> Self { - match s { - "user_not_found" => InfoError::UserNotFound, - "user_not_visible" => InfoError::UserNotVisible, - "not_authed" => InfoError::NotAuthed, - "invalid_auth" => InfoError::InvalidAuth, - "account_inactive" => InfoError::AccountInactive, - "invalid_arg_name" => InfoError::InvalidArgName, - "invalid_array_arg" => InfoError::InvalidArrayArg, - "invalid_charset" => InfoError::InvalidCharset, - "invalid_form_data" => InfoError::InvalidFormData, - "invalid_post_type" => InfoError::InvalidPostType, - "missing_post_type" => InfoError::MissingPostType, - "team_added_to_org" => InfoError::TeamAddedToOrg, - "request_timeout" => InfoError::RequestTimeout, - _ => InfoError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for InfoError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - InfoError::UserNotFound => "user_not_found: Value passed for user was invalid.", -InfoError::UserNotVisible => "user_not_visible: The requested user is not visible to the calling user", -InfoError::NotAuthed => "not_authed: No authentication token provided.", -InfoError::InvalidAuth => "invalid_auth: Invalid authentication token.", -InfoError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -InfoError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -InfoError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -InfoError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -InfoError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -InfoError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -InfoError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -InfoError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -InfoError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - InfoError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - InfoError::Unknown(ref s) => return write!(f, "{}", s), - InfoError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for InfoError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - InfoError::MalformedResponse(_, ref e) => Some(e), - InfoError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct ListRequest { - /// Whether to include presence data in the output - pub presence: Option, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct ListResponse { - error: Option, - pub members: Option>, - #[serde(default)] - ok: bool, -} - -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum ListError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for ListError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => ListError::NotAuthed, - "invalid_auth" => ListError::InvalidAuth, - "account_inactive" => ListError::AccountInactive, - "invalid_arg_name" => ListError::InvalidArgName, - "invalid_array_arg" => ListError::InvalidArrayArg, - "invalid_charset" => ListError::InvalidCharset, - "invalid_form_data" => ListError::InvalidFormData, - "invalid_post_type" => ListError::InvalidPostType, - "missing_post_type" => ListError::MissingPostType, - "team_added_to_org" => ListError::TeamAddedToOrg, - "request_timeout" => ListError::RequestTimeout, - _ => ListError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for ListError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - ListError::NotAuthed => "not_authed: No authentication token provided.", -ListError::InvalidAuth => "invalid_auth: Invalid authentication token.", -ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - ListError::Unknown(ref s) => return write!(f, "{}", s), - ListError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for ListError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - ListError::MalformedResponse(_, ref e) => Some(e), - ListError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Debug, Deserialize)] -pub struct SetActiveResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for SetActiveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum SetActiveError { - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for SetActiveError { - fn from(s: &'a str) -> Self { - match s { - "not_authed" => SetActiveError::NotAuthed, - "invalid_auth" => SetActiveError::InvalidAuth, - "account_inactive" => SetActiveError::AccountInactive, - "invalid_arg_name" => SetActiveError::InvalidArgName, - "invalid_array_arg" => SetActiveError::InvalidArrayArg, - "invalid_charset" => SetActiveError::InvalidCharset, - "invalid_form_data" => SetActiveError::InvalidFormData, - "invalid_post_type" => SetActiveError::InvalidPostType, - "missing_post_type" => SetActiveError::MissingPostType, - "team_added_to_org" => SetActiveError::TeamAddedToOrg, - "request_timeout" => SetActiveError::RequestTimeout, - _ => SetActiveError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for SetActiveError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - SetActiveError::NotAuthed => "not_authed: No authentication token provided.", -SetActiveError::InvalidAuth => "invalid_auth: Invalid authentication token.", -SetActiveError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -SetActiveError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -SetActiveError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -SetActiveError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -SetActiveError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -SetActiveError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -SetActiveError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -SetActiveError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -SetActiveError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - SetActiveError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - SetActiveError::Unknown(ref s) => return write!(f, "{}", s), - SetActiveError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for SetActiveError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - SetActiveError::MalformedResponse(_, ref e) => Some(e), - SetActiveError::Client(ref inner) => Some(inner), - _ => None, - } - } -} - -#[derive(Clone, Default, Debug)] -pub struct SetPresenceRequest<'a> { - /// Either auto or away - pub presence: &'a str, -} - -#[derive(Clone, Debug, Deserialize)] -pub struct SetPresenceResponse { - error: Option, - #[serde(default)] - ok: bool, -} - -impl Into>> for SetPresenceResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) - } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) - } - } -} -#[derive(Debug)] -pub enum SetPresenceError { - /// Value passed for presence was invalid. - InvalidPresence, - /// No authentication token provided. - NotAuthed, - /// Invalid authentication token. - InvalidAuth, - /// Authentication token is for a deleted user or team. - AccountInactive, - /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call. - InvalidArgName, - /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API. - InvalidArrayArg, - /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1. - InvalidCharset, - /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid. - InvalidFormData, - /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain. - InvalidPostType, - /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header. - MissingPostType, - /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete. - TeamAddedToOrg, - /// The method was called via a POST request, but the POST data was either missing or truncated. - RequestTimeout, - /// The response was not parseable as the expected object - MalformedResponse(String, serde_json::error::Error), - /// The response returned an error that was unknown to the library - Unknown(String), - /// The client had an error sending the request to Slack - Client(E), -} - -impl<'a, E: Error> From<&'a str> for SetPresenceError { - fn from(s: &'a str) -> Self { - match s { - "invalid_presence" => SetPresenceError::InvalidPresence, - "not_authed" => SetPresenceError::NotAuthed, - "invalid_auth" => SetPresenceError::InvalidAuth, - "account_inactive" => SetPresenceError::AccountInactive, - "invalid_arg_name" => SetPresenceError::InvalidArgName, - "invalid_array_arg" => SetPresenceError::InvalidArrayArg, - "invalid_charset" => SetPresenceError::InvalidCharset, - "invalid_form_data" => SetPresenceError::InvalidFormData, - "invalid_post_type" => SetPresenceError::InvalidPostType, - "missing_post_type" => SetPresenceError::MissingPostType, - "team_added_to_org" => SetPresenceError::TeamAddedToOrg, - "request_timeout" => SetPresenceError::RequestTimeout, - _ => SetPresenceError::Unknown(s.to_owned()), - } - } -} - -impl fmt::Display for SetPresenceError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let d = match *self { - SetPresenceError::InvalidPresence => "invalid_presence: Value passed for presence was invalid.", -SetPresenceError::NotAuthed => "not_authed: No authentication token provided.", -SetPresenceError::InvalidAuth => "invalid_auth: Invalid authentication token.", -SetPresenceError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.", -SetPresenceError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.", -SetPresenceError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.", -SetPresenceError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.", -SetPresenceError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.", -SetPresenceError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.", -SetPresenceError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.", -SetPresenceError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.", -SetPresenceError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.", - SetPresenceError::MalformedResponse(_, ref e) => return write!(f, "{}", e), - SetPresenceError::Unknown(ref s) => return write!(f, "{}", s), - SetPresenceError::Client(ref inner) => return write!(f, "{}", inner), - }; - write!(f, "{}", d) - } -} - -impl Error for SetPresenceError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match *self { - SetPresenceError::MalformedResponse(_, ref e) => Some(e), - SetPresenceError::Client(ref inner) => Some(inner), - _ => None, - } - } -} diff --git a/src/mod_types/views_types.rs b/src/mod_types/views_types.rs new file mode 100644 index 00000000..82697d58 --- /dev/null +++ b/src/mod_types/views_types.rs @@ -0,0 +1,57 @@ +pub struct PublishRequest { + /// `id` of the user you want publish a view to. + pub user_id: Option, + /// A [view payload](/reference/surfaces/views). This must be a JSON-encoded string. + pub view: Option, + /// A string that represents view state to protect against possible race conditions. + pub hash: String, +} + +pub struct PublishResponse { + pub ok: Option, +} + +pub struct PublishError {} + +pub struct UpdateRequest { + /// A unique identifier of the view to be updated. Either `view_id` or `external_id` is required. + pub view_id: String, + /// A unique identifier of the view set by the developer. Must be unique for all views on a team. Max length of 255 characters. Either `view_id` or `external_id` is required. + pub external_id: String, + /// A [view object](/reference/surfaces/views). This must be a JSON-encoded string. + pub view: String, + /// A string that represents view state to protect against possible race conditions. + pub hash: String, +} + +pub struct UpdateResponse { + pub ok: Option, +} + +pub struct UpdateError {} + +pub struct PushRequest { + /// Exchange a trigger to post to the user. + pub trigger_id: Option, + /// A [view payload](/reference/surfaces/views). This must be a JSON-encoded string. + pub view: Option, +} + +pub struct PushResponse { + pub ok: Option, +} + +pub struct PushError {} + +pub struct OpenRequest { + /// Exchange a trigger to post to the user. + pub trigger_id: Option, + /// A [view payload](/reference/surfaces/views). This must be a JSON-encoded string. + pub view: Option, +} + +pub struct OpenResponse { + pub ok: Option, +} + +pub struct OpenError {} diff --git a/src/mod_types/workflows_types.rs b/src/mod_types/workflows_types.rs new file mode 100644 index 00000000..2280b397 --- /dev/null +++ b/src/mod_types/workflows_types.rs @@ -0,0 +1,44 @@ +pub struct StepFailedRequest { + /// Context identifier that maps to the correct workflow step execution. + pub workflow_step_execute_id: Option, + /// A JSON-based object with a `message` property that should contain a human readable error message. + pub error: Option, +} + +pub struct StepFailedResponse { + pub ok: Option, +} + +pub struct StepFailedError {} + +pub struct StepCompletedRequest { + /// Context identifier that maps to the correct workflow step execution. + pub workflow_step_execute_id: Option, + /// Key-value object of outputs from your step. Keys of this object reflect the configured `key` properties of your [`outputs`](/reference/workflows/workflow_step#output) array from your `workflow_step` object. + pub outputs: String, +} + +pub struct StepCompletedResponse { + pub ok: Option, +} + +pub struct StepCompletedError {} + +pub struct UpdateStepRequest { + /// A context identifier provided with `view_submission` payloads used to call back to `workflows.updateStep`. + pub workflow_step_edit_id: Option, + /// A JSON key-value map of inputs required from a user during configuration. This is the data your app expects to receive when the workflow step starts. **Please note**: the embedded variable format is set and replaced by the workflow system. You cannot create custom variables that will be replaced at runtime. [Read more about variables in workflow steps here](/workflows/steps#variables). + pub inputs: String, + /// An JSON array of output objects used during step execution. This is the data your app agrees to provide when your workflow step was executed. + pub outputs: String, + /// An optional field that can be used to override the step name that is shown in the Workflow Builder. + pub step_name: String, + /// An optional field that can be used to override app image that is shown in the Workflow Builder. + pub step_image_url: String, +} + +pub struct UpdateStepResponse { + pub ok: Option, +} + +pub struct UpdateStepError {}