Skip to content

Commit

Permalink
Flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
0xRy4n committed Sep 20, 2023
1 parent bd3c288 commit daa890d
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 126 deletions.
2 changes: 2 additions & 0 deletions intercom_python_sdk/apis/articles/languages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from enum import Enum


class ArticleLanguages(Enum):
ARABIC = "ar"
BULGARIAN = "bg"
Expand Down
4 changes: 1 addition & 3 deletions intercom_python_sdk/apis/articles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
# From Current Package
from ...core.model_base import ModelBase

from .languages import ArticleLanguages

# Type Check Imports - TYPE_CHECKING is assumed True by type-checkers but is False at runtime.
# See: https://docs.python.org/3/library/typing.html#typing.TYPE_CHECKING
if TYPE_CHECKING:
Expand Down Expand Up @@ -245,7 +243,7 @@ def translated_content(self) -> dict:
dict: The translated content of the Article.
"""
return self.__translated_content

@property
def content(self) -> BeautifulSoup:
"""
Expand Down
9 changes: 1 addition & 8 deletions intercom_python_sdk/apis/articles/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@
---
- [1] https://developers.intercom.com/intercom-api-reference/reference/the-article-model
"""

# Built-in
from enum import Enum

# External
# Third-party
import marshmallow
from marshmallow import fields

# From Current API
from . import models as a_models
from .languages import ArticleLanguages

# From Current Package
from ...core.schema_base import SchemaBase
Expand Down Expand Up @@ -116,5 +111,3 @@ class ArticleListSchema(SchemaBase):
@marshmallow.post_load
def make_article_list(self, data, **kwargs):
return a_models.ArticleList(**data)


1 change: 0 additions & 1 deletion intercom_python_sdk/apis/data_export/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import requests
from typing import (
TYPE_CHECKING,
Optional
)

# From Current Package
Expand Down
29 changes: 10 additions & 19 deletions intercom_python_sdk/apis/help_center/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
"""
# Help Center API
`apis/help_center/api.py`
Expand All @@ -12,15 +12,13 @@
"""

# Built-ins
import functools
from typing import Union, cast
from typing import Union

# External
from uplink import (
get, put, post,
returns, args,
error_handler, response_handler,
Field, Body, json, Url, Path, Query,delete
get,
returns,
response_handler,
)

# From Current API
Expand All @@ -31,22 +29,17 @@
SectionListSchema,
)

from .models import (
Collection,
CollectionList,


)

# From Current Package
from ...core.api_base import APIBase
from ...core.errors import catch_api_error


@response_handler(catch_api_error)
class HelpCenterAPI(APIBase):
URI = "/help_center/"

@returns(CollectionSchema(many=False)) # type: ignore
@returns(CollectionSchema(many=False)) # type: ignore
@get("collections/{collection_id}")
def get_collection_by_id(self, collection_id: Union[str, int]):
""" Get a Collection by ID.
Expand All @@ -58,7 +51,7 @@ def get_collection_by_id(self, collection_id: Union[str, int]):
Collection: The Collection with the given ID.
"""

@returns(CollectionListSchema(many=False)) # type: ignore
@returns(CollectionListSchema(many=False)) # type: ignore
@get("collections")
def list_all_collections(self):
""" List all Collections.
Expand All @@ -67,8 +60,7 @@ def list_all_collections(self):
CollectionList: A list of all Collections.
"""


@returns(SectionSchema(many=False)) # type: ignore
@returns(SectionSchema(many=False)) # type: ignore
@get("sections/{section_id}")
def get_section_by_id(self, section_id: Union[str, int]):
""" Get a Section by ID.
Expand All @@ -80,12 +72,11 @@ def get_section_by_id(self, section_id: Union[str, int]):
Section: The Section with the given ID.
"""

@returns(SectionListSchema(many=False)) # type: ignore
@returns(SectionListSchema(many=False)) # type: ignore
@get("sections")
def list_all_sections(self):
""" List all Sections.
Returns:
SectionList: A list of all Sections.
"""

31 changes: 7 additions & 24 deletions intercom_python_sdk/apis/teams/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,32 @@
[1] https://developers.intercom.com/intercom-api-reference/reference/listallteams
[2] https://github.com/intercom/Intercom-OpenAPI
"""


# Built-ins
import functools
from typing import Union, cast
from typing import Union

# External
from uplink import (
get, put, post,
returns, args,
error_handler, response_handler,
Field, Body, json, Url, Path, Query,delete
get,
returns,
response_handler,
)

# From Current API
from .schemas import (
TeamSchema,
AdminPriorityLevelSchema,
TeamListSchema,
)

from .models import (
Team,
AdminPriorityLevel,
TeamList,

)

# From Current Package
from ...core.api_base import APIBase
from ...core.errors import catch_api_error


@response_handler(catch_api_error)
class TeamsAPI(APIBase):
URI = "/teams/"

@returns(TeamListSchema(many=False)) # type: ignore
@returns(TeamListSchema(many=False)) # type: ignore
@get("")
def get_all_teams(self):
""" Get all Teams.
Expand All @@ -56,8 +45,7 @@ def get_all_teams(self):
"""
pass


@returns(TeamSchema(many=False)) # type: ignore
@returns(TeamSchema(many=False)) # type: ignore
@get("{team_id}")
def get_team_by_id(self, team_id: Union[str, int]):
""" Get a Team by ID.
Expand All @@ -69,8 +57,3 @@ def get_team_by_id(self, team_id: Union[str, int]):
Team: The Team with the given ID.
"""
pass





32 changes: 1 addition & 31 deletions intercom_python_sdk/apis/teams/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@


# External
import marshmallow
from marshmallow import fields
from typing import List, Optional, Union , TYPE_CHECKING

# From Current API
from . import schemas as t_schemas
from typing import List, TYPE_CHECKING

# From Current Package
from ...core.model_base import ModelBase
Expand All @@ -41,22 +36,18 @@ def __init__(self, *args, **kwargs):
self.primary_admin_ids: List[int] = kwargs.get("primary_admin_ids", [])
self.secondary_admin_ids: List[int] = kwargs.get("secondary_admin_ids", [])


# Properties
@property
def api_client(self) -> 'TeamsAPI':
return self._api_client


@property
def primary_admin_ids(self) -> List[int]:
return self._primary_admin_ids


@property
def secondary_admin_ids(self) -> List[int]:
return self._secondary_admin_ids


@primary_admin_ids.setter
def primary_admin_ids(self, primary_admin_ids: List[int]):
Expand All @@ -71,7 +62,6 @@ def api_client(self, api_client: 'TeamsAPI'):
self._api_client = api_client



class Team(ModelBase):
"""
This model represents a Team on Intercom.
Expand All @@ -91,37 +81,30 @@ def __init__(self, *args, **kwargs):
self.admin_ids: List[int] = kwargs.get("admin_ids", [])
self.admin_priority_level: AdminPriorityLevel = kwargs.get("admin_priority_level", None)


# Properties
@property
def api_client(self) -> 'TeamsAPI':
return self._api_client


@property
def id(self) -> int:
return self._id


@property
def type(self) -> str:
return self._type


@property
def name(self) -> str:
return self._name


@property
def admin_ids(self) -> List[int]:
return self._admin_ids


@property
def admin_priority_level(self) -> AdminPriorityLevel:
return self._admin_priority_level


@id.setter
def id(self, id: int):
Expand All @@ -146,7 +129,6 @@ def admin_priority_level(self, admin_priority_level: AdminPriorityLevel):
@api_client.setter
def api_client(self, api_client: 'TeamsAPI'):
self._api_client = api_client



class TeamList(ModelBase):
Expand All @@ -160,17 +142,14 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.teams: List[Team] = kwargs.get("teams", [])


# Properties
@property
def api_client(self) -> 'TeamsAPI':
return self._api_client


@property
def teams(self) -> List[Team]:
return self._teams


@teams.setter
def teams(self, teams: List[Team]):
Expand All @@ -179,12 +158,3 @@ def teams(self, teams: List[Team]):
@api_client.setter
def api_client(self, api_client: 'TeamsAPI'):
self._api_client = api_client









28 changes: 2 additions & 26 deletions intercom_python_sdk/apis/teams/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,13 @@
- [1] https://developers.intercom.com/intercom-api-reference/reference/listteams
"""


# External
import marshmallow
from marshmallow import fields

# From Current API
from . import models as t_models

# From Current Package
from ...core.schema_base import SchemaBase

'''
{
"type": "team",
"id": "814865",
"name": "Example Team",
"admin_ids": [
493881
814860
]
"admin_priority_level": {
"primary_admin_ids": [
493881
],
"secondary_admin_ids": [
814860
]
},
}
'''

class AdminPriorityLevelSchema(SchemaBase):
"""
This schema represents a AdminPriorityLevel on Intercom.
Expand All @@ -52,6 +29,7 @@ class AdminPriorityLevelSchema(SchemaBase):
primary_admin_ids = fields.List(fields.Int())
secondary_admin_ids = fields.List(fields.Int())


class TeamSchema(SchemaBase):
"""
This schema represents a Team on Intercom.
Expand All @@ -68,8 +46,6 @@ class TeamSchema(SchemaBase):
name = fields.Str()
admin_ids = fields.List(fields.Int())
admin_priority_level = fields.Nested(AdminPriorityLevelSchema)




class TeamListSchema(SchemaBase):
Expand Down
Loading

0 comments on commit daa890d

Please sign in to comment.