Commit 83aa5aaa authored by Chunchi Che's avatar Chunchi Che

add mycard match api

parent 0676365d
Pipeline #22772 passed with stages
in 14 minutes and 5 seconds
export * from "./cards";
export * from "./deck";
export * from "./mycard";
export * from "./ocgcore/idl/ocgcore";
export * from "./ocgcore/ocgHelper";
export * from "./strings";
// Collection of APIs provided by MyCard
export * from "./match";
import axios from "axios";
const API_URL = "https://sapi.moecube.com:444/ygopro/match";
interface MatchInfo {
ip: string;
port: number;
password: string;
}
export async function match(
userName: string,
extraId: number,
arena: string = "entertain"
): Promise<MatchInfo | undefined> {
const headers = { Authorization: "Basic " + btoa(userName + ":" + extraId) };
const response = await axios
.post(API_URL, undefined, {
headers: headers,
params: {
arena,
// TODO: locale?
},
})
.catch((error) => {
console.error(`match error: ${error}`);
return undefined;
});
return response ? JSON.parse(response.data) : undefined;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment