-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnotion_property.py
91 lines (89 loc) · 2.48 KB
/
notion_property.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# 用于notion property的自定义
# 如果自己想改就可以在这里修改
# 需要保证与Notion Database中的property一致
def notion_property(content, price, category, date, counterparty, remarks,
transaction_number="",
merchant_tracking_number="",
payment_method="undefined"):
"""将输入的内容转换为notion的json格式
Args:
content (str): 商品名称
price (float): 价格
category (str): 交易分类
date (str): 交易时间
Counterparty (str): 交易对方
remarks (str): 备注
transaction_number (str, optional): 交易订单号. Defaults to ""
merchant_tracking_number (str, optional): 商家订单号. Defaults to ""
payment_method (str, optional): 支付方式. Defaults to ""
Returns:
properties: 返回notion的json格式
"""
properties = {
"Name": {
"title": [
{
"text": {
"content": content
}
}
]
},
"Price": {
"number": price
},
"Category": {
"select": {
"name": category
}
},
"Date": {
"date": {
"start": date,
"time_zone": "Asia/Shanghai" # 时区, 参见官方文档
}
},
"From": {
"select": {
"name": "Alipay"
}
},
"Counterparty": {
"rich_text": [
{
"text": {
"content": counterparty
}
}]
},
"Remarks": {
"rich_text": [
{
"text": {
"content": remarks
}
}]
},
"Transaction Number": {
"rich_text": [
{
"text": {
"content": transaction_number
}
}]
},
"Merchant Tracking Number": {
"rich_text": [
{
"text": {
"content": merchant_tracking_number
}
}]
},
"Payment Method": {
"select": {
"name": payment_method
}
},
}
return properties