0

Get FaPiao Object ID (Matteroom)

by
Published Jan 7, 2026

Get FaPiao Object ID (Matteroom)

Script matteroom Verified

The script

Submitted by dev626 Bun
Verified 154 days ago
1
// native
2
type Matteroom = {
3
  base_url: string;
4
  username: string;
5
  password: string;
6
};
7

8
/**
9
 * Search Fapiao
10
 * Retrieves fapiao information from Matteroom
11
 */
12
export async function main(
13
  auth: Matteroom,
14
  start: number = 0,
15
  size: number = 100,
16
  status: number = 6,
17
) {
18
  const url = new URL(`${auth.base_url}/api/v3/search/`);
19

20
  // Basic Auth: username:password -> Base64
21
  const token = btoa(`${auth.username}:${auth.password}`);
22

23
  const headers: Record<string, string> = {
24
    Authorization: `Basic ${token}`,
25
    "Content-Type": "application/json",
26
  };
27

28
  const body = {
29
    object_type: "fapiao",
30
    start,
31
    size,
32
    order_by: "-created_on",
33
    q: `status:(${status})`,
34
    result_type: "2",
35
    fl: "obj_id",
36
  };
37

38
  const response = await fetch(url.toString(), {
39
    method: "POST",
40
    headers,
41
    body: JSON.stringify(body),
42
  });
43

44
  if (!response.ok) {
45
    const text = await response.text();
46
    throw new Error(`${response.status} ${text}`);
47
  }
48

49
  return await response.json();
50
}