esi-sdk 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +9 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +36 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/ISSUE_TEMPLATE/support.md +7 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +37 -0
- data/.github/dependabot.yml +17 -0
- data/.github/workflows/cicd.yml +181 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.rubocop.yml +36 -0
- data/.ruby-version +1 -0
- data/.yardext.rb +18 -0
- data/.yardopts +17 -0
- data/CHANGELOG.md +17 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/CONTRIBUTING.md +69 -0
- data/Gemfile +24 -0
- data/Gemfile.lock +141 -0
- data/LICENSE.txt +21 -0
- data/README.md +87 -0
- data/Rakefile +349 -0
- data/SECURITY.md +13 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/esi-sdk.gemspec +32 -0
- data/exe/esi-sdk +4 -0
- data/lib/esi/client/alliance.rb +104 -0
- data/lib/esi/client/assets.rb +179 -0
- data/lib/esi/client/bookmarks.rb +126 -0
- data/lib/esi/client/calendar.rb +139 -0
- data/lib/esi/client/character.rb +389 -0
- data/lib/esi/client/clones.rb +69 -0
- data/lib/esi/client/contacts.rb +277 -0
- data/lib/esi/client/contracts.rb +274 -0
- data/lib/esi/client/corporation.rb +626 -0
- data/lib/esi/client/dogma.rb +117 -0
- data/lib/esi/client/faction_warfare.rb +196 -0
- data/lib/esi/client/fittings.rb +93 -0
- data/lib/esi/client/fleets.rb +428 -0
- data/lib/esi/client/incursions.rb +30 -0
- data/lib/esi/client/industry.rb +237 -0
- data/lib/esi/client/insurance.rb +30 -0
- data/lib/esi/client/killmails.rb +95 -0
- data/lib/esi/client/location.rb +100 -0
- data/lib/esi/client/loyalty.rb +61 -0
- data/lib/esi/client/mail.rb +244 -0
- data/lib/esi/client/market.rb +302 -0
- data/lib/esi/client/opportunities.rb +124 -0
- data/lib/esi/client/planetary_interaction.rb +122 -0
- data/lib/esi/client/routes.rb +37 -0
- data/lib/esi/client/search.rb +68 -0
- data/lib/esi/client/skills.rb +97 -0
- data/lib/esi/client/sovereignty.rb +74 -0
- data/lib/esi/client/status.rb +31 -0
- data/lib/esi/client/universe.rb +640 -0
- data/lib/esi/client/user_interface.rb +145 -0
- data/lib/esi/client/wallet.rb +191 -0
- data/lib/esi/client/wars.rb +82 -0
- data/lib/esi/client.rb +225 -0
- data/lib/esi/errors.rb +51 -0
- data/lib/esi/version.rb +5 -0
- data/lib/esi-sdk.rb +8 -0
- data/release.config.js +32 -0
- data/yard/fulldoc/html/css/pygments-default.css +69 -0
- data/yard/fulldoc/html/setup.rb +6 -0
- data/yard/layout/html/setup.rb +6 -0
- metadata +156 -0
data/Gemfile.lock
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
esi-sdk (1.1.1)
|
5
|
+
faraday (~> 1.5)
|
6
|
+
faraday-http-cache (~> 2.2)
|
7
|
+
faraday_middleware (~> 1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (6.1.4)
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
i18n (>= 1.6, < 2)
|
15
|
+
minitest (>= 5.1)
|
16
|
+
tzinfo (~> 2.0)
|
17
|
+
zeitwerk (~> 2.3)
|
18
|
+
addressable (2.8.0)
|
19
|
+
public_suffix (>= 2.0.2, < 5.0)
|
20
|
+
ast (2.4.2)
|
21
|
+
concurrent-ruby (1.1.9)
|
22
|
+
crack (0.4.5)
|
23
|
+
rexml
|
24
|
+
diff-lcs (1.4.4)
|
25
|
+
docile (1.4.0)
|
26
|
+
faraday (1.5.1)
|
27
|
+
faraday-em_http (~> 1.0)
|
28
|
+
faraday-em_synchrony (~> 1.0)
|
29
|
+
faraday-excon (~> 1.1)
|
30
|
+
faraday-httpclient (~> 1.0.1)
|
31
|
+
faraday-net_http (~> 1.0)
|
32
|
+
faraday-net_http_persistent (~> 1.1)
|
33
|
+
faraday-patron (~> 1.0)
|
34
|
+
multipart-post (>= 1.2, < 3)
|
35
|
+
ruby2_keywords (>= 0.0.4)
|
36
|
+
faraday-em_http (1.0.0)
|
37
|
+
faraday-em_synchrony (1.0.0)
|
38
|
+
faraday-excon (1.1.0)
|
39
|
+
faraday-http-cache (2.2.0)
|
40
|
+
faraday (>= 0.8)
|
41
|
+
faraday-httpclient (1.0.1)
|
42
|
+
faraday-net_http (1.0.1)
|
43
|
+
faraday-net_http_persistent (1.2.0)
|
44
|
+
faraday-patron (1.0.0)
|
45
|
+
faraday_middleware (1.0.0)
|
46
|
+
faraday (~> 1.0)
|
47
|
+
hashdiff (1.0.1)
|
48
|
+
i18n (1.8.10)
|
49
|
+
concurrent-ruby (~> 1.0)
|
50
|
+
kramdown (2.3.1)
|
51
|
+
rexml
|
52
|
+
kramdown-parser-gfm (1.1.0)
|
53
|
+
kramdown (~> 2.0)
|
54
|
+
minitest (5.14.4)
|
55
|
+
multipart-post (2.1.1)
|
56
|
+
parallel (1.20.1)
|
57
|
+
parser (3.0.2.0)
|
58
|
+
ast (~> 2.4.1)
|
59
|
+
public_suffix (4.0.6)
|
60
|
+
rainbow (3.0.0)
|
61
|
+
rake (13.0.6)
|
62
|
+
regexp_parser (2.1.1)
|
63
|
+
rexml (3.2.5)
|
64
|
+
rouge (3.26.0)
|
65
|
+
rspec (3.10.0)
|
66
|
+
rspec-core (~> 3.10.0)
|
67
|
+
rspec-expectations (~> 3.10.0)
|
68
|
+
rspec-mocks (~> 3.10.0)
|
69
|
+
rspec-core (3.10.1)
|
70
|
+
rspec-support (~> 3.10.0)
|
71
|
+
rspec-expectations (3.10.1)
|
72
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
73
|
+
rspec-support (~> 3.10.0)
|
74
|
+
rspec-mocks (3.10.2)
|
75
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
76
|
+
rspec-support (~> 3.10.0)
|
77
|
+
rspec-support (3.10.2)
|
78
|
+
rubocop (1.18.3)
|
79
|
+
parallel (~> 1.10)
|
80
|
+
parser (>= 3.0.0.0)
|
81
|
+
rainbow (>= 2.2.2, < 4.0)
|
82
|
+
regexp_parser (>= 1.8, < 3.0)
|
83
|
+
rexml
|
84
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
85
|
+
ruby-progressbar (~> 1.7)
|
86
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
87
|
+
rubocop-ast (1.8.0)
|
88
|
+
parser (>= 3.0.1.1)
|
89
|
+
rubocop-performance (1.11.4)
|
90
|
+
rubocop (>= 1.7.0, < 2.0)
|
91
|
+
rubocop-ast (>= 0.4.0)
|
92
|
+
rubocop-rake (0.6.0)
|
93
|
+
rubocop (~> 1.0)
|
94
|
+
rubocop-rspec (2.4.0)
|
95
|
+
rubocop (~> 1.0)
|
96
|
+
rubocop-ast (>= 1.1.0)
|
97
|
+
ruby-progressbar (1.11.0)
|
98
|
+
ruby2_keywords (0.0.5)
|
99
|
+
simplecov (0.21.2)
|
100
|
+
docile (~> 1.1)
|
101
|
+
simplecov-html (~> 0.11)
|
102
|
+
simplecov_json_formatter (~> 0.1)
|
103
|
+
simplecov-html (0.12.3)
|
104
|
+
simplecov_json_formatter (0.1.3)
|
105
|
+
tzinfo (2.0.4)
|
106
|
+
concurrent-ruby (~> 1.0)
|
107
|
+
unicode-display_width (2.0.0)
|
108
|
+
vcr (6.0.0)
|
109
|
+
webmock (3.13.0)
|
110
|
+
addressable (>= 2.3.6)
|
111
|
+
crack (>= 0.3.2)
|
112
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
113
|
+
yard (0.9.26)
|
114
|
+
zeitwerk (2.4.2)
|
115
|
+
|
116
|
+
PLATFORMS
|
117
|
+
arm64-darwin-20
|
118
|
+
x86_64-linux
|
119
|
+
|
120
|
+
DEPENDENCIES
|
121
|
+
activesupport (~> 6.1)
|
122
|
+
esi-sdk!
|
123
|
+
kramdown-parser-gfm (~> 1.1)
|
124
|
+
rake (~> 13.0)
|
125
|
+
rouge (~> 3.26)
|
126
|
+
rspec (~> 3.10)
|
127
|
+
rubocop (~> 1.18)
|
128
|
+
rubocop-performance (~> 1.11)
|
129
|
+
rubocop-rake (~> 0.6)
|
130
|
+
rubocop-rspec (~> 2.4)
|
131
|
+
simplecov (~> 0.21)
|
132
|
+
simplecov_json_formatter (~> 0.1)
|
133
|
+
vcr (~> 6.0)
|
134
|
+
webmock (~> 3.13)
|
135
|
+
yard (~> 0.9)
|
136
|
+
|
137
|
+
RUBY VERSION
|
138
|
+
ruby 3.0.2p107
|
139
|
+
|
140
|
+
BUNDLED WITH
|
141
|
+
2.2.22
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Bokobo Shahni
|
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,87 @@
|
|
1
|
+
# EVE Swagger Interface (ESI) SDK
|
2
|
+
|
3
|
+
ESI SDK is a Ruby API client for the EVE Swagger Interface (ESI), the official API for the [EVE Online](https://eveonline.com) MMORPG.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's `Gemfile`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'esi-sdk'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```shell
|
16
|
+
bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself with:
|
20
|
+
|
21
|
+
```shell
|
22
|
+
gem install esi-sdk
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Create an instance of `ESI::Client` with your own `User-Agent`:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'esi-sdk'
|
31
|
+
|
32
|
+
client = ESI::Client.new(user_agent: 'My ESI Bot/1.0; +(https://example.com)')
|
33
|
+
```
|
34
|
+
|
35
|
+
Call an ESI endpoint:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
response = client.get_character(character_id: 2113024536)
|
39
|
+
|
40
|
+
{
|
41
|
+
"alliance_id" => 99003214,
|
42
|
+
"ancestry_id" => 37,
|
43
|
+
"birthday" => "2017-07-20T16:28:17Z",
|
44
|
+
"bloodline_id" => 13,
|
45
|
+
"corporation_id" => 98169165,
|
46
|
+
"description" => "",
|
47
|
+
"gender" => "male",
|
48
|
+
"name" => "Bokobo Shahni",
|
49
|
+
"race_id" => 4,
|
50
|
+
"security_status" => 0.7826388230000001
|
51
|
+
}
|
52
|
+
```
|
53
|
+
|
54
|
+
See the documentation for [ESI::Client](https://bokoboshahni.github.io/esi-sdk-ruby/ESI/Client.html) for detailed information on each endpoint.
|
55
|
+
|
56
|
+
## Development
|
57
|
+
|
58
|
+
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.
|
59
|
+
|
60
|
+
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).
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
|
64
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bokoboshahni/esi-sdk. 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/bokoboshahni/esi-sdk/blob/master/CODE_OF_CONDUCT.md).
|
65
|
+
|
66
|
+
## Code of Conduct
|
67
|
+
|
68
|
+
Everyone interacting in the ESI SDK's project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bokoboshahni/esi-sdk/blob/master/CODE_OF_CONDUCT.md).
|
69
|
+
|
70
|
+
## License
|
71
|
+
|
72
|
+
Copyright © 2020 Bokobo Shahni <shahni@bokobo.space>
|
73
|
+
|
74
|
+
|
75
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
76
|
+
|
77
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
78
|
+
|
79
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
80
|
+
|
81
|
+
### CCP hf. Developer License Agreement
|
82
|
+
|
83
|
+
This software is developed in accordance with the [CCP hf. Developer License Agreement](https://developers.eveonline.com/resource/license-agreement).
|
84
|
+
|
85
|
+
CCP Tools and Game Data as defined by the CCP hf. Developer License Agreement © is 2014 CCP hf. All rights reserved.
|
86
|
+
|
87
|
+
"EVE", "EVE Online", "CCP", and all related logos and images are trademarks or registered trademarks of CCP hf.
|
data/Rakefile
ADDED
@@ -0,0 +1,349 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "yard"
|
5
|
+
require "yard/rake/yardoc_task"
|
6
|
+
require "rspec/core/rake_task"
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
|
+
|
10
|
+
require "rubocop/rake_task"
|
11
|
+
|
12
|
+
RuboCop::RakeTask.new
|
13
|
+
|
14
|
+
YARD::Rake::YardocTask.new(:doc)
|
15
|
+
|
16
|
+
task default: %i[spec rubocop]
|
17
|
+
|
18
|
+
task :set_version do
|
19
|
+
version_file = File.join(File.dirname(__FILE__), "lib/esi/version.rb")
|
20
|
+
version_content = File.read(version_file)
|
21
|
+
new_version = ENV["VERSION"]
|
22
|
+
new_content = version_content.gsub(/VERSION = ".+"/m, "VERSION = \"#{new_version}\"")
|
23
|
+
File.write("lib/esi/version.rb", new_content)
|
24
|
+
end
|
25
|
+
|
26
|
+
task :generate do
|
27
|
+
require "active_support/core_ext/string/inflections"
|
28
|
+
require "json"
|
29
|
+
require "open-uri"
|
30
|
+
|
31
|
+
swagger = JSON.parse(URI.open("https://esi.evetech.net/latest/swagger.json").read)
|
32
|
+
|
33
|
+
paths = swagger["paths"]
|
34
|
+
all_operations = paths.each_with_object({}) do |(path, operations), h|
|
35
|
+
operations.each do |(http_method, operation)|
|
36
|
+
description = operation["description"].split("\n").first.strip
|
37
|
+
|
38
|
+
method_name_parts = path.split("/").map { |p| p.gsub(/[{}]/, "") }.map { |p| p.gsub(/_id/, "") }
|
39
|
+
operation_name = operation["operationId"]
|
40
|
+
method_name_parts.map! do |p|
|
41
|
+
if [(method_name_parts[method_name_parts.index(p) + 1]).to_s,
|
42
|
+
"#{method_name_parts[method_name_parts.index(p) + 1]}s", ""].include?(p)
|
43
|
+
nil
|
44
|
+
else
|
45
|
+
p
|
46
|
+
end
|
47
|
+
end
|
48
|
+
method_name_parts.map! do |p|
|
49
|
+
next unless p
|
50
|
+
|
51
|
+
next_part = method_name_parts[method_name_parts.index(p) + 1]
|
52
|
+
if !next_part || (next_part && next_part.singularize == next_part)
|
53
|
+
p
|
54
|
+
else
|
55
|
+
p.singularize
|
56
|
+
end
|
57
|
+
end
|
58
|
+
method_name = "#{http_method}_#{method_name_parts.compact.join("_")}"
|
59
|
+
|
60
|
+
path_params = operation["parameters"].select { |p| p["in"] == "path" || p["$ref"] }
|
61
|
+
path_params.map! do |param|
|
62
|
+
if param["$ref"]
|
63
|
+
ref_name = param["$ref"].match(%r{#/parameters/(alliance_id|corporation_id|character_id)})
|
64
|
+
ref_name = ref_name[1] if ref_name
|
65
|
+
|
66
|
+
next unless ref_name
|
67
|
+
|
68
|
+
swagger["parameters"][ref_name]
|
69
|
+
else
|
70
|
+
param
|
71
|
+
end
|
72
|
+
end
|
73
|
+
path_params.compact!.sort_by! { |p| p["name"] }
|
74
|
+
|
75
|
+
body_param = operation["parameters"].select { |p| p["in"] == "body" }.first
|
76
|
+
|
77
|
+
tag = operation["tags"].first || "Untagged"
|
78
|
+
operation[tag]
|
79
|
+
|
80
|
+
scopes = (operation["security"].first["evesso"] if operation["security"].present?)
|
81
|
+
|
82
|
+
cache = operation["x-cached-seconds"]
|
83
|
+
errors = operation["responses"].reject { |(k, _)| %w[200 201 204 304].include?(k) }
|
84
|
+
versions = operation["x-alternate-versions"]
|
85
|
+
|
86
|
+
query = operation["parameters"].select { |p| p["in"] == "query" }
|
87
|
+
|
88
|
+
h[method_name] =
|
89
|
+
{ params: path_params, method: http_method, description: description, tag: tag, path: path,
|
90
|
+
name: operation_name, body: body_param, scopes: scopes, cache: cache, versions: versions, errors: errors,
|
91
|
+
responses: operation["responses"], query: query }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
method_aliases = {
|
96
|
+
"get_killmail_killmail_hash" => "get_killmail",
|
97
|
+
"get_markets_groups_market_group" => "get_market_group",
|
98
|
+
"get_markets_groups" => "get_market_groups",
|
99
|
+
"get_character_corporationhistory" => "get_character_corporation_history",
|
100
|
+
"get_corporation_alliancehistory" => "get_corporation_alliance_history"
|
101
|
+
}
|
102
|
+
|
103
|
+
error_mapping = {
|
104
|
+
400 => "ESI::Errors::BadRequestError",
|
105
|
+
401 => "ESI::Errors::UnauthorizedError",
|
106
|
+
403 => "ESI::Errors::ForbiddenError",
|
107
|
+
404 => "ESI::Errors::NotFoundError",
|
108
|
+
420 => "ESI::Errors::ErrorLimitedError",
|
109
|
+
422 => "ESI::Errors::UnprocessableEntityError",
|
110
|
+
500 => "ESI::Errors::InternalServerError",
|
111
|
+
503 => "ESI::Errors::ServiceUnavailableError",
|
112
|
+
504 => "ESI::Errors::GatewayTimeoutError",
|
113
|
+
520 => "ESI::Errors::EveServerError"
|
114
|
+
}.freeze
|
115
|
+
|
116
|
+
requires = []
|
117
|
+
includes = []
|
118
|
+
all_operations.group_by { |(_, v)| v[:tag] }.each do |(tag, operations)|
|
119
|
+
lib_filename = "#{tag.gsub(/ /, "_").underscore}.rb"
|
120
|
+
module_name = tag.gsub(/ /, "_").classify
|
121
|
+
method_definitions = operations.sort_by { |(k, _v)| k }.each_with_object([]) do |(method_name, operation), a|
|
122
|
+
signature_params = operation[:params].map { |p| "#{p["name"]}:" }
|
123
|
+
|
124
|
+
description = "# #{operation[:description]}"
|
125
|
+
description = "#{description}." unless description.end_with?(".")
|
126
|
+
description += "\n"
|
127
|
+
|
128
|
+
description += "#\n\n# This endpoint is cached for up to #{operation[:cache]} seconds.\n" if operation[:cache]
|
129
|
+
|
130
|
+
if operation[:scopes]
|
131
|
+
description += "#\n"
|
132
|
+
description += "# This endpoint requires authorization (see {ESI::Client#authorize}).\n#\n"
|
133
|
+
scope_tags = operation[:scopes].map { |s| "# @esi_scope #{s}" }
|
134
|
+
description += scope_tags.join("\n")
|
135
|
+
description += "\n"
|
136
|
+
end
|
137
|
+
|
138
|
+
if operation[:versions]
|
139
|
+
description += "#\n"
|
140
|
+
description += operation[:versions].map { |v| "# @esi_version #{v}" }.join("\n")
|
141
|
+
description += "\n"
|
142
|
+
end
|
143
|
+
|
144
|
+
param_tags = operation[:params].map do |p|
|
145
|
+
"# @param #{p["name"]} [Integer,String] #{p["description"]}"
|
146
|
+
end
|
147
|
+
|
148
|
+
if operation[:body]
|
149
|
+
body_param = operation[:body]
|
150
|
+
body_name = body_param["name"]
|
151
|
+
body_type =
|
152
|
+
case body_param["schema"]["type"]
|
153
|
+
when "array"
|
154
|
+
"Array"
|
155
|
+
when "object"
|
156
|
+
"Hash"
|
157
|
+
end
|
158
|
+
|
159
|
+
signature_params << "#{body_name}:"
|
160
|
+
param_tags += ["# @param #{body_name} [#{body_type}] #{body_param["description"]}"]
|
161
|
+
end
|
162
|
+
|
163
|
+
operation[:query]&.each do |p|
|
164
|
+
signature_params << "#{p["name"]}:"
|
165
|
+
param_tags << "# @param #{p["name"]} [#{p["type"].capitalize}] #{p["description"]}"
|
166
|
+
end
|
167
|
+
|
168
|
+
if %w[delete get].include?(operation[:method])
|
169
|
+
signature_params << "params: {}"
|
170
|
+
param_tags << "# @param params [Hash] Additional query string parameters"
|
171
|
+
end
|
172
|
+
|
173
|
+
param_tags += [
|
174
|
+
"# @param headers [Hash] Additional headers"
|
175
|
+
]
|
176
|
+
description += "#\n"
|
177
|
+
description += param_tags.join("\n")
|
178
|
+
description += "\n"
|
179
|
+
|
180
|
+
description += "#\n"
|
181
|
+
raise_tags = operation[:errors].map do |(e, v)|
|
182
|
+
"# @raise [#{error_mapping[e.to_i]}] #{v["description"]}"
|
183
|
+
end
|
184
|
+
description += raise_tags.join("\n")
|
185
|
+
description += "\n"
|
186
|
+
|
187
|
+
description += "#\n"
|
188
|
+
description += "# @see https://esi.evetech.net/ui/#/#{operation[:tag]}/#{operation[:name]}"
|
189
|
+
description.gsub!(/^$\n/m, "")
|
190
|
+
|
191
|
+
signature_params += %w[headers].map do |p|
|
192
|
+
"#{p}: {}"
|
193
|
+
end
|
194
|
+
signature = "(#{signature_params.join(", ")})"
|
195
|
+
path_parts = operation[:path].split("/")
|
196
|
+
path_parts.map! do |p|
|
197
|
+
if p =~ /\{\w+\}/
|
198
|
+
"##{p}"
|
199
|
+
else
|
200
|
+
p
|
201
|
+
end
|
202
|
+
end
|
203
|
+
path = "#{path_parts.join("/")}/"
|
204
|
+
|
205
|
+
http_call_params = %w[headers].map { |p| "#{p}: #{p}" }
|
206
|
+
http_call_params << if %w[delete get].include?(operation[:method])
|
207
|
+
"params: params"
|
208
|
+
elsif operation[:body]
|
209
|
+
"payload: #{body_param["name"]}"
|
210
|
+
end
|
211
|
+
|
212
|
+
if operation[:query].any?
|
213
|
+
http_call = "query_string = URI.encode_www_form([#{operation[:query].map { |q| "['#{q["name"]}', #{q["name"]}]" }.join(", ")}])\n"
|
214
|
+
http_call += "#{operation[:method]}(\"#{path}?\#{query_string}\", #{http_call_params.join(", ")})"
|
215
|
+
else
|
216
|
+
http_call = "#{operation[:method]}(\"#{path}\", #{http_call_params.join(", ")})"
|
217
|
+
end
|
218
|
+
|
219
|
+
alias_methods = if method_aliases[method_name]
|
220
|
+
Array(method_aliases[method_name]).sort.map do |alias_name|
|
221
|
+
["alias_method :#{alias_name}, :#{method_name}"]
|
222
|
+
end
|
223
|
+
else
|
224
|
+
[]
|
225
|
+
end
|
226
|
+
alias_methods << "alias_method :#{operation[:name]}, :#{method_name}" unless operation[:name] == method_name
|
227
|
+
alias_methods = alias_methods.join("\n")
|
228
|
+
|
229
|
+
a << <<~METHOD_DEFINITION
|
230
|
+
#{description}
|
231
|
+
def #{method_name}#{signature}
|
232
|
+
#{http_call}
|
233
|
+
end
|
234
|
+
#{alias_methods}
|
235
|
+
METHOD_DEFINITION
|
236
|
+
end
|
237
|
+
|
238
|
+
lib_content = <<~MODULE_DEFINITION
|
239
|
+
# frozen_string_literal: true
|
240
|
+
|
241
|
+
module ESI
|
242
|
+
class Client
|
243
|
+
# ESI #{tag.downcase} operations.
|
244
|
+
module #{module_name}
|
245
|
+
#{method_definitions.join("\n\n")}
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
MODULE_DEFINITION
|
250
|
+
|
251
|
+
File.write(File.join("lib/esi/client/#{lib_filename}"), lib_content)
|
252
|
+
|
253
|
+
spec_filename = "#{tag.gsub(/ /, "_").underscore}_spec.rb"
|
254
|
+
spec_path = File.join("spec/lib/esi/client/#{spec_filename}")
|
255
|
+
|
256
|
+
describe_blocks = operations.sort_by { |(k, _v)| k }.each_with_object([]) do |(method_name, operation), a|
|
257
|
+
success_path = operation[:path].gsub(/\{\w+\}/, "1234567890")
|
258
|
+
success_response = operation[:responses].find { |(k, _)| k.start_with?("20") }
|
259
|
+
success_code = success_response.first
|
260
|
+
success_desc = success_response.last
|
261
|
+
|
262
|
+
success_response_body = case success_code
|
263
|
+
when "204"
|
264
|
+
"nil"
|
265
|
+
else
|
266
|
+
success_desc["examples"]["application/json"].inspect
|
267
|
+
end
|
268
|
+
|
269
|
+
success_params = operation[:params].map { |p| "#{p["name"]}: \"1234567890\"" }
|
270
|
+
success_params += operation[:query].map { |p| "#{p["name"]}: \"1234567890\"" }
|
271
|
+
|
272
|
+
if operation[:query].any?
|
273
|
+
query = URI.encode_www_form(operation[:query].map { |q| [q["name"], "1234567890"] })
|
274
|
+
success_path = "#{success_path}?#{query}"
|
275
|
+
end
|
276
|
+
|
277
|
+
if operation[:body]
|
278
|
+
body_param = operation[:body]
|
279
|
+
body_name = body_param["name"]
|
280
|
+
body_value =
|
281
|
+
case body_param["schema"]["type"]
|
282
|
+
when "array"
|
283
|
+
"[1, 2, 3]"
|
284
|
+
when "object"
|
285
|
+
'{ "foo" => "bar" }'
|
286
|
+
end
|
287
|
+
success_params << "#{body_name}: #{body_value}"
|
288
|
+
end
|
289
|
+
|
290
|
+
describe = " describe \"##{method_name}\" do\n"
|
291
|
+
describe += " context \"when the response is #{success_code}\" do\n"
|
292
|
+
describe += " let(:response) { #{success_response_body} }\n"
|
293
|
+
describe += "\n"
|
294
|
+
describe += " before do\n"
|
295
|
+
describe += " stub_request(:#{operation[:method]}, \"https://esi.evetech.net/latest#{success_path}\").to_return(body: response.to_json)\n"
|
296
|
+
describe += " end\n"
|
297
|
+
describe += "\n"
|
298
|
+
describe += " it \"returns the response\" do\n"
|
299
|
+
describe += " expect(client.#{method_name}(#{success_params.join(", ")})).to eq(response)\n"
|
300
|
+
describe += " end\n"
|
301
|
+
describe += " end\n"
|
302
|
+
|
303
|
+
describe += "\n"
|
304
|
+
|
305
|
+
error_contexts = operation[:errors].map do |(code, error)|
|
306
|
+
error_response_body = error["examples"]["application/json"].inspect
|
307
|
+
|
308
|
+
context = " context \"when the response is #{code}\" do\n"
|
309
|
+
context += " let(:response) { #{error_response_body} }\n"
|
310
|
+
context += "\n"
|
311
|
+
context += " before do\n"
|
312
|
+
context += " stub_request(:#{operation[:method]}, \"https://esi.evetech.net/latest#{success_path}\").to_return(body: response.to_json, status: #{code})\n"
|
313
|
+
context += " end\n"
|
314
|
+
context += "\n"
|
315
|
+
context += " it \"raises a #{error_mapping[code.to_i]} error\" do\n"
|
316
|
+
context += " expect { client.#{method_name}(#{success_params.join(", ")}) }.to raise_error(#{error_mapping[code.to_i]})\n"
|
317
|
+
context += " end\n"
|
318
|
+
"#{context} end\n"
|
319
|
+
end
|
320
|
+
|
321
|
+
describe += error_contexts.join("\n")
|
322
|
+
|
323
|
+
describe += " end"
|
324
|
+
a << describe
|
325
|
+
end
|
326
|
+
|
327
|
+
spec_content = <<~SPEC_FILE
|
328
|
+
# frozen_string_literal: true
|
329
|
+
|
330
|
+
RSpec.describe ESI::Client::#{module_name} do
|
331
|
+
subject(:client) { ESI::Client.new(user_agent: \"ESI SDK Tests/1.0; +(https://github.com/bokoboshahni/esi-sdk)\") }
|
332
|
+
|
333
|
+
#{describe_blocks.join("\n\n")}
|
334
|
+
end
|
335
|
+
SPEC_FILE
|
336
|
+
|
337
|
+
File.write(spec_path, spec_content)
|
338
|
+
|
339
|
+
requires << "require_relative \"./client/#{lib_filename.gsub(/\.rb/, "")}\""
|
340
|
+
includes << "include ESI::Client::#{module_name}"
|
341
|
+
end
|
342
|
+
|
343
|
+
at_exit do
|
344
|
+
puts requires
|
345
|
+
puts includes
|
346
|
+
end
|
347
|
+
|
348
|
+
Rake::Task["rubocop:auto_correct"].invoke
|
349
|
+
end
|
data/SECURITY.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
5
|
+
We release patches for security vulnerabilities against the following versions of ESI SDK:
|
6
|
+
|
7
|
+
| Version | Supported |
|
8
|
+
| ------- | ------------------ |
|
9
|
+
| 1.0.x | :white_check_mark: |
|
10
|
+
|
11
|
+
## Reporting a Vulnerability
|
12
|
+
|
13
|
+
Please report (suspected) security vulnerabilities to [shahni@bokobo.space](mailto:security@bokobo.space). You will receive a response from us within 48 hours. If the issue is confirmed, we will release a patch as soon as possible depending on complexity but historically within a few days.
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "esi/sdk"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/esi-sdk.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./lib/esi/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "esi-sdk"
|
7
|
+
spec.version = ESI::VERSION
|
8
|
+
spec.authors = ["Bokobo Shahni"]
|
9
|
+
spec.email = ["shahni@bokobo.space"]
|
10
|
+
|
11
|
+
spec.summary = "API client for the EVE Swagger Interface (ESI)"
|
12
|
+
spec.description = "ESI SDK is a Ruby API client for the EVE Swagger Interface (ESI), "\
|
13
|
+
"the official API for the EVE Online MMORPG."
|
14
|
+
spec.homepage = "https://github.com/bokoboshahni/esi-sdk"
|
15
|
+
spec.license = "MIT"
|
16
|
+
spec.required_ruby_version = ">= 3.0.0"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/bokoboshahni/esi-sdk"
|
20
|
+
spec.metadata["changelog_uri"] = "https://github.com/bokoboshahni/blob/main/CHANGELOG.md"
|
21
|
+
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_dependency "faraday", "~> 1.5"
|
30
|
+
spec.add_dependency "faraday-http-cache", "~> 2.2"
|
31
|
+
spec.add_dependency "faraday_middleware", "~> 1.0"
|
32
|
+
end
|
data/exe/esi-sdk
ADDED