Skip to content

Commit

Permalink
added service institution
Browse files Browse the repository at this point in the history
  • Loading branch information
ij committed Sep 28, 2015
1 parent bd91aa4 commit 2d9c725
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/sf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require "sf/room"
require "sf/venue"
require "sf/opportunity"
require "sf/service_institution"
module Sf
class << self
def client
Expand Down
13 changes: 13 additions & 0 deletions lib/sf/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,17 @@ def self.inc_certs_to_be
build_collection Sf.client.query("select #{FIELDS_SELECT_STR} from Account where InCommon_Participant__c = true and Id in (#{accts_str})")
end

def self.active_inc_parts(service_name)
today = Date.today.strftime('%Y-%m-%d')
sobjects = Sf.client.query("select
Supporting_Institution__r.Id,
Supporting_Institution__r.Name,
Supporting_Institution__r.InCommon_Website_Name__c,
Supporting_Institution__r.InCommon_Participant_Type__c,
Supporting_Institution__r.InCommon_Weblink__c
from Service_Institution__c where Service__r.Name = \'#{service_name}\'
and (Service_End_Date__c = null or Service_End_Date__c > today)
and (Service_Start_Date__c = null or Service_Start_Date__c < today)")
build_collection sobjects.map(&:Supporting_Institution__r) unless sobjects.blank?
end
end
39 changes: 39 additions & 0 deletions lib/sf/service_institution.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
class Sf::ServiceInstitution
include Sf::Base
API_NAME = 'Service_Institution__c'
FIELDS = [
'Id', 'Name', 'Account_ID__c', 'Current_Phase__c', 'Do_Not_Publish__c',
'Provider__c', 'Service__c', 'Service_End_Date__c', 'Service_Provider__c',
'Service_Start_Date__c', 'Subscription__c', 'Supporting_Institution__c',
'Tier_of_Support__c'
]
FIELDS_SELECT_STR = FIELDS.join(', ')

def initialize(service_institution = nil)
@service_institution = service_institution
end

def account
new Sf::Account.find("Account", Supporting_Institution__c)
end

def method_missing(method_name, *args, &block)
@contact_affiliation.send(method_name, *args, &block)
end

def respond_to_missing?(method_name, include_private = false)
@contact_affiliation.respond_to?(method_name, include_private) || super
end

def self.find(id)
new Sf.client.find("ServiceInstitution__c", id)
end

def self.where(args = {})
where = args.map {|k,v| "#{k} = \'#{v}\'"}.join(" and ")
sobjects = Sf.client.query("select #{FIELDS_SELECT_STR} from #{API_NAME} where #{where}")
build_collection sobjects unless sobjects.blank?
end

end

2 changes: 1 addition & 1 deletion lib/sf/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Sf
VERSION = "0.1.30"
VERSION = "0.1.31"
end

0 comments on commit 2d9c725

Please sign in to comment.