def account_statistics(self, callback, account_id, fields=None): try: account_id = int(account_id) except (TypeError, ValueError): error = exceptions.BadRequest() return callback({'description': error.description}, error.status_code, error.response_code) url = '/external_api/accounts/{account_id}'.format(account_id=account_id) @preprocess_callback(callback, 'wgsh') def inner_callback(data): return data or {} return self._request_data(inner_callback, 'wgsh', url, method='GET')
def leave_room(self, callback, periphery_id, unit_server_id, fields=None): try: periphery_id = int(periphery_id) unit_server_id = int(unit_server_id) except (TypeError, ValueError): error = exceptions.BadRequest() return callback({'description': error.description}, error.status_code, error.response_code) url = '/unit_api/periphery/{periphery_id}/units/{unit_server_id}/participants/{account_id}/leave'.format(periphery_id=periphery_id, unit_server_id=unit_server_id, account_id=self._account) @preprocess_callback(callback, 'wgsh') def inner_callback(data): return data or {} return self._request_data(inner_callback, 'wgsh', url, method='POST')
def get_wgsh_unit_info(self, callback, periphery_id, unit_server_id, fields=None): try: periphery_id = int(periphery_id) unit_server_id = int(unit_server_id) except (TypeError, ValueError): error = exceptions.BadRequest() return callback({'description': error.description}, error.status_code, error.response_code) url = '/unit_api/periphery/{periphery_id}/units/{unit_server_id}/'.format(periphery_id=periphery_id, unit_server_id=unit_server_id) @preprocess_callback(callback, 'wgsh') def inner_callback(data): return data or {} return self._request_data(inner_callback, 'wgsh', url)
def set_equipment_commander(self, callback, periphery_id, unit_server_id, target_account_id, fields=None): try: periphery_id = int(periphery_id) unit_server_id = int(unit_server_id) except (TypeError, ValueError): error = exceptions.BadRequest() return callback({'description': error.description}, error.status_code, error.response_code) url = '/unit_api/periphery/{periphery_id}/units/{unit_server_id}/members/{account_id}/equipment_commander'.format(periphery_id=periphery_id, unit_server_id=unit_server_id, account_id=self._account) post_data = {'equipment_commander_id': target_account_id} @preprocess_callback(callback, 'wgsh') def inner_callback(data): return data or {} return self._request_data(inner_callback, 'wgsh', url, method='PATCH', postData=post_data)
def invite_players(self, callback, periphery_id, unit_server_id, accounts_to_invite, comment, fields=None): try: periphery_id = int(periphery_id) unit_server_id = int(unit_server_id) except (TypeError, ValueError): error = exceptions.BadRequest() return callback({'description': error.description}, error.status_code, error.response_code) url = '/unit_api/periphery/{periphery_id}/units/{unit_server_id}/participants/{account_id}/invite'.format(periphery_id=periphery_id, unit_server_id=unit_server_id, account_id=self._account) post_data = {'accounts_to_invite': accounts_to_invite, 'comment': comment} @preprocess_callback(callback, 'wgsh') def inner_callback(data): return data or {} return self._request_data(inner_callback, 'wgsh', url, method='POST', postData=post_data)
def set_readiness(self, callback, periphery_id, unit_server_id, is_ready, reset_vehicle, fields=None): try: periphery_id = int(periphery_id) unit_server_id = int(unit_server_id) except (TypeError, ValueError): error = exceptions.BadRequest() return callback({'description': error.description}, error.status_code, error.response_code) url = '/unit_api/periphery/{periphery_id}/units/{unit_server_id}/members/{account_id}/readiness'.format(periphery_id=periphery_id, unit_server_id=unit_server_id, account_id=self._account) patch_data = {'is_ready': is_ready, 'reset_vehicle': reset_vehicle} @preprocess_callback(callback, 'wgsh') def inner_callback(data): return data or {} return self._request_data(inner_callback, 'wgsh', url, method='PATCH', postData=patch_data)
def get_strongholds_statistics(self, callback, clan_id, fields=None): get_params = urlencode({'performer_id': self._account}) try: clan_id = int(clan_id) except (TypeError, ValueError): error = exceptions.BadRequest() return callback({'description': error.description}, error.status_code, error.response_code) url = '/api/strongholds/statistics/%s/' % clan_id if self._account: url = '?'.join([url, get_params]) @preprocess_callback(callback, 'strongholds') def inner_callback(data): return data[0] return self._request_data(inner_callback, 'strongholds', url)
def get_strongholds_state(self, callback, clan_id, fields=None): get_params = {'clan_id': clan_id} try: clan_id = int(clan_id) except (TypeError, ValueError): error = exceptions.BadRequest() return callback({'description': error.description}, error.status_code, error.response_code) if self._account: get_params['performer_id'] = self._account url = '/api/strongholds/state/?%s' % urlencode(get_params) @preprocess_callback(callback, 'strongholds') def inner_callback(data): return data and data[0] or {} return self._request_data(inner_callback, 'strongholds', url)
def get_stronghold_info(self, callback, clan_id, fields = None): """ return data from WGCCFE backend using `stronghold info API method`_ .. _stronghold info API method: http://rtd.wargaming.net/docs/wgccfe/en/latest/rst/ strongholds.html#strongholds-clan-id """ get_params = urlencode({'performer_id': self._account}) try: clan_id = int(clan_id) except (TypeError, ValueError): error = exceptions.BadRequest() return callback({'description': error.description}, error.status_code, error.response_code) url = 'api/strongholds/%s/' % clan_id if self._account: url = '?'.join([url, get_params]) @preprocess_callback(callback, 'strongholds') def inner_callback(data): return data['stronghold'] return self._request_data(inner_callback, 'strongholds', url)
def get_strongholds_state(self, callback, clan_id, fields = None): """ return data from WGCCFE backend using `stronghold state API method`_ .. _stronghold state API method: http://rtd.wargaming.net/docs/wgccfe/en/latest/ rst/strongholds.html#strongholds-state """ get_params = {'clan_id': clan_id} try: clan_id = int(clan_id) except (TypeError, ValueError): error = exceptions.BadRequest() return callback({'description': error.description}, error.status_code, error.response_code) if self._account: get_params['performer_id'] = self._account url = '/api/strongholds/state/?%s' % urlencode(get_params) @preprocess_callback(callback, 'strongholds') def inner_callback(data): return data and data[0] or {} return self._request_data(inner_callback, 'strongholds', url)