openstax_salesforce 4.0.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/initializers/openstax_salesforce.rb +4 -0
- data/lib/openstax/salesforce/engine.rb +5 -3
- data/lib/openstax/salesforce/remote/lead.rb +45 -0
- data/lib/openstax/salesforce/remote/school.rb +5 -1
- data/lib/openstax/salesforce/spec_helpers.rb +37 -14
- data/lib/openstax/salesforce/version.rb +1 -1
- metadata +14 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4af4bba63b1345bb56d81997d7aa50a8f6c54a8543231cf1404200e0aa9e57cf
|
4
|
+
data.tar.gz: 854d11cc4dbb4e5ba190ef12f4973c4c2712c3ec3c9790795d8660ca1bb5826f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f4506420c7f30b59896e6fba242aff72ef55dec86270fbbb0b4089d9b3bbe725c2be6c8b3584e5a36906b5b043f547b9cd4676e0cb093ed6e24a357f97650fd
|
7
|
+
data.tar.gz: 2f5a63de18f7deaaf7aa8d08608c3cd686af132ab542bf67bafff851c38d61dbd71e1571dd8f953664daff0beb3e7912b747a00a4c13f91664939cc8f87694f1
|
@@ -5,6 +5,10 @@
|
|
5
5
|
OpenStax::Salesforce.configure do |config|
|
6
6
|
salesforce_secrets = Rails.application.secrets.salesforce
|
7
7
|
|
8
|
+
if salesforce_secrets.nil?
|
9
|
+
raise "Add a `salesforce` section to your Rails secrets!"
|
10
|
+
end
|
11
|
+
|
8
12
|
# Username, client id, instance url and private key for connecting to the Salesforce app
|
9
13
|
config.username = salesforce_secrets[:username]
|
10
14
|
config.password = salesforce_secrets[:password]
|
@@ -2,8 +2,10 @@ ActiveSupport::Inflector.inflections do |inflect|
|
|
2
2
|
inflect.acronym 'OpenStax'
|
3
3
|
end
|
4
4
|
|
5
|
-
module OpenStax
|
6
|
-
|
7
|
-
|
5
|
+
module OpenStax
|
6
|
+
module Salesforce
|
7
|
+
class Engine < ::Rails::Engine
|
8
|
+
isolate_namespace OpenStax::Salesforce
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
@@ -1,5 +1,19 @@
|
|
1
1
|
module OpenStax::Salesforce::Remote
|
2
2
|
class Lead < ActiveForce::SObject
|
3
|
+
|
4
|
+
VALID_VERIFICATION_STATUSES = %w[pending_faculty confirmed_faculty rejected_faculty].freeze
|
5
|
+
VALID_ROLES = %w[
|
6
|
+
student
|
7
|
+
faculty
|
8
|
+
other
|
9
|
+
administrator
|
10
|
+
librarian
|
11
|
+
adjunct\ faculty
|
12
|
+
instructional\ designer
|
13
|
+
home\ school\ teacher
|
14
|
+
].freeze
|
15
|
+
VALID_WHO_CHOOSES_BOOKS = %w[instructor committee coordinator].freeze
|
16
|
+
|
3
17
|
field :name, from: "Name"
|
4
18
|
field :first_name, from: "FirstName"
|
5
19
|
field :last_name, from: "LastName"
|
@@ -19,7 +33,38 @@ module OpenStax::Salesforce::Remote
|
|
19
33
|
field :accounts_uuid, from: "accounts_uuid_c__c"
|
20
34
|
field :application_source, from: "Application_Source__c"
|
21
35
|
field :role, from: "Role__c"
|
36
|
+
field :who_chooses_books, from: "who_chooses_books__c"
|
37
|
+
field :verification_status, from: "FV_Status__c"
|
38
|
+
field :finalize_educator_signup, from: "FV_Final__c", as: :boolean
|
39
|
+
|
40
|
+
validates(
|
41
|
+
:role,
|
42
|
+
allow_blank: true,
|
43
|
+
inclusion: {
|
44
|
+
in: VALID_ROLES,
|
45
|
+
message: "must be either #{VALID_ROLES.join(' or ')}"
|
46
|
+
}
|
47
|
+
)
|
48
|
+
|
49
|
+
validates(
|
50
|
+
:verification_status,
|
51
|
+
allow_blank: true,
|
52
|
+
inclusion: {
|
53
|
+
in: VALID_VERIFICATION_STATUSES,
|
54
|
+
message: "must be either #{VALID_VERIFICATION_STATUSES.join(' or ')}"
|
55
|
+
}
|
56
|
+
)
|
57
|
+
|
58
|
+
validates(
|
59
|
+
:who_chooses_books,
|
60
|
+
allow_blank: true,
|
61
|
+
inclusion: {
|
62
|
+
in: VALID_WHO_CHOOSES_BOOKS,
|
63
|
+
message: "must be either #{VALID_WHO_CHOOSES_BOOKS.join(' or ')}"
|
64
|
+
}
|
65
|
+
)
|
22
66
|
|
23
67
|
self.table_name = 'Lead'
|
68
|
+
|
24
69
|
end
|
25
70
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module OpenStax::Salesforce::Remote
|
2
2
|
class School < ActiveForce::SObject
|
3
|
-
field :name,
|
3
|
+
field :name, from: 'Name'
|
4
|
+
field :type, from: 'Type'
|
5
|
+
field :school_location, from: 'School_Location__c'
|
6
|
+
field :is_kip, from: 'K_I_P__c', as: :boolean
|
7
|
+
field :is_child_of_kip, from: 'child_of_kip__c', as: :boolean
|
4
8
|
|
5
9
|
self.table_name = 'Account'
|
6
10
|
end
|
@@ -131,27 +131,23 @@ module OpenStax::Salesforce::SpecHelpers
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def ensure_books_exist(book_names)
|
134
|
-
book_names.
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
books.push(book)
|
139
|
-
end
|
134
|
+
@books = OpenStax::Salesforce::Remote::Book.where(name: book_names).to_a
|
135
|
+
|
136
|
+
(book_names - books.map(&:name)).each do |book_name|
|
137
|
+
OpenStax::Salesforce::Remote::Book.new(name: book_name).save!
|
140
138
|
end
|
141
139
|
end
|
142
140
|
|
143
141
|
def ensure_schools_exist(school_names)
|
144
|
-
school_names.
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
schools.push(school)
|
149
|
-
end
|
142
|
+
@schools = OpenStax::Salesforce::Remote::School.where(name: school_names).to_a
|
143
|
+
|
144
|
+
(school_names - schools.map(&:name)).each do |school_name|
|
145
|
+
OpenStax::Salesforce::Remote::School.new(name: school_name).save!
|
150
146
|
end
|
151
147
|
end
|
152
148
|
|
153
149
|
def books
|
154
|
-
@books ||= Book.all
|
150
|
+
@books ||= OpenStax::Salesforce::Remote::Book.all
|
155
151
|
end
|
156
152
|
|
157
153
|
def book(name)
|
@@ -163,7 +159,7 @@ module OpenStax::Salesforce::SpecHelpers
|
|
163
159
|
end
|
164
160
|
|
165
161
|
def schools
|
166
|
-
@schools ||= School.all
|
162
|
+
@schools ||= OpenStax::Salesforce::Remote::School.all
|
167
163
|
end
|
168
164
|
|
169
165
|
def school_id(name)
|
@@ -173,5 +169,32 @@ module OpenStax::Salesforce::SpecHelpers
|
|
173
169
|
def school(name)
|
174
170
|
schools.find { |ss| ss.name == name }
|
175
171
|
end
|
172
|
+
|
173
|
+
def setup_cassette
|
174
|
+
VCR.configure do |config|
|
175
|
+
config.define_cassette_placeholder('<salesforce_instance_url>') do
|
176
|
+
'https://example.salesforce.com'
|
177
|
+
end
|
178
|
+
config.define_cassette_placeholder('<salesforce_instance_url_lower>') do
|
179
|
+
'https://example.salesforce.com'
|
180
|
+
end
|
181
|
+
authentication = ActiveForce.sfdc_client.authenticate!
|
182
|
+
config.define_cassette_placeholder('<salesforce_instance_url>') do
|
183
|
+
authentication.instance_url
|
184
|
+
end
|
185
|
+
config.define_cassette_placeholder('<salesforce_instance_url_lower>') do
|
186
|
+
authentication.instance_url.downcase
|
187
|
+
end
|
188
|
+
config.define_cassette_placeholder('<salesforce_id>') do
|
189
|
+
authentication.id
|
190
|
+
end
|
191
|
+
config.define_cassette_placeholder('<salesforce_access_token>') do
|
192
|
+
authentication.access_token
|
193
|
+
end
|
194
|
+
config.define_cassette_placeholder('<salesforce_signature>') do
|
195
|
+
authentication.signature
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
176
199
|
end
|
177
200
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstax_salesforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Slavinsky
|
@@ -9,22 +9,28 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-07-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '5.0'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '7.0'
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
|
-
- - "
|
28
|
+
- - ">="
|
26
29
|
- !ruby/object:Gem::Version
|
27
30
|
version: '5.0'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '7.0'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: restforce
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,16 +91,16 @@ dependencies:
|
|
85
91
|
name: sprockets
|
86
92
|
requirement: !ruby/object:Gem::Requirement
|
87
93
|
requirements:
|
88
|
-
- - "
|
94
|
+
- - ">="
|
89
95
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
96
|
+
version: '0'
|
91
97
|
type: :development
|
92
98
|
prerelease: false
|
93
99
|
version_requirements: !ruby/object:Gem::Requirement
|
94
100
|
requirements:
|
95
|
-
- - "
|
101
|
+
- - ">="
|
96
102
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
103
|
+
version: '0'
|
98
104
|
description: Interface gem for accessing OpenStax's Salesforce instance
|
99
105
|
email:
|
100
106
|
- jps@kindlinglabs.com
|