class YNAB::CategoriesApi

Attributes

api_client[RW]

Public Class Methods

new(api_client = ApiClient.default) click to toggle source
# File lib/ynab/api/categories_api.rb, line 19
def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Public Instance Methods

get_categories(budget_id, opts = {}) click to toggle source

List categories Returns all categories grouped by category group. Amounts (budgeted, activity, balance, etc.) are specific to the current budget month (UTC). @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: api.youneedabudget.com/#oauth-default-budget). @param [Hash] opts the optional parameters @option opts [Integer] :last_knowledge_of_server The starting server knowledge. If provided, only entities that have changed since `last_knowledge_of_server` will be included. @return [CategoriesResponse]

# File lib/ynab/api/categories_api.rb, line 28
def get_categories(budget_id, opts = {})
  data, _status_code, _headers = get_categories_with_http_info(budget_id, opts)
  data
end
get_categories_with_http_info(budget_id, opts = {}) click to toggle source

List categories Returns all categories grouped by category group. Amounts (budgeted, activity, balance, etc.) are specific to the current budget month (UTC). @param budget_id The id of the budget. "last-used&quot; can be used to specify the last used budget and "default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget). @param [Hash] opts the optional parameters @option opts [Integer] :last_knowledge_of_server The starting server knowledge. If provided, only entities that have changed since &#x60;last_knowledge_of_server&#x60; will be included. @return [Array<(CategoriesResponse, Fixnum, Hash)>] CategoriesResponse data, response status code and response headers

# File lib/ynab/api/categories_api.rb, line 39
def get_categories_with_http_info(budget_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CategoriesApi.get_categories ...'
  end
  # verify the required parameter 'budget_id' is set
  if @api_client.config.client_side_validation && budget_id.nil?
    fail ArgumentError, "Missing the required parameter 'budget_id' when calling CategoriesApi.get_categories"
  end
  # resource path
  local_var_path = '/budgets/{budget_id}/categories'.sub('{' + 'budget_id' + '}', budget_id.to_s)

  # query parameters
  query_params = {}
  query_params[:'last_knowledge_of_server'] = opts[:'last_knowledge_of_server'] if !opts[:'last_knowledge_of_server'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['bearer']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'CategoriesResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CategoriesApi#get_categories\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
get_category_by_id(budget_id, category_id, opts = {}) click to toggle source

Single category Returns a single category. Amounts (budgeted, activity, balance, etc.) are specific to the current budget month (UTC). @param budget_id The id of the budget. "last-used&quot; can be used to specify the last used budget and "default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget). @param category_id The id of the category @param [Hash] opts the optional parameters @return [CategoryResponse]

# File lib/ynab/api/categories_api.rb, line 83
def get_category_by_id(budget_id, category_id, opts = {})
  data, _status_code, _headers = get_category_by_id_with_http_info(budget_id, category_id, opts)
  data
end
get_category_by_id_with_http_info(budget_id, category_id, opts = {}) click to toggle source

Single category Returns a single category. Amounts (budgeted, activity, balance, etc.) are specific to the current budget month (UTC). @param budget_id The id of the budget. "last-used&quot; can be used to specify the last used budget and "default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget). @param category_id The id of the category @param [Hash] opts the optional parameters @return [Array<(CategoryResponse, Fixnum, Hash)>] CategoryResponse data, response status code and response headers

# File lib/ynab/api/categories_api.rb, line 94
def get_category_by_id_with_http_info(budget_id, category_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CategoriesApi.get_category_by_id ...'
  end
  # verify the required parameter 'budget_id' is set
  if @api_client.config.client_side_validation && budget_id.nil?
    fail ArgumentError, "Missing the required parameter 'budget_id' when calling CategoriesApi.get_category_by_id"
  end
  # verify the required parameter 'category_id' is set
  if @api_client.config.client_side_validation && category_id.nil?
    fail ArgumentError, "Missing the required parameter 'category_id' when calling CategoriesApi.get_category_by_id"
  end
  # resource path
  local_var_path = '/budgets/{budget_id}/categories/{category_id}'.sub('{' + 'budget_id' + '}', budget_id.to_s).sub('{' + 'category_id' + '}', category_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['bearer']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'CategoryResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CategoriesApi#get_category_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
get_month_category_by_id(budget_id, month, category_id, opts = {}) click to toggle source

Single category for a specific budget month Returns a single category for a specific budget month. Amounts (budgeted, activity, balance, etc.) are specific to the current budget month (UTC). @param budget_id The id of the budget. "last-used&quot; can be used to specify the last used budget and "default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget). @param month The budget month in ISO format (e.g. 2016-12-01) ("current&quot; can also be used to specify the current calendar month (UTC)) @param category_id The id of the category @param [Hash] opts the optional parameters @return [CategoryResponse]

# File lib/ynab/api/categories_api.rb, line 142
def get_month_category_by_id(budget_id, month, category_id, opts = {})
  data, _status_code, _headers = get_month_category_by_id_with_http_info(budget_id, month, category_id, opts)
  data
end
get_month_category_by_id_with_http_info(budget_id, month, category_id, opts = {}) click to toggle source

Single category for a specific budget month Returns a single category for a specific budget month. Amounts (budgeted, activity, balance, etc.) are specific to the current budget month (UTC). @param budget_id The id of the budget. "last-used&quot; can be used to specify the last used budget and "default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget). @param month The budget month in ISO format (e.g. 2016-12-01) ("current&quot; can also be used to specify the current calendar month (UTC)) @param category_id The id of the category @param [Hash] opts the optional parameters @return [Array<(CategoryResponse, Fixnum, Hash)>] CategoryResponse data, response status code and response headers

# File lib/ynab/api/categories_api.rb, line 154
def get_month_category_by_id_with_http_info(budget_id, month, category_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CategoriesApi.get_month_category_by_id ...'
  end
  # verify the required parameter 'budget_id' is set
  if @api_client.config.client_side_validation && budget_id.nil?
    fail ArgumentError, "Missing the required parameter 'budget_id' when calling CategoriesApi.get_month_category_by_id"
  end
  # verify the required parameter 'month' is set
  if @api_client.config.client_side_validation && month.nil?
    fail ArgumentError, "Missing the required parameter 'month' when calling CategoriesApi.get_month_category_by_id"
  end
  # verify the required parameter 'category_id' is set
  if @api_client.config.client_side_validation && category_id.nil?
    fail ArgumentError, "Missing the required parameter 'category_id' when calling CategoriesApi.get_month_category_by_id"
  end
  # resource path
  local_var_path = '/budgets/{budget_id}/months/{month}/categories/{category_id}'.sub('{' + 'budget_id' + '}', budget_id.to_s).sub('{' + 'month' + '}', month.to_s).sub('{' + 'category_id' + '}', category_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['bearer']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'CategoryResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CategoriesApi#get_month_category_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
update_month_category(budget_id, month, category_id, data, opts = {}) click to toggle source

Update a category for a specific month Update a category for a specific month. Only `budgeted` amount can be updated. @param budget_id The id of the budget. "last-used&quot; can be used to specify the last used budget and "default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget). @param month The budget month in ISO format (e.g. 2016-12-01) ("current&quot; can also be used to specify the current calendar month (UTC)) @param category_id The id of the category @param data The category to update. Only &#x60;budgeted&#x60; amount can be updated and any other fields specified will be ignored. @param [Hash] opts the optional parameters @return [SaveCategoryResponse]

# File lib/ynab/api/categories_api.rb, line 207
def update_month_category(budget_id, month, category_id, data, opts = {})
  data, _status_code, _headers = update_month_category_with_http_info(budget_id, month, category_id, data, opts)
  data
end
update_month_category_with_http_info(budget_id, month, category_id, data, opts = {}) click to toggle source

Update a category for a specific month Update a category for a specific month. Only &#x60;budgeted&#x60; amount can be updated. @param budget_id The id of the budget. "last-used&quot; can be used to specify the last used budget and "default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget). @param month The budget month in ISO format (e.g. 2016-12-01) ("current&quot; can also be used to specify the current calendar month (UTC)) @param category_id The id of the category @param data The category to update. Only &#x60;budgeted&#x60; amount can be updated and any other fields specified will be ignored. @param [Hash] opts the optional parameters @return [Array<(SaveCategoryResponse, Fixnum, Hash)>] SaveCategoryResponse data, response status code and response headers

# File lib/ynab/api/categories_api.rb, line 220
def update_month_category_with_http_info(budget_id, month, category_id, data, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CategoriesApi.update_month_category ...'
  end
  # verify the required parameter 'budget_id' is set
  if @api_client.config.client_side_validation && budget_id.nil?
    fail ArgumentError, "Missing the required parameter 'budget_id' when calling CategoriesApi.update_month_category"
  end
  # verify the required parameter 'month' is set
  if @api_client.config.client_side_validation && month.nil?
    fail ArgumentError, "Missing the required parameter 'month' when calling CategoriesApi.update_month_category"
  end
  # verify the required parameter 'category_id' is set
  if @api_client.config.client_side_validation && category_id.nil?
    fail ArgumentError, "Missing the required parameter 'category_id' when calling CategoriesApi.update_month_category"
  end
  # verify the required parameter 'data' is set
  if @api_client.config.client_side_validation && data.nil?
    fail ArgumentError, "Missing the required parameter 'data' when calling CategoriesApi.update_month_category"
  end
  # resource path
  local_var_path = '/budgets/{budget_id}/months/{month}/categories/{category_id}'.sub('{' + 'budget_id' + '}', budget_id.to_s).sub('{' + 'month' + '}', month.to_s).sub('{' + 'category_id' + '}', category_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(data)
  auth_names = ['bearer']
  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'SaveCategoryResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CategoriesApi#update_month_category\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end