Skip to content

Instantly share code, notes, and snippets.

@ashleymason
Last active February 21, 2019 21:39
Show Gist options
  • Save ashleymason/b65e810b3a8e5940da21e82b268852fc to your computer and use it in GitHub Desktop.
Save ashleymason/b65e810b3a8e5940da21e82b268852fc to your computer and use it in GitHub Desktop.
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)
pf = Partner::Feed.where(partner: partner, type: 'Partner::ListingFeed').first
pf.update(enabled: true)
pa = PartnerAgent.create(
partner_id: 24,
partner_office_id: 6918,
partner_key: "433510ED-A54D-4405-AB68-616743C25CBA",
first_name: "Vance",
last_name: "Young",
display_name: "Vance Young",
phone: "910-509-1965",
email: "vanceyoung@intracoastalrealty.com",
website_url: "www.luxuryportfolio.com",
city: "Wilmington",
state: "NC",
postal_code: "28480",
latitude: 34.2072,
longitude: -77.7963,
phone_set: [],
city_served_set: [],
automation_opt_out: false
)
po = PartnerOffice.create(
partner_id: partner.id,
partner_key: "31a696d626b7959cb6605ed9ba7da658",
name: "Intracoastal Realty Corporation",
address1: "1900 Eastwood Rd",
city: "Wilmington",
state: "NC",
website_url: "www.luxuryportfolio.com",
remote_image_url: "http://www.luxuryportfolio.com/photos/broker/D36E4CB2-EEF8-403A-86F2-86D33519F144.png",
latitude: 37.0902,
longitude: -95.7129,
image_file_name: "D36E4CB2-EEF8-403A-86F2-86D33519F144.png",
image_content_type: "image/png",
image_file_size: 8555,
image_updated_at: '2019-01-23 00:00:00'
)
pl = Partner::Listing.create(
partner_id: partner.id,
partner_feed_id: pf.id,
remote_key: "BF885E8D-2603-443F-8F82-A7D3F4690F3F",
partner_agent_id: PartnerAgent.last.id,
partner_office_id: PartnerOffice.last.id,
mls_number: "100061209",
luxury: false,
address1: "114 S Lumina Avenue",
city: "Wrightsville Beach",
state: "NC",
postal_code: "28480",
country: "USA",
latitude: 34.2066,
longitude: -77.7968,
description: nil,
list_price: "2999000",
currency: "USD",
bedrooms: 5.0,
bathrooms: 4.0,
property_type: "Single Family",
url: "www.luxuryportfolio.com/Property/Wrightsville-BeachCustom-Coastal-design-in-wrightsville-beach/LXBV",
labels: []
)
plp = Partner::Listing::Photo.create(
partner_listing_id: pl.id,
external_url: "http://luxport.s3.amazonaws.com/4124/532908_1-EXT.jpg",
image_updated_at: '2019-01-28 00:00:00',
image_file_size: 73577,
image_content_type: "application/octet-stream",
image_file_name: "532908_1-EXT.jpg",
sequence: 0
)
foc = FeedObjectChange.create(
feed_object: pl,
field_name: 'remote_key',
field_value: pl.remote_key
)
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