Skip to content

Commit 3efaf8c

Browse files
authored
send language with lead creation (#1280)
1 parent a0685bc commit 3efaf8c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

app/routines/newflow/create_or_update_salesforce_lead.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,23 @@ def build_book_adoption_json_for_salesforce(user)
146146
return nil unless user.books_used_details
147147

148148
user.books_used_details.each do |book|
149-
books_json << {
150-
name: book[0],
149+
book_value = book[0]
150+
if book_value.match(/\[.*\]/)
151+
book_name = book_value.gsub(/\[.*\]/, '').strip # Calculus Volume 1
152+
book_language = book_value[/\[(.*?)\]/, 1] # Spanish (no brackets)
153+
books_json << {
154+
name: book_name,
155+
students: book[1]["num_students_using_book"],
156+
howUsing: book[1]["how_using_book"],
157+
language: book_language,
158+
}
159+
else
160+
books_json << {
161+
name: book_value,
151162
students: book[1]["num_students_using_book"],
152163
howUsing: book[1]["how_using_book"]
153164
}
165+
end
154166
end
155167

156168
adoption_json['Books'] = books_json

0 commit comments

Comments
 (0)