Class: Ruby::Pubg::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/pubg/client.rb

Constant Summary collapse

NICK_API_URL =
"https://pubgtracker.com/api/profile/pc"
ID_API_URL =
"https://pubgtracker.com/api/search"

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Client

Returns a new instance of Client.



10
11
12
# File 'lib/ruby/pubg/client.rb', line 10

def initialize(api_key)
  @api_key = api_key
end

Instance Method Details

#find_by_name(name) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/ruby/pubg/client.rb', line 14

def find_by_name(name)
  response = RestClient::Request.execute(
     :method => :get,
     :url => "#{NICK_API_URL}/#{name}",
     :headers => {"TRN-Api-Key": @api_key}
  )

  JSON.parse(response)
end

#find_name_by_steam_id(steam_id) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/ruby/pubg/client.rb', line 24

def find_name_by_steam_id(steam_id)
  response = RestClient::Request.execute(
     :method => :get,
     :url => "#{ID_API_URL}/?steamId=#{steam_id}",
     :headers => {"TRN-Api-Key": @api_key}
  )

  JSON.parse(response)
end