Class: HappyCo::V1Report

Inherits:
Object
  • Object
show all
Defined in:
lib/happyco_json/models/v1_report.rb

Overview

  • Reports are the end artifact of one or sometimes two inspections. They are generated from inspection(s) at a point in time but do not update if the underlying inspection updates. They are self contained once generated. They are intended to be similar to a printed pieice of paper in that they can’t be edited but they can be signed at any time.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ V1Report

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
# File 'lib/happyco_json/models/v1_report.rb', line 118

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?(:'id')
    self.id = attributes[:'id']
  end

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

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

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

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

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

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

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

  if attributes.has_key?(:'inspection_ids')
    if (value = attributes[:'inspection_ids']).is_a?(Array)
      self.inspection_ids = value
    end
  end

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

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

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

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

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

  if attributes.has_key?(:'signatories')
    if (value = attributes[:'signatories']).is_a?(Array)
      self.signatories = value
    end
  end

end

Instance Attribute Details

#account_idObject

  • Account ID that the report belongs to. For custom integrations (i.e. not integration partners) it may be omitted.



45
46
47
# File 'lib/happyco_json/models/v1_report.rb', line 45

def 
  @account_id
end

#asset_idObject

  • Asset ID references the parent that inspection is attached to. This field must reference a non archived asset in the same folder as the template referenced below.



51
52
53
# File 'lib/happyco_json/models/v1_report.rb', line 51

def asset_id
  @asset_id
end

#dataObject

Returns the value of attribute data.



68
69
70
# File 'lib/happyco_json/models/v1_report.rb', line 68

def data
  @data
end

#finalized_atObject

  • Finalized is the time (as reported by the mobile device) that the report was locked. Until the report is locked the display settings can be changed. Signing a report locks it immediately.



60
61
62
# File 'lib/happyco_json/models/v1_report.rb', line 60

def finalized_at
  @finalized_at
end

#folder_idObject

  • FolderID references the folder that contains the inspections used to generate the report.



48
49
50
# File 'lib/happyco_json/models/v1_report.rb', line 48

def folder_id
  @folder_id
end

#generated_atObject

  • Generated at is the time (as reported by the mobile device) that the report was generated at.



57
58
59
# File 'lib/happyco_json/models/v1_report.rb', line 57

def generated_at
  @generated_at
end

#idObject

  • ID of report.



30
31
32
# File 'lib/happyco_json/models/v1_report.rb', line 30

def id
  @id
end

#inspection_idsObject

  • Inspection IDs references one or more inspection(s) used to generate the report.



54
55
56
# File 'lib/happyco_json/models/v1_report.rb', line 54

def inspection_ids
  @inspection_ids
end

#inspector_idObject

  • Inspector ID references the user who completed the most recent inspection used to generate the report.



63
64
65
# File 'lib/happyco_json/models/v1_report.rb', line 63

def inspector_id
  @inspector_id
end

#inspector_nameObject

  • Inspector name references the user who completed the most recent inspection used to generate the report.



66
67
68
# File 'lib/happyco_json/models/v1_report.rb', line 66

def inspector_name
  @inspector_name
end

#nameObject

  • Name of the asset that was inspected. This is typically the address of the unit or house that was inspected.



36
37
38
# File 'lib/happyco_json/models/v1_report.rb', line 36

def name
  @name
end

#public_urlObject

  • Public URL can be used to share the inspection. It contains a UUID to provide security.



33
34
35
# File 'lib/happyco_json/models/v1_report.rb', line 33

def public_url
  @public_url
end

#revisionObject

  • The revision of the report. This will increment when a change occurs. Reports are limited to changes being archive/unarchive operations or new signatures being added.



42
43
44
# File 'lib/happyco_json/models/v1_report.rb', line 42

def revision
  @revision
end

#signatoriesObject

  • A map of signatories added to the report. Each key in the map only needs to be unique to this report.



71
72
73
# File 'lib/happyco_json/models/v1_report.rb', line 71

def signatories
  @signatories
end

#titleObject

  • Title of the report. This can be overriden by the user in the report settings but typically comes from the template name used to perform the inspection.



39
40
41
# File 'lib/happyco_json/models/v1_report.rb', line 39

def title
  @title
end

Class Method Details

.attribute_mapObject

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



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/happyco_json/models/v1_report.rb', line 75

def self.attribute_map
  {
    :'id' => :'id',
    :'public_url' => :'public_url',
    :'name' => :'name',
    :'title' => :'title',
    :'revision' => :'revision',
    :'account_id' => :'account_id',
    :'folder_id' => :'folder_id',
    :'asset_id' => :'asset_id',
    :'inspection_ids' => :'inspection_ids',
    :'generated_at' => :'generated_at',
    :'finalized_at' => :'finalized_at',
    :'inspector_id' => :'inspector_id',
    :'inspector_name' => :'inspector_name',
    :'data' => :'data',
    :'signatories' => :'signatories'
  }
end

.swagger_typesObject

Attribute type mapping.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/happyco_json/models/v1_report.rb', line 96

def self.swagger_types
  {
    :'id' => :'V1IntegrationID',
    :'public_url' => :'String',
    :'name' => :'String',
    :'title' => :'String',
    :'revision' => :'Integer',
    :'account_id' => :'V1IntegrationID',
    :'folder_id' => :'V1IntegrationID',
    :'asset_id' => :'V1IntegrationID',
    :'inspection_ids' => :'Array<V1IntegrationID>',
    :'generated_at' => :'V1DateTime',
    :'finalized_at' => :'V1DateTime',
    :'inspector_id' => :'V1IntegrationID',
    :'inspector_name' => :'String',
    :'data' => :'String',
    :'signatories' => :'Hash<String, V1Signatory>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/happyco_json/models/v1_report.rb', line 205

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      public_url == o.public_url &&
      name == o.name &&
      title == o.title &&
      revision == o.revision &&
       == o. &&
      folder_id == o.folder_id &&
      asset_id == o.asset_id &&
      inspection_ids == o.inspection_ids &&
      generated_at == o.generated_at &&
      finalized_at == o.finalized_at &&
      inspector_id == o.inspector_id &&
      inspector_name == o.inspector_name &&
      data == o.data &&
      signatories == o.signatories
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/happyco_json/models/v1_report.rb', line 261

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 =~ /^(true|t|yes|y|1)$/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 = HappyCo.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

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/happyco_json/models/v1_report.rb', line 327

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

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/happyco_json/models/v1_report.rb', line 240

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/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

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


227
228
229
# File 'lib/happyco_json/models/v1_report.rb', line 227

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



233
234
235
# File 'lib/happyco_json/models/v1_report.rb', line 233

def hash
  [id, public_url, name, title, revision, , folder_id, asset_id, inspection_ids, generated_at, finalized_at, inspector_id, inspector_name, data, signatories].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properies with the reasons



192
193
194
195
# File 'lib/happyco_json/models/v1_report.rb', line 192

def list_invalid_properties
  invalid_properties = Array.new
  return invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



307
308
309
# File 'lib/happyco_json/models/v1_report.rb', line 307

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



313
314
315
316
317
318
319
320
321
# File 'lib/happyco_json/models/v1_report.rb', line 313

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

Returns:

  • (String)

    String presentation of the object



301
302
303
# File 'lib/happyco_json/models/v1_report.rb', line 301

def to_s
  to_hash.to_s
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



199
200
201
# File 'lib/happyco_json/models/v1_report.rb', line 199

def valid?
  return true
end