Class: Clienteer::Outgester::Maliero
- Inherits:
-
Object
- Object
- Clienteer::Outgester::Maliero
- Defined in:
- lib/clienteer/outgesters/maliero.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize ⇒ Maliero
constructor
A new instance of Maliero.
- #new_client(row) ⇒ Object
- #write(row) ⇒ Object
Constructor Details
#initialize ⇒ Maliero
Returns a new instance of Maliero.
4 5 6 |
# File 'lib/clienteer/outgesters/maliero.rb', line 4 def initialize @clients = [] end |
Instance Method Details
#close ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/clienteer/outgesters/maliero.rb', line 33 def close Client.transaction do success = @clients.map(&:save) unless success.all? binding.pry errored = @clients.select{ |b| !b.errors.blank? } errored.each do |e| e.save!(validate: false) rescue next end end end end |
#new_client(row) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/clienteer/outgesters/maliero.rb', line 12 def new_client(row) Client.find_or_create_by(email: row[:raw].email) do |c| c.first_name = row[:raw].first_name.capitalize, c.last_name = row[:raw].last_name.capitalize c.mindbody_id = row[:raw].id.to_s c.birthdate = row[:raw].birth_date c.gender = row[:raw].gender # c.blood_work = row["blood_work"] # c.constant_contact = row["constant_contact"] c.health_profile = true c.ideal_subscription_id = row.fetch("ideal_subscription_id", "").to_s c.ideal_protein_subscription = !row.fetch("ideal_subscription_id", "").blank? # c.needs_blood_work = row["needs_blood_work"] # c.newsletter = row["newsletter"] c.notes = row[:raw].notes c.phone_number = row[:raw].home_phone || row[:raw].mobile_phone || nil c.build_referral c.build_fitness_profile end end |
#write(row) ⇒ Object
8 9 10 |
# File 'lib/clienteer/outgesters/maliero.rb', line 8 def write(row) @clients << new_client(row) end |