docs: update query input and output type (#4509)
This commit is contained in:
+61
-45
@@ -6,53 +6,69 @@ Here's an example function on how you might perform the query:
|
||||
|
||||
```ts
|
||||
export async function fetchInAppWalletMetadataFromThirdweb(
|
||||
args:
|
||||
| {
|
||||
queryBy: "walletAddress";
|
||||
walletAddress: string;
|
||||
}
|
||||
| {
|
||||
queryBy: "email";
|
||||
email: string;
|
||||
}
|
||||
| {
|
||||
queryBy: "phone";
|
||||
phone: string;
|
||||
}
|
||||
| {
|
||||
queryBy: "phone";
|
||||
phone: string;
|
||||
},
|
||||
args:
|
||||
| {
|
||||
queryBy: "walletAddress";
|
||||
walletAddress: string;
|
||||
}
|
||||
| {
|
||||
queryBy: "email";
|
||||
email: string;
|
||||
}
|
||||
| {
|
||||
queryBy: "phone";
|
||||
phone: string;
|
||||
}
|
||||
| {
|
||||
queryBy: "phone";
|
||||
phone: string;
|
||||
}
|
||||
| {
|
||||
queryBy: "id";
|
||||
id: string;
|
||||
},
|
||||
) {
|
||||
const url = new URL(
|
||||
"https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details",
|
||||
);
|
||||
if (args.queryBy === "walletAddress") {
|
||||
url.searchParams.set("queryBy", "walletAddress");
|
||||
url.searchParams.set("walletAddress", args.walletAddress);
|
||||
}
|
||||
if (args.queryBy === "email") {
|
||||
url.searchParams.set("queryBy", "email");
|
||||
url.searchParams.set("email", args.email);
|
||||
}
|
||||
if (args.queryBy === "phone") {
|
||||
url.searchParams.set("queryBy", "phone");
|
||||
url.searchParams.set("phone", args.phone);
|
||||
}
|
||||
const url = new URL(
|
||||
"https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details",
|
||||
);
|
||||
if (args.queryBy === "walletAddress") {
|
||||
url.searchParams.set("queryBy", "walletAddress");
|
||||
url.searchParams.set("walletAddress", args.walletAddress);
|
||||
}
|
||||
if (args.queryBy === "email") {
|
||||
url.searchParams.set("queryBy", "email");
|
||||
url.searchParams.set("email", args.email);
|
||||
}
|
||||
if (args.queryBy === "phone") {
|
||||
url.searchParams.set("queryBy", "phone");
|
||||
url.searchParams.set("phone", args.phone);
|
||||
}
|
||||
if (args.queryBy === "id") {
|
||||
url.searchParams.set("queryBy", "id");
|
||||
url.searchParams.set("id", args.phone);
|
||||
}
|
||||
|
||||
const resp = await fetchReq(url.href, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${THIRD_WEB_CLIENT_SECRET}`,
|
||||
},
|
||||
});
|
||||
const resp = await fetchReq(url.href, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${THIRD_WEB_CLIENT_SECRET}`,
|
||||
},
|
||||
});
|
||||
|
||||
const data = (await resp.json()) as {
|
||||
userId: string;
|
||||
walletAddress: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
createdAt: string;
|
||||
}[];
|
||||
return data;
|
||||
const data = (await resp.json()) as {
|
||||
userId: string;
|
||||
walletAddress: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
createdAt: string;
|
||||
linkedAccounts: {
|
||||
type: string;
|
||||
details:
|
||||
| { phone: string, [key: string]: string; }
|
||||
| { email: string, [key: string]: string; }
|
||||
| { address: string, [key: string]: string; };
|
||||
| { id: string, [key: string]: string; };
|
||||
}[];
|
||||
}[];
|
||||
return data;
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user