ynab 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -185,7 +185,7 @@ module YnabApi
185
185
  return false if @id.nil?
186
186
  return false if @name.nil?
187
187
  return false if @type.nil?
188
- type_validator = EnumAttributeValidator.new('String', ["checking", "savings", "creditCard", "cash", "lineOfCredit", "merchantAccount", "investmentAccount", "mortgage", "otherAsset", "otherLiability"])
188
+ type_validator = EnumAttributeValidator.new('String', ["checking", "savings", "creditCard", "cash", "lineOfCredit", "merchantAccount", "payPal", "investmentAccount", "mortgage", "otherAsset", "otherLiability"])
189
189
  return false unless type_validator.valid?(@type)
190
190
  return false if @on_budget.nil?
191
191
  return false if @closed.nil?
@@ -199,7 +199,7 @@ module YnabApi
199
199
  # Custom attribute writer method checking allowed values (enum).
200
200
  # @param [Object] type Object to be assigned
201
201
  def type=(type)
202
- validator = EnumAttributeValidator.new('String', ["checking", "savings", "creditCard", "cash", "lineOfCredit", "merchantAccount", "investmentAccount", "mortgage", "otherAsset", "otherLiability"])
202
+ validator = EnumAttributeValidator.new('String', ["checking", "savings", "creditCard", "cash", "lineOfCredit", "merchantAccount", "payPal", "investmentAccount", "mortgage", "otherAsset", "otherLiability"])
203
203
  unless validator.valid?(type)
204
204
  fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
205
205
  end
@@ -30,6 +30,7 @@ module YnabApi
30
30
 
31
31
  attr_accessor :memo
32
32
 
33
+ # The scheduled transaction flag
33
34
  attr_accessor :flag_color
34
35
 
35
36
  attr_accessor :account_id
@@ -229,6 +230,8 @@ module YnabApi
229
230
  return false if @amount.nil?
230
231
  return false if @memo.nil?
231
232
  return false if @flag_color.nil?
233
+ flag_color_validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple"])
234
+ return false unless flag_color_validator.valid?(@flag_color)
232
235
  return false if @account_id.nil?
233
236
  return false if @payee_id.nil?
234
237
  return false if @category_id.nil?
@@ -247,6 +250,16 @@ module YnabApi
247
250
  @frequency = frequency
248
251
  end
249
252
 
253
+ # Custom attribute writer method checking allowed values (enum).
254
+ # @param [Object] flag_color Object to be assigned
255
+ def flag_color=(flag_color)
256
+ validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple"])
257
+ unless validator.valid?(flag_color)
258
+ fail ArgumentError, "invalid value for 'flag_color', must be one of #{validator.allowable_values}."
259
+ end
260
+ @flag_color = flag_color
261
+ end
262
+
250
263
  # Checks equality by comparing each attribute.
251
264
  # @param [Object] Object to be compared
252
265
  def ==(o)
@@ -30,6 +30,7 @@ module YnabApi
30
30
 
31
31
  attr_accessor :memo
32
32
 
33
+ # The scheduled transaction flag
33
34
  attr_accessor :flag_color
34
35
 
35
36
  attr_accessor :account_id
@@ -214,6 +215,8 @@ module YnabApi
214
215
  return false if @amount.nil?
215
216
  return false if @memo.nil?
216
217
  return false if @flag_color.nil?
218
+ flag_color_validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple"])
219
+ return false unless flag_color_validator.valid?(@flag_color)
217
220
  return false if @account_id.nil?
218
221
  return false if @payee_id.nil?
219
222
  return false if @category_id.nil?
@@ -231,6 +234,16 @@ module YnabApi
231
234
  @frequency = frequency
232
235
  end
233
236
 
237
+ # Custom attribute writer method checking allowed values (enum).
238
+ # @param [Object] flag_color Object to be assigned
239
+ def flag_color=(flag_color)
240
+ validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple"])
241
+ unless validator.valid?(flag_color)
242
+ fail ArgumentError, "invalid value for 'flag_color', must be one of #{validator.allowable_values}."
243
+ end
244
+ @flag_color = flag_color
245
+ end
246
+
234
247
  # Checks equality by comparing each attribute.
235
248
  # @param [Object] Object to be compared
236
249
  def ==(o)
@@ -30,6 +30,7 @@ module YnabApi
30
30
  # Whether or not the transaction is approved
31
31
  attr_accessor :approved
32
32
 
33
+ # The transaction flag
33
34
  attr_accessor :flag_color
34
35
 
35
36
  attr_accessor :account_id
@@ -241,6 +242,8 @@ module YnabApi
241
242
  return false unless cleared_validator.valid?(@cleared)
242
243
  return false if @approved.nil?
243
244
  return false if @flag_color.nil?
245
+ flag_color_validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple"])
246
+ return false unless flag_color_validator.valid?(@flag_color)
244
247
  return false if @account_id.nil?
245
248
  return false if @payee_id.nil?
246
249
  return false if @category_id.nil?
@@ -260,6 +263,16 @@ module YnabApi
260
263
  @cleared = cleared
261
264
  end
262
265
 
266
+ # Custom attribute writer method checking allowed values (enum).
267
+ # @param [Object] flag_color Object to be assigned
268
+ def flag_color=(flag_color)
269
+ validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple"])
270
+ unless validator.valid?(flag_color)
271
+ fail ArgumentError, "invalid value for 'flag_color', must be one of #{validator.allowable_values}."
272
+ end
273
+ @flag_color = flag_color
274
+ end
275
+
263
276
  # Checks equality by comparing each attribute.
264
277
  # @param [Object] Object to be compared
265
278
  def ==(o)
@@ -30,6 +30,7 @@ module YnabApi
30
30
  # Whether or not the transaction is approved
31
31
  attr_accessor :approved
32
32
 
33
+ # The transaction flag
33
34
  attr_accessor :flag_color
34
35
 
35
36
  attr_accessor :account_id
@@ -226,6 +227,8 @@ module YnabApi
226
227
  return false unless cleared_validator.valid?(@cleared)
227
228
  return false if @approved.nil?
228
229
  return false if @flag_color.nil?
230
+ flag_color_validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple"])
231
+ return false unless flag_color_validator.valid?(@flag_color)
229
232
  return false if @account_id.nil?
230
233
  return false if @payee_id.nil?
231
234
  return false if @category_id.nil?
@@ -244,6 +247,16 @@ module YnabApi
244
247
  @cleared = cleared
245
248
  end
246
249
 
250
+ # Custom attribute writer method checking allowed values (enum).
251
+ # @param [Object] flag_color Object to be assigned
252
+ def flag_color=(flag_color)
253
+ validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple"])
254
+ unless validator.valid?(flag_color)
255
+ fail ArgumentError, "invalid value for 'flag_color', must be one of #{validator.allowable_values}."
256
+ end
257
+ @flag_color = flag_color
258
+ end
259
+
247
260
  # Checks equality by comparing each attribute.
248
261
  # @param [Object] Object to be compared
249
262
  def ==(o)
@@ -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 User
18
+ attr_accessor :id
19
+
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'id' => :'id'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.swagger_types
30
+ {
31
+ :'id' => :'String'
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?(:'id')
44
+ self.id = attributes[:'id']
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 @id.nil?
54
+ invalid_properties.push("invalid value for 'id', id 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 @id.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
+ id == o.id
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
+ [id].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 UserResponse
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' => :'UserWrapper'
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