|
1 | 1 | package notionapi
|
2 | 2 |
|
3 |
| -import "time" |
4 |
| - |
5 | 3 | type FilterOperator string
|
6 | 4 |
|
7 |
| -type Filter interface{} |
8 |
| - |
9 |
| -type CompoundFilter map[FilterOperator]Filter |
| 5 | +type CompoundFilter map[FilterOperator][]PropertyFilter |
10 | 6 |
|
11 | 7 | type Condition string
|
12 | 8 |
|
13 | 9 | type PropertyFilter struct {
|
14 |
| - Property PropertyType `json:"property"` |
15 |
| - Text map[Condition]string `json:"text,omitempty"` |
16 |
| - Number map[Condition]float64 `json:"number,omitempty"` |
17 |
| - Checkbox map[Condition]bool `json:"checkbox,omitempty"` |
18 |
| - Select map[Condition]interface{} `json:"select,omitempty"` |
19 |
| - MultiSelect map[Condition]interface{} `json:"multi_select,omitempty"` |
20 |
| - Date map[Condition]time.Time `json:"date,omitempty"` |
21 |
| - People map[Condition]interface{} `json:"people,omitempty"` |
22 |
| - Files map[Condition]bool `json:"files,omitempty"` |
23 |
| - Relation map[Condition]interface{} `json:"relation,omitempty"` |
24 |
| - Formula map[PropertyType]PropertyFilter `json:"formula,omitempty"` |
| 10 | + Property string `json:"property"` |
| 11 | + Text *TextFilterCondition `json:"text,omitempty"` |
| 12 | + Number *NumberFilterCondition `json:"number,omitempty"` |
| 13 | + Checkbox *CheckboxFilterCondition `json:"checkbox,omitempty"` |
| 14 | + Select *SelectFilterCondition `json:"select,omitempty"` |
| 15 | + MultiSelect *MultiSelectFilterCondition `json:"multi_select,omitempty"` |
| 16 | + Date *DateFilterCondition `json:"date,omitempty"` |
| 17 | + People *PeopleFilterCondition `json:"people,omitempty"` |
| 18 | + Files *FilesFilterCondition `json:"files,omitempty"` |
| 19 | + Relation *RelationFilterCondition `json:"relation,omitempty"` |
| 20 | + Formula *FormulaFilterCondition `json:"formula,omitempty"` |
| 21 | +} |
| 22 | + |
| 23 | +type TextFilterCondition struct { |
| 24 | + Equals string `json:"equals,omitempty"` |
| 25 | + DoesNotEqual string `json:"does_not_equal,omitempty"` |
| 26 | + Contains string `json:"contains,omitempty"` |
| 27 | + DoesNotContain string `json:"does_not_contain,omitempty"` |
| 28 | + StartsWith string `json:"starts_with,omitempty"` |
| 29 | + EndsWith string `json:"ends_with,omitempty"` |
| 30 | + IsEmpty bool `json:"is_empty,omitempty"` |
| 31 | + IsNotEmpty bool `json:"is_not_empty,omitempty"` |
| 32 | +} |
| 33 | + |
| 34 | +type NumberFilterCondition struct { |
| 35 | + Equals float64 `json:"equals,omitempty"` |
| 36 | + DoesNotEqual float64 `json:"does_not_equal,omitempty"` |
| 37 | + GreaterThan float64 `json:"greater_than,omitempty"` |
| 38 | + LessThan float64 `json:"less_than,omitempty"` |
| 39 | + GreaterThanOrEqualTo float64 `json:"greater_than_or_equal_to"` |
| 40 | + LessThanOrEqualTo float64 `json:"less_than_or_equal_to"` |
| 41 | + IsEmpty bool `json:"is_empty,omitempty"` |
| 42 | + IsNotEmpty bool `json:"is_not_empty,omitempty"` |
| 43 | +} |
| 44 | + |
| 45 | +type CheckboxFilterCondition struct { |
| 46 | + Equals bool `json:"equals,omitempty"` |
| 47 | + DoesNotEqual bool `json:"does_not_equal,omitempty"` |
| 48 | +} |
| 49 | + |
| 50 | +type SelectFilterCondition struct { |
| 51 | + Equals string `json:"equals,omitempty"` |
| 52 | + DoesNotEqual string `json:"does_not_equal,omitempty"` |
| 53 | + IsEmpty bool `json:"is_empty,omitempty"` |
| 54 | + IsNotEmpty bool `json:"is_not_empty,omitempty"` |
| 55 | +} |
| 56 | + |
| 57 | +type MultiSelectFilterCondition struct { |
| 58 | + Contains string `json:"contains,omitempty"` |
| 59 | + DoesNotContain string `json:"does_not_contain,omitempty"` |
| 60 | + IsEmpty bool `json:"is_empty,omitempty"` |
| 61 | + IsNotEmpty bool `json:"is_not_empty,omitempty"` |
| 62 | +} |
| 63 | + |
| 64 | +type DateFilterCondition struct { |
| 65 | + Equals *Date `json:"equals,omitempty"` |
| 66 | + Before *Date `json:"before,omitempty"` |
| 67 | + After *Date `json:"after,omitempty"` |
| 68 | + OnOrBefore *Date `json:"on_or_before,omitempty"` |
| 69 | + OnOrAfter *Date `json:"on_or_after,omitempty"` |
| 70 | + PastWeek *struct{} `json:"past_week,omitempty"` |
| 71 | + PastMonth *struct{} `json:"past_month,omitempty"` |
| 72 | + PastYear *struct{} `json:"past_year,omitempty"` |
| 73 | + NextWeek *struct{} `json:"next_week,omitempty"` |
| 74 | + NextMonth *struct{} `json:"next_month,omitempty"` |
| 75 | + NextYear *struct{} `json:"next_year,omitempty"` |
| 76 | + IsEmpty bool `json:"is_empty,omitempty"` |
| 77 | + IsNotEmpty bool `json:"is_not_empty,omitempty"` |
| 78 | +} |
| 79 | + |
| 80 | +type PeopleFilterCondition struct { |
| 81 | + Contains string `json:"contains,omitempty"` |
| 82 | + DoesNotContain string `json:"does_not_contain,omitempty"` |
| 83 | + IsEmpty bool `json:"is_empty,omitempty"` |
| 84 | + IsNotEmpty bool `json:"is_not_empty,omitempty"` |
| 85 | +} |
| 86 | + |
| 87 | +type FilesFilterCondition struct { |
| 88 | + IsEmpty bool `json:"is_empty,omitempty"` |
| 89 | + IsNotEmpty bool `json:"is_not_empty,omitempty"` |
| 90 | +} |
| 91 | + |
| 92 | +type RelationFilterCondition struct { |
| 93 | + Contains string `json:"contains,omitempty"` |
| 94 | + DoesNotContain string `json:"does_not_contain,omitempty"` |
| 95 | + IsEmpty bool `json:"is_empty,omitempty"` |
| 96 | + IsNotEmpty bool `json:"is_not_empty,omitempty"` |
| 97 | +} |
| 98 | + |
| 99 | +type FormulaFilterCondition struct { |
| 100 | + Text *TextFilterCondition `json:"text,omitempty"` |
| 101 | + Checkbox *CheckboxFilterCondition `json:"checkbox,omitempty"` |
| 102 | + Number *NumberFilterCondition `json:"number,omitempty"` |
| 103 | + Date *DateFilterCondition `json:"date,omitempty"` |
25 | 104 | }
|
0 commit comments