aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Edgecumbe <git@esotericnonsense.com>2019-10-27 03:05:39 +0100
committerDaniel Edgecumbe <git@esotericnonsense.com>2019-10-27 03:05:39 +0100
commit7f2d53e82035dc3c2106d1fc98c034aa0c4a7be7 (patch)
treecd3ddb153c3ed694ba9a401c1983370dd63c0f3f
parentf335100bafdecbf89d48e98e91b3a05081f1d025 (diff)
Seperate the generated code more effectively
We also create a prelude module, scrap the trait, remove some unnecessary deps, and a bunch of other stuff
-rw-r--r--Cargo.lock90
-rw-r--r--Cargo.toml2
-rwxr-xr-xgenapi/main.py130
-rwxr-xr-xgenapi/main.sh6
-rw-r--r--src/generated_methods.rs502
-rw-r--r--src/generated_requests.rs256
-rw-r--r--src/generated_types.rs (renamed from src/generated_api.rs)895
-rw-r--r--src/lib.rs37
-rw-r--r--src/result.rs38
9 files changed, 918 insertions, 1038 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 1c3dc89..97efaf9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -22,15 +22,6 @@ dependencies = [
]
[[package]]
-name = "atty"
-version = "0.2.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.8 (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"
@@ -69,6 +60,17 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "botfair"
+version = "0.1.99"
+dependencies = [
+ "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "reqwest 0.9.22 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "bumpalo"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -240,18 +242,6 @@ dependencies = [
]
[[package]]
-name = "env_logger"
-version = "0.7.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
name = "error-chain"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -404,14 +394,6 @@ version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "humantime"
-version = "1.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
name = "hyper"
version = "0.12.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -781,11 +763,6 @@ dependencies = [
]
[[package]]
-name = "quick-error"
-version = "1.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
name = "quote"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1055,19 +1032,6 @@ dependencies = [
]
[[package]]
-name = "schroedinger"
-version = "0.1.0"
-dependencies = [
- "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "reqwest 0.9.22 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
name = "scopeguard"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1226,14 +1190,6 @@ dependencies = [
]
[[package]]
-name = "termcolor"
-version = "1.0.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
name = "thread_local"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1618,28 +1574,11 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "winapi-util"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "wincolor"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
name = "winreg"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1660,7 +1599,6 @@ dependencies = [
"checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2"
"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"
"checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9"
-"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90"
"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
"checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea"
"checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491"
@@ -1687,7 +1625,6 @@ dependencies = [
"checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e"
"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
"checksum encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9"
-"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
"checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9"
"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9"
"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08"
@@ -1706,7 +1643,6 @@ dependencies = [
"checksum http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "d7e06e336150b178206af098a055e3621e8336027e2b4d126bda0bc64824baaf"
"checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d"
"checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9"
-"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
"checksum hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)" = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6"
"checksum hyper-rustls 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)" = "719d85c7df4a7f309a77d145340a063ea929dcb2e025bae46a80345cffec2952"
"checksum hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f"
@@ -1747,7 +1683,6 @@ dependencies = [
"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27"
"checksum publicsuffix 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9bf259a81de2b2eb9850ec990ec78e6a25319715584fd7652b9b26f96fcb1510"
-"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
"checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412"
@@ -1794,7 +1729,6 @@ dependencies = [
"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf"
"checksum synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203"
"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
-"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e"
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
"checksum tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6"
@@ -1837,8 +1771,6 @@ dependencies = [
"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
-"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-"checksum wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9"
"checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9"
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
diff --git a/Cargo.toml b/Cargo.toml
index 2dc2872..ca33861 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "botfair"
-version = "0.1.0"
+version = "0.1.99"
description = "rust bindings for Betfair's SportsAPING"
keywords = ["betfair", "jsonrpc", "aping", "sports", "betting"]
repository = "https://git.esotericnonsense.com/pub/botfair.git"
diff --git a/genapi/main.py b/genapi/main.py
index 5061e52..b162fe1 100755
--- a/genapi/main.py
+++ b/genapi/main.py
@@ -509,7 +509,7 @@ def python_type_to_rust_type(_type: str, mandatory: bool = True) -> str:
return _type
-def generate_rust_types(simple_types: List[SimpleType]) -> str:
+def generate_rust_simple_types(simple_types: List[SimpleType]) -> List[str]:
"""
Return API bindings for the operations.
For the time being the function bodies are just empty.
@@ -538,10 +538,10 @@ pub enum {simple_type.name} {{ {formatted_values} }}"""
)
continue
- return "\n".join(types)
+ return types
-def generate_rust_data_types(data_types: List[DataType]) -> str:
+def generate_rust_data_types(data_types: List[DataType]) -> List[str]:
"""
Return API bindings for the operations.
For the time being the function bodies are just empty.
@@ -577,18 +577,25 @@ pub {x[0]}: {x[1]}"""
pub struct {data_type.name} {{ {formatted_params} }}"""
)
- return "\n".join(types)
+ return types
-def generate_rust_functions(operations: List[Operation]) -> str:
+@dataclass
+class RustOperations:
+ """Rust code derived from the BF operations"""
+
+ request_structs: List[str]
+ functions: List[str]
+
+
+def generate_rust_operations(operations: List[Operation]) -> RustOperations:
"""
Return API bindings for the operations.
For the time being the function bodies are just empty.
"""
- structs: List[str] = []
+ request_structs: List[str] = []
functions: List[str] = []
- fn_signatures: List[str] = []
for operation in operations: # type: Operation
# print(operation)
@@ -623,7 +630,7 @@ pub {x[0]}: {x[1]}"""
format_param(x) for x in params_converted
)
- structs.append(
+ request_structs.append(
f"""#[derive(Serialize)]
pub struct {struct_name} {{ {formatted_params_struct} }}"""
)
@@ -650,23 +657,14 @@ let rpc_request: RpcRequest<()> = RpcRequest::new(
self.req(rpc_request).map(|x| x.into_inner())
"""
- fn_signature = f"""fn {operation.name}({formatted_params_args}) ->
+ function_signature = f"""fn {operation.name}({formatted_params_args}) ->
Result<{resp_type}>"""
+ functions.append(
+ f"""#[allow(dead_code)]
+pub {function_signature} {{ {function_interior} }}"""
+ )
- fn_signatures.append(fn_signature + ";")
- functions.append(f"{fn_signature} {{ {function_interior} }}")
-
- structs_out = "\n".join(structs)
- fn_signatures_out = "\n".join(fn_signatures)
- functions_out = "\n".join(functions)
-
- return "\n".join(
- [
- structs_out,
- f"pub trait BFApiCalls {{ {fn_signatures_out} }}",
- f"impl BFApiCalls for crate::BFClient {{ {functions_out} }}",
- ]
- )
+ return RustOperations(request_structs=request_structs, functions=functions)
def main() -> None:
@@ -674,21 +672,77 @@ def main() -> None:
aping: APING = parse_aping(tree.getroot())
# print(aping.to_json())
- print("// This file has been automatically generated.")
- print("// Any manual edits may be overwritten.")
- print()
- print("#![allow(non_camel_case_types)]") # TODO figure this out
- print("#![allow(non_snake_case)]") # TODO figure this out
- print("#![allow(unused_variables)]")
- print("#![allow(dead_code)]")
- print("use std::collections::HashMap;")
- print("use chrono::{DateTime, Utc};")
- print("use serde::{Deserialize, Serialize};")
- print("use crate::json_rpc::RpcRequest;")
- print("use crate::Result;")
- print(generate_rust_functions(aping.operations))
- print(generate_rust_types(aping.simple_types))
- print(generate_rust_data_types(aping.data_types))
+ header = [
+ "// This file has been automatically generated by botfair",
+ "// from the Betfair APING documentation at",
+ "// https://docs.developer.betfair.com",
+ "",
+ ]
+
+ rust_operations: RustOperations = generate_rust_operations(
+ aping.operations
+ )
+ rust_simple_types: List[str] = generate_rust_simple_types(
+ aping.simple_types
+ )
+ rust_data_types: List[str] = generate_rust_data_types(aping.data_types)
+ with open("../src/generated_types.rs", "w") as f:
+ for l in header:
+ f.write(l + "\n")
+ a = [
+ "#![allow(non_camel_case_types)]",
+ "#![allow(non_snake_case)]",
+ "use chrono::{DateTime, Utc};",
+ "use std::collections::HashMap;",
+ "use serde::{Deserialize, Serialize};",
+ ]
+ for l in a:
+ f.write(l + "\n")
+ for l in rust_simple_types:
+ f.write(l + "\n")
+ for l in rust_data_types:
+ f.write(l + "\n")
+
+ with open("../src/generated_methods.rs", "w") as f:
+ for l in header:
+ f.write(l + "\n")
+ a = [
+ "#![allow(non_snake_case)]",
+ "use chrono::{DateTime, Utc};",
+ "use crate::result::Result;",
+ "use crate::json_rpc::RpcRequest;",
+ "use crate::generated_requests::*;",
+ "use crate::generated_types::*;",
+ ]
+ for l in a:
+ f.write(l + "\n")
+ f.write("impl crate::BFClient {\n")
+ for l in rust_operations.functions:
+ f.write(l + "\n")
+ f.write("}\n")
+
+ with open("../src/generated_requests.rs", "w") as f:
+ for l in header:
+ f.write(l + "\n")
+ a = [
+ "#![allow(non_camel_case_types)]",
+ "#![allow(non_snake_case)]",
+ "use chrono::{DateTime, Utc};",
+ "use serde::Serialize;",
+ "use crate::generated_types::*;",
+ ]
+ for l in a:
+ f.write(l + "\n")
+ for l in rust_operations.request_structs:
+ f.write(l + "\n")
+
+ # print("#![allow(unused_variables)]")
+ # print("#![allow(dead_code)]")
+
+ # TODO this stuff goes in the non included file I guess
+
+ # print("use crate::json_rpc::RpcRequest;")
+ # print("use crate::Result;")
if __name__ == "__main__":
diff --git a/genapi/main.sh b/genapi/main.sh
index 41a4d3a..0e32772 100755
--- a/genapi/main.sh
+++ b/genapi/main.sh
@@ -72,8 +72,12 @@ fi
_output="$(realpath ../src/generated_api.rs)"
+echo "Removing old generated files..." >&2
+rm -f ../src/generated_*.rs
echo "Writing generated API to ${_output}" >&2
-./main.py | rustfmt --config max_width=79 > "${_output}"
+./main.py
+echo "Running rustfmt" >&2
+rustfmt --config max_width=79 ../src/generated_*.rs
echo "---" >&2
echo "Done!" >&2
diff --git a/src/generated_methods.rs b/src/generated_methods.rs
new file mode 100644
index 0000000..0a5c646
--- /dev/null
+++ b/src/generated_methods.rs
@@ -0,0 +1,502 @@
+// This file has been automatically generated by botfair
+// from the Betfair APING documentation at
+// https://docs.developer.betfair.com
+
+#![allow(non_snake_case)]
+use crate::generated_requests::*;
+use crate::generated_types::*;
+use crate::json_rpc::RpcRequest;
+use crate::result::Result;
+use chrono::{DateTime, Utc};
+impl crate::BFClient {
+ #[allow(dead_code)]
+ pub fn listEventTypes(
+ &self,
+ filter: MarketFilter,
+ locale: Option<String>,
+ ) -> Result<Vec<EventTypeResult>> {
+ let req: listEventTypesRequest =
+ listEventTypesRequest { filter, locale };
+ let rpc_request: RpcRequest<listEventTypesRequest> =
+ RpcRequest::new("SportsAPING/v1.0/listEventTypes".to_owned(), req);
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn listCompetitions(
+ &self,
+ filter: MarketFilter,
+ locale: Option<String>,
+ ) -> Result<Vec<CompetitionResult>> {
+ let req: listCompetitionsRequest =
+ listCompetitionsRequest { filter, locale };
+ let rpc_request: RpcRequest<listCompetitionsRequest> = RpcRequest::new(
+ "SportsAPING/v1.0/listCompetitions".to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn listTimeRanges(
+ &self,
+ filter: MarketFilter,
+ granularity: TimeGranularity,
+ ) -> Result<Vec<TimeRangeResult>> {
+ let req: listTimeRangesRequest = listTimeRangesRequest {
+ filter,
+ granularity,
+ };
+ let rpc_request: RpcRequest<listTimeRangesRequest> =
+ RpcRequest::new("SportsAPING/v1.0/listTimeRanges".to_owned(), req);
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn listEvents(
+ &self,
+ filter: MarketFilter,
+ locale: Option<String>,
+ ) -> Result<Vec<EventResult>> {
+ let req: listEventsRequest = listEventsRequest { filter, locale };
+ let rpc_request: RpcRequest<listEventsRequest> =
+ RpcRequest::new("SportsAPING/v1.0/listEvents".to_owned(), req);
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn listMarketTypes(
+ &self,
+ filter: MarketFilter,
+ locale: Option<String>,
+ ) -> Result<Vec<MarketTypeResult>> {
+ let req: listMarketTypesRequest =
+ listMarketTypesRequest { filter, locale };
+ let rpc_request: RpcRequest<listMarketTypesRequest> = RpcRequest::new(
+ "SportsAPING/v1.0/listMarketTypes".to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn listCountries(
+ &self,
+ filter: MarketFilter,
+ locale: Option<String>,
+ ) -> Result<Vec<CountryCodeResult>> {
+ let req: listCountriesRequest =
+ listCountriesRequest { filter, locale };
+ let rpc_request: RpcRequest<listCountriesRequest> =
+ RpcRequest::new("SportsAPING/v1.0/listCountries".to_owned(), req);
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn listVenues(
+ &self,
+ filter: MarketFilter,
+ locale: Option<String>,
+ ) -> Result<Vec<VenueResult>> {
+ let req: listVenuesRequest = listVenuesRequest { filter, locale };
+ let rpc_request: RpcRequest<listVenuesRequest> =
+ RpcRequest::new("SportsAPING/v1.0/listVenues".to_owned(), req);
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn listMarketCatalogue(
+ &self,
+ filter: MarketFilter,
+ marketProjection: Option<Vec<MarketProjection>>,
+ sort: Option<MarketSort>,
+ maxResults: i32,
+ locale: Option<String>,
+ ) -> Result<Vec<MarketCatalogue>> {
+ let req: listMarketCatalogueRequest = listMarketCatalogueRequest {
+ filter,
+ marketProjection,
+ sort,
+ maxResults,
+ locale,
+ };
+ let rpc_request: RpcRequest<listMarketCatalogueRequest> =
+ RpcRequest::new(
+ "SportsAPING/v1.0/listMarketCatalogue".to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn listMarketBook(
+ &self,
+ marketIds: Vec<MarketId>,
+ priceProjection: Option<PriceProjection>,
+ orderProjection: Option<OrderProjection>,
+ matchProjection: Option<MatchProjection>,
+ includeOverallPosition: Option<bool>,
+ partitionMatchedByStrategyRef: Option<bool>,
+ customerStrategyRefs: Option<Vec<String>>,
+ currencyCode: Option<String>,
+ locale: Option<String>,
+ matchedSince: Option<DateTime<Utc>>,
+ betIds: Option<Vec<BetId>>,
+ ) -> Result<Vec<MarketBook>> {
+ let req: listMarketBookRequest = listMarketBookRequest {
+ marketIds,
+ priceProjection,
+ orderProjection,
+ matchProjection,
+ includeOverallPosition,
+ partitionMatchedByStrategyRef,
+ customerStrategyRefs,
+ currencyCode,
+ locale,
+ matchedSince,
+ betIds,
+ };
+ let rpc_request: RpcRequest<listMarketBookRequest> =
+ RpcRequest::new("SportsAPING/v1.0/listMarketBook".to_owned(), req);
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn listRunnerBook(
+ &self,
+ marketId: MarketId,
+ selectionId: SelectionId,
+ handicap: Option<f64>,
+ priceProjection: Option<PriceProjection>,
+ orderProjection: Option<OrderProjection>,
+ matchProjection: Option<MatchProjection>,
+ includeOverallPosition: Option<bool>,
+ partitionMatchedByStrategyRef: Option<bool>,
+ customerStrategyRefs: Option<Vec<String>>,
+ currencyCode: Option<String>,
+ locale: Option<String>,
+ matchedSince: Option<DateTime<Utc>>,
+ betIds: Option<Vec<BetId>>,
+ ) -> Result<Vec<MarketBook>> {
+ let req: listRunnerBookRequest = listRunnerBookRequest {
+ marketId,
+ selectionId,
+ handicap,
+ priceProjection,
+ orderProjection,
+ matchProjection,
+ includeOverallPosition,
+ partitionMatchedByStrategyRef,
+ customerStrategyRefs,
+ currencyCode,
+ locale,
+ matchedSince,
+ betIds,
+ };
+ let rpc_request: RpcRequest<listRunnerBookRequest> =
+ RpcRequest::new("SportsAPING/v1.0/listRunnerBook".to_owned(), req);
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn listCurrentOrders(
+ &self,
+ betIds: Option<Vec<BetId>>,
+ marketIds: Option<Vec<MarketId>>,
+ orderProjection: Option<OrderProjection>,
+ customerOrderRefs: Option<Vec<CustomerOrderRef>>,
+ customerStrategyRefs: Option<Vec<CustomerStrategyRef>>,
+ placedDateRange: Option<TimeRange>,
+ dateRange: Option<TimeRange>,
+ orderBy: Option<OrderBy>,
+ sortDir: Option<SortDir>,
+ fromRecord: Option<i32>,
+ recordCount: Option<i32>,
+ ) -> Result<CurrentOrderSummaryReport> {
+ let req: listCurrentOrdersRequest = listCurrentOrdersRequest {
+ betIds,
+ marketIds,
+ orderProjection,
+ customerOrderRefs,
+ customerStrategyRefs,
+ placedDateRange,
+ dateRange,
+ orderBy,
+ sortDir,
+ fromRecord,
+ recordCount,
+ };
+ let rpc_request: RpcRequest<listCurrentOrdersRequest> =
+ RpcRequest::new(
+ "SportsAPING/v1.0/listCurrentOrders".to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn listClearedOrders(
+ &self,
+ betStatus: BetStatus,
+ eventTypeIds: Option<Vec<EventTypeId>>,
+ eventIds: Option<Vec<EventId>>,
+ marketIds: Option<Vec<MarketId>>,
+ runnerIds: Option<Vec<RunnerId>>,
+ betIds: Option<Vec<BetId>>,
+ customerOrderRefs: Option<Vec<CustomerOrderRef>>,
+ customerStrategyRefs: Option<Vec<CustomerStrategyRef>>,
+ side: Option<Side>,
+ settledDateRange: Option<TimeRange>,
+ groupBy: Option<GroupBy>,
+ includeItemDescription: Option<bool>,
+ locale: Option<String>,
+ fromRecord: Option<i32>,
+ recordCount: Option<i32>,
+ ) -> Result<ClearedOrderSummaryReport> {
+ let req: listClearedOrdersRequest = listClearedOrdersRequest {
+ betStatus,
+ eventTypeIds,
+ eventIds,
+ marketIds,
+ runnerIds,
+ betIds,
+ customerOrderRefs,
+ customerStrategyRefs,
+ side,
+ settledDateRange,
+ groupBy,
+ includeItemDescription,
+ locale,
+ fromRecord,
+ recordCount,
+ };
+ let rpc_request: RpcRequest<listClearedOrdersRequest> =
+ RpcRequest::new(
+ "SportsAPING/v1.0/listClearedOrders".to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn placeOrders(
+ &self,
+ marketId: MarketId,
+ instructions: Vec<PlaceInstruction>,
+ customerRef: Option<String>,
+ marketVersion: Option<MarketVersion>,
+ customerStrategyRef: Option<String>,
+ r#async: Option<bool>,
+ ) -> Result<PlaceExecutionReport> {
+ let req: placeOrdersRequest = placeOrdersRequest {
+ marketId,
+ instructions,
+ customerRef,
+ marketVersion,
+ customerStrategyRef,
+ r#async,
+ };
+ let rpc_request: RpcRequest<placeOrdersRequest> =
+ RpcRequest::new("SportsAPING/v1.0/placeOrders".to_owned(), req);
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn cancelOrders(
+ &self,
+ marketId: Option<MarketId>,
+ instructions: Option<Vec<CancelInstruction>>,
+ customerRef: Option<String>,
+ ) -> Result<CancelExecutionReport> {
+ let req: cancelOrdersRequest = cancelOrdersRequest {
+ marketId,
+ instructions,
+ customerRef,
+ };
+ let rpc_request: RpcRequest<cancelOrdersRequest> =
+ RpcRequest::new("SportsAPING/v1.0/cancelOrders".to_owned(), req);
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn replaceOrders(
+ &self,
+ marketId: MarketId,
+ instructions: Vec<ReplaceInstruction>,
+ customerRef: Option<String>,
+ marketVersion: Option<MarketVersion>,
+ r#async: Option<bool>,
+ ) -> Result<ReplaceExecutionReport> {
+ let req: replaceOrdersRequest = replaceOrdersRequest {
+ marketId,
+ instructions,
+ customerRef,
+ marketVersion,
+ r#async,
+ };
+ let rpc_request: RpcRequest<replaceOrdersRequest> =
+ RpcRequest::new("SportsAPING/v1.0/replaceOrders".to_owned(), req);
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn updateOrders(
+ &self,
+ marketId: MarketId,
+ instructions: Vec<UpdateInstruction>,
+ customerRef: Option<String>,
+ ) -> Result<UpdateExecutionReport> {
+ let req: updateOrdersRequest = updateOrdersRequest {
+ marketId,
+ instructions,
+ customerRef,
+ };
+ let rpc_request: RpcRequest<updateOrdersRequest> =
+ RpcRequest::new("SportsAPING/v1.0/updateOrders".to_owned(), req);
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn listMarketProfitAndLoss(
+ &self,
+ marketIds: Vec<MarketId>,
+ includeSettledBets: Option<bool>,
+ includeBspBets: Option<bool>,
+ netOfCommission: Option<bool>,
+ ) -> Result<Vec<MarketProfitAndLoss>> {
+ let req: listMarketProfitAndLossRequest =
+ listMarketProfitAndLossRequest {
+ marketIds,
+ includeSettledBets,
+ includeBspBets,
+ netOfCommission,
+ };
+ let rpc_request: RpcRequest<listMarketProfitAndLossRequest> =
+ RpcRequest::new(
+ "SportsAPING/v1.0/listMarketProfitAndLoss".to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn setDefaultExposureLimitForMarketGroups(
+ &self,
+ marketGroupType: MarketGroupType,
+ limit: ExposureLimit,
+ ) -> Result<String> {
+ let req: setDefaultExposureLimitForMarketGroupsRequest =
+ setDefaultExposureLimitForMarketGroupsRequest {
+ marketGroupType,
+ limit,
+ };
+ let rpc_request: RpcRequest<
+ setDefaultExposureLimitForMarketGroupsRequest,
+ > = RpcRequest::new(
+ "SportsAPING/v1.0/setDefaultExposureLimitForMarketGroups"
+ .to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn setExposureLimitForMarketGroup(
+ &self,
+ marketGroup: MarketGroup,
+ limit: ExposureLimit,
+ ) -> Result<String> {
+ let req: setExposureLimitForMarketGroupRequest =
+ setExposureLimitForMarketGroupRequest { marketGroup, limit };
+ let rpc_request: RpcRequest<setExposureLimitForMarketGroupRequest> =
+ RpcRequest::new(
+ "SportsAPING/v1.0/setExposureLimitForMarketGroup".to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn removeDefaultExposureLimitForMarketGroups(
+ &self,
+ marketGroupType: MarketGroupType,
+ ) -> Result<String> {
+ let req: removeDefaultExposureLimitForMarketGroupsRequest =
+ removeDefaultExposureLimitForMarketGroupsRequest {
+ marketGroupType,
+ };
+ let rpc_request: RpcRequest<
+ removeDefaultExposureLimitForMarketGroupsRequest,
+ > = RpcRequest::new(
+ "SportsAPING/v1.0/removeDefaultExposureLimitForMarketGroups"
+ .to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn removeExposureLimitForMarketGroup(
+ &self,
+ marketGroup: MarketGroup,
+ ) -> Result<String> {
+ let req: removeExposureLimitForMarketGroupRequest =
+ removeExposureLimitForMarketGroupRequest { marketGroup };
+ let rpc_request: RpcRequest<removeExposureLimitForMarketGroupRequest> =
+ RpcRequest::new(
+ "SportsAPING/v1.0/removeExposureLimitForMarketGroup"
+ .to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn listExposureLimitsForMarketGroups(
+ &self,
+ marketGroupTypeFilter: Option<MarketGroupType>,
+ marketGroupFilter: Option<Vec<MarketGroup>>,
+ ) -> Result<Vec<ExposureLimitsForMarketGroups>> {
+ let req: listExposureLimitsForMarketGroupsRequest =
+ listExposureLimitsForMarketGroupsRequest {
+ marketGroupTypeFilter,
+ marketGroupFilter,
+ };
+ let rpc_request: RpcRequest<listExposureLimitsForMarketGroupsRequest> =
+ RpcRequest::new(
+ "SportsAPING/v1.0/listExposureLimitsForMarketGroups"
+ .to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn unblockMarketGroup(
+ &self,
+ marketGroup: MarketGroup,
+ ) -> Result<String> {
+ let req: unblockMarketGroupRequest =
+ unblockMarketGroupRequest { marketGroup };
+ let rpc_request: RpcRequest<unblockMarketGroupRequest> =
+ RpcRequest::new(
+ "SportsAPING/v1.0/unblockMarketGroup".to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn getExposureReuseEnabledEvents(&self) -> Result<Vec<i64>> {
+ let rpc_request: RpcRequest<()> = RpcRequest::new(
+ "SportsAPING/v1.0/getExposureReuseEnabledEvents".to_owned(),
+ (),
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn addExposureReuseEnabledEvents(
+ &self,
+ eventIds: Vec<i64>,
+ ) -> Result<String> {
+ let req: addExposureReuseEnabledEventsRequest =
+ addExposureReuseEnabledEventsRequest { eventIds };
+ let rpc_request: RpcRequest<addExposureReuseEnabledEventsRequest> =
+ RpcRequest::new(
+ "SportsAPING/v1.0/addExposureReuseEnabledEvents".to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+ #[allow(dead_code)]
+ pub fn removeExposureReuseEnabledEvents(
+ &self,
+ eventIds: Vec<i64>,
+ ) -> Result<String> {
+ let req: removeExposureReuseEnabledEventsRequest =
+ removeExposureReuseEnabledEventsRequest { eventIds };
+ let rpc_request: RpcRequest<removeExposureReuseEnabledEventsRequest> =
+ RpcRequest::new(
+ "SportsAPING/v1.0/removeExposureReuseEnabledEvents".to_owned(),
+ req,
+ );
+ self.req(rpc_request).map(|x| x.into_inner())
+ }
+}
diff --git a/src/generated_requests.rs b/src/generated_requests.rs
new file mode 100644
index 0000000..372e2e8
--- /dev/null
+++ b/src/generated_requests.rs
@@ -0,0 +1,256 @@
+// This file has been automatically generated by botfair
+// from the Betfair APING documentation at
+// https://docs.developer.betfair.com
+
+#![allow(non_camel_case_types)]
+#![allow(non_snake_case)]
+use crate::generated_types::*;
+use chrono::{DateTime, Utc};
+use serde::Serialize;
+#[derive(Serialize)]
+pub struct listEventTypesRequest {
+ pub filter: MarketFilter,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub locale: Option<String>,
+}
+#[derive(Serialize)]
+pub struct listCompetitionsRequest {
+ pub filter: MarketFilter,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub locale: Option<String>,
+}
+#[derive(Serialize)]
+pub struct listTimeRangesRequest {
+ pub filter: MarketFilter,
+ pub granularity: TimeGranularity,
+}
+#[derive(Serialize)]
+pub struct listEventsRequest {
+ pub filter: MarketFilter,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub locale: Option<String>,
+}
+#[derive(Serialize)]
+pub struct listMarketTypesRequest {
+ pub filter: MarketFilter,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub locale: Option<String>,
+}
+#[derive(Serialize)]
+pub struct listCountriesRequest {
+ pub filter: MarketFilter,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub locale: Option<String>,
+}
+#[derive(Serialize)]
+pub struct listVenuesRequest {
+ pub filter: MarketFilter,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub locale: Option<String>,
+}
+#[derive(Serialize)]
+pub struct listMarketCatalogueRequest {
+ pub filter: MarketFilter,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub marketProjection: Option<Vec<MarketProjection>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub sort: Option<MarketSort>,
+ pub maxResults: i32,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub locale: Option<String>,
+}
+#[derive(Serialize)]
+pub struct listMarketBookRequest {
+ pub marketIds: Vec<MarketId>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub priceProjection: Option<PriceProjection>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub orderProjection: Option<OrderProjection>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub matchProjection: Option<MatchProjection>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub includeOverallPosition: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub partitionMatchedByStrategyRef: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub customerStrategyRefs: Option<Vec<String>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub currencyCode: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub locale: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub matchedSince: Option<DateTime<Utc>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub betIds: Option<Vec<BetId>>,
+}
+#[derive(Serialize)]
+pub struct listRunnerBookRequest {
+ pub marketId: MarketId,
+ pub selectionId: SelectionId,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub handicap: Option<f64>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub priceProjection: Option<PriceProjection>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub orderProjection: Option<OrderProjection>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub matchProjection: Option<MatchProjection>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub includeOverallPosition: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub partitionMatchedByStrategyRef: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub customerStrategyRefs: Option<Vec<String>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub currencyCode: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub locale: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub matchedSince: Option<DateTime<Utc>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub betIds: Option<Vec<BetId>>,
+}
+#[derive(Serialize)]
+pub struct listCurrentOrdersRequest {
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub betIds: Option<Vec<BetId>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub marketIds: Option<Vec<MarketId>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub orderProjection: Option<OrderProjection>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub customerOrderRefs: Option<Vec<CustomerOrderRef>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub customerStrategyRefs: Option<Vec<CustomerStrategyRef>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub placedDateRange: Option<TimeRange>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub dateRange: Option<TimeRange>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub orderBy: Option<OrderBy>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub sortDir: Option<SortDir>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub fromRecord: Option<i32>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub recordCount: Option<i32>,
+}
+#[derive(Serialize)]
+pub struct listClearedOrdersRequest {
+ pub betStatus: BetStatus,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub eventTypeIds: Option<Vec<EventTypeId>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub eventIds: Option<Vec<EventId>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub marketIds: Option<Vec<MarketId>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub runnerIds: Option<Vec<RunnerId>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub betIds: Option<Vec<BetId>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub customerOrderRefs: Option<Vec<CustomerOrderRef>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub customerStrategyRefs: Option<Vec<CustomerStrategyRef>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub side: Option<Side>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub settledDateRange: Option<TimeRange>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub groupBy: Option<GroupBy>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub includeItemDescription: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub locale: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub fromRecord: Option<i32>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub recordCount: Option<i32>,
+}
+#[derive(Serialize)]
+pub struct placeOrdersRequest {
+ pub marketId: MarketId,
+ pub instructions: Vec<PlaceInstruction>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub customerRef: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub marketVersion: Option<MarketVersion>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub customerStrategyRef: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub r#async: Option<bool>,
+}
+#[derive(Serialize)]
+pub struct cancelOrdersRequest {
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub marketId: Option<MarketId>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub instructions: Option<Vec<CancelInstruction>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub customerRef: Option<String>,
+}
+#[derive(Serialize)]
+pub struct replaceOrdersRequest {
+ pub marketId: MarketId,
+ pub instructions: Vec<ReplaceInstruction>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub customerRef: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub marketVersion: Option<MarketVersion>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub r#async: Option<bool>,
+}
+#[derive(Serialize)]
+pub struct updateOrdersRequest {
+ pub marketId: MarketId,
+ pub instructions: Vec<UpdateInstruction>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub customerRef: Option<String>,
+}
+#[derive(Serialize)]
+pub struct listMarketProfitAndLossRequest {
+ pub marketIds: Vec<MarketId>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub includeSettledBets: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub includeBspBets: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub netOfCommission: Option<bool>,
+}
+#[derive(Serialize)]
+pub struct setDefaultExposureLimitForMarketGroupsRequest {
+ pub marketGroupType: MarketGroupType,
+ pub limit: ExposureLimit,
+}
+#[derive(Serialize)]
+pub struct setExposureLimitForMarketGroupRequest {
+ pub marketGroup: MarketGroup,
+ pub limit: ExposureLimit,
+}
+#[derive(Serialize)]
+pub struct removeDefaultExposureLimitForMarketGroupsRequest {
+ pub marketGroupType: MarketGroupType,
+}
+#[derive(Serialize)]
+pub struct removeExposureLimitForMarketGroupRequest {
+ pub marketGroup: MarketGroup,
+}
+#[derive(Serialize)]
+pub struct listExposureLimitsForMarketGroupsRequest {
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub marketGroupTypeFilter: Option<MarketGroupType>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub marketGroupFilter: Option<Vec<MarketGroup>>,
+}
+#[derive(Serialize)]
+pub struct unblockMarketGroupRequest {
+ pub marketGroup: MarketGroup,
+}
+#[derive(Serialize)]
+pub struct addExposureReuseEnabledEventsRequest {
+ pub eventIds: Vec<i64>,
+}
+#[derive(Serialize)]
+pub struct removeExposureReuseEnabledEventsRequest {
+ pub eventIds: Vec<i64>,
+}
diff --git a/src/generated_api.rs b/src/generated_types.rs
index bead448..8e1e08b 100644
--- a/src/generated_api.rs
+++ b/src/generated_types.rs
@@ -1,901 +1,12 @@
-// This file is generated.
-// Any manual edits will be overwritten.
+// This file has been automatically generated by botfair
+// from the Betfair APING documentation at
+// https://docs.developer.betfair.com
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
-#![allow(unused_variables)]
-#![allow(dead_code)]
-use crate::json_rpc::RpcRequest;
-use crate::Result;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
-#[derive(Serialize)]
-pub struct listEventTypesRequest {
- pub filter: MarketFilter,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub locale: Option<String>,
-}
-#[derive(Serialize)]
-pub struct listCompetitionsRequest {
- pub filter: MarketFilter,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub locale: Option<String>,
-}
-#[derive(Serialize)]
-pub struct listTimeRangesRequest {
- pub filter: MarketFilter,
- pub granularity: TimeGranularity,
-}
-#[derive(Serialize)]
-pub struct listEventsRequest {
- pub filter: MarketFilter,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub locale: Option<String>,
-}
-#[derive(Serialize)]
-pub struct listMarketTypesRequest {
- pub filter: MarketFilter,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub locale: Option<String>,
-}
-#[derive(Serialize)]
-pub struct listCountriesRequest {
- pub filter: MarketFilter,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub locale: Option<String>,
-}
-#[derive(Serialize)]
-pub struct listVenuesRequest {
- pub filter: MarketFilter,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub locale: Option<String>,
-}
-#[derive(Serialize)]
-pub struct listMarketCatalogueRequest {
- pub filter: MarketFilter,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub marketProjection: Option<Vec<MarketProjection>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub sort: Option<MarketSort>,
- pub maxResults: i32,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub locale: Option<String>,
-}
-#[derive(Serialize)]
-pub struct listMarketBookRequest {
- pub marketIds: Vec<MarketId>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub priceProjection: Option<PriceProjection>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub orderProjection: Option<OrderProjection>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub matchProjection: Option<MatchProjection>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub includeOverallPosition: Option<bool>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub partitionMatchedByStrategyRef: Option<bool>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub customerStrategyRefs: Option<Vec<String>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub currencyCode: Option<String>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub locale: Option<String>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub matchedSince: Option<DateTime<Utc>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub betIds: Option<Vec<BetId>>,
-}
-#[derive(Serialize)]
-pub struct listRunnerBookRequest {
- pub marketId: MarketId,
- pub selectionId: SelectionId,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub handicap: Option<f64>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub priceProjection: Option<PriceProjection>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub orderProjection: Option<OrderProjection>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub matchProjection: Option<MatchProjection>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub includeOverallPosition: Option<bool>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub partitionMatchedByStrategyRef: Option<bool>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub customerStrategyRefs: Option<Vec<String>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub currencyCode: Option<String>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub locale: Option<String>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub matchedSince: Option<DateTime<Utc>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub betIds: Option<Vec<BetId>>,
-}
-#[derive(Serialize)]
-pub struct listCurrentOrdersRequest {
- #[serde(skip_serializing_if = "Option::is_none")]
- pub betIds: Option<Vec<BetId>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub marketIds: Option<Vec<MarketId>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub orderProjection: Option<OrderProjection>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub customerOrderRefs: Option<Vec<CustomerOrderRef>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub customerStrategyRefs: Option<Vec<CustomerStrategyRef>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub placedDateRange: Option<TimeRange>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub dateRange: Option<TimeRange>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub orderBy: Option<OrderBy>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub sortDir: Option<SortDir>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub fromRecord: Option<i32>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub recordCount: Option<i32>,
-}
-#[derive(Serialize)]
-pub struct listClearedOrdersRequest {
- pub betStatus: BetStatus,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub eventTypeIds: Option<Vec<EventTypeId>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub eventIds: Option<Vec<EventId>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub marketIds: Option<Vec<MarketId>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub runnerIds: Option<Vec<RunnerId>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub betIds: Option<Vec<BetId>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub customerOrderRefs: Option<Vec<CustomerOrderRef>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub customerStrategyRefs: Option<Vec<CustomerStrategyRef>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub side: Option<Side>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub settledDateRange: Option<TimeRange>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub groupBy: Option<GroupBy>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub includeItemDescription: Option<bool>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub locale: Option<String>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub fromRecord: Option<i32>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub recordCount: Option<i32>,
-}
-#[derive(Serialize)]
-pub struct placeOrdersRequest {
- pub marketId: MarketId,
- pub instructions: Vec<PlaceInstruction>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub customerRef: Option<String>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub marketVersion: Option<MarketVersion>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub customerStrategyRef: Option<String>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub r#async: Option<bool>,
-}
-#[derive(Serialize)]
-pub struct cancelOrdersRequest {
- #[serde(skip_serializing_if = "Option::is_none")]
- pub marketId: Option<MarketId>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub instructions: Option<Vec<CancelInstruction>>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub customerRef: Option<String>,
-}
-#[derive(Serialize)]
-pub struct replaceOrdersRequest {
- pub marketId: MarketId,
- pub instructions: Vec<ReplaceInstruction>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub customerRef: Option<String>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub marketVersion: Option<MarketVersion>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub r#async: Option<bool>,
-}
-#[derive(Serialize)]
-pub struct updateOrdersRequest {
- pub marketId: MarketId,
- pub instructions: Vec<UpdateInstruction>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub customerRef: Option<String>,
-}
-#[derive(Serialize)]
-pub struct listMarketProfitAndLossRequest {
- pub marketIds: Vec<MarketId>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub includeSettledBets: Option<bool>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub includeBspBets: Option<bool>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub netOfCommission: Option<bool>,
-}
-#[derive(Serialize)]
-pub struct setDefaultExposureLimitForMarketGroupsRequest {
- pub marketGroupType: MarketGroupType,
- pub limit: ExposureLimit,
-}
-#[derive(Serialize)]
-pub struct setExposureLimitForMarketGroupRequest {
- pub marketGroup: MarketGroup,
- pub limit: ExposureLimit,
-}
-#[derive(Serialize)]
-pub struct removeDefaultExposureLimitForMarketGroupsRequest {
- pub marketGroupType: MarketGroupType,
-}
-#[derive(Serialize)]
-pub struct removeExposureLimitForMarketGroupRequest {
- pub marketGroup: MarketGroup,
-}
-#[derive(Serialize)]
-pub struct listExposureLimitsForMarketGroupsRequest {
- #[serde(skip_serializing_if = "Option::is_none")]
- pub marketGroupTypeFilter: Option<MarketGroupType>,
- #[serde(skip_serializing_if = "Option::is_none")]
- pub marketGroupFilter: Option<Vec<MarketGroup>>,
-}
-#[derive(Serialize)]
-pub struct unblockMarketGroupRequest {
- pub marketGroup: MarketGroup,
-}
-#[derive(Serialize)]
-pub struct addExposureReuseEnabledEventsRequest {
- pub eventIds: Vec<i64>,
-}
-#[derive(Serialize)]
-pub struct removeExposureReuseEnabledEventsRequest {
- pub eventIds: Vec<i64>,
-}
-pub trait BFApiCalls {
- fn listEventTypes(
- &self,
- filter: MarketFilter,
- locale: Option<String>,
- ) -> Result<Vec<EventTypeResult>>;
- fn listCompetitions(
- &self,
- filter: MarketFilter,
- locale: Option<String>,
- ) -> Result<Vec<CompetitionResult>>;
- fn listTimeRanges(
- &self,
- filter: MarketFilter,
- granularity: TimeGranularity,
- ) -> Result<Vec<TimeRangeResult>>;
- fn listEvents(
- &self,
- filter: MarketFilter,
- locale: Option<String>,
- ) -> Result<Vec<EventResult>>;
- fn listMarketTypes(
- &self,
- filter: MarketFilter,
- locale: Option<String>,
- ) -> Result<Vec<MarketTypeResult>>;
- fn listCountries(
- &self,
- filter: MarketFilter,
- locale: Option<String>,
- ) -> Result<Vec<CountryCodeResult>>;
- fn listVenues(
- &self,
- filter: MarketFilter,
- locale: Option<String>,
- ) -> Result<Vec<VenueResult>>;
- fn listMarketCatalogue(
- &self,
- filter: MarketFilter,
- marketProjection: Option<Vec<MarketProjection>>,
- sort: Option<MarketSort>,
- maxResults: i32,
- locale: Option<String>,
- ) -> Result<Vec<MarketCatalogue>>;
- fn listMarketBook(
- &self,
- marketIds: Vec<MarketId>,
- priceProjection: Option<PriceProjection>,
- orderProjection: Option<OrderProjection>,
- matchProjection: Option<MatchProjection>,
- includeOverallPosition: Option<bool>,
- partitionMatchedByStrategyRef: Option<bool>,
- customerStrategyRefs: Option<Vec<String>>,
- currencyCode: Option<String>,
- locale: Option<String>,
- matchedSince: Option<DateTime<Utc>>,
- betIds: Option<Vec<BetId>>,
- ) -> Result<Vec<MarketBook>>;
- fn listRunnerBook(
- &self,
- marketId: MarketId,
- selectionId: SelectionId,
- handicap: Option<f64>,
- priceProjection: Option<PriceProjection>,
- orderProjection: Option<OrderProjection>,
- matchProjection: Option<MatchProjection>,
- includeOverallPosition: Option<bool>,
- partitionMatchedByStrategyRef: Option<bool>,
- customerStrategyRefs: Option<Vec<String>>,
- currencyCode: Option<String>,
- locale: Option<String>,
- matchedSince: Option<DateTime<Utc>>,
- betIds: Option<Vec<BetId>>,
- ) -> Result<Vec<MarketBook>>;
- fn listCurrentOrders(
- &self,
- betIds: Option<Vec<BetId>>,
- marketIds: Option<Vec<MarketId>>,
- orderProjection: Option<OrderProjection>,
- customerOrderRefs: Option<Vec<CustomerOrderRef>>,
- customerStrategyRefs: Option<Vec<CustomerStrategyRef>>,
- placedDateRange: Option<TimeRange>,
- dateRange: Option<TimeRange>,
- orderBy: Option<OrderBy>,
- sortDir: Option<SortDir>,
- fromRecord: Option<i32>,
- recordCount: Option<i32>,
- ) -> Result<CurrentOrderSummaryReport>;
- fn listClearedOrders(
- &self,
- betStatus: BetStatus,
- eventTypeIds: Option<Vec<EventTypeId>>,
- eventIds: Option<Vec<EventId>>,
- marketIds: Option<Vec<MarketId>>,
- runnerIds: Option<Vec<RunnerId>>,
- betIds: Option<Vec<BetId>>,
- customerOrderRefs: Option<Vec<CustomerOrderRef>>,
- customerStrategyRefs: Option<Vec<CustomerStrategyRef>>,
- side: Option<Side>,
- settledDateRange: Option<TimeRange>,
- groupBy: Option<GroupBy>,
- includeItemDescription: Option<bool>,
- locale: Option<String>,
- fromRecord: Option<i32>,
- recordCount: Option<i32>,
- ) -> Result<ClearedOrderSummaryReport>;
- fn placeOrders(
- &self,
- marketId: MarketId,
- instructions: Vec<PlaceInstruction>,
- customerRef: Option<String>,
- marketVersion: Option<MarketVersion>,
- customerStrategyRef: Option<String>,
- r#async: Option<bool>,
- ) -> Result<PlaceExecutionReport>;
- fn cancelOrders(
- &self,
- marketId: Option<MarketId>,
- instructions: Option<Vec<CancelInstruction>>,
- customerRef: Option<String>,
- ) -> Result<CancelExecutionReport>;
- fn replaceOrders(
- &self,
- marketId: MarketId,
- instructions: Vec<ReplaceInstruction>,
- customerRef: Option<String>,
- marketVersion: Option<MarketVersion>,
- r#async: Option<bool>,
- ) -> Result<ReplaceExecutionReport>;
- fn updateOrders(
- &self,
- marketId: MarketId,
- instructions: Vec<UpdateInstruction>,
- customerRef: Option<String>,
- ) -> Result<UpdateExecutionReport>;
- fn listMarketProfitAndLoss(
- &self,
- marketIds: Vec<MarketId>,
- includeSettledBets: Option<bool>,
- includeBspBets: Option<bool>,
- netOfCommission: Option<bool>,
- ) -> Result<Vec<MarketProfitAndLoss>>;
- fn setDefaultExposureLimitForMarketGroups(
- &self,
- marketGroupType: MarketGroupType,
- limit: ExposureLimit,
- ) -> Result<String>;
- fn setExposureLimitForMarketGroup(
- &self,
- marketGroup: MarketGroup,
- limit: ExposureLimit,
- ) -> Result<String>;
- fn removeDefaultExposureLimitForMarketGroups(
- &self,
- marketGroupType: MarketGroupType,
- ) -> Result<String>;
- fn removeExposureLimitForMarketGroup(
- &self,
- marketGroup: MarketGroup,
- ) -> Result<String>;
- fn listExposureLimitsForMarketGroups(
- &self,
- marketGroupTypeFilter: Option<MarketGroupType>,
- marketGroupFilter: Option<Vec<MarketGroup>>,
- ) -> Result<Vec<ExposureLimitsForMarketGroups>>;
- fn unblockMarketGroup(&self, marketGroup: MarketGroup) -> Result<String>;
- fn getExposureReuseEnabledEvents(&self) -> Result<Vec<i64>>;
- fn addExposureReuseEnabledEvents(
- &self,
- eventIds: Vec<i64>,
- ) -> Result<String>;
- fn removeExposureReuseEnabledEvents(
- &self,
- eventIds: Vec<i64>,
- ) -> Result<String>;
-}
-impl BFApiCalls for crate::BFClient {
- fn listEventTypes(
- &self,
- filter: MarketFilter,
- locale: Option<String>,
- ) -> Result<Vec<EventTypeResult>> {
- let req: listEventTypesRequest =
- listEventTypesRequest { filter, locale };
- let rpc_request: RpcRequest<listEventTypesRequest> =
- RpcRequest::new("SportsAPING/v1.0/listEventTypes".to_owned(), req);
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn listCompetitions(
- &self,
- filter: MarketFilter,
- locale: Option<String>,
- ) -> Result<Vec<CompetitionResult>> {
- let req: listCompetitionsRequest =
- listCompetitionsRequest { filter, locale };
- let rpc_request: RpcRequest<listCompetitionsRequest> = RpcRequest::new(
- "SportsAPING/v1.0/listCompetitions".to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn listTimeRanges(
- &self,
- filter: MarketFilter,
- granularity: TimeGranularity,
- ) -> Result<Vec<TimeRangeResult>> {
- let req: listTimeRangesRequest = listTimeRangesRequest {
- filter,
- granularity,
- };
- let rpc_request: RpcRequest<listTimeRangesRequest> =
- RpcRequest::new("SportsAPING/v1.0/listTimeRanges".to_owned(), req);
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn listEvents(
- &self,
- filter: MarketFilter,
- locale: Option<String>,
- ) -> Result<Vec<EventResult>> {
- let req: listEventsRequest = listEventsRequest { filter, locale };
- let rpc_request: RpcRequest<listEventsRequest> =
- RpcRequest::new("SportsAPING/v1.0/listEvents".to_owned(), req);
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn listMarketTypes(
- &self,
- filter: MarketFilter,
- locale: Option<String>,
- ) -> Result<Vec<MarketTypeResult>> {
- let req: listMarketTypesRequest =
- listMarketTypesRequest { filter, locale };
- let rpc_request: RpcRequest<listMarketTypesRequest> = RpcRequest::new(
- "SportsAPING/v1.0/listMarketTypes".to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn listCountries(
- &self,
- filter: MarketFilter,
- locale: Option<String>,
- ) -> Result<Vec<CountryCodeResult>> {
- let req: listCountriesRequest =
- listCountriesRequest { filter, locale };
- let rpc_request: RpcRequest<listCountriesRequest> =
- RpcRequest::new("SportsAPING/v1.0/listCountries".to_owned(), req);
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn listVenues(
- &self,
- filter: MarketFilter,
- locale: Option<String>,
- ) -> Result<Vec<VenueResult>> {
- let req: listVenuesRequest = listVenuesRequest { filter, locale };
- let rpc_request: RpcRequest<listVenuesRequest> =
- RpcRequest::new("SportsAPING/v1.0/listVenues".to_owned(), req);
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn listMarketCatalogue(
- &self,
- filter: MarketFilter,
- marketProjection: Option<Vec<MarketProjection>>,
- sort: Option<MarketSort>,
- maxResults: i32,
- locale: Option<String>,
- ) -> Result<Vec<MarketCatalogue>> {
- let req: listMarketCatalogueRequest = listMarketCatalogueRequest {
- filter,
- marketProjection,
- sort,
- maxResults,
- locale,
- };
- let rpc_request: RpcRequest<listMarketCatalogueRequest> =
- RpcRequest::new(
- "SportsAPING/v1.0/listMarketCatalogue".to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn listMarketBook(
- &self,
- marketIds: Vec<MarketId>,
- priceProjection: Option<PriceProjection>,
- orderProjection: Option<OrderProjection>,
- matchProjection: Option<MatchProjection>,
- includeOverallPosition: Option<bool>,
- partitionMatchedByStrategyRef: Option<bool>,
- customerStrategyRefs: Option<Vec<String>>,
- currencyCode: Option<String>,
- locale: Option<String>,
- matchedSince: Option<DateTime<Utc>>,
- betIds: Option<Vec<BetId>>,
- ) -> Result<Vec<MarketBook>> {
- let req: listMarketBookRequest = listMarketBookRequest {
- marketIds,
- priceProjection,
- orderProjection,
- matchProjection,
- includeOverallPosition,
- partitionMatchedByStrategyRef,
- customerStrategyRefs,
- currencyCode,
- locale,
- matchedSince,
- betIds,
- };
- let rpc_request: RpcRequest<listMarketBookRequest> =
- RpcRequest::new("SportsAPING/v1.0/listMarketBook".to_owned(), req);
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn listRunnerBook(
- &self,
- marketId: MarketId,
- selectionId: SelectionId,
- handicap: Option<f64>,
- priceProjection: Option<PriceProjection>,
- orderProjection: Option<OrderProjection>,
- matchProjection: Option<MatchProjection>,
- includeOverallPosition: Option<bool>,
- partitionMatchedByStrategyRef: Option<bool>,
- customerStrategyRefs: Option<Vec<String>>,
- currencyCode: Option<String>,
- locale: Option<String>,
- matchedSince: Option<DateTime<Utc>>,
- betIds: Option<Vec<BetId>>,
- ) -> Result<Vec<MarketBook>> {
- let req: listRunnerBookRequest = listRunnerBookRequest {
- marketId,
- selectionId,
- handicap,
- priceProjection,
- orderProjection,
- matchProjection,
- includeOverallPosition,
- partitionMatchedByStrategyRef,
- customerStrategyRefs,
- currencyCode,
- locale,
- matchedSince,
- betIds,
- };
- let rpc_request: RpcRequest<listRunnerBookRequest> =
- RpcRequest::new("SportsAPING/v1.0/listRunnerBook".to_owned(), req);
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn listCurrentOrders(
- &self,
- betIds: Option<Vec<BetId>>,
- marketIds: Option<Vec<MarketId>>,
- orderProjection: Option<OrderProjection>,
- customerOrderRefs: Option<Vec<CustomerOrderRef>>,
- customerStrategyRefs: Option<Vec<CustomerStrategyRef>>,
- placedDateRange: Option<TimeRange>,
- dateRange: Option<TimeRange>,
- orderBy: Option<OrderBy>,
- sortDir: Option<SortDir>,
- fromRecord: Option<i32>,
- recordCount: Option<i32>,
- ) -> Result<CurrentOrderSummaryReport> {
- let req: listCurrentOrdersRequest = listCurrentOrdersRequest {
- betIds,
- marketIds,
- orderProjection,
- customerOrderRefs,
- customerStrategyRefs,
- placedDateRange,
- dateRange,
- orderBy,
- sortDir,
- fromRecord,
- recordCount,
- };
- let rpc_request: RpcRequest<listCurrentOrdersRequest> =
- RpcRequest::new(
- "SportsAPING/v1.0/listCurrentOrders".to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn listClearedOrders(
- &self,
- betStatus: BetStatus,
- eventTypeIds: Option<Vec<EventTypeId>>,
- eventIds: Option<Vec<EventId>>,
- marketIds: Option<Vec<MarketId>>,
- runnerIds: Option<Vec<RunnerId>>,
- betIds: Option<Vec<BetId>>,
- customerOrderRefs: Option<Vec<CustomerOrderRef>>,
- customerStrategyRefs: Option<Vec<CustomerStrategyRef>>,
- side: Option<Side>,
- settledDateRange: Option<TimeRange>,
- groupBy: Option<GroupBy>,
- includeItemDescription: Option<bool>,
- locale: Option<String>,
- fromRecord: Option<i32>,
- recordCount: Option<i32>,
- ) -> Result<ClearedOrderSummaryReport> {
- let req: listClearedOrdersRequest = listClearedOrdersRequest {
- betStatus,
- eventTypeIds,
- eventIds,
- marketIds,
- runnerIds,
- betIds,
- customerOrderRefs,
- customerStrategyRefs,
- side,
- settledDateRange,
- groupBy,
- includeItemDescription,
- locale,
- fromRecord,
- recordCount,
- };
- let rpc_request: RpcRequest<listClearedOrdersRequest> =
- RpcRequest::new(
- "SportsAPING/v1.0/listClearedOrders".to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn placeOrders(
- &self,
- marketId: MarketId,
- instructions: Vec<PlaceInstruction>,
- customerRef: Option<String>,
- marketVersion: Option<MarketVersion>,
- customerStrategyRef: Option<String>,
- r#async: Option<bool>,
- ) -> Result<PlaceExecutionReport> {
- let req: placeOrdersRequest = placeOrdersRequest {
- marketId,
- instructions,
- customerRef,
- marketVersion,
- customerStrategyRef,
- r#async,
- };
- let rpc_request: RpcRequest<placeOrdersRequest> =
- RpcRequest::new("SportsAPING/v1.0/placeOrders".to_owned(), req);
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn cancelOrders(
- &self,
- marketId: Option<MarketId>,
- instructions: Option<Vec<CancelInstruction>>,
- customerRef: Option<String>,
- ) -> Result<CancelExecutionReport> {
- let req: cancelOrdersRequest = cancelOrdersRequest {
- marketId,
- instructions,
- customerRef,
- };
- let rpc_request: RpcRequest<cancelOrdersRequest> =
- RpcRequest::new("SportsAPING/v1.0/cancelOrders".to_owned(), req);
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn replaceOrders(
- &self,
- marketId: MarketId,
- instructions: Vec<ReplaceInstruction>,
- customerRef: Option<String>,
- marketVersion: Option<MarketVersion>,
- r#async: Option<bool>,
- ) -> Result<ReplaceExecutionReport> {
- let req: replaceOrdersRequest = replaceOrdersRequest {
- marketId,
- instructions,
- customerRef,
- marketVersion,
- r#async,
- };
- let rpc_request: RpcRequest<replaceOrdersRequest> =
- RpcRequest::new("SportsAPING/v1.0/replaceOrders".to_owned(), req);
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn updateOrders(
- &self,
- marketId: MarketId,
- instructions: Vec<UpdateInstruction>,
- customerRef: Option<String>,
- ) -> Result<UpdateExecutionReport> {
- let req: updateOrdersRequest = updateOrdersRequest {
- marketId,
- instructions,
- customerRef,
- };
- let rpc_request: RpcRequest<updateOrdersRequest> =
- RpcRequest::new("SportsAPING/v1.0/updateOrders".to_owned(), req);
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn listMarketProfitAndLoss(
- &self,
- marketIds: Vec<MarketId>,
- includeSettledBets: Option<bool>,
- includeBspBets: Option<bool>,
- netOfCommission: Option<bool>,
- ) -> Result<Vec<MarketProfitAndLoss>> {
- let req: listMarketProfitAndLossRequest =
- listMarketProfitAndLossRequest {
- marketIds,
- includeSettledBets,
- includeBspBets,
- netOfCommission,
- };
- let rpc_request: RpcRequest<listMarketProfitAndLossRequest> =
- RpcRequest::new(
- "SportsAPING/v1.0/listMarketProfitAndLoss".to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn setDefaultExposureLimitForMarketGroups(
- &self,
- marketGroupType: MarketGroupType,
- limit: ExposureLimit,
- ) -> Result<String> {
- let req: setDefaultExposureLimitForMarketGroupsRequest =
- setDefaultExposureLimitForMarketGroupsRequest {
- marketGroupType,
- limit,
- };
- let rpc_request: RpcRequest<
- setDefaultExposureLimitForMarketGroupsRequest,
- > = RpcRequest::new(
- "SportsAPING/v1.0/setDefaultExposureLimitForMarketGroups"
- .to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn setExposureLimitForMarketGroup(
- &self,
- marketGroup: MarketGroup,
- limit: ExposureLimit,
- ) -> Result<String> {
- let req: setExposureLimitForMarketGroupRequest =
- setExposureLimitForMarketGroupRequest { marketGroup, limit };
- let rpc_request: RpcRequest<setExposureLimitForMarketGroupRequest> =
- RpcRequest::new(
- "SportsAPING/v1.0/setExposureLimitForMarketGroup".to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn removeDefaultExposureLimitForMarketGroups(
- &self,
- marketGroupType: MarketGroupType,
- ) -> Result<String> {
- let req: removeDefaultExposureLimitForMarketGroupsRequest =
- removeDefaultExposureLimitForMarketGroupsRequest {
- marketGroupType,
- };
- let rpc_request: RpcRequest<
- removeDefaultExposureLimitForMarketGroupsRequest,
- > = RpcRequest::new(
- "SportsAPING/v1.0/removeDefaultExposureLimitForMarketGroups"
- .to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn removeExposureLimitForMarketGroup(
- &self,
- marketGroup: MarketGroup,
- ) -> Result<String> {
- let req: removeExposureLimitForMarketGroupRequest =
- removeExposureLimitForMarketGroupRequest { marketGroup };
- let rpc_request: RpcRequest<removeExposureLimitForMarketGroupRequest> =
- RpcRequest::new(
- "SportsAPING/v1.0/removeExposureLimitForMarketGroup"
- .to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn listExposureLimitsForMarketGroups(
- &self,
- marketGroupTypeFilter: Option<MarketGroupType>,
- marketGroupFilter: Option<Vec<MarketGroup>>,
- ) -> Result<Vec<ExposureLimitsForMarketGroups>> {
- let req: listExposureLimitsForMarketGroupsRequest =
- listExposureLimitsForMarketGroupsRequest {
- marketGroupTypeFilter,
- marketGroupFilter,
- };
- let rpc_request: RpcRequest<listExposureLimitsForMarketGroupsRequest> =
- RpcRequest::new(
- "SportsAPING/v1.0/listExposureLimitsForMarketGroups"
- .to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn unblockMarketGroup(&self, marketGroup: MarketGroup) -> Result<String> {
- let req: unblockMarketGroupRequest =
- unblockMarketGroupRequest { marketGroup };
- let rpc_request: RpcRequest<unblockMarketGroupRequest> =
- RpcRequest::new(
- "SportsAPING/v1.0/unblockMarketGroup".to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn getExposureReuseEnabledEvents(&self) -> Result<Vec<i64>> {
- let rpc_request: RpcRequest<()> = RpcRequest::new(
- "SportsAPING/v1.0/getExposureReuseEnabledEvents".to_owned(),
- (),
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn addExposureReuseEnabledEvents(
- &self,
- eventIds: Vec<i64>,
- ) -> Result<String> {
- let req: addExposureReuseEnabledEventsRequest =
- addExposureReuseEnabledEventsRequest { eventIds };
- let rpc_request: RpcRequest<addExposureReuseEnabledEventsRequest> =
- RpcRequest::new(
- "SportsAPING/v1.0/addExposureReuseEnabledEvents".to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
- fn removeExposureReuseEnabledEvents(
- &self,
- eventIds: Vec<i64>,
- ) -> Result<String> {
- let req: removeExposureReuseEnabledEventsRequest =
- removeExposureReuseEnabledEventsRequest { eventIds };
- let rpc_request: RpcRequest<removeExposureReuseEnabledEventsRequest> =
- RpcRequest::new(
- "SportsAPING/v1.0/removeExposureReuseEnabledEvents".to_owned(),
- req,
- );
- self.req(rpc_request).map(|x| x.into_inner())
- }
-}
#[derive(Debug, Deserialize, Serialize)]
pub enum MarketProjection {
COMPETITION,
diff --git a/src/lib.rs b/src/lib.rs
index d19467e..7a22055 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -17,38 +17,21 @@
#[macro_use]
extern crate log;
+use crate::json_rpc::{RpcRequest, RpcResponse};
+use crate::result::{Error, Result};
use reqwest::{Client, Identity};
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use std::sync::{Arc, RwLock};
-// TODO this should not be public, re-export relevant parts
-pub mod generated_api;
+mod generated_methods;
+mod generated_requests;
+pub mod generated_types;
mod json_rpc;
-
-use crate::json_rpc::{RpcRequest, RpcResponse};
-
-#[derive(Debug)]
-pub enum Error {
- Io(std::io::Error),
- Reqwest(reqwest::Error),
- BFLoginFailure(String),
- General(String),
- Other,
-}
-
-pub type Result<T> = std::result::Result<T, Error>;
-
-impl From<std::io::Error> for Error {
- fn from(e: std::io::Error) -> Self {
- Error::Io(e)
- }
-}
-
-impl From<reqwest::Error> for Error {
- fn from(e: reqwest::Error) -> Self {
- Error::Reqwest(e)
- }
+pub mod result;
+pub mod prelude {
+ pub use crate::BFClient;
+ pub use crate::BFCredentials;
}
#[derive(Debug, Serialize)]
@@ -129,7 +112,7 @@ impl BFClient {
}
// TODO keepalive
- // https://identitysso.betfair.com/api/keepAliveo
+ // https://identitysso.betfair.com/api/keepAlive
// Accept (mandatory)
// Header that signals that the response should be returned as JSON application/json
// X-Authentication (mandatory)
diff --git a/src/result.rs b/src/result.rs
new file mode 100644
index 0000000..55f0f1a
--- /dev/null
+++ b/src/result.rs
@@ -0,0 +1,38 @@
+// SPDX-Copyright: Copyright (c) 2019 Daniel Edgecumbe (esotericnonsense)
+// SPDX-License-Identifier: AGPL-3.0-only
+//
+// This file is part of botfair. botfair is free software: you can
+// redistribute it and/or modify it under the terms of the GNU Affero General
+// Public License as published by the Free Software Foundation, either version
+// 3 of the License, or (at your option) any later version.
+//
+// botfair is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
+// for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with botfair. If not, see <http://www.gnu.org/licenses/>.
+
+#[derive(Debug)]
+pub enum Error {
+ Io(std::io::Error),
+ Reqwest(reqwest::Error),
+ BFLoginFailure(String),
+ General(String),
+ Other,
+}
+
+pub type Result<T> = std::result::Result<T, Error>;
+
+impl From<std::io::Error> for Error {
+ fn from(e: std::io::Error) -> Self {
+ Error::Io(e)
+ }
+}
+
+impl From<reqwest::Error> for Error {
+ fn from(e: reqwest::Error) -> Self {
+ Error::Reqwest(e)
+ }
+}