Class: Spree::CloudSenderController
- Inherits:
-
BaseController
- Object
- BaseController
- Spree::CloudSenderController
- Includes:
- Spree::Core::ControllerHelpers::Order
- Defined in:
- app/controllers/spree/cloud_sender_controller.rb
Instance Method Summary collapse
- #cloudsponge_proxy ⇒ Object
- #importAOL ⇒ Object
- #importCheck ⇒ Object
- #importContacts ⇒ Object
- #importGmail ⇒ Object
- #importOSX ⇒ Object
- #importOutlook ⇒ Object
- #send_mail ⇒ Object
Instance Method Details
#cloudsponge_proxy ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'app/controllers/spree/cloud_sender_controller.rb', line 112 def cloudsponge_proxy importer = Cloudsponge::ContactImporter.new(Spree::Cloudsponge::Config[:domain_key], Spree::Cloudsponge::Config[:domain_password]) url = Cloudsponge::URL_BASE + 'auth?' + request.query_string response = if request.post? Cloudsponge::Utility::post_url(url, request.parameters) elsif request.get? Cloudsponge::Utility::get_url(url) else nil end if response.is_a?(Net::HTTPRedirection) redirect_to response["location"] else render :text => response.try(:body) end end |
#importAOL ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/spree/cloud_sender_controller.rb', line 30 def importAOL client = HTTPClient.new body = { 'service' => params[:service], 'username' => params[:username], 'password' => params[:password], 'domain_key' => Spree::Cloudsponge::Config[:domain_key], 'domain_password' => Spree::Cloudsponge::Config[:domain_password], 'referrer' => 'sweet_spree' } response = client.post('https://api.cloudsponge.com/begin_import/import.json', body) data = ActiveSupport::JSON.decode(response.body) @importID = data["import_id"] respond_to do | format | format.html {render :layout => false} end end |
#importCheck ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/spree/cloud_sender_controller.rb', line 68 def importCheck @success = false; client = HTTPClient.new body = { 'import_id' => params[:id], 'domain_key' => Spree::Cloudsponge::Config[:domain_key], 'domain_password' => Spree::Cloudsponge::Config[:domain_password] } response = client.get('https://api.cloudsponge.com/events/' + params[:id], body) @data = ActiveSupport::JSON.decode(response.body) if (@data["events"].count > 0) if ((@data["events"][0]["event_type"] == "COMPLETE") && (@data["events"][0]["status"] == "COMPLETED")) @success = "true" elsif ((@data["events"][0]["event_type"] == "COMPLETE") && (@data["events"][0]["status"] == "ERROR")) @success = "error" else @success = "false" end end respond_to do | format | format.html {render :layout => false} end end |
#importContacts ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/controllers/spree/cloud_sender_controller.rb', line 90 def importContacts client = HTTPClient.new body = { 'import_id' => params[:id], 'domain_key' => Spree::Cloudsponge::Config[:domain_key], 'domain_password' => Spree::Cloudsponge::Config[:domain_password] } response = client.get('https://api.cloudsponge.com/contacts/' + params[:id], body) @data = ActiveSupport::JSON.decode(response.body) @contacts_with_dups = @data["contacts"].sort {|x,y| x["first_name"].capitalize <=> y["first_name"].capitalize} @contacts = Array.new emailList = Array.new @contacts_with_dups.each do |contact| if !(contact["email"].nil?) && !(contact["email"][0].nil?) && !(contact["email"][0]["address"].nil?) && (contact["email"][0]["address"] != "") if !(emailList.include?(contact["email"][0]["address"])) emailList << contact["email"][0]["address"] @contacts << contact end end end respond_to do | format | format.html {render :layout => false} end end |
#importGmail ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/spree/cloud_sender_controller.rb', line 17 def importGmail client = HTTPClient.new body = { 'service' => params[:service], 'domain_key' => Spree::Cloudsponge::Config[:domain_key], 'domain_password' => Spree::Cloudsponge::Config[:domain_password], 'referrer' => 'sweet_spree' } response = client.post('https://api.cloudsponge.com/begin_import/user_consent.json', body) data = ActiveSupport::JSON.decode(response.body) @authURL = data["url"] @importID = data["import_id"] respond_to do | format | format.html {render :layout => false} end end |
#importOSX ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/spree/cloud_sender_controller.rb', line 55 def importOSX client = HTTPClient.new body = { 'service' => 'ADDRESSBOOK', 'domain_key' => Spree::Cloudsponge::Config[:domain_key], 'domain_password' => Spree::Cloudsponge::Config[:domain_password], 'referrer' => 'sweet_spree' } response = client.post('https://api.cloudsponge.com/begin_import/desktop_applet.json', body) data = ActiveSupport::JSON.decode(response.body) @authURL = data["url"] @importID = data["import_id"] respond_to do | format | format.html {render :layout => false} end end |
#importOutlook ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/spree/cloud_sender_controller.rb', line 42 def importOutlook client = HTTPClient.new body = { 'service' => 'OUTLOOK', 'domain_key' => Spree::Cloudsponge::Config[:domain_key], 'domain_password' => Spree::Cloudsponge::Config[:domain_password], 'referrer' => 'sweet_spree' } response = client.post('https://api.cloudsponge.com/begin_import/desktop_applet.json', body) data = ActiveSupport::JSON.decode(response.body) @authURL = data["url"] @importID = data["import_id"] respond_to do | format | format.html {render :layout => false} end end |
#send_mail ⇒ Object
9 10 11 12 13 14 15 |
# File 'app/controllers/spree/cloud_sender_controller.rb', line 9 def send_mail if request.get? @mail_to_cloud = Spree::MailToCloud.new(:sender_email => spree_current_user.try(:email)) else mail_to_cloud end end |