wot-api 1.0.2 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 950e5aebd8c3e0e38d48e02369793b76e0e6c2b9
4
- data.tar.gz: 2c469f79f7f17cc9707a107ec2c3d827c53ec0f5
3
+ metadata.gz: fdcb4b1021a09d973d2e4136b3ac15212a5aab90
4
+ data.tar.gz: 79ba8782152e833f008c226124a86057847deb11
5
5
  SHA512:
6
- metadata.gz: 9b50c44a4600b4d7a2e280fd53a957aeb187130bd7ded509082792bde0e13e5fc7648a929ca013df0ba4941ae5f43ce6823c8f32019ee081981bc353a151a33d
7
- data.tar.gz: c6f16eab94dacf7b04cf253f195887c59d302b09ef3f5d7040cb55b0f295225afcdcb238cb87ec9083c27c73a8d38ee0d7e0ff1890860aaf5ce884f1155fa802
6
+ metadata.gz: b4b80ba12430e3c56822cd8df6d0dd7261e97e6c981c6c87f2ed5765316cf9aef6b42c12184380ef67db0ef0229ab1efa82b37baca88192f41d20ee548f74492
7
+ data.tar.gz: 33f1bcea97ade195505afc29bd1c662a99e03fabf65bbfb726051d224c38231550cacd80827e9ebdc475ee9a77bd33f41537896d5cc7122b2a5c5884d4f46697
data/README.md CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
  ## Usage
21
21
 
22
22
  ```ruby
23
- require 'wot-api'
23
+ require 'wot/api'
24
24
 
25
25
  # create a new instance of api
26
26
  api = Wot::Api.new("EU")
@@ -1,7 +1,90 @@
1
+ require 'json'
2
+ require 'rest-client'
3
+ require 'active_support/core_ext/hash/indifferent_access'
1
4
  require "wot/api/version"
5
+ require 'wot/api/clusters'
6
+ require 'wot/api/error'
7
+ require 'wot/player'
2
8
 
3
9
  module Wot
4
- module Api
5
- # Your code goes here...
10
+ class Api
11
+
12
+ def initialize(region, language = 'en')
13
+ cluster = Wot::Api.cluster(region)
14
+ @app_id = cluster[:application_id]
15
+ @base_url = cluster[:base_url]
16
+ @language = language
17
+ end
18
+
19
+ def search(username, options = {})
20
+ return Wot::Player.search self, username, options
21
+ end
22
+
23
+ def find(account_ids, options = {})
24
+ return Wot::Player.find self, account_ids, options
25
+ end
26
+
27
+ def players_info(account_ids)
28
+ ids = (account_ids.class == Array ? account_ids : [account_ids])
29
+ return make_request "account/info/", {:account_id => ids.join(",")}
30
+ end
31
+
32
+ def player_tanks(account_id)
33
+ return make_request "account/tanks/", {:account_id => account_id}
34
+ end
35
+
36
+ def player_achievements(account_id)
37
+ return make_request "account/achievements/", {:account_id => account_id}
38
+ end
39
+
40
+ def player_stats(account_id,hours_ago)
41
+ return make_request "stats/accountbytime/", {:account_id => account_id, :hours_ago => hours_ago}
42
+ end
43
+
44
+ def player_raitings(account_id)
45
+ return make_request "account/raitings/", {:account_id => account_id}
46
+ end
47
+
48
+ def tanks_list()
49
+ return make_request "encyclopedia/tanks/", {}
50
+ end
51
+
52
+ def tank_info(tank_id)
53
+ return make_request "encyclopedia/tankinfo/", {:tank_id => tank_id}
54
+ end
55
+
56
+ def achievements_list()
57
+ raise NotImplementedError
58
+ end
59
+
60
+ def engines_list()
61
+ raise NotImplementedError
62
+ end
63
+
64
+ def guns_list()
65
+ raise NotImplementedError
66
+ end
67
+
68
+ def radios_list()
69
+ raise NotImplementedError
70
+ end
71
+
72
+ def suspensions_list()
73
+ raise NotImplementedError
74
+ end
75
+
76
+ def turrets_list
77
+ raise NotImplementedError
78
+ end
79
+
80
+ def make_request(suffix,parameters)
81
+ params = {:params => parameters.dup}
82
+ params[:params][:application_id] = @app_id
83
+ params[:params][:language] = @language
84
+ response = JSON.parse(RestClient.get("#{@base_url}/2.0/#{suffix}", params))
85
+ response = response.nested_under_indifferent_access
86
+ raise Wot::Api::Error.new(response[:error]) if response[:status].downcase == "error"
87
+ return response
88
+ end
6
89
  end
7
- end
90
+ end
@@ -0,0 +1,32 @@
1
+ module Wot
2
+ class Api
3
+ CLUSTERS = {
4
+ "RU" => {
5
+ :base_url => "http://api.worldoftanks.ru",
6
+ :application_id => "171745d21f7f98fd8878771da1000a31"
7
+ },
8
+ "EU" => {
9
+ :base_url => "api.worldoftanks.eu",
10
+ :application_id => "d0a293dc77667c9328783d489c8cef73"
11
+ },
12
+ "NA" => {
13
+ :base_url => "http://api.worldoftanks.com",
14
+ :application_id => "16924c431c705523aae25b6f638c54dd"
15
+ },
16
+ "ASIA" => {
17
+ :base_url => "http://api.worldoftanks.asia",
18
+ :application_id => "39b4939f5f2460b3285bfa708e4b252c"
19
+ },
20
+ "KR" => {
21
+ :base_url => "http://api.worldoftanks.kr",
22
+ :application_id => "ffea0f1c3c5f770db09357d94fe6abfb"
23
+ }
24
+ }
25
+
26
+ def self.cluster(region)
27
+ cluster = CLUSTERS[region.to_s]
28
+ fail "Region '#{region}' not found!" if cluster.nil?
29
+ return cluster
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,14 @@
1
+ module Wot
2
+ class Api
3
+ class Error < StandardError
4
+ attr_accessor :field, :message, :code, :value
5
+ def initialize(options)
6
+ super options[:message]
7
+ @field = options[:field]
8
+ @message = options[:message]
9
+ @code = options[:code]
10
+ @value = options[:value]
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,9 @@
1
1
  module Wot
2
- module Api
3
- VERSION = "0.0.1"
2
+ class Api
3
+ VERSION = "1.1.0"
4
+
5
+ def self.version
6
+ return VERSION
7
+ end
4
8
  end
5
9
  end
@@ -1,12 +1,10 @@
1
-
1
+ require 'wot/player/info'
2
+ require 'wot/player/tank'
3
+ require 'wot/player/achievement'
4
+ require 'wot/player/statistics'
5
+ require 'wot/player/extended_statistics'
2
6
  module Wot
3
7
  class Player
4
- autoload :Info, 'wot-api/player/info'
5
- autoload :Tank, 'wot-api/player/tank'
6
- autoload :Achievement, 'wot-api/player/achievement'
7
- autoload :Statistics, 'wot-api/player/statistics'
8
- autoload :ExtendedStatistics, 'wot-api/player/extended_statistics'
9
-
10
8
  attr_accessor :id, :account_id, :nickname, :api
11
9
 
12
10
  def self.search(api, nickname, options = {})
File without changes
File without changes
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'wot-api/version'
4
+ require 'wot/api/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "wot-api"
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["info@code-panic.com"]
11
11
  spec.summary = %q{Ruby World of Tanks API v2.0}
12
12
  spec.description = %q{A simple ruby library that allows to interface with World of Tanks API v2.0!}
13
- spec.homepage = "http://wot.code-panic.com"
13
+ spec.homepage = "https://github.com/serioja90/wot-api"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
- spec.add_development_dependency "rake", "~> 10.3"
23
- spec.add_development_dependency "rspec", "~> 3.1"
22
+ spec.add_development_dependency "rake", "~> 10"
23
+ spec.add_development_dependency "rspec", "~> 3"
24
24
  spec.add_development_dependency "json","~> 1.8"
25
25
  spec.add_development_dependency "rest-client","~> 1.7"
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wot-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Groza Sergiu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-29 00:00:00.000000000 Z
11
+ date: 2014-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.3'
33
+ version: '10'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.3'
40
+ version: '10'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.1'
47
+ version: '3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.1'
54
+ version: '3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: json
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -95,23 +95,20 @@ files:
95
95
  - LICENSE.txt
96
96
  - README.md
97
97
  - Rakefile
98
- - lib/wot-api.rb
99
- - lib/wot-api/clusters.rb
100
- - lib/wot-api/error.rb
101
- - lib/wot-api/player.rb
102
- - lib/wot-api/player/achievement.rb
103
- - lib/wot-api/player/extended_statistics.rb
104
- - lib/wot-api/player/info.rb
105
- - lib/wot-api/player/statistics.rb
106
- - lib/wot-api/player/tank.rb
107
- - lib/wot-api/version.rb
108
98
  - lib/wot/api.rb
99
+ - lib/wot/api/clusters.rb
100
+ - lib/wot/api/error.rb
109
101
  - lib/wot/api/version.rb
102
+ - lib/wot/player.rb
103
+ - lib/wot/player/achievement.rb
104
+ - lib/wot/player/extended_statistics.rb
105
+ - lib/wot/player/info.rb
106
+ - lib/wot/player/statistics.rb
107
+ - lib/wot/player/tank.rb
110
108
  - spec/spec_helper.rb
111
109
  - spec/wot/api_spec.rb
112
- - test/wot_api_test.rb
113
110
  - wot-api.gemspec
114
- homepage: http://wot.code-panic.com
111
+ homepage: https://github.com/serioja90/wot-api
115
112
  licenses:
116
113
  - MIT
117
114
  metadata: {}
@@ -138,4 +135,3 @@ summary: Ruby World of Tanks API v2.0
138
135
  test_files:
139
136
  - spec/spec_helper.rb
140
137
  - spec/wot/api_spec.rb
141
- - test/wot_api_test.rb
@@ -1,97 +0,0 @@
1
-
2
- require 'json'
3
- require 'rest-client'
4
- require 'active_support/core_ext/hash/indifferent_access'
5
-
6
- module Wot
7
- autoload :Player, 'wot-api/player'
8
-
9
- class Api
10
-
11
- def initialize(region, language = 'en')
12
- cluster = Wot::cluster(region)
13
- @app_id = cluster[:application_id]
14
- @base_url = cluster[:base_url]
15
- @language = language
16
- end
17
-
18
- def search(username, options = {})
19
- return Wot::Player.search self, username, options
20
- end
21
-
22
- def find(account_ids, options = {})
23
- return Wot::Player.find self, account_ids, options
24
- end
25
-
26
- def players_info(account_ids)
27
- ids = (account_ids.class == Array ? account_ids : [account_ids])
28
- return make_request "account/info/", {:account_id => ids.join(",")}
29
- end
30
-
31
- def player_tanks(account_id)
32
- return make_request "account/tanks/", {:account_id => account_id}
33
- end
34
-
35
- def player_achievements(account_id)
36
- return make_request "account/achievements/", {:account_id => account_id}
37
- end
38
-
39
- def player_stats(account_id,hours_ago)
40
- return make_request "stats/accountbytime/", {:account_id => account_id, :hours_ago => hours_ago}
41
- end
42
-
43
- def player_raitings(account_id)
44
- return make_request "account/raitings/", {:account_id => account_id}
45
- end
46
-
47
- def tanks_list()
48
- return make_request "encyclopedia/tanks/", {}
49
- end
50
-
51
- def tank_info(tank_id)
52
- return make_request "encyclopedia/tankinfo/", {:tank_id => tank_id}
53
- end
54
-
55
- def achievements_list()
56
- unless @achievements
57
- response = make_request "encyclopedia/achievements/", {}
58
- @achievements = Wot::Parser.get_achievements_list(response[:data])
59
- end
60
- return @achievements
61
- end
62
-
63
- def engines_list()
64
- raise NotImplementedError
65
- end
66
-
67
- def guns_list()
68
- raise NotImplementedError
69
- end
70
-
71
- def radios_list()
72
- raise NotImplementedError
73
- end
74
-
75
- def suspensions_list()
76
- raise NotImplementedError
77
- end
78
-
79
- def turrets_list
80
- raise NotImplementedError
81
- end
82
-
83
- def make_request(suffix,parameters)
84
- params = {:params => parameters.dup}
85
- params[:params][:application_id] = @app_id
86
- params[:params][:language] = @language
87
- response = JSON.parse(RestClient.get("#{@base_url}/2.0/#{suffix}", params))
88
- response = response.nested_under_indifferent_access
89
- raise Wot::Error.new(response[:error]) if response[:status].downcase == "error"
90
- return response
91
- end
92
- end
93
- end
94
-
95
- require 'wot-api/clusters'
96
- require 'wot-api/error'
97
- require 'wot-api/version'
@@ -1,33 +0,0 @@
1
-
2
- module Wot
3
- CLUSTERS = {
4
- "RU" => {
5
- :base_url => "http://api.worldoftanks.ru",
6
- :application_id => "171745d21f7f98fd8878771da1000a31"
7
- },
8
- "EU" => {
9
- :base_url => "api.worldoftanks.eu",
10
- :application_id => "d0a293dc77667c9328783d489c8cef73"
11
- },
12
- "NA" => {
13
- :base_url => "http://api.worldoftanks.com",
14
- :application_id => "16924c431c705523aae25b6f638c54dd"
15
- },
16
- "ASIA" => {
17
- :base_url => "http://api.worldoftanks.asia",
18
- :application_id => "39b4939f5f2460b3285bfa708e4b252c"
19
- },
20
- "KR" => {
21
- :base_url => "http://api.worldoftanks.kr",
22
- :application_id => "ffea0f1c3c5f770db09357d94fe6abfb"
23
- }
24
- }
25
-
26
- module_function
27
-
28
- def cluster(region)
29
- cluster = Wot::CLUSTERS[region.to_s]
30
- raise "Region '#{region}' not found!" if cluster.nil?
31
- return cluster
32
- end
33
- end
@@ -1,13 +0,0 @@
1
-
2
- module Wot
3
- class Error < StandardError
4
- attr_accessor :field, :message, :code, :value
5
- def initialize(options)
6
- super options[:message]
7
- @field = options[:field]
8
- @message = options[:message]
9
- @code = options[:code]
10
- @value = options[:value]
11
- end
12
- end
13
- end
@@ -1,10 +0,0 @@
1
-
2
- module Wot
3
- class Api
4
- VERSION = "1.0.2"
5
-
6
- def self.version
7
- return VERSION
8
- end
9
- end
10
- end
@@ -1,11 +0,0 @@
1
- #!/usr/bin/ruby
2
- # @Author: Groza Sergiu
3
- # @Date: 2014-07-10 02:28:29
4
- # @Last Modified by: Groza Sergiu
5
- # @Last Modified time: 2014-07-10 02:50:43
6
- require "minitest/autorun"
7
-
8
- class WotApiTest < Minitest::Test
9
- def test_initialize
10
- end
11
- end