ynab 1.29.0 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/DEVELOPMENT.md +11 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +42 -0
- data/README.md +6 -6
- data/Rakefile +58 -0
- data/config.json +9 -0
- data/docs/Account.md +25 -0
- data/docs/AccountResponse.md +8 -0
- data/docs/AccountResponseData.md +8 -0
- data/docs/AccountType.md +7 -0
- data/docs/AccountWrapper.md +8 -0
- data/docs/AccountsApi.md +70 -0
- data/docs/AccountsResponse.md +8 -0
- data/docs/AccountsResponseData.md +9 -0
- data/docs/AccountsWrapper.md +9 -0
- data/docs/BudgetDetail.md +24 -0
- data/docs/BudgetDetailAllOf.md +17 -0
- data/docs/BudgetDetailResponse.md +8 -0
- data/docs/BudgetDetailResponseData.md +9 -0
- data/docs/BudgetDetailWrapper.md +9 -0
- data/docs/BudgetSettings.md +9 -0
- data/docs/BudgetSettingsResponse.md +8 -0
- data/docs/BudgetSettingsResponseData.md +8 -0
- data/docs/BudgetSettingsWrapper.md +8 -0
- data/docs/BudgetSummary.md +15 -0
- data/docs/BudgetSummaryResponse.md +8 -0
- data/docs/BudgetSummaryResponseData.md +9 -0
- data/docs/BudgetSummaryWrapper.md +9 -0
- data/docs/BudgetsApi.md +68 -0
- data/docs/BulkIdWrapper.md +8 -0
- data/docs/BulkIds.md +9 -0
- data/docs/BulkResponse.md +8 -0
- data/docs/BulkResponseData.md +8 -0
- data/docs/BulkResponseDataBulk.md +9 -0
- data/docs/BulkTransactionCreateResponse.md +8 -0
- data/docs/BulkTransactionIds.md +8 -0
- data/docs/BulkTransactions.md +8 -0
- data/docs/CategoriesApi.md +94 -0
- data/docs/CategoriesResponse.md +8 -0
- data/docs/CategoriesResponseData.md +9 -0
- data/docs/Category.md +30 -0
- data/docs/CategoryGroup.md +11 -0
- data/docs/CategoryGroupWithCategories.md +12 -0
- data/docs/CategoryGroupWithCategoriesAllOf.md +8 -0
- data/docs/CategoryGroupsWrapper.md +9 -0
- data/docs/CategoryResponse.md +8 -0
- data/docs/CategoryResponseData.md +8 -0
- data/docs/CategoryWrapper.md +9 -0
- data/docs/CurrencyFormat.md +15 -0
- data/docs/DateFormat.md +8 -0
- data/docs/DeprecatedApi.md +28 -0
- data/docs/ErrorDetail.md +10 -0
- data/docs/ErrorResponse.md +8 -0
- data/docs/HybridTransaction.md +30 -0
- data/docs/HybridTransactionAllOf.md +12 -0
- data/docs/HybridTransactionsResponse.md +8 -0
- data/docs/HybridTransactionsResponseData.md +9 -0
- data/docs/HybridTransactionsWrapper.md +8 -0
- data/docs/LoanAccountPeriodicValue.md +7 -0
- data/docs/MonthDetail.md +16 -0
- data/docs/MonthDetailAllOf.md +8 -0
- data/docs/MonthDetailResponse.md +8 -0
- data/docs/MonthDetailResponseData.md +8 -0
- data/docs/MonthDetailWrapper.md +8 -0
- data/docs/MonthSummariesResponse.md +8 -0
- data/docs/MonthSummariesResponseData.md +9 -0
- data/docs/MonthSummariesWrapper.md +9 -0
- data/docs/MonthSummary.md +15 -0
- data/docs/MonthsApi.md +49 -0
- data/docs/PatchMonthCategoryWrapper.md +8 -0
- data/docs/PatchTransactionsWrapper.md +8 -0
- data/docs/Payee.md +11 -0
- data/docs/PayeeLocation.md +12 -0
- data/docs/PayeeLocationResponse.md +8 -0
- data/docs/PayeeLocationResponseData.md +8 -0
- data/docs/PayeeLocationWrapper.md +8 -0
- data/docs/PayeeLocationsApi.md +69 -0
- data/docs/PayeeLocationsResponse.md +8 -0
- data/docs/PayeeLocationsResponseData.md +8 -0
- data/docs/PayeeLocationsWrapper.md +8 -0
- data/docs/PayeeResponse.md +8 -0
- data/docs/PayeeResponseData.md +8 -0
- data/docs/PayeeWrapper.md +8 -0
- data/docs/PayeesApi.md +49 -0
- data/docs/PayeesResponse.md +8 -0
- data/docs/PayeesResponseData.md +9 -0
- data/docs/PayeesWrapper.md +9 -0
- data/docs/PostAccountWrapper.md +8 -0
- data/docs/PostTransactionsWrapper.md +9 -0
- data/docs/PutTransactionWrapper.md +8 -0
- data/docs/SaveAccount.md +10 -0
- data/docs/SaveAccountWrapper.md +8 -0
- data/docs/SaveCategoryResponse.md +8 -0
- data/docs/SaveCategoryResponseData.md +9 -0
- data/docs/SaveMonthCategory.md +8 -0
- data/docs/SaveMonthCategoryWrapper.md +8 -0
- data/docs/SaveSubTransaction.md +12 -0
- data/docs/SaveTransaction.md +19 -0
- data/docs/SaveTransactionWithId.md +20 -0
- data/docs/SaveTransactionWithIdAllOf.md +8 -0
- data/docs/SaveTransactionWithOptionalFields.md +19 -0
- data/docs/SaveTransactionWrapper.md +8 -0
- data/docs/SaveTransactionsResponse.md +8 -0
- data/docs/SaveTransactionsResponseData.md +12 -0
- data/docs/SaveTransactionsWrapper.md +9 -0
- data/docs/ScheduledSubTransaction.md +15 -0
- data/docs/ScheduledTransactionDetail.md +23 -0
- data/docs/ScheduledTransactionDetailAllOf.md +11 -0
- data/docs/ScheduledTransactionResponse.md +8 -0
- data/docs/ScheduledTransactionResponseData.md +8 -0
- data/docs/ScheduledTransactionSummary.md +19 -0
- data/docs/ScheduledTransactionWrapper.md +8 -0
- data/docs/ScheduledTransactionsApi.md +49 -0
- data/docs/ScheduledTransactionsResponse.md +8 -0
- data/docs/ScheduledTransactionsResponseData.md +9 -0
- data/docs/ScheduledTransactionsWrapper.md +8 -0
- data/docs/SubTransaction.md +18 -0
- data/docs/TransactionDetail.md +29 -0
- data/docs/TransactionDetailAllOf.md +11 -0
- data/docs/TransactionResponse.md +8 -0
- data/docs/TransactionResponseData.md +8 -0
- data/docs/TransactionSummary.md +25 -0
- data/docs/TransactionWrapper.md +8 -0
- data/docs/TransactionsApi.md +228 -0
- data/docs/TransactionsImportResponse.md +8 -0
- data/docs/TransactionsImportResponseData.md +8 -0
- data/docs/TransactionsResponse.md +8 -0
- data/docs/TransactionsResponseData.md +9 -0
- data/docs/TransactionsWrapper.md +9 -0
- data/docs/UpdateTransaction.md +20 -0
- data/docs/UpdateTransactionsWrapper.md +8 -0
- data/docs/User.md +8 -0
- data/docs/UserApi.md +25 -0
- data/docs/UserResponse.md +8 -0
- data/docs/UserResponseData.md +8 -0
- data/docs/UserWrapper.md +8 -0
- data/examples/budget-list.rb +21 -0
- data/examples/budget-month.rb +33 -0
- data/examples/category-balance.rb +23 -0
- data/examples/create-multiple-transactions.rb +42 -0
- data/examples/create-transaction.rb +30 -0
- data/examples/update-category-budgeted.rb +25 -0
- data/examples/update-multiple-transactions.rb +20 -0
- data/lib/ynab/api/accounts_api.rb +79 -42
- data/lib/ynab/api/budgets_api.rb +69 -37
- data/lib/ynab/api/categories_api.rb +109 -61
- data/lib/ynab/api/deprecated_api.rb +33 -18
- data/lib/ynab/api/months_api.rb +50 -29
- data/lib/ynab/api/payee_locations_api.rb +74 -42
- data/lib/ynab/api/payees_api.rb +50 -29
- data/lib/ynab/api/scheduled_transactions_api.rb +50 -29
- data/lib/ynab/api/transactions_api.rb +269 -141
- data/lib/ynab/api/user_api.rb +23 -13
- data/lib/ynab/api_client.rb +98 -96
- data/lib/ynab/configuration.rb +103 -16
- data/lib/ynab/models/account.rb +118 -56
- data/lib/ynab/models/account_response.rb +54 -19
- data/lib/ynab/models/account_response_data.rb +54 -19
- data/lib/ynab/models/account_type.rb +31 -21
- data/lib/ynab/models/accounts_response.rb +54 -19
- data/lib/ynab/models/accounts_response_data.rb +55 -20
- data/lib/ynab/models/budget_detail.rb +81 -36
- data/lib/ynab/models/budget_detail_all_of.rb +320 -0
- data/lib/ynab/models/budget_detail_response.rb +54 -19
- data/lib/ynab/models/budget_detail_response_data.rb +55 -20
- data/lib/ynab/models/budget_settings.rb +57 -30
- data/lib/ynab/models/budget_settings_response.rb +54 -19
- data/lib/ynab/models/budget_settings_response_data.rb +54 -19
- data/lib/ynab/models/budget_summary.rb +64 -27
- data/lib/ynab/models/budget_summary_response.rb +54 -19
- data/lib/ynab/models/budget_summary_response_data.rb +55 -21
- data/lib/ynab/models/bulk_response.rb +54 -19
- data/lib/ynab/models/bulk_response_data.rb +54 -19
- data/lib/ynab/models/bulk_response_data_bulk.rb +55 -20
- data/lib/ynab/models/bulk_transactions.rb +54 -19
- data/lib/ynab/models/categories_response.rb +54 -19
- data/lib/ynab/models/categories_response_data.rb +55 -20
- data/lib/ynab/models/category.rb +111 -49
- data/lib/ynab/models/category_group.rb +59 -24
- data/lib/ynab/models/category_group_with_categories.rb +68 -25
- data/lib/ynab/models/{save_month_category_wrapper.rb → category_group_with_categories_all_of.rb} +67 -29
- data/lib/ynab/models/category_response.rb +54 -19
- data/lib/ynab/models/category_response_data.rb +54 -19
- data/lib/ynab/models/currency_format.rb +63 -28
- data/lib/ynab/models/date_format.rb +54 -19
- data/lib/ynab/models/error_detail.rb +56 -21
- data/lib/ynab/models/error_response.rb +54 -19
- data/lib/ynab/models/hybrid_transaction.rb +120 -47
- data/lib/ynab/models/hybrid_transaction_all_of.rb +304 -0
- data/lib/ynab/models/hybrid_transactions_response.rb +54 -19
- data/lib/ynab/models/hybrid_transactions_response_data.rb +55 -20
- data/lib/ynab/models/month_detail.rb +73 -28
- data/lib/ynab/models/{update_transactions_wrapper.rb → month_detail_all_of.rb} +66 -30
- data/lib/ynab/models/month_detail_response.rb +54 -19
- data/lib/ynab/models/month_detail_response_data.rb +54 -19
- data/lib/ynab/models/month_summaries_response.rb +54 -19
- data/lib/ynab/models/month_summaries_response_data.rb +55 -20
- data/lib/ynab/models/month_summary.rb +64 -27
- data/lib/ynab/models/patch_month_category_wrapper.rb +54 -19
- data/lib/ynab/models/patch_transactions_wrapper.rb +54 -19
- data/lib/ynab/models/payee.rb +59 -23
- data/lib/ynab/models/payee_location.rb +59 -24
- data/lib/ynab/models/payee_location_response.rb +54 -19
- data/lib/ynab/models/payee_location_response_data.rb +54 -19
- data/lib/ynab/models/payee_locations_response.rb +54 -19
- data/lib/ynab/models/payee_locations_response_data.rb +54 -19
- data/lib/ynab/models/payee_response.rb +54 -19
- data/lib/ynab/models/payee_response_data.rb +54 -19
- data/lib/ynab/models/payees_response.rb +54 -19
- data/lib/ynab/models/payees_response_data.rb +55 -20
- data/lib/ynab/models/post_account_wrapper.rb +54 -19
- data/lib/ynab/models/post_transactions_wrapper.rb +55 -20
- data/lib/ynab/models/put_transaction_wrapper.rb +54 -19
- data/lib/ynab/models/save_account.rb +78 -21
- data/lib/ynab/models/save_category_response.rb +54 -19
- data/lib/ynab/models/save_category_response_data.rb +55 -20
- data/lib/ynab/models/save_month_category.rb +54 -19
- data/lib/ynab/models/save_sub_transaction.rb +62 -23
- data/lib/ynab/models/save_transaction.rb +89 -34
- data/lib/ynab/models/save_transaction_with_id.rb +103 -47
- data/lib/ynab/models/{save_transactions_wrapper.rb → save_transaction_with_id_all_of.rb} +60 -36
- data/lib/ynab/models/save_transaction_with_optional_fields.rb +82 -34
- data/lib/ynab/models/save_transactions_response.rb +54 -19
- data/lib/ynab/models/save_transactions_response_data.rb +58 -24
- data/lib/ynab/models/scheduled_sub_transaction.rb +67 -28
- data/lib/ynab/models/scheduled_transaction_detail.rb +96 -37
- data/lib/ynab/models/scheduled_transaction_detail_all_of.rb +262 -0
- data/lib/ynab/models/scheduled_transaction_response.rb +54 -19
- data/lib/ynab/models/scheduled_transaction_response_data.rb +54 -19
- data/lib/ynab/models/scheduled_transaction_summary.rb +81 -33
- data/lib/ynab/models/scheduled_transactions_response.rb +54 -19
- data/lib/ynab/models/scheduled_transactions_response_data.rb +55 -20
- data/lib/ynab/models/sub_transaction.rb +72 -30
- data/lib/ynab/models/transaction_detail.rb +114 -45
- data/lib/ynab/models/{save_transaction_wrapper.rb → transaction_detail_all_of.rb} +102 -29
- data/lib/ynab/models/transaction_response.rb +54 -19
- data/lib/ynab/models/transaction_response_data.rb +54 -19
- data/lib/ynab/models/transaction_summary.rb +99 -41
- data/lib/ynab/models/transactions_import_response.rb +54 -19
- data/lib/ynab/models/transactions_import_response_data.rb +54 -19
- data/lib/ynab/models/transactions_response.rb +54 -19
- data/lib/ynab/models/transactions_response_data.rb +55 -20
- data/lib/ynab/models/user.rb +54 -19
- data/lib/ynab/models/user_response.rb +54 -19
- data/lib/ynab/models/user_response_data.rb +54 -19
- data/lib/ynab/version.rb +1 -1
- data/lib/ynab.rb +21 -16
- data/open_api_spec.yaml +3012 -0
- data/templates/api_client.mustache +274 -0
- data/templates/api_client_typhoeus_partial.mustache +156 -0
- data/templates/api_doc.mustache +44 -0
- data/templates/gem.mustache +84 -0
- data/templates/partial_model_generic_doc.mustache +9 -0
- data/ynab.gemspec +38 -0
- metadata +197 -90
- data/lib/ynab/models/loan_account_periodic_value.rb +0 -175
- data/lib/ynab/models/save_account_wrapper.rb +0 -189
- data/lib/ynab/models/update_transaction.rb +0 -407
- data/spec/models/transaction_detail_spec.rb +0 -11
@@ -1,189 +0,0 @@
|
|
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.4.14
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
|
15
|
-
module YNAB
|
16
|
-
class SaveAccountWrapper
|
17
|
-
attr_accessor :account
|
18
|
-
|
19
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
-
def self.attribute_map
|
21
|
-
{
|
22
|
-
:'account' => :'account'
|
23
|
-
}
|
24
|
-
end
|
25
|
-
|
26
|
-
# Attribute type mapping.
|
27
|
-
def self.swagger_types
|
28
|
-
{
|
29
|
-
:'account' => :'SaveAccount'
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
# Initializes the object
|
34
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
35
|
-
def initialize(attributes = {})
|
36
|
-
return unless attributes.is_a?(Hash)
|
37
|
-
|
38
|
-
# convert string to symbol for hash key
|
39
|
-
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
40
|
-
|
41
|
-
if attributes.has_key?(:'account')
|
42
|
-
self.account = attributes[:'account']
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
47
|
-
# @return Array for valid properties with the reasons
|
48
|
-
def list_invalid_properties
|
49
|
-
invalid_properties = Array.new
|
50
|
-
if @account.nil?
|
51
|
-
invalid_properties.push('invalid value for "account", account cannot be nil.')
|
52
|
-
end
|
53
|
-
|
54
|
-
invalid_properties
|
55
|
-
end
|
56
|
-
|
57
|
-
# Check to see if the all the properties in the model are valid
|
58
|
-
# @return true if the model is valid
|
59
|
-
def valid?
|
60
|
-
return false if @account.nil?
|
61
|
-
true
|
62
|
-
end
|
63
|
-
|
64
|
-
# Checks equality by comparing each attribute.
|
65
|
-
# @param [Object] Object to be compared
|
66
|
-
def ==(o)
|
67
|
-
return true if self.equal?(o)
|
68
|
-
self.class == o.class &&
|
69
|
-
account == o.account
|
70
|
-
end
|
71
|
-
|
72
|
-
# @see the `==` method
|
73
|
-
# @param [Object] Object to be compared
|
74
|
-
def eql?(o)
|
75
|
-
self == o
|
76
|
-
end
|
77
|
-
|
78
|
-
# Calculates hash code according to all attributes.
|
79
|
-
# @return [Fixnum] Hash code
|
80
|
-
def hash
|
81
|
-
[account].hash
|
82
|
-
end
|
83
|
-
# Builds the object from hash
|
84
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
85
|
-
# @return [Object] Returns the model itself
|
86
|
-
def build_from_hash(attributes)
|
87
|
-
return nil unless attributes.is_a?(Hash)
|
88
|
-
self.class.swagger_types.each_pair do |key, type|
|
89
|
-
if type =~ /\AArray<(.*)>/i
|
90
|
-
# check to ensure the input is an array given that the attribute
|
91
|
-
# is documented as an array but the input is not
|
92
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
93
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
94
|
-
end
|
95
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
96
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
97
|
-
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
98
|
-
end
|
99
|
-
|
100
|
-
self
|
101
|
-
end
|
102
|
-
|
103
|
-
# Deserializes the data based on type
|
104
|
-
# @param string type Data type
|
105
|
-
# @param string value Value to be deserialized
|
106
|
-
# @return [Object] Deserialized data
|
107
|
-
def _deserialize(type, value)
|
108
|
-
case type.to_sym
|
109
|
-
when :DateTime
|
110
|
-
DateTime.parse(value)
|
111
|
-
when :Date
|
112
|
-
Date.parse(value)
|
113
|
-
when :String
|
114
|
-
value.to_s
|
115
|
-
when :Integer
|
116
|
-
value.to_i
|
117
|
-
when :Float
|
118
|
-
value.to_f
|
119
|
-
when :BOOLEAN
|
120
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
121
|
-
true
|
122
|
-
else
|
123
|
-
false
|
124
|
-
end
|
125
|
-
when :Object
|
126
|
-
# generic object (usually a Hash), return directly
|
127
|
-
value
|
128
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
129
|
-
inner_type = Regexp.last_match[:inner_type]
|
130
|
-
value.map { |v| _deserialize(inner_type, v) }
|
131
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
132
|
-
k_type = Regexp.last_match[:k_type]
|
133
|
-
v_type = Regexp.last_match[:v_type]
|
134
|
-
{}.tap do |hash|
|
135
|
-
value.each do |k, v|
|
136
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
137
|
-
end
|
138
|
-
end
|
139
|
-
else # model
|
140
|
-
temp_model = YNAB.const_get(type).new
|
141
|
-
temp_model.build_from_hash(value)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
# Returns the string representation of the object
|
146
|
-
# @return [String] String presentation of the object
|
147
|
-
def to_s
|
148
|
-
to_hash.to_s
|
149
|
-
end
|
150
|
-
|
151
|
-
# to_body is an alias to to_hash (backward compatibility)
|
152
|
-
# @return [Hash] Returns the object in the form of hash
|
153
|
-
def to_body
|
154
|
-
to_hash
|
155
|
-
end
|
156
|
-
|
157
|
-
# Returns the object in the form of hash
|
158
|
-
# @return [Hash] Returns the object in the form of hash
|
159
|
-
def to_hash
|
160
|
-
hash = {}
|
161
|
-
self.class.attribute_map.each_pair do |attr, param|
|
162
|
-
value = self.send(attr)
|
163
|
-
next if value.nil?
|
164
|
-
hash[param] = _to_hash(value)
|
165
|
-
end
|
166
|
-
hash
|
167
|
-
end
|
168
|
-
|
169
|
-
# Outputs non-array value in the form of hash
|
170
|
-
# For object, use to_hash. Otherwise, just return the value
|
171
|
-
# @param [Object] value Any valid value
|
172
|
-
# @return [Hash] Returns the value in the form of hash
|
173
|
-
def _to_hash(value)
|
174
|
-
if value.is_a?(Array)
|
175
|
-
value.compact.map { |v| _to_hash(v) }
|
176
|
-
elsif value.is_a?(Hash)
|
177
|
-
{}.tap do |hash|
|
178
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
179
|
-
end
|
180
|
-
elsif value.respond_to? :to_hash
|
181
|
-
value.to_hash
|
182
|
-
else
|
183
|
-
value
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
end
|
188
|
-
|
189
|
-
end
|
@@ -1,407 +0,0 @@
|
|
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.4.14
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
|
15
|
-
module YNAB
|
16
|
-
class UpdateTransaction
|
17
|
-
attr_accessor :account_id
|
18
|
-
|
19
|
-
# The transaction date in ISO format (e.g. 2016-12-01). Future dates (scheduled transactions) are not permitted. Split transaction dates cannot be changed and if a different date is supplied it will be ignored.
|
20
|
-
attr_accessor :date
|
21
|
-
|
22
|
-
# The transaction amount in milliunits format. Split transaction amounts cannot be changed and if a different amount is supplied it will be ignored.
|
23
|
-
attr_accessor :amount
|
24
|
-
|
25
|
-
# The payee for the transaction. To create a transfer between two accounts, use the account transfer payee pointing to the target account. Account transfer payees are specified as `tranfer_payee_id` on the account resource.
|
26
|
-
attr_accessor :payee_id
|
27
|
-
|
28
|
-
# The payee name. If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule (only if `import_id` is also specified) or (2) a payee with the same name or (3) creation of a new payee.
|
29
|
-
attr_accessor :payee_name
|
30
|
-
|
31
|
-
# The category for the transaction. To configure a split transaction, you can specify null for `category_id` and provide a `subtransactions` array as part of the transaction object. If an existing transaction is a split, the `category_id` cannot be changed. Credit Card Payment categories are not permitted and will be ignored if supplied.
|
32
|
-
attr_accessor :category_id
|
33
|
-
|
34
|
-
attr_accessor :memo
|
35
|
-
|
36
|
-
# The cleared status of the transaction
|
37
|
-
attr_accessor :cleared
|
38
|
-
|
39
|
-
# Whether or not the transaction is approved. If not supplied, transaction will be unapproved by default.
|
40
|
-
attr_accessor :approved
|
41
|
-
|
42
|
-
# The transaction flag
|
43
|
-
attr_accessor :flag_color
|
44
|
-
|
45
|
-
# If specified, the new transaction will be assigned this `import_id` and considered \"imported\". We will also attempt to match this imported transaction to an existing \"user-entered\" transation on the same account, with the same amount, and with a date +/-10 days from the imported transaction date.<br><br>Transactions imported through File Based Import or Direct Import (not through the API) are assigned an import_id in the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. Using a consistent format will prevent duplicates through Direct Import and File Based Import.<br><br>If import_id is omitted or specified as null, the transaction will be treated as a \"user-entered\" transaction. As such, it will be eligible to be matched against transactions later being imported (via DI, FBI, or API).
|
46
|
-
attr_accessor :import_id
|
47
|
-
|
48
|
-
# An array of subtransactions to configure a transaction as a split. Updating `subtransactions` on an existing split transaction is not supported.
|
49
|
-
attr_accessor :subtransactions
|
50
|
-
|
51
|
-
attr_accessor :id
|
52
|
-
|
53
|
-
class EnumAttributeValidator
|
54
|
-
attr_reader :datatype
|
55
|
-
attr_reader :allowable_values
|
56
|
-
|
57
|
-
def initialize(datatype, allowable_values)
|
58
|
-
@allowable_values = allowable_values.map do |value|
|
59
|
-
case datatype.to_s
|
60
|
-
when /Integer/i
|
61
|
-
value.to_i
|
62
|
-
when /Float/i
|
63
|
-
value.to_f
|
64
|
-
else
|
65
|
-
value
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def valid?(value)
|
71
|
-
!value || allowable_values.include?(value)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
76
|
-
def self.attribute_map
|
77
|
-
{
|
78
|
-
:'account_id' => :'account_id',
|
79
|
-
:'date' => :'date',
|
80
|
-
:'amount' => :'amount',
|
81
|
-
:'payee_id' => :'payee_id',
|
82
|
-
:'payee_name' => :'payee_name',
|
83
|
-
:'category_id' => :'category_id',
|
84
|
-
:'memo' => :'memo',
|
85
|
-
:'cleared' => :'cleared',
|
86
|
-
:'approved' => :'approved',
|
87
|
-
:'flag_color' => :'flag_color',
|
88
|
-
:'import_id' => :'import_id',
|
89
|
-
:'subtransactions' => :'subtransactions',
|
90
|
-
:'id' => :'id'
|
91
|
-
}
|
92
|
-
end
|
93
|
-
|
94
|
-
# Attribute type mapping.
|
95
|
-
def self.swagger_types
|
96
|
-
{
|
97
|
-
:'account_id' => :'String',
|
98
|
-
:'date' => :'Date',
|
99
|
-
:'amount' => :'Integer',
|
100
|
-
:'payee_id' => :'String',
|
101
|
-
:'payee_name' => :'String',
|
102
|
-
:'category_id' => :'String',
|
103
|
-
:'memo' => :'String',
|
104
|
-
:'cleared' => :'String',
|
105
|
-
:'approved' => :'BOOLEAN',
|
106
|
-
:'flag_color' => :'String',
|
107
|
-
:'import_id' => :'String',
|
108
|
-
:'subtransactions' => :'Array<SaveSubTransaction>',
|
109
|
-
:'id' => :'String'
|
110
|
-
}
|
111
|
-
end
|
112
|
-
|
113
|
-
# Initializes the object
|
114
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
115
|
-
def initialize(attributes = {})
|
116
|
-
return unless attributes.is_a?(Hash)
|
117
|
-
|
118
|
-
# convert string to symbol for hash key
|
119
|
-
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
120
|
-
|
121
|
-
if attributes.has_key?(:'account_id')
|
122
|
-
self.account_id = attributes[:'account_id']
|
123
|
-
end
|
124
|
-
|
125
|
-
if attributes.has_key?(:'date')
|
126
|
-
self.date = attributes[:'date']
|
127
|
-
end
|
128
|
-
|
129
|
-
if attributes.has_key?(:'amount')
|
130
|
-
self.amount = attributes[:'amount']
|
131
|
-
end
|
132
|
-
|
133
|
-
if attributes.has_key?(:'payee_id')
|
134
|
-
self.payee_id = attributes[:'payee_id']
|
135
|
-
end
|
136
|
-
|
137
|
-
if attributes.has_key?(:'payee_name')
|
138
|
-
self.payee_name = attributes[:'payee_name']
|
139
|
-
end
|
140
|
-
|
141
|
-
if attributes.has_key?(:'category_id')
|
142
|
-
self.category_id = attributes[:'category_id']
|
143
|
-
end
|
144
|
-
|
145
|
-
if attributes.has_key?(:'memo')
|
146
|
-
self.memo = attributes[:'memo']
|
147
|
-
end
|
148
|
-
|
149
|
-
if attributes.has_key?(:'cleared')
|
150
|
-
self.cleared = attributes[:'cleared']
|
151
|
-
end
|
152
|
-
|
153
|
-
if attributes.has_key?(:'approved')
|
154
|
-
self.approved = attributes[:'approved']
|
155
|
-
end
|
156
|
-
|
157
|
-
if attributes.has_key?(:'flag_color')
|
158
|
-
self.flag_color = attributes[:'flag_color']
|
159
|
-
end
|
160
|
-
|
161
|
-
if attributes.has_key?(:'import_id')
|
162
|
-
self.import_id = attributes[:'import_id']
|
163
|
-
end
|
164
|
-
|
165
|
-
if attributes.has_key?(:'subtransactions')
|
166
|
-
if (value = attributes[:'subtransactions']).is_a?(Array)
|
167
|
-
self.subtransactions = value
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
if attributes.has_key?(:'id')
|
172
|
-
self.id = attributes[:'id']
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
177
|
-
# @return Array for valid properties with the reasons
|
178
|
-
def list_invalid_properties
|
179
|
-
invalid_properties = Array.new
|
180
|
-
if @account_id.nil?
|
181
|
-
invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
|
182
|
-
end
|
183
|
-
|
184
|
-
if @date.nil?
|
185
|
-
invalid_properties.push('invalid value for "date", date cannot be nil.')
|
186
|
-
end
|
187
|
-
|
188
|
-
if @amount.nil?
|
189
|
-
invalid_properties.push('invalid value for "amount", amount cannot be nil.')
|
190
|
-
end
|
191
|
-
|
192
|
-
if !@payee_name.nil? && @payee_name.to_s.length > 50
|
193
|
-
invalid_properties.push('invalid value for "payee_name", the character length must be smaller than or equal to 50.')
|
194
|
-
end
|
195
|
-
|
196
|
-
if !@memo.nil? && @memo.to_s.length > 200
|
197
|
-
invalid_properties.push('invalid value for "memo", the character length must be smaller than or equal to 200.')
|
198
|
-
end
|
199
|
-
|
200
|
-
if !@import_id.nil? && @import_id.to_s.length > 36
|
201
|
-
invalid_properties.push('invalid value for "import_id", the character length must be smaller than or equal to 36.')
|
202
|
-
end
|
203
|
-
|
204
|
-
if @id.nil?
|
205
|
-
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
206
|
-
end
|
207
|
-
|
208
|
-
invalid_properties
|
209
|
-
end
|
210
|
-
|
211
|
-
# Check to see if the all the properties in the model are valid
|
212
|
-
# @return true if the model is valid
|
213
|
-
def valid?
|
214
|
-
return false if @account_id.nil?
|
215
|
-
return false if @date.nil?
|
216
|
-
return false if @amount.nil?
|
217
|
-
return false if !@payee_name.nil? && @payee_name.to_s.length > 50
|
218
|
-
return false if !@memo.nil? && @memo.to_s.length > 200
|
219
|
-
cleared_validator = EnumAttributeValidator.new('String', ['cleared', 'uncleared', 'reconciled'])
|
220
|
-
return false unless cleared_validator.valid?(@cleared)
|
221
|
-
flag_color_validator = EnumAttributeValidator.new('String', ['red', 'orange', 'yellow', 'green', 'blue', 'purple'])
|
222
|
-
return false unless flag_color_validator.valid?(@flag_color)
|
223
|
-
return false if !@import_id.nil? && @import_id.to_s.length > 36
|
224
|
-
return false if @id.nil?
|
225
|
-
true
|
226
|
-
end
|
227
|
-
|
228
|
-
# Custom attribute writer method with validation
|
229
|
-
# @param [Object] payee_name Value to be assigned
|
230
|
-
def payee_name=(payee_name)
|
231
|
-
if !payee_name.nil? && payee_name.to_s.length > 50
|
232
|
-
fail ArgumentError, 'invalid value for "payee_name", the character length must be smaller than or equal to 50.'
|
233
|
-
end
|
234
|
-
|
235
|
-
@payee_name = payee_name
|
236
|
-
end
|
237
|
-
|
238
|
-
# Custom attribute writer method with validation
|
239
|
-
# @param [Object] memo Value to be assigned
|
240
|
-
def memo=(memo)
|
241
|
-
if !memo.nil? && memo.to_s.length > 200
|
242
|
-
fail ArgumentError, 'invalid value for "memo", the character length must be smaller than or equal to 200.'
|
243
|
-
end
|
244
|
-
|
245
|
-
@memo = memo
|
246
|
-
end
|
247
|
-
|
248
|
-
# Custom attribute writer method checking allowed values (enum).
|
249
|
-
# @param [Object] cleared Object to be assigned
|
250
|
-
def cleared=(cleared)
|
251
|
-
@cleared = cleared
|
252
|
-
end
|
253
|
-
|
254
|
-
# Custom attribute writer method checking allowed values (enum).
|
255
|
-
# @param [Object] flag_color Object to be assigned
|
256
|
-
def flag_color=(flag_color)
|
257
|
-
@flag_color = flag_color
|
258
|
-
end
|
259
|
-
|
260
|
-
# Custom attribute writer method with validation
|
261
|
-
# @param [Object] import_id Value to be assigned
|
262
|
-
def import_id=(import_id)
|
263
|
-
if !import_id.nil? && import_id.to_s.length > 36
|
264
|
-
fail ArgumentError, 'invalid value for "import_id", the character length must be smaller than or equal to 36.'
|
265
|
-
end
|
266
|
-
|
267
|
-
@import_id = import_id
|
268
|
-
end
|
269
|
-
|
270
|
-
# Checks equality by comparing each attribute.
|
271
|
-
# @param [Object] Object to be compared
|
272
|
-
def ==(o)
|
273
|
-
return true if self.equal?(o)
|
274
|
-
self.class == o.class &&
|
275
|
-
account_id == o.account_id &&
|
276
|
-
date == o.date &&
|
277
|
-
amount == o.amount &&
|
278
|
-
payee_id == o.payee_id &&
|
279
|
-
payee_name == o.payee_name &&
|
280
|
-
category_id == o.category_id &&
|
281
|
-
memo == o.memo &&
|
282
|
-
cleared == o.cleared &&
|
283
|
-
approved == o.approved &&
|
284
|
-
flag_color == o.flag_color &&
|
285
|
-
import_id == o.import_id &&
|
286
|
-
subtransactions == o.subtransactions &&
|
287
|
-
id == o.id
|
288
|
-
end
|
289
|
-
|
290
|
-
# @see the `==` method
|
291
|
-
# @param [Object] Object to be compared
|
292
|
-
def eql?(o)
|
293
|
-
self == o
|
294
|
-
end
|
295
|
-
|
296
|
-
# Calculates hash code according to all attributes.
|
297
|
-
# @return [Fixnum] Hash code
|
298
|
-
def hash
|
299
|
-
[account_id, date, amount, payee_id, payee_name, category_id, memo, cleared, approved, flag_color, import_id, subtransactions, id].hash
|
300
|
-
end
|
301
|
-
# Builds the object from hash
|
302
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
303
|
-
# @return [Object] Returns the model itself
|
304
|
-
def build_from_hash(attributes)
|
305
|
-
return nil unless attributes.is_a?(Hash)
|
306
|
-
self.class.swagger_types.each_pair do |key, type|
|
307
|
-
if type =~ /\AArray<(.*)>/i
|
308
|
-
# check to ensure the input is an array given that the attribute
|
309
|
-
# is documented as an array but the input is not
|
310
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
311
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
312
|
-
end
|
313
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
314
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
315
|
-
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
316
|
-
end
|
317
|
-
|
318
|
-
self
|
319
|
-
end
|
320
|
-
|
321
|
-
# Deserializes the data based on type
|
322
|
-
# @param string type Data type
|
323
|
-
# @param string value Value to be deserialized
|
324
|
-
# @return [Object] Deserialized data
|
325
|
-
def _deserialize(type, value)
|
326
|
-
case type.to_sym
|
327
|
-
when :DateTime
|
328
|
-
DateTime.parse(value)
|
329
|
-
when :Date
|
330
|
-
Date.parse(value)
|
331
|
-
when :String
|
332
|
-
value.to_s
|
333
|
-
when :Integer
|
334
|
-
value.to_i
|
335
|
-
when :Float
|
336
|
-
value.to_f
|
337
|
-
when :BOOLEAN
|
338
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
339
|
-
true
|
340
|
-
else
|
341
|
-
false
|
342
|
-
end
|
343
|
-
when :Object
|
344
|
-
# generic object (usually a Hash), return directly
|
345
|
-
value
|
346
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
347
|
-
inner_type = Regexp.last_match[:inner_type]
|
348
|
-
value.map { |v| _deserialize(inner_type, v) }
|
349
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
350
|
-
k_type = Regexp.last_match[:k_type]
|
351
|
-
v_type = Regexp.last_match[:v_type]
|
352
|
-
{}.tap do |hash|
|
353
|
-
value.each do |k, v|
|
354
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
355
|
-
end
|
356
|
-
end
|
357
|
-
else # model
|
358
|
-
temp_model = YNAB.const_get(type).new
|
359
|
-
temp_model.build_from_hash(value)
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
# Returns the string representation of the object
|
364
|
-
# @return [String] String presentation of the object
|
365
|
-
def to_s
|
366
|
-
to_hash.to_s
|
367
|
-
end
|
368
|
-
|
369
|
-
# to_body is an alias to to_hash (backward compatibility)
|
370
|
-
# @return [Hash] Returns the object in the form of hash
|
371
|
-
def to_body
|
372
|
-
to_hash
|
373
|
-
end
|
374
|
-
|
375
|
-
# Returns the object in the form of hash
|
376
|
-
# @return [Hash] Returns the object in the form of hash
|
377
|
-
def to_hash
|
378
|
-
hash = {}
|
379
|
-
self.class.attribute_map.each_pair do |attr, param|
|
380
|
-
value = self.send(attr)
|
381
|
-
next if value.nil?
|
382
|
-
hash[param] = _to_hash(value)
|
383
|
-
end
|
384
|
-
hash
|
385
|
-
end
|
386
|
-
|
387
|
-
# Outputs non-array value in the form of hash
|
388
|
-
# For object, use to_hash. Otherwise, just return the value
|
389
|
-
# @param [Object] value Any valid value
|
390
|
-
# @return [Hash] Returns the value in the form of hash
|
391
|
-
def _to_hash(value)
|
392
|
-
if value.is_a?(Array)
|
393
|
-
value.compact.map { |v| _to_hash(v) }
|
394
|
-
elsif value.is_a?(Hash)
|
395
|
-
{}.tap do |hash|
|
396
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
397
|
-
end
|
398
|
-
elsif value.respond_to? :to_hash
|
399
|
-
value.to_hash
|
400
|
-
else
|
401
|
-
value
|
402
|
-
end
|
403
|
-
end
|
404
|
-
|
405
|
-
end
|
406
|
-
|
407
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe YNAB::TransactionDetail do
|
4
|
-
subject(:transaction) { described_class.new() }
|
5
|
-
|
6
|
-
describe '#flag_color' do
|
7
|
-
it 'allows setting an unsupported value' do
|
8
|
-
expect { transaction.flag_color = 'invalidFlagName' }.not_to raise_error
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|