Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding A Formatting Option #134

Closed
ghost opened this issue Jun 9, 2022 · 2 comments
Closed

Adding A Formatting Option #134

ghost opened this issue Jun 9, 2022 · 2 comments

Comments

@ghost
Copy link

ghost commented Jun 9, 2022

I would like to add a formatter that will automatically create the dictionaries in their correct format based on the property. I think this will help make the code just more readable since without it there are just extremely large dictionaries and a whole bunch of curly braces. I personally use this formatter for my own scripts that I use to automate some things on Notion.

For example:

Before using a formatter:

create_details = {
    "parent": DB_ID,
    "properties": {
        "some date property": {
            "date": {
                "start": "starting date",
                "end": "ending date",
            }
        },
        "some multi select property": {
            "multi_select": [
                {
                    "name": "option name"
                },
                {
                    "name": "option name",
                    "color": "option color"
                }
            ]
        },
        "some select property": {
            "select": {
                "option": "option name",
                "color": "option color"
            }
        }
    }
}

After using a formatter:

# this is needed because `formatter.multi_select` takes a dictionary
# as the input
multi_select_options = {
    "option one": "default",
    "option two": "color"
}
# the same dictionary, but using the formatter
create_details = {
    "parent": DB_ID,
    "properties": {
        "some date property": formatter.date("start date", "end date"),
        "some multi select property": formatter.multi_select(multi_select_options),
        "some select property": formatter.select("option name", "option color")
    }
}
@ramnes
Copy link
Owner

ramnes commented Jun 9, 2022

Hi @VisakhChekur!

At the moment I'm not interested in diverging from the official Notion SDK (and API), so this will not make it into the tree.

That being said, feel free to share your formatter as a gist or repository and advertise it here! I'm sure it can help some people.

@ramnes ramnes closed this as completed Jun 9, 2022
@ghost
Copy link
Author

ghost commented Jun 10, 2022

@ramnes That's completely fine :) Thank you for considering this though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant