Class: Gonebusy::EntitiesSearchResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/gonebusy/models/entities_search_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(services = nil, users = nil) ⇒ EntitiesSearchResponse

Returns a new instance of EntitiesSearchResponse.



23
24
25
26
27
# File 'lib/gonebusy/models/entities_search_response.rb', line 23

def initialize(services = nil,
               users = nil)
  @services = services
  @users = users
end

Instance Attribute Details

#servicesList of EntitiesServiceResponse

array of Services matching query

Returns:



7
8
9
# File 'lib/gonebusy/models/entities_search_response.rb', line 7

def services
  @services
end

#usersList of EntitiesUserResponse

array of Users matching query

Returns:



11
12
13
# File 'lib/gonebusy/models/entities_search_response.rb', line 11

def users
  @users
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/gonebusy/models/entities_search_response.rb', line 30

def self.from_hash(hash)
  if hash == nil
    nil
  else
    # Extract variables from the hash
    # Parameter is an array, so we need to iterate through it
    services = nil
    if hash["services"] != nil
      services = Array.new
      hash["services"].each{|structure| services << (EntitiesServiceResponse.from_hash(structure) if structure)}
    end
    # Parameter is an array, so we need to iterate through it
    users = nil
    if hash["users"] != nil
      users = Array.new
      hash["users"].each{|structure| users << (EntitiesUserResponse.from_hash(structure) if structure)}
    end

    # Create object from extracted values
    EntitiesSearchResponse.new(services,
                               users)
  end
end

.namesObject

A mapping from model property names to API property names



14
15
16
17
18
19
20
21
# File 'lib/gonebusy/models/entities_search_response.rb', line 14

def self.names
  if @hash.nil?
    @hash = {}
    @hash["services"] = "services"
    @hash["users"] = "users"
  end
  @hash
end