Class: MoveToGo::DealStatusReference

Inherits:
Object
  • Object
show all
Includes:
SerializeHelper
Defined in:
lib/move-to-go/model/deal_status_reference.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializeHelper

#get_import_rows, #serialize, #serialize_to_file

Constructor Details

#initialize(opt = nil) ⇒ DealStatusReference

Returns a new instance of DealStatusReference.



7
8
9
10
11
12
13
14
# File 'lib/move-to-go/model/deal_status_reference.rb', line 7

def initialize(opt = nil)
    if opt != nil
        serialize_variables.each do |myattr|
            val = opt[myattr[:id]]
            instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
        end
    end
end

Instance Attribute Details

#integration_idObject

Returns the value of attribute integration_id.



5
6
7
# File 'lib/move-to-go/model/deal_status_reference.rb', line 5

def integration_id
  @integration_id
end

#labelObject

Returns the value of attribute label.



5
6
7
# File 'lib/move-to-go/model/deal_status_reference.rb', line 5

def label
  @label
end

Class Method Details

.from_deal_status(deal_status) ⇒ Object

Converts the specifed status to a status reference.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/move-to-go/model/deal_status_reference.rb', line 25

def self.from_deal_status(deal_status)
    if deal_status.nil?
        return nil
    elsif deal_status.is_a?(DealStatusSetting)
        return deal_status.to_reference
    elsif deal_status.is_a?(String)
        return DealStatusReference.new({:label => deal_status, :integration_id => deal_status})
    end

    raise InvalidDealStatusError
end

Instance Method Details

#serialize_nameObject



20
21
22
# File 'lib/move-to-go/model/deal_status_reference.rb', line 20

def serialize_name
    "StatusReference"
end

#serialize_variablesObject



16
17
18
# File 'lib/move-to-go/model/deal_status_reference.rb', line 16

def serialize_variables
    [:integration_id, :label].map {|p| {:id => p, :type => :string} }
end

#validateObject



37
38
39
40
41
42
43
44
45
# File 'lib/move-to-go/model/deal_status_reference.rb', line 37

def validate
    error = ""

    if (@label.nil? || @label.empty?) && (@integration_id.nil? || @integration_id.empty?)
        error = "label and integration_id can't all be nil or empty"
    end

    return error
end