gw2-api 0.2.0 → 0.4.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
  SHA256:
3
- metadata.gz: bff8b7a236713ec7ab718626fc956da6d1063e59efa52fce48ff8b864500993f
4
- data.tar.gz: ddb30ca1c16e8aeb6b7c146910743d43ec2d6c61881bd57458164749261c1517
3
+ metadata.gz: f6dcc9e1374f9272f25aeff77172fd2c2f0b4d2e231fb0ed76c06a7fda74721a
4
+ data.tar.gz: 4d69081af045e6d07245d112c8634917c993460295841de5450733a9f8c20c56
5
5
  SHA512:
6
- metadata.gz: 97efa70f1ce3643a02fb937be1e8fa7f918351893a1a10a539c15179967f8a036108c43419998e275a49aaf0523d6cec5bf8c47d04a420a3ebfe2395b708241d
7
- data.tar.gz: b63f4448a59fbbb5cf538442d30226f4e4732753e846250353b9886885fdf50afda5e62618b5d445c77a11525a50c5ac7942914a3c3feb76473fa2f99326cf06
6
+ metadata.gz: 1427fbf7900e4c44b60968a9e05686ad9af3e18fbd1d681b85f652f550bfcaf4f8f93e0835eb450e32f7a3be442388b2b8ffb30e1bd5867bcac11af572edaa9e
7
+ data.tar.gz: a2cb6ba23d89dd5ac73113307f3cc48348cd6cb736c0318ce40fd6503bf9dd74afeda53b662775e112e02e41cd26a766e238bc3914d26bee70eb5243d720d3e0
data/.rubocop.yml CHANGED
@@ -1,6 +1,11 @@
1
1
  AllCops:
2
+ Exclude:
3
+ - 'gw2-api.gemspec'
2
4
  TargetRubyVersion: 2.6
3
5
 
6
+ Metrics/BlockLength:
7
+ Enabled: false
8
+
4
9
  Style/StringLiterals:
5
10
  Enabled: true
6
11
  EnforcedStyle: double_quotes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gw2-api (0.1.0)
4
+ gw2-api (0.4.0)
5
5
  rake (~> 13.0)
6
6
  rspec (~> 3.0)
7
7
  rubocop (~> 1.21)
data/README.md CHANGED
@@ -1,59 +1,59 @@
1
- # Gw2::Api
2
-
3
- This is a gem used to make calls to the Guild Wars 2 API.
4
-
5
- ## Installation
6
-
7
- Install the gem and add to the application's Gemfile by executing:
8
-
9
- $ bundle add gw2-api
10
-
11
- If bundler is not being used to manage dependencies, install the gem by executing:
12
-
13
- $ gem install gw2-api
14
-
15
- ## Usage
16
-
17
- To use the gem, first require it in the application, then create a new instance of the `Gw2::Api::Client` class:
18
-
19
- ```ruby
20
- require 'gw2-api'
21
-
22
- client = Gw2::Api::Client.new(api_key: ENV["GW2_API_KEY"])
23
-
24
- puts client.account.body
25
- puts client.achievements(ids: "1840,910")
26
- ```
27
-
28
- You can replace `ENV["GW2_API_KEY"]` with your own API Key, or set the env variable
29
-
30
- A list of available functions can be found `lib/gw2/modules`.
31
-
32
- You can find valid parameters for each function in the [Guild Wars 2 API documentation](https://wiki.guildwars2.com/wiki/API:Main) or from the public [API-CDI](https://github.com/arenanet/api-cdi) repo.
33
-
34
- ## Tests
35
-
36
- To run the tests, execute:
37
-
38
- $ bundle exec rspec
39
-
40
- Note that you need to set a valid API key in the environment variable `GW2_API_KEY` to run the tests.
41
- GW2's API Availability can affect the result of the tests (if it's down, the tests will fail).
42
-
43
- ## Development
44
-
45
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
-
47
- 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).
48
-
49
- ## Contributing
50
-
51
- Bug reports and pull requests are welcome on GitHub at https://github.com/nicholasrobertm/gw2-api.
52
-
53
- ## License
54
-
55
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
56
-
57
- ## Code of Conduct
58
-
59
- Be a decent person, and don't be a jerk, it's that simple!
1
+ # Gw2::Api
2
+
3
+ This is a gem used to make calls to the Guild Wars 2 API.
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ $ bundle add gw2-api
10
+
11
+ If bundler is not being used to manage dependencies, install the gem by executing:
12
+
13
+ $ gem install gw2-api
14
+
15
+ ## Usage
16
+
17
+ To use the gem, first require it in the application, then create a new instance of the `Gw2::Api::Client` class:
18
+
19
+ ```ruby
20
+ require 'gw2-api'
21
+
22
+ client = Gw2::Api::Client.new(api_key: ENV["GW2_API_KEY"])
23
+
24
+ puts client.account.body
25
+ puts client.achievements(ids: "1840,910")
26
+ ```
27
+
28
+ You can replace `ENV["GW2_API_KEY"]` with your own API Key, or set the env variable
29
+
30
+ A list of available functions can be found `lib/gw2/modules`.
31
+
32
+ You can find valid parameters for each function in the [Guild Wars 2 API documentation](https://wiki.guildwars2.com/wiki/API:Main) or from the public [API-CDI](https://github.com/arenanet/api-cdi) repo.
33
+
34
+ ## Tests
35
+
36
+ To run the tests, execute:
37
+
38
+ $ bundle exec rspec
39
+
40
+ Note that you need to set a valid API key in the environment variable `GW2_API_KEY` to run the tests.
41
+ GW2's API Availability can affect the result of the tests (if it's down, the tests will fail).
42
+
43
+ ## Development
44
+
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
+
47
+ 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).
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nicholasrobertm/gw2-api.
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
56
+
57
+ ## Code of Conduct
58
+
59
+ Be a decent person, and don't be a jerk, it's that simple!
data/Rakefile CHANGED
@@ -5,8 +5,4 @@ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- require "rubocop/rake_task"
9
-
10
- RuboCop::RakeTask.new
11
-
12
- task default: %i[spec rubocop]
8
+ task default: %i[spec]
data/gw2-api.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/gw2/api/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "gw2-api"
7
+ spec.version = Gw2::Api::VERSION
8
+ spec.authors = ["Rob Nicholas"]
9
+ spec.email = ["rob@projectshiba.com"]
10
+
11
+ spec.summary = "This is an API wrapper for the Guild Wars 2 API."
12
+ spec.description = "This is a wrapper to the Guild Wars 2 API. It is designed to make it easier to interact with the API and to provide a more Ruby-like interface to the data provided by the API."
13
+ spec.homepage = "https://github.com/nicholasrobertm/gw2-api"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/nicholasrobertm/gw2-api"
21
+ spec.metadata["changelog_uri"] = "https://github.com/nicholasrobertm/gw2-api"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
28
+ end
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_dependency "rake", "~> 13.0"
35
+ spec.add_dependency "rspec", "~> 3.0"
36
+ spec.add_dependency "rubocop", "~> 1.21"
37
+
38
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gw2
4
4
  module Api
5
- VERSION = "0.2.0"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
data/lib/gw2/api.rb CHANGED
@@ -7,8 +7,17 @@ require_relative "modules/account"
7
7
 
8
8
  module Gw2
9
9
  module Api
10
+ # Used to create a client to talk to the Guild Wars 2 API
11
+ # Arguments
12
+ # @args [Hash] the arguments to create the client
13
+ # Valid Arguments
14
+ # - api_key: [String] the api key to use for the client, defaults to ENV["GW2_API_KEY"]
15
+ # Variables
16
+ # @api_key [String] the api key to use for the client
17
+ # @base_url [String] the base url for the API
18
+ # See modules for available methods
19
+ # See https://wiki.guildwars2.com/wiki/API:Main
10
20
  class Client
11
-
12
21
  include Gw2::Api::Achievements
13
22
  include Gw2::Api::Account
14
23
 
@@ -18,17 +27,14 @@ module Gw2
18
27
  end
19
28
 
20
29
  # Executes a request with parameters
21
- # @endpoint [String] the endpoint to request, e.g. achievements
22
- # @params [Hash] the parameters to filter the request
23
- # @return [Net::HTTP] the response from the request
24
- def execute_with_params(endpoint, params)
30
+ def execute_with_params(endpoint, parameters)
25
31
  output = endpoint
26
32
 
27
- return execute_request(output) if params.empty?
33
+ return execute_request(output) if parameters.empty?
28
34
 
29
35
  output += "?"
30
- params.each do |key, value|
31
- output += "#{key.to_s}=#{value}&"
36
+ parameters.each do |key, value|
37
+ output += "#{key}=#{value}&"
32
38
  end
33
39
  execute_request(output)
34
40
  end
@@ -45,7 +51,6 @@ module Gw2
45
51
  http.request(request)
46
52
  end
47
53
  end
48
-
49
54
  end
50
55
  end
51
56
  end
@@ -17,7 +17,7 @@ module Gw2
17
17
  # - page: [String] the page number to filter
18
18
  # - page_size: [String] the page size to filter
19
19
  def account_achievements(params = {})
20
- execute_with_params('account/achievements', params)
20
+ execute_with_params("account/achievements", params)
21
21
  end
22
22
 
23
23
  # Returns the account bank
@@ -135,7 +135,6 @@ module Gw2
135
135
  def account_wallet
136
136
  execute_request("account/wallet")
137
137
  end
138
-
139
138
  end
140
139
  end
141
140
  end
@@ -13,7 +13,7 @@ module Gw2
13
13
  # - page: [String] the page number to filter
14
14
  # - page_size: [String] the page size to filter
15
15
  def achievements(params = {})
16
- execute_with_params('achievements', params)
16
+ execute_with_params("achievements", params)
17
17
  end
18
18
 
19
19
  # Returns the achievements groups
@@ -24,7 +24,7 @@ module Gw2
24
24
  # - page: [String] the page number to filter
25
25
  # - page_size: [String] the page size to filter
26
26
  def achievements_groups(params = {})
27
- execute_with_params('achievements/groups', params)
27
+ execute_with_params("achievements/groups", params)
28
28
  end
29
29
 
30
30
  # Returns the achievements categories
@@ -34,9 +34,8 @@ module Gw2
34
34
  # - ids: [String] the ids of the achievements to filter comma seperated
35
35
  # - page: [String] the page number to filter
36
36
  def achievements_categories(params = {})
37
- execute_with_params('achievements/categories', params)
37
+ execute_with_params("achievements/categories", params)
38
38
  end
39
-
40
39
  end
41
40
  end
42
- end
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gw2-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Nicholas
@@ -69,6 +69,7 @@ files:
69
69
  - LICENSE.txt
70
70
  - README.md
71
71
  - Rakefile
72
+ - gw2-api.gemspec
72
73
  - lib/gw2/api.rb
73
74
  - lib/gw2/api/version.rb
74
75
  - lib/gw2/modules/account.rb
@@ -100,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
101
  - !ruby/object:Gem::Version
101
102
  version: '0'
102
103
  requirements: []
103
- rubygems_version: 3.4.1
104
+ rubygems_version: 3.5.11
104
105
  signing_key:
105
106
  specification_version: 4
106
107
  summary: This is an API wrapper for the Guild Wars 2 API.