Top Level Namespace
Defined Under Namespace
Modules: Valorant
Classes: Article, Articles, Asset, Content, Leader, LeaderBoard, MMRHistory, MMRV1, Match, MatcheshHistory, Player, User
Constant Summary
collapse
- BASE_URL =
'https://api.henrikdev.xyz/valorant/'
Instance Method Summary
collapse
Instance Method Details
#fetch_resposne(endpoint, validate: true) ⇒ Object
9
10
11
12
13
14
|
# File 'lib/api/utils/utilities.rb', line 9
def fetch_resposne(endpoint, validate: true)
response = RestClient.get(BASE_URL + endpoint)
return FastJsonparser.parse(validate_response(response), symbolize_keys: false) unless validate == false
FastJsonparser.parse(response, symbolize_keys: false)
end
|
#validate_filter(filter) ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/api/utils/utilities.rb', line 22
def validate_filter(filter)
return if filter.empty?
filters = %w[escalation spikerush deathmatch competitive unrated replication game_updates dev esports
announcments]
raise "Error: Invalid filter. Valid filters are: #{filters.join(", ")}" unless filters.include?(filter)
filter
end
|
#validate_locale(locale) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/api/utils/utilities.rb', line 32
def validate_locale(locale)
return if locale.empty?
locales = %w[en-us en-gb de-de es-es fr-fr it-it ru-ru tr-tr es-mx ja-jp ko-kr pt-br]
raise "Error: Invalid locale. Valid locales are: #{locales.join(", ")}" unless locales.include?(locale)
locale
end
|
#validate_response(response) ⇒ Object
16
17
18
19
20
|
# File 'lib/api/utils/utilities.rb', line 16
def validate_response(response)
return response.body if response.code == 200
raise "Error: #{response.code} - #{response["message"]}"
end
|