class ECUtils::ECToolsApis

Constants

EP

Attributes

tools_session[RW]

Public Class Methods

instance() click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 15
def self.instance
  @@instance 
end

Public Instance Methods

add_balance(seeker_id, amount) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 63
def add_balance(seeker_id, amount)
  options = {
    headers: authorized_headers,
    timeout: 30
  }

  retry_with_network_timeout do
    self.class.get("/api/tools/debug/set_user_balance?user_id=#{seeker_id}&amount=#{amount}&bucket_type=1", options)
  end
end
authorized_headers() click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 28
def authorized_headers
  {
    'Cookie': "_tools_session=#{tools_session}",
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  }
end
complete_chat(caller_id, receiver_id) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 390
def complete_chat(caller_id, receiver_id)
  options = {
    body: { caller_id: caller_id, receiver_id: receiver_id }.to_json,
    headers: authorized_headers
  }
  self.class.post('/api/tools/debug/chats/complete', options)
end
complete_last_call(seeker_id, advisor_id) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 318
def complete_last_call(seeker_id, advisor_id)
  options = {
    body: {
      'seeker_id': seeker_id,
      'advisor_id': advisor_id
    }.to_json,
    headers: authorized_headers
  }
  self.class.post('/debug/last_call', options)
end
create_fake_call(seeker_id, advisor_id, minutes=5) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 412
def create_fake_call(seeker_id, advisor_id, minutes=5)
  options = {
    body: {
      caller_id: seeker_id,
      receiver_id: advisor_id,
      caller_tn: "+14159060000",
      receiver_tn: "+14158430000",
      minutes: minutes
    }.to_json,
    headers: authorized_headers
  }
  puts response = self.class.post('/api/tools/debug/sessions/call', options)
end
delete_mood_entries_seeker(seeker_id) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 258
def delete_mood_entries_seeker(seeker_id)
  options = {
    body: {
      'user_id': seeker_id
    }.to_json,
    headers: authorized_headers,
    timeout: 30
  }

  retry_with_network_timeout do
    self.class.delete('/api/tools/debug/delete_user_mood_entries', options)
  end
end
delete_promoted_campaign(advisor_id) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 398
def delete_promoted_campaign(advisor_id)
  options = {
    body: {
      'advisor_id': advisor_id
    }.to_json,
    headers: authorized_headers,
    timeout: 30
  }

  retry_with_network_timeout do
    puts response = self.class.delete('/api/tools/debug/delete_promote_campaign', options)
  end
end
delete_seeker_phones(seeker_id) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 89
def delete_seeker_phones(seeker_id)
  options = {
    body: {
      'user_id': seeker_id
    }.to_json,
    headers: authorized_headers,
    timeout: 30
  }

  retry_with_network_timeout do
    self.class.delete('/api/tools/debug/delete_user_phones', options)
  end
end
delete_user_risk_known_device_at(email) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 114
def delete_user_risk_known_device_at(email)
  options = {
    body: {
      'email': email
    }.to_json,
    headers: authorized_headers,
    timeout: 30
  }

  retry_with_network_timeout do
    self.class.delete('/api/tools/debug/delete_known_device_at', options)
  end
end
encrypt_credit_card_number(card_number) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 362
def encrypt_credit_card_number(card_number)
  options = {
    query: {
      'number': card_number
    },
    headers: authorized_headers
  }
  self.class.get('/api/tools/debug/encrypted_card', options)
end
get_advisor_relay_number(advisor_id) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 381
def get_advisor_relay_number(advisor_id)
  options = {
      query: { "advisor_id": advisor_id },
      headers: authorized_headers
  }
  response = self.class.get('/api/tools/debug/advisor_relay_number', options)
  JSON.parse(response.body)
end
get_auto_seeker(seeker_type, amount=nil) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 345
def get_auto_seeker(seeker_type, amount=nil)
  query = {
    'seeker_type': seeker_type
  }
  
  unless amount.nil?
    query['amount'] = amount
  end

  options = {
    query: query,
    headers: authorized_headers
  }
  response = self.class.get("/api/tools/debug/get_auto_seeker", options)
  JSON.parse(response.body)['data']
end
get_call_data(call_id) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 308
def get_call_data(call_id)
  options = {
    query: {
      'call_id': call_id
    },
    headers: authorized_headers
  }
  self.class.get('/api/tools/debug/telephony/calls', options)
end
get_campaigns(advisor_id) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 435
def get_campaigns(advisor_id)
  options = {
    query: {advisor_id: advisor_id},
    headers: authorized_headers
  }
  response = self.class.get('/api/tools/debug/get_promote_campaign', options)
end
get_chat_sessions(caller_id, receiver_id, status) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 372
def get_chat_sessions(caller_id, receiver_id, status)
  options = {
    body: { caller_id: caller_id, receiver_id: receiver_id, status: status }.to_json,
    headers: authorized_headers
  }
  response = self.class.get('/api/tools/debug/sessions/chat', options)
  JSON.parse(response.body)
end
get_user_info(email, fields='') click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 143
def get_user_info(email, fields='')
  options = {
    query: {
      email: email,
      fields: fields
    },
    headers: authorized_headers,
    timeout: 30
  }

  response = nil

  retry_with_network_timeout do
    response = self.class.get('/api/tools/debug/user_info', options)
  end
  JSON.parse(response.body)
end
modify_campaign(advisor_id, status, max_bid=nil, budget=nil) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 426
def modify_campaign(advisor_id, status, max_bid=nil, budget=nil)
  options = {
    body: {advisor_id: advisor_id, status: status.to_i, max_bid: max_bid, budget: budget}.to_json,
    headers: authorized_headers
  }
  response = self.class.post('/api/tools/debug/modify_promote_campaign', options)
  JSON.parse(response.body)
end
reset_user_balance(seeker_id) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 301
def reset_user_balance(seeker_id)
  options = {
    headers: authorized_headers
  }
  self.class.get("/api/tools/debug/set_user_balance?user_id=#{seeker_id}&reset_user_balance=true", options)
end
retry_with_network_timeout() { || ... } click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 36
def retry_with_network_timeout
  retry_with(
    errors: [Net::OpenTimeout, Net::ReadTimeout],
    increment_delay: false
  ) {
    yield
  }
end
set_special_offer_user(seeker_email, status) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 194
def set_special_offer_user(seeker_email, status)
  options = {
    body: {
      'email': seeker_email,
      'status': status
    }.to_json,
    headers: authorized_headers,
    timeout: 30
  }
  puts options
  response = nil

  retry_with_network_timeout do
    response = self.class.post('/api/tools/debug/set_special_offer_user', options)
  end
  response
end
set_user_availability(user_id, availability = { phone: 'on', arranged_calls_enabled: false } ) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 212
def set_user_availability(user_id, availability = { phone: 'on', arranged_calls_enabled: false } )
  options = {
    body: {
      user_id: user_id,
      availability: availability
    }.to_json,
    headers: authorized_headers,
    timeout: 30
  }

  retry_with_network_timeout do
    self.class.post('/api/tools/debug/user_availability', options)
  end
end
set_well_established(advisor, seeker) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 284
def set_well_established(advisor, seeker)
  options = {
    query: {
      'advisor': advisor,
      'seeker': seeker
    },
    headers: authorized_headers,
    timeout: 30
  }

  response = nil
  retry_with_network_timeout do
    response = self.class.get('/api/tools/debug/set_well_established', options)
  end
  JSON.parse(response.body)
end
sign_in_as_admin(email='admin@platphormcorp.com', password='ev3rc1ear') click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 45
def sign_in_as_admin(email='admin@platphormcorp.com', password='ev3rc1ear')
  options = {
    body: {
      'email': email,
      'password': password
    },
    timeout: 30
  }

  tools_session = nil
  retry_with_network_timeout do
    response = self.class.post('/users/sign_in', options)
    tools_session = response.headers['Set-Cookie'].split(/[=;]/)[1]
  end
  puts @tools_session = tools_session
  @tools_session
end
unblock_all(seeker_id) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 103
def unblock_all(seeker_id)
  options = {
    headers: authorized_headers,
    timeout: 30
  }

  retry_with_network_timeout do
    self.class.delete("/api/tools/debug/unblock_all/#{seeker_id}", options)
  end
end
unpurchase_special_offer(user_email) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 74
def unpurchase_special_offer(user_email)
  options = {
    body: {
      'email': user_email
    }.to_json,
    headers: authorized_headers,
    timeout: 30
  }

  puts options
  retry_with_network_timeout do
    self.class.post('/api/tools/debug/unpurchase_special_offer', options)
  end
end
update_account_status(user_id, status='closed', reason='customer_request') click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 161
def update_account_status(user_id, status='closed', reason='customer_request')
  body = (status == 'closed' ? {user: {reason: reason, comment: 'Updated by Selenium Tools API helper'}} : {})
  options = {
    body: body.to_json,
    headers: authorized_headers,
    timeout: 30
  }
  action = status == 'closed' ? 'close' : 'activate'

  retry_with_network_timeout do
    self.class.post("/api/tools/users/#{user_id}/#{action}", options)
  end
end
update_feedback(advisor_email, request) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 329
def update_feedback(advisor_email, request)
  options = {
    body: { 'email': advisor_email, 'request': request }.to_json,
    headers: authorized_headers
  }
  self.class.post('/api/tools/debug/feedback', options)
end
update_name(advisor_id, name) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 337
def update_name(advisor_id, name)
  options = {
    body: { 'user': { 'name': name } }.to_json,
    headers: authorized_headers
  }
  self.class.patch("/api/tools/users/#{advisor_id}", options)
end
update_special_offer_user(seeker_email, quantity=0, availability=0) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 175
def update_special_offer_user(seeker_email, quantity=0, availability=0)
  options = {
    body: {
      'email': seeker_email,
      'quantity': quantity.to_i,
      'availability': availability
    }.to_json,
    headers: authorized_headers,
    timeout: 30
  }

  response = nil

  retry_with_network_timeout do
    response = self.class.post('/api/tools/debug/special_offer_user', options)
  end
  response
end
update_user_cards_age(email, days = 121) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 272
def update_user_cards_age(email, days = 121)
  options = {
    body: { email: email, days: days }.to_json,
    headers: authorized_headers,
    timeout: 30
  }

  retry_with_network_timeout do
    self.class.post('/api/tools/debug/update_card_age', options)
  end
end
update_user_risk_known_device_at(seeker_id) click to toggle source
# File lib/ec_utils/ec_tools_apis.rb, line 128
def update_user_risk_known_device_at(seeker_id)
  options = {
    body: {
      'user_id': seeker_id
    }.to_json,
    headers: authorized_headers,
    timeout: 30
  }

  retry_with_network_timeout do
    response = self.class.post('/api/tools/debug/update_known_device_at', options)
    puts response.body
  end
end