103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/notion_api/notion_types/collection_view_blocks.rb', line 103
def add_property(name, type)
cookies = Core.options["cookies"]
= Core.options["headers"]
request_id = (SecureRandom.hex(16))
transaction_id = (SecureRandom.hex(16))
space_id = (SecureRandom.hex(16))
request_ids = {
request_id: request_id,
transaction_id: transaction_id,
space_id: space_id,
}
schema = (@collection_id, @view_id)
schema[name] = {
name: name,
type: type,
}
new_schema = {
schema: schema,
}
add_collection_property = Utils::CollectionViewComponents.add_collection_property(@collection_id, new_schema)
operations = [
add_collection_property,
]
request_url = URLS[:UPDATE_BLOCK]
request_body = build_payload(operations, request_ids)
response = HTTParty.post(
request_url,
body: request_body.to_json,
cookies: cookies,
headers: ,
)
unless response.code == 200; raise "There was an issue completing your request. Here is the response from Notion: #{response.body}, and here is the payload that was sent: #{operations}.
Please try again, and if issues persist open an issue in GitHub."; end
true
end
|