-
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
3 changed files
with
42 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| class Sf::Sponsorship | ||
| include Sf::Base | ||
| attr_reader :sobject | ||
| attr_accessor :sponsor | ||
|
|
||
| def initialize(sobject=nil) | ||
| @sobject = sobject.nil? ? Restforce::SObject.new(sobject_type: 'EventSponsorship__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 attrs_from_sponsor | ||
| attrs = {} | ||
| attrs["cms_sponsor_id__c"] = self.sponsor.id | ||
| attrs["cms_sponsor_name__c"] = self.sponsor.sponsor_name | ||
| attrs["event__c"] = self.sponsor.sf_event_id | ||
| attrs["logo_url__c"] = self.sponsor.image | ||
| attrs["sponsor__c"] = self.sponsor.sf_id unless self.sponsor.sf_id.blank? | ||
| attrs["sponsorship_type__c"] = self.sponsor.sponsorship_type.try(:humanize) | ||
| attrs | ||
| end | ||
|
|
||
| def create_from_sponsor | ||
| Sf.client.create!("EventSponsorship__c", self.attrs_from_sponsor) if self.sponsor.present? | ||
| end | ||
|
|
||
| def update_from_sponsor | ||
| attrs = self.attrs_from_sponsor | ||
| attrs["Id"] = self.Id | ||
| Sf.client.update!("EventSponsorship__c", attrs) if self.sponsor.present? | ||
| 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.1.8" | ||
| VERSION = "0.1.9" | ||
| end |