Skip to content

Commit

Permalink
Resolve merge conflicts with add_create_labels_if_missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Christina D'Astolfo authored and Christina D'Astolfo committed May 20, 2021
2 parents 8b92f2f + 8955c9e commit 2f41e41
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ monday.items.create_item(board_id='12345678', group_id='today', item_name='Do a

**Available methods:**
#### Items Resource (monday.items)
- `create_item(board_id, group_id, item_name, column_values=None)` - Create an item on a board in the given group with name item_name.
- `create_item(board_id, group_id, item_name, column_values=None, create_labels_if_missing=False)` - Create an item on a board in the given group with name item_name.

- `create_subitem(parent_item_id, subitem_name, column_values=None)` - Create a subitem underneath a given parent item. Monday API will return an error if the board you're trying to add to does not have a subitems column/at least one subitem created.
- `create_subitem(parent_item_id, subitem_name, column_values=None, create_labels_if_missing=False)` - Create a subitem underneath a given parent item. Monday API will return an error if the board you're trying to add to does not have a subitems column/at least one subitem created.

- `fetch_items_by_column_value(board_id, column_id, value)` - Fetch items on a board by column value.

Expand Down
18 changes: 12 additions & 6 deletions monday/query_joins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# Eventually I will organize this file better but you know what today is not that day.

# ITEM RESOURCE QUERIES
def mutate_item_query(board_id, group_id, item_name, column_values):
def mutate_item_query(board_id, group_id, item_name, column_values,
create_labels_if_missing):
# Monday does not allow passing through non-JSON null values here,
# so if you choose not to specify column values, need to set column_values to empty object.
column_values = column_values if column_values else {}
Expand All @@ -17,24 +18,28 @@ def mutate_item_query(board_id, group_id, item_name, column_values):
board_id: %s,
group_id: "%s",
item_name: "%s",
column_values: %s
column_values: %s,
create_labels_if_missing: %s
) {
id
}
}''' % (board_id, group_id, item_name, monday_json_stringify(column_values))
}''' % (board_id, group_id, item_name, monday_json_stringify(column_values),
str(create_labels_if_missing).lower())

return query


def mutate_subitem_query(parent_item_id, subitem_name, column_values):
def mutate_subitem_query(parent_item_id, subitem_name, column_values,
create_labels_if_missing):
column_values = column_values if column_values else {}

return '''mutation
{
create_subitem (
parent_item_id: %s,
item_name: "%s",
column_values: %s
column_values: %s,
create_labels_if_missing: %s
) {
id,
name,
Expand All @@ -47,7 +52,8 @@ def mutate_subitem_query(parent_item_id, subitem_name, column_values):
name
}
}
}''' % (parent_item_id, subitem_name, monday_json_stringify(column_values))
}''' % (parent_item_id, subitem_name, monday_json_stringify(column_values),
str(create_labels_if_missing).lower())


def get_item_query(board_id, column_id, value):
Expand Down
12 changes: 8 additions & 4 deletions monday/resources/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ class ItemResource(BaseResource):
def __init__(self, token):
super().__init__(token)

def create_item(self, board_id, group_id, item_name, column_values=None):
query = mutate_item_query(board_id, group_id, item_name, column_values)
def create_item(self, board_id, group_id, item_name, column_values=None,
create_labels_if_missing=False):
query = mutate_item_query(board_id, group_id, item_name, column_values,
create_labels_if_missing)
return self.client.execute(query)

def create_subitem(self, parent_item_id, subitem_name, column_values=None):
query = mutate_subitem_query(parent_item_id, subitem_name, column_values)
def create_subitem(self, parent_item_id, subitem_name, column_values=None,
create_labels_if_missing=False):
query = mutate_subitem_query(parent_item_id, subitem_name, column_values,
create_labels_if_missing)
return self.client.execute(query)

def fetch_items_by_column_value(self, board_id, column_id, value):
Expand Down

0 comments on commit 2f41e41

Please sign in to comment.