gw2 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/gw2.gemspec +2 -2
- data/lib/gw2.rb +22 -1
- data/lib/gw2/characters.rb +13 -0
- data/lib/gw2/colors.rb +13 -0
- data/lib/gw2/commerce/exchange.rb +15 -0
- data/lib/gw2/commerce/listings.rb +16 -0
- data/lib/gw2/commerce/prices.rb +16 -0
- data/lib/gw2/commerce/transactions.rb +10 -0
- data/lib/gw2/event.rb +2 -2
- data/lib/gw2/guild.rb +1 -1
- data/lib/gw2/https.rb +6 -4
- data/lib/gw2/item.rb +2 -2
- data/lib/gw2/map.rb +7 -9
- data/lib/gw2/misc.rb +5 -5
- data/lib/gw2/quaggans.rb +13 -0
- data/lib/gw2/recipe.rb +10 -2
- data/lib/gw2/resource.rb +3 -2
- data/lib/gw2/skins.rb +13 -0
- data/lib/gw2/wvw.rb +1 -1
- data/spec/fixtures/GW2_Colors/_colors/returns_all_colors.yml +114 -0
- data/spec/fixtures/GW2_Event/_event_names/returns_the_names_of_all_events.yml +20 -2034
- data/spec/fixtures/GW2_Event/_world_names/returns_the_names_of_all_worlds.yml +18 -7
- data/spec/fixtures/GW2_Guild/_details/returns_the_guild_based_on_id.yml +19 -8
- data/spec/fixtures/GW2_Guild/_details/returns_the_guild_based_on_name.yml +19 -8
- data/spec/fixtures/GW2_Item/_all/returns_all_items.yml +60909 -11
- data/spec/fixtures/GW2_Item/_details/returns_the_details_of_the_item.yml +53 -11
- data/spec/fixtures/GW2_Map/_all/returns_all_maps.yml +70 -1078
- data/spec/fixtures/GW2_Map/_continents/returns_all_continents.yml +179 -11
- data/spec/fixtures/GW2_Map/_map_floor/returns_a_specific_map_floor.yml +20 -3409
- data/spec/fixtures/GW2_Misc/_build/returns_the_build.yml +27 -11
- data/spec/fixtures/GW2_Misc/_files/returns_all_files.yml +502 -11
- data/spec/fixtures/GW2_Quaggans/_all/returns_all_Quaggans.yml +102 -0
- data/spec/fixtures/GW2_Quaggans/_details/returns_the_details_of_the_quaggan.yml +67 -0
- data/spec/fixtures/GW2_Recipe/_all/returns_all_recipes.yml +11764 -11
- data/spec/fixtures/GW2_Recipe/_details/returns_the_details_of_a_recipe_by_id.yml +61 -11
- data/spec/fixtures/GW2_Skins/_all/returns_all_Skins.yml +5374 -0
- data/spec/fixtures/GW2_Skins/_details/returns_the_details_of_the_skin.yml +78 -0
- data/spec/fixtures/GW2_WvW/_match_details/returns_the_details_of_a_match.yml +19 -8
- data/spec/fixtures/GW2_WvW/_matches/returns_all_matches.yml +19 -8
- data/spec/fixtures/GW2_WvW/_objective_names/returns_all_objectives.yml +88 -27
- data/spec/gw2/colors_spec.rb +47 -0
- data/spec/gw2/event_spec.rb +1 -14
- data/spec/gw2/guild_spec.rb +2 -2
- data/spec/gw2/item_spec.rb +7 -7
- data/spec/gw2/map_spec.rb +38 -59
- data/spec/gw2/misc_spec.rb +3 -44
- data/spec/gw2/quaggan_spec.rb +31 -0
- data/spec/gw2/recipe_spec.rb +12 -11
- data/spec/gw2/skins_spec.rb +40 -0
- data/spec/gw2/wvw_spec.rb +9 -9
- metadata +42 -24
- data/spec/fixtures/GW2_Event/_map_names/returns_the_names_of_all_maps.yml +0 -53
- data/spec/fixtures/GW2_Map/_maps/returns_the_map_by_id.yml +0 -41
- data/spec/fixtures/GW2_Misc/_colors/returns_all_colors.yml +0 -239
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d6ac8dd61d426c0299f39e846ad9417748127ba9d4356b072af28d78e5d43fba
|
4
|
+
data.tar.gz: cf6428288351bbd387a6ca9736dd0495c62a5813b03ac1e64f978f1900458a7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac67406923268394feec369b502e74694c322116d16d316f304624eddb7fb07da7ed10cbc11d8787c4c2976ce089e3be2dec5e8e647032e5fa0bdb62c5a8dad6
|
7
|
+
data.tar.gz: afc4b16b16d3eb72ea4625c94f5d16e86ab380538580a5d4f51fed77f7b64ab0b92b8364799517d11fc452df1f3b2dd3e484c6e855766f049dd328484b95f12f
|
data/gw2.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "gw2"
|
3
|
-
s.version = "1.
|
4
|
-
s.date = "
|
3
|
+
s.version = "1.5.0"
|
4
|
+
s.date = "2018-06-13"
|
5
5
|
s.summary = "Guild Wars 2 API"
|
6
6
|
s.description = "A ruby gem for accessing the Guild Wars 2 API"
|
7
7
|
s.authors = ["Chris Rosario"]
|
data/lib/gw2.rb
CHANGED
@@ -7,9 +7,30 @@ require "gw2/item"
|
|
7
7
|
require "gw2/recipe"
|
8
8
|
require "gw2/guild"
|
9
9
|
require "gw2/misc"
|
10
|
+
require "gw2/colors"
|
11
|
+
require "gw2/quaggans"
|
12
|
+
require "gw2/skins"
|
10
13
|
require "gw2/map"
|
14
|
+
require "gw2/characters"
|
15
|
+
require "gw2/commerce/listings"
|
16
|
+
require "gw2/commerce/exchange"
|
17
|
+
require "gw2/commerce/prices"
|
18
|
+
require "gw2/commerce/transactions"
|
11
19
|
require "gw2/disabled"
|
12
20
|
|
13
21
|
module GW2
|
14
|
-
|
22
|
+
attr_accessor :api_key
|
23
|
+
|
24
|
+
BASE_URL_V1 = "https://api.guildwars2.com/v1"
|
25
|
+
BASE_URL_V2 = "https://api.guildwars2.com/v2"
|
26
|
+
V1_ENDPOINTS = ["world_names", "event_names", "guild_details", "wvw", "map_floor"]
|
27
|
+
|
28
|
+
def self.api_key
|
29
|
+
@api_key
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.api_key=api_key
|
33
|
+
@api_key = api_key
|
34
|
+
end
|
35
|
+
|
15
36
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module GW2
|
2
|
+
module Characters
|
3
|
+
extend Resource
|
4
|
+
|
5
|
+
def self.all
|
6
|
+
get("/characters.json?access_token=#{GW2.api_key}")
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.details(character_name)
|
10
|
+
get("/characters/#{character_name}.json?access_token=#{GW2.api_key}")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/gw2/colors.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module GW2
|
2
|
+
module Commerce
|
3
|
+
module Exchange
|
4
|
+
extend Resource
|
5
|
+
|
6
|
+
def self.all
|
7
|
+
get("/commerce/exchange.json")
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.details(exchange_type, quantity)
|
11
|
+
get("/commerce/exchange/#{exchange_type}.json", {quantity: quantity})
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/gw2/event.rb
CHANGED
data/lib/gw2/guild.rb
CHANGED
data/lib/gw2/https.rb
CHANGED
@@ -3,7 +3,6 @@ require "net/https"
|
|
3
3
|
module GW2
|
4
4
|
module HTTPS
|
5
5
|
DEFAULT_REQUEST = { action: "Get", ssl: true }
|
6
|
-
|
7
6
|
def query_string(query_hash = {})
|
8
7
|
string = query_hash.collect{ |k,v| "#{k}=#{v}" }.join("&")
|
9
8
|
string.prepend("?") unless string.empty?
|
@@ -13,18 +12,21 @@ module GW2
|
|
13
12
|
|
14
13
|
def request(end_point = "", attr = {})
|
15
14
|
attr = DEFAULT_REQUEST.merge(attr)
|
16
|
-
|
15
|
+
|
16
|
+
if V1_ENDPOINTS.any? { |word| end_point.include?(word) }
|
17
|
+
uri = URI.parse(BASE_URL_V1 + end_point + query_string(attr[:query] || {}))
|
18
|
+
else
|
19
|
+
uri = URI.parse(BASE_URL_V2 + end_point + query_string(attr[:query] || {}))
|
20
|
+
end
|
17
21
|
|
18
22
|
http = Net::HTTP.new(uri.host, uri.port)
|
19
23
|
http.use_ssl = attr[:ssl]
|
20
24
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if attr[:ssl] # need to get a cert -_____-
|
21
25
|
|
22
|
-
net_http = Net::HTTP
|
23
26
|
request = Net::HTTP.const_get(attr[:action]).new(uri.request_uri)
|
24
27
|
attr[:headers].each { |key, value| request[key.to_s] = value } if attr[:headers]
|
25
28
|
|
26
29
|
request.set_form_data(attr[:form_data]) if attr[:form_data]
|
27
|
-
|
28
30
|
http.request(request)
|
29
31
|
end
|
30
32
|
end
|
data/lib/gw2/item.rb
CHANGED
data/lib/gw2/map.rb
CHANGED
@@ -2,22 +2,20 @@ module GW2
|
|
2
2
|
module Map
|
3
3
|
extend Resource
|
4
4
|
|
5
|
-
PARAMS_FILTER = [:map_id]
|
6
|
-
|
7
5
|
def self.all
|
8
|
-
|
6
|
+
get("/maps.json")
|
9
7
|
end
|
10
8
|
|
11
|
-
def self.
|
12
|
-
get("/maps.json"
|
9
|
+
def self.details(map_id)
|
10
|
+
get("/maps/#{map_id}.json")
|
13
11
|
end
|
14
12
|
|
15
|
-
def self.
|
16
|
-
get("/map_floor.json", { continent_id: continent_id, floor: floor })
|
13
|
+
def self.floor(continent_id, floor)
|
14
|
+
get("/map_floor.json", query: { continent_id: continent_id, floor: floor })
|
17
15
|
end
|
18
16
|
|
19
|
-
def self.continents
|
20
|
-
get("/continents.json")
|
17
|
+
def self.continents(continent_id="all")
|
18
|
+
get("/continents.json", query: { ids: continent_id })
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
data/lib/gw2/misc.rb
CHANGED
@@ -3,15 +3,15 @@ module GW2
|
|
3
3
|
extend Resource
|
4
4
|
|
5
5
|
def self.build
|
6
|
-
get("/build.json")["
|
6
|
+
get("/build.json")["id"]
|
7
7
|
end
|
8
8
|
|
9
|
-
def self.
|
10
|
-
get("/
|
9
|
+
def self.files
|
10
|
+
get("/files.json", query: { ids: "all" })
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.
|
14
|
-
get("/
|
13
|
+
def self.worlds
|
14
|
+
get("/worlds.json", { ids: "all" })
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/lib/gw2/quaggans.rb
ADDED
data/lib/gw2/recipe.rb
CHANGED
@@ -3,11 +3,19 @@ module GW2
|
|
3
3
|
extend Resource
|
4
4
|
|
5
5
|
def self.all
|
6
|
-
get("/recipes.json")
|
6
|
+
get("/recipes.json")
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.details(recipe_id)
|
10
|
-
get("/
|
10
|
+
get("/recipes/#{recipe_id}.json")
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.search_input(item_id)
|
14
|
+
get("/recipes/search.json", { input: item_id})
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.search_output(item_id)
|
18
|
+
get("/recipes/search.json", { output: item_id})
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
data/lib/gw2/resource.rb
CHANGED
@@ -6,10 +6,11 @@ module GW2
|
|
6
6
|
include HTTPS
|
7
7
|
include JSON
|
8
8
|
|
9
|
-
|
9
|
+
BASE_URL_V1 = "https://api.guildwars2.com/v1"
|
10
|
+
BASE_URL_V2 = "https://api.guildwars2.com/v2"
|
10
11
|
|
11
12
|
def get(endpoint, query = {})
|
12
|
-
parse(request(endpoint, query
|
13
|
+
parse(request(endpoint, query).body)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
data/lib/gw2/skins.rb
ADDED
data/lib/gw2/wvw.rb
CHANGED
@@ -0,0 +1,114 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.guildwars2.com/v2/colors/126.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Wed, 13 Jun 2018 22:10:39 GMT
|
23
|
+
Content-Type:
|
24
|
+
- application/json; charset=utf-8
|
25
|
+
Content-Length:
|
26
|
+
- '277'
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Cache-Control:
|
30
|
+
- public,max-age=3600
|
31
|
+
Content-Language:
|
32
|
+
- en
|
33
|
+
Expires:
|
34
|
+
- Wed, 13 Jun 2018 23:10:39 GMT
|
35
|
+
Vary:
|
36
|
+
- Accept-Encoding
|
37
|
+
Server:
|
38
|
+
- Quaggans
|
39
|
+
X-Result-Total:
|
40
|
+
- '549'
|
41
|
+
Access-Control-Expose-Headers:
|
42
|
+
- X-Result-Total
|
43
|
+
X-Rate-Limit-Limit:
|
44
|
+
- '600'
|
45
|
+
X-Content-Type-Options:
|
46
|
+
- nosniff
|
47
|
+
- nosniff
|
48
|
+
Access-Control-Allow-Origin:
|
49
|
+
- "*"
|
50
|
+
X-Powered-By:
|
51
|
+
- ARR/2.5
|
52
|
+
X-Frame-Options:
|
53
|
+
- SAMEORIGIN
|
54
|
+
X-Xss-Protection:
|
55
|
+
- 1; mode=block
|
56
|
+
Strict-Transport-Security:
|
57
|
+
- max-age=31536000; includeSubDomains; preload
|
58
|
+
body:
|
59
|
+
encoding: ASCII-8BIT
|
60
|
+
string: |-
|
61
|
+
{
|
62
|
+
"id": 126,
|
63
|
+
"name": "Hot Pink",
|
64
|
+
"base_rgb": [
|
65
|
+
128,
|
66
|
+
26,
|
67
|
+
26
|
68
|
+
],
|
69
|
+
"cloth": {
|
70
|
+
"brightness": 14,
|
71
|
+
"contrast": 1.21094,
|
72
|
+
"hue": 340,
|
73
|
+
"saturation": 0.820313,
|
74
|
+
"lightness": 1.44531,
|
75
|
+
"rgb": [
|
76
|
+
169,
|
77
|
+
54,
|
78
|
+
94
|
79
|
+
]
|
80
|
+
},
|
81
|
+
"leather": {
|
82
|
+
"brightness": 14,
|
83
|
+
"contrast": 1.21094,
|
84
|
+
"hue": 340,
|
85
|
+
"saturation": 0.703125,
|
86
|
+
"lightness": 1.44531,
|
87
|
+
"rgb": [
|
88
|
+
160,
|
89
|
+
62,
|
90
|
+
96
|
91
|
+
]
|
92
|
+
},
|
93
|
+
"metal": {
|
94
|
+
"brightness": 14,
|
95
|
+
"contrast": 1.21094,
|
96
|
+
"hue": 340,
|
97
|
+
"saturation": 0.585938,
|
98
|
+
"lightness": 1.44531,
|
99
|
+
"rgb": [
|
100
|
+
151,
|
101
|
+
69,
|
102
|
+
98
|
103
|
+
]
|
104
|
+
},
|
105
|
+
"item": 20594,
|
106
|
+
"categories": [
|
107
|
+
"Red",
|
108
|
+
"Vibrant",
|
109
|
+
"Rare"
|
110
|
+
]
|
111
|
+
}
|
112
|
+
http_version:
|
113
|
+
recorded_at: Wed, 13 Jun 2018 22:10:39 GMT
|
114
|
+
recorded_with: VCR 2.9.3
|