eveapi 0.1.2 → 0.1.3
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 +8 -8
- data/.document +0 -4
- data/.gitignore +2 -0
- data/.yardopts +1 -0
- data/CONTRIBUTING.md +31 -0
- data/README.md +90 -56
- data/Rakefile +5 -41
- data/gemspec.yml +1 -1
- data/lib/eveapi.rb +17 -31
- data/lib/eveapi/alliance.rb +21 -8
- data/lib/eveapi/character.rb +44 -14
- data/lib/eveapi/client.rb +141 -15
- data/lib/eveapi/crest.rb +24 -10
- data/lib/eveapi/request.rb +5 -0
- data/lib/eveapi/util.rb +60 -3
- data/lib/eveapi/version.rb +1 -1
- data/spec/cassettes/EVEApi/EVEApi_Alliance/expect_Alliance_corporations_to_be_an_Array.yml +194 -206
- data/spec/cassettes/EVEApi/EVEApi_Alliance/expect_Alliance_find_to_fill_short_name_and_name_values.yml +25 -31
- data/spec/cassettes/EVEApi/EVEApi_Alliance/expect_Alliance_info_to_be_a_Hash.yml +195 -207
- data/spec/cassettes/EVEApi/EVEApi_Alliance/expect_Alliance_new_with_id_argument_to_create_an_Alliance.yml +18 -18
- data/spec/cassettes/EVEApi/EVEApi_Alliance/expect_Alliance_to_h_to_be_a_Hash.yml +192 -204
- data/spec/cassettes/EVEApi/EVEApi_Character/expect_Character_new_args_to_create_a_Character.yml +28 -28
- data/spec/cassettes/EVEApi/EVEApi_Character/expect_a_Character_account_balance_to_return_a_Hash.yml +32 -32
- data/spec/cassettes/EVEApi/{EVEApi_Client/calling_api_method_account_characters.yml → EVEApi_Character/raises_ArgumentError_on_non-existing_instance_variable.yml} +54 -23
- data/spec/cassettes/EVEApi/{EVEApi_Client/calling_api_method_char_wallet_journal.yml → EVEApi_Character/sets_Client_instance_variable_if_method_argument_key_matches_name.yml} +85 -23
- data/spec/cassettes/EVEApi/EVEApi_Client/{calling_api_method_account_account_status.yml → calling_api_method_account_status.yml} +22 -22
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_api_methods.yml +288 -0
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_call_list.yml +288 -0
- data/spec/cassettes/EVEApi/EVEApi_Client/{calling_api_method_char_notifications.yml → calling_api_method_characters.yml} +58 -24
- data/spec/cassettes/EVEApi/EVEApi_Client/{calling_api_method_account_api_key_info.yml → calling_api_method_key_info.yml} +23 -23
- data/spec/cassettes/EVEApi/EVEApi_Client/{calling_api_method_server_server_status.yml → calling_api_method_server_status.yml} +23 -23
- data/spec/cassettes/EVEApi/EVEApi_Client/expect_Client_characters_to_handle_mutiple_characters_differently.yml +18 -18
- data/spec/cassettes/EVEApi/EVEApi_Client/expect_Client_charcaters_to_succeed.yml +18 -18
- data/spec/cassettes/EVEApi/EVEApi_Client/expect_Client_connection_to_be_an_Excon_Connection.yml +18 -18
- data/spec/cassettes/EVEApi/EVEApi_Client/expect_Client_new_to_succeed.yml +18 -18
- data/spec/cassettes/EVEApi/EVEApi_Client/expect_Client_params_to_return_an_empty_hash_when_on_no_param.yml +18 -18
- data/spec/cassettes/EVEApi/EVEApi_Client/{expect_check_path_to_return_a_non-empty_String_for_a_muti-part_name.yml → expect_Symbol_to_path_to_return_a_String_for_a_muti-part_name.yml} +18 -18
- data/spec/cassettes/EVEApi/EVEApi_Client/{expect_check_path_to_return_an_empty_String_for_a_one_part_name.yml → expect_Symbol_to_path_to_return_an_empty_String_for_a_one_part_name.yml} +18 -18
- data/spec/cassettes/EVEApi/EVEApi_Client/expect_api_methods_to_return_an_Array_of_method_symobls.yml +23 -23
- data/spec/cassettes/EVEApi/EVEApi_Client/expect_calling_a_non-existing_API_method_to_fail.yml +21 -21
- data/spec/cassettes/EVEApi/EVEApi_Client/expect_calling_an_existing_API_method_to_succeed.yml +23 -23
- data/spec/cassettes/EVEApi/EVEApi_Crest/expect_Crest_alliances_to_be_an_Array.yml +192 -204
- data/spec/cassettes/EVEApi/EVEApi_Crest/expect_Crest_new_to_succeed.yml +18 -18
- data/spec/cassettes/EVEApi/EVEApi_Crest/expect_Crest_types_to_be_an_Array.yml +25972 -0
- data/spec/cassettes/EVEApi/EVEApi_Crest/expect_details_to_return_Hash_when_called_on_Hash_with_href_key.yml +26023 -0
- data/spec/cassettes/EVEApi/EVEApi_Request/expect_there_to_be_a_EVEApi_Request_class.yml +18 -18
- data/spec/eve_api_spec.rb +19 -5
- metadata +31 -41
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_account_balance.yml +0 -160
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_asset_list.yml +0 -207
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_character_sheet.yml +0 -207
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_contact_list.yml +0 -175
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_contact_notifications.yml +0 -159
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_contracts.yml +0 -159
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_industry_jobs.yml +0 -159
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_mail_messages.yml +0 -159
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_mailing_lists.yml +0 -159
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_market_orders.yml +0 -159
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_medals.yml +0 -160
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_research.yml +0 -159
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_skill_in_training.yml +0 -159
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_skill_queue.yml +0 -159
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_standings.yml +0 -173
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_upcoming_calendar_events.yml +0 -169
- data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_wallet_transactions.yml +0 -159
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
YjcxM2EzYTRlNzY2ZTY4MmJkZDRiYWUyOTUxMjc5YTRhYmFkNWY5Ng==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
NjZhMWI5ZjYwNjVlNzQzYjkwNDI4YTZiZDJmNjRmYmI0ZmU1NWVlNw==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
MDExYTlhZGE4MGJhYTExZGYyNzYyMDlmYjUzMTgzOWE5MWJlNWVlOTMxNGE2
|
|
10
|
+
YzhiODc2NTRjNDdhYjQxOWU5Y2ZlN2Q5YmMzNTIxZjkwYWM2YWE0NzEyZTZk
|
|
11
|
+
MjY4ZmIyODU1NzhiYmIxMTU5MWU5ZjgyZTVkYzIzYzViYTU1NmM=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
YWM1NjVkNzBhODg2MDQ0ZWYwMWYxYzNkYTE4NzI4MjdkOWM4M2QyMzVmYmM2
|
|
14
|
+
M2JlYjNkOTljYjFiZDA1ZjI0ZmVjMWE3NDIyMjg5ZDNjMWQ0MzU4ZDNmN2Rm
|
|
15
|
+
M2M1MzJhNGE0NzI1OTM0N2Q4NjQzNDY4MWI0NjVkNDg0MWVhNDQ=
|
data/.document
CHANGED
data/.gitignore
CHANGED
data/.yardopts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--output-dir ./doc/yard
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
1. Fork the repo <iframe src="https://ghbtns.com/github-btn.html?user=aladac&repo=eveapi&type=fork&count=true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe>
|
|
2
|
+
2. Create a feature branch with a reasonable name like `add_client_foobar_method`
|
|
3
|
+
|
|
4
|
+
```
|
|
5
|
+
$ git checkout -b add_client_foobar_method
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
3. Push your changes to your repo
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
$ git push
|
|
13
|
+
Counting objects: 7, done.
|
|
14
|
+
Delta compression using up to 4 threads.
|
|
15
|
+
Compressing objects: 100% (2/2), done.
|
|
16
|
+
Writing objects: 100% (3/3), 269 bytes | 0 bytes/s, done.
|
|
17
|
+
Total 3 (delta 1), reused 0 (delta 0)
|
|
18
|
+
To git@github.com:saidenpl/eveapi.git
|
|
19
|
+
* [new branch] add_client_foobar_method -> add_client_foobar_method
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
4. Make a pull request to this repos `master`
|
|
23
|
+
- Click on `Compare & pull request`
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
- Make sure that `aladac/eveapi` and your feature branch are selectedd
|
|
28
|
+
- Write a comment
|
|
29
|
+
- Click `Create pull request`
|
|
30
|
+
|
|
31
|
+

|
data/README.md
CHANGED
|
@@ -10,51 +10,57 @@
|
|
|
10
10
|
[](https://rubygems.org/gems/eveapi)
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
13
|
+
## General
|
|
14
|
+
|
|
15
|
+
Working methods names can be listed by calling `EVEApi::Client#working_methods`.
|
|
16
|
+
|
|
17
|
+
## Working methods
|
|
18
|
+
|
|
19
|
+
Check out [rubydoc.info](http://www.rubydoc.info/github/aladac/eveapi) for the documentation.
|
|
20
|
+
|
|
21
|
+
*Legacy methods are available [here](https://github.com/aladac/eveapi/wiki)*
|
|
22
|
+
|
|
23
|
+
#### Client
|
|
24
|
+
- `EVEApi::Client.new`
|
|
25
|
+
- `EVEApi::Client#characters`
|
|
26
|
+
- `EVEApi::Client#server_status`
|
|
27
|
+
- `EVEApi::Client#call_list`
|
|
28
|
+
- `EVEApi::Client#working_methods`
|
|
29
|
+
- `EVEApi::Client#account_status`
|
|
30
|
+
- `EVEApi::Client#key_info`
|
|
31
|
+
|
|
32
|
+
#### Character
|
|
33
|
+
|
|
34
|
+
- `EVEApi::Character#wallet_journal`
|
|
35
|
+
- `EVEApi::Character#contracts`
|
|
36
|
+
- `EVEApi::Character#wallet_transactions`
|
|
37
|
+
- `EVEApi::Character#upcoming_calendar_events`
|
|
38
|
+
- `EVEApi::Character#standings`
|
|
39
|
+
- `EVEApi::Character#skill_queue`
|
|
40
|
+
- `EVEApi::Character#skill_in_training`
|
|
41
|
+
- `EVEApi::Character#research`
|
|
42
|
+
- `EVEApi::Character#notifications`
|
|
43
|
+
- `EVEApi::Character#medals`
|
|
44
|
+
- `EVEApi::Character#market_orders`
|
|
45
|
+
- `EVEApi::Character#mail_messages`
|
|
46
|
+
- `EVEApi::Character#mailing_lists`
|
|
47
|
+
- `EVEApi::Character#industry_jobs`
|
|
48
|
+
- `EVEApi::Character#contact_notifications`
|
|
49
|
+
- `EVEApi::Character#contact_list`
|
|
50
|
+
- `EVEApi::Character#character_sheet`
|
|
51
|
+
- `EVEApi::Character#asset_list`
|
|
52
|
+
- `EVEApi::Character#account_balance`
|
|
53
|
+
|
|
54
|
+
#### Crest
|
|
55
|
+
- `EVEApi::Crest.new`
|
|
56
|
+
- `EVEApi::Crest#allainces`
|
|
57
|
+
- `EVEApi::Crest#types`
|
|
58
|
+
|
|
59
|
+
#### Alliance
|
|
60
|
+
- `EVEApi::Alliance.find(id = nil)`
|
|
61
|
+
- `EVEApi::Alliance#info`
|
|
62
|
+
- `EVEApi::Alliance#corporations`
|
|
63
|
+
- `EVEApi::Alliance#to_h`
|
|
58
64
|
|
|
59
65
|
## CREST
|
|
60
66
|
Rudimentary CREST support is added via the `EVEApi::Crest` class.
|
|
@@ -110,22 +116,50 @@ Uses [excon](https://github.com/excon/excon), [crack](https://github.com/jnunem
|
|
|
110
116
|
|
|
111
117
|
## Examples
|
|
112
118
|
|
|
119
|
+
### Getting Implant names for character
|
|
120
|
+
```ruby
|
|
121
|
+
require 'eveapi'
|
|
122
|
+
# initialize the client with key_id, vcode, character_id
|
|
123
|
+
client = Client.new(4278167, "supersecretstuff", 95512059)
|
|
124
|
+
# => #<EVEApi::Client:0x007fe349ad0d48 ... >
|
|
125
|
+
client.characters.first.character_sheet[:implants].map { |i| i[:type_name] }
|
|
126
|
+
# => [
|
|
127
|
+
# [0] "Social Adaptation Chip - Basic",
|
|
128
|
+
# [1] "Cybernetic Subprocessor - Standard",
|
|
129
|
+
# [2] "Memory Augmentation - Standard",
|
|
130
|
+
# [3] "Neural Boost - Standard",
|
|
131
|
+
# [4] "Ocular Filter - Standard"
|
|
132
|
+
# ]
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Server status
|
|
136
|
+
```ruby
|
|
137
|
+
require 'eveapi'
|
|
138
|
+
client.server_status
|
|
139
|
+
# => {
|
|
140
|
+
# :server_open => "True",
|
|
141
|
+
# :online_players => "32500"
|
|
142
|
+
# }
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Showing accounts characters
|
|
146
|
+
|
|
113
147
|
```ruby
|
|
114
148
|
require 'eveapi'
|
|
115
149
|
client = EVEApi::Client.new
|
|
116
150
|
client.key_id = 4278167
|
|
117
151
|
client.vcode = "7QJg6p5BZNpDBp2FIz39dGwa7jnNaXAuYyLUVitlTQ3rY60VPBcaTpJVfYIkiW5l"
|
|
118
|
-
client.
|
|
119
|
-
=> {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
152
|
+
client.characters
|
|
153
|
+
# => {
|
|
154
|
+
# :name => "Quint Slade",
|
|
155
|
+
# :character_id => "95512059",
|
|
156
|
+
# :corporation_name => "Imperial Academy",
|
|
157
|
+
# :corporation_id => "1000166",
|
|
158
|
+
# :alliance_id => "0",
|
|
159
|
+
# :alliance_name => "",
|
|
160
|
+
# :faction_id => "0",
|
|
161
|
+
# :faction_name => ""
|
|
162
|
+
# }
|
|
129
163
|
```
|
|
130
164
|
|
|
131
165
|
## Requirements
|
data/Rakefile
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
require 'rubygems'
|
|
4
|
-
|
|
5
2
|
begin
|
|
6
3
|
require 'bundler/setup'
|
|
7
4
|
rescue LoadError => e
|
|
@@ -9,12 +6,12 @@ rescue LoadError => e
|
|
|
9
6
|
end
|
|
10
7
|
|
|
11
8
|
require 'rake'
|
|
12
|
-
|
|
9
|
+
require 'rubygems'
|
|
13
10
|
require 'bundler/gem_tasks'
|
|
14
11
|
|
|
15
|
-
require '
|
|
16
|
-
|
|
17
|
-
task doc: :
|
|
12
|
+
require 'yard'
|
|
13
|
+
YARD::Rake::YardocTask.new
|
|
14
|
+
task doc: :yard
|
|
18
15
|
|
|
19
16
|
require 'rspec/core/rake_task'
|
|
20
17
|
RSpec::Core::RakeTask.new
|
|
@@ -37,39 +34,6 @@ task :console do
|
|
|
37
34
|
Pry.start
|
|
38
35
|
end
|
|
39
36
|
|
|
40
|
-
desc 'Generate method docs'
|
|
41
|
-
task :methods do
|
|
42
|
-
Bundler.require
|
|
43
|
-
require 'awesome_print'
|
|
44
|
-
EVEApi::Client.new.working_methods.each do |m|
|
|
45
|
-
p m
|
|
46
|
-
@client = EVEApi::Client.new
|
|
47
|
-
@client.key_id = 4_278_167
|
|
48
|
-
@client.vcode = 'supersecretstuff'
|
|
49
|
-
@client.character_id = '95512059'
|
|
50
|
-
out = ''
|
|
51
|
-
begin
|
|
52
|
-
out << @client.api_methods_hash.find { |me| me[:name] == m }[:desc]
|
|
53
|
-
rescue
|
|
54
|
-
out << "TODO Description (#{m})"
|
|
55
|
-
end
|
|
56
|
-
out << "\n\n"
|
|
57
|
-
out << "```ruby\n@client = EVEApi::Client.new\n"
|
|
58
|
-
out << "@client.key_id = 4278167\n"
|
|
59
|
-
out << "@client.vcode = 'supersecretstuff'\n\n"
|
|
60
|
-
out << "@client.#{m}\n\n"
|
|
61
|
-
begin
|
|
62
|
-
out << @client.send(m).pretty_inspect
|
|
63
|
-
out << '```'
|
|
64
|
-
f = File.new("./doc/wiki/#{m}.md", 'w')
|
|
65
|
-
f.puts out
|
|
66
|
-
f.close
|
|
67
|
-
rescue => e
|
|
68
|
-
puts e.message
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
37
|
task c: :console
|
|
74
38
|
task test: :spec
|
|
75
|
-
task default: [:spec, :rubocop]
|
|
39
|
+
task default: [:spec, :"rubocop:auto_correct", :rubocop]
|
data/gemspec.yml
CHANGED
data/lib/eveapi.rb
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
lib_dir = File.dirname(__FILE__)
|
|
2
2
|
$LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
|
|
3
3
|
|
|
4
|
+
# EVEApi namespace
|
|
5
|
+
module EVEApi
|
|
6
|
+
# CREST API endpoint
|
|
7
|
+
CREST_ENDPOINT = 'https://public-crest.eveonline.com/'
|
|
8
|
+
# v2 API endpoint
|
|
9
|
+
API_ENDPOINT = 'https://api.eveonline.com'
|
|
10
|
+
# Client methods implemented
|
|
11
|
+
WORKING_METHODS = [
|
|
12
|
+
:account_status,
|
|
13
|
+
:server_status,
|
|
14
|
+
:characters,
|
|
15
|
+
:api_methods,
|
|
16
|
+
:key_info,
|
|
17
|
+
:call_list
|
|
18
|
+
]
|
|
19
|
+
end
|
|
20
|
+
|
|
4
21
|
require 'eveapi/version'
|
|
5
22
|
require 'eveapi/client'
|
|
6
23
|
require 'eveapi/request'
|
|
@@ -12,34 +29,3 @@ require 'excon'
|
|
|
12
29
|
require 'crack'
|
|
13
30
|
|
|
14
31
|
include EVEApi::Util
|
|
15
|
-
|
|
16
|
-
# EVEApi namespace
|
|
17
|
-
module EVEApi
|
|
18
|
-
CREST_ENDPOINT = 'https://public-crest.eveonline.com/'
|
|
19
|
-
API_ENDPOINT = 'https://api.eveonline.com'
|
|
20
|
-
WORKING_METHODS = [
|
|
21
|
-
:account_api_key_info,
|
|
22
|
-
:account_account_status,
|
|
23
|
-
:account_characters,
|
|
24
|
-
:server_server_status,
|
|
25
|
-
:char_contracts,
|
|
26
|
-
:char_wallet_transactions,
|
|
27
|
-
:char_wallet_journal,
|
|
28
|
-
:char_upcoming_calendar_events,
|
|
29
|
-
:char_standings,
|
|
30
|
-
:char_skill_queue,
|
|
31
|
-
:char_skill_in_training,
|
|
32
|
-
:char_research,
|
|
33
|
-
:char_notifications,
|
|
34
|
-
:char_medals,
|
|
35
|
-
:char_market_orders,
|
|
36
|
-
:char_mail_messages,
|
|
37
|
-
:char_mailing_lists,
|
|
38
|
-
:char_industry_jobs,
|
|
39
|
-
:char_contact_notifications,
|
|
40
|
-
:char_contact_list,
|
|
41
|
-
:char_character_sheet,
|
|
42
|
-
:char_asset_list,
|
|
43
|
-
:char_account_balance
|
|
44
|
-
]
|
|
45
|
-
end
|
data/lib/eveapi/alliance.rb
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
module EVEApi
|
|
2
2
|
# Alliance CREST object
|
|
3
3
|
class Alliance
|
|
4
|
-
|
|
4
|
+
# CREST alliances endpoint
|
|
5
|
+
BASE_URI = CREST_ENDPOINT + 'alliances/'
|
|
5
6
|
|
|
6
|
-
attr_accessor :href
|
|
7
|
-
attr_accessor :id_str
|
|
8
|
-
attr_accessor :short_name
|
|
9
|
-
attr_accessor :name
|
|
10
|
-
attr_accessor :id
|
|
11
|
-
attr_accessor :info
|
|
7
|
+
attr_accessor :href # @return [String] href
|
|
8
|
+
attr_accessor :id_str # @return [String] String ID
|
|
9
|
+
attr_accessor :short_name # @return [String] Short name
|
|
10
|
+
attr_accessor :name # @return [String] Name
|
|
11
|
+
attr_accessor :id # @return [Fixnum] ID
|
|
12
|
+
attr_accessor :info # @return [Hash] Info
|
|
12
13
|
|
|
13
14
|
def initialize(args)
|
|
14
15
|
case args
|
|
@@ -23,20 +24,32 @@ module EVEApi
|
|
|
23
24
|
end
|
|
24
25
|
end
|
|
25
26
|
|
|
27
|
+
# Get detailed Alliance info from CREST
|
|
28
|
+
#
|
|
29
|
+
# @return [Hash] Alliance info
|
|
26
30
|
def info
|
|
27
|
-
@info ||=
|
|
31
|
+
@info ||= json_get(href)
|
|
28
32
|
end
|
|
29
33
|
|
|
34
|
+
# Show corporations belonging to the Alliance
|
|
35
|
+
#
|
|
36
|
+
# @return [Array] List of corporations
|
|
30
37
|
def corporations
|
|
31
38
|
info[:corporations]
|
|
32
39
|
end
|
|
33
40
|
|
|
41
|
+
# Get Alliance from CREST by ID
|
|
42
|
+
#
|
|
43
|
+
# @return [Alliance] Alliance object
|
|
34
44
|
def find
|
|
35
45
|
@short_name = info[:short_name]
|
|
36
46
|
@name = info[:name]
|
|
37
47
|
self
|
|
38
48
|
end
|
|
39
49
|
|
|
50
|
+
# Converts {Alliance} to {Hash}
|
|
51
|
+
#
|
|
52
|
+
# @return [Hash] Alliance in {Hash} format
|
|
40
53
|
def to_h
|
|
41
54
|
h = {}
|
|
42
55
|
instance_variables.each do |var|
|
data/lib/eveapi/character.rb
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
module EVEApi
|
|
2
2
|
# Character class
|
|
3
3
|
class Character
|
|
4
|
-
attr_accessor :name
|
|
5
|
-
attr_accessor :character_id
|
|
6
|
-
attr_accessor :corporation_name
|
|
7
|
-
attr_accessor :corporation_id
|
|
8
|
-
attr_accessor :alliance_id
|
|
9
|
-
attr_accessor :alliance_name
|
|
10
|
-
attr_accessor :faction_id
|
|
11
|
-
attr_accessor :faction_name
|
|
12
|
-
attr_accessor :key_id
|
|
13
|
-
attr_accessor :vcode
|
|
14
|
-
attr_accessor :client
|
|
4
|
+
attr_accessor :name # @return [String] Character name
|
|
5
|
+
attr_accessor :character_id # @return [String] Character ID
|
|
6
|
+
attr_accessor :corporation_name # @return [String] Corporation name
|
|
7
|
+
attr_accessor :corporation_id # @return [String] Corporation ID
|
|
8
|
+
attr_accessor :alliance_id # @return [String] Alliance ID
|
|
9
|
+
attr_accessor :alliance_name # @return [String] Alliance name
|
|
10
|
+
attr_accessor :faction_id # @return [String] Faction ID
|
|
11
|
+
attr_accessor :faction_name # @return [String] Faction name
|
|
12
|
+
attr_accessor :key_id # @return [String] API key ID
|
|
13
|
+
attr_accessor :vcode # @return [String] API key verification code
|
|
14
|
+
attr_accessor :client # @return [Client] {EVEApi::Client} instance
|
|
15
15
|
|
|
16
16
|
def initialize(args = {})
|
|
17
17
|
@key_id = args[:key_id]
|
|
@@ -30,10 +30,11 @@ module EVEApi
|
|
|
30
30
|
@client ||= Client.new(key_id, vcode, character_id)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
# Character methods known to work
|
|
33
34
|
METHODS = [
|
|
35
|
+
:wallet_journal,
|
|
34
36
|
:contracts,
|
|
35
37
|
:wallet_transactions,
|
|
36
|
-
:wallet_journal,
|
|
37
38
|
:upcoming_calendar_events,
|
|
38
39
|
:standings,
|
|
39
40
|
:skill_queue,
|
|
@@ -52,9 +53,38 @@ module EVEApi
|
|
|
52
53
|
:account_balance
|
|
53
54
|
]
|
|
54
55
|
|
|
56
|
+
# Converts the {Character} method name to {Client} method name
|
|
57
|
+
#
|
|
58
|
+
# @param [Symbol] method_name +Character+ method name
|
|
59
|
+
# @return [Symbol] {Client} method name
|
|
60
|
+
def client_method(method_name)
|
|
61
|
+
"char_#{method_name}".to_sym
|
|
62
|
+
end
|
|
63
|
+
private :client_method
|
|
64
|
+
|
|
65
|
+
# Process arguments for Client method
|
|
66
|
+
#
|
|
67
|
+
# @param [Hash] args = {} Client method arguments
|
|
68
|
+
def process_args(args = {})
|
|
69
|
+
args.each_pair do |k, v|
|
|
70
|
+
fail ArgumentError unless client.respond_to?(k)
|
|
71
|
+
client.instance_variable_set("@#{k}".to_sym, v)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
private :process_args
|
|
75
|
+
|
|
76
|
+
# Send a method to a {Client} instance
|
|
77
|
+
#
|
|
78
|
+
# @param [String] method_name Method name
|
|
79
|
+
# @param [Hash] args = {} Method arguments
|
|
80
|
+
def send_client_method(method_name, args = {})
|
|
81
|
+
process_args(args)
|
|
82
|
+
client.send(client_method(method_name))
|
|
83
|
+
end
|
|
84
|
+
private :send_client_method
|
|
85
|
+
|
|
55
86
|
METHODS.each do |m|
|
|
56
|
-
|
|
57
|
-
define_method(m) { client.send(name) }
|
|
87
|
+
define_method(m) { |args = {}| send_client_method(m, args) }
|
|
58
88
|
end
|
|
59
89
|
end
|
|
60
90
|
end
|