ynab 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -30
- data/lib/ynab.rb +4 -1
- data/lib/ynab/api/categories_api.rb +10 -10
- data/lib/ynab/api/deprecated_api.rb +81 -0
- data/lib/ynab/api/months_api.rb +2 -2
- data/lib/ynab/api/payee_locations_api.rb +2 -2
- data/lib/ynab/api/transactions_api.rb +12 -58
- data/lib/ynab/models/bulk_ids.rb +1 -1
- data/lib/ynab/models/category.rb +3 -3
- data/lib/ynab/models/category_group_with_categories.rb +1 -1
- data/lib/ynab/models/month_detail.rb +1 -1
- data/lib/ynab/models/transactions_wrapper.rb +19 -4
- data/lib/ynab/overrides/transactions_api.rb +44 -0
- data/lib/ynab/version.rb +1 -1
- data/spec/api/transactions_spec.rb +23 -1
- data/spec/fixtures/vcr_cassettes/create_transactions.yml +46 -0
- metadata +6 -105
- data/Gemfile +0 -7
- data/Gemfile.lock +0 -44
- data/Rakefile +0 -34
- data/config.json +0 -10
- data/docs/Account.md +0 -18
- data/docs/AccountResponse.md +0 -8
- data/docs/AccountWrapper.md +0 -8
- data/docs/AccountsApi.md +0 -45
- data/docs/AccountsResponse.md +0 -8
- data/docs/AccountsWrapper.md +0 -8
- data/docs/BudgetDetail.md +0 -22
- data/docs/BudgetDetailResponse.md +0 -8
- data/docs/BudgetDetailWrapper.md +0 -9
- data/docs/BudgetSettings.md +0 -9
- data/docs/BudgetSettingsResponse.md +0 -8
- data/docs/BudgetSettingsWrapper.md +0 -8
- data/docs/BudgetSummary.md +0 -12
- data/docs/BudgetSummaryResponse.md +0 -8
- data/docs/BudgetSummaryWrapper.md +0 -8
- data/docs/BudgetsApi.md +0 -60
- data/docs/BulkIdWrapper.md +0 -8
- data/docs/BulkIds.md +0 -9
- data/docs/BulkResponse.md +0 -8
- data/docs/BulkTransactionCreateResponse.md +0 -8
- data/docs/BulkTransactionIds.md +0 -8
- data/docs/BulkTransactions.md +0 -8
- data/docs/CategoriesApi.md +0 -86
- data/docs/CategoriesResponse.md +0 -8
- data/docs/Category.md +0 -22
- data/docs/CategoryGroup.md +0 -11
- data/docs/CategoryGroupWithCategories.md +0 -12
- data/docs/CategoryGroupsWrapper.md +0 -8
- data/docs/CategoryResponse.md +0 -8
- data/docs/CategoryWrapper.md +0 -8
- data/docs/CurrencyFormat.md +0 -15
- data/docs/DateFormat.md +0 -8
- data/docs/ErrorDetail.md +0 -10
- data/docs/ErrorResponse.md +0 -8
- data/docs/HybridTransaction.md +0 -26
- data/docs/HybridTransactionsResponse.md +0 -8
- data/docs/HybridTransactionsWrapper.md +0 -8
- data/docs/MonthDetail.md +0 -15
- data/docs/MonthDetailResponse.md +0 -8
- data/docs/MonthDetailWrapper.md +0 -8
- data/docs/MonthSummariesResponse.md +0 -8
- data/docs/MonthSummariesWrapper.md +0 -8
- data/docs/MonthSummary.md +0 -14
- data/docs/MonthsApi.md +0 -45
- data/docs/Payee.md +0 -11
- data/docs/PayeeLocation.md +0 -12
- data/docs/PayeeLocationResponse.md +0 -8
- data/docs/PayeeLocationWrapper.md +0 -8
- data/docs/PayeeLocationsApi.md +0 -64
- data/docs/PayeeLocationsResponse.md +0 -8
- data/docs/PayeeLocationsWrapper.md +0 -8
- data/docs/PayeeResponse.md +0 -8
- data/docs/PayeeWrapper.md +0 -8
- data/docs/PayeesApi.md +0 -45
- data/docs/PayeesResponse.md +0 -8
- data/docs/PayeesWrapper.md +0 -8
- data/docs/SaveMonthCategory.md +0 -8
- data/docs/SaveMonthCategoryWrapper.md +0 -8
- data/docs/SaveTransaction.md +0 -18
- data/docs/SaveTransactionWrapper.md +0 -8
- data/docs/SaveTransactionsResponse.md +0 -8
- data/docs/SaveTransactionsResponseData.md +0 -11
- data/docs/SaveTransactionsWrapper.md +0 -9
- data/docs/ScheduledSubTransaction.md +0 -15
- data/docs/ScheduledTransactionDetail.md +0 -23
- data/docs/ScheduledTransactionResponse.md +0 -8
- data/docs/ScheduledTransactionSummary.md +0 -19
- data/docs/ScheduledTransactionWrapper.md +0 -8
- data/docs/ScheduledTransactionsApi.md +0 -45
- data/docs/ScheduledTransactionsResponse.md +0 -8
- data/docs/ScheduledTransactionsWrapper.md +0 -8
- data/docs/SubTransaction.md +0 -15
- data/docs/TransactionDetail.md +0 -25
- data/docs/TransactionResponse.md +0 -8
- data/docs/TransactionSummary.md +0 -21
- data/docs/TransactionWrapper.md +0 -8
- data/docs/TransactionsApi.md +0 -168
- data/docs/TransactionsResponse.md +0 -8
- data/docs/TransactionsWrapper.md +0 -8
- data/docs/User.md +0 -8
- data/docs/UserApi.md +0 -23
- data/docs/UserResponse.md +0 -8
- data/docs/UserWrapper.md +0 -8
- data/examples/budget-list.rb +0 -24
- data/examples/budget-month.rb +0 -35
- data/examples/category-balance.rb +0 -26
- data/examples/create-multiple-transactions.rb +0 -44
- data/examples/create-transaction.rb +0 -31
- data/examples/update-category-budgeted.rb +0 -23
- data/pkg/ynab-1.0.0.gem +0 -0
- data/pkg/ynab-1.1.0.gem +0 -0
- data/pkg/ynab-1.3.0.gem +0 -0
- data/pkg/ynab-1.4.0.gem +0 -0
- data/spec-v1-swagger.json +0 -2729
- data/swagger-templates/api_client.mustache +0 -386
- data/swagger-templates/api_doc.mustache +0 -32
- data/swagger-templates/gem.mustache +0 -83
- data/swagger-templates/gemspec.mustache +0 -37
- data/ynab.gemspec +0 -40
@@ -1,386 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
{{> api_info}}
|
3
|
-
=end
|
4
|
-
|
5
|
-
require 'date'
|
6
|
-
require 'json'
|
7
|
-
require 'logger'
|
8
|
-
require 'tempfile'
|
9
|
-
require 'typhoeus'
|
10
|
-
require 'uri'
|
11
|
-
|
12
|
-
module {{moduleName}}
|
13
|
-
class ApiClient
|
14
|
-
# The Configuration object holding settings to be used in the API client.
|
15
|
-
attr_accessor :config
|
16
|
-
|
17
|
-
# Defines the headers to be used in HTTP requests of all API calls by default.
|
18
|
-
#
|
19
|
-
# @return [Hash]
|
20
|
-
attr_accessor :default_headers
|
21
|
-
|
22
|
-
attr_accessor :last_request
|
23
|
-
|
24
|
-
# Initializes the ApiClient
|
25
|
-
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
26
|
-
def initialize(config = Configuration.default)
|
27
|
-
@config = config
|
28
|
-
@user_agent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}api_client/ruby/#{VERSION}{{/httpUserAgent}}"
|
29
|
-
@default_headers = {
|
30
|
-
'Content-Type' => "application/json",
|
31
|
-
'User-Agent' => @user_agent
|
32
|
-
}
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.default
|
36
|
-
@@default ||= ApiClient.new
|
37
|
-
end
|
38
|
-
|
39
|
-
# Call an API with given options.
|
40
|
-
#
|
41
|
-
# @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
|
42
|
-
# the data deserialized from response body (could be nil), response status code and response headers.
|
43
|
-
def call_api(http_method, path, opts = {})
|
44
|
-
request = build_request(http_method, path, opts)
|
45
|
-
@last_request = request
|
46
|
-
response = request.run
|
47
|
-
|
48
|
-
if @config.debugging
|
49
|
-
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
50
|
-
end
|
51
|
-
|
52
|
-
unless response.success?
|
53
|
-
if response.timed_out?
|
54
|
-
fail ApiError.new('Connection timed out')
|
55
|
-
elsif response.code == 0
|
56
|
-
# Errors from libcurl will be made visible here
|
57
|
-
fail ApiError.new(:code => 0,
|
58
|
-
:message => response.return_message)
|
59
|
-
else
|
60
|
-
fail ApiError.new(:code => response.code,
|
61
|
-
:response_headers => response.headers,
|
62
|
-
:response_body => response.body),
|
63
|
-
response.status_message
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
if opts[:return_type]
|
68
|
-
data = deserialize(response, opts[:return_type])
|
69
|
-
else
|
70
|
-
data = nil
|
71
|
-
end
|
72
|
-
return data, response.code, response.headers
|
73
|
-
end
|
74
|
-
|
75
|
-
# Builds the HTTP request
|
76
|
-
#
|
77
|
-
# @param [String] http_method HTTP method/verb (e.g. POST)
|
78
|
-
# @param [String] path URL path (e.g. /account/new)
|
79
|
-
# @option opts [Hash] :header_params Header parameters
|
80
|
-
# @option opts [Hash] :query_params Query parameters
|
81
|
-
# @option opts [Hash] :form_params Query parameters
|
82
|
-
# @option opts [Object] :body HTTP body (JSON/XML)
|
83
|
-
# @return [Typhoeus::Request] A Typhoeus Request
|
84
|
-
def build_request(http_method, path, opts = {})
|
85
|
-
url = build_request_url(path)
|
86
|
-
http_method = http_method.to_sym.downcase
|
87
|
-
|
88
|
-
header_params = @default_headers.merge(opts[:header_params] || {})
|
89
|
-
query_params = opts[:query_params] || {}
|
90
|
-
form_params = opts[:form_params] || {}
|
91
|
-
|
92
|
-
{{#hasAuthMethods}}
|
93
|
-
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
94
|
-
{{/hasAuthMethods}}
|
95
|
-
|
96
|
-
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
97
|
-
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
98
|
-
|
99
|
-
req_opts = {
|
100
|
-
:method => http_method,
|
101
|
-
:headers => header_params,
|
102
|
-
:params => query_params,
|
103
|
-
:params_encoding => @config.params_encoding,
|
104
|
-
:timeout => @config.timeout,
|
105
|
-
:ssl_verifypeer => @config.verify_ssl,
|
106
|
-
:ssl_verifyhost => _verify_ssl_host,
|
107
|
-
:sslcert => @config.cert_file,
|
108
|
-
:sslkey => @config.key_file,
|
109
|
-
:verbose => @config.debugging
|
110
|
-
}
|
111
|
-
|
112
|
-
# set custom cert, if provided
|
113
|
-
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
114
|
-
|
115
|
-
if [:post, :patch, :put, :delete].include?(http_method)
|
116
|
-
req_body = build_request_body(header_params, form_params, opts[:body])
|
117
|
-
req_opts.update :body => req_body
|
118
|
-
if @config.debugging
|
119
|
-
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
request = Typhoeus::Request.new(url, req_opts)
|
124
|
-
download_file(request) if opts[:return_type] == 'File'
|
125
|
-
request
|
126
|
-
end
|
127
|
-
|
128
|
-
# Check if the given MIME is a JSON MIME.
|
129
|
-
# JSON MIME examples:
|
130
|
-
# application/json
|
131
|
-
# application/json; charset=UTF8
|
132
|
-
# APPLICATION/JSON
|
133
|
-
# */*
|
134
|
-
# @param [String] mime MIME
|
135
|
-
# @return [Boolean] True if the MIME is application/json
|
136
|
-
def json_mime?(mime)
|
137
|
-
(mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
138
|
-
end
|
139
|
-
|
140
|
-
# Deserialize the response to the given return type.
|
141
|
-
#
|
142
|
-
# @param [Response] response HTTP response
|
143
|
-
# @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
|
144
|
-
def deserialize(response, return_type)
|
145
|
-
body = response.body
|
146
|
-
|
147
|
-
# handle file downloading - return the File instance processed in request callbacks
|
148
|
-
# note that response body is empty when the file is written in chunks in request on_body callback
|
149
|
-
return @tempfile if return_type == 'File'
|
150
|
-
|
151
|
-
return nil if body.nil? || body.empty?
|
152
|
-
|
153
|
-
# return response body directly for String return type
|
154
|
-
return body if return_type == 'String'
|
155
|
-
|
156
|
-
# ensuring a default content type
|
157
|
-
content_type = response.headers['Content-Type'] || 'application/json'
|
158
|
-
|
159
|
-
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
|
160
|
-
|
161
|
-
begin
|
162
|
-
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
163
|
-
rescue JSON::ParserError => e
|
164
|
-
if %w(String Date DateTime).include?(return_type)
|
165
|
-
data = body
|
166
|
-
else
|
167
|
-
raise e
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
convert_to_type data, return_type
|
172
|
-
end
|
173
|
-
|
174
|
-
# Convert data to the given return type.
|
175
|
-
# @param [Object] data Data to be converted
|
176
|
-
# @param [String] return_type Return type
|
177
|
-
# @return [Mixed] Data in a particular type
|
178
|
-
def convert_to_type(data, return_type)
|
179
|
-
return nil if data.nil?
|
180
|
-
case return_type
|
181
|
-
when 'String'
|
182
|
-
data.to_s
|
183
|
-
when 'Integer'
|
184
|
-
data.to_i
|
185
|
-
when 'Float'
|
186
|
-
data.to_f
|
187
|
-
when 'BOOLEAN'
|
188
|
-
data == true
|
189
|
-
when 'DateTime'
|
190
|
-
# parse date time (expecting ISO 8601 format)
|
191
|
-
DateTime.parse data
|
192
|
-
when 'Date'
|
193
|
-
# parse date time (expecting ISO 8601 format)
|
194
|
-
Date.parse data
|
195
|
-
when 'Object'
|
196
|
-
# generic object (usually a Hash), return directly
|
197
|
-
data
|
198
|
-
when /\AArray<(.+)>\z/
|
199
|
-
# e.g. Array<Pet>
|
200
|
-
sub_type = $1
|
201
|
-
data.map {|item| convert_to_type(item, sub_type) }
|
202
|
-
when /\AHash\<String, (.+)\>\z/
|
203
|
-
# e.g. Hash<String, Integer>
|
204
|
-
sub_type = $1
|
205
|
-
{}.tap do |hash|
|
206
|
-
data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
|
207
|
-
end
|
208
|
-
else
|
209
|
-
# models, e.g. Pet
|
210
|
-
{{moduleName}}.const_get(return_type).new.tap do |model|
|
211
|
-
model.build_from_hash data
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
# Save response body into a file in (the defined) temporary folder, using the filename
|
217
|
-
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
218
|
-
# The response body is written to the file in chunks in order to handle files which
|
219
|
-
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
220
|
-
# process can use.
|
221
|
-
#
|
222
|
-
# @see Configuration#temp_folder_path
|
223
|
-
def download_file(request)
|
224
|
-
tempfile = nil
|
225
|
-
encoding = nil
|
226
|
-
request.on_headers do |response|
|
227
|
-
content_disposition = response.headers['Content-Disposition']
|
228
|
-
if content_disposition and content_disposition =~ /filename=/i
|
229
|
-
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
230
|
-
prefix = sanitize_filename(filename)
|
231
|
-
else
|
232
|
-
prefix = 'download-'
|
233
|
-
end
|
234
|
-
prefix = prefix + '-' unless prefix.end_with?('-')
|
235
|
-
encoding = response.body.encoding
|
236
|
-
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
237
|
-
@tempfile = tempfile
|
238
|
-
end
|
239
|
-
request.on_body do |chunk|
|
240
|
-
chunk.force_encoding(encoding)
|
241
|
-
tempfile.write(chunk)
|
242
|
-
end
|
243
|
-
request.on_complete do |response|
|
244
|
-
tempfile.close
|
245
|
-
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
246
|
-
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
247
|
-
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
248
|
-
"explicitly with `tempfile.delete`"
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
# Sanitize filename by removing path.
|
253
|
-
# e.g. ../../sun.gif becomes sun.gif
|
254
|
-
#
|
255
|
-
# @param [String] filename the filename to be sanitized
|
256
|
-
# @return [String] the sanitized filename
|
257
|
-
def sanitize_filename(filename)
|
258
|
-
filename.gsub(/.*[\/\\]/, '')
|
259
|
-
end
|
260
|
-
|
261
|
-
def build_request_url(path)
|
262
|
-
# Add leading and trailing slashes to path
|
263
|
-
path = "/#{path}".gsub(/\/+/, '/')
|
264
|
-
URI.encode(@config.base_url + path)
|
265
|
-
end
|
266
|
-
|
267
|
-
# Builds the HTTP request body
|
268
|
-
#
|
269
|
-
# @param [Hash] header_params Header parameters
|
270
|
-
# @param [Hash] form_params Query parameters
|
271
|
-
# @param [Object] body HTTP body (JSON/XML)
|
272
|
-
# @return [String] HTTP body data in the form of string
|
273
|
-
def build_request_body(header_params, form_params, body)
|
274
|
-
# http form
|
275
|
-
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
276
|
-
header_params['Content-Type'] == 'multipart/form-data'
|
277
|
-
data = {}
|
278
|
-
form_params.each do |key, value|
|
279
|
-
case value
|
280
|
-
when ::File, ::Array, nil
|
281
|
-
# let typhoeus handle File, Array and nil parameters
|
282
|
-
data[key] = value
|
283
|
-
else
|
284
|
-
data[key] = value.to_s
|
285
|
-
end
|
286
|
-
end
|
287
|
-
elsif body
|
288
|
-
data = body.is_a?(String) ? body : body.to_json
|
289
|
-
else
|
290
|
-
data = nil
|
291
|
-
end
|
292
|
-
data
|
293
|
-
end
|
294
|
-
|
295
|
-
# Update hearder and query params based on authentication settings.
|
296
|
-
#
|
297
|
-
# @param [Hash] header_params Header parameters
|
298
|
-
# @param [Hash] query_params Query parameters
|
299
|
-
# @param [String] auth_names Authentication scheme name
|
300
|
-
def update_params_for_auth!(header_params, query_params, auth_names)
|
301
|
-
Array(auth_names).each do |auth_name|
|
302
|
-
auth_setting = @config.auth_settings[auth_name]
|
303
|
-
next unless auth_setting
|
304
|
-
case auth_setting[:in]
|
305
|
-
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
|
306
|
-
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
|
307
|
-
else fail ArgumentError, 'Authentication token must be in `query` of `header`'
|
308
|
-
end
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
# Sets user agent in HTTP header
|
313
|
-
#
|
314
|
-
# @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
|
315
|
-
def user_agent=(user_agent)
|
316
|
-
@user_agent = user_agent
|
317
|
-
@default_headers['User-Agent'] = @user_agent
|
318
|
-
end
|
319
|
-
|
320
|
-
# Return Accept header based on an array of accepts provided.
|
321
|
-
# @param [Array] accepts array for Accept
|
322
|
-
# @return [String] the Accept header (e.g. application/json)
|
323
|
-
def select_header_accept(accepts)
|
324
|
-
return nil if accepts.nil? || accepts.empty?
|
325
|
-
# use JSON when present, otherwise use all of the provided
|
326
|
-
json_accept = accepts.find { |s| json_mime?(s) }
|
327
|
-
return json_accept || accepts.join(',')
|
328
|
-
end
|
329
|
-
|
330
|
-
# Return Content-Type header based on an array of content types provided.
|
331
|
-
# @param [Array] content_types array for Content-Type
|
332
|
-
# @return [String] the Content-Type header (e.g. application/json)
|
333
|
-
def select_header_content_type(content_types)
|
334
|
-
# use application/json by default
|
335
|
-
return 'application/json' if content_types.nil? || content_types.empty?
|
336
|
-
# use JSON when present, otherwise use the first one
|
337
|
-
json_content_type = content_types.find { |s| json_mime?(s) }
|
338
|
-
return json_content_type || content_types.first
|
339
|
-
end
|
340
|
-
|
341
|
-
# Convert object (array, hash, object, etc) to JSON string.
|
342
|
-
# @param [Object] model object to be converted into JSON string
|
343
|
-
# @return [String] JSON string representation of the object
|
344
|
-
def object_to_http_body(model)
|
345
|
-
return model if model.nil? || model.is_a?(String)
|
346
|
-
local_body = nil
|
347
|
-
if model.is_a?(Array)
|
348
|
-
local_body = model.map{|m| object_to_hash(m) }
|
349
|
-
else
|
350
|
-
local_body = object_to_hash(model)
|
351
|
-
end
|
352
|
-
local_body.to_json
|
353
|
-
end
|
354
|
-
|
355
|
-
# Convert object(non-array) to hash.
|
356
|
-
# @param [Object] obj object to be converted into JSON string
|
357
|
-
# @return [String] JSON string representation of the object
|
358
|
-
def object_to_hash(obj)
|
359
|
-
if obj.respond_to?(:to_hash)
|
360
|
-
obj.to_hash
|
361
|
-
else
|
362
|
-
obj
|
363
|
-
end
|
364
|
-
end
|
365
|
-
|
366
|
-
# Build parameter value according to the given collection format.
|
367
|
-
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
|
368
|
-
def build_collection_param(param, collection_format)
|
369
|
-
case collection_format
|
370
|
-
when :csv
|
371
|
-
param.join(',')
|
372
|
-
when :ssv
|
373
|
-
param.join(' ')
|
374
|
-
when :tsv
|
375
|
-
param.join("\t")
|
376
|
-
when :pipes
|
377
|
-
param.join('|')
|
378
|
-
when :multi
|
379
|
-
# return the array directly as typhoeus will handle it as expected
|
380
|
-
param
|
381
|
-
else
|
382
|
-
fail "unknown collection format: #{collection_format.inspect}"
|
383
|
-
end
|
384
|
-
end
|
385
|
-
end
|
386
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# {{moduleName}}::{{classname}}{{#description}}
|
2
|
-
{{description}}{{/description}}
|
3
|
-
|
4
|
-
All URIs are relative to *{{basePath}}*
|
5
|
-
|
6
|
-
Method | HTTP request | Description
|
7
|
-
------------- | ------------- | -------------
|
8
|
-
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
9
|
-
{{/operation}}{{/operations}}
|
10
|
-
|
11
|
-
{{#operations}}
|
12
|
-
{{#operation}}
|
13
|
-
# **{{operationId}}**
|
14
|
-
> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}{{#hasParams}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}){{/hasParams}}
|
15
|
-
|
16
|
-
{{{summary}}}{{#notes}}
|
17
|
-
|
18
|
-
{{{notes}}}{{/notes}}
|
19
|
-
|
20
|
-
### Parameters
|
21
|
-
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
|
22
|
-
Name | Type | Description | Notes
|
23
|
-
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
|
24
|
-
{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
|
25
|
-
{{/allParams}}
|
26
|
-
|
27
|
-
### Return type
|
28
|
-
|
29
|
-
{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}nil (empty response body){{/returnType}}
|
30
|
-
|
31
|
-
{{/operation}}
|
32
|
-
{{/operations}}
|
@@ -1,83 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
{{> api_info}}
|
3
|
-
=end
|
4
|
-
|
5
|
-
# Common files
|
6
|
-
require '{{gemName}}/api_client'
|
7
|
-
require '{{gemName}}/api_error'
|
8
|
-
require '{{gemName}}/version'
|
9
|
-
require '{{gemName}}/configuration'
|
10
|
-
|
11
|
-
# Models
|
12
|
-
{{#models}}
|
13
|
-
{{#model}}
|
14
|
-
require '{{gemName}}/{{modelPackage}}/{{classFilename}}'{{/model}}
|
15
|
-
{{/models}}
|
16
|
-
|
17
|
-
# APIs
|
18
|
-
{{#apiInfo}}
|
19
|
-
{{#apis}}
|
20
|
-
require '{{importPath}}'
|
21
|
-
{{/apis}}
|
22
|
-
{{/apiInfo}}
|
23
|
-
|
24
|
-
module {{moduleName}}
|
25
|
-
class API
|
26
|
-
def initialize(access_token, host = 'api.youneedabudget.com', useHttps = true)
|
27
|
-
config = Configuration.default
|
28
|
-
config.api_key['Authorization'] = access_token
|
29
|
-
config.api_key_prefix['Authorization'] = 'Bearer'
|
30
|
-
config.scheme = useHttps ? 'https' : 'http'
|
31
|
-
config.host = host
|
32
|
-
config.base_path = '/v1'
|
33
|
-
|
34
|
-
@client = ApiClient.new(config)
|
35
|
-
end
|
36
|
-
|
37
|
-
def user
|
38
|
-
UserApi.new(@client)
|
39
|
-
end
|
40
|
-
|
41
|
-
def budgets
|
42
|
-
BudgetsApi.new(@client)
|
43
|
-
end
|
44
|
-
|
45
|
-
def accounts
|
46
|
-
AccountsApi.new(@client)
|
47
|
-
end
|
48
|
-
|
49
|
-
def categories
|
50
|
-
CategoriesApi.new(@client)
|
51
|
-
end
|
52
|
-
|
53
|
-
def months
|
54
|
-
MonthsApi.new(@client)
|
55
|
-
end
|
56
|
-
|
57
|
-
def payees
|
58
|
-
PayeesApi.new(@client)
|
59
|
-
end
|
60
|
-
|
61
|
-
def payee_locations
|
62
|
-
PayeeLocationsApi.new(@client)
|
63
|
-
end
|
64
|
-
|
65
|
-
def transactions
|
66
|
-
TransactionsApi.new(@client)
|
67
|
-
end
|
68
|
-
|
69
|
-
def scheduled_transactions
|
70
|
-
ScheduledTransactionsApi.new(@client)
|
71
|
-
end
|
72
|
-
|
73
|
-
def last_request
|
74
|
-
@client.last_request
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Support old interface: YnabApi::Client
|
80
|
-
module YnabApi
|
81
|
-
class Client < {{moduleName}}::API
|
82
|
-
end
|
83
|
-
end
|