bnet_api 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTdlMGYxMjczNzZkMjJkYjQ4OGNkOWU0ZWNlMmUxZTBkMWVhMDVkNg==
4
+ ZmEwYWMxYWUzNGFkNjhkYmY1NjAyZGJmOTkwZTcxNzczMWE1ZWRiNA==
5
5
  data.tar.gz: !binary |-
6
- Njk1NmI3MmU2NDdhNWM0MTk5NGViMjBmZjAyNTAwMWJhNGY1OTJlOQ==
6
+ ZDBhYTljZjAwYTk3NGQ5NTgyZTIyZjZjMDRiNzliMmZjNjBiNzNkMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Mzk4NDBmMDVlZWQzZDgyNDE1YjI1ZDNjZjVlOTdjYzM2N2E4ZDE3YjNmZmJl
10
- OTg4M2M1ZThkZWNhMTVlOTI0YzZlZDQ5ZjZlNGEyODc3MWI0MWQzNDJjNTcz
11
- OTFkZjIxNDQzYTYxNTUyNWRjOGNhN2QwMDAxMjc0MjA0YjQ5NWQ=
9
+ YjU5ZWRhNjRhYmJhZTMwNDUzMjMyZTk4ZTk3MGViYTY1NTJhZWU0ZmVkMDA3
10
+ ODFkZmZkYjRkZGIyMjg0NDMwOWQ1ZDgwNDYzMjYyZWViYmQ2OTlkZjljMWI1
11
+ MDc3ZWYzNWNjMzkwMDk0ZjZmY2E5YjAxOTQxYmQ2ZDI0OTQ0ZTY=
12
12
  data.tar.gz: !binary |-
13
- ZGY5MWM0YzU2OGExNWFlZGM5ZTkzZmQyMzMxNGM4ZGFjZDE2ZTI4MTA5Zjll
14
- Mzk1MWYyMTUxNmJlMzMxZDkzMWUyYjU3ZTYxNzQ2YzAxZjZjNDBmMTk3YmMx
15
- ODY0MWYxYTE1OTlhYjBjOGE4ZjA4N2E0Y2JmYWZhNWIyYTFjNGM=
13
+ YjM3ZGE3NmRkNTZkYjllN2QzMjU4YjA5OTdmYTJiZDdhMTBjYTQzNmU5MjQx
14
+ OGVlMjk2ZjE1YWUzZjA0YjhmOGI2ODIzYzEzYTE0MmViNDE2Zjc0YmZlOTY1
15
+ NmNiNmQwMmRhYjI3ZWNlYjU2ODU5NGIwZmI0ZGU4NmI2Y2YzMDQ=
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
- rspec_results.html
1
+ /coverage
2
+ *.gem
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
- --format progress
2
- --format html
3
- --out rspec_results.html
1
+ --color
2
+ --order random
data/.travis.yml ADDED
@@ -0,0 +1,24 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1
7
+ - jruby-19mode
8
+ - jruby-head
9
+ - ruby-head
10
+
11
+ sudo: false
12
+
13
+ bundler_args: --without development --retry=3 --jobs=3
14
+
15
+ env:
16
+ global:
17
+ - JRUBY_OPTS="$JRUBY_OPTS --debug"
18
+
19
+ matrix:
20
+ allow_failures:
21
+ - rvm: jruby-head
22
+ - rvm: rbx-2
23
+ - rvm: ruby-head
24
+ fast_finish: true
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ # 0.1.2
2
+
3
+ * Added OAuth Account API
4
+ * Added Community OAuth Profile API
data/Gemfile CHANGED
@@ -1,3 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'rake'
4
+
5
+ group :test do
6
+ gem 'coveralls'
7
+ gem 'rspec', '>= 2.14'
8
+ end
9
+
3
10
  gemspec
data/Gemfile.lock CHANGED
@@ -1,46 +1,59 @@
1
- PATH
2
- remote: .
3
- specs:
4
- omniauth-bnet (0.0.1)
5
- httparty
6
- omniauth
7
- omniauth-bnet
8
- recursive-open-struct
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- diff-lcs (1.2.5)
14
- hashie (3.3.2)
15
- httparty (0.13.3)
16
- json (~> 1.8)
17
- multi_xml (>= 0.5.2)
18
- json (1.8.1)
19
- multi_xml (0.5.5)
20
- omniauth (1.2.2)
21
- hashie (>= 1.2, < 4)
22
- rack (~> 1.0)
23
- rack (1.5.2)
24
- rake (10.4.2)
25
- recursive-open-struct (0.5.0)
26
- rspec (3.1.0)
27
- rspec-core (~> 3.1.0)
28
- rspec-expectations (~> 3.1.0)
29
- rspec-mocks (~> 3.1.0)
30
- rspec-core (3.1.7)
31
- rspec-support (~> 3.1.0)
32
- rspec-expectations (3.1.2)
33
- diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.1.0)
35
- rspec-mocks (3.1.3)
36
- rspec-support (~> 3.1.0)
37
- rspec-support (3.1.2)
38
-
39
- PLATFORMS
40
- x86-mingw32
41
-
42
- DEPENDENCIES
43
- bundler
44
- omniauth-bnet!
45
- rake
46
- rspec
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bnet_api (0.1.1)
5
+ httparty (= 0.13.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coveralls (0.7.2)
11
+ multi_json (~> 1.3)
12
+ rest-client (= 1.6.7)
13
+ simplecov (>= 0.7)
14
+ term-ansicolor (= 1.2.2)
15
+ thor (= 0.18.1)
16
+ diff-lcs (1.2.5)
17
+ docile (1.1.5)
18
+ httparty (0.13.3)
19
+ json (~> 1.8)
20
+ multi_xml (>= 0.5.2)
21
+ json (1.8.1)
22
+ mime-types (2.4.3)
23
+ multi_json (1.10.1)
24
+ multi_xml (0.5.5)
25
+ rake (10.4.2)
26
+ rest-client (1.6.7)
27
+ mime-types (>= 1.16)
28
+ rspec (3.1.0)
29
+ rspec-core (~> 3.1.0)
30
+ rspec-expectations (~> 3.1.0)
31
+ rspec-mocks (~> 3.1.0)
32
+ rspec-core (3.1.7)
33
+ rspec-support (~> 3.1.0)
34
+ rspec-expectations (3.1.2)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.1.0)
37
+ rspec-mocks (3.1.3)
38
+ rspec-support (~> 3.1.0)
39
+ rspec-support (3.1.2)
40
+ simplecov (0.9.1)
41
+ docile (~> 1.1.0)
42
+ multi_json (~> 1.0)
43
+ simplecov-html (~> 0.8.0)
44
+ simplecov-html (0.8.0)
45
+ term-ansicolor (1.2.2)
46
+ tins (~> 0.8)
47
+ thor (0.18.1)
48
+ tins (0.13.2)
49
+
50
+ PLATFORMS
51
+ x64-mingw32
52
+ x86-mingw32
53
+
54
+ DEPENDENCIES
55
+ bnet_api!
56
+ bundler
57
+ coveralls
58
+ rake
59
+ rspec (>= 2.14)
data/README.md CHANGED
@@ -1,10 +1,27 @@
1
1
  # BnetApi
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/bnet_api.svg)](http://badge.fury.io/rb/bnet_api)
4
+ [![Build Status](https://travis-ci.org/tconnolly/BnetApi.svg?branch=master)](https://travis-ci.org/tconnolly/BnetApi)
5
+ [![Code Climate](https://codeclimate.com/github/tconnolly/BnetApi/badges/gpa.svg)](https://codeclimate.com/github/tconnolly/BnetApi)
6
+ [![Coverage Status](https://coveralls.io/repos/tconnolly/BnetApi/badge.png?branch=master)](https://coveralls.io/r/tconnolly/BnetApi?branch=master
7
+ )[![Inline docs](http://inch-ci.org/github/tconnolly/bnetapi.svg?branch=master)](http://inch-ci.org/github/tconnolly/bnetapi)
8
+
3
9
  A Ruby wrapper for the Battle.net API
4
10
 
11
+ ## Current Version: 0.1.2
12
+
13
+ ### Status
14
+
15
+ API | Status
16
+ ------------------|-----------------
17
+ World of Warcraft | Implemented
18
+ Diablo III | Not implemented
19
+ Starcraft II | Not implemented
20
+ OAuth | Implemented
21
+
5
22
  ## Installation
6
23
 
7
- TODO
24
+ gem install bnet_api
8
25
 
9
26
  ## Configuration
10
27
 
@@ -51,7 +68,7 @@ tw | zh_TW
51
68
 
52
69
  Each API method returns a hash containing the values returned from the API.
53
70
 
54
- For more detailed documentation visit the official documentation (https://dev.battle.net).
71
+ For more detailed documentation on returned data visit the official documentation (https://dev.battle.net).
55
72
 
56
73
  ### Achievement API
57
74
 
@@ -265,4 +282,4 @@ To get the data for a spell:
265
282
 
266
283
  ```ruby
267
284
  BnetApi::WoW.spell(8056)
268
- ```
285
+ ```
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'rspec/core/rake_task'
2
+ RSpec::Core::RakeTask.new(:spec)
3
+
4
+ task test: :spec
5
+
6
+ task default: [:spec]
data/bnet_api.gemspec CHANGED
@@ -21,6 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'httparty', '0.13.3'
22
22
 
23
23
  spec.add_development_dependency 'bundler'
24
- spec.add_development_dependency 'rake'
25
24
  spec.add_development_dependency 'rspec'
26
25
  end
data/lib/bnet_api.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'bnet_api/oauth'
1
2
  require 'bnet_api/wow'
2
3
  require 'bnet_api/wow_data'
3
4
  require 'bnet_api/version'
@@ -43,6 +44,10 @@ module BnetApi
43
44
  return response
44
45
  end
45
46
 
47
+ def make_request_oauth(request, access_token)
48
+ self.get("https://#{@config.region}.api.battle.net/#{request}?locale=#{@config.locale}&access_token=#{access_token}")
49
+ end
50
+
46
51
  private
47
52
  def build_url_params(*optional_fields)
48
53
  url_params = "?locale=#{@config.locale}&apikey=#{@config.api_key}"
@@ -0,0 +1,21 @@
1
+ module BnetApi
2
+ module OAuth
3
+ extend self
4
+
5
+ def account_id(access_token)
6
+ BnetApi.make_request_oauth('/account/user/id', access_token)
7
+ end
8
+
9
+ def battletag(access_token)
10
+ BnetApi.make_request_oauth('/account/user/battletag', access_token)
11
+ end
12
+
13
+ def sc2_profile(access_token)
14
+ BnetApi.make_request_oauth('/sc2/profile/user', access_token)
15
+ end
16
+
17
+ def wow_profile(access_token)
18
+ BnetApi.make_request_oauth('/wow/user/characters', access_token)
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module BnetApi
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::OAuth do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "gets an account ID from the API" do
13
+ account = BnetApi::OAuth.account_id('q3dqppcugfk7phjxbrtwuux3')
14
+
15
+ expect(account['id']).to eq 50804047
16
+ end
17
+
18
+ it "gets a battletag from the API" do
19
+ account = BnetApi::OAuth.battletag('q3dqppcugfk7phjxbrtwuux3')
20
+
21
+ expect(account['battletag']).to eq 'Ragwolf#2851'
22
+ end
23
+
24
+ it "gets a Starcraft II profile from the API" do
25
+ profile = BnetApi::OAuth.sc2_profile('q3dqppcugfk7phjxbrtwuux3')
26
+
27
+ expect(profile['characters']).not_to be_nil
28
+ end
29
+
30
+ it "gets a World of Warcraft profile from the API" do
31
+ profile = BnetApi::OAuth.wow_profile('q3dqppcugfk7phjxbrtwuux3')
32
+
33
+ expect(profile['characters']).not_to be_nil
34
+ end
35
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,5 @@
1
1
  require 'rspec'
2
- require 'bnet_api'
2
+ require 'bnet_api'
3
+ require 'coveralls'
4
+
5
+ Coveralls.wear!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bnet_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Connolly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2014-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ! '>='
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rspec
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -75,16 +61,21 @@ extra_rdoc_files: []
75
61
  files:
76
62
  - .gitignore
77
63
  - .rspec
64
+ - .travis.yml
65
+ - CHANGELOG.md
78
66
  - Gemfile
79
67
  - Gemfile.lock
80
68
  - LICENSE.md
81
69
  - README.md
70
+ - Rakefile
82
71
  - bnet_api.gemspec
83
72
  - lib/bnet_api.rb
73
+ - lib/bnet_api/oauth.rb
84
74
  - lib/bnet_api/version.rb
85
75
  - lib/bnet_api/wow.rb
86
76
  - lib/bnet_api/wow_data.rb
87
77
  - spec/bnet_api/bnet_api_spec.rb
78
+ - spec/bnet_api/oauth_spec.rb
88
79
  - spec/bnet_api/wow/wow_achievement_spec.rb
89
80
  - spec/bnet_api/wow/wow_auction_data_spec.rb
90
81
  - spec/bnet_api/wow/wow_battlepet_spec.rb
@@ -125,6 +116,7 @@ specification_version: 4
125
116
  summary: Ruby wrapper for the Battle.net web API.
126
117
  test_files:
127
118
  - spec/bnet_api/bnet_api_spec.rb
119
+ - spec/bnet_api/oauth_spec.rb
128
120
  - spec/bnet_api/wow/wow_achievement_spec.rb
129
121
  - spec/bnet_api/wow/wow_auction_data_spec.rb
130
122
  - spec/bnet_api/wow/wow_battlepet_spec.rb