hearthstone_api 1.0.3
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 +21 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +259 -0
- data/Rakefile +2 -0
- data/hearthstone_api.gemspec +34 -0
- data/lib/hearthstone_api.rb +18 -0
- data/lib/hearthstone_api/base_model.rb +21 -0
- data/lib/hearthstone_api/cardbacks.rb +7 -0
- data/lib/hearthstone_api/cards.rb +39 -0
- data/lib/hearthstone_api/configuration.rb +23 -0
- data/lib/hearthstone_api/connection.rb +4 -0
- data/lib/hearthstone_api/exceptions.rb +6 -0
- data/lib/hearthstone_api/info.rb +7 -0
- data/lib/hearthstone_api/request.rb +31 -0
- data/lib/hearthstone_api/version.rb +3 -0
- data/spec/hearthstone_api/cardbacks_spec.rb +20 -0
- data/spec/hearthstone_api/cards_spec.rb +192 -0
- data/spec/hearthstone_api/hearthstone_api_spec.rb +7 -0
- data/spec/hearthstone_api/info_spec.rb +21 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cardbacks.yml +186 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cardbacks/options.yml +57 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards.yml +5366 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/classes.yml +105 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/classes/options.yml +105 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/faction.yml +155 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/options.yml +471 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/quality.yml +403 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/quality/options.yml +403 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/races.yml +85 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/races/options.yml +85 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/search.yml +147 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/set.yml +44 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/set/options.yml +44 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/sets.yml +710 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/sets/options.yml +396 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/single/id.yml +48 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/single/id/options.yml +89 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/single/name.yml +48 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/type.yml +882 -0
- data/spec/support/vcr_cassettes/hearthstone_api/cards/type/options.yml +120 -0
- data/spec/support/vcr_cassettes/hearthstone_api/info.yml +92 -0
- data/spec/support/vcr_cassettes/hearthstone_api/info/options.yml +46 -0
- metadata +249 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 01e5c2077c3b00238347ac848b8fbfd94e495b21
|
|
4
|
+
data.tar.gz: c986de5b61784f8f22d28e0696bf4abeb0899722
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6fd7721d218f57ebecfcd1419356b60f60d69713816aa88dbcb36d5f7f62dd3433c6fe49161437641451bba41235cac9aaf931ee47961915bf1748ffeb0b571f
|
|
7
|
+
data.tar.gz: 65562f7449172b4e3191701814aa16bd2bad0a064c71c9aa9873a121dbbd245f07bf84a8657191ea1945fd8490da7b4f48347db2ad18b5c6eac840dbe45391d6
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2015, 2016 Bryan Mytko
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# HearthstoneApi
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/rb/hearthstone_api)
|
|
6
|
+
|
|
7
|
+
API Wrapper for hearthstoneapi.com
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'hearthstone_api'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
And then execute:
|
|
18
|
+
|
|
19
|
+
$ bundle
|
|
20
|
+
|
|
21
|
+
Or install it yourself as:
|
|
22
|
+
|
|
23
|
+
$ gem install hearthstone_api
|
|
24
|
+
|
|
25
|
+
Create a .env file and add your [API Key](https://market.mashape.com/omgvamp/hearthstone)
|
|
26
|
+
|
|
27
|
+
$ touch .env
|
|
28
|
+
|
|
29
|
+
**In the .env file:**
|
|
30
|
+
|
|
31
|
+
HEARTHSTONE_API_KEY=xxxxxxxxxxxxxxxxxxxx
|
|
32
|
+
|
|
33
|
+
## Endpoints
|
|
34
|
+
|
|
35
|
+
All endpoints available via [hearthstoneapi.com](http://hearthstoneapi.com)
|
|
36
|
+
|
|
37
|
+
1. [All Cards](#all-cards)
|
|
38
|
+
1. [Single Card](#single-card)
|
|
39
|
+
1. [Class Cards](#class-cards)
|
|
40
|
+
1. [Types](#types)
|
|
41
|
+
1. [Sets](#sets)
|
|
42
|
+
1. [Races](#races)
|
|
43
|
+
1. [Qualities](#qualities)
|
|
44
|
+
1. [Factions](#factions)
|
|
45
|
+
1. [Search](#search)
|
|
46
|
+
1. [Card Backs](#card-backs)
|
|
47
|
+
1. [Info](#info)
|
|
48
|
+
|
|
49
|
+
Examples:
|
|
50
|
+
|
|
51
|
+
#### All Cards
|
|
52
|
+
_N.B. Cards come back organized by the set they belong to_
|
|
53
|
+
|
|
54
|
+
```ruby
|
|
55
|
+
HearthstoneApi::Card.all(attack: 12)
|
|
56
|
+
|
|
57
|
+
=> {"Basic"=>[],
|
|
58
|
+
"Classic"=>
|
|
59
|
+
[{"cardId"=>"NEW1_030",
|
|
60
|
+
"name"=>"Deathwing",
|
|
61
|
+
"cardSet"=>"Classic",
|
|
62
|
+
"type"=>"Minion",
|
|
63
|
+
"rarity"=>"Legendary",
|
|
64
|
+
"cost"=>10,
|
|
65
|
+
"attack"=>12,
|
|
66
|
+
"health"=>12,
|
|
67
|
+
[...]
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### Single Card
|
|
71
|
+
_This endpoint accepts name or card ID_
|
|
72
|
+
|
|
73
|
+
```ruby
|
|
74
|
+
HearthstoneApi::Card.single("Ysera", locale: "jaJP")
|
|
75
|
+
|
|
76
|
+
=> [{"cardId"=>"EX1_572",
|
|
77
|
+
"name"=>"イセラ",
|
|
78
|
+
"cardSet"=>"Classic",
|
|
79
|
+
"type"=>"Minion",
|
|
80
|
+
"faction"=>"Neutral",
|
|
81
|
+
"rarity"=>"Legendary",
|
|
82
|
+
"cost"=>9,
|
|
83
|
+
[...]
|
|
84
|
+
|
|
85
|
+
HearthstoneApi::Card.single("EX1_572", locale: "jaJP")
|
|
86
|
+
|
|
87
|
+
=> [{"cardId"=>"EX1_572",
|
|
88
|
+
"name"=>"イセラ",
|
|
89
|
+
"cardSet"=>"Classic",
|
|
90
|
+
"type"=>"Minion",
|
|
91
|
+
"faction"=>"Neutral",
|
|
92
|
+
"rarity"=>"Legendary",
|
|
93
|
+
"cost"=>9,
|
|
94
|
+
[...]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Class Cards
|
|
98
|
+
|
|
99
|
+
```ruby
|
|
100
|
+
HearthstoneApi::Card.classes("Paladin", cost: 2)
|
|
101
|
+
|
|
102
|
+
=> [{"cardId"=>"OG_311",
|
|
103
|
+
"name"=>"A Light in the Darkness",
|
|
104
|
+
"cardSet"=>"Whispers of the Old Gods",
|
|
105
|
+
"type"=>"Spell",
|
|
106
|
+
"rarity"=>"Common",
|
|
107
|
+
"cost"=>2,
|
|
108
|
+
"text"=>"<b>Discover</b> a minion.\nGive it +1/+1.",
|
|
109
|
+
[...]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Types
|
|
113
|
+
|
|
114
|
+
```ruby
|
|
115
|
+
HearthstoneApi::Cards.type("Weapon")
|
|
116
|
+
|
|
117
|
+
=> [{"cardId"=>"TB_SPT_BossWeapon",
|
|
118
|
+
"name"=>"Armory",
|
|
119
|
+
"cardSet"=>"Tavern Brawl",
|
|
120
|
+
"type"=>"Weapon",
|
|
121
|
+
"cost"=>1,
|
|
122
|
+
"attack"=>0,
|
|
123
|
+
"durability"=>1,
|
|
124
|
+
[...]
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### Sets
|
|
128
|
+
|
|
129
|
+
```ruby
|
|
130
|
+
HearthstoneApi::Cards.sets("Blackrock Mountain")
|
|
131
|
+
|
|
132
|
+
=> [{"cardId"=>"BRMA16_1",
|
|
133
|
+
"name"=>"Atramedes",
|
|
134
|
+
"cardSet"=>"Blackrock Mountain",
|
|
135
|
+
"type"=>"Hero",
|
|
136
|
+
"health"=>30,
|
|
137
|
+
[...]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### Races
|
|
141
|
+
_Mrglglrglglglglglglgl!_
|
|
142
|
+
|
|
143
|
+
```ruby
|
|
144
|
+
HearthstoneApi::Cards.races("Murloc")
|
|
145
|
+
|
|
146
|
+
=> [{"cardId"=>"PRO_001at",
|
|
147
|
+
"name"=>"Murloc",
|
|
148
|
+
"cardSet"=>"Promotion",
|
|
149
|
+
"type"=>"Minion",
|
|
150
|
+
"cost"=>0,
|
|
151
|
+
"attack"=>1,
|
|
152
|
+
"health"=>1,
|
|
153
|
+
"race"=>"Murloc",
|
|
154
|
+
[...]
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
#### Qualities
|
|
158
|
+
|
|
159
|
+
```ruby
|
|
160
|
+
HearthstoneApi::Cards.qualities("Legendary")
|
|
161
|
+
|
|
162
|
+
=> [{"cardId"=>"BRMA14_3",
|
|
163
|
+
"name"=>"Arcanotron",
|
|
164
|
+
"cardSet"=>"Blackrock Mountain",
|
|
165
|
+
"type"=>"Minion",
|
|
166
|
+
"rarity"=>"Legendary",
|
|
167
|
+
[...]
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### Factions
|
|
171
|
+
|
|
172
|
+
```ruby
|
|
173
|
+
HearthstoneApi::Cards.factions("Horde")
|
|
174
|
+
|
|
175
|
+
=> [{"cardId"=>"CS2_189",
|
|
176
|
+
"name"=>"Elven Archer",
|
|
177
|
+
"cardSet"=>"Basic",
|
|
178
|
+
"type"=>"Minion",
|
|
179
|
+
"faction"=>"Horde",
|
|
180
|
+
"rarity"=>"Free",
|
|
181
|
+
"cost"=>1,
|
|
182
|
+
"attack"=>1,
|
|
183
|
+
"health"=>1,
|
|
184
|
+
[...]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### Search
|
|
188
|
+
_Returns cards by partial name_
|
|
189
|
+
|
|
190
|
+
** Note: While the official documentation says the search API can accept a locale parameter, it currently breaks the request. Because of this the gem's search API only accepts a search string with no option parameters**
|
|
191
|
+
|
|
192
|
+
```ruby
|
|
193
|
+
HearthstoneApi::Cards.search("Onyx")
|
|
194
|
+
|
|
195
|
+
=> [{"cardId"=>"BRMA17_3",
|
|
196
|
+
"name"=>"Onyxia",
|
|
197
|
+
"cardSet"=>"Blackrock Mountain",
|
|
198
|
+
"type"=>"Hero",
|
|
199
|
+
"health"=>15,
|
|
200
|
+
[...]
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### Card Backs
|
|
204
|
+
|
|
205
|
+
```ruby
|
|
206
|
+
HearthstoneApi::Cardbacks.all
|
|
207
|
+
|
|
208
|
+
=> [{"cardBackId"=>"0",
|
|
209
|
+
"name"=>"Classic",
|
|
210
|
+
"description"=>"The only card back you’ll ever need.",
|
|
211
|
+
"source"=>"startup",
|
|
212
|
+
"sourceDescription"=>"Default",
|
|
213
|
+
"enabled"=>true,
|
|
214
|
+
"img"=>
|
|
215
|
+
"http://wow.zamimg.com/images/hearthstone/backs/original/Card_Back_Default.png",
|
|
216
|
+
"imgAnimated"=>
|
|
217
|
+
"http://wow.zamimg.com/images/hearthstone/backs/animated/Card_Back_Default.gif",
|
|
218
|
+
"sortCategory"=>"1",
|
|
219
|
+
"sortOrder"=>"1",
|
|
220
|
+
[...]
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
#### Info
|
|
224
|
+
|
|
225
|
+
```ruby
|
|
226
|
+
HearthstoneApi::Info.all
|
|
227
|
+
|
|
228
|
+
=> {"patch"=>"5.0.0.12574",
|
|
229
|
+
"classes"=>
|
|
230
|
+
["Druid",
|
|
231
|
+
"Hunter",
|
|
232
|
+
"Mage",
|
|
233
|
+
"Paladin",
|
|
234
|
+
"Priest",
|
|
235
|
+
"Rogue",
|
|
236
|
+
"Shaman",
|
|
237
|
+
"Warlock",
|
|
238
|
+
"Warrior",
|
|
239
|
+
"Dream"],
|
|
240
|
+
"sets"=>
|
|
241
|
+
["Basic",
|
|
242
|
+
"Classic",
|
|
243
|
+
"Credits",
|
|
244
|
+
"Naxxramas",
|
|
245
|
+
[...]
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Contributing
|
|
249
|
+
|
|
250
|
+
1. Fork it ( https://github.com/[my-github-username]/hearthstone_api/fork )
|
|
251
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
252
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
253
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
254
|
+
5. Create a new Pull Request
|
|
255
|
+
|
|
256
|
+
## Development
|
|
257
|
+
|
|
258
|
+
gem build hearthstone_api.gemspec
|
|
259
|
+
gem install ./hearthstone_api-1.0.2.gem
|
data/Rakefile
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'hearthstone_api/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "hearthstone_api"
|
|
8
|
+
spec.version = HearthstoneApi::VERSION
|
|
9
|
+
spec.authors = ["Bryan Mytko"]
|
|
10
|
+
spec.email = ["bryanmytko@gmail.com"]
|
|
11
|
+
spec.summary = %q{API Wrapper for hearthstoneapi.com}
|
|
12
|
+
spec.description = <<-EOF
|
|
13
|
+
A wrapper for the Hearthstone API found at hearthstoneapi.com
|
|
14
|
+
EOF
|
|
15
|
+
spec.homepage = "https://github.com/bryanmytko/hearthstone_api"
|
|
16
|
+
spec.license = "MIT"
|
|
17
|
+
|
|
18
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
21
|
+
spec.require_paths = ["lib"]
|
|
22
|
+
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
24
|
+
spec.add_development_dependency "rake", "~> 10"
|
|
25
|
+
|
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.3"
|
|
27
|
+
spec.add_development_dependency "vcr", "~> 2.9"
|
|
28
|
+
spec.add_development_dependency "webmock", "~> 1.8"
|
|
29
|
+
spec.add_development_dependency "byebug", '~> 8.2', '>= 8.2.4'
|
|
30
|
+
|
|
31
|
+
spec.add_dependency "httparty", "~> 0.13"
|
|
32
|
+
spec.add_dependency "json", "~> 1.8"
|
|
33
|
+
spec.add_dependency "dotenv", "~>2.0"
|
|
34
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "httparty"
|
|
2
|
+
require "dotenv"
|
|
3
|
+
|
|
4
|
+
Dotenv.load
|
|
5
|
+
|
|
6
|
+
require "hearthstone_api/base_model"
|
|
7
|
+
require "hearthstone_api/cardbacks"
|
|
8
|
+
require "hearthstone_api/cards"
|
|
9
|
+
require "hearthstone_api/configuration"
|
|
10
|
+
require "hearthstone_api/connection"
|
|
11
|
+
require "hearthstone_api/exceptions"
|
|
12
|
+
require "hearthstone_api/info"
|
|
13
|
+
require "hearthstone_api/version"
|
|
14
|
+
|
|
15
|
+
module HearthstoneApi
|
|
16
|
+
include HTTParty
|
|
17
|
+
extend Configuration
|
|
18
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module HearthstoneApi
|
|
2
|
+
require "hearthstone_api/request"
|
|
3
|
+
|
|
4
|
+
class BaseModel
|
|
5
|
+
class << self
|
|
6
|
+
include Request
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def endpoint
|
|
11
|
+
HearthstoneApi.endpoint
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class ::String
|
|
16
|
+
def capitalize_all
|
|
17
|
+
split.map(&:capitalize).join(" ")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module HearthstoneApi
|
|
2
|
+
class Cards < BaseModel
|
|
3
|
+
def self.all(options = {})
|
|
4
|
+
get "/cards", options
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.single(name_or_id, options = {})
|
|
8
|
+
get "/cards/#{name_or_id}", options
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.classes(klass, options = {})
|
|
12
|
+
get "/cards/classes/#{klass.capitalize_all}", options
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.type(type, options = {})
|
|
16
|
+
get "/cards/types/#{type.capitalize_all}", options
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.sets(set, options = {})
|
|
20
|
+
get "/cards/sets/#{set.capitalize_all}", options
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.races(race, options = {})
|
|
24
|
+
get "/cards/races/#{race.capitalize_all}", options
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.qualities(quality, options = {})
|
|
28
|
+
get "/cards/qualities/#{quality.capitalize_all}", options
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.factions(faction, options = {})
|
|
32
|
+
get "/cards/factions/#{faction.capitalize_all}", options
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.search(search_term)
|
|
36
|
+
get "/cards/search/#{search_term}"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|