Class: ReliefWebAPI::PostParams

Inherits:
Object
  • Object
show all
Defined in:
lib/reliefweb-api/models/post_params.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ PostParams

Initializes the object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/reliefweb-api/models/post_params.rb', line 115

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  if attributes.has_key?(:'query[value]')
    self.query_value = attributes[:'query[value]']
  end

  if attributes.has_key?(:'query[operator]-post')
    self.query_operator_post = attributes[:'query[operator]-post']
  end

  if attributes.has_key?(:'query[fields][]-post')
    self.query_fields_post = attributes[:'query[fields][]-post']
  end

  if attributes.has_key?(:'filter[field]-post')
    self.filter_field_post = attributes[:'filter[field]-post']
  end

  if attributes.has_key?(:'filter[value][]-post')
    self.filter_value_post = attributes[:'filter[value][]-post']
  end

  if attributes.has_key?(:'filter[operator]-post')
    self.filter_operator_post = attributes[:'filter[operator]-post']
  end

  if attributes.has_key?(:'filter[negate]-post')
    self.filter_negate_post = attributes[:'filter[negate]-post']
  end

  if attributes.has_key?(:'filter[conditions][]-post')
    self.filter_conditions_post = attributes[:'filter[conditions][]-post']
  end

  if attributes.has_key?(:'facets[field]-post')
    self.facets_field_post = attributes[:'facets[field]-post']
  end

  if attributes.has_key?(:'facets[name]-post')
    self.facets_name_post = attributes[:'facets[name]-post']
  end

  if attributes.has_key?(:'facets[limit]-post')
    self.facets_limit_post = attributes[:'facets[limit]-post']
  end

  if attributes.has_key?(:'facets[sort]-post')
    self.facets_sort_post = attributes[:'facets[sort]-post']
  end

  if attributes.has_key?(:'facets[filter][]-post')
    self.facets_filter_post = attributes[:'facets[filter][]-post']
  end

  if attributes.has_key?(:'facets[interval]-post')
    self.facets_interval_post = attributes[:'facets[interval]-post']
  end

  if attributes.has_key?(:'fields[include][]')
    self.fields_include = attributes[:'fields[include][]']
  end

  if attributes.has_key?(:'fields[exclude][]')
    self.fields_exclude = attributes[:'fields[exclude][]']
  end

  if attributes.has_key?(:'sort[]-post')
    self.sort_post = attributes[:'sort[]-post']
  end

  if attributes.has_key?(:'limit-post')
    self.limit_post = attributes[:'limit-post']
  end

  if attributes.has_key?(:'offset-post')
    self.offset_post = attributes[:'offset-post']
  end

  if attributes.has_key?(:'profile')
    self.profile = attributes[:'profile']
  end

  if attributes.has_key?(:'preset-post')
    self.preset_post = attributes[:'preset-post']
  end
end

Instance Attribute Details

#facets_field_postObject

Returns the value of attribute facets_field_post.



33
34
35
# File 'lib/reliefweb-api/models/post_params.rb', line 33

def facets_field_post
  @facets_field_post
end

#facets_filter_postObject

Returns the value of attribute facets_filter_post.



41
42
43
# File 'lib/reliefweb-api/models/post_params.rb', line 41

def facets_filter_post
  @facets_filter_post
end

#facets_interval_postObject

Returns the value of attribute facets_interval_post.



43
44
45
# File 'lib/reliefweb-api/models/post_params.rb', line 43

def facets_interval_post
  @facets_interval_post
end

#facets_limit_postObject

Returns the value of attribute facets_limit_post.



37
38
39
# File 'lib/reliefweb-api/models/post_params.rb', line 37

def facets_limit_post
  @facets_limit_post
end

#facets_name_postObject

Returns the value of attribute facets_name_post.



35
36
37
# File 'lib/reliefweb-api/models/post_params.rb', line 35

def facets_name_post
  @facets_name_post
end

#facets_sort_postObject

Returns the value of attribute facets_sort_post.



39
40
41
# File 'lib/reliefweb-api/models/post_params.rb', line 39

def facets_sort_post
  @facets_sort_post
end

#fields_excludeObject

Returns the value of attribute fields_exclude.



47
48
49
# File 'lib/reliefweb-api/models/post_params.rb', line 47

def fields_exclude
  @fields_exclude
end

#fields_includeObject

Returns the value of attribute fields_include.



45
46
47
# File 'lib/reliefweb-api/models/post_params.rb', line 45

def fields_include
  @fields_include
end

#filter_conditions_postObject

Returns the value of attribute filter_conditions_post.



31
32
33
# File 'lib/reliefweb-api/models/post_params.rb', line 31

def filter_conditions_post
  @filter_conditions_post
end

#filter_field_postObject

Returns the value of attribute filter_field_post.



23
24
25
# File 'lib/reliefweb-api/models/post_params.rb', line 23

def filter_field_post
  @filter_field_post
end

#filter_negate_postObject

Returns the value of attribute filter_negate_post.



29
30
31
# File 'lib/reliefweb-api/models/post_params.rb', line 29

def filter_negate_post
  @filter_negate_post
end

#filter_operator_postObject

Returns the value of attribute filter_operator_post.



27
28
29
# File 'lib/reliefweb-api/models/post_params.rb', line 27

def filter_operator_post
  @filter_operator_post
end

#filter_value_postObject

Returns the value of attribute filter_value_post.



25
26
27
# File 'lib/reliefweb-api/models/post_params.rb', line 25

def filter_value_post
  @filter_value_post
end

#limit_postObject

Returns the value of attribute limit_post.



51
52
53
# File 'lib/reliefweb-api/models/post_params.rb', line 51

def limit_post
  @limit_post
end

#offset_postObject

Returns the value of attribute offset_post.



53
54
55
# File 'lib/reliefweb-api/models/post_params.rb', line 53

def offset_post
  @offset_post
end

#preset_postObject

Returns the value of attribute preset_post.



57
58
59
# File 'lib/reliefweb-api/models/post_params.rb', line 57

def preset_post
  @preset_post
end

#profileObject

Returns the value of attribute profile.



55
56
57
# File 'lib/reliefweb-api/models/post_params.rb', line 55

def profile
  @profile
end

#query_fields_postObject

Returns the value of attribute query_fields_post.



21
22
23
# File 'lib/reliefweb-api/models/post_params.rb', line 21

def query_fields_post
  @query_fields_post
end

#query_operator_postObject

Returns the value of attribute query_operator_post.



19
20
21
# File 'lib/reliefweb-api/models/post_params.rb', line 19

def query_operator_post
  @query_operator_post
end

#query_valueObject

Returns the value of attribute query_value.



17
18
19
# File 'lib/reliefweb-api/models/post_params.rb', line 17

def query_value
  @query_value
end

#sort_postObject

Returns the value of attribute sort_post.



49
50
51
# File 'lib/reliefweb-api/models/post_params.rb', line 49

def sort_post
  @sort_post
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/reliefweb-api/models/post_params.rb', line 60

def self.attribute_map
  {
    :'query_value' => :'query[value]',
    :'query_operator_post' => :'query[operator]-post',
    :'query_fields_post' => :'query[fields][]-post',
    :'filter_field_post' => :'filter[field]-post',
    :'filter_value_post' => :'filter[value][]-post',
    :'filter_operator_post' => :'filter[operator]-post',
    :'filter_negate_post' => :'filter[negate]-post',
    :'filter_conditions_post' => :'filter[conditions][]-post',
    :'facets_field_post' => :'facets[field]-post',
    :'facets_name_post' => :'facets[name]-post',
    :'facets_limit_post' => :'facets[limit]-post',
    :'facets_sort_post' => :'facets[sort]-post',
    :'facets_filter_post' => :'facets[filter][]-post',
    :'facets_interval_post' => :'facets[interval]-post',
    :'fields_include' => :'fields[include][]',
    :'fields_exclude' => :'fields[exclude][]',
    :'sort_post' => :'sort[]-post',
    :'limit_post' => :'limit-post',
    :'offset_post' => :'offset-post',
    :'profile' => :'profile',
    :'preset_post' => :'preset-post'
  }
end

.swagger_typesObject

Attribute type mapping.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/reliefweb-api/models/post_params.rb', line 87

def self.swagger_types
  {
    :'query_value' => :'QueryValuePost',
    :'query_operator_post' => :'QueryOperatorPost',
    :'query_fields_post' => :'QueryFieldsPost',
    :'filter_field_post' => :'FilterFieldPost',
    :'filter_value_post' => :'FilterValuePost',
    :'filter_operator_post' => :'FilterOperatorPost',
    :'filter_negate_post' => :'FilterNegatePost',
    :'filter_conditions_post' => :'FilterConditionsPost',
    :'facets_field_post' => :'FacetsFieldPost',
    :'facets_name_post' => :'FacetsNamePost',
    :'facets_limit_post' => :'FacetsLimitPost',
    :'facets_sort_post' => :'FacetsSortPost',
    :'facets_filter_post' => :'FacetsFilterPost',
    :'facets_interval_post' => :'FacetsIntervalPost',
    :'fields_include' => :'FieldsIncludePost',
    :'fields_exclude' => :'FieldsExcludePost',
    :'sort_post' => :'SortPost',
    :'limit_post' => :'LimitPost',
    :'offset_post' => :'OffsetPost',
    :'profile' => :'ProfilePost',
    :'preset_post' => :'PresetPost'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/reliefweb-api/models/post_params.rb', line 221

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      query_value == o.query_value &&
      query_operator_post == o.query_operator_post &&
      query_fields_post == o.query_fields_post &&
      filter_field_post == o.filter_field_post &&
      filter_value_post == o.filter_value_post &&
      filter_operator_post == o.filter_operator_post &&
      filter_negate_post == o.filter_negate_post &&
      filter_conditions_post == o.filter_conditions_post &&
      facets_field_post == o.facets_field_post &&
      facets_name_post == o.facets_name_post &&
      facets_limit_post == o.facets_limit_post &&
      facets_sort_post == o.facets_sort_post &&
      facets_filter_post == o.facets_filter_post &&
      facets_interval_post == o.facets_interval_post &&
      fields_include == o.fields_include &&
      fields_exclude == o.fields_exclude &&
      sort_post == o.sort_post &&
      limit_post == o.limit_post &&
      offset_post == o.offset_post &&
      profile == o.profile &&
      preset_post == o.preset_post
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type



283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/reliefweb-api/models/post_params.rb', line 283

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = ReliefWebAPI.const_get(type).new
    temp_model.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value



349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/reliefweb-api/models/post_params.rb', line 349

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/reliefweb-api/models/post_params.rb', line 262

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

See Also:

  • `==` method


249
250
251
# File 'lib/reliefweb-api/models/post_params.rb', line 249

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.



255
256
257
# File 'lib/reliefweb-api/models/post_params.rb', line 255

def hash
  [query_value, query_operator_post, query_fields_post, filter_field_post, filter_value_post, filter_operator_post, filter_negate_post, filter_conditions_post, facets_field_post, facets_name_post, facets_limit_post, facets_sort_post, facets_filter_post, facets_interval_post, fields_include, fields_exclude, sort_post, limit_post, offset_post, profile, preset_post].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?



208
209
210
211
# File 'lib/reliefweb-api/models/post_params.rb', line 208

def list_invalid_properties
  invalid_properties = Array.new
  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)



329
330
331
# File 'lib/reliefweb-api/models/post_params.rb', line 329

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash



335
336
337
338
339
340
341
342
343
# File 'lib/reliefweb-api/models/post_params.rb', line 335

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object



323
324
325
# File 'lib/reliefweb-api/models/post_params.rb', line 323

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid



215
216
217
# File 'lib/reliefweb-api/models/post_params.rb', line 215

def valid?
  true
end