rb-commons 0.7.8__py3-none-any.whl → 0.7.10__py3-none-any.whl

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.
rb_commons/orm/enum.py CHANGED
@@ -4,4 +4,10 @@ class OriginType(str, Enum):
4
4
  MANUAL = "MANUAL"
5
5
  ETL = "ETL"
6
6
  API = "API"
7
- DEFAULT = "DEFAULT"
7
+ DEFAULT = "DEFAULT"
8
+
9
+ class MediaSource(str, Enum):
10
+ ROBO = "ROBO"
11
+ BILLZ = "BILLZ"
12
+ BITO = "BITO"
13
+ EUROPHARM = "EUROPHARM"
rb_commons/utils/media.py CHANGED
@@ -1,9 +1,17 @@
1
+ from typing import Optional
2
+
1
3
  from pydantic import ValidationError
4
+ from rb_commons.orm.enum import MediaSource
5
+
2
6
 
3
7
  class MediaUtils:
8
+ BILLZ_S3_ENDPOINT_URL = "https://cdn-grocery.billz.ai/billz"
9
+ BITTO_S3_ENDPOINT_URL = "https://api.bito.uz/upload-api/public/uploads"
10
+
11
+ @classmethod
12
+ def url_builder(cls, key: str, source: Optional[MediaSource] = MediaSource.ROBO):
13
+ source = MediaSource.ROBO if source is None else source
4
14
 
5
- @staticmethod
6
- def url_builder(key: str):
7
15
  try:
8
16
  from rb_commons.configs.config import configs
9
17
  DIGITALOCEAN_S3_ENDPOINT_URL = configs.DIGITALOCEAN_S3_ENDPOINT_URL
@@ -13,6 +21,11 @@ class MediaUtils:
13
21
  DIGITALOCEAN_S3_ENDPOINT_URL = configs.DIGITALOCEAN_S3_ENDPOINT_URL
14
22
  DIGITALOCEAN_STORAGE_BUCKET_NAME = configs.DIGITALOCEAN_STORAGE_BUCKET_NAME
15
23
 
16
- return "{endpoint_url}/{bucket_name}/{key}" \
17
- .format(endpoint_url=DIGITALOCEAN_S3_ENDPOINT_URL,
18
- bucket_name=DIGITALOCEAN_STORAGE_BUCKET_NAME, key=key)
24
+ media_url = f"{DIGITALOCEAN_S3_ENDPOINT_URL}/{DIGITALOCEAN_STORAGE_BUCKET_NAME}/{key}"
25
+
26
+ if source == MediaSource.BILLZ:
27
+ media_url = f"{cls.BILLZ_S3_ENDPOINT_URL}/{key}"
28
+ elif source == MediaSource.BITO:
29
+ media_url = f"{cls.BITTO_S3_ENDPOINT_URL}/{key}"
30
+
31
+ return media_url
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rb-commons
3
- Version: 0.7.8
3
+ Version: 0.7.10
4
4
  Summary: Commons of project and simplified orm based on sqlalchemy.
5
5
  Home-page: https://github.com/RoboSell-organization/rb-commons
6
6
  Author: Abdulvoris
@@ -12,7 +12,7 @@ rb_commons/http/base_api.py,sha256=ZiSJX5z-1QbL5RuKm30wf-3kbOu4s2plb8q3v0DQUKo,5
12
12
  rb_commons/http/consul.py,sha256=Ioq72VD1jGwoC96set7n2SgxN40olzI-myA2lwKkYi4,1864
13
13
  rb_commons/http/exceptions.py,sha256=EGRMr1cRgiJ9Q2tkfANbf0c6-zzXf1CD6J3cmCaT_FA,1885
14
14
  rb_commons/orm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- rb_commons/orm/enum.py,sha256=Y0Zew1tE4djDIj4sfswITTZRbcNG8ljKoJy-CGOZVzE,135
15
+ rb_commons/orm/enum.py,sha256=x-Yyw5DXJwYW5DbLwV0rpAQt14ZcNWbwIlS2nW2Nd_4,256
16
16
  rb_commons/orm/exceptions.py,sha256=1aMctiEwrPjyehoXVX1l6ML5ZOhmDkmBISzlTD5ey1Y,509
17
17
  rb_commons/orm/managers.py,sha256=BrpMvOkRoAPKtUV1SfakXMYd73-RhqIaoj1Wmru1gAs,20319
18
18
  rb_commons/orm/querysets.py,sha256=Q4iY_TKZItpNnrbCAvlSwyCxJikhaX5qVF3Y2rVgAYQ,1666
@@ -23,8 +23,8 @@ rb_commons/schemes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
23
23
  rb_commons/schemes/jwt.py,sha256=ZKLJ5D3fcEmEKySjzbxEgUcza4K-oPoHr14_Z0r9Yic,2495
24
24
  rb_commons/schemes/pagination.py,sha256=8VZW1wZGJIPR9jEBUgppZUoB4uqP8ORudHkMwvEJSxg,1866
25
25
  rb_commons/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- rb_commons/utils/media.py,sha256=J2Zi0J28DhcVQVzt-myNNVuzj9Msaetul53VjZtdDdc,820
27
- rb_commons-0.7.8.dist-info/METADATA,sha256=VFeytR4r8on0mSERmVL4PHcVctvhiomb2zVl7y8h_0g,6570
28
- rb_commons-0.7.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
- rb_commons-0.7.8.dist-info/top_level.txt,sha256=HPx_WAYo3_fbg1WCeGHsz3wPGio1ucbnrlm2lmqlJog,11
30
- rb_commons-0.7.8.dist-info/RECORD,,
26
+ rb_commons/utils/media.py,sha256=yfOe3L1ZrylZpP-n-pN49UlP9zg7oAuG0BOq7PT-9Cs,1300
27
+ rb_commons-0.7.10.dist-info/METADATA,sha256=7Z_LZ3yKop88LCt8piDYIvx6IBsUAzKAMtpd4m7PSl8,6571
28
+ rb_commons-0.7.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
+ rb_commons-0.7.10.dist-info/top_level.txt,sha256=HPx_WAYo3_fbg1WCeGHsz3wPGio1ucbnrlm2lmqlJog,11
30
+ rb_commons-0.7.10.dist-info/RECORD,,