ynab 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +44 -0
- data/LICENSE.md +201 -0
- data/README.md +57 -0
- data/Rakefile +31 -0
- data/config.json +10 -0
- data/docs/Account.md +16 -0
- data/docs/AccountResponse.md +8 -0
- data/docs/AccountWrapper.md +8 -0
- data/docs/AccountsApi.md +121 -0
- data/docs/AccountsResponse.md +8 -0
- data/docs/AccountsWrapper.md +8 -0
- data/docs/BudgetDetail.md +22 -0
- data/docs/BudgetDetailResponse.md +8 -0
- data/docs/BudgetDetailWrapper.md +9 -0
- data/docs/BudgetSummary.md +12 -0
- data/docs/BudgetSummaryResponse.md +8 -0
- data/docs/BudgetSummaryWrapper.md +8 -0
- data/docs/BudgetsApi.md +116 -0
- data/docs/BulkIdWrapper.md +8 -0
- data/docs/BulkIds.md +9 -0
- data/docs/BulkResponse.md +8 -0
- data/docs/BulkTransactionCreateResponse.md +8 -0
- data/docs/BulkTransactionIds.md +8 -0
- data/docs/BulkTransactions.md +8 -0
- data/docs/CategoriesApi.md +121 -0
- data/docs/CategoriesResponse.md +8 -0
- data/docs/Category.md +15 -0
- data/docs/CategoryGroup.md +10 -0
- data/docs/CategoryGroupWithCategories.md +11 -0
- data/docs/CategoryGroupsWrapper.md +8 -0
- data/docs/CategoryResponse.md +8 -0
- data/docs/CategoryWrapper.md +8 -0
- data/docs/CurrencyFormat.md +8 -0
- data/docs/DateFormat.md +8 -0
- data/docs/ErrorDetail.md +10 -0
- data/docs/ErrorResponse.md +8 -0
- data/docs/MonthDetail.md +12 -0
- data/docs/MonthDetailResponse.md +8 -0
- data/docs/MonthDetailWrapper.md +8 -0
- data/docs/MonthSummariesResponse.md +8 -0
- data/docs/MonthSummariesWrapper.md +8 -0
- data/docs/MonthSummary.md +11 -0
- data/docs/MonthsApi.md +121 -0
- data/docs/Payee.md +10 -0
- data/docs/PayeeLocation.md +11 -0
- data/docs/PayeeLocationResponse.md +8 -0
- data/docs/PayeeLocationWrapper.md +8 -0
- data/docs/PayeeLocationsApi.md +179 -0
- data/docs/PayeeLocationsResponse.md +8 -0
- data/docs/PayeeLocationsWrapper.md +8 -0
- data/docs/PayeeResponse.md +8 -0
- data/docs/PayeeWrapper.md +8 -0
- data/docs/PayeesApi.md +121 -0
- data/docs/PayeesResponse.md +8 -0
- data/docs/PayeesWrapper.md +8 -0
- data/docs/SaveTransaction.md +18 -0
- data/docs/SaveTransactionWrapper.md +8 -0
- data/docs/ScheduledSubTransaction.md +14 -0
- data/docs/ScheduledTransactionDetail.md +19 -0
- data/docs/ScheduledTransactionResponse.md +8 -0
- data/docs/ScheduledTransactionSummary.md +18 -0
- data/docs/ScheduledTransactionWrapper.md +8 -0
- data/docs/ScheduledTransactionsApi.md +121 -0
- data/docs/ScheduledTransactionsResponse.md +8 -0
- data/docs/ScheduledTransactionsWrapper.md +8 -0
- data/docs/SubTransaction.md +14 -0
- data/docs/TransactionDetail.md +20 -0
- data/docs/TransactionResponse.md +8 -0
- data/docs/TransactionSummary.md +19 -0
- data/docs/TransactionWrapper.md +8 -0
- data/docs/TransactionsApi.md +428 -0
- data/docs/TransactionsResponse.md +8 -0
- data/docs/TransactionsWrapper.md +8 -0
- data/examples/budget-list.rb +25 -0
- data/examples/budget-month.rb +36 -0
- data/examples/category-balance.rb +27 -0
- data/lib/ynab.rb +136 -0
- data/lib/ynab/api/accounts_api.rb +135 -0
- data/lib/ynab/api/budgets_api.rb +126 -0
- data/lib/ynab/api/categories_api.rb +135 -0
- data/lib/ynab/api/months_api.rb +135 -0
- data/lib/ynab/api/payee_locations_api.rb +194 -0
- data/lib/ynab/api/payees_api.rb +135 -0
- data/lib/ynab/api/scheduled_transactions_api.rb +135 -0
- data/lib/ynab/api/transactions_api.rb +451 -0
- data/lib/ynab/api_client.rb +392 -0
- data/lib/ynab/api_error.rb +38 -0
- data/lib/ynab/configuration.rb +209 -0
- data/lib/ynab/models/account.rb +343 -0
- data/lib/ynab/models/account_response.rb +193 -0
- data/lib/ynab/models/account_wrapper.rb +193 -0
- data/lib/ynab/models/accounts_response.rb +193 -0
- data/lib/ynab/models/accounts_wrapper.rb +195 -0
- data/lib/ynab/models/budget_detail.rb +345 -0
- data/lib/ynab/models/budget_detail_response.rb +193 -0
- data/lib/ynab/models/budget_detail_wrapper.rb +208 -0
- data/lib/ynab/models/budget_summary.rb +235 -0
- data/lib/ynab/models/budget_summary_response.rb +193 -0
- data/lib/ynab/models/budget_summary_wrapper.rb +195 -0
- data/lib/ynab/models/bulk_id_wrapper.rb +193 -0
- data/lib/ynab/models/bulk_ids.rb +213 -0
- data/lib/ynab/models/bulk_response.rb +193 -0
- data/lib/ynab/models/bulk_transaction_create_response.rb +193 -0
- data/lib/ynab/models/bulk_transaction_ids.rb +195 -0
- data/lib/ynab/models/bulk_transactions.rb +195 -0
- data/lib/ynab/models/categories_response.rb +193 -0
- data/lib/ynab/models/category.rb +295 -0
- data/lib/ynab/models/category_group.rb +222 -0
- data/lib/ynab/models/category_group_with_categories.rb +239 -0
- data/lib/ynab/models/category_groups_wrapper.rb +195 -0
- data/lib/ynab/models/category_response.rb +193 -0
- data/lib/ynab/models/category_wrapper.rb +193 -0
- data/lib/ynab/models/currency_format.rb +193 -0
- data/lib/ynab/models/date_format.rb +193 -0
- data/lib/ynab/models/error_detail.rb +221 -0
- data/lib/ynab/models/error_response.rb +193 -0
- data/lib/ynab/models/month_detail.rb +253 -0
- data/lib/ynab/models/month_detail_response.rb +193 -0
- data/lib/ynab/models/month_detail_wrapper.rb +193 -0
- data/lib/ynab/models/month_summaries_response.rb +193 -0
- data/lib/ynab/models/month_summaries_wrapper.rb +195 -0
- data/lib/ynab/models/month_summary.rb +236 -0
- data/lib/ynab/models/payee.rb +222 -0
- data/lib/ynab/models/payee_location.rb +235 -0
- data/lib/ynab/models/payee_location_response.rb +193 -0
- data/lib/ynab/models/payee_location_wrapper.rb +193 -0
- data/lib/ynab/models/payee_locations_response.rb +193 -0
- data/lib/ynab/models/payee_locations_wrapper.rb +195 -0
- data/lib/ynab/models/payee_response.rb +193 -0
- data/lib/ynab/models/payee_wrapper.rb +193 -0
- data/lib/ynab/models/payees_response.rb +193 -0
- data/lib/ynab/models/payees_wrapper.rb +195 -0
- data/lib/ynab/models/save_transaction.rb +346 -0
- data/lib/ynab/models/save_transaction_wrapper.rb +193 -0
- data/lib/ynab/models/scheduled_sub_transaction.rb +279 -0
- data/lib/ynab/models/scheduled_transaction_detail.rb +387 -0
- data/lib/ynab/models/scheduled_transaction_response.rb +193 -0
- data/lib/ynab/models/scheduled_transaction_summary.rb +370 -0
- data/lib/ynab/models/scheduled_transaction_wrapper.rb +193 -0
- data/lib/ynab/models/scheduled_transactions_response.rb +193 -0
- data/lib/ynab/models/scheduled_transactions_wrapper.rb +195 -0
- data/lib/ynab/models/sub_transaction.rb +279 -0
- data/lib/ynab/models/transaction_detail.rb +401 -0
- data/lib/ynab/models/transaction_response.rb +193 -0
- data/lib/ynab/models/transaction_summary.rb +384 -0
- data/lib/ynab/models/transaction_wrapper.rb +193 -0
- data/lib/ynab/models/transactions_response.rb +193 -0
- data/lib/ynab/models/transactions_wrapper.rb +195 -0
- data/lib/ynab/version.rb +15 -0
- data/pkg/ynab-0.1.0.gem +0 -0
- data/spec-v1-swagger.json +2121 -0
- data/spec/api/accounts_spec.rb +56 -0
- data/spec/api/budgets_spec.rb +55 -0
- data/spec/api/categories_spec.rb +57 -0
- data/spec/api/months_spec.rb +57 -0
- data/spec/api/payee_locations_spec.rb +57 -0
- data/spec/api/payees_spec.rb +56 -0
- data/spec/api/scheduled_transactions_spec.rb +56 -0
- data/spec/api/transactions_spec.rb +122 -0
- data/spec/fixtures/.DS_Store +0 -0
- data/spec/fixtures/vcr_cassettes/account.yml +46 -0
- data/spec/fixtures/vcr_cassettes/accounts.yml +46 -0
- data/spec/fixtures/vcr_cassettes/accounts_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/budget.yml +1413 -0
- data/spec/fixtures/vcr_cassettes/budgets.yml +49 -0
- data/spec/fixtures/vcr_cassettes/budgets_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/bulk_transactions.yml +46 -0
- data/spec/fixtures/vcr_cassettes/categories.yml +67 -0
- data/spec/fixtures/vcr_cassettes/categories_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/category.yml +46 -0
- data/spec/fixtures/vcr_cassettes/create_transaction.yml +46 -0
- data/spec/fixtures/vcr_cassettes/month.yml +59 -0
- data/spec/fixtures/vcr_cassettes/months.yml +47 -0
- data/spec/fixtures/vcr_cassettes/months_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/payee.yml +47 -0
- data/spec/fixtures/vcr_cassettes/payee_location.yml +46 -0
- data/spec/fixtures/vcr_cassettes/payee_locations.yml +46 -0
- data/spec/fixtures/vcr_cassettes/payee_locations_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/payees.yml +51 -0
- data/spec/fixtures/vcr_cassettes/payees_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/scheduled_transaction.yml +46 -0
- data/spec/fixtures/vcr_cassettes/scheduled_transactions.yml +46 -0
- data/spec/fixtures/vcr_cassettes/scheduled_transactions_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/transaction.yml +46 -0
- data/spec/fixtures/vcr_cassettes/transactions.yml +46 -0
- data/spec/fixtures/vcr_cassettes/transactions_unauthorized.yml +49 -0
- data/spec/fixtures/vcr_cassettes/update_transaction.yml +46 -0
- data/spec/spec_helper.rb +18 -0
- data/swagger-templates/api_client.mustache +386 -0
- data/swagger-templates/gemspec.mustache +37 -0
- data/ynab.gemspec +40 -0
- metadata +353 -0
@@ -0,0 +1,193 @@
|
|
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 'date'
|
14
|
+
|
15
|
+
module YnabApi
|
16
|
+
|
17
|
+
class MonthDetailWrapper
|
18
|
+
attr_accessor :month
|
19
|
+
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'month' => :'month'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.swagger_types
|
30
|
+
{
|
31
|
+
:'month' => :'MonthDetail'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Initializes the object
|
36
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
37
|
+
def initialize(attributes = {})
|
38
|
+
return unless attributes.is_a?(Hash)
|
39
|
+
|
40
|
+
# convert string to symbol for hash key
|
41
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
42
|
+
|
43
|
+
if attributes.has_key?(:'month')
|
44
|
+
self.month = attributes[:'month']
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
50
|
+
# @return Array for valid properties with the reasons
|
51
|
+
def list_invalid_properties
|
52
|
+
invalid_properties = Array.new
|
53
|
+
if @month.nil?
|
54
|
+
invalid_properties.push("invalid value for 'month', month cannot be nil.")
|
55
|
+
end
|
56
|
+
|
57
|
+
return invalid_properties
|
58
|
+
end
|
59
|
+
|
60
|
+
# Check to see if the all the properties in the model are valid
|
61
|
+
# @return true if the model is valid
|
62
|
+
def valid?
|
63
|
+
return false if @month.nil?
|
64
|
+
return true
|
65
|
+
end
|
66
|
+
|
67
|
+
# Checks equality by comparing each attribute.
|
68
|
+
# @param [Object] Object to be compared
|
69
|
+
def ==(o)
|
70
|
+
return true if self.equal?(o)
|
71
|
+
self.class == o.class &&
|
72
|
+
month == o.month
|
73
|
+
end
|
74
|
+
|
75
|
+
# @see the `==` method
|
76
|
+
# @param [Object] Object to be compared
|
77
|
+
def eql?(o)
|
78
|
+
self == o
|
79
|
+
end
|
80
|
+
|
81
|
+
# Calculates hash code according to all attributes.
|
82
|
+
# @return [Fixnum] Hash code
|
83
|
+
def hash
|
84
|
+
[month].hash
|
85
|
+
end
|
86
|
+
|
87
|
+
# Builds the object from hash
|
88
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
89
|
+
# @return [Object] Returns the model itself
|
90
|
+
def build_from_hash(attributes)
|
91
|
+
return nil unless attributes.is_a?(Hash)
|
92
|
+
self.class.swagger_types.each_pair do |key, type|
|
93
|
+
if type =~ /\AArray<(.*)>/i
|
94
|
+
# check to ensure the input is an array given that the the attribute
|
95
|
+
# is documented as an array but the input is not
|
96
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
97
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
98
|
+
end
|
99
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
100
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
101
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
102
|
+
end
|
103
|
+
|
104
|
+
self
|
105
|
+
end
|
106
|
+
|
107
|
+
# Deserializes the data based on type
|
108
|
+
# @param string type Data type
|
109
|
+
# @param string value Value to be deserialized
|
110
|
+
# @return [Object] Deserialized data
|
111
|
+
def _deserialize(type, value)
|
112
|
+
case type.to_sym
|
113
|
+
when :DateTime
|
114
|
+
DateTime.parse(value)
|
115
|
+
when :Date
|
116
|
+
Date.parse(value)
|
117
|
+
when :String
|
118
|
+
value.to_s
|
119
|
+
when :Integer
|
120
|
+
value.to_i
|
121
|
+
when :Float
|
122
|
+
value.to_f
|
123
|
+
when :BOOLEAN
|
124
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
125
|
+
true
|
126
|
+
else
|
127
|
+
false
|
128
|
+
end
|
129
|
+
when :Object
|
130
|
+
# generic object (usually a Hash), return directly
|
131
|
+
value
|
132
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
133
|
+
inner_type = Regexp.last_match[:inner_type]
|
134
|
+
value.map { |v| _deserialize(inner_type, v) }
|
135
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
136
|
+
k_type = Regexp.last_match[:k_type]
|
137
|
+
v_type = Regexp.last_match[:v_type]
|
138
|
+
{}.tap do |hash|
|
139
|
+
value.each do |k, v|
|
140
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
else # model
|
144
|
+
temp_model = YnabApi.const_get(type).new
|
145
|
+
temp_model.build_from_hash(value)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# Returns the string representation of the object
|
150
|
+
# @return [String] String presentation of the object
|
151
|
+
def to_s
|
152
|
+
to_hash.to_s
|
153
|
+
end
|
154
|
+
|
155
|
+
# to_body is an alias to to_hash (backward compatibility)
|
156
|
+
# @return [Hash] Returns the object in the form of hash
|
157
|
+
def to_body
|
158
|
+
to_hash
|
159
|
+
end
|
160
|
+
|
161
|
+
# Returns the object in the form of hash
|
162
|
+
# @return [Hash] Returns the object in the form of hash
|
163
|
+
def to_hash
|
164
|
+
hash = {}
|
165
|
+
self.class.attribute_map.each_pair do |attr, param|
|
166
|
+
value = self.send(attr)
|
167
|
+
next if value.nil?
|
168
|
+
hash[param] = _to_hash(value)
|
169
|
+
end
|
170
|
+
hash
|
171
|
+
end
|
172
|
+
|
173
|
+
# Outputs non-array value in the form of hash
|
174
|
+
# For object, use to_hash. Otherwise, just return the value
|
175
|
+
# @param [Object] value Any valid value
|
176
|
+
# @return [Hash] Returns the value in the form of hash
|
177
|
+
def _to_hash(value)
|
178
|
+
if value.is_a?(Array)
|
179
|
+
value.compact.map{ |v| _to_hash(v) }
|
180
|
+
elsif value.is_a?(Hash)
|
181
|
+
{}.tap do |hash|
|
182
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
183
|
+
end
|
184
|
+
elsif value.respond_to? :to_hash
|
185
|
+
value.to_hash
|
186
|
+
else
|
187
|
+
value
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
@@ -0,0 +1,193 @@
|
|
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 'date'
|
14
|
+
|
15
|
+
module YnabApi
|
16
|
+
|
17
|
+
class MonthSummariesResponse
|
18
|
+
attr_accessor :data
|
19
|
+
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'data' => :'data'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.swagger_types
|
30
|
+
{
|
31
|
+
:'data' => :'MonthSummariesWrapper'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Initializes the object
|
36
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
37
|
+
def initialize(attributes = {})
|
38
|
+
return unless attributes.is_a?(Hash)
|
39
|
+
|
40
|
+
# convert string to symbol for hash key
|
41
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
42
|
+
|
43
|
+
if attributes.has_key?(:'data')
|
44
|
+
self.data = attributes[:'data']
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
50
|
+
# @return Array for valid properties with the reasons
|
51
|
+
def list_invalid_properties
|
52
|
+
invalid_properties = Array.new
|
53
|
+
if @data.nil?
|
54
|
+
invalid_properties.push("invalid value for 'data', data cannot be nil.")
|
55
|
+
end
|
56
|
+
|
57
|
+
return invalid_properties
|
58
|
+
end
|
59
|
+
|
60
|
+
# Check to see if the all the properties in the model are valid
|
61
|
+
# @return true if the model is valid
|
62
|
+
def valid?
|
63
|
+
return false if @data.nil?
|
64
|
+
return true
|
65
|
+
end
|
66
|
+
|
67
|
+
# Checks equality by comparing each attribute.
|
68
|
+
# @param [Object] Object to be compared
|
69
|
+
def ==(o)
|
70
|
+
return true if self.equal?(o)
|
71
|
+
self.class == o.class &&
|
72
|
+
data == o.data
|
73
|
+
end
|
74
|
+
|
75
|
+
# @see the `==` method
|
76
|
+
# @param [Object] Object to be compared
|
77
|
+
def eql?(o)
|
78
|
+
self == o
|
79
|
+
end
|
80
|
+
|
81
|
+
# Calculates hash code according to all attributes.
|
82
|
+
# @return [Fixnum] Hash code
|
83
|
+
def hash
|
84
|
+
[data].hash
|
85
|
+
end
|
86
|
+
|
87
|
+
# Builds the object from hash
|
88
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
89
|
+
# @return [Object] Returns the model itself
|
90
|
+
def build_from_hash(attributes)
|
91
|
+
return nil unless attributes.is_a?(Hash)
|
92
|
+
self.class.swagger_types.each_pair do |key, type|
|
93
|
+
if type =~ /\AArray<(.*)>/i
|
94
|
+
# check to ensure the input is an array given that the the attribute
|
95
|
+
# is documented as an array but the input is not
|
96
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
97
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
98
|
+
end
|
99
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
100
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
101
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
102
|
+
end
|
103
|
+
|
104
|
+
self
|
105
|
+
end
|
106
|
+
|
107
|
+
# Deserializes the data based on type
|
108
|
+
# @param string type Data type
|
109
|
+
# @param string value Value to be deserialized
|
110
|
+
# @return [Object] Deserialized data
|
111
|
+
def _deserialize(type, value)
|
112
|
+
case type.to_sym
|
113
|
+
when :DateTime
|
114
|
+
DateTime.parse(value)
|
115
|
+
when :Date
|
116
|
+
Date.parse(value)
|
117
|
+
when :String
|
118
|
+
value.to_s
|
119
|
+
when :Integer
|
120
|
+
value.to_i
|
121
|
+
when :Float
|
122
|
+
value.to_f
|
123
|
+
when :BOOLEAN
|
124
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
125
|
+
true
|
126
|
+
else
|
127
|
+
false
|
128
|
+
end
|
129
|
+
when :Object
|
130
|
+
# generic object (usually a Hash), return directly
|
131
|
+
value
|
132
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
133
|
+
inner_type = Regexp.last_match[:inner_type]
|
134
|
+
value.map { |v| _deserialize(inner_type, v) }
|
135
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
136
|
+
k_type = Regexp.last_match[:k_type]
|
137
|
+
v_type = Regexp.last_match[:v_type]
|
138
|
+
{}.tap do |hash|
|
139
|
+
value.each do |k, v|
|
140
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
else # model
|
144
|
+
temp_model = YnabApi.const_get(type).new
|
145
|
+
temp_model.build_from_hash(value)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# Returns the string representation of the object
|
150
|
+
# @return [String] String presentation of the object
|
151
|
+
def to_s
|
152
|
+
to_hash.to_s
|
153
|
+
end
|
154
|
+
|
155
|
+
# to_body is an alias to to_hash (backward compatibility)
|
156
|
+
# @return [Hash] Returns the object in the form of hash
|
157
|
+
def to_body
|
158
|
+
to_hash
|
159
|
+
end
|
160
|
+
|
161
|
+
# Returns the object in the form of hash
|
162
|
+
# @return [Hash] Returns the object in the form of hash
|
163
|
+
def to_hash
|
164
|
+
hash = {}
|
165
|
+
self.class.attribute_map.each_pair do |attr, param|
|
166
|
+
value = self.send(attr)
|
167
|
+
next if value.nil?
|
168
|
+
hash[param] = _to_hash(value)
|
169
|
+
end
|
170
|
+
hash
|
171
|
+
end
|
172
|
+
|
173
|
+
# Outputs non-array value in the form of hash
|
174
|
+
# For object, use to_hash. Otherwise, just return the value
|
175
|
+
# @param [Object] value Any valid value
|
176
|
+
# @return [Hash] Returns the value in the form of hash
|
177
|
+
def _to_hash(value)
|
178
|
+
if value.is_a?(Array)
|
179
|
+
value.compact.map{ |v| _to_hash(v) }
|
180
|
+
elsif value.is_a?(Hash)
|
181
|
+
{}.tap do |hash|
|
182
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
183
|
+
end
|
184
|
+
elsif value.respond_to? :to_hash
|
185
|
+
value.to_hash
|
186
|
+
else
|
187
|
+
value
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
@@ -0,0 +1,195 @@
|
|
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 'date'
|
14
|
+
|
15
|
+
module YnabApi
|
16
|
+
|
17
|
+
class MonthSummariesWrapper
|
18
|
+
attr_accessor :months
|
19
|
+
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'months' => :'months'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.swagger_types
|
30
|
+
{
|
31
|
+
:'months' => :'Array<MonthSummary>'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Initializes the object
|
36
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
37
|
+
def initialize(attributes = {})
|
38
|
+
return unless attributes.is_a?(Hash)
|
39
|
+
|
40
|
+
# convert string to symbol for hash key
|
41
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
42
|
+
|
43
|
+
if attributes.has_key?(:'months')
|
44
|
+
if (value = attributes[:'months']).is_a?(Array)
|
45
|
+
self.months = value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
52
|
+
# @return Array for valid properties with the reasons
|
53
|
+
def list_invalid_properties
|
54
|
+
invalid_properties = Array.new
|
55
|
+
if @months.nil?
|
56
|
+
invalid_properties.push("invalid value for 'months', months cannot be nil.")
|
57
|
+
end
|
58
|
+
|
59
|
+
return invalid_properties
|
60
|
+
end
|
61
|
+
|
62
|
+
# Check to see if the all the properties in the model are valid
|
63
|
+
# @return true if the model is valid
|
64
|
+
def valid?
|
65
|
+
return false if @months.nil?
|
66
|
+
return true
|
67
|
+
end
|
68
|
+
|
69
|
+
# Checks equality by comparing each attribute.
|
70
|
+
# @param [Object] Object to be compared
|
71
|
+
def ==(o)
|
72
|
+
return true if self.equal?(o)
|
73
|
+
self.class == o.class &&
|
74
|
+
months == o.months
|
75
|
+
end
|
76
|
+
|
77
|
+
# @see the `==` method
|
78
|
+
# @param [Object] Object to be compared
|
79
|
+
def eql?(o)
|
80
|
+
self == o
|
81
|
+
end
|
82
|
+
|
83
|
+
# Calculates hash code according to all attributes.
|
84
|
+
# @return [Fixnum] Hash code
|
85
|
+
def hash
|
86
|
+
[months].hash
|
87
|
+
end
|
88
|
+
|
89
|
+
# Builds the object from hash
|
90
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
91
|
+
# @return [Object] Returns the model itself
|
92
|
+
def build_from_hash(attributes)
|
93
|
+
return nil unless attributes.is_a?(Hash)
|
94
|
+
self.class.swagger_types.each_pair do |key, type|
|
95
|
+
if type =~ /\AArray<(.*)>/i
|
96
|
+
# check to ensure the input is an array given that the the attribute
|
97
|
+
# is documented as an array but the input is not
|
98
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
99
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
100
|
+
end
|
101
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
102
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
103
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
104
|
+
end
|
105
|
+
|
106
|
+
self
|
107
|
+
end
|
108
|
+
|
109
|
+
# Deserializes the data based on type
|
110
|
+
# @param string type Data type
|
111
|
+
# @param string value Value to be deserialized
|
112
|
+
# @return [Object] Deserialized data
|
113
|
+
def _deserialize(type, value)
|
114
|
+
case type.to_sym
|
115
|
+
when :DateTime
|
116
|
+
DateTime.parse(value)
|
117
|
+
when :Date
|
118
|
+
Date.parse(value)
|
119
|
+
when :String
|
120
|
+
value.to_s
|
121
|
+
when :Integer
|
122
|
+
value.to_i
|
123
|
+
when :Float
|
124
|
+
value.to_f
|
125
|
+
when :BOOLEAN
|
126
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
127
|
+
true
|
128
|
+
else
|
129
|
+
false
|
130
|
+
end
|
131
|
+
when :Object
|
132
|
+
# generic object (usually a Hash), return directly
|
133
|
+
value
|
134
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
135
|
+
inner_type = Regexp.last_match[:inner_type]
|
136
|
+
value.map { |v| _deserialize(inner_type, v) }
|
137
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
138
|
+
k_type = Regexp.last_match[:k_type]
|
139
|
+
v_type = Regexp.last_match[:v_type]
|
140
|
+
{}.tap do |hash|
|
141
|
+
value.each do |k, v|
|
142
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
else # model
|
146
|
+
temp_model = YnabApi.const_get(type).new
|
147
|
+
temp_model.build_from_hash(value)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Returns the string representation of the object
|
152
|
+
# @return [String] String presentation of the object
|
153
|
+
def to_s
|
154
|
+
to_hash.to_s
|
155
|
+
end
|
156
|
+
|
157
|
+
# to_body is an alias to to_hash (backward compatibility)
|
158
|
+
# @return [Hash] Returns the object in the form of hash
|
159
|
+
def to_body
|
160
|
+
to_hash
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns the object in the form of hash
|
164
|
+
# @return [Hash] Returns the object in the form of hash
|
165
|
+
def to_hash
|
166
|
+
hash = {}
|
167
|
+
self.class.attribute_map.each_pair do |attr, param|
|
168
|
+
value = self.send(attr)
|
169
|
+
next if value.nil?
|
170
|
+
hash[param] = _to_hash(value)
|
171
|
+
end
|
172
|
+
hash
|
173
|
+
end
|
174
|
+
|
175
|
+
# Outputs non-array value in the form of hash
|
176
|
+
# For object, use to_hash. Otherwise, just return the value
|
177
|
+
# @param [Object] value Any valid value
|
178
|
+
# @return [Hash] Returns the value in the form of hash
|
179
|
+
def _to_hash(value)
|
180
|
+
if value.is_a?(Array)
|
181
|
+
value.compact.map{ |v| _to_hash(v) }
|
182
|
+
elsif value.is_a?(Hash)
|
183
|
+
{}.tap do |hash|
|
184
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
185
|
+
end
|
186
|
+
elsif value.respond_to? :to_hash
|
187
|
+
value.to_hash
|
188
|
+
else
|
189
|
+
value
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|