class Bwclient::BwApi
Public Instance Methods
check_balance(user)
click to toggle source
# File lib/bwclient.rb, line 59 def check_balance(user) response = RestClient.post('https://paybits.binarywallet.com/api/checkbal/checkbal.php', :api_key => user.api_key, :acc_id => user.acc_id ) splited_response = response.split("<br/>") splited_status = splited_response[0].split(":") if splited_status[1] == "Success" return [ { "status"=>200 }, { "balance"=>splited_response[1].split(":")[1], "last_deposit_date"=>splited_response[2].split("=")[1] } ] else return [ { "status"=>422 }, { "error"=>response } ] end end
create_account(user)
click to toggle source
# File lib/bwclient.rb, line 8 def create_account(user) address = "#{user.address_1}, #{user.address_2}, #{user.city}, #{user.state}, #{user.postal_code}" , response = RestClient.post('https://paybits.binarywallet.com/api/createaccount/new.php', :api_id => Rails.application.secrets[:bw_api_id], :fname => user.first_name, :lname => user.last_name, :dob => '', :gender => 'Male', :addr => address, :phno => user.phone, :email => user.email, :emp_name => 'Paybits', :emp_addr => '', :src_funds => 'employer', :est_turnover => '2600', :photo_id => File.open(File.join(Rails.root, '/app/assets/images/photo1.jpg')), :address_proof => File.open(File.join(Rails.root, '/app/assets/images/proof_of_address.jpg')), :pass => sample_password ) splited_response = response.split("<br/>") splited_status = splited_response[0].split("=") if splited_status[1] == "success" return [ { "status"=>201 }, { "message"=>splited_response[1].split("=")[1], "acc_id"=>splited_response[2].split("=")[1], "api_key"=>splited_response[3].split("=")[1] } ] else return [ { "status"=>422 }, { "error"=>response } ] end end
resume_account(user)
click to toggle source
# File lib/bwclient.rb, line 121 def resume_account(user) response = RestClient.post('https://paybits.binarywallet.com/api/accountstatus/chngestatus.php', :api_key => user.api_key, :acc_id => user.acc_id, :status => 'Active' ) splited_response = response.split("<br/>") splited_status = splited_response[0].split(":") if splited_status[1] == "Success" return [ { "status"=>200 }, { "message"=>"Success" } ] else return [ { "status"=>422 }, { "error"=>response } ] end end
sample_password()
click to toggle source
# File lib/bwclient.rb, line 55 def sample_password ([*('A'..'Z'),*('a'..'z'),*('0'..'9')]-%w(0 1 I O)).sample(8).join end
suspend_account(user)
click to toggle source
# File lib/bwclient.rb, line 90 def suspend_account(user) response = RestClient.post('https://paybits.binarywallet.com/api/accountstatus/chngestatus.php', :api_key => user.api_key, :acc_id => user.acc_id, :status => 'Inactive' ) splited_response = response.split("<br/>") splited_status = splited_response[0].split(":") if splited_status[1] == "Success" return [ { "status"=>200 }, { "message"=>"Success" } ] else return [ { "status"=>422 }, { "error"=>response } ] end end