Last active
May 31, 2017 20:12
-
-
Save rdetert/8111350 to your computer and use it in GitHub Desktop.
Revisions
-
rdetert revised this gist
Dec 24, 2013 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class Subscriber < ActiveRecord::Base end SENDY_LIST_ID = 11 # Change This! ShopifyAPI::Customer.all( from: :search, params: {q: "accepts_marketing:true", limit:250}).each do |customer| @@ -35,11 +35,10 @@ class Subscriber < ActiveRecord::Base :email => customer.email, :userID => 1, :custom_fields => "", :list => SENDY_LIST_ID, :join_date => DateTime.parse(customer.created_at), :timestamp => DateTime.parse(customer.created_at) subscriber.save end -
rdetert created this gist
Dec 24, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ SHOPIFY_API_KEY = 'my-key' SHOPIFY_PASSWORD = 'my-pass' STORE_NAME = 'my-store' This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ # Sync Shopify Customers that Accept Marketing with Sendy require 'rubygems' require 'active_record' require 'protected_attributes' require 'shopify_api' require 'yaml' dbconfig = YAML::load(File.open('sync_shopify.yml')) ActiveRecord::Base.establish_connection(dbconfig) eval File.open('shopify_api.conf').read shop_url = "https://#{SHOPIFY_API_KEY}:#{SHOPIFY_PASSWORD}@#{STORE_NAME}.myshopify.com/admin" ShopifyAPI::Base.site = shop_url class Subscriber < ActiveRecord::Base attr_accessible :name, :email, :join_date, :timestamp, :list, :last_campaign, :userID, :custom_fields validates_uniqueness_of :email end ShopifyAPI::Customer.all( from: :search, params: {q: "accepts_marketing:true", limit:250}).each do |customer| name = "#{customer.first_name} #{customer.last_name}" subscriber = Subscriber.new :name => name, :email => customer.email, :join_date => customer.created_at, :timestamp => customer.created_at email_with_name = "#{name} <#{customer.email}>" subscriber = Subscriber.new :name => name, :email => customer.email, :userID => 1, :custom_fields => "", :list => 11, :join_date => DateTime.parse(customer.created_at), :timestamp => DateTime.parse(customer.created_at) subscriber.save end This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ adapter: mysql host: localhost username: user password: pass database: database_name