-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
175 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| class Sf::Presenter | ||
| include Sf::Base | ||
| attr_reader :sobject | ||
|
|
||
| def initialize(sobject=nil) | ||
| @sobject = sobject.nil? ? Restforce::SObject.new(sobject_type: 'EventPresenter__c') : sobject | ||
| end | ||
|
|
||
| def method_missing(method_name, *args, &block) | ||
| @sobject.send(method_name, *args, &block) | ||
| end | ||
|
|
||
| def respond_to_missing?(method_name, include_private = false) | ||
| @sobject.respond_to?(method_name, include_private) || super | ||
| end | ||
|
|
||
| def where(args = {}) | ||
| where = args.map {|k,v| "#{k} = \'#{v}\'"}.join(" and ") | ||
| sobjects = Sf.client.query("select Id, Name, cms_presenter_id__c from #{self.class_name} where #{where}") | ||
| build_collection sobjects unless sobjects.blank? | ||
| end | ||
|
|
||
| end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| class Sf::Session | ||
| include Sf::Base | ||
| attr_reader :sobject | ||
| attr_accessor :proposal | ||
|
|
||
| def initialize(sobject=nil) | ||
| @sobject = sobject.nil? ? Restforce::SObject.new(sobject_type: 'EventSession__c') : sobject | ||
| end | ||
|
|
||
| def method_missing(method_name, *args, &block) | ||
| @sobject.send(method_name, *args, &block) | ||
| end | ||
|
|
||
| def respond_to_missing?(method_name, include_private = false) | ||
| @sobject.respond_to?(method_name, include_private) || super | ||
| end | ||
|
|
||
| def create_from_proposal | ||
| Sf.client.create!('EventSession__c', proposal_attrs) | ||
| end | ||
|
|
||
| def proposal_attrs | ||
| sf_event = Sf::RegEvent.find_by_code(self.proposal.meeting_config.event_code) | ||
| attrs = {} | ||
| attrs['event__c'] = sf_event.Id | ||
| attrs['Name'] = self.proposal.session_title[0..79] | ||
| attrs['title__c'] = self.proposal.session_title | ||
| attrs['abstract__c'] = self.proposal.abstract | ||
| attrs['cms_proposal_id__c'] = self.proposal.id | ||
| attrs['submitter_email__c'] = self.proposal.submitter_email | ||
| attrs['submitter_phone__c'] = self.proposal.submitter_phone | ||
| attrs['cms_proposal_id__c'] = self.proposal.id | ||
| if session_type_id = self.proposal.session_type_id | ||
| sf_session_type = Sf::SessionType.find_by(cms_session_type_id__c: session_type_id) | ||
| attrs['session_type__c'] = sf_session_type.Id unless sf_session_type.blank? | ||
| end | ||
| if primary_track_id = self.proposal.primary_track_id | ||
| sf_primary_track = Sf::Track.find_by(cms_track_id__c: primary_track_id) | ||
| attrs['primary_track_id__c'] = sf_primary_track.Id unless sf_primary_track.blank? | ||
| end | ||
| if secondary_track_id = self.proposal.secondary_track_id | ||
| sf_secondary_track = Sf::Track.find_by(cms_track_id__c: secondary_track_id) | ||
| attrs['secondary_track_id__c'] = sf_secondary_track.Id unless sf_secondary_track.blank? | ||
| end | ||
| attrs['timestamp__c'] = Time.now.iso8601 | ||
| meeting = self.proposal.meeting_config.meeting | ||
| if meeting.present? | ||
| attrs['cms_meeting_id__c'] = meeting.id | ||
| end | ||
| attrs | ||
| end | ||
|
|
||
| def timestamp | ||
| self.timestamp__c.try(:to_datetime) | ||
| end | ||
|
|
||
| def ready_to_publish? | ||
| required_attrs = %w(title__c abstract__c timestamp__c start_time__c date__c end_time__c) | ||
| ready = true | ||
| required_attrs.each do |attr| | ||
| if attr.blank? | ||
| ready = false | ||
| break | ||
| end | ||
| end | ||
| ready | ||
| end | ||
|
|
||
| def self.by_event_code(code) | ||
| event = Sf::RegEvent.find_by(code__c: code) | ||
| self.where(event__c: event.Id) unless event.blank? | ||
| end | ||
|
|
||
| def self.where(args = {}) | ||
| where = args.map {|k,v| "#{k} = \'#{v}\'"}.join(" and ") | ||
| sobjects = Sf.client.query("select Id, Name, title__c, primary_track_id__r.Name, session_type__r.Name, start_time__c, room_id__r.Name, cms_session_id__c from EventSession__c where #{where}") | ||
| build_collection sobjects unless sobjects.blank? | ||
| end | ||
| end | ||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| class Sf::SessionType | ||
| include Sf::Base | ||
| attr_reader :sobject, :sesstion_type | ||
| def initialize(sobject=nil) | ||
| @sobject = sobject.nil? ? Restforce::SObject.new(sobject_type: 'EventSessionType__c') : sobject | ||
| end | ||
|
|
||
| def method_missing(method_name, *args, &block) | ||
| @sobject.send(method_name, *args, &block) | ||
| end | ||
|
|
||
| def respond_to_missing?(method_name, include_private = false) | ||
| @sobject.respond_to?(method_name, include_private) || super | ||
| end | ||
|
|
||
|
|
||
| end | ||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| class Sf::Track | ||
| include Sf::Base | ||
| attr_reader :sobject | ||
| attr_accessor :track | ||
|
|
||
| def initialize(sobject=nil) | ||
| @sobject = sobject.nil? ? Restforce::SObject.new(sobject_type: 'EventTrack__c') : sobject | ||
| end | ||
|
|
||
| def method_missing(method_name, *args, &block) | ||
| @sobject.send(method_name, *args, &block) | ||
| end | ||
|
|
||
| def respond_to_missing?(method_name, include_private = false) | ||
| @sobject.respond_to?(method_name, include_private) || super | ||
| end | ||
| end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| module Sf | ||
| VERSION = "0.0.4" | ||
| VERSION = "0.1.4" | ||
| end |