From e1a81d4c9ac79c494c8ba70a3cae6cb86bb54bec Mon Sep 17 00:00:00 2001 From: IJ Kim Date: Thu, 20 Jul 2017 15:39:48 -0400 Subject: [PATCH] added eduroam opportunity list --- lib/sf/contact.rb | 15 +++++++++++---- lib/sf/opportunity.rb | 12 ++++++++++++ lib/sf/version.rb | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/sf/contact.rb b/lib/sf/contact.rb index e81887e..8c255f1 100644 --- a/lib/sf/contact.rb +++ b/lib/sf/contact.rb @@ -37,6 +37,10 @@ def update(args={}) Sf.client.update!("Contact", params) end + def update_biography(biography) + Sf.client.update!("Contact", {'Id' => self.Id, 'Biography__c' => biography}) + end + def set_person_by_email(email) self.person = Sf::Contact.find_by(Email: email) end @@ -98,16 +102,19 @@ def sf_person_mapping 'zip' => 'MailingPostalCode', 'country' => 'MailingCountry', 'exclude_directory' => 'Meeting_Reg_Pre_Population_Opt_Out__c', + 'biography' => 'Biography__c', 'sf_id' => 'Id', 'sf_account_id' => 'AccountId' } end def compare_attr(sf_attrs, person_attr, sf_attr) - person_value = person.send(person_attr) - sf_value = self.send(sf_attr) - if person_value.present? and !person_value.eql?(sf_value) - sf_attrs[sf_attr] = person_value + if person.respond_to?(person_attr) + person_value = person.send(person_attr) + sf_value = self.send(sf_attr) + if person_value.present? and !person_value.eql?(sf_value) + sf_attrs[sf_attr] = person_value + end end end def self.find(id) diff --git a/lib/sf/opportunity.rb b/lib/sf/opportunity.rb index 7b138b0..c1807fe 100644 --- a/lib/sf/opportunity.rb +++ b/lib/sf/opportunity.rb @@ -38,4 +38,16 @@ def self.cert_subscribers(since_date=nil) sobjects = Sf.client.query("select #{FIELDS_SELECT_STR} from Opportunity where Name like '%Certificate Service%' and IsWon = true and CloseDate >= #{since}") build_collection sobjects unless sobjects.blank? end + + def self.eduroam_opportunities + stages = "('Closed Won', 'Negotiation/Review', 'Transferred Internally', 'Proposal/Price Quote', 'Prospecting')" + sobjects = Sf.client.query("select #{FIELDS_SELECT_STR}, Account.Name from Opportunity where Name like '%Trust and Identity - eduroam%' and StageName in #{stages}") + build_collection sobjects unless sobjects.blank? + end + + # stages + # "Prospecting", "Closed Won", "Proposal/Price Quote", "Closed Lost", + # "Negotiation/Review", "INACTIVE", "Value Proposition", + # "Transferred Internally", "Referred", "Id. Decision Makers", + # "Needs Analysis", "Qualification", "Perception Analysis" end diff --git a/lib/sf/version.rb b/lib/sf/version.rb index 4df1306..39ac944 100644 --- a/lib/sf/version.rb +++ b/lib/sf/version.rb @@ -1,3 +1,3 @@ module Sf - VERSION = "0.1.50" + VERSION = "0.1.51" end