gw2-api 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a0f2c8c108757427255fb7802ca45d1a5c6b36197acd5c4f498d0df2421f2188
4
+ data.tar.gz: 594ee6f6c58ab53349fcf8039287c4c0bbd2723a0164f89e2d4eb98e847f98c9
5
+ SHA512:
6
+ metadata.gz: d7ec10329b559efcfd8f19d305baab012952101cdae93882fd56dcee9266a24618920b34ffc97c79df2e42aac6f2ca1c3487eae65ff8929201bc525adcdedd2a
7
+ data.tar.gz: 47b049252cc2965b71a1bad430aad0e14f68ed29f045a4e0a4ad6a8972c2b6d56e7fa2d8c5cd79e2fdc0d287fea9cf7da1be6042a5519a39740cc797eec080f6
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-06-13
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in gw2-api.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gw2-api (0.1.0)
5
+ rake (~> 13.0)
6
+ rspec (~> 3.0)
7
+ rubocop (~> 1.21)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.2)
13
+ diff-lcs (1.5.1)
14
+ json (2.7.2)
15
+ language_server-protocol (3.17.0.3)
16
+ parallel (1.25.1)
17
+ parser (3.3.3.0)
18
+ ast (~> 2.4.1)
19
+ racc
20
+ racc (1.8.0)
21
+ rainbow (3.1.1)
22
+ rake (13.2.1)
23
+ regexp_parser (2.9.2)
24
+ rexml (3.3.0)
25
+ strscan
26
+ rspec (3.13.0)
27
+ rspec-core (~> 3.13.0)
28
+ rspec-expectations (~> 3.13.0)
29
+ rspec-mocks (~> 3.13.0)
30
+ rspec-core (3.13.0)
31
+ rspec-support (~> 3.13.0)
32
+ rspec-expectations (3.13.0)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.13.0)
35
+ rspec-mocks (3.13.1)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.13.0)
38
+ rspec-support (3.13.1)
39
+ rubocop (1.64.1)
40
+ json (~> 2.3)
41
+ language_server-protocol (>= 3.17.0)
42
+ parallel (~> 1.10)
43
+ parser (>= 3.3.0.2)
44
+ rainbow (>= 2.2.2, < 4.0)
45
+ regexp_parser (>= 1.8, < 3.0)
46
+ rexml (>= 3.2.5, < 4.0)
47
+ rubocop-ast (>= 1.31.1, < 2.0)
48
+ ruby-progressbar (~> 1.7)
49
+ unicode-display_width (>= 2.4.0, < 3.0)
50
+ rubocop-ast (1.31.3)
51
+ parser (>= 3.3.1.0)
52
+ ruby-progressbar (1.13.0)
53
+ strscan (3.1.0)
54
+ unicode-display_width (2.5.0)
55
+
56
+ PLATFORMS
57
+ x86_64-linux
58
+
59
+ DEPENDENCIES
60
+ gw2-api!
61
+
62
+ BUNDLED WITH
63
+ 2.4.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Rob Nicholas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Gw2::Api
2
+
3
+ This is a gem used to make calls to the Guild Wars 2 API.
4
+
5
+ ## Installation
6
+
7
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ## Development
22
+
23
+ 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.
24
+
25
+ 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).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gw2-api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/gw2-api/blob/main/CODE_OF_CONDUCT.md).
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
34
+
35
+ ## Code of Conduct
36
+
37
+ Everyone interacting in the Gw2::Api project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/gw2-api/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gw2
4
+ module Api
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
data/lib/gw2/api.rb ADDED
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "api/version"
4
+ require "net/http"
5
+ require_relative "modules/achievements"
6
+ require_relative "modules/account"
7
+
8
+ module Gw2
9
+ module Api
10
+ class Client
11
+
12
+ include Gw2::Api::Achievements
13
+ include Gw2::Api::Account
14
+
15
+ def initialize(args)
16
+ @api_key = args[:api_key]
17
+ @base_url = "https://api.guildwars2.com/v2"
18
+ end
19
+
20
+ # 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)
25
+ output = endpoint
26
+
27
+ return execute_request(output) if params.empty?
28
+
29
+ output += "?"
30
+ params.each do |key, value|
31
+ output += "#{key.to_s}=#{value}&"
32
+ end
33
+ execute_request(output)
34
+ end
35
+
36
+ # Executes a request
37
+ # @endpoint [String] the endpoint to request, e.g. achievements
38
+ # @return [Net::HTTP] the response from the request
39
+ def execute_request(endpoint)
40
+ uri = URI("#{@base_url}/#{endpoint}")
41
+ request = Net::HTTP::Get.new(uri)
42
+ request["Authorization"] = "Bearer #{@api_key}"
43
+
44
+ Net::HTTP.start(request.uri.hostname, request.uri.port, use_ssl: true) do |http|
45
+ http.request(request)
46
+ end
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,141 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gw2
4
+ module Api
5
+ # achievements.rb
6
+ module Account
7
+ # Returns the account information
8
+ def account
9
+ execute_request("account")
10
+ end
11
+
12
+ # Returns the account achievements
13
+ # @param [Hash] params the options to filter the achievements
14
+ # Valid Parameters
15
+ # - id: [String] the id of the achievement to filter
16
+ # - ids: [String] the ids of the achievements to filter comma seperated
17
+ # - page: [String] the page number to filter
18
+ # - page_size: [String] the page size to filter
19
+ def account_achievements(params = {})
20
+ execute_with_params('account/achievements', params)
21
+ end
22
+
23
+ # Returns the account bank
24
+ # Empty slots are represented by null
25
+ # Slot is indicated by the index of the array
26
+ def account_bank
27
+ request_string = "account/bank"
28
+
29
+ execute_request(request_string)
30
+ end
31
+
32
+ # Returns the daily dungeons for the account
33
+ def account_dungeons
34
+ execute_request("account/dungeons")
35
+ end
36
+
37
+ # Returns the dye ids unlocked on the account
38
+ def account_dyes
39
+ execute_request("account/dyes")
40
+ end
41
+
42
+ # Returns the finisher ids unlocked on the account
43
+ def account_finishers
44
+ execute_request("account/finishers")
45
+ end
46
+
47
+ # Returns the glider IDs unlocked on the account
48
+ def account_gliders
49
+ execute_request("account/gliders")
50
+ end
51
+
52
+ # Returns the cat unlocks for the home instance on the account
53
+ def account_home_cats
54
+ execute_request("account/home/cats")
55
+ end
56
+
57
+ # Returns the nodes unlocked for the home instance on the account
58
+ def account_home_nodes
59
+ execute_request("account/home/nodes")
60
+ end
61
+
62
+ # Alias to account_shared_inventory
63
+ def account_inventory
64
+ account_shared_inventory
65
+ end
66
+
67
+ # Returns the shared inventory slots for the account
68
+ # Empty slots are represented by null
69
+ # Slot is indicated by the index of the array
70
+ def account_shared_inventory
71
+ execute_request("account/inventory")
72
+ end
73
+
74
+ # Returns the mail carrier ids unlocked on the account
75
+ def account_mail_carriers
76
+ execute_request("account/mailcarriers")
77
+ end
78
+
79
+ # Returns the masteries unlocked on the account
80
+ def account_masteries
81
+ execute_request("account/masteries")
82
+ end
83
+
84
+ # Returns the mastery points earned / spent on the account
85
+ def account_mastery_points
86
+ execute_request("account/mastery/points")
87
+ end
88
+
89
+ # Returns the account materials
90
+ # Array index indicates the slot
91
+ # Empty slots are represented by a count of 0
92
+ # @param [Hash] params the options to filter the materials
93
+ # Valid Parameters
94
+ # ids: [String] the ids of the materials to filter comma seperated, can optionally use 'all' to get all of them
95
+ def account_materials(params = {})
96
+ execute_with_params("account/materials", params)
97
+ end
98
+
99
+ # Returns the account mini ids unlocked
100
+ def account_minis
101
+ execute_request("account/minis")
102
+ end
103
+
104
+ # Returns the account outfit ids unlocked
105
+ def account_outfits
106
+ execute_request("account/outfits")
107
+ end
108
+
109
+ # Returns the account pvp hero ids unlocked
110
+ def account_pvp_heroes
111
+ execute_request("account/pvp/heroes")
112
+ end
113
+
114
+ # Returns the account weekly raid progress
115
+ def account_raids
116
+ execute_request("account/raids")
117
+ end
118
+
119
+ # Returns the account recipe ids unlocked
120
+ def account_recipes
121
+ execute_request("account/recipes")
122
+ end
123
+
124
+ # Returns the account skin ids unlocked
125
+ def account_skins
126
+ execute_request("account/skins")
127
+ end
128
+
129
+ # Returns the account title ids unlocked
130
+ def account_titles
131
+ execute_request("account/titles")
132
+ end
133
+
134
+ # Returns the account currencies to the amount of currency the account has
135
+ def account_wallet
136
+ execute_request("account/wallet")
137
+ end
138
+
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gw2
4
+ module Api
5
+ # achievements.rb
6
+ # This module is responsible for methods for querying information about achievements
7
+ module Achievements
8
+ # Returns the achievements
9
+ # @param [Hash] params the options to filter the achievements
10
+ # Valid Parameters
11
+ # - id: [String] the id of the achievement to filter
12
+ # - ids: [String] the ids of the achievements to filter comma seperated
13
+ # - page: [String] the page number to filter
14
+ # - page_size: [String] the page size to filter
15
+ def achievements(params = {})
16
+ execute_with_params('achievements', params)
17
+ end
18
+
19
+ # Returns the achievements groups
20
+ # @param [Hash] params the options to filter the achievements
21
+ # Valid Parameters
22
+ # - id: [String] the id of the achievement to filter
23
+ # - ids: [String] the ids of the achievements to filter comma seperated
24
+ # - page: [String] the page number to filter
25
+ # - page_size: [String] the page size to filter
26
+ def achievements_groups(params = {})
27
+ execute_with_params('achievements/groups', params)
28
+ end
29
+
30
+ # Returns the achievements categories
31
+ # @param [Hash] params the options to filter the achievements
32
+ # Valid Parameters
33
+ # - id: [String] the id of the achievement to filter
34
+ # - ids: [String] the ids of the achievements to filter comma seperated
35
+ # - page: [String] the page number to filter
36
+ def achievements_categories(params = {})
37
+ execute_with_params('achievements/categories', params)
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,51 @@
1
+ module Gw2
2
+ module Api
3
+ module Account
4
+ def account: -> Net::HTTP
5
+
6
+ def account_achievements: -> Net::HTTP
7
+
8
+ def account_bank: -> Net::HTTP
9
+
10
+ def account_dungeons: -> Net::HTTP
11
+
12
+ def account_dyes: -> Net::HTTP
13
+
14
+ def account_finishers: -> Net::HTTP
15
+
16
+ def account_gliders: -> Net::HTTP
17
+
18
+ def account_home_cats: -> Net::HTTP
19
+
20
+ def account_home_nodes: -> Net::HTTP
21
+
22
+ def account_inventory: -> Net::HTTP
23
+
24
+ def account_mail_carriers: -> Net::HTTP
25
+
26
+ def account_masteries: -> Net::HTTP
27
+
28
+ def account_mastery_points: -> Net::HTTP
29
+
30
+ def account_materials: -> Net::HTTP
31
+
32
+ def account_minis: -> Net::HTTP
33
+
34
+ def account_outfits: -> Net::HTTP
35
+
36
+ def account_pvp_heroes: -> Net::HTTP
37
+
38
+ def account_raids: -> Net::HTTP
39
+
40
+ def account_recipes: -> Net::HTTP
41
+
42
+ def account_shared_inventory: -> Net::HTTP
43
+
44
+ def account_skins: -> Net::HTTP
45
+
46
+ def account_titles: -> Net::HTTP
47
+
48
+ def account_wallet: -> Net::HTTP
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,12 @@
1
+ module Gw2
2
+ module Api
3
+ module Achievements
4
+ def achievements: -> Net::HTTP
5
+
6
+ def achievements_categories: -> Net::HTTP
7
+
8
+ def achievements_groups: -> Net::HTTP
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ module Gw2
2
+ module Api
3
+ class Client
4
+ def execute_request: -> Net::HTTP
5
+
6
+ def execute_with_params: -> Net::HTTP
7
+ end
8
+ end
9
+ end
data/sig/gw2/api.rbs ADDED
@@ -0,0 +1,6 @@
1
+ module Gw2
2
+ module Api
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gw2-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rob Nicholas
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-06-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.21'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.21'
55
+ description: This is a wrapper to the Guild Wars 2 API. It is designed to make it
56
+ easier to interact with the API and to provide a more Ruby-like interface to the
57
+ data provided by the API.
58
+ email:
59
+ - rob@projectshiba.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".rspec"
65
+ - ".rubocop.yml"
66
+ - CHANGELOG.md
67
+ - Gemfile
68
+ - Gemfile.lock
69
+ - LICENSE.txt
70
+ - README.md
71
+ - Rakefile
72
+ - lib/gw2/api.rb
73
+ - lib/gw2/api/version.rb
74
+ - lib/gw2/modules/account.rb
75
+ - lib/gw2/modules/achievements.rb
76
+ - sig/gw2/api.rbs
77
+ - sig/gw2/api/account.rbs
78
+ - sig/gw2/api/achievements.rbs
79
+ - sig/gw2/api/client.rbs
80
+ homepage: https://github.com/nicholasrobertm/gw2-api
81
+ licenses:
82
+ - MIT
83
+ metadata:
84
+ allowed_push_host: https://rubygems.org
85
+ homepage_uri: https://github.com/nicholasrobertm/gw2-api
86
+ source_code_uri: https://github.com/nicholasrobertm/gw2-api
87
+ changelog_uri: https://github.com/nicholasrobertm/gw2-api
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.6.0
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.4.1
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: This is an API wrapper for the Guild Wars 2 API.
107
+ test_files: []