Class: CapsuleCRM::Opportunity

Inherits:
Base
  • Object
show all
Defined in:
lib/capsulecrm/opportunity.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#id, #raw_data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, #errors, find, #initialize, last_response, #new_record?

Constructor Details

This class inherits a constructor from CapsuleCRM::Base

Instance Attribute Details

#actual_close_dateObject

Returns the value of attribute actual_close_date.



10
11
12
# File 'lib/capsulecrm/opportunity.rb', line 10

def actual_close_date
  @actual_close_date
end

#created_onObject

Returns the value of attribute created_on.



13
14
15
# File 'lib/capsulecrm/opportunity.rb', line 13

def created_on
  @created_on
end

#currencyObject

Returns the value of attribute currency.



5
6
7
# File 'lib/capsulecrm/opportunity.rb', line 5

def currency
  @currency
end

#durationObject

Returns the value of attribute duration.



8
9
10
# File 'lib/capsulecrm/opportunity.rb', line 8

def duration
  @duration
end

#duration_basisObject

Returns the value of attribute duration_basis.



7
8
9
# File 'lib/capsulecrm/opportunity.rb', line 7

def duration_basis
  @duration_basis
end

#expected_close_dateObject

Returns the value of attribute expected_close_date.



9
10
11
# File 'lib/capsulecrm/opportunity.rb', line 9

def expected_close_date
  @expected_close_date
end

#milestoneObject

Returns the value of attribute milestone.



11
12
13
# File 'lib/capsulecrm/opportunity.rb', line 11

def milestone
  @milestone
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/capsulecrm/opportunity.rb', line 3

def name
  @name
end

#party_idObject

Returns the value of attribute party_id.



4
5
6
# File 'lib/capsulecrm/opportunity.rb', line 4

def party_id
  @party_id
end

#probabilityObject

Returns the value of attribute probability.



14
15
16
# File 'lib/capsulecrm/opportunity.rb', line 14

def probability
  @probability
end

#updated_onObject

Returns the value of attribute updated_on.



12
13
14
# File 'lib/capsulecrm/opportunity.rb', line 12

def updated_on
  @updated_on
end

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/capsulecrm/opportunity.rb', line 6

def value
  @value
end

Class Method Details

.get_pathObject

nodoc



42
43
44
# File 'lib/capsulecrm/opportunity.rb', line 42

def self.get_path
  '/api/opportunity'
end

.init_many(response) ⇒ Object

nodoc



48
49
50
51
# File 'lib/capsulecrm/opportunity.rb', line 48

def self.init_many(response)
  data = response['opportunities']['opportunity']
  CapsuleCRM::Collection.new(self, data)
end

.init_one(response) ⇒ Object

nodoc



55
56
57
58
# File 'lib/capsulecrm/opportunity.rb', line 55

def self.init_one(response)
  data = response['opportunity']
  new(attributes_from_xml_hash(data))
end

.xml_mapObject

nodoc



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/capsulecrm/opportunity.rb', line 17

def self.xml_map
  map = {
    'name' => 'name',
    'partyId' => 'party_id',
    'currency' => 'currency',
    'value' => 'value',
    'durationBasis' => 'duration_basis',
    'expectedCloseDate' => 'expected_close_date',
    'actualCloseDate' => 'actual_close_date',
    'milestone' => 'milestone',
    'updatedOn' => 'updated_on',
    'createdOn' => 'created_on',
    'probability' => 'probability',
  }
  super.merge map
end

Instance Method Details

#allObject



34
35
36
37
38
39
# File 'lib/capsulecrm/opportunity.rb', line 34

def all
  return @opportunities if @opportunities
  path = self.class.get_path
  last_response = self.class.get(path)
  @opportunities = CapsuleCRM::Opportunity.init_many(last_response)
end

#partyObject



60
61
62
63
# File 'lib/capsulecrm/opportunity.rb', line 60

def party
  return nil if party_id.nil?
  @party ||= CapsuleCRM::Party.find(party_id)
end