Class: Smite::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/smite/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dev_id, auth_key, lang = 1) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
# File 'lib/smite/client.rb', line 7

def initialize(dev_id, auth_key, lang = 1)
  @dev_id     = dev_id
  @auth_key   = auth_key
  @lang       = [1,2,3,7,9,10,11,12,13].include?(lang) ? lang : 1
  create_session
end

Instance Attribute Details

#auth_keyObject (readonly)

Returns the value of attribute auth_key.



3
4
5
# File 'lib/smite/client.rb', line 3

def auth_key
  @auth_key
end

#dev_idObject (readonly)

Returns the value of attribute dev_id.



3
4
5
# File 'lib/smite/client.rb', line 3

def dev_id
  @dev_id
end

#langObject (readonly)

Returns the value of attribute lang.



3
4
5
# File 'lib/smite/client.rb', line 3

def lang
  @lang
end

#session_idObject (readonly)

Returns the value of attribute session_id.



3
4
5
# File 'lib/smite/client.rb', line 3

def session_id
  @session_id
end

Instance Method Details

#achievements(player_id) ⇒ Object



74
75
76
# File 'lib/smite/client.rb', line 74

def achievements(player_id)
  api_call('getplayerachievements', [player_id])
end

#create_sessionObject



106
107
108
109
110
111
# File 'lib/smite/client.rb', line 106

def create_session
  return @session_id if valid_session?

  response    = api_call('createsession', [], false)
  @session_id = response['session_id']
end

#data_usedObject



102
103
104
# File 'lib/smite/client.rb', line 102

def data_used
  api_call('getdataused')
end

#esports_pro_league_detailsObject



14
15
16
# File 'lib/smite/client.rb', line 14

def esports_pro_league_details
  api_call('getesportsproleaguedetails')
end

#friends(player_name) ⇒ Object



78
79
80
# File 'lib/smite/client.rb', line 78

def friends(player_name)
  api_call('getfriends', [player_name])
end

#god_ranks(player_name) ⇒ Object



82
83
84
# File 'lib/smite/client.rb', line 82

def god_ranks(player_name)
  api_call('getgodranks', [player_name])
end


18
19
20
# File 'lib/smite/client.rb', line 18

def god_recommended_items(god_id)
  api_call('getgodrecommendeditems', [god_id, lang])
end

#godsObject



66
67
68
# File 'lib/smite/client.rb', line 66

def gods
  api_call('getgods', [lang])
end

#itemsObject



70
71
72
# File 'lib/smite/client.rb', line 70

def items
  api_call('getitems', [lang])
end

#league_leaderboard(queue, tier, season) ⇒ Object



34
35
36
# File 'lib/smite/client.rb', line 34

def league_leaderboard(queue, tier, season)
  api_call('getleagueleaderboard', [queue, tier, season])
end

#league_seasons(queue) ⇒ Object



30
31
32
# File 'lib/smite/client.rb', line 30

def league_seasons(queue)
  api_call('getleagueseasons', [queue])
end

#match_details(match_id) ⇒ Object



62
63
64
# File 'lib/smite/client.rb', line 62

def match_details(match_id)
  api_call('getmatchdetails', [match_id])
end

#match_history(player_name) ⇒ Object



90
91
92
# File 'lib/smite/client.rb', line 90

def match_history(player_name)
  api_call('getmatchhistory', [player_name])
end

#match_ids_by_queue(queue, date, hour) ⇒ Object



26
27
28
# File 'lib/smite/client.rb', line 26

def match_ids_by_queue(queue, date, hour)
  api_call('getmatchidsbyqueue', [queue, date, hour])
end

#match_player_details(match_id) ⇒ Object



22
23
24
# File 'lib/smite/client.rb', line 22

def match_player_details(match_id)
  api_call('getmatchplayerdetails', [match_id])
end

#motdObject



38
39
40
# File 'lib/smite/client.rb', line 38

def motd
  api_call('getmotd')
end

#player(player_name) ⇒ Object



86
87
88
# File 'lib/smite/client.rb', line 86

def player(player_name)
  api_call('getplayer', [player_name])
end

#player_status(player_name) ⇒ Object



42
43
44
# File 'lib/smite/client.rb', line 42

def player_status(player_name)
  api_call('getplayerstatus', [player_name])
end

#queue_stats(player_name, queue) ⇒ Object



46
47
48
# File 'lib/smite/client.rb', line 46

def queue_stats(player_name, queue)
  api_call('getqueuestats', [player_name, queue])
end

#search_teams(team_name) ⇒ Object



94
95
96
# File 'lib/smite/client.rb', line 94

def search_teams(team_name)
  api_call('searchteams', [team_name])
end

#team_details(clan_id) ⇒ Object



50
51
52
# File 'lib/smite/client.rb', line 50

def team_details(clan_id)
  api_call('getteamdetails', [clan_id])
end

#team_players(clan_id) ⇒ Object



54
55
56
# File 'lib/smite/client.rb', line 54

def team_players(clan_id)
  api_call('getteamplayers', [clan_id])
end

#test_sessionObject



98
99
100
# File 'lib/smite/client.rb', line 98

def test_session
  api_call('testsession')
end

#top_matchesObject



58
59
60
# File 'lib/smite/client.rb', line 58

def top_matches
  api_call('gettopmatches')
end

#valid_session?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/smite/client.rb', line 113

def valid_session?
  !!(test_session =~ /successful/i)
end