Class: Insightly::Opportunity
Constant Summary
collapse
- CUSTOM_FIELD_PREFIX =
"OPPORTUNITY_FIELD"
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from TagHelper
#add_tag, #tags, #tags=
Methods included from LinkHelper
#add_link, #links, #links=
Methods inherited from ReadWrite
#post_collection, #put_collection, #to_json, #update_data
Methods inherited from Base
#==, all, api_field, build, #build, #config, custom_fields, #get_collection, #initialize, #load, #process, #reload, #remote_data, #to_json, #url_base
Class Method Details
.find_by_name(name) ⇒ Object
82
83
84
85
86
87
|
# File 'lib/insightly/opportunity.rb', line 82
def self.find_by_name(name)
Insightly::Opportunity.all.each do |o|
return o if o.opportunity_name && o.opportunity_name == name
end
nil
end
|
.search_by_name(name) ⇒ Object
89
90
91
92
93
94
95
96
97
|
# File 'lib/insightly/opportunity.rb', line 89
def self.search_by_name(name)
list = []
Insightly::Opportunity.all.each do |o|
if o.opportunity_name && o.opportunity_name.match(name)
list << o
end
end
list
end
|
Instance Method Details
#fix_for_link(link) ⇒ Object
112
113
114
115
116
|
# File 'lib/insightly/opportunity.rb', line 112
def fix_for_link(link)
link.opportunity_id = self.remote_id
link
end
|
#remote_id ⇒ Object
41
42
43
|
# File 'lib/insightly/opportunity.rb', line 41
def remote_id
opportunity_id
end
|
#save ⇒ Object
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/insightly/opportunity.rb', line 99
def save
creating = remote_id ? false : true
super
if creating
@state_reason = Insightly::OpportunityStateReason.find_by_state_reason("Open", "Created by API")
if @state_reason
put_collection("OpportunityStateChange/#{opportunity_id}", @state_reason.remote_data.to_json)
end
end
end
|