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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdbcb2ca4eabdf7962da5946b5e6769d6b8642d30daa503265028255a693f158
4
- data.tar.gz: e0572de4235bca3f219a5a2b650ffc83f8627ef43f438a2ebfa042ed8c169fbf
3
+ metadata.gz: 583953eef38f7cb4d3cc7c69d4186c8ce70c40d0a1d4cfe2deffb4532a30f3db
4
+ data.tar.gz: 7aa95b1f58e8b39dc4b2b5adfff5fb59a6d4b8f3acc5c11aaead9d6931707c9a
5
5
  SHA512:
6
- metadata.gz: fa20d717b00457b204d9933eba0258d2fc404b2d204fc303f1772aecaf631acf5bd2b75c68defa4657b292734d7c3f9f66f82fb01d8a5d6c5d32add42051daa8
7
- data.tar.gz: fd40c79d4e641a78d514b6cc76ca65d401d16b96fd36d33444cc3a437a08ef099f75dd3701ab12775e346c4599f279a57fce68f07616092889728469dc341788
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
- desc 'Run all specs in spec directory (excluding plugin specs)'
25
- RSpec::Core::RakeTask.new :spec
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
- # Monkey patching
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
- if !original_sfdc_client.is_a?(OpenStax::Salesforce::Client)
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::Salesforce
2
- class Client < ::Restforce::Data::Client
3
- def initialize
4
- configuration = OpenStax::Salesforce.configuration
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
- configuration.validate!
8
+ configuration.validate!
7
9
 
8
- super(
9
- username: configuration.username,
10
- password: configuration.password,
11
- security_token: configuration.security_token,
12
- client_id: configuration.consumer_key,
13
- client_secret: configuration.consumer_secret,
14
- api_version: configuration.api_version,
15
- host: configuration.login_domain
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
- module OpenStax::Salesforce::Remote
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
- belongs_to :contact, foreign_key: :contact_id,
7
- model: OpenStax::Salesforce::Remote::Contact
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
- field :contact_id, from: 'ContactId'
10
- field :primary, from: 'IsDirect', as: :boolean
11
- field :school_id, from: 'AccountId'
11
+ belongs_to :contact, foreign_key: :contact_id,
12
+ model: OpenStax::Salesforce::Remote::Contact
12
13
 
13
- self.table_name = 'AccountContactRelation'
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
- module OpenStax::Salesforce::Remote
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
- self.table_name = 'Book__c'
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
- module OpenStax::Salesforce::Remote
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
- self.table_name = 'Campaign'
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
- module OpenStax::Salesforce::Remote
2
- class CampaignMember < ActiveForce::SObject
3
- field :campaign_id, from: "CampaignId"
4
- field :contact_id, from: "ContactId"
5
- field :accounts_uuid, from: "accounts_uuid__c"
6
-
7
- field :pardot_reported_contact_id, from: "pardot_reported_contact_id__c"
8
- field :pardot_reported_piaid, from: "pardot_reported_piaid__c"
9
- field :pardot_reported_picid, from: "pardot_reported_picid__c"
10
-
11
- field :first_teacher_contact_id, from: "first_teacher_contact_id__c"
12
-
13
- field :arrived_marketing_page_from_pardot_at, from: "arrived_marketing_page_from_pardot_at__c", as: :datetime
14
- field :arrived_marketing_page_not_from_pardot_at, from: "arrived_marketing_page_not_from_pardot_a__c", as: :datetime
15
- field :first_arrived_my_courses_at, from: "first_arrived_my_courses_at__c", as: :datetime
16
- field :preview_created_at, from: "preview_created_at__c", as: :datetime
17
- field :real_course_created_at, from: "real_course_created_at__c", as: :datetime
18
- field :like_preview_ask_later_count, from: "like_preview_ask_later_count__c", as: :int
19
- field :like_preview_yes_at, from: "like_preview_yes_at__c", as: :datetime
20
- field :latest_adoption_decision, from: "latest_adoption_decision__c", as: :picklist
21
- field :latest_adoption_decision_at, from: "latest_adoption_decision_at__c", as: :datetime
22
-
23
- field :estimated_enrollment, from: "Estimated_Enrollment__c", as: :int
24
- field :ignored_osas, from: "Ignored_OSAs__c", as: :boolean
25
-
26
- field :percent_enrolled, from: "Percent_Enrolled__c", as: :percent
27
- field :school_type, from: "School_Type__c"
28
- field :students_registered, from: "Students_Registered__c", as: :int
29
- field :students_reported_by_teacher, from: "Students_Reported_by_Teacher__c", as: :int
30
- field :students_with_work, from: "Students_with_work__c", as: :int
31
- field :sync_field, from: "SyncField__c", as: :datetime
32
-
33
- belongs_to :contact, model: OpenStax::Salesforce::Remote::Contact
34
- belongs_to :first_teacher_contact, model: OpenStax::Salesforce::Remote::Contact
35
- belongs_to :pardot_reported_contact, model: OpenStax::Salesforce::Remote::Contact
36
-
37
- self.table_name = 'CampaignMember'
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
- module OpenStax::Salesforce::Remote
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
- field :id, from: 'Id'
7
- field :name, from: 'Name'
8
- field :first_name, from: 'FirstName'
9
- field :last_name, from: 'LastName'
10
- field :email, from: 'Email'
11
- field :email_alt, from: 'Email_alt__c'
12
- field :faculty_confirmed_date, from: 'Faculty_Confirmed_Date__c', as: :datetime
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
- self.table_name = 'Contact'
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
- module OpenStax::Salesforce::Remote
2
- class Lead < ActiveForce::SObject
1
+ # frozen_string_literal: true
3
2
 
4
- VALID_VERIFICATION_STATUSES = %w[
5
- pending_faculty
6
- confirmed_faculty
7
- rejected_faculty
8
- ].freeze
3
+ module OpenStax
4
+ module Salesforce
5
+ module Remote
6
+ # Lead object from Salesforce
7
+ class Lead < ActiveForce::SObject
9
8
 
10
- VALID_WHO_CHOOSES_BOOKS = %w[instructor committee coordinator].freeze
9
+ VALID_VERIFICATION_STATUSES = %w[
10
+ pending_faculty
11
+ confirmed_faculty
12
+ rejected_faculty
13
+ ].freeze
11
14
 
12
- field :id, from: 'Id'
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
- # These 2 fields both hold the Account (School) ID, but have different data types and uses in SF
47
- field :account_id, from: 'Account_ID__c'
48
- field :school_id, from: 'School__c'
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
- validates(:last_name, presence: true)
51
- validates(:school, presence: true)
52
- validates(
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
- validates(
62
- :who_chooses_books,
63
- allow_blank: true,
64
- inclusion: {
65
- in: VALID_WHO_CHOOSES_BOOKS,
66
- message: "must be either #{VALID_WHO_CHOOSES_BOOKS.join(' or ')}"
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
- self.table_name = 'Lead'
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
- module OpenStax::Salesforce::Remote
2
- class Opportunity < ActiveForce::SObject
3
- field :term_year, from: "TermYear__c"
4
- field :book_name, from: "Book_Text__c"
5
- field :contact_id, from: "Contact__c"
6
- field :renewal_status, from: "Renewal_Status__c"
7
- field :close_date, from: "CloseDate", as: :datetime
8
- field :stage_name, from: "StageName"
9
- field :type, from: "Type"
10
- field :number_of_students, from: "Students__c"
11
- field :student_number_status, from: "Student_No_Status__c"
12
- field :time_period, from: "Time_Period__c"
13
- field :class_start_date, from: "Class_Start_Date__c", as: :datetime
14
- field :renewal_class_start_date, from: "CSDInput__c", as: :datetime
15
- field :school_id, from: "AccountId"
16
- field :book_id, from: "Book__c"
17
- field :contact_id, from: "Contact__c"
18
- field :os_accounts_id, from: "OS_Accounts_ID__c"
19
- field :accounts_uuid, from: 'Accounts_UUID__c'
20
- field :name, from: "Name"
21
- field :record_type_name, from: "Opportunity_Record_Type_Name__c"
22
- field :record_type_id, from: "RecordTypeId"
23
-
24
-
25
- self.table_name = 'Opportunity'
26
-
27
- def term_year_object
28
- @term_year_object ||= OpenStax::Salesforce::Remote::TermYear.from_string(term_year)
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
- module OpenStax::Salesforce::Remote
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
- self.table_name = 'Account'
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
- def self.query
18
- super.where("RecordType.Name = 'School'")
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: "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
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 = "Approved"
45
- STATUS_ARCHIVED = "ArchivedPeriod"
46
- STATUS_DROPPED = "Dropped"
47
- STATUS_PREVIEW = "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: "JP University",
76
- email: nil, email_alt: nil, faculty_verified: nil, school_type: 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!(last_name),
81
+ last_name: last_name || Faker::Name.last_name,
82
82
  school_id: school_id(school_name),
83
- email: email,
84
- email_alt: email_alt,
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, school_name: "JP University")
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: school_name,
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
 
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Salesforce
3
- VERSION = '7.0.0'
3
+ VERSION = '7.1.0'
4
4
  end
5
5
  end
@@ -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.0.0
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-16 00:00:00.000000000 Z
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
- - jps@kindlinglabs.com
135
+ - mwharrison@rice.edu
135
136
  executables: []
136
137
  extensions: []
137
138
  extra_rdoc_files: []