@managebetcodes/sdk 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +30 -5
- package/dist/client.js +33 -5
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
export declare const VERSION = "1.0.
|
|
1
|
+
export declare const VERSION = "1.0.2";
|
|
2
2
|
export declare const BASE_URL = "https://api.managebetcodes.app/v1";
|
|
3
|
-
export type QueryValue = string | number | boolean | null | undefined;
|
|
3
|
+
export type QueryValue = string | number | boolean | string[] | null | undefined;
|
|
4
4
|
export type Query = Record<string, QueryValue>;
|
|
5
|
+
export interface EventMarketsQuery extends Query {
|
|
6
|
+
bookmaker?: string;
|
|
7
|
+
view?: "canonical" | "all";
|
|
8
|
+
market?: string | string[];
|
|
9
|
+
q?: string;
|
|
10
|
+
names_only?: boolean;
|
|
11
|
+
}
|
|
5
12
|
export type APIResponse = Record<string, any>;
|
|
6
13
|
export interface ClientOptions {
|
|
7
14
|
baseUrl?: string;
|
|
@@ -18,12 +25,25 @@ export declare class Client {
|
|
|
18
25
|
private readonly maxRetries;
|
|
19
26
|
constructor(apiKey: string, options?: ClientOptions);
|
|
20
27
|
convert(code: string, source: string, target: string | string[], options?: RequestOptions): Promise<APIResponse>;
|
|
28
|
+
convertToAll(code: string, source: string, options?: RequestOptions & {
|
|
29
|
+
to?: string | string[];
|
|
30
|
+
includeCard?: boolean;
|
|
31
|
+
}): Promise<APIResponse>;
|
|
32
|
+
convertBulk(codes: Array<{
|
|
33
|
+
code: string;
|
|
34
|
+
from: string;
|
|
35
|
+
}>, options?: RequestOptions & {
|
|
36
|
+
to?: string | string[];
|
|
37
|
+
includeCard?: boolean;
|
|
38
|
+
}): Promise<APIResponse>;
|
|
21
39
|
view(code: string, bookmaker: string): Promise<APIResponse>;
|
|
22
40
|
viewImage(code: string, bookmaker: string): Promise<Uint8Array>;
|
|
23
41
|
split(code: string, bookmaker: string, options?: RequestOptions & {
|
|
24
42
|
count?: number;
|
|
25
|
-
pattern?: "alternate" | "blocks";
|
|
26
|
-
order?: "slip" | "kickoff";
|
|
43
|
+
pattern?: "equal" | "by_batches" | "target_odds" | "custom" | "alternate" | "blocks";
|
|
44
|
+
order?: "mixed" | "by_start_time" | "slip" | "kickoff";
|
|
45
|
+
targetOdds?: number;
|
|
46
|
+
counts?: number[];
|
|
27
47
|
}): Promise<APIResponse>;
|
|
28
48
|
merge(pairs: Array<Record<string, string>>, options?: RequestOptions & {
|
|
29
49
|
target?: string;
|
|
@@ -43,7 +63,12 @@ export declare class Client {
|
|
|
43
63
|
detail?: "compact" | "full" | "agent";
|
|
44
64
|
}): Promise<APIResponse>;
|
|
45
65
|
events(query?: Query): Promise<APIResponse>;
|
|
46
|
-
|
|
66
|
+
/**
|
|
67
|
+
* List the markets of one event. Pass `market` as a string or an array;
|
|
68
|
+
* an array sends one `market=` parameter for each name, so one call reads
|
|
69
|
+
* several markets and the response lists absent names in `not_found`.
|
|
70
|
+
*/
|
|
71
|
+
eventMarkets(eventId: string, query?: EventMarketsQuery): Promise<APIResponse>;
|
|
47
72
|
resolve(bookmaker: string, picks: Array<Record<string, unknown>>, options?: RequestOptions & {
|
|
48
73
|
strict?: boolean;
|
|
49
74
|
acceptOddsChange?: boolean;
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { APIError, errorFromResponse } from "./errors.js";
|
|
3
|
-
export const VERSION = "1.0.
|
|
3
|
+
export const VERSION = "1.0.2";
|
|
4
4
|
export const BASE_URL = "https://api.managebetcodes.app/v1";
|
|
5
5
|
const RETRY_STATUSES = new Set([429, 502, 503, 504]);
|
|
6
6
|
const NON_RETRYABLE_CODES = new Set([
|
|
@@ -53,6 +53,21 @@ export class Client {
|
|
|
53
53
|
convert(code, source, target, options = {}) {
|
|
54
54
|
return this.post("/convert", { code, from: source, to: target }, options.idempotencyKey);
|
|
55
55
|
}
|
|
56
|
+
convertToAll(code, source, options = {}) {
|
|
57
|
+
return this.post("/convert/all", compact({
|
|
58
|
+
code,
|
|
59
|
+
from: source,
|
|
60
|
+
to: options.to,
|
|
61
|
+
include_card: options.includeCard,
|
|
62
|
+
}), options.idempotencyKey);
|
|
63
|
+
}
|
|
64
|
+
convertBulk(codes, options = {}) {
|
|
65
|
+
return this.post("/convert/bulk", compact({
|
|
66
|
+
codes,
|
|
67
|
+
to: options.to,
|
|
68
|
+
include_card: options.includeCard,
|
|
69
|
+
}), options.idempotencyKey);
|
|
70
|
+
}
|
|
56
71
|
view(code, bookmaker) {
|
|
57
72
|
return this.get("/view", { code, bookmaker });
|
|
58
73
|
}
|
|
@@ -64,13 +79,15 @@ export class Client {
|
|
|
64
79
|
return new Uint8Array(await response.arrayBuffer());
|
|
65
80
|
}
|
|
66
81
|
split(code, bookmaker, options = {}) {
|
|
67
|
-
return this.post("/split", {
|
|
82
|
+
return this.post("/split", compact({
|
|
68
83
|
code,
|
|
69
84
|
bookmaker,
|
|
70
85
|
count: options.count ?? 2,
|
|
71
|
-
pattern: options.pattern ?? "
|
|
72
|
-
order: options.order ?? "
|
|
73
|
-
|
|
86
|
+
pattern: options.pattern ?? "equal",
|
|
87
|
+
order: options.order ?? "mixed",
|
|
88
|
+
target_odds: options.targetOdds,
|
|
89
|
+
counts: options.counts,
|
|
90
|
+
}), options.idempotencyKey);
|
|
74
91
|
}
|
|
75
92
|
merge(pairs, options = {}) {
|
|
76
93
|
return this.post("/merge", compact({ pairs, target: options.target }), options.idempotencyKey);
|
|
@@ -99,6 +116,11 @@ export class Client {
|
|
|
99
116
|
events(query = {}) {
|
|
100
117
|
return this.get("/events", query);
|
|
101
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* List the markets of one event. Pass `market` as a string or an array;
|
|
121
|
+
* an array sends one `market=` parameter for each name, so one call reads
|
|
122
|
+
* several markets and the response lists absent names in `not_found`.
|
|
123
|
+
*/
|
|
102
124
|
eventMarkets(eventId, query = {}) {
|
|
103
125
|
return this.get(`/events/${encodeURIComponent(eventId)}/markets`, query);
|
|
104
126
|
}
|
|
@@ -211,6 +233,12 @@ export class Client {
|
|
|
211
233
|
if (value === undefined || value === null || value === "") {
|
|
212
234
|
continue;
|
|
213
235
|
}
|
|
236
|
+
if (Array.isArray(value)) {
|
|
237
|
+
for (const item of value) {
|
|
238
|
+
url.searchParams.append(key, String(item));
|
|
239
|
+
}
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
214
242
|
url.searchParams.set(key, String(value));
|
|
215
243
|
}
|
|
216
244
|
const headers = {
|