Last active
May 23, 2017 22:18
-
-
Save ornerymoose/6cd7633acbeb2364c81c8d7e8c3c867a to your computer and use it in GitHub Desktop.
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
class CustomersController < ApplicationController | |
include CustomersHelper | |
def lookup_phone | |
customer_phone = Customer.lookup_phone(params[:PhoneNumber]) | |
if customer_phone == [] | |
customer_phone += @match_not_found | |
else | |
customer_phone = Customer.lookup_phone(params[:PhoneNumber]).each {|c| [c.match_found = true, c.transfer_flag = false, c.reset_url = Customer.obtain_url(c)]} | |
end | |
customer_phone.to_json(:methods => [:transfer_flag, :match_found, :reset_url]) | |
reset_device(customer_phone) | |
end | |
def lookup_account_id | |
customer_account_id = Customer.lookup_account_id(params[:AccountID]) | |
if customer_account_id == [] | |
customer_account_id += @match_not_found | |
else | |
customer_account_id = Customer.lookup_account_id(params[:AccountID]).each {|c| [c.match_found = true, c.transfer_flag = false, c.reset_url = Customer.obtain_url(c)]} | |
end | |
customer_account_id.to_json(:methods => [:transfer_flag, :match_found, :reset_url]) | |
reset_device(customer_account_id) | |
end | |
end |
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
module CustomersHelper | |
def reset_device(customer_data) | |
url_list = [] | |
customer_data.each_with_index do |e, index| | |
url_list << e.reset_url | |
end | |
responses = [] | |
url_list.each do |url| | |
responses << RestClient::Request.execute(method: :get, url: url) | |
end | |
@success = [] | |
@failing = [] | |
responses.zip(customer_data).each do |res, customer| | |
data = Hash.from_xml(res) | |
cust_string = "Account Code: #{customer['AccountCode']}, Serial Number: #{customer['sSerialNumber']}" | |
if (data['string']['xmlns'] == "http://localhost/CHRPPVWS/") | |
@success << cust_string | |
else | |
@failing << cust_string | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment