Class: MoesifApi::CompanyModel

Inherits:
BaseModel show all
Defined in:
lib/moesif_api/models/company_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#clean_str, #to_hash, #to_json

Constructor Details

#initialize(company_id = nil, modified_time = nil, ip_address = nil, session_token = nil, company_domain = nil, metadata = nil, campaign = nil) ⇒ CompanyModel

Returns a new instance of CompanyModel.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/moesif_api/models/company_model.rb', line 50

def initialize(company_id = nil,
               modified_time = nil,
               ip_address = nil,
               session_token = nil,
               company_domain = nil,
                = nil,
               campaign = nil)
  @company_id = company_id
  @modified_time = modified_time
  @ip_address = ip_address
  @session_token = session_token
  @company_domain = company_domain
  @metadata = 
  @campaign = campaign
end

Instance Attribute Details

#campaignCampaignModel

campaign object

Returns:



33
34
35
# File 'lib/moesif_api/models/company_model.rb', line 33

def campaign
  @campaign
end

#company_domainString

Optionally tag the company with the company domain.

Returns:



25
26
27
# File 'lib/moesif_api/models/company_model.rb', line 25

def company_domain
  @company_domain
end

#company_idString

company id of the company

Returns:



9
10
11
# File 'lib/moesif_api/models/company_model.rb', line 9

def company_id
  @company_id
end

#ip_addressString

ip address associated with user if avaialble.

Returns:



17
18
19
# File 'lib/moesif_api/models/company_model.rb', line 17

def ip_address
  @ip_address
end

#metadataObject

meta data

Returns:

  • (Object)


29
30
31
# File 'lib/moesif_api/models/company_model.rb', line 29

def 
  @metadata
end

#modified_timeDateTime

Time when modification was made. default to current time on server side.

Returns:

  • (DateTime)


13
14
15
# File 'lib/moesif_api/models/company_model.rb', line 13

def modified_time
  @modified_time
end

#session_tokenString

session token associated with user if avaialble.

Returns:



21
22
23
# File 'lib/moesif_api/models/company_model.rb', line 21

def session_token
  @session_token
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/moesif_api/models/company_model.rb', line 67

def self.from_hash(hash)
  if hash == nil
    nil
  else
    # Extract variables from the hash
    company_id = hash["company_id"]
    modified_time = DateTime.iso8601(hash["modified_time"]) if hash["modified_time"]
    ip_address = hash["ip_address"]
    session_token = hash["session_token"]
    company_domain = hash["company_domain"]
     = hash["metadata"]
    campaign = CampaignModel.from_hash(hash["campaign"]) if hash["campaign"]

    # Create object from extracted values
    CompanyModel.new(company_id,
                  modified_time,
                  ip_address,
                  session_token,
                  company_domain,
                  ,
                  campaign)
  end
end

.namesObject

A mapping from model property names to API property names



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/moesif_api/models/company_model.rb', line 36

def self.names
  if @hash.nil?
    @hash = {}
    @hash["company_id"] = "company_id"
    @hash["modified_time"] = "modified_time"
    @hash["ip_address"] = "ip_address"
    @hash["session_token"] = "session_token"
    @hash["company_domain"] = "company_domain"
    @hash["metadata"] = "metadata"
    @hash["campaign"] = "campaign"
  end
  @hash
end