Class: GoImport::Deal
- Inherits:
-
Object
- Object
- GoImport::Deal
- Includes:
- ModelHasCustomFields, ModelHasTags, SerializeHelper
- Defined in:
- lib/go_import/model/deal.rb
Instance Attribute Summary collapse
-
#custom_values ⇒ Object
readonly
you add custom values by using ModelHasCustomFields#set_custom_value.
-
#customer ⇒ Object
Gets the customer to which this deal belongs.
-
#customer_contact ⇒ Object
Returns the value of attribute customer_contact.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#integration_id ⇒ Object
Returns the value of attribute integration_id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#order_date ⇒ Object
Returns the value of attribute order_date.
-
#probability ⇒ Object
Returns the value of attribute probability.
-
#responsible_coworker ⇒ Object
Returns the value of attribute responsible_coworker.
-
#status ⇒ Object
Get/set the deal’s status.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(opt = nil) ⇒ Deal
constructor
A new instance of Deal.
- #is_float?(value) ⇒ Boolean
- #is_integer?(value) ⇒ Boolean
- #serialize_name ⇒ Object
- #serialize_variables ⇒ Object
- #to_reference ⇒ Object
- #to_s ⇒ Object
- #validate ⇒ Object
- #with_status {|@status| ... } ⇒ Object
Methods included from SerializeHelper
#get_import_rows, #serialize, #serialize_to_file
Methods included from ModelHasCustomFields
#set_custom_field, #set_custom_value
Methods included from ModelHasTags
Constructor Details
#initialize(opt = nil) ⇒ Deal
Returns a new instance of Deal.
72 73 74 75 76 77 78 79 |
# File 'lib/go_import/model/deal.rb', line 72 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
#custom_values ⇒ Object (readonly)
you add custom values by using ModelHasCustomFields#set_custom_value
47 48 49 |
# File 'lib/go_import/model/deal.rb', line 47 def custom_values @custom_values end |
#customer ⇒ Object
Gets the customer to which this deal belongs
142 143 144 |
# File 'lib/go_import/model/deal.rb', line 142 def customer @customer end |
#customer_contact ⇒ Object
Returns the value of attribute customer_contact.
49 50 51 |
# File 'lib/go_import/model/deal.rb', line 49 def customer_contact @customer_contact end |
#description ⇒ Object
Returns the value of attribute description.
44 45 46 |
# File 'lib/go_import/model/deal.rb', line 44 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
44 45 46 |
# File 'lib/go_import/model/deal.rb', line 44 def id @id end |
#integration_id ⇒ Object
Returns the value of attribute integration_id.
44 45 46 |
# File 'lib/go_import/model/deal.rb', line 44 def integration_id @integration_id end |
#name ⇒ Object
Returns the value of attribute name.
44 45 46 |
# File 'lib/go_import/model/deal.rb', line 44 def name @name end |
#order_date ⇒ Object
Returns the value of attribute order_date.
44 45 46 |
# File 'lib/go_import/model/deal.rb', line 44 def order_date @order_date end |
#probability ⇒ Object
Returns the value of attribute probability.
44 45 46 |
# File 'lib/go_import/model/deal.rb', line 44 def probability @probability end |
#responsible_coworker ⇒ Object
Returns the value of attribute responsible_coworker.
49 50 51 |
# File 'lib/go_import/model/deal.rb', line 49 def responsible_coworker @responsible_coworker end |
#status ⇒ Object
Get/set the deal’s status. Statuses must be configured in LIME Go before the import.
42 43 44 |
# File 'lib/go_import/model/deal.rb', line 42 def status @status end |
#value ⇒ Object
Returns the value of attribute value.
49 50 51 |
# File 'lib/go_import/model/deal.rb', line 49 def value @value end |
Instance Method Details
#is_float?(value) ⇒ Boolean
189 190 191 |
# File 'lib/go_import/model/deal.rb', line 189 def is_float?(value) true if Float(value) rescue false end |
#is_integer?(value) ⇒ Boolean
185 186 187 |
# File 'lib/go_import/model/deal.rb', line 185 def is_integer?(value) true if Integer(value) rescue false end |
#serialize_name ⇒ Object
68 69 70 |
# File 'lib/go_import/model/deal.rb', line 68 def serialize_name "Deal" end |
#serialize_variables ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/go_import/model/deal.rb', line 51 def serialize_variables [ :id, :integration_id, :name, :description, :probability, :value, :order_date ].map { |p| { :id => p, :type => :string } } + [ { :id => :customer_reference, :type => :organization_reference, :element_name => :customer }, { :id => :responsible_coworker_reference, :type => :coworker_reference, :element_name => :responsible_coworker }, { :id => :customer_contact_reference, :type => :person_reference, :element_name => :customer_contact}, { :id => :custom_values, :type => :custom_values }, { :id => :tags, :type => :tags }, { :id => :status, :type => :deal_status } ] end |
#to_reference ⇒ Object
85 86 87 88 89 90 |
# File 'lib/go_import/model/deal.rb', line 85 def to_reference reference = DealReference.new reference.id = @id reference.integration_id = @integration_id return reference end |
#to_s ⇒ Object
81 82 83 |
# File 'lib/go_import/model/deal.rb', line 81 def to_s return "deal[id=#{@id}, integration_id=#{@integration_id}]" end |
#validate ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/go_import/model/deal.rb', line 92 def validate error = String.new if @name.nil? || @name.empty? error = "A name is required for deal.\n}" end if !@status.nil? && @status.status_reference.nil? error = "#{error}\nStatus must have a status reference." end if !@status.nil? && !@status.status_reference.nil? && @status.status_reference.validate.length > 0 error = "#{error}\n#{@status.status_reference.validate}" end if error.length > 0 error = "#{error}\n#{serialize()}" end return error end |
#with_status {|@status| ... } ⇒ Object
115 116 117 118 |
# File 'lib/go_import/model/deal.rb', line 115 def with_status @status = DealStatus.new if @status.nil? yield @status end |