Class: TestPack1::SiteWithData

Inherits:
BaseModel show all
Defined in:
lib/test_pack_1/models/site_with_data.rb

Overview

SiteWithData Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(site_id = nil, title = nil, country = nil, identity = nil, metadata = nil) ⇒ SiteWithData

Returns a new instance of SiteWithData.



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/test_pack_1/models/site_with_data.rb', line 40

def initialize(site_id = nil,
               title = nil,
               country = nil,
               identity = nil,
                = nil)
  @site_id = site_id
  @title = title
  @country = country
  @identity = identity
  @metadata = 
end

Instance Attribute Details

#countryString

The id of a site.

Returns:



19
20
21
# File 'lib/test_pack_1/models/site_with_data.rb', line 19

def country
  @country
end

#identityString

The id of a site.

Returns:



23
24
25
# File 'lib/test_pack_1/models/site_with_data.rb', line 23

def identity
  @identity
end

#metadataList of MetadataField

A list of metadata fields and their values.

Returns:



27
28
29
# File 'lib/test_pack_1/models/site_with_data.rb', line 27

def 
  @metadata
end

#site_idInteger

The id of a site.

Returns:

  • (Integer)


11
12
13
# File 'lib/test_pack_1/models/site_with_data.rb', line 11

def site_id
  @site_id
end

#titleString

The id of a site.

Returns:



15
16
17
# File 'lib/test_pack_1/models/site_with_data.rb', line 15

def title
  @title
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/test_pack_1/models/site_with_data.rb', line 53

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  site_id = hash['siteId']
  title = hash['title']
  country = hash['country']
  identity = hash['identity']
  # Parameter is an array, so we need to iterate through it
   = nil
  unless hash['metadata'].nil?
     = []
    hash['metadata'].each do |structure|
       << (MetadataField.from_hash(structure) if structure)
    end
  end

  # Create object from extracted values.
  SiteWithData.new(site_id,
                   title,
                   country,
                   identity,
                   )
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
38
# File 'lib/test_pack_1/models/site_with_data.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['site_id'] = 'siteId'
  @_hash['title'] = 'title'
  @_hash['country'] = 'country'
  @_hash['identity'] = 'identity'
  @_hash['metadata'] = 'metadata'
  @_hash
end