Class: YNAB::CategoriesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/ynab/api/categories_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ CategoriesApi

Returns a new instance of CategoriesApi.



19
20
21
# File 'lib/ynab/api/categories_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/ynab/api/categories_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_categories(budget_id, opts = {}) ⇒ CategoriesResponse

List categories Returns all categories grouped by category group. Amounts (budgeted, activity, balance, etc.) are specific to the current budget month (UTC).

Parameters:

  • 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)

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :last_knowledge_of_server (Integer)

    The starting server knowledge. If provided, only entities that have changed since last_knowledge_of_server will be included.

Returns:



28
29
30
31
# 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 = {}) ⇒ Array<(CategoriesResponse, Fixnum, Hash)>

List categories Returns all categories grouped by category group. Amounts (budgeted, activity, balance, etc.) are specific to the current budget month (UTC).

Parameters:

  • budget_id

    The id of the budget (&quot;last-used&quot; can be used to specify the last used budget and &quot;default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget)

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :last_knowledge_of_server (Integer)

    The starting server knowledge. If provided, only entities that have changed since last_knowledge_of_server will be included.

Returns:

  • (Array<(CategoriesResponse, Fixnum, Hash)>)

    CategoriesResponse data, response status code and response headers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# 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 = {}) ⇒ CategoryResponse

Single category Returns a single category. Amounts (budgeted, activity, balance, etc.) are specific to the current budget month (UTC).

Parameters:

  • budget_id

    The id of the budget (&quot;last-used&quot; can be used to specify the last used budget and &quot;default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget)

  • category_id

    The id of the category

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



83
84
85
86
# 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 = {}) ⇒ Array<(CategoryResponse, Fixnum, Hash)>

Single category Returns a single category. Amounts (budgeted, activity, balance, etc.) are specific to the current budget month (UTC).

Parameters:

  • budget_id

    The id of the budget (&quot;last-used&quot; can be used to specify the last used budget and &quot;default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget)

  • category_id

    The id of the category

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(CategoryResponse, Fixnum, Hash)>)

    CategoryResponse data, response status code and response headers



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# 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 = {}) ⇒ CategoryResponse

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).

Parameters:

  • budget_id

    The id of the budget (&quot;last-used&quot; can be used to specify the last used budget and &quot;default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget)

  • month

    The budget month in ISO format (e.g. 2016-12-01) (&quot;current&quot; can also be used to specify the current calendar month (UTC))

  • category_id

    The id of the category

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



142
143
144
145
# 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 = {}) ⇒ Array<(CategoryResponse, Fixnum, Hash)>

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).

Parameters:

  • budget_id

    The id of the budget (&quot;last-used&quot; can be used to specify the last used budget and &quot;default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget)

  • month

    The budget month in ISO format (e.g. 2016-12-01) (&quot;current&quot; can also be used to specify the current calendar month (UTC))

  • category_id

    The id of the category

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(CategoryResponse, Fixnum, Hash)>)

    CategoryResponse data, response status code and response headers



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# 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 = {}) ⇒ CategoryResponse

Update a category for a specific month Update a category for a specific month

Parameters:

  • budget_id

    The id of the budget (&quot;last-used&quot; can be used to specify the last used budget and &quot;default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget)

  • month

    The budget month in ISO format (e.g. 2016-12-01) (&quot;current&quot; can also be used to specify the current calendar month (UTC))

  • category_id

    The id of the category

  • data

    The category to update

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



207
208
209
210
# 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 = {}) ⇒ Array<(CategoryResponse, Fixnum, Hash)>

Update a category for a specific month Update a category for a specific month

Parameters:

  • budget_id

    The id of the budget (&quot;last-used&quot; can be used to specify the last used budget and &quot;default&quot; can be used if default budget selection is enabled (see: api.youneedabudget.com/#oauth-default-budget)

  • month

    The budget month in ISO format (e.g. 2016-12-01) (&quot;current&quot; can also be used to specify the current calendar month (UTC))

  • category_id

    The id of the category

  • data

    The category to update

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(CategoryResponse, Fixnum, Hash)>)

    CategoryResponse data, response status code and response headers



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# 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 => 'CategoryResponse')
  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