class ECUtils::ECSeekerWebApis

Attributes

everclear_session[RW]

Public Instance Methods

authorized_headers() click to toggle source
# File lib/ec_utils/ec_seeker_web_apis.rb, line 15
def authorized_headers
  {
      'Cookie': "everclear_session=#{everclear_session}",
      'Content-Type': 'application/json',
      'Accept': 'application/json'
  }
end
end_chat_session(chat_id) click to toggle source
# File lib/ec_utils/ec_seeker_web_apis.rb, line 82
def end_chat_session(chat_id)
  options = {
      body: {type: "end_session", success: true}.to_json,
      headers: authorized_headers
  }
  self.class.patch("/seeker_app/web/chats/#{chat_id}", options)
end
get_chat_contacts(last_activity_at=nil) click to toggle source
# File lib/ec_utils/ec_seeker_web_apis.rb, line 46
def get_chat_contacts(last_activity_at=nil)
  options = {
      query: { 'last_activity_at': last_activity_at },
      headers: authorized_headers
  }
  response = self.class.get('/seeker_app/web/chat/contacts.json', options)
  expect(response.code).to eq 200
  JSON.parse(response.body)['data']
end
get_dashboard_data() click to toggle source
# File lib/ec_utils/ec_seeker_web_apis.rb, line 36
def get_dashboard_data
  options = {
      query: {},
      headers: authorized_headers
  }
  response = self.class.get('/seeker_app/web/my/dashboard.json', options)
  expect(response.code).to eq 200
  JSON.parse(response.body)['data']['dashboardAdvisors']
end
initial_ppm_chat(advisor_id, rate, qa_sync=false) click to toggle source
# File lib/ec_utils/ec_seeker_web_apis.rb, line 56
def initial_ppm_chat(advisor_id, rate, qa_sync=false)
  options = {
      body: {advisor_id: advisor_id, rate: rate, qa_sync: qa_sync}.to_json,
      headers: authorized_headers
  }
  puts options
  response = self.class.post("/seeker_app/web/chats", options)
  JSON.parse(response.body)
end
send_ppm_chat(chat_id, content) click to toggle source
# File lib/ec_utils/ec_seeker_web_apis.rb, line 74
def send_ppm_chat(chat_id, content)
  options = {
      body: {content: content}.to_json,
      headers: authorized_headers
  }
  self.class.post("/seeker_app/web/chats/#{chat_id}/messages", options)
end
sign_in_as_seeker(email, password='12345678') click to toggle source
# File lib/ec_utils/ec_seeker_web_apis.rb, line 23
def sign_in_as_seeker(email, password='12345678')
  options = {
      body: {
          'seeker[email]': email,
          'seeker[password]': password,
          'commit': 'Sign in'
      }
  }
  response = self.class.post('/client/sign_in', options)
  puts @everclear_session = response.headers['Set-Cookie'].scan(/everclear_session[^;]*/)[0].split(/[=;]/)[1]
end
start_chat_conference(chat_id) click to toggle source
# File lib/ec_utils/ec_seeker_web_apis.rb, line 66
def start_chat_conference(chat_id)
  options = {
      body: {type: "start_conference", success: true}.to_json,
      headers: authorized_headers
  }
  self.class.patch("/seeker_app/web/chats/#{chat_id}.json", options)
end