blocket-api 0.3.6__tar.gz → 0.3.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blocket_api
3
- Version: 0.3.6
3
+ Version: 0.3.7
4
4
  Summary: A python API wrapper for blocket.se
5
5
  Author-email: dunderrrrrr <emil.bjorkroth@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -16,7 +16,7 @@ Requires-Dist: mkdocs>=1.6.1
16
16
  Requires-Dist: mkdocs-material>=9.6.21
17
17
  Requires-Dist: mkdocs-swagger-ui-tag>=0.7.2
18
18
  Requires-Dist: websockets>=15.0.1
19
- Requires-Dist: ruff>=0.14.4
19
+ Requires-Dist: ruff>=0.14.5
20
20
  Dynamic: license-file
21
21
 
22
22
  <p align="center">
@@ -83,6 +83,7 @@ Some calls require a `bearerToken`. However, some calls are public and don't req
83
83
  | [`api.get_saved_ads()`](#get_saved_ads) | 🔐 Yes | - | List all saved ads.
84
84
  | [`api.get_threads()`](#get_threads) | 🔐 Yes | - | List all threads (messages).
85
85
  | [`api.get_messages_from_thread()`](#get_messages_from_thread) | 🔐 Yes | - | Get all messages from a thread.
86
+ | [`api.unread_messages_count()`](#unread_messages_count) | 🔐 Yes | Yes | Get the total count of unread messages.
86
87
 
87
88
 
88
89
  ## 🤓 Detailed usage
@@ -422,6 +423,17 @@ Returns all of your messages from an existing thread/conversation.
422
423
  }
423
424
  ```
424
425
 
426
+ ### unread_messages_count
427
+ Returns the count of unread messages.
428
+
429
+ ```py
430
+ >>> api = BlocketAPI("YourBlocketTokenHere")
431
+ >>> api.unread_messages_count()
432
+ {
433
+ "unread_count": 5
434
+ }
435
+ ```
436
+
425
437
 
426
438
 
427
439
  ## 🔐 Blocket API token
@@ -62,6 +62,7 @@ Some calls require a `bearerToken`. However, some calls are public and don't req
62
62
  | [`api.get_saved_ads()`](#get_saved_ads) | 🔐 Yes | - | List all saved ads.
63
63
  | [`api.get_threads()`](#get_threads) | 🔐 Yes | - | List all threads (messages).
64
64
  | [`api.get_messages_from_thread()`](#get_messages_from_thread) | 🔐 Yes | - | Get all messages from a thread.
65
+ | [`api.unread_messages_count()`](#unread_messages_count) | 🔐 Yes | Yes | Get the total count of unread messages.
65
66
 
66
67
 
67
68
  ## 🤓 Detailed usage
@@ -401,6 +402,17 @@ Returns all of your messages from an existing thread/conversation.
401
402
  }
402
403
  ```
403
404
 
405
+ ### unread_messages_count
406
+ Returns the count of unread messages.
407
+
408
+ ```py
409
+ >>> api = BlocketAPI("YourBlocketTokenHere")
410
+ >>> api.unread_messages_count()
411
+ {
412
+ "unread_count": 5
413
+ }
414
+ ```
415
+
404
416
 
405
417
 
406
418
  ## 🔐 Blocket API token
@@ -17,6 +17,7 @@ from blocket_api.models import (
17
17
  SavedSearchResponse,
18
18
  StoreListings,
19
19
  StoreSearchResults,
20
+ UnreadMessagesCount,
20
21
  )
21
22
  from blocket_api.qasa import HOME_SEARCH_ORDERING, HomeType, OrderBy, Qasa
22
23
 
@@ -609,3 +610,22 @@ class BlocketAPI:
609
610
  assert self.token
610
611
  sendbird = Sendbird.generate(self.token)
611
612
  return sendbird.get_messages_from_thread(channel_id)
613
+
614
+ @overload
615
+ def unread_messages_count(
616
+ self, *, as_objects: Literal[True]
617
+ ) -> UnreadMessagesCount: ...
618
+
619
+ @overload
620
+ def unread_messages_count(self, *, as_objects: Literal[False] = False) -> dict: ...
621
+
622
+ @auth_token
623
+ def unread_messages_count(
624
+ self, as_objects: bool = False
625
+ ) -> dict | UnreadMessagesCount:
626
+ """
627
+ Returns the total count of unread messages.
628
+ """
629
+ assert self.token
630
+ response = Sendbird.generate(self.token).unread_messages_count()
631
+ return UnreadMessagesCount.model_validate(response) if as_objects else response
@@ -612,3 +612,10 @@ class SavedSearch(_BaseModel):
612
612
 
613
613
  class SavedSearchResponse(_BaseModel):
614
614
  searches: list[SavedSearch]
615
+
616
+
617
+ ## UnreadMessagesCount ##
618
+
619
+
620
+ class UnreadMessagesCount(_BaseModel):
621
+ unread_count: int
@@ -175,3 +175,16 @@ class Sendbird:
175
175
  )
176
176
  response.raise_for_status()
177
177
  return response.json()
178
+
179
+ def unread_messages_count(self) -> dict:
180
+ sendbird = SendbirdResponse.model_validate_json(self.sendbird_client.get_data())
181
+ response = httpx.get(
182
+ f"{SENDBIRD_URL}/v3/users/{self.sendbird_client.user_id}/unread_message_count",
183
+ params={"super_mode": "all", "include_feed_channel": False},
184
+ headers={
185
+ "Session-Key": sendbird.session_key,
186
+ "Access-Token": self.sendbird_client.access_token,
187
+ },
188
+ )
189
+ response.raise_for_status()
190
+ return response.json()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blocket_api
3
- Version: 0.3.6
3
+ Version: 0.3.7
4
4
  Summary: A python API wrapper for blocket.se
5
5
  Author-email: dunderrrrrr <emil.bjorkroth@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -16,7 +16,7 @@ Requires-Dist: mkdocs>=1.6.1
16
16
  Requires-Dist: mkdocs-material>=9.6.21
17
17
  Requires-Dist: mkdocs-swagger-ui-tag>=0.7.2
18
18
  Requires-Dist: websockets>=15.0.1
19
- Requires-Dist: ruff>=0.14.4
19
+ Requires-Dist: ruff>=0.14.5
20
20
  Dynamic: license-file
21
21
 
22
22
  <p align="center">
@@ -83,6 +83,7 @@ Some calls require a `bearerToken`. However, some calls are public and don't req
83
83
  | [`api.get_saved_ads()`](#get_saved_ads) | 🔐 Yes | - | List all saved ads.
84
84
  | [`api.get_threads()`](#get_threads) | 🔐 Yes | - | List all threads (messages).
85
85
  | [`api.get_messages_from_thread()`](#get_messages_from_thread) | 🔐 Yes | - | Get all messages from a thread.
86
+ | [`api.unread_messages_count()`](#unread_messages_count) | 🔐 Yes | Yes | Get the total count of unread messages.
86
87
 
87
88
 
88
89
  ## 🤓 Detailed usage
@@ -422,6 +423,17 @@ Returns all of your messages from an existing thread/conversation.
422
423
  }
423
424
  ```
424
425
 
426
+ ### unread_messages_count
427
+ Returns the count of unread messages.
428
+
429
+ ```py
430
+ >>> api = BlocketAPI("YourBlocketTokenHere")
431
+ >>> api.unread_messages_count()
432
+ {
433
+ "unread_count": 5
434
+ }
435
+ ```
436
+
425
437
 
426
438
 
427
439
  ## 🔐 Blocket API token
@@ -8,4 +8,4 @@ mkdocs>=1.6.1
8
8
  mkdocs-material>=9.6.21
9
9
  mkdocs-swagger-ui-tag>=0.7.2
10
10
  websockets>=15.0.1
11
- ruff>=0.14.4
11
+ ruff>=0.14.5
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "blocket_api"
3
- version = "0.3.6"
3
+ version = "0.3.7"
4
4
  description = "A python API wrapper for blocket.se"
5
5
  authors = [{name = "dunderrrrrr", email = "emil.bjorkroth@gmail.com"}]
6
6
  readme = "README.md"
@@ -16,7 +16,7 @@ dependencies = [
16
16
  "mkdocs-material>=9.6.21",
17
17
  "mkdocs-swagger-ui-tag>=0.7.2",
18
18
  "websockets>=15.0.1",
19
- "ruff>=0.14.4",
19
+ "ruff>=0.14.5",
20
20
  ]
21
21
 
22
22
 
File without changes
File without changes