Last active
February 25, 2019 19:49
-
-
Save ashleymason/5fa404098d1a344261879713c8ae2807 to your computer and use it in GitHub Desktop.
luxpo_retargeting_using_real_estate_ads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
partner = Partner[:luxpo]; | |
partner.extra_data[:default_layouts][:retargeting] = {anx_web: 'luxpo_retargeting_web', facebook: 'luxpo_retargeting_fb'}; | |
partner.save; | |
pas = PartnerAutomationSetting.find_by(partner_id: partner.id); | |
unless pas.present? | |
pas = PartnerAutomationSetting.create( | |
automation_type: 'retargeting', | |
send_email: false, | |
launch_date: 1.year.ago, | |
partner: partner | |
) | |
end | |
pf = Partner::Feed.where(partner: partner, type: 'Partner::ListingFeed').first; | |
pf.enabled = true; | |
pf.save; | |
po = PartnerOffice.find_by(partner_key: '0118CDB2-1ACF-49F4-9B7F-FC48F7FF0CB9', partner_id: partner.id); | |
unless po.present? | |
po = PartnerOffice.create( | |
partner_key: '0118CDB2-1ACF-49F4-9B7F-FC48F7FF0CB9', | |
partner: partner, | |
name: 'Orchard Park - E. Quaker Street', | |
address1: '6505 East Quaker Street', | |
city: 'Orchard Park', | |
state: 'NY', | |
postal_code: 14127, | |
remote_image_url: 'http://www.luxuryportfolio.com/photos/broker/D042CD1E-05FC-493A-B6DD-F70E18B220B9.png' | |
) | |
end; | |
pa = PartnerAgent.find_by(partner_key: '100019024', partner_id: partner.id); | |
unless pa.present? | |
pa = PartnerAgent.create( | |
partner: partner, | |
partner_key: '100019024', | |
partner_office_id: po.id, | |
partner_office_key: po.partner_key, | |
first_name: 'Garry', | |
last_name: 'Reimer', | |
display_name: 'Garry Reimer', | |
phone: '7035057614', | |
email: '[email protected]', | |
website_url: 'www.thegarryreimergroup.com', | |
remote_image_url: 'http://matrix.remax.net/profilephotos/100019024.jpg', | |
city: 'Chantiily', | |
state: 'VA', | |
postal_code: '20152', | |
latitude: 38.9076, | |
longitude: -77.518, | |
automation_opt_out: 0 | |
) | |
end; | |
pl = Partner::Listing.find_by(remote_key: '225629522', partner_id: partner.id); | |
unless pl.present? | |
pl = Partner::Listing.create( | |
partner: partner, | |
remote_key: '225629522', | |
partner_feed_id: pf.id, | |
partner_agent_id: pa.id, | |
partner_office_id: po.id, | |
mls_id: 'R2323871', | |
mls_name: 'Fraser Valley Real Estate Board', | |
address1: '29399 MARSH MCCORMICK ROAD', | |
city: 'Abbotsford', | |
state: 'NC', | |
postal_code: 27712, | |
country: 'US', | |
latitude: 49.1479, | |
longitude: -122.41, | |
list_price: 1199888, | |
currency: 'ZAR', | |
bedrooms: 5, | |
bathrooms: 3, | |
living_area: 3749, | |
property_type: 'SingleFamily', | |
listing_status: 'For Sale', | |
url: 'https://www.luxuryportfolio.com/Property/lake-bluff-properties-magnificent-lakefront-estate/ERPE' | |
) | |
end; | |
plp = Partner::Listing::Photo.find_by(sequence: 0, partner_listing_id: pl.id); | |
unless plp.present? | |
Partner::Listing::Photo.create( | |
partner_listing_id: pl.id, | |
sequence: 0, | |
image_file_size: 122778, | |
image_content_type: 'image/jpeg', | |
image_file_name: '831602.jpg', | |
external_url: 'http://cdn-3.eneighborhoods.com/x2/@v=-253950529@/733/8/871/r2323871/r2323871_1.jpg' | |
) | |
end; | |
foc = FeedObjectChange.find_by(field_name: 'remote_key', field_value: '225629522'); | |
unless foc.present? | |
foc = FeedObjectChange.create( | |
feed_object: pl, | |
field_name: 'remote_key', | |
field_value: '225629522' | |
) | |
end; | |
acc = AutomatedCampaignConfig.find_or_create_by(active: true, rulesset: 'default_config', sequence: 0, spec_subdirectory: 'default'); | |
pf.automated_campaign_configs << acc if pf.automated_campaign_configs.size == 0; | |
Automation::Retargeting::CreateCampaignInsertionOrder.new.perform(feed_object_change_id: foc.id, partner_id: partner.id, partner_feed_id: pf.id); | |
Automation::Retargeting::CreateCampaign.new.perform(campaign_insertion_order_id: CampaignInsertionOrder.last.id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment