def __setattr__(self, name, value): object.__setattr__(self, name, value) if name == 'disabled_client_side_validations': s = set(filter(None, value.split(','))) for v in s: if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: raise ApiValueError( "Invalid keyword: '{0}''".format(v)) self._disabled_client_side_validations = s
def _apply_auth_params(self, headers, querys, auth_setting): """Updates the request parameters based on a single auth_setting :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. :param auth_setting: auth settings for the endpoint """ if auth_setting['in'] == 'cookie': headers['Cookie'] = auth_setting['value'] elif auth_setting['in'] == 'header': headers[auth_setting['key']] = auth_setting['value'] elif auth_setting['in'] == 'query': querys.append((auth_setting['key'], auth_setting['value'])) else: raise ApiValueError( 'Authentication token must be in `query` or `header`')
def get_payee_by_id_with_http_info(self, budget_id, payee_id, **kwargs): # noqa: E501 """Single payee # noqa: E501 Returns a single payee # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_payee_by_id_with_http_info(budget_id, payee_id, async_req=True) >>> result = thread.get() :param budget_id: The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.youneedabudget.com/#oauth-default-budget). (required) :type budget_id: str :param payee_id: The id of the payee (required) :type payee_id: str :param async_req: Whether to execute the request asynchronously. :type async_req: bool, optional :param _return_http_data_only: response data without head status code and headers :type _return_http_data_only: bool, optional :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :type _preload_content: bool, optional :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :param _request_auth: set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request. :type _request_auth: dict, optional :return: Returns the result object. If the method is called asynchronously, returns the request thread. :rtype: tuple(PayeeResponse, status_code(int), headers(HTTPHeaderDict)) """ local_var_params = locals() all_params = ['budget_id', 'payee_id'] all_params.extend([ 'async_req', '_return_http_data_only', '_preload_content', '_request_timeout', '_request_auth' ]) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_payee_by_id" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'budget_id' is set if self.api_client.client_side_validation and ( 'budget_id' not in local_var_params or # noqa: E501 local_var_params['budget_id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `budget_id` when calling `get_payee_by_id`" ) # noqa: E501 # verify the required parameter 'payee_id' is set if self.api_client.client_side_validation and ( 'payee_id' not in local_var_params or # noqa: E501 local_var_params['payee_id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `payee_id` when calling `get_payee_by_id`" ) # noqa: E501 collection_formats = {} path_params = {} if 'budget_id' in local_var_params: path_params['budget_id'] = local_var_params[ 'budget_id'] # noqa: E501 if 'payee_id' in local_var_params: path_params['payee_id'] = local_var_params[ 'payee_id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # Authentication setting auth_settings = ['bearer'] # noqa: E501 response_types_map = { 200: "PayeeResponse", 404: "ErrorResponse", } return self.api_client.call_api( '/budgets/{budget_id}/payees/{payee_id}', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_types_map=response_types_map, auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats, _request_auth=local_var_params.get('_request_auth'))
def request(self, method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, _request_timeout=None): """Makes the HTTP request using RESTClient.""" if method == "GET": return self.rest_client.GET(url, query_params=query_params, _preload_content=_preload_content, _request_timeout=_request_timeout, headers=headers) elif method == "HEAD": return self.rest_client.HEAD(url, query_params=query_params, _preload_content=_preload_content, _request_timeout=_request_timeout, headers=headers) elif method == "OPTIONS": return self.rest_client.OPTIONS(url, query_params=query_params, headers=headers, _preload_content=_preload_content, _request_timeout=_request_timeout) elif method == "POST": return self.rest_client.POST(url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) elif method == "PUT": return self.rest_client.PUT(url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) elif method == "PATCH": return self.rest_client.PATCH(url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) elif method == "DELETE": return self.rest_client.DELETE(url, query_params=query_params, headers=headers, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) else: raise ApiValueError("http method must be `GET`, `HEAD`, `OPTIONS`," " `POST`, `PATCH`, `PUT` or `DELETE`.")
def update_month_category_with_http_info(self, budget_id, month, category_id, data, **kwargs): # noqa: E501 """Update a category for a specific month # noqa: E501 Update a category for a specific month. Only `budgeted` amount can be updated. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_month_category_with_http_info(budget_id, month, category_id, data, async_req=True) >>> result = thread.get() :param budget_id: The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.youneedabudget.com/#oauth-default-budget). (required) :type budget_id: str :param month: The budget month in ISO format (e.g. 2016-12-01) (\"current\" can also be used to specify the current calendar month (UTC)) (required) :type month: date :param category_id: The id of the category (required) :type category_id: str :param data: The category to update. Only `budgeted` amount can be updated and any other fields specified will be ignored. (required) :type data: SaveMonthCategoryWrapper :param async_req: Whether to execute the request asynchronously. :type async_req: bool, optional :param _return_http_data_only: response data without head status code and headers :type _return_http_data_only: bool, optional :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :type _preload_content: bool, optional :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :param _request_auth: set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request. :type _request_auth: dict, optional :return: Returns the result object. If the method is called asynchronously, returns the request thread. :rtype: tuple(SaveCategoryResponse, status_code(int), headers(HTTPHeaderDict)) """ local_var_params = locals() all_params = ['budget_id', 'month', 'category_id', 'data'] all_params.extend([ 'async_req', '_return_http_data_only', '_preload_content', '_request_timeout', '_request_auth' ]) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method update_month_category" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'budget_id' is set if self.api_client.client_side_validation and ( 'budget_id' not in local_var_params or # noqa: E501 local_var_params['budget_id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `budget_id` when calling `update_month_category`" ) # noqa: E501 # verify the required parameter 'month' is set if self.api_client.client_side_validation and ( 'month' not in local_var_params or # noqa: E501 local_var_params['month'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `month` when calling `update_month_category`" ) # noqa: E501 # verify the required parameter 'category_id' is set if self.api_client.client_side_validation and ( 'category_id' not in local_var_params or # noqa: E501 local_var_params['category_id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `category_id` when calling `update_month_category`" ) # noqa: E501 # verify the required parameter 'data' is set if self.api_client.client_side_validation and ( 'data' not in local_var_params or # noqa: E501 local_var_params['data'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `data` when calling `update_month_category`" ) # noqa: E501 collection_formats = {} path_params = {} if 'budget_id' in local_var_params: path_params['budget_id'] = local_var_params[ 'budget_id'] # noqa: E501 if 'month' in local_var_params: path_params['month'] = local_var_params['month'] # noqa: E501 if 'category_id' in local_var_params: path_params['category_id'] = local_var_params[ 'category_id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'data' in local_var_params: body_params = local_var_params['data'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # Authentication setting auth_settings = ['bearer'] # noqa: E501 response_types_map = { 200: "SaveCategoryResponse", 400: "ErrorResponse", } return self.api_client.call_api( '/budgets/{budget_id}/months/{month}/categories/{category_id}', 'PATCH', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_types_map=response_types_map, auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats, _request_auth=local_var_params.get('_request_auth'))