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(users = nil, services = 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(users = nil,
               services = nil)
  @users = users
  @services = services
end

Instance Attribute Details

#servicesList of EntitiesServiceResponse

array of Services matching query

Returns:



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

def services
  @services
end

#usersList of EntitiesUserResponse

array of Users matching query

Returns:



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

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
# File 'lib/gonebusy/models/entities_search_response.rb', line 30

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash
  # 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
  # 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

  # Create object from extracted values
  EntitiesSearchResponse.new(users,
                             services)
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["users"] = "users"
    @_hash["services"] = "services"
  end
  @_hash
end