<!-- Source: https://docs.squirro.com/en/latest/api/squirro_client.topic.CommunitySubscriptionsMixin.html -->
# CommunitySubscriptionsMixin

**`class CommunitySubscriptionsMixin`**

Bases: [`object`](https://docs.python.org/3.11/library/functions.html#object)

Methods SummaryMethods Documentation

**`delete_community_subscription(project_id, subscription_id)`**

Deletes a community subscription

Parameters

- `project_id` – Project Identifier
- `subscription_id` – Community subscription Identifier

Example:

```
>>> client.delete_community_subscription(
    'Xh9CeyQtTYe2cv5F11e6nQ',
    'mNDkc6q9QvuL8EVMWA3cgg')
{}
```

**`get_community_subscriptions(project_id, include_count_of_items=False, query=None, start=None, count=-1, query_context=None)`**

Returns all community subscriptions for a project and a user.

Parameters

- `project_id` – Project Identifier
- `include_count_of_items` – Boolean argument to include the count of
  items belonging to the subscribed communities of the user.
  Defaults to False.
- `query` ([`Optional`](https://docs.python.org/3.11/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3.11/library/stdtypes.html#str)]) – Query to filter community subscriptions.
- `start` – Integer. Used for pagination of objects. If set, the
  objects starting with offset start are returned. Defaults to None.
- `count` – Integer. Used for pagination of objects. If set, count
  number of communities are returned. To return all communities, set
  to -1. Defaults to -1.
- `query_context` ([`Optional`](https://docs.python.org/3.11/library/typing.html#typing.Optional)[[`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)[[`str`](https://docs.python.org/3.11/library/stdtypes.html#str), [`Any`](https://docs.python.org/3.11/library/typing.html#typing.Any)]]) – 

  Dictionary with more context of the user’s input / intent:
  - searchbar_query : Terms that user typed in a searchbar.
  - dashboard_filters : Additional filter-queries provided via dashboard or widget configuration.
  - community_query : Selected community in the Community 360 dashboard.
  - like : Additional input to perform approximate search on.

  > For now like is considered to be a long string (e.g. paragraphs)

  - parsed : The parsed, analysed and enriched representation of the searchbar_query (response of the configured [query-processing workflow](https://go.squirro.com/libnlp-query-processing))

Example:

```
>>> client.get_community_subscriptions('Xh9CeyQtTYe2cv5F11e6nQ')
[
    {
    "id": "D0nEBlUmTLqxq6lwZj4rTw",
    "user_id": "-XNqd1bARxuA0L1jh3OeeQ",
    "community_id": "OSACPQKbRz2dadBM4nSseA",
    "created_at": "2020-09-14T09:12:21"
    },
    {
    "id": "QmykmwR3Tb6ZEHI6DJQzUg",
    "user_id": "-XNqd1bARxuA0L1jh3OeeQ",
    "community_id": "mNDkc6q9QvuL8EVMWA3cgg",
    "created_at": "2020-09-14T09:17:15"
    }

]
```

TODO: allow for specifying user id

**`new_community_subscriptions(project_id, community_ids, remove_existing_subscriptions=False, user_id=None, include_count_of_items=False)`**

Creates a new community subscription for a project
given the community_id

Parameters

- `project_id` – Project Identifier
- `community_ids` – Ids of the communities to subscribe to
- `remove_existing_subscriptions` – Boolean flag to remove existing subscriptions
- `user_id` – Id of the user subscribing to the community ids
- `include_count_of_items` – Boolean flag to add total count of items for a community subscription

Example:

```
>>> client.new_community_subscription(
        'Xh9CeyQtTYe2cv5F11e6nQ',
        ['mNDkc6q9QvuL8EVMWA3cgg','otCTwaF9Qs-66MFGLCtyKQ']
        remove_existing_subscriptions = True
    )
{
    "id": "QmykmwR3Tb6ZEHI6DJQzUg",
    "user_id": "-XNqd1bARxuA0L1jh3OeeQ",
    "community_id": "mNDkc6q9QvuL8EVMWA3cgg",
    "created_at": "2020-09-14T09:17:15"
}
```
