ynab 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +44 -0
  4. data/LICENSE.md +201 -0
  5. data/README.md +57 -0
  6. data/Rakefile +31 -0
  7. data/config.json +10 -0
  8. data/docs/Account.md +16 -0
  9. data/docs/AccountResponse.md +8 -0
  10. data/docs/AccountWrapper.md +8 -0
  11. data/docs/AccountsApi.md +121 -0
  12. data/docs/AccountsResponse.md +8 -0
  13. data/docs/AccountsWrapper.md +8 -0
  14. data/docs/BudgetDetail.md +22 -0
  15. data/docs/BudgetDetailResponse.md +8 -0
  16. data/docs/BudgetDetailWrapper.md +9 -0
  17. data/docs/BudgetSummary.md +12 -0
  18. data/docs/BudgetSummaryResponse.md +8 -0
  19. data/docs/BudgetSummaryWrapper.md +8 -0
  20. data/docs/BudgetsApi.md +116 -0
  21. data/docs/BulkIdWrapper.md +8 -0
  22. data/docs/BulkIds.md +9 -0
  23. data/docs/BulkResponse.md +8 -0
  24. data/docs/BulkTransactionCreateResponse.md +8 -0
  25. data/docs/BulkTransactionIds.md +8 -0
  26. data/docs/BulkTransactions.md +8 -0
  27. data/docs/CategoriesApi.md +121 -0
  28. data/docs/CategoriesResponse.md +8 -0
  29. data/docs/Category.md +15 -0
  30. data/docs/CategoryGroup.md +10 -0
  31. data/docs/CategoryGroupWithCategories.md +11 -0
  32. data/docs/CategoryGroupsWrapper.md +8 -0
  33. data/docs/CategoryResponse.md +8 -0
  34. data/docs/CategoryWrapper.md +8 -0
  35. data/docs/CurrencyFormat.md +8 -0
  36. data/docs/DateFormat.md +8 -0
  37. data/docs/ErrorDetail.md +10 -0
  38. data/docs/ErrorResponse.md +8 -0
  39. data/docs/MonthDetail.md +12 -0
  40. data/docs/MonthDetailResponse.md +8 -0
  41. data/docs/MonthDetailWrapper.md +8 -0
  42. data/docs/MonthSummariesResponse.md +8 -0
  43. data/docs/MonthSummariesWrapper.md +8 -0
  44. data/docs/MonthSummary.md +11 -0
  45. data/docs/MonthsApi.md +121 -0
  46. data/docs/Payee.md +10 -0
  47. data/docs/PayeeLocation.md +11 -0
  48. data/docs/PayeeLocationResponse.md +8 -0
  49. data/docs/PayeeLocationWrapper.md +8 -0
  50. data/docs/PayeeLocationsApi.md +179 -0
  51. data/docs/PayeeLocationsResponse.md +8 -0
  52. data/docs/PayeeLocationsWrapper.md +8 -0
  53. data/docs/PayeeResponse.md +8 -0
  54. data/docs/PayeeWrapper.md +8 -0
  55. data/docs/PayeesApi.md +121 -0
  56. data/docs/PayeesResponse.md +8 -0
  57. data/docs/PayeesWrapper.md +8 -0
  58. data/docs/SaveTransaction.md +18 -0
  59. data/docs/SaveTransactionWrapper.md +8 -0
  60. data/docs/ScheduledSubTransaction.md +14 -0
  61. data/docs/ScheduledTransactionDetail.md +19 -0
  62. data/docs/ScheduledTransactionResponse.md +8 -0
  63. data/docs/ScheduledTransactionSummary.md +18 -0
  64. data/docs/ScheduledTransactionWrapper.md +8 -0
  65. data/docs/ScheduledTransactionsApi.md +121 -0
  66. data/docs/ScheduledTransactionsResponse.md +8 -0
  67. data/docs/ScheduledTransactionsWrapper.md +8 -0
  68. data/docs/SubTransaction.md +14 -0
  69. data/docs/TransactionDetail.md +20 -0
  70. data/docs/TransactionResponse.md +8 -0
  71. data/docs/TransactionSummary.md +19 -0
  72. data/docs/TransactionWrapper.md +8 -0
  73. data/docs/TransactionsApi.md +428 -0
  74. data/docs/TransactionsResponse.md +8 -0
  75. data/docs/TransactionsWrapper.md +8 -0
  76. data/examples/budget-list.rb +25 -0
  77. data/examples/budget-month.rb +36 -0
  78. data/examples/category-balance.rb +27 -0
  79. data/lib/ynab.rb +136 -0
  80. data/lib/ynab/api/accounts_api.rb +135 -0
  81. data/lib/ynab/api/budgets_api.rb +126 -0
  82. data/lib/ynab/api/categories_api.rb +135 -0
  83. data/lib/ynab/api/months_api.rb +135 -0
  84. data/lib/ynab/api/payee_locations_api.rb +194 -0
  85. data/lib/ynab/api/payees_api.rb +135 -0
  86. data/lib/ynab/api/scheduled_transactions_api.rb +135 -0
  87. data/lib/ynab/api/transactions_api.rb +451 -0
  88. data/lib/ynab/api_client.rb +392 -0
  89. data/lib/ynab/api_error.rb +38 -0
  90. data/lib/ynab/configuration.rb +209 -0
  91. data/lib/ynab/models/account.rb +343 -0
  92. data/lib/ynab/models/account_response.rb +193 -0
  93. data/lib/ynab/models/account_wrapper.rb +193 -0
  94. data/lib/ynab/models/accounts_response.rb +193 -0
  95. data/lib/ynab/models/accounts_wrapper.rb +195 -0
  96. data/lib/ynab/models/budget_detail.rb +345 -0
  97. data/lib/ynab/models/budget_detail_response.rb +193 -0
  98. data/lib/ynab/models/budget_detail_wrapper.rb +208 -0
  99. data/lib/ynab/models/budget_summary.rb +235 -0
  100. data/lib/ynab/models/budget_summary_response.rb +193 -0
  101. data/lib/ynab/models/budget_summary_wrapper.rb +195 -0
  102. data/lib/ynab/models/bulk_id_wrapper.rb +193 -0
  103. data/lib/ynab/models/bulk_ids.rb +213 -0
  104. data/lib/ynab/models/bulk_response.rb +193 -0
  105. data/lib/ynab/models/bulk_transaction_create_response.rb +193 -0
  106. data/lib/ynab/models/bulk_transaction_ids.rb +195 -0
  107. data/lib/ynab/models/bulk_transactions.rb +195 -0
  108. data/lib/ynab/models/categories_response.rb +193 -0
  109. data/lib/ynab/models/category.rb +295 -0
  110. data/lib/ynab/models/category_group.rb +222 -0
  111. data/lib/ynab/models/category_group_with_categories.rb +239 -0
  112. data/lib/ynab/models/category_groups_wrapper.rb +195 -0
  113. data/lib/ynab/models/category_response.rb +193 -0
  114. data/lib/ynab/models/category_wrapper.rb +193 -0
  115. data/lib/ynab/models/currency_format.rb +193 -0
  116. data/lib/ynab/models/date_format.rb +193 -0
  117. data/lib/ynab/models/error_detail.rb +221 -0
  118. data/lib/ynab/models/error_response.rb +193 -0
  119. data/lib/ynab/models/month_detail.rb +253 -0
  120. data/lib/ynab/models/month_detail_response.rb +193 -0
  121. data/lib/ynab/models/month_detail_wrapper.rb +193 -0
  122. data/lib/ynab/models/month_summaries_response.rb +193 -0
  123. data/lib/ynab/models/month_summaries_wrapper.rb +195 -0
  124. data/lib/ynab/models/month_summary.rb +236 -0
  125. data/lib/ynab/models/payee.rb +222 -0
  126. data/lib/ynab/models/payee_location.rb +235 -0
  127. data/lib/ynab/models/payee_location_response.rb +193 -0
  128. data/lib/ynab/models/payee_location_wrapper.rb +193 -0
  129. data/lib/ynab/models/payee_locations_response.rb +193 -0
  130. data/lib/ynab/models/payee_locations_wrapper.rb +195 -0
  131. data/lib/ynab/models/payee_response.rb +193 -0
  132. data/lib/ynab/models/payee_wrapper.rb +193 -0
  133. data/lib/ynab/models/payees_response.rb +193 -0
  134. data/lib/ynab/models/payees_wrapper.rb +195 -0
  135. data/lib/ynab/models/save_transaction.rb +346 -0
  136. data/lib/ynab/models/save_transaction_wrapper.rb +193 -0
  137. data/lib/ynab/models/scheduled_sub_transaction.rb +279 -0
  138. data/lib/ynab/models/scheduled_transaction_detail.rb +387 -0
  139. data/lib/ynab/models/scheduled_transaction_response.rb +193 -0
  140. data/lib/ynab/models/scheduled_transaction_summary.rb +370 -0
  141. data/lib/ynab/models/scheduled_transaction_wrapper.rb +193 -0
  142. data/lib/ynab/models/scheduled_transactions_response.rb +193 -0
  143. data/lib/ynab/models/scheduled_transactions_wrapper.rb +195 -0
  144. data/lib/ynab/models/sub_transaction.rb +279 -0
  145. data/lib/ynab/models/transaction_detail.rb +401 -0
  146. data/lib/ynab/models/transaction_response.rb +193 -0
  147. data/lib/ynab/models/transaction_summary.rb +384 -0
  148. data/lib/ynab/models/transaction_wrapper.rb +193 -0
  149. data/lib/ynab/models/transactions_response.rb +193 -0
  150. data/lib/ynab/models/transactions_wrapper.rb +195 -0
  151. data/lib/ynab/version.rb +15 -0
  152. data/pkg/ynab-0.1.0.gem +0 -0
  153. data/spec-v1-swagger.json +2121 -0
  154. data/spec/api/accounts_spec.rb +56 -0
  155. data/spec/api/budgets_spec.rb +55 -0
  156. data/spec/api/categories_spec.rb +57 -0
  157. data/spec/api/months_spec.rb +57 -0
  158. data/spec/api/payee_locations_spec.rb +57 -0
  159. data/spec/api/payees_spec.rb +56 -0
  160. data/spec/api/scheduled_transactions_spec.rb +56 -0
  161. data/spec/api/transactions_spec.rb +122 -0
  162. data/spec/fixtures/.DS_Store +0 -0
  163. data/spec/fixtures/vcr_cassettes/account.yml +46 -0
  164. data/spec/fixtures/vcr_cassettes/accounts.yml +46 -0
  165. data/spec/fixtures/vcr_cassettes/accounts_unauthorized.yml +49 -0
  166. data/spec/fixtures/vcr_cassettes/budget.yml +1413 -0
  167. data/spec/fixtures/vcr_cassettes/budgets.yml +49 -0
  168. data/spec/fixtures/vcr_cassettes/budgets_unauthorized.yml +49 -0
  169. data/spec/fixtures/vcr_cassettes/bulk_transactions.yml +46 -0
  170. data/spec/fixtures/vcr_cassettes/categories.yml +67 -0
  171. data/spec/fixtures/vcr_cassettes/categories_unauthorized.yml +49 -0
  172. data/spec/fixtures/vcr_cassettes/category.yml +46 -0
  173. data/spec/fixtures/vcr_cassettes/create_transaction.yml +46 -0
  174. data/spec/fixtures/vcr_cassettes/month.yml +59 -0
  175. data/spec/fixtures/vcr_cassettes/months.yml +47 -0
  176. data/spec/fixtures/vcr_cassettes/months_unauthorized.yml +49 -0
  177. data/spec/fixtures/vcr_cassettes/payee.yml +47 -0
  178. data/spec/fixtures/vcr_cassettes/payee_location.yml +46 -0
  179. data/spec/fixtures/vcr_cassettes/payee_locations.yml +46 -0
  180. data/spec/fixtures/vcr_cassettes/payee_locations_unauthorized.yml +49 -0
  181. data/spec/fixtures/vcr_cassettes/payees.yml +51 -0
  182. data/spec/fixtures/vcr_cassettes/payees_unauthorized.yml +49 -0
  183. data/spec/fixtures/vcr_cassettes/scheduled_transaction.yml +46 -0
  184. data/spec/fixtures/vcr_cassettes/scheduled_transactions.yml +46 -0
  185. data/spec/fixtures/vcr_cassettes/scheduled_transactions_unauthorized.yml +49 -0
  186. data/spec/fixtures/vcr_cassettes/transaction.yml +46 -0
  187. data/spec/fixtures/vcr_cassettes/transactions.yml +46 -0
  188. data/spec/fixtures/vcr_cassettes/transactions_unauthorized.yml +49 -0
  189. data/spec/fixtures/vcr_cassettes/update_transaction.yml +46 -0
  190. data/spec/spec_helper.rb +18 -0
  191. data/swagger-templates/api_client.mustache +386 -0
  192. data/swagger-templates/gemspec.mustache +37 -0
  193. data/ynab.gemspec +40 -0
  194. metadata +353 -0
@@ -0,0 +1,8 @@
1
+ # YnabApi::TransactionsResponse
2
+
3
+ ## Properties
4
+ Name | Type | Description | Notes
5
+ ------------ | ------------- | ------------- | -------------
6
+ **data** | [**TransactionsWrapper**](TransactionsWrapper.md) | |
7
+
8
+
@@ -0,0 +1,8 @@
1
+ # YnabApi::TransactionsWrapper
2
+
3
+ ## Properties
4
+ Name | Type | Description | Notes
5
+ ------------ | ------------- | ------------- | -------------
6
+ **transactions** | [**Array<TransactionDetail>**](TransactionDetail.md) | |
7
+
8
+
@@ -0,0 +1,25 @@
1
+ $:.unshift('../lib')
2
+ require 'ynab'
3
+
4
+ def print_budget_list
5
+ access_token = 'bf0cbb14b4330-not-real-3de12e66a389eaafe2'
6
+ ynab = YnabApi::Client.new(access_token)
7
+
8
+ puts "Fetching budgets..."
9
+ begin
10
+ budget_response = ynab.budgets.get_budgets
11
+ budgets = budget_response.data.budgets
12
+
13
+ puts "==========="
14
+ puts "BUDGET LIST"
15
+ puts "==========="
16
+
17
+ budgets.each do |budget|
18
+ puts "[id: #{budget.id}, name: #{budget.name}]"
19
+ end
20
+ rescue => e
21
+ puts "ERROR: #{e}"
22
+ end
23
+ end
24
+
25
+ print_budget_list()
@@ -0,0 +1,36 @@
1
+ $:.unshift('../lib')
2
+ require 'ynab'
3
+ require 'date'
4
+
5
+ def print_budget_month
6
+ access_token = 'bf0cbb14b4330-not-real-3de12e66a389eaafe2'
7
+ ynab = YnabApi::Client.new(access_token)
8
+
9
+ budget_id = "f968197b-2863-not-real-c2406dbe7f0d"
10
+ first_day_of_month_iso = Date.new(Date.today.year, Date.today.month, 1).iso8601
11
+
12
+ begin
13
+ puts "Fetching month..."
14
+ current_date = Date.today
15
+ first_day_of_month = Date.new(current_date.year, current_date.month, 1)
16
+ month_response = ynab.months.get_budget_month(budget_id, first_day_of_month_iso)
17
+ budget_month = month_response.data.month
18
+
19
+ puts "============"
20
+ puts "BUDGET MONTH"
21
+ puts "============"
22
+ puts " Month: #{budget_month.month}"
23
+ puts " Note: #{budget_month.note}"
24
+ puts "To Be Budgeted: #{budget_month.to_be_budgeted}"
25
+ puts " Age of Money: #{budget_month.age_of_money}"
26
+ puts " Categories: "
27
+
28
+ budget_month.categories.each do |category|
29
+ puts " #{category.name} - $#{category.balance}"
30
+ end
31
+ rescue => e
32
+ puts "ERROR: #{e}"
33
+ end
34
+ end
35
+
36
+ print_budget_month()
@@ -0,0 +1,27 @@
1
+ $:.unshift('../lib')
2
+ require 'ynab'
3
+
4
+ def print_category_info
5
+ access_token = 'bf0cbb14b4330-not-real-3de12e66a389eaafe2'
6
+ ynab = YnabApi::Client.new(access_token)
7
+
8
+ budget_id = "f968197b-2863-not-real-c2406dbe7f0d"
9
+ category_id = "a191ac84-de09-not-real-6c5ed8cfdabe"
10
+
11
+ begin
12
+ puts "Fetching category..."
13
+ category_response = ynab.categories.get_category_by_id(budget_id, category_id)
14
+ category = category_response.data.category
15
+
16
+ puts "==========="
17
+ puts "CATEGORY"
18
+ puts "==========="
19
+ puts " Name: #{category.name}"
20
+ puts " Budgeted: #{category.budgeted}"
21
+ puts " Balance: #{category.balance}"
22
+ rescue => e
23
+ puts "ERROR: #{e}"
24
+ end
25
+ end
26
+
27
+ print_category_info()
data/lib/ynab.rb ADDED
@@ -0,0 +1,136 @@
1
+ =begin
2
+ #YNAB API Endpoints
3
+
4
+ #Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.youneedabudget.com
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ # Common files
14
+ require 'ynab/api_client'
15
+ require 'ynab/api_error'
16
+ require 'ynab/version'
17
+ require 'ynab/configuration'
18
+
19
+ # Models
20
+ require 'ynab/models/account'
21
+ require 'ynab/models/account_response'
22
+ require 'ynab/models/account_wrapper'
23
+ require 'ynab/models/accounts_response'
24
+ require 'ynab/models/accounts_wrapper'
25
+ require 'ynab/models/budget_detail_response'
26
+ require 'ynab/models/budget_detail_wrapper'
27
+ require 'ynab/models/budget_summary'
28
+ require 'ynab/models/budget_summary_response'
29
+ require 'ynab/models/budget_summary_wrapper'
30
+ require 'ynab/models/categories_response'
31
+ require 'ynab/models/category'
32
+ require 'ynab/models/category_group'
33
+ require 'ynab/models/category_groups_wrapper'
34
+ require 'ynab/models/category_response'
35
+ require 'ynab/models/category_wrapper'
36
+ require 'ynab/models/currency_format'
37
+ require 'ynab/models/date_format'
38
+ require 'ynab/models/error_detail'
39
+ require 'ynab/models/error_response'
40
+ require 'ynab/models/month_detail_response'
41
+ require 'ynab/models/month_detail_wrapper'
42
+ require 'ynab/models/month_summaries_response'
43
+ require 'ynab/models/month_summaries_wrapper'
44
+ require 'ynab/models/month_summary'
45
+ require 'ynab/models/payee'
46
+ require 'ynab/models/payee_location'
47
+ require 'ynab/models/payee_location_response'
48
+ require 'ynab/models/payee_location_wrapper'
49
+ require 'ynab/models/payee_locations_response'
50
+ require 'ynab/models/payee_locations_wrapper'
51
+ require 'ynab/models/payee_response'
52
+ require 'ynab/models/payee_wrapper'
53
+ require 'ynab/models/payees_response'
54
+ require 'ynab/models/payees_wrapper'
55
+ require 'ynab/models/scheduled_sub_transaction'
56
+ require 'ynab/models/scheduled_transaction_response'
57
+ require 'ynab/models/scheduled_transaction_wrapper'
58
+ require 'ynab/models/scheduled_transactions_response'
59
+ require 'ynab/models/scheduled_transactions_wrapper'
60
+ require 'ynab/models/scheduled_transaction_summary'
61
+ require 'ynab/models/sub_transaction'
62
+ require 'ynab/models/transaction_response'
63
+ require 'ynab/models/transaction_wrapper'
64
+ require 'ynab/models/transactions_response'
65
+ require 'ynab/models/transactions_wrapper'
66
+ require 'ynab/models/transaction_summary'
67
+ require 'ynab/models/budget_detail'
68
+ require 'ynab/models/category_group_with_categories'
69
+ require 'ynab/models/month_detail'
70
+ require 'ynab/models/scheduled_transaction_detail'
71
+ require 'ynab/models/transaction_detail'
72
+ require 'ynab/models/transaction_detail'
73
+ require 'ynab/models/bulk_id_wrapper'
74
+ require 'ynab/models/bulk_ids'
75
+ require 'ynab/models/bulk_response'
76
+
77
+ # APIs
78
+ require 'ynab/api/accounts_api'
79
+ require 'ynab/api/budgets_api'
80
+ require 'ynab/api/categories_api'
81
+ require 'ynab/api/months_api'
82
+ require 'ynab/api/payee_locations_api'
83
+ require 'ynab/api/payees_api'
84
+ require 'ynab/api/scheduled_transactions_api'
85
+ require 'ynab/api/transactions_api'
86
+
87
+ module YnabApi
88
+ class Client
89
+ def initialize(access_token, host = 'api.youneedabudget.com', useHttps = true)
90
+ config = Configuration.default
91
+ config.api_key['Authorization'] = access_token
92
+ config.api_key_prefix['Authorization'] = 'Bearer'
93
+ config.scheme = useHttps ? 'https' : 'http'
94
+ config.host = host
95
+ config.base_path = '/v1'
96
+
97
+ @client = ApiClient.new(config)
98
+ end
99
+
100
+ def budgets
101
+ BudgetsApi.new(@client)
102
+ end
103
+
104
+ def accounts
105
+ AccountsApi.new(@client)
106
+ end
107
+
108
+ def categories
109
+ CategoriesApi.new(@client)
110
+ end
111
+
112
+ def months
113
+ MonthsApi.new(@client)
114
+ end
115
+
116
+ def payees
117
+ PayeesApi.new(@client)
118
+ end
119
+
120
+ def payee_locations
121
+ PayeeLocationsApi.new(@client)
122
+ end
123
+
124
+ def transactions
125
+ TransactionsApi.new(@client)
126
+ end
127
+
128
+ def scheduled_transactions
129
+ ScheduledTransactionsApi.new(@client)
130
+ end
131
+
132
+ def last_request
133
+ @client.last_request
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,135 @@
1
+ =begin
2
+ #YNAB API Endpoints
3
+
4
+ #Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.youneedabudget.com
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require "uri"
14
+
15
+ module YnabApi
16
+ class AccountsApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+
23
+ # Single account
24
+ # Returns a single account
25
+ # @param budget_id The ID of the Budget.
26
+ # @param account_id The ID of the Account.
27
+ # @param [Hash] opts the optional parameters
28
+ # @return [AccountResponse]
29
+ def get_account_by_id(budget_id, account_id, opts = {})
30
+ data, _status_code, _headers = get_account_by_id_with_http_info(budget_id, account_id, opts)
31
+ return data
32
+ end
33
+
34
+ # Single account
35
+ # Returns a single account
36
+ # @param budget_id The ID of the Budget.
37
+ # @param account_id The ID of the Account.
38
+ # @param [Hash] opts the optional parameters
39
+ # @return [Array<(AccountResponse, Fixnum, Hash)>] AccountResponse data, response status code and response headers
40
+ def get_account_by_id_with_http_info(budget_id, account_id, opts = {})
41
+ if @api_client.config.debugging
42
+ @api_client.config.logger.debug "Calling API: AccountsApi.get_account_by_id ..."
43
+ end
44
+ # verify the required parameter 'budget_id' is set
45
+ if @api_client.config.client_side_validation && budget_id.nil?
46
+ fail ArgumentError, "Missing the required parameter 'budget_id' when calling AccountsApi.get_account_by_id"
47
+ end
48
+ # verify the required parameter 'account_id' is set
49
+ if @api_client.config.client_side_validation && account_id.nil?
50
+ fail ArgumentError, "Missing the required parameter 'account_id' when calling AccountsApi.get_account_by_id"
51
+ end
52
+ # resource path
53
+ local_var_path = "/budgets/{budget_id}/accounts/{account_id}".sub('{' + 'budget_id' + '}', budget_id.to_s).sub('{' + 'account_id' + '}', account_id.to_s)
54
+
55
+ # query parameters
56
+ query_params = {}
57
+
58
+ # header parameters
59
+ header_params = {}
60
+ # HTTP header 'Accept' (if needed)
61
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
62
+
63
+ # form parameters
64
+ form_params = {}
65
+
66
+ # http body (model)
67
+ post_body = nil
68
+ auth_names = ['bearer']
69
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
70
+ :header_params => header_params,
71
+ :query_params => query_params,
72
+ :form_params => form_params,
73
+ :body => post_body,
74
+ :auth_names => auth_names,
75
+ :return_type => 'AccountResponse')
76
+ if @api_client.config.debugging
77
+ @api_client.config.logger.debug "API called: AccountsApi#get_account_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
78
+ end
79
+ return data, status_code, headers
80
+ end
81
+
82
+ # Account list
83
+ # Returns all accounts
84
+ # @param budget_id The ID of the Budget.
85
+ # @param [Hash] opts the optional parameters
86
+ # @return [AccountsResponse]
87
+ def get_accounts(budget_id, opts = {})
88
+ data, _status_code, _headers = get_accounts_with_http_info(budget_id, opts)
89
+ return data
90
+ end
91
+
92
+ # Account list
93
+ # Returns all accounts
94
+ # @param budget_id The ID of the Budget.
95
+ # @param [Hash] opts the optional parameters
96
+ # @return [Array<(AccountsResponse, Fixnum, Hash)>] AccountsResponse data, response status code and response headers
97
+ def get_accounts_with_http_info(budget_id, opts = {})
98
+ if @api_client.config.debugging
99
+ @api_client.config.logger.debug "Calling API: AccountsApi.get_accounts ..."
100
+ end
101
+ # verify the required parameter 'budget_id' is set
102
+ if @api_client.config.client_side_validation && budget_id.nil?
103
+ fail ArgumentError, "Missing the required parameter 'budget_id' when calling AccountsApi.get_accounts"
104
+ end
105
+ # resource path
106
+ local_var_path = "/budgets/{budget_id}/accounts".sub('{' + 'budget_id' + '}', budget_id.to_s)
107
+
108
+ # query parameters
109
+ query_params = {}
110
+
111
+ # header parameters
112
+ header_params = {}
113
+ # HTTP header 'Accept' (if needed)
114
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
115
+
116
+ # form parameters
117
+ form_params = {}
118
+
119
+ # http body (model)
120
+ post_body = nil
121
+ auth_names = ['bearer']
122
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
123
+ :header_params => header_params,
124
+ :query_params => query_params,
125
+ :form_params => form_params,
126
+ :body => post_body,
127
+ :auth_names => auth_names,
128
+ :return_type => 'AccountsResponse')
129
+ if @api_client.config.debugging
130
+ @api_client.config.logger.debug "API called: AccountsApi#get_accounts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
131
+ end
132
+ return data, status_code, headers
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,126 @@
1
+ =begin
2
+ #YNAB API Endpoints
3
+
4
+ #Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.youneedabudget.com
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require "uri"
14
+
15
+ module YnabApi
16
+ class BudgetsApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+
23
+ # Single budget
24
+ # Returns a single budget with all related entities. This resource is effectively a full budget export.
25
+ # @param budget_id The ID of the Budget.
26
+ # @param [Hash] opts the optional parameters
27
+ # @option opts [Float] :last_knowledge_of_server The starting server knowledge. If provided, only entities that have changed since last_knowledge_of_server will be included.
28
+ # @return [BudgetDetailResponse]
29
+ def get_budget_by_id(budget_id, opts = {})
30
+ data, _status_code, _headers = get_budget_by_id_with_http_info(budget_id, opts)
31
+ return data
32
+ end
33
+
34
+ # Single budget
35
+ # Returns a single budget with all related entities. This resource is effectively a full budget export.
36
+ # @param budget_id The ID of the Budget.
37
+ # @param [Hash] opts the optional parameters
38
+ # @option opts [Float] :last_knowledge_of_server The starting server knowledge. If provided, only entities that have changed since last_knowledge_of_server will be included.
39
+ # @return [Array<(BudgetDetailResponse, Fixnum, Hash)>] BudgetDetailResponse data, response status code and response headers
40
+ def get_budget_by_id_with_http_info(budget_id, opts = {})
41
+ if @api_client.config.debugging
42
+ @api_client.config.logger.debug "Calling API: BudgetsApi.get_budget_by_id ..."
43
+ end
44
+ # verify the required parameter 'budget_id' is set
45
+ if @api_client.config.client_side_validation && budget_id.nil?
46
+ fail ArgumentError, "Missing the required parameter 'budget_id' when calling BudgetsApi.get_budget_by_id"
47
+ end
48
+ # resource path
49
+ local_var_path = "/budgets/{budget_id}".sub('{' + 'budget_id' + '}', budget_id.to_s)
50
+
51
+ # query parameters
52
+ query_params = {}
53
+ query_params[:'last_knowledge_of_server'] = opts[:'last_knowledge_of_server'] if !opts[:'last_knowledge_of_server'].nil?
54
+
55
+ # header parameters
56
+ header_params = {}
57
+ # HTTP header 'Accept' (if needed)
58
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
59
+
60
+ # form parameters
61
+ form_params = {}
62
+
63
+ # http body (model)
64
+ post_body = nil
65
+ auth_names = ['bearer']
66
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
67
+ :header_params => header_params,
68
+ :query_params => query_params,
69
+ :form_params => form_params,
70
+ :body => post_body,
71
+ :auth_names => auth_names,
72
+ :return_type => 'BudgetDetailResponse')
73
+ if @api_client.config.debugging
74
+ @api_client.config.logger.debug "API called: BudgetsApi#get_budget_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
75
+ end
76
+ return data, status_code, headers
77
+ end
78
+
79
+ # List budgets
80
+ # Returns budgets list with summary information.
81
+ # @param [Hash] opts the optional parameters
82
+ # @return [BudgetSummaryResponse]
83
+ def get_budgets(opts = {})
84
+ data, _status_code, _headers = get_budgets_with_http_info(opts)
85
+ return data
86
+ end
87
+
88
+ # List budgets
89
+ # Returns budgets list with summary information.
90
+ # @param [Hash] opts the optional parameters
91
+ # @return [Array<(BudgetSummaryResponse, Fixnum, Hash)>] BudgetSummaryResponse data, response status code and response headers
92
+ def get_budgets_with_http_info(opts = {})
93
+ if @api_client.config.debugging
94
+ @api_client.config.logger.debug "Calling API: BudgetsApi.get_budgets ..."
95
+ end
96
+ # resource path
97
+ local_var_path = "/budgets"
98
+
99
+ # query parameters
100
+ query_params = {}
101
+
102
+ # header parameters
103
+ header_params = {}
104
+ # HTTP header 'Accept' (if needed)
105
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
106
+
107
+ # form parameters
108
+ form_params = {}
109
+
110
+ # http body (model)
111
+ post_body = nil
112
+ auth_names = ['bearer']
113
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
114
+ :header_params => header_params,
115
+ :query_params => query_params,
116
+ :form_params => form_params,
117
+ :body => post_body,
118
+ :auth_names => auth_names,
119
+ :return_type => 'BudgetSummaryResponse')
120
+ if @api_client.config.debugging
121
+ @api_client.config.logger.debug "API called: BudgetsApi#get_budgets\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
122
+ end
123
+ return data, status_code, headers
124
+ end
125
+ end
126
+ end