ivapi 0.0.6 → 1.0.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 +7 -0
- data/.gitignore +1 -0
- data/.rspec +2 -1
- data/.travis.yml +7 -0
- data/CONTRIBUTING.md +38 -0
- data/Gemfile +11 -1
- data/Guardfile +13 -0
- data/{LICENSE.txt → LICENSE.md} +0 -0
- data/README.md +28 -26
- data/Rakefile +8 -1
- data/ivapi.gemspec +20 -13
- data/lib/faraday/response/raise_ivapi_error.rb +24 -0
- data/lib/ivapi.rb +6 -30
- data/lib/ivapi/authentication.rb +15 -0
- data/lib/ivapi/client.rb +27 -0
- data/lib/ivapi/client/account.rb +30 -0
- data/lib/ivapi/client/server.rb +92 -0
- data/lib/ivapi/configuration.rb +43 -0
- data/lib/ivapi/connection.rb +29 -0
- data/lib/ivapi/error.rb +35 -0
- data/lib/ivapi/request.rb +22 -0
- data/lib/ivapi/version.rb +1 -1
- data/spec/fixtures/account_bonuses.json +20 -0
- data/spec/fixtures/account_info.json +42 -0
- data/spec/fixtures/account_orders.json +29 -0
- data/spec/fixtures/account_services.json +35 -0
- data/spec/fixtures/server_change.json +3 -0
- data/spec/fixtures/server_domain.json +3 -0
- data/spec/fixtures/server_graphs.json +26 -0
- data/spec/fixtures/server_info.json +30 -0
- data/spec/fixtures/server_os.json +132 -0
- data/spec/fixtures/server_reboot.json +3 -0
- data/spec/fixtures/server_recreate.json +3 -0
- data/spec/fixtures/server_reset_password.json +3 -0
- data/spec/fixtures/server_tasks.json +14 -0
- data/spec/fixtures/version.json +3 -0
- data/spec/ivapi/client/account_spec.rb +34 -0
- data/spec/ivapi/client/server_spec.rb +58 -0
- data/spec/ivapi/client_spec.rb +13 -0
- data/spec/spec_helper.rb +64 -15
- metadata +130 -21
- data/lib/ivapi/account.rb +0 -32
- data/lib/ivapi/base.rb +0 -23
- data/lib/ivapi/railtie.rb +0 -26
- data/lib/ivapi/server.rb +0 -59
data/lib/ivapi/base.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require 'ivapi/account'
|
|
2
|
-
|
|
3
|
-
module Ivapi
|
|
4
|
-
class Base
|
|
5
|
-
|
|
6
|
-
include HTTParty
|
|
7
|
-
base_uri 'https://api.iv.lt'
|
|
8
|
-
format :json
|
|
9
|
-
|
|
10
|
-
attr_reader :auth, :file
|
|
11
|
-
|
|
12
|
-
def initialize
|
|
13
|
-
@auth = {:nick => Ivapi.config['username'], :password => Ivapi.config['password'] }
|
|
14
|
-
@file = '/json.php'
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def version
|
|
18
|
-
options = { :command => 'version' }
|
|
19
|
-
self.class.get(self.file, :query => options.merge!(@auth))['version']
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end
|
|
23
|
-
end
|
data/lib/ivapi/railtie.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
require "ivapi"
|
|
2
|
-
require "rails"
|
|
3
|
-
require "active_model/railtie"
|
|
4
|
-
|
|
5
|
-
module Ivapi
|
|
6
|
-
class Railtie < Rails::Railtie
|
|
7
|
-
|
|
8
|
-
config.ivapi = ActiveSupport::OrderedOptions.new
|
|
9
|
-
|
|
10
|
-
initializer "ivapi.set_configs" do |app|
|
|
11
|
-
ActiveSupport.on_load(:ivapi) do
|
|
12
|
-
app.config.ivapi.each do |k,v|
|
|
13
|
-
send "#{k}=", v
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
initializer "ivapi.initialize_database" do |app|
|
|
19
|
-
config_file = Rails.root.join('config/ivapi.yml')
|
|
20
|
-
if config_file.file?
|
|
21
|
-
config = YAML.load(ERB.new(config_file.read).result)
|
|
22
|
-
Ivapi.setup(config)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
data/lib/ivapi/server.rb
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
require "ivapi/base"
|
|
2
|
-
|
|
3
|
-
module Ivapi
|
|
4
|
-
class Server < Base
|
|
5
|
-
|
|
6
|
-
attr_reader :server_id
|
|
7
|
-
|
|
8
|
-
def id(i)
|
|
9
|
-
@server_id = i
|
|
10
|
-
self
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def info
|
|
14
|
-
options = { :command => 'server_info' , :id => self.server_id }
|
|
15
|
-
self.class.get(self.file, :query => options.merge!(@auth))
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def tasks(o={})
|
|
19
|
-
options = { :command => 'server_tasks' , :id => self.server_id, :count => 10 }.merge!(o)
|
|
20
|
-
self.class.get(self.file, :query => options.merge!(@auth))
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def graphs(o={})
|
|
24
|
-
options = { :command => 'server_graphs' , :id => self.server_id }.merge!(o)
|
|
25
|
-
self.class.get(self.file, :query => options.merge!(@auth))
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def os
|
|
29
|
-
options = { :command => 'server_os' , :id => self.server_id }
|
|
30
|
-
self.class.get(self.file, :query => options.merge!(@auth))
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def reboot
|
|
34
|
-
options = { :command => 'server_reboot' , :id => self.server_id }
|
|
35
|
-
self.class.get(self.file, :query => options.merge!(@auth))
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def recreate(o={})
|
|
39
|
-
options = { :command => 'server_recreate' , :id => self.server_id }.merge!(o)
|
|
40
|
-
self.class.get(self.file, :query => options.merge!(@auth))
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def reset_password
|
|
44
|
-
options = { :command => 'server_reset_password' , :id => self.server_id }
|
|
45
|
-
self.class.get(self.file, :query => options.merge!(@auth))
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def change(o={})
|
|
49
|
-
options = { :command => 'server_change' , :id => self.server_id }.merge!(o)
|
|
50
|
-
self.class.get(self.file, :query => options.merge!(@auth))
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def domain(o={})
|
|
54
|
-
options = { :command => 'server_domain' , :id => self.server_id }.merge!(o)
|
|
55
|
-
self.class.get(self.file, :query => options.merge!(@auth))
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
end
|
|
59
|
-
end
|