Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
prostomarkeloff committed Apr 5, 2020
1 parent 4a24c85 commit f827154
Show file tree
Hide file tree
Showing 45 changed files with 186 additions and 384 deletions.
2 changes: 1 addition & 1 deletion tests/bots/utils/test_vkwave_bots_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from vkwave.bots.utils.uploaders import PhotoUploader, DocUploader
from vkwave.bots.utils.uploaders import DocUploader, PhotoUploader
from vkwave.easy import create_bot_aiohttp


Expand Down
3 changes: 3 additions & 0 deletions vkwave/api/methods/_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ def __init__(self, code: int, message: str, request_params: dict):
self.message = f"[{code}] {message}"
super().__init__(self.message)


_NO_DEFAULT_HANDLER = object()


async def _noop_default_handler(error: Error, ctx: "APIOptionsRequestContext"):
return _NO_DEFAULT_HANDLER


class ErrorDispatcher:
def __init__(self):
self.handlers: typing.Dict[int, ErrorHandlerCallable] = {}
Expand Down
13 changes: 4 additions & 9 deletions vkwave/api/methods/account.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from vkwave.types.responses import *

from ._category import Category
from ._utils import get_params

Expand Down Expand Up @@ -111,9 +112,7 @@ async def get_banned(
return result

async def get_counters(
self,
filter: typing.Optional[typing.List[str]] = None,
return_raw_response: bool = False,
self, filter: typing.Optional[typing.List[str]] = None, return_raw_response: bool = False,
) -> typing.Union[dict, AccountGetCountersResponse]:
"""
:param filter: - Counters to be returned.
Expand All @@ -131,9 +130,7 @@ async def get_counters(
return result

async def get_info(
self,
fields: typing.Optional[typing.List[str]] = None,
return_raw_response: bool = False,
self, fields: typing.Optional[typing.List[str]] = None, return_raw_response: bool = False,
) -> typing.Union[dict, AccountGetInfoResponse]:
"""
:param fields: - Fields to return. Possible values: *'country' — user country,, *'https_required' — is "HTTPS only" option enabled,, *'own_posts_default' — is "Show my posts only" option is enabled,, *'no_wall_replies' — are wall replies disabled or not,, *'intro' — is intro passed by user or not,, *'lang' — user language. By default: all.
Expand Down Expand Up @@ -325,9 +322,7 @@ async def set_offline(
return result

async def set_online(
self,
voip: typing.Optional[BaseBoolInt] = None,
return_raw_response: bool = False,
self, voip: typing.Optional[BaseBoolInt] = None, return_raw_response: bool = False,
) -> typing.Union[dict, OkResponse]:
"""
:param voip: - '1' if videocalls are available for current device.
Expand Down
61 changes: 13 additions & 48 deletions vkwave/api/methods/ads.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from vkwave.types.responses import *

from ._category import Category
from ._utils import get_params


class Ads(Category):
async def add_office_users(
self,
account_id: int = None,
data: str = None,
return_raw_response: bool = False,
self, account_id: int = None, data: str = None, return_raw_response: bool = False,
) -> typing.Union[dict, AdsAddOfficeUsersResponse]:
"""
:param account_id: - Advertising account ID.
Expand Down Expand Up @@ -53,10 +51,7 @@ async def check_link(
return result

async def create_ads(
self,
account_id: int = None,
data: str = None,
return_raw_response: bool = False,
self, account_id: int = None, data: str = None, return_raw_response: bool = False,
) -> typing.Union[dict, AdsCreateAdsResponse]:
"""
:param account_id: - Advertising account ID.
Expand All @@ -75,10 +70,7 @@ async def create_ads(
return result

async def create_campaigns(
self,
account_id: int = None,
data: str = None,
return_raw_response: bool = False,
self, account_id: int = None, data: str = None, return_raw_response: bool = False,
) -> typing.Union[dict, AdsCreateCampaignsResponse]:
"""
:param account_id: - Advertising account ID.
Expand All @@ -97,10 +89,7 @@ async def create_campaigns(
return result

async def create_clients(
self,
account_id: int = None,
data: str = None,
return_raw_response: bool = False,
self, account_id: int = None, data: str = None, return_raw_response: bool = False,
) -> typing.Union[dict, AdsCreateClientsResponse]:
"""
:param account_id: - Advertising account ID.
Expand Down Expand Up @@ -149,10 +138,7 @@ async def create_target_group(
return result

async def delete_ads(
self,
account_id: int = None,
ids: str = None,
return_raw_response: bool = False,
self, account_id: int = None, ids: str = None, return_raw_response: bool = False,
) -> typing.Union[dict, AdsDeleteAdsResponse]:
"""
:param account_id: - Advertising account ID.
Expand All @@ -171,10 +157,7 @@ async def delete_ads(
return result

async def delete_campaigns(
self,
account_id: int = None,
ids: str = None,
return_raw_response: bool = False,
self, account_id: int = None, ids: str = None, return_raw_response: bool = False,
) -> typing.Union[dict, AdsDeleteCampaignsResponse]:
"""
:param account_id: - Advertising account ID.
Expand All @@ -193,10 +176,7 @@ async def delete_campaigns(
return result

async def delete_clients(
self,
account_id: int = None,
ids: str = None,
return_raw_response: bool = False,
self, account_id: int = None, ids: str = None, return_raw_response: bool = False,
) -> typing.Union[dict, AdsDeleteClientsResponse]:
"""
:param account_id: - Advertising account ID.
Expand Down Expand Up @@ -522,10 +502,7 @@ async def get_posts_reach(
return result

async def get_rejection_reason(
self,
account_id: int = None,
ad_id: int = None,
return_raw_response: bool = False,
self, account_id: int = None, ad_id: int = None, return_raw_response: bool = False,
) -> typing.Union[dict, AdsGetRejectionReasonResponse]:
"""
:param account_id: - Advertising account ID.
Expand Down Expand Up @@ -731,10 +708,7 @@ async def import_target_contacts(
return result

async def remove_office_users(
self,
account_id: int = None,
ids: str = None,
return_raw_response: bool = False,
self, account_id: int = None, ids: str = None, return_raw_response: bool = False,
) -> typing.Union[dict, AdsRemoveOfficeUsersResponse]:
"""
:param account_id: - Advertising account ID.
Expand All @@ -753,10 +727,7 @@ async def remove_office_users(
return result

async def update_ads(
self,
account_id: int = None,
data: str = None,
return_raw_response: bool = False,
self, account_id: int = None, data: str = None, return_raw_response: bool = False,
) -> typing.Union[dict, AdsUpdateAdsResponse]:
"""
:param account_id: - Advertising account ID.
Expand All @@ -775,10 +746,7 @@ async def update_ads(
return result

async def update_campaigns(
self,
account_id: int = None,
data: str = None,
return_raw_response: bool = False,
self, account_id: int = None, data: str = None, return_raw_response: bool = False,
) -> typing.Union[dict, AdsUpdateCampaignsResponse]:
"""
:param account_id: - Advertising account ID.
Expand All @@ -797,10 +765,7 @@ async def update_campaigns(
return result

async def update_clients(
self,
account_id: int = None,
data: str = None,
return_raw_response: bool = False,
self, account_id: int = None, data: str = None, return_raw_response: bool = False,
) -> typing.Union[dict, AdsUpdateClientsResponse]:
"""
:param account_id: - Advertising account ID.
Expand Down
1 change: 1 addition & 0 deletions vkwave/api/methods/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from vkwave.types.responses import *

from ._category import Category
from ._utils import get_params

Expand Down
5 changes: 2 additions & 3 deletions vkwave/api/methods/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from vkwave.types.responses import *

from ._category import Category
from ._utils import get_params

Expand Down Expand Up @@ -127,9 +128,7 @@ async def get_leaderboard(
global_: typing.Optional[BaseBoolInt] = None,
extended: typing.Optional[BaseBoolInt] = None,
return_raw_response: bool = False,
) -> typing.Union[
dict, AppsGetLeaderboardResponse, AppsGetLeaderboardExtendedResponse
]:
) -> typing.Union[dict, AppsGetLeaderboardResponse, AppsGetLeaderboardExtendedResponse]:
"""
:param type: - Leaderboard type. Possible values: *'level' — by level,, *'points' — by mission points,, *'score' — by score ().
:param global_: - Rating type. Possible values: *'1' — global rating among all players,, *'0' — rating among user friends.
Expand Down
6 changes: 2 additions & 4 deletions vkwave/api/methods/auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from vkwave.types.responses import *

from ._category import Category
from ._utils import get_params

Expand Down Expand Up @@ -31,10 +32,7 @@ async def check_phone(
return result

async def restore(
self,
phone: str = None,
last_name: str = None,
return_raw_response: bool = False,
self, phone: str = None, last_name: str = None, return_raw_response: bool = False,
) -> typing.Union[dict, AuthRestoreResponse]:
"""
:param phone: - User phone number.
Expand Down
26 changes: 6 additions & 20 deletions vkwave/api/methods/board.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from vkwave.types.responses import *

from ._category import Category
from ._utils import get_params

Expand Down Expand Up @@ -33,10 +34,7 @@ async def add_topic(
return result

async def close_topic(
self,
group_id: int = None,
topic_id: int = None,
return_raw_response: bool = False,
self, group_id: int = None, topic_id: int = None, return_raw_response: bool = False,
) -> typing.Union[dict, OkResponse]:
"""
:param group_id: - ID of the community that owns the discussion board.
Expand Down Expand Up @@ -111,10 +109,7 @@ async def delete_comment(
return result

async def delete_topic(
self,
group_id: int = None,
topic_id: int = None,
return_raw_response: bool = False,
self, group_id: int = None, topic_id: int = None, return_raw_response: bool = False,
) -> typing.Union[dict, OkResponse]:
"""
:param group_id: - ID of the community that owns the discussion board.
Expand Down Expand Up @@ -185,10 +180,7 @@ async def edit_topic(
return result

async def fix_topic(
self,
group_id: int = None,
topic_id: int = None,
return_raw_response: bool = False,
self, group_id: int = None, topic_id: int = None, return_raw_response: bool = False,
) -> typing.Union[dict, OkResponse]:
"""
:param group_id: - ID of the community that owns the discussion board.
Expand Down Expand Up @@ -283,10 +275,7 @@ async def get_topics(
return result

async def open_topic(
self,
group_id: int = None,
topic_id: int = None,
return_raw_response: bool = False,
self, group_id: int = None, topic_id: int = None, return_raw_response: bool = False,
) -> typing.Union[dict, OkResponse]:
"""
:param group_id: - ID of the community that owns the discussion board.
Expand Down Expand Up @@ -329,10 +318,7 @@ async def restore_comment(
return result

async def unfix_topic(
self,
group_id: int = None,
topic_id: int = None,
return_raw_response: bool = False,
self, group_id: int = None, topic_id: int = None, return_raw_response: bool = False,
) -> typing.Union[dict, OkResponse]:
"""
:param group_id: - ID of the community that owns the discussion board.
Expand Down
5 changes: 2 additions & 3 deletions vkwave/api/methods/database.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from vkwave.types.responses import *

from ._category import Category
from ._utils import get_params

Expand Down Expand Up @@ -221,9 +222,7 @@ async def get_regions(
return result

async def get_school_classes(
self,
country_id: typing.Optional[int] = None,
return_raw_response: bool = False,
self, country_id: typing.Optional[int] = None, return_raw_response: bool = False,
) -> typing.Union[dict, DatabaseGetSchoolClassesResponse]:
"""
:param country_id: - Country ID.
Expand Down
1 change: 1 addition & 0 deletions vkwave/api/methods/docs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from vkwave.types.responses import *

from ._category import Category
from ._utils import get_params

Expand Down
6 changes: 2 additions & 4 deletions vkwave/api/methods/fave.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from vkwave.types.responses import *

from ._category import Category
from ._utils import get_params

Expand Down Expand Up @@ -270,10 +271,7 @@ async def mark_seen(
return result

async def remove_article(
self,
owner_id: int = None,
article_id: int = None,
return_raw_response: bool = False,
self, owner_id: int = None, article_id: int = None, return_raw_response: bool = False,
) -> typing.Union[dict, BaseBoolResponse]:
"""
:param owner_id:
Expand Down
5 changes: 2 additions & 3 deletions vkwave/api/methods/friends.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from vkwave.types.responses import *

from ._category import Category
from ._utils import get_params

Expand Down Expand Up @@ -361,9 +362,7 @@ async def get_requests(
ref: typing.Optional[str] = None,
fields: typing.Optional[typing.List[UsersFields]] = None,
return_raw_response: bool = False,
) -> typing.Union[
dict, FriendsGetRequestsResponse, FriendsGetRequestsExtendedResponse
]:
) -> typing.Union[dict, FriendsGetRequestsResponse, FriendsGetRequestsExtendedResponse]:
"""
:param offset: - Offset needed to return a specific subset of friend requests.
:param count: - Number of friend requests to return (default 100, maximum 1000).
Expand Down
1 change: 1 addition & 0 deletions vkwave/api/methods/gifts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from vkwave.types.responses import *

from ._category import Category
from ._utils import get_params

Expand Down
Loading

0 comments on commit f827154

Please sign in to comment.