smiten 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +10 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +131 -0
- data/Rakefile +16 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/smiten.rb +12 -0
- data/lib/smiten/api.rb +38 -0
- data/lib/smiten/core.rb +148 -0
- data/lib/smiten/paladins.rb +23 -0
- data/lib/smiten/smite.rb +23 -0
- data/lib/smiten/version.rb +5 -0
- data/smiten.gemspec +42 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fc1724485965ecc6ec0100db7a13354e3a387fdbc23c2ce235ccb3bc267fc3ae
|
4
|
+
data.tar.gz: 7dc7ae5ede5650d092576fe1c7f7c21c90c45bb52c3b74ae41949a1e28d07534
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5f131bb8fe197b440217a89cc1cefd5eba7c7ad53499f08954c9cdad079174e82aef4678520e9df4bd17a4ddf47e29055e587a1fb41d8e9e166bdc284b81fa2a
|
7
|
+
data.tar.gz: dda04445357c4b066f2186bee17074b621f8965f00099ea3752ef48b02bf60a57e69530905eb3f58cd3c8766593f16301b89c431c1499723cbc29e2fd3c49f34
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Changelog
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 pkelly
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
# Smiten
|
2
|
+
|
3
|
+
This Gem provides a Ruby interface to the Hirez Paladins and Smite APIs
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'smiten'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install smiten
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
This gem implements the API described here: https://docs.google.com/document/d/1OFS-3ocSx-1Rvg4afAnEHlT3917MAK_6eJTR6rzr-BM/edit
|
24
|
+
|
25
|
+
Note that session management is handled internally
|
26
|
+
|
27
|
+
To retrieve a list of champions
|
28
|
+
|
29
|
+
champions = Smiten:Paladins.new({developerId('xxx', authKey(''yyy').get_champions
|
30
|
+
|
31
|
+
The returned value is a hash with two keys: **:kind** and **:payload**.
|
32
|
+
|
33
|
+
**:kind** refers to the Capitalized class name
|
34
|
+
of the returned object, such as *Player* or *ChampionCard*. For most calls this is nil.
|
35
|
+
|
36
|
+
**:payload** may be a String, Hash or Array depending on the API
|
37
|
+
|
38
|
+
## Supported APIs
|
39
|
+
|
40
|
+
The arguments to the method should be provided in a hash using the keys shown below
|
41
|
+
- get_bounty_items
|
42
|
+
- get_champion_cards(champion_id, language_code)
|
43
|
+
- get_champion_leaderboard(champion_id, queue_id)
|
44
|
+
- get_champion_ranks(player_id)
|
45
|
+
- get_champions(language_code)
|
46
|
+
- get_champion_skins(champion_id, language_code)
|
47
|
+
- get_data_used()
|
48
|
+
- get_demo_details(match_id)
|
49
|
+
- get_esports_proleague_details()
|
50
|
+
- get_friends(player_id)
|
51
|
+
- get_god_leaderboard(god_id, queue_id)
|
52
|
+
- get_god_ranks(player_id)
|
53
|
+
- get_god_recommended_items(god_id, language_code)
|
54
|
+
- get_gods(language_code)
|
55
|
+
- get_god_skins(god_id, language_code)
|
56
|
+
- get_hirez_server_status()
|
57
|
+
- get_items(language_code)
|
58
|
+
- get_league_leaderboard(queue_id, tier, round)
|
59
|
+
- get_league_seasons(queue_id)
|
60
|
+
- get_match_details_batch(match_ids)
|
61
|
+
- get_match_details(match_id)
|
62
|
+
- get_match_history(player_id)
|
63
|
+
- get_match_ids_by_queue(queue_id, date, hour)
|
64
|
+
- get_match_player_details(match_id)
|
65
|
+
- get_motd()
|
66
|
+
- get_patch_info()
|
67
|
+
- get_player(player [,portal_id])
|
68
|
+
- get_player_batch(player_ids)
|
69
|
+
- get_player_achievements(player_id)
|
70
|
+
- get_player_id_by_name(player_name)
|
71
|
+
- get_player_id_by_portal_user_id(portal_id, portal_user_id)
|
72
|
+
- get_player_id_info_for_xbox_and_switch(player_name)
|
73
|
+
- get_player_ids_by_gamer_tag(portal_id, gamer_tag)
|
74
|
+
- get_player_loadouts(player_id, language_code)
|
75
|
+
- get_player_status(player_id)
|
76
|
+
- get_queue_stats(player_id, queue_id)
|
77
|
+
- get_team_details(team_id)
|
78
|
+
- get_team_players(team_id)
|
79
|
+
- get_top_matches()
|
80
|
+
- ping()
|
81
|
+
- search_players(search_string)
|
82
|
+
- search_teams(search_string)
|
83
|
+
- test_session()
|
84
|
+
|
85
|
+
## Helper methods
|
86
|
+
- for_champion(champion_id)
|
87
|
+
|
88
|
+
This scopes the following call to that champion
|
89
|
+
|
90
|
+
Smiten:Paladins.new({developerId('xxx', authKey(''yyy').get_champion_cards({champion_id: 55, language_code: Smiten::Language[:english]}) and
|
91
|
+
|
92
|
+
Smiten:Paladins.new({developerId('xxx', authKey(''yyy').for_champion(55).get_champion_cards({language_code: Smiten::Language[:english]})
|
93
|
+
|
94
|
+
are identical
|
95
|
+
|
96
|
+
- in_language(identifier)
|
97
|
+
|
98
|
+
This scopes the following call to use the selected language
|
99
|
+
|
100
|
+
Smiten:Paladins.new({developerId('xxx', authKey(''yyy').get_champion_cards({champion_id: 55, language_code: Smiten::Language[:english]}) and
|
101
|
+
|
102
|
+
Smiten:Paladins.new({developerId('xxx', authKey(''yyy').in_language(:english).get_champion_cards({champion_id: 55}) and
|
103
|
+
|
104
|
+
Smiten:Paladins.new({developerId('xxx', authKey(''yyy').in_language(1).get_champion_cards({champion_id: 55})
|
105
|
+
|
106
|
+
are identical
|
107
|
+
|
108
|
+
- hi_rez | steam | ps4 | xbox| switch| discord | epic
|
109
|
+
|
110
|
+
These methods set the portal_id on the Smiten connector
|
111
|
+
|
112
|
+
Smiten:Paladins.new({developerId('xxx', authKey(''yyy').get_player({:portal_id: 10, player: 'a_name'}) and
|
113
|
+
|
114
|
+
Smiten:Paladins.new({developerId('xxx', authKey(''yyy').xbox.get_player({player: 'a_name''})
|
115
|
+
|
116
|
+
are identical
|
117
|
+
|
118
|
+
## Development
|
119
|
+
|
120
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
121
|
+
|
122
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
123
|
+
|
124
|
+
## Contributing
|
125
|
+
|
126
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/pikelly/smiten. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/pikelly/smiten/blob/master/CODE_OF_CONDUCT.md).
|
127
|
+
|
128
|
+
## License
|
129
|
+
|
130
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
131
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
require "rubocop/rake_task"
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "smiten"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/smiten.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'time'
|
4
|
+
require 'digest'
|
5
|
+
require 'ostruct'
|
6
|
+
require 'faraday'
|
7
|
+
require 'faraday_middleware'
|
8
|
+
require_relative 'smiten/version'
|
9
|
+
require_relative 'smiten/core'
|
10
|
+
require_relative 'smiten/paladins'
|
11
|
+
require_relative 'smiten/smite'
|
12
|
+
|
data/lib/smiten/api.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Smiten
|
2
|
+
class Core < OpenStruct
|
3
|
+
# Returns a hash containing the API signatures keyed by ruby method name
|
4
|
+
def core_api
|
5
|
+
{ ping: [nil, -> { "ping#{ResponseFormat}" }],
|
6
|
+
create_session: [nil, -> { "#{boilerplate('createsession')}/#{timestamp}" }],
|
7
|
+
test_session: [nil, -> { "#{boilerplate('testsession')}" }],
|
8
|
+
get_data_used: [nil, -> { "#{boilerplate('getdataused')}" }],
|
9
|
+
get_hirez_server_status: [nil, -> { "#{boilerplate('gethirezserverstatus')}" }],
|
10
|
+
get_patch_info: [nil, -> { "#{boilerplate('getpatchinfo')}" }],
|
11
|
+
get_items: ['Item', -> { "#{boilerplate('getitems')}/#{language_code}" }],
|
12
|
+
get_bounty_items: [nil, -> { "#{boilerplate('getbountyitems')}" }],
|
13
|
+
get_player: ['Player', -> { "#{boilerplate('getplayer')}/#{player}#{"/#{portal_id}" if portal_id }"}],
|
14
|
+
get_player_batch: ['Player', -> { "#{boilerplate('getplayerbatch')}/#{player_ids.map(&:to_s).join(',')}" }],
|
15
|
+
get_player_id_by_name: [nil, -> { "#{boilerplate('getplayeridbyname')}/#{player_name}" }],
|
16
|
+
get_player_id_by_portal_user_id: [nil, -> { "#{boilerplate('getplayeridbyportaluserid')}/#{portal_id}/#{portal_user_id}" }],
|
17
|
+
get_player_ids_by_gamer_tag: [nil, -> { "#{boilerplate('getplayeridsbygamertag')}/#{portal_id}/#{gamer_tag}" }],
|
18
|
+
get_friends: [nil, -> { "#{boilerplate('getfriends')}/#{player_id}" }],
|
19
|
+
get_player_status: [nil, -> { "#{boilerplate('getplayerstatus')}/#{player_id}" }],
|
20
|
+
get_match_history: [nil, -> { "#{boilerplate('getmatchhistory')}/#{player_id}" }],
|
21
|
+
get_queue_stats: [nil, -> { "#{boilerplate('getqueuestats')}/#{player_id}/#{queue_id}" }],
|
22
|
+
search_players: [nil, -> { "#{boilerplate('searchplayers')}/#{search_string}" }],
|
23
|
+
get_demo_details: [nil, -> { "#{boilerplate('getdemodetails')}/#{match_id}" }],
|
24
|
+
get_match_details: [nil, -> { "#{boilerplate('getmatchdetails')}/#{match_id}" }],
|
25
|
+
get_match_details_batch: [nil, -> { "#{boilerplate('getmatchdetailsbatch')}/#{match_ids.map(&:to_s).join(',')}" }],
|
26
|
+
get_match_ids_by_queue: [nil, -> { "#{boilerplate('getmatchidsbyqueue')}/#{queue_id}/#{date}/#{hour}" }],
|
27
|
+
get_match_player_details: [nil, -> { "#{boilerplate('getmatchplayerdetails')}/#{match_id}" }],
|
28
|
+
get_top_matches: [nil, -> { "#{boilerplate('gettopmatches')}" }],
|
29
|
+
get_league_leaderboard: [nil, -> { "#{boilerplate('getleagueleaderboard')}/#{queue_id}/#{tier}/#{round}" }],
|
30
|
+
get_league_seasons: [nil, -> { "#{boilerplate('getleagueseasons')}/#{queue_id}" }],
|
31
|
+
get_team_details: [nil, -> { "#{boilerplate('getteamdetails')}/#{team_id}" }],
|
32
|
+
get_team_players: [nil, -> { "#{boilerplate('getteamplayers')}/#{team_id}" }],
|
33
|
+
get_esports_proleague_details: [nil, -> { "#{boilerplate('getesportsproleaguedetails')}" }],
|
34
|
+
get_motd: [nil, -> { "#{boilerplate('getmotd')}"}]
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/smiten/core.rb
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Smiten
|
4
|
+
PaladinsEndpoint = 'https://api.paladins.com/paladinsapi.svc' # :nodoc:
|
5
|
+
SmiteEndpoint = 'https://api.smitegame.com/smiteapi.svc' # :nodoc:
|
6
|
+
# At what interval do we need to refresh the session_id
|
7
|
+
FifteenMins = (15 * 60 * 60) - 10
|
8
|
+
# The responses are always encoded using JSON
|
9
|
+
ResponseFormat = 'Json'
|
10
|
+
Portal = { hi_rez: 1, steam: 5, ps4: 9, xbox: 10, switch: 22, discord: 25, epic: 28 }.freeze
|
11
|
+
LanguageCode = { english: 1, german: 2, french: 3, chinese: 5, spanish: 7, spanish_latin_america: 9, portuguese: 10, russian: 11, polish: 12 }.freeze
|
12
|
+
QueueCode = { live_siege: 424, conquest: 426, joust_ranked_1v1: 440, joust_ranked_3v3: 450, conquest_ranked: 451, live_competitive_gamepad: 428 }.freeze
|
13
|
+
|
14
|
+
require_relative 'api'
|
15
|
+
|
16
|
+
class Error < StandardError; end
|
17
|
+
|
18
|
+
# The Core class implements those calls that are common to both the Smite and Paladins endpoints
|
19
|
+
class Core < OpenStruct
|
20
|
+
attr_reader :connector, :language_code, :calls
|
21
|
+
attr_accessor :developerId, :authKey, :portal_id
|
22
|
+
|
23
|
+
def build_apis # :nodoc:
|
24
|
+
@calls.merge!(core_api).freeze
|
25
|
+
calls.each_key do |api|
|
26
|
+
next if self.class.method_defined?(api)
|
27
|
+
|
28
|
+
self.class.define_method(api) do |args = {}|
|
29
|
+
args.each_pair do |key, value|
|
30
|
+
if key == :timeout
|
31
|
+
@url.timeout = value
|
32
|
+
else
|
33
|
+
send("#{key}=", value)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
@url = calls[api][1].call
|
37
|
+
payload = get
|
38
|
+
{ kind: calls[api][0], payload: payload }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Creates a new connection to the Hirez API end points
|
44
|
+
# It takes a single hash parameter which must contain the following two keys
|
45
|
+
#
|
46
|
+
# :developerId
|
47
|
+
# :authKey
|
48
|
+
#
|
49
|
+
# These can be requested from the Hirez development team
|
50
|
+
def initialize(options)
|
51
|
+
# We default to talking to the paladins endpoint
|
52
|
+
options.merge!(headers: { 'Content-Type' => 'application/json' })
|
53
|
+
options.merge!(url: PaladinsEndpoint) unless options[:url]
|
54
|
+
@developerId = options.delete(:developerId)
|
55
|
+
@authKey = options.delete(:authKey)
|
56
|
+
@language_code = LanguageCode[:english]
|
57
|
+
@portal_id = nil
|
58
|
+
@session_id = nil
|
59
|
+
@connector = Faraday.new(options) do |f|
|
60
|
+
f.request :json # encode req bodies as JSON
|
61
|
+
f.request :retry # retry transient failures
|
62
|
+
f.response :json # decode response bodies as JSON
|
63
|
+
end
|
64
|
+
@calls = {}
|
65
|
+
build_apis
|
66
|
+
super
|
67
|
+
end
|
68
|
+
|
69
|
+
def incept # :nodoc:
|
70
|
+
@incept ||= Time.now
|
71
|
+
end
|
72
|
+
|
73
|
+
def timestamp # :nodoc:
|
74
|
+
@timestamp ||= incept.getutc.strftime('%Y%m%d%H%M%S')
|
75
|
+
end
|
76
|
+
|
77
|
+
def signature(api_call) # :nodoc:
|
78
|
+
Digest::MD5.hexdigest(developerId + api_call.to_s + authKey + timestamp)
|
79
|
+
end
|
80
|
+
|
81
|
+
def session_id # :nodoc:
|
82
|
+
return @session_id if @session_id && (incept + FifteenMins > Time.now)
|
83
|
+
|
84
|
+
response = connector.get("createsession#{ResponseFormat}/#{developerId}/#{signature('createsession')}/#{timestamp}")
|
85
|
+
raise Error("Failed to retrieve a session ID from #{connector.url}") unless response.status == 200
|
86
|
+
|
87
|
+
@session_id = response.body['session_id']
|
88
|
+
end
|
89
|
+
|
90
|
+
def boilerplate(meth) #:nodoc:
|
91
|
+
"#{meth}#{ResponseFormat}/#{developerId}/#{signature(meth)}/#{session_id}/#{timestamp}"
|
92
|
+
end
|
93
|
+
|
94
|
+
# Sets the champion_id on the connection and returns the connection
|
95
|
+
def for_champion(id)
|
96
|
+
self.id = id
|
97
|
+
yield(self)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Sets the language on the connection and returns the connection
|
101
|
+
# Accepts either a language_code or the language name as a symbol
|
102
|
+
def in_language(name_or_id)
|
103
|
+
self.language_code = name_or_id.is_a?(Numeric) ? name_or_id : LanguageCode[name_or_id]
|
104
|
+
yield(self)
|
105
|
+
end
|
106
|
+
|
107
|
+
Portal.each_key do |portal|
|
108
|
+
define_method(portal) do
|
109
|
+
instance_variable_set(:@portal_id, Portal[portal])
|
110
|
+
self
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Synchronously retrieve the response from the Hirez WEB API
|
115
|
+
def get
|
116
|
+
# NOTE: The html error page returned from Hirez breaks the json parser. I just ignore that and
|
117
|
+
# retrieve the original response
|
118
|
+
start = Time.now
|
119
|
+
5.times do
|
120
|
+
begin
|
121
|
+
result = connector.get(@url)
|
122
|
+
rescue Faraday::ParsingError => e
|
123
|
+
result = e.response
|
124
|
+
end
|
125
|
+
case
|
126
|
+
when (200..300).include?(result.status)
|
127
|
+
return result.body
|
128
|
+
when result.status == 408
|
129
|
+
puts '* Server Timeout detected... Retrying'
|
130
|
+
when result.status == 504
|
131
|
+
puts '* Gateway Timeout detected... Retrying'
|
132
|
+
else
|
133
|
+
raise(Error, "API Response Error:\n#{textify(result.body)}")
|
134
|
+
end
|
135
|
+
end
|
136
|
+
puts "* Timeout detected... Terminating after #{Time.new - start} seconds"
|
137
|
+
''
|
138
|
+
end
|
139
|
+
|
140
|
+
def textify(html) # :nodoc:
|
141
|
+
return html unless html =~ /<head>/
|
142
|
+
|
143
|
+
body = html[%r{<body>(.*)</body>}m,1]
|
144
|
+
body.split(/<p[^>]*>/)[1..-1].map { |txt| txt.sub(%r{</p>.*}m, "") }.join(": ")
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Smiten
|
2
|
+
# The Paladins class implements those calls that are specific to the Paladins endpoint
|
3
|
+
class Paladins < Core
|
4
|
+
# See Core for details
|
5
|
+
def initialize(options)
|
6
|
+
super(options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def build_apis # :nodoc:
|
10
|
+
# Obsolete: get_champion_recommended_items: [nil, -> { "#{boilerplate('getchampionrecommendeditems')}/#{champion_id}/#{language_code}" }, {champion_id: 2056}],
|
11
|
+
@calls = {
|
12
|
+
get_champions: ['Champion', -> { "#{boilerplate('getchampions')}/#{language_code}" }],
|
13
|
+
get_champion_cards: ['ChampionCard', -> { "#{boilerplate('getchampioncards')}/#{champion_id}/#{language_code}" }],
|
14
|
+
get_champion_skins: ['ChampionSkin', -> { "#{boilerplate('getchampionskins')}/#{champion_id}/#{language_code}" }],
|
15
|
+
get_champion_leaderboard: [nil, -> { "#{boilerplate('getchampionleaderboard')}/#{champion_id}/#{queue_id}" }],
|
16
|
+
get_champion_ranks: [nil, -> { "#{boilerplate('getchampionranks')}/#{player_id}" }],
|
17
|
+
get_player_id_info_for_xbox_and_switch: [nil, -> { "#{boilerplate('getplayeridinfoforxboxandswitch')}/#{player_name}" }],
|
18
|
+
get_player_loadouts: [nil, -> { "#{boilerplate('getplayerloadouts')}/#{player_id}/#{language_code}" }],
|
19
|
+
}
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/smiten/smite.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Smiten
|
2
|
+
# The Smite class implements those calls that are specific to the Smite endpoint
|
3
|
+
class Smite < Core
|
4
|
+
# See Core
|
5
|
+
def initialize(options)
|
6
|
+
options.merge!(url: SmiteEndpoint)
|
7
|
+
super(options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def build_apis # :nodoc:
|
11
|
+
@calls = {
|
12
|
+
get_gods: ['God', -> { "#{boilerplate('getgods')}/#{language_code}"}],
|
13
|
+
get_god_leaderboard: [nil, -> { "#{boilerplate('getgodleaderboard')}/#{god_id}/#{queue_id}"}],
|
14
|
+
get_god_skins: ['GodSkin', -> { "#{boilerplate('getgodskins')}/#{god_id}/#{language_code}"}],
|
15
|
+
get_god_recommended_items: [nil, -> { "#{boilerplate('getgodrecommendeditems')}/#{god_id}/#{language_code}"}],
|
16
|
+
get_god_ranks: [nil, -> { "#{boilerplate('getgodranks')}/#{player_id}"}],
|
17
|
+
get_player_achievements: [nil, -> { "#{boilerplate('getplayerachievements')}/#{player_id}" }],
|
18
|
+
search_teams: [nil, -> { "#{boilerplate('searchteams')}/#{search_string}" }],
|
19
|
+
}
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/smiten.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/smiten/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "smiten"
|
7
|
+
spec.version = Smiten::VERSION
|
8
|
+
spec.authors = ["pikelly"]
|
9
|
+
spec.email = ["paul.ian.kelly@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Connects to hirez smite and paladins apis"
|
12
|
+
spec.description = "Connects to hirez smite and paladins apis"
|
13
|
+
spec.homepage = "https://github.com/pikelly/smiten"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] = spec.homepage + "/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|.creds)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency "faraday", "~> 1.4"
|
31
|
+
spec.add_dependency "faraday_middleware", "~> 1.0"
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
34
|
+
spec.add_development_dependency "rubocop", "~> 0.80"
|
35
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
36
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
37
|
+
spec.add_development_dependency "yaml"
|
38
|
+
|
39
|
+
|
40
|
+
# For more information and examples about making a new gem, checkout our
|
41
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: smiten
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- pikelly
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.80'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.80'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '13.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '13.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yaml
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Connects to hirez smite and paladins apis
|
112
|
+
email:
|
113
|
+
- paul.ian.kelly@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rubocop.yml"
|
120
|
+
- CHANGELOG.md
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/console
|
126
|
+
- bin/setup
|
127
|
+
- lib/smiten.rb
|
128
|
+
- lib/smiten/api.rb
|
129
|
+
- lib/smiten/core.rb
|
130
|
+
- lib/smiten/paladins.rb
|
131
|
+
- lib/smiten/smite.rb
|
132
|
+
- lib/smiten/version.rb
|
133
|
+
- smiten.gemspec
|
134
|
+
homepage: https://github.com/pikelly/smiten
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
metadata:
|
138
|
+
homepage_uri: https://github.com/pikelly/smiten
|
139
|
+
source_code_uri: https://github.com/pikelly/smiten
|
140
|
+
changelog_uri: https://github.com/pikelly/smiten/CHANGELOG.md
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 2.3.0
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubygems_version: 3.1.4
|
157
|
+
signing_key:
|
158
|
+
specification_version: 4
|
159
|
+
summary: Connects to hirez smite and paladins apis
|
160
|
+
test_files: []
|