openstax_salesforce 7.0.0 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +10 -2
- data/lib/openstax/salesforce/active_force.rb +3 -2
- data/lib/openstax/salesforce/client.rb +17 -14
- data/lib/openstax/salesforce/remote/account_contact_relation.rb +17 -10
- data/lib/openstax/salesforce/remote/book.rb +12 -5
- data/lib/openstax/salesforce/remote/campaign.rb +12 -5
- data/lib/openstax/salesforce/remote/campaign_member.rb +44 -37
- data/lib/openstax/salesforce/remote/contact.rb +32 -25
- data/lib/openstax/salesforce/remote/lead.rb +70 -63
- data/lib/openstax/salesforce/remote/opportunity.rb +67 -28
- data/lib/openstax/salesforce/remote/school.rb +23 -16
- data/lib/openstax/salesforce/remote/tutor_course_period.rb +31 -31
- data/lib/openstax/salesforce/spec_helpers.rb +11 -21
- data/lib/openstax/salesforce/version.rb +1 -1
- data/lib/openstax_salesforce.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 583953eef38f7cb4d3cc7c69d4186c8ce70c40d0a1d4cfe2deffb4532a30f3db
|
4
|
+
data.tar.gz: 7aa95b1f58e8b39dc4b2b5adfff5fb59a6d4b8f3acc5c11aaead9d6931707c9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8be9b66e18b856f8e381e23ba2d60f45a94920bc1a736b9da5996423ca4069ba6b9c8f38370d97cf1272395119096d2f865f3df285b337fff557331932261360
|
7
|
+
data.tar.gz: 2ac6a4b94054d6f8346da25022710890a92d28ab8515cd9213be0719caad7b6a8f84807fd2682debade62f62061461e0b136fb4c86c25b7a3e01b6881253a443
|
data/Rakefile
CHANGED
@@ -21,7 +21,15 @@ Bundler::GemHelper.install_tasks
|
|
21
21
|
require 'rspec/core'
|
22
22
|
require 'rspec/core/rake_task'
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
if defined?(RSpec)
|
25
|
+
desc 'Run factory specs.'
|
26
|
+
RSpec::Core::RakeTask.new(:factory_specs) do |t|
|
27
|
+
t.pattern = './spec/factories_spec.rb'
|
28
|
+
end
|
26
29
|
|
30
|
+
desc 'Run all specs in spec directory (excluding plugin specs)'
|
31
|
+
RSpec::Core::RakeTask.new :spec
|
32
|
+
end
|
33
|
+
|
34
|
+
task spec: :factory_specs
|
27
35
|
task default: :spec
|
@@ -1,12 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Monkey patching
|
3
4
|
module ActiveForce
|
4
5
|
class << self
|
5
6
|
# Use a lazy setting of the client so that migrations etc are in place
|
6
7
|
# to allow the Client to be successfully instantiated.
|
7
8
|
alias_method :original_sfdc_client, :sfdc_client
|
8
9
|
def sfdc_client
|
9
|
-
|
10
|
+
unless original_sfdc_client.is_a?(OpenStax::Salesforce::Client)
|
10
11
|
self.sfdc_client = OpenStax::Salesforce::Client.new
|
11
12
|
end
|
12
13
|
original_sfdc_client
|
@@ -1,19 +1,22 @@
|
|
1
|
-
module OpenStax
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module OpenStax
|
2
|
+
module Salesforce
|
3
|
+
# OpenStax Salesforce Client connection for Salesforce, inherits from Restforce Client
|
4
|
+
class Client < ::Restforce::Data::Client
|
5
|
+
def initialize
|
6
|
+
configuration = OpenStax::Salesforce.configuration
|
5
7
|
|
6
|
-
|
8
|
+
configuration.validate!
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
super(
|
11
|
+
username: configuration.username,
|
12
|
+
password: configuration.password,
|
13
|
+
security_token: configuration.security_token,
|
14
|
+
client_id: configuration.consumer_key,
|
15
|
+
client_secret: configuration.consumer_secret,
|
16
|
+
api_version: configuration.api_version,
|
17
|
+
host: configuration.login_domain
|
18
|
+
)
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
19
22
|
end
|
@@ -1,15 +1,22 @@
|
|
1
|
-
|
2
|
-
class AccountContactRelation < ActiveForce::SObject
|
3
|
-
belongs_to :school, foreign_key: :school_id,
|
4
|
-
model: OpenStax::Salesforce::Remote::School
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
6
|
-
|
7
|
-
|
3
|
+
module OpenStax
|
4
|
+
module Salesforce
|
5
|
+
module Remote
|
6
|
+
# School/Contact relation object from Salesforce
|
7
|
+
class AccountContactRelation < ActiveForce::SObject
|
8
|
+
belongs_to :school, foreign_key: :school_id,
|
9
|
+
model: OpenStax::Salesforce::Remote::School
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
field :school_id, from: 'AccountId'
|
11
|
+
belongs_to :contact, foreign_key: :contact_id,
|
12
|
+
model: OpenStax::Salesforce::Remote::Contact
|
12
13
|
|
13
|
-
|
14
|
+
field :contact_id, from: 'ContactId'
|
15
|
+
field :primary, from: 'IsDirect', as: :boolean
|
16
|
+
field :school_id, from: 'AccountId'
|
17
|
+
|
18
|
+
self.table_name = 'AccountContactRelation'
|
19
|
+
end
|
20
|
+
end
|
14
21
|
end
|
15
22
|
end
|
@@ -1,8 +1,15 @@
|
|
1
|
-
|
2
|
-
class Book < ActiveForce::SObject
|
3
|
-
field :name, from: "Name"
|
4
|
-
field :annualization_number, from: "Annualization_number__c", as: :decimal
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
6
|
-
|
3
|
+
module OpenStax
|
4
|
+
module Salesforce
|
5
|
+
module Remote
|
6
|
+
# Book object from Salesforce
|
7
|
+
class Book < ActiveForce::SObject
|
8
|
+
field :name, from: 'Name'
|
9
|
+
field :annualization_number, from: 'Annualization_number__c', as: :decimal
|
10
|
+
|
11
|
+
self.table_name = 'Book__c'
|
12
|
+
end
|
13
|
+
end
|
7
14
|
end
|
8
15
|
end
|
@@ -1,8 +1,15 @@
|
|
1
|
-
|
2
|
-
class Campaign < ActiveForce::SObject
|
3
|
-
field :is_active, from: "IsActive", as: :boolean
|
4
|
-
field :name, from: "Name"
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
6
|
-
|
3
|
+
module OpenStax
|
4
|
+
module Salesforce
|
5
|
+
module Remote
|
6
|
+
# Campaign object from Salesforce
|
7
|
+
class Campaign < ActiveForce::SObject
|
8
|
+
field :is_active, from: 'IsActive', as: :boolean
|
9
|
+
field :name, from: 'Name'
|
10
|
+
|
11
|
+
self.table_name = 'Campaign'
|
12
|
+
end
|
13
|
+
end
|
7
14
|
end
|
8
15
|
end
|
@@ -1,39 +1,46 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OpenStax
|
4
|
+
module Salesforce
|
5
|
+
module Remote
|
6
|
+
# CampaignMember object from Salesforce
|
7
|
+
class CampaignMember < ActiveForce::SObject
|
8
|
+
field :campaign_id, from: 'CampaignId'
|
9
|
+
field :contact_id, from: 'ContactId'
|
10
|
+
field :accounts_uuid, from: 'accounts_uuid__c'
|
11
|
+
|
12
|
+
field :pardot_reported_contact_id, from: 'pardot_reported_contact_id__c'
|
13
|
+
field :pardot_reported_piaid, from: 'pardot_reported_piaid__c'
|
14
|
+
field :pardot_reported_picid, from: 'pardot_reported_picid__c'
|
15
|
+
|
16
|
+
field :first_teacher_contact_id, from: 'first_teacher_contact_id__c'
|
17
|
+
|
18
|
+
field :arrived_marketing_page_from_pardot_at, from: 'arrived_marketing_page_from_pardot_at__c', as: :datetime
|
19
|
+
field :arrived_marketing_page_not_from_pardot_at, from: 'arrived_marketing_page_not_from_pardot_a__c', as: :datetime
|
20
|
+
field :first_arrived_my_courses_at, from: 'first_arrived_my_courses_at__c', as: :datetime
|
21
|
+
field :preview_created_at, from: 'preview_created_at__c', as: :datetime
|
22
|
+
field :real_course_created_at, from: 'real_course_created_at__c', as: :datetime
|
23
|
+
field :like_preview_ask_later_count, from: 'like_preview_ask_later_count__c', as: :int
|
24
|
+
field :like_preview_yes_at, from: 'like_preview_yes_at__c', as: :datetime
|
25
|
+
field :latest_adoption_decision, from: 'latest_adoption_decision__c', as: :picklist
|
26
|
+
field :latest_adoption_decision_at, from: 'latest_adoption_decision_at__c', as: :datetime
|
27
|
+
|
28
|
+
field :estimated_enrollment, from: 'Estimated_Enrollment__c', as: :int
|
29
|
+
field :ignored_osas, from: 'Ignored_OSAs__c', as: :boolean
|
30
|
+
|
31
|
+
field :percent_enrolled, from: 'Percent_Enrolled__c', as: :percent
|
32
|
+
field :school_type, from: 'School_Type__c'
|
33
|
+
field :students_registered, from: 'Students_Registered__c', as: :int
|
34
|
+
field :students_reported_by_teacher, from: 'Students_Reported_by_Teacher__c', as: :int
|
35
|
+
field :students_with_work, from: 'Students_with_work__c', as: :int
|
36
|
+
field :sync_field, from: 'SyncField__c', as: :datetime
|
37
|
+
|
38
|
+
belongs_to :contact, model: OpenStax::Salesforce::Remote::Contact
|
39
|
+
belongs_to :first_teacher_contact, model: OpenStax::Salesforce::Remote::Contact
|
40
|
+
belongs_to :pardot_reported_contact, model: OpenStax::Salesforce::Remote::Contact
|
41
|
+
|
42
|
+
self.table_name = 'CampaignMember'
|
43
|
+
end
|
44
|
+
end
|
38
45
|
end
|
39
46
|
end
|
@@ -1,29 +1,36 @@
|
|
1
|
-
|
2
|
-
class Contact < ActiveForce::SObject
|
3
|
-
belongs_to :school, foreign_key: :school_id,
|
4
|
-
model: OpenStax::Salesforce::Remote::School
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
field :faculty_verified, from: 'FV_Status__c'
|
14
|
-
field :last_modified_at, from: 'LastModifiedDate'
|
15
|
-
field :school_id, from: 'AccountId'
|
16
|
-
field :school_type, from: 'School_Type__c'
|
17
|
-
field :send_faculty_verification_to, from: 'SendFacultyVerificationTo__c'
|
18
|
-
field :all_emails, from: 'All_Emails__c'
|
19
|
-
field :confirmed_emails, from: 'Confirmed_Emails__c'
|
20
|
-
field :adoption_status, from: 'Adoption_Status__c'
|
21
|
-
field :grant_tutor_access, from: 'Grant_Tutor_Access__c', as: :boolean
|
22
|
-
field :b_r_i_marketing, from: 'BRI_Marketing__c', as: :boolean # Bill of Rights Institute (book) marketing
|
23
|
-
field :title_1_school, from: 'Title_1_school__c', as: :boolean
|
24
|
-
field :accounts_uuid, from: 'Accounts_UUID__c'
|
25
|
-
field :lead_source, from: 'LeadSource'
|
3
|
+
module OpenStax
|
4
|
+
module Salesforce
|
5
|
+
module Remote
|
6
|
+
# Contact object from Salesforce
|
7
|
+
class Contact < ActiveForce::SObject
|
8
|
+
belongs_to :school, foreign_key: :school_id,
|
9
|
+
model: OpenStax::Salesforce::Remote::School
|
26
10
|
|
27
|
-
|
11
|
+
field :id, from: 'Id'
|
12
|
+
field :name, from: 'Name'
|
13
|
+
field :first_name, from: 'FirstName'
|
14
|
+
field :last_name, from: 'LastName'
|
15
|
+
field :email, from: 'Email'
|
16
|
+
field :email_alt, from: 'Email_alt__c'
|
17
|
+
field :faculty_confirmed_date, from: 'Faculty_Confirmed_Date__c', as: :datetime
|
18
|
+
field :faculty_verified, from: 'FV_Status__c'
|
19
|
+
field :last_modified_at, from: 'LastModifiedDate'
|
20
|
+
field :school_id, from: 'AccountId'
|
21
|
+
field :school_type, from: 'School_Type__c'
|
22
|
+
field :send_faculty_verification_to, from: 'SendFacultyVerificationTo__c'
|
23
|
+
field :all_emails, from: 'All_Emails__c'
|
24
|
+
field :confirmed_emails, from: 'Confirmed_Emails__c'
|
25
|
+
field :adoption_status, from: 'Adoption_Status__c'
|
26
|
+
field :grant_tutor_access, from: 'Grant_Tutor_Access__c', as: :boolean
|
27
|
+
field :b_r_i_marketing, from: 'BRI_Marketing__c', as: :boolean # Bill of Rights Institute (book) marketing
|
28
|
+
field :title_1_school, from: 'Title_1_school__c', as: :boolean
|
29
|
+
field :accounts_uuid, from: 'Accounts_UUID__c'
|
30
|
+
field :lead_source, from: 'LeadSource'
|
31
|
+
|
32
|
+
self.table_name = 'Contact'
|
33
|
+
end
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
@@ -1,73 +1,80 @@
|
|
1
|
-
|
2
|
-
class Lead < ActiveForce::SObject
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
module OpenStax
|
4
|
+
module Salesforce
|
5
|
+
module Remote
|
6
|
+
# Lead object from Salesforce
|
7
|
+
class Lead < ActiveForce::SObject
|
9
8
|
|
10
|
-
|
9
|
+
VALID_VERIFICATION_STATUSES = %w[
|
10
|
+
pending_faculty
|
11
|
+
confirmed_faculty
|
12
|
+
rejected_faculty
|
13
|
+
].freeze
|
11
14
|
|
12
|
-
|
13
|
-
field :name, from: 'Name'
|
14
|
-
field :first_name, from: 'FirstName'
|
15
|
-
field :last_name, from: 'LastName'
|
16
|
-
field :salutation, from: 'Salutation'
|
17
|
-
field :title, from: 'Title'
|
18
|
-
field :subject, from: 'Subject__c'
|
19
|
-
field :school, from: 'Company'
|
20
|
-
field :city, from: 'City'
|
21
|
-
field :state, from: 'State'
|
22
|
-
field :state_code, from: 'StateCode'
|
23
|
-
field :country, from: 'Country'
|
24
|
-
field :phone, from: 'Phone'
|
25
|
-
field :website, from: 'Website'
|
26
|
-
field :status, from: 'Status'
|
27
|
-
field :email, from: 'Email'
|
28
|
-
field :source, from: 'LeadSource'
|
29
|
-
field :newsletter, from: 'Newsletter__c'
|
30
|
-
field :newsletter_opt_in, from: 'Newsletter_Opt_In__c'
|
31
|
-
field :adoption_status, from: 'Adoption_Status__c'
|
32
|
-
field :adoption_json, from: 'AdoptionsJSON__c'
|
33
|
-
field :num_students, from: 'Number_of_Students__c'
|
34
|
-
field :os_accounts_id, from: 'Accounts_ID__c'
|
35
|
-
field :accounts_uuid, from: 'Accounts_UUID__c'
|
36
|
-
field :application_source, from: 'Application_Source__c'
|
37
|
-
field :role, from: 'Role__c'
|
38
|
-
field :position, from: 'Position__c'
|
39
|
-
field :who_chooses_books, from: 'who_chooses_books__c'
|
40
|
-
field :verification_status, from: 'FV_Status__c'
|
41
|
-
field :b_r_i_marketing, from: 'BRI_Marketing__c', as: :boolean # Bill of Rights Institute (book) marketing
|
42
|
-
field :title_1_school, from: 'Title_1_school__c', as: :boolean
|
43
|
-
field :sheerid_school_name, from: 'SheerID_School_Name__c'
|
44
|
-
field :instant_conversion, from: 'Instant_Conversion__c', as: :boolean
|
15
|
+
VALID_WHO_CHOOSES_BOOKS = %w[instructor committee coordinator].freeze
|
45
16
|
|
46
|
-
|
47
|
-
|
48
|
-
|
17
|
+
field :id, from: 'Id'
|
18
|
+
field :name, from: 'Name'
|
19
|
+
field :first_name, from: 'FirstName'
|
20
|
+
field :last_name, from: 'LastName'
|
21
|
+
field :salutation, from: 'Salutation'
|
22
|
+
field :title, from: 'Title'
|
23
|
+
field :subject, from: 'Subject__c'
|
24
|
+
field :school, from: 'Company'
|
25
|
+
field :city, from: 'City'
|
26
|
+
field :state, from: 'State'
|
27
|
+
field :state_code, from: 'StateCode'
|
28
|
+
field :country, from: 'Country'
|
29
|
+
field :phone, from: 'Phone'
|
30
|
+
field :website, from: 'Website'
|
31
|
+
field :status, from: 'Status'
|
32
|
+
field :email, from: 'Email'
|
33
|
+
field :source, from: 'LeadSource'
|
34
|
+
field :newsletter, from: 'Newsletter__c'
|
35
|
+
field :newsletter_opt_in, from: 'Newsletter_Opt_In__c'
|
36
|
+
field :adoption_status, from: 'Adoption_Status__c'
|
37
|
+
field :adoption_json, from: 'AdoptionsJSON__c'
|
38
|
+
field :num_students, from: 'Number_of_Students__c'
|
39
|
+
field :os_accounts_id, from: 'Accounts_ID__c'
|
40
|
+
field :accounts_uuid, from: 'Accounts_UUID__c'
|
41
|
+
field :application_source, from: 'Application_Source__c'
|
42
|
+
field :role, from: 'Role__c'
|
43
|
+
field :position, from: 'Position__c'
|
44
|
+
field :who_chooses_books, from: 'who_chooses_books__c'
|
45
|
+
field :verification_status, from: 'FV_Status__c'
|
46
|
+
field :b_r_i_marketing, from: 'BRI_Marketing__c', as: :boolean # Bill of Rights Institute (book) marketing
|
47
|
+
field :title_1_school, from: 'Title_1_school__c', as: :boolean
|
48
|
+
field :sheerid_school_name, from: 'SheerID_School_Name__c'
|
49
|
+
field :instant_conversion, from: 'Instant_Conversion__c', as: :boolean
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
:verification_status,
|
54
|
-
allow_blank: true,
|
55
|
-
inclusion: {
|
56
|
-
in: VALID_VERIFICATION_STATUSES,
|
57
|
-
message: "must be either #{VALID_VERIFICATION_STATUSES.join(' or ')}"
|
58
|
-
}
|
59
|
-
)
|
51
|
+
# These 2 fields both hold the Account (School) ID, but have different data types and uses in SF
|
52
|
+
field :account_id, from: 'Account_ID__c'
|
53
|
+
field :school_id, from: 'School__c'
|
60
54
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
55
|
+
validates(:last_name, presence: true)
|
56
|
+
validates(:school, presence: true)
|
57
|
+
validates(
|
58
|
+
:verification_status,
|
59
|
+
allow_blank: true,
|
60
|
+
inclusion: {
|
61
|
+
in: VALID_VERIFICATION_STATUSES,
|
62
|
+
message: "must be either #{VALID_VERIFICATION_STATUSES.join(' or ')}"
|
63
|
+
}
|
64
|
+
)
|
69
65
|
|
70
|
-
|
66
|
+
validates(
|
67
|
+
:who_chooses_books,
|
68
|
+
allow_blank: true,
|
69
|
+
inclusion: {
|
70
|
+
in: VALID_WHO_CHOOSES_BOOKS,
|
71
|
+
message: "must be either #{VALID_WHO_CHOOSES_BOOKS.join(' or ')}"
|
72
|
+
}
|
73
|
+
)
|
71
74
|
|
75
|
+
self.table_name = 'Lead'
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
72
79
|
end
|
73
80
|
end
|
@@ -1,31 +1,70 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OpenStax
|
4
|
+
module Salesforce
|
5
|
+
module Remote
|
6
|
+
# Opportunity object from Salesforce
|
7
|
+
class Opportunity < ActiveForce::SObject
|
8
|
+
|
9
|
+
belongs_to :record_type, foreign_key: :record_type_id, model: OpenStax::Salesforce::Remote::RecordType
|
10
|
+
belongs_to :book, foreign_key: :book_id, model: OpenStax::Salesforce::Remote::Book
|
11
|
+
belongs_to :school, foreign_key: :school_id, model: OpenStax::Salesforce::Remote::School
|
12
|
+
|
13
|
+
VALID_STAGE_NAMES = [
|
14
|
+
'Confirmed Adoption Won',
|
15
|
+
'Closed Lost'
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
VALID_TYPES = [
|
19
|
+
'New Business',
|
20
|
+
'Renewal',
|
21
|
+
'Renewal - Verified'
|
22
|
+
].freeze
|
23
|
+
|
24
|
+
field :term_year, from: 'TermYear__c'
|
25
|
+
field :book_name, from: 'Book_Text__c'
|
26
|
+
field :contact_id, from: 'Contact__c'
|
27
|
+
field :close_date, from: 'CloseDate', as: :datetime
|
28
|
+
field :stage_name, from: 'StageName'
|
29
|
+
field :type, from: 'Type'
|
30
|
+
field :number_of_students, from: 'Students__c'
|
31
|
+
field :student_number_status, from: 'Student_No_Status__c'
|
32
|
+
field :time_period, from: 'Time_Period__c'
|
33
|
+
field :class_start_date, from: 'Class_Start_Date__c', as: :datetime
|
34
|
+
field :renewal_class_start_date, from: 'CSDInput__c', as: :datetime
|
35
|
+
field :school_id, from: 'AccountId'
|
36
|
+
field :book_id, from: 'Book__c'
|
37
|
+
field :contact_id, from: 'Contact__c'
|
38
|
+
field :os_accounts_id, from: 'OS_Accounts_ID__c'
|
39
|
+
field :accounts_uuid, from: 'Accounts_UUID__c'
|
40
|
+
field :name, from: 'Name'
|
41
|
+
field :record_type_name, from: 'Opportunity_Record_Type_Name__c'
|
42
|
+
field :record_type_id, from: 'RecordTypeId'
|
43
|
+
|
44
|
+
validates(
|
45
|
+
:stage_name,
|
46
|
+
allow_blank: false,
|
47
|
+
inclusion: {
|
48
|
+
in: VALID_STAGE_NAMES,
|
49
|
+
message: "must be either #{VALID_STAGE_NAMES.join(' or ')}"
|
50
|
+
}
|
51
|
+
)
|
52
|
+
|
53
|
+
validates(
|
54
|
+
:type,
|
55
|
+
allow_blank: false,
|
56
|
+
inclusion: {
|
57
|
+
in: VALID_TYPES,
|
58
|
+
message: "must be either #{VALID_TYPES.join(' or ')}"
|
59
|
+
}
|
60
|
+
)
|
61
|
+
|
62
|
+
self.table_name = 'Opportunity'
|
63
|
+
|
64
|
+
def term_year_object
|
65
|
+
@term_year_object ||= OpenStax::Salesforce::Remote::TermYear.from_string(term_year)
|
66
|
+
end
|
67
|
+
end
|
29
68
|
end
|
30
69
|
end
|
31
70
|
end
|
@@ -1,21 +1,28 @@
|
|
1
|
-
|
2
|
-
class School < ActiveForce::SObject
|
3
|
-
field :id, from: 'Id'
|
4
|
-
field :name, from: 'Name'
|
5
|
-
field :city, from: 'BillingCity'
|
6
|
-
field :state, from: 'BillingState'
|
7
|
-
field :country, from: 'BillingCountry'
|
8
|
-
field :type, from: 'Type'
|
9
|
-
field :school_location, from: 'School_Location__c'
|
10
|
-
field :sheerid_school_name, from: 'SheerID_School_Name__c'
|
11
|
-
field :is_kip, from: 'K_I_P__c', as: :boolean
|
12
|
-
field :is_child_of_kip, from: 'child_of_kip__c', as: :boolean
|
13
|
-
field :total_school_enrollment, from: 'Total_School_Enrollment__c', as: :integer
|
1
|
+
# frozen_string_literal: true
|
14
2
|
|
15
|
-
|
3
|
+
module OpenStax
|
4
|
+
module Salesforce
|
5
|
+
module Remote
|
6
|
+
# School object from Salesforce
|
7
|
+
class School < ActiveForce::SObject
|
8
|
+
field :id, from: 'Id'
|
9
|
+
field :name, from: 'Name'
|
10
|
+
field :city, from: 'BillingCity'
|
11
|
+
field :state, from: 'BillingState'
|
12
|
+
field :country, from: 'BillingCountry'
|
13
|
+
field :type, from: 'Type'
|
14
|
+
field :school_location, from: 'School_Location__c'
|
15
|
+
field :sheerid_school_name, from: 'SheerID_School_Name__c'
|
16
|
+
field :is_kip, from: 'K_I_P__c', as: :boolean
|
17
|
+
field :is_child_of_kip, from: 'child_of_kip__c', as: :boolean
|
18
|
+
field :total_school_enrollment, from: 'Total_School_Enrollment__c', as: :integer
|
16
19
|
|
17
|
-
|
18
|
-
|
20
|
+
self.table_name = 'Account'
|
21
|
+
|
22
|
+
def self.query
|
23
|
+
super.where("RecordType.Name = 'School'")
|
24
|
+
end
|
25
|
+
end
|
19
26
|
end
|
20
27
|
end
|
21
28
|
end
|
@@ -1,32 +1,32 @@
|
|
1
1
|
module OpenStax::Salesforce::Remote
|
2
2
|
class TutorCoursePeriod < ActiveForce::SObject
|
3
|
-
field :num_teachers, from:
|
4
|
-
field :base_year, from:
|
5
|
-
field :book_name, from:
|
6
|
-
field :contact_id, from:
|
7
|
-
field :course_code, from:
|
8
|
-
field :course_name, from:
|
9
|
-
field :course_start_date, from:
|
10
|
-
field :created_at, from:
|
11
|
-
field :teacher_email, from:
|
12
|
-
field :error, from:
|
13
|
-
field :estimated_enrollment, from:
|
14
|
-
field :course_id, from:
|
15
|
-
field :course_uuid, from:
|
16
|
-
field :latest_adoption_decision, from:
|
17
|
-
field :does_cost, from:
|
18
|
-
field :is_research, from:
|
19
|
-
field :num_periods, from:
|
20
|
-
field :status, from:
|
21
|
-
field :num_students_comped, from:
|
22
|
-
field :num_students_dropped, from:
|
23
|
-
field :num_students_paid, from:
|
24
|
-
field :num_students_refunded, from:
|
25
|
-
field :num_students, from:
|
26
|
-
field :num_students_with_work, from:
|
27
|
-
field :period_uuid, from:
|
28
|
-
field :term, from:
|
29
|
-
field :is_pilot, from:
|
3
|
+
field :num_teachers, from: 'Active_Teachers__c', as: :int
|
4
|
+
field :base_year, from: 'Base_Year__c', as: :int
|
5
|
+
field :book_name, from: 'Book_Name__c'
|
6
|
+
field :contact_id, from: 'Contact__c'
|
7
|
+
field :course_code, from: 'Course_Code__c'
|
8
|
+
field :course_name, from: 'Course_Name__c'
|
9
|
+
field :course_start_date, from: 'Course_Start_Date__c', as: :date
|
10
|
+
field :created_at, from: 'E_Created_Date__c', as: :datetime
|
11
|
+
field :teacher_email, from: 'Email__c'
|
12
|
+
field :error, from: 'Error__c'
|
13
|
+
field :estimated_enrollment, from: 'Estimated_Enrollment__c', as: :int
|
14
|
+
field :course_id, from: 'External_ID__c'
|
15
|
+
field :course_uuid, from: 'External_UUID__c'
|
16
|
+
field :latest_adoption_decision, from: 'Latest_Adoption_Decision__c'
|
17
|
+
field :does_cost, from: 'Paid_Course__c', as: :boolean
|
18
|
+
field :is_research, from: 'Research_Project__c', as: :boolean
|
19
|
+
field :num_periods, from: 'Sections__c', as: :int
|
20
|
+
field :status, from: 'Status__c', as: :picklist
|
21
|
+
field :num_students_comped, from: 'Students_Comped__c', as: :int
|
22
|
+
field :num_students_dropped, from: 'Students_Dropped__c', as: :int
|
23
|
+
field :num_students_paid, from: 'Students_Paid__c', as: :int
|
24
|
+
field :num_students_refunded, from: 'Students_Refunded__c', as: :int
|
25
|
+
field :num_students, from: 'Students_Using__c', as: :int
|
26
|
+
field :num_students_with_work, from: 'Students_With_Work__c', as: :int
|
27
|
+
field :period_uuid, from: 'Period_UUID__c'
|
28
|
+
field :term, from: 'Term__c'
|
29
|
+
field :is_pilot, from: 'Tutor_Pilot__c', as: :boolean
|
30
30
|
|
31
31
|
self.table_name = 'Tutor_Course__c'
|
32
32
|
|
@@ -41,9 +41,9 @@ module OpenStax::Salesforce::Remote
|
|
41
41
|
self.num_teachers = 0
|
42
42
|
end
|
43
43
|
|
44
|
-
STATUS_APPROVED =
|
45
|
-
STATUS_ARCHIVED =
|
46
|
-
STATUS_DROPPED =
|
47
|
-
STATUS_PREVIEW =
|
44
|
+
STATUS_APPROVED = 'Approved'.freeze
|
45
|
+
STATUS_ARCHIVED = 'ArchivedPeriod'.freeze
|
46
|
+
STATUS_DROPPED = 'Dropped'.freeze
|
47
|
+
STATUS_PREVIEW = 'Preview'.freeze
|
48
48
|
end
|
49
49
|
end
|
@@ -72,36 +72,30 @@ module OpenStax::Salesforce::SpecHelpers
|
|
72
72
|
@unique_token = nil
|
73
73
|
end
|
74
74
|
|
75
|
-
def new_contact(first_name: nil, last_name: nil, school_name: "
|
76
|
-
email: nil,
|
75
|
+
def new_contact(first_name: nil, last_name: nil, school_name: "RSpec University",
|
76
|
+
email: nil, faculty_verified: nil)
|
77
77
|
ensure_schools_exist([school_name])
|
78
78
|
|
79
79
|
Contact.new(
|
80
80
|
first_name: first_name || Faker::Name.first_name,
|
81
|
-
last_name: last_name
|
81
|
+
last_name: last_name || Faker::Name.last_name,
|
82
82
|
school_id: school_id(school_name),
|
83
|
-
email: email,
|
84
|
-
|
85
|
-
faculty_verified: faculty_verified,
|
86
|
-
school_type: school_type
|
83
|
+
email: email || Faker::Internet.safe_email,
|
84
|
+
faculty_verified: faculty_verified
|
87
85
|
).tap do |contact|
|
88
|
-
unless contact.save
|
89
|
-
raise "Could not save SF contact: #{contact.errors}"
|
90
|
-
end
|
86
|
+
raise "Could not save SF contact: #{contact.errors}" unless contact.save
|
91
87
|
end
|
92
88
|
end
|
93
89
|
|
94
|
-
def new_lead(email:, status: nil, last_name: nil, source: nil
|
90
|
+
def new_lead(email:, status: nil, last_name: nil, source: nil)
|
95
91
|
Lead.new(
|
96
92
|
email: email,
|
97
93
|
status: status,
|
98
94
|
last_name: last_name!(last_name),
|
99
|
-
school:
|
95
|
+
school: 'RSpec University',
|
100
96
|
source: source
|
101
97
|
).tap do |lead|
|
102
|
-
unless lead.save
|
103
|
-
raise "Could not save SF lead: #{lead.errors}"
|
104
|
-
end
|
98
|
+
raise "Could not save SF lead: #{lead.errors}" unless lead.save
|
105
99
|
end
|
106
100
|
end
|
107
101
|
|
@@ -109,9 +103,7 @@ module OpenStax::Salesforce::SpecHelpers
|
|
109
103
|
Campaign.new(
|
110
104
|
name: name
|
111
105
|
).tap do |campaign|
|
112
|
-
unless campaign.save
|
113
|
-
raise "Could not save SF Campaign: #{campaign.errors}"
|
114
|
-
end
|
106
|
+
raise "Could not save SF Campaign: #{campaign.errors}" unless campaign.save
|
115
107
|
end
|
116
108
|
end
|
117
109
|
|
@@ -120,9 +112,7 @@ module OpenStax::Salesforce::SpecHelpers
|
|
120
112
|
contact_id: contact_id,
|
121
113
|
campaign_id: campaign_id
|
122
114
|
).tap do |campaign_member|
|
123
|
-
unless campaign_member.save
|
124
|
-
raise "Could not save SF Campaign Member: #{campaign_member.errors}"
|
125
|
-
end
|
115
|
+
raise "Could not save SF Campaign Member: #{campaign_member.errors}" unless campaign_member.save
|
126
116
|
end
|
127
117
|
end
|
128
118
|
|
data/lib/openstax_salesforce.rb
CHANGED
@@ -7,6 +7,7 @@ require "openstax/salesforce/engine"
|
|
7
7
|
require "openstax/salesforce/client"
|
8
8
|
|
9
9
|
require "openstax/salesforce/remote/term_year"
|
10
|
+
require "openstax/salesforce/remote/record_type"
|
10
11
|
require "openstax/salesforce/remote/book"
|
11
12
|
require "openstax/salesforce/remote/school"
|
12
13
|
require "openstax/salesforce/remote/opportunity"
|
@@ -16,7 +17,6 @@ require "openstax/salesforce/remote/lead"
|
|
16
17
|
require "openstax/salesforce/remote/campaign"
|
17
18
|
require "openstax/salesforce/remote/campaign_member"
|
18
19
|
require "openstax/salesforce/remote/account_contact_relation"
|
19
|
-
require "openstax/salesforce/remote/record_type"
|
20
20
|
|
21
21
|
module OpenStax
|
22
22
|
module Salesforce
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstax_salesforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Slavinsky
|
8
8
|
- Dante Soares
|
9
|
+
- Michael Harrison
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2022-02-
|
13
|
+
date: 2022-02-22 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: rails
|
@@ -131,7 +132,7 @@ dependencies:
|
|
131
132
|
version: '0'
|
132
133
|
description: Interface gem for accessing OpenStax's Salesforce instance
|
133
134
|
email:
|
134
|
-
-
|
135
|
+
- mwharrison@rice.edu
|
135
136
|
executables: []
|
136
137
|
extensions: []
|
137
138
|
extra_rdoc_files: []
|