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
13
# 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
  @created    = Time.now - 20 * 60
  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

#createdObject (readonly)

Returns the value of attribute created.



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

def created
  @created
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



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

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

#create_sessionObject



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

def create_session
  return @session_id if valid_session?

  response      = api_call('createsession', [], false)
  @session_id   = response['session_id']
  @created      = Time.now
end

#data_usedObject



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

def data_used
  api_call('getdataused')
end

#esports_pro_league_detailsObject



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

def esports_pro_league_details
  api_call('getesportsproleaguedetails')
end

#friends(player_name) ⇒ Object



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

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

#god_ranks(player_name) ⇒ Object



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

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


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

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

#godsObject



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

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

#itemsObject



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

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

#league_leaderboard(queue, tier, season) ⇒ Object



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

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

#league_seasons(queue) ⇒ Object



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

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

#match_details(match_id) ⇒ Object



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

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

#match_history(player_name) ⇒ Object



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

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

#match_ids_by_queue(queue, date, hour) ⇒ Object



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

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

#match_player_details(match_id) ⇒ Object



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

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

#motdObject



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

def motd
  api_call('getmotd')
end

#player(player_name) ⇒ Object



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

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

#player_status(player_name) ⇒ Object



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

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

#queue_stats(player_name, queue) ⇒ Object



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

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

#search_teams(team_name) ⇒ Object



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

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

#team_details(clan_id) ⇒ Object



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

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

#team_players(clan_id) ⇒ Object



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

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

#test_sessionObject



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

def test_session
  api_call('testsession')
end

#top_matchesObject



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

def top_matches
  api_call('gettopmatches')
end

#valid_session?Boolean

Returns:

  • (Boolean)


115
116
117
# File 'lib/smite/client.rb', line 115

def valid_session?
  (created + (15 * 60)) > Time.now
end