ivapi 0.0.5

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ivapi.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Justas Palumickas
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Ivapi
2
+
3
+ Gem which helps to communicate with iv.lt API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ivapi'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ivapi
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ require 'ivapi'
23
+
24
+ API_NAME = "your_account_name" #You must to set it on https://klientams.iv.lt/users.php with description "API".
25
+ API_PASSWORD = "your_account_password"
26
+
27
+ account = Ivapi::Account.new(API_NAME, API_PASSWORD)
28
+
29
+ puts "Account name: #{account.info['ac_name']}"
30
+ puts "Account created: #{account.info['ac_created']}"
31
+
32
+ account.services.each do |order|
33
+ puts "Id: #{order['se_id']} Description: #{order['se_description']}"
34
+ end
35
+
36
+ server = Ivapi::Server.new(API_NAME, API_PASSWORD).id(123) # Where is id, there is your service id.
37
+ server.tasks.each do |task| # can be: server.tasks(:count => 15) (Max: 1000)
38
+ puts "Id: #{task['ta_id']} Command: #{task['ta_command']}"
39
+ end
40
+ ```
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/ivapi.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ivapi/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "ivapi"
8
+ gem.version = Ivapi::VERSION
9
+ gem.authors = ["Justas Palumickas"]
10
+ gem.email = ["justas@elish.lt"]
11
+ gem.description = %q{ Gem which helps to communicate with iv.lt API }
12
+ gem.summary = %q{ Gem which helps to communicate with iv.lt API }
13
+ gem.homepage = "https://github.com/jpalumickas/ivapi/"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'httparty', '~> 0.9.0'
21
+ end
@@ -0,0 +1,32 @@
1
+ require "ivapi/base"
2
+
3
+ module Ivapi
4
+ class Account < Base
5
+
6
+ def info
7
+ options = { :command => 'account_info' }
8
+ self.class.get(self.file, :query => options.merge!(@auth))
9
+ end
10
+
11
+ def orders
12
+ options = { :command => 'account_orders' }
13
+ self.class.get(self.file, :query => options.merge!(@auth))
14
+ end
15
+
16
+ def services
17
+ options = { :command => 'account_services' }
18
+ self.class.get(self.file, :query => options.merge!(@auth))
19
+ end
20
+
21
+ def credits(o = { :count => 10 })
22
+ options = { :command => 'account_credits' }.merge!(o)
23
+ self.class.get(self.file, :query => options.merge!(@auth))
24
+ end
25
+
26
+ def bonuses(o = { :count => 10 })
27
+ options = { :command => 'account_bonuses' }.merge!(o)
28
+ self.class.get(self.file, :query => options.merge!(@auth))
29
+ end
30
+
31
+ end
32
+ end
data/lib/ivapi/base.rb ADDED
@@ -0,0 +1,23 @@
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(u, p)
13
+ @auth = {:nick => u, :password => p }
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
@@ -0,0 +1,59 @@
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
@@ -0,0 +1,3 @@
1
+ module Ivapi
2
+ VERSION = '0.0.5'
3
+ end
data/lib/ivapi.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "ivapi/version"
2
+ require "httparty"
3
+
4
+ module Ivapi
5
+ autoload :Account, 'ivapi/account'
6
+ autoload :Server, 'ivapi/server'
7
+ end
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ivapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Justas Palumickas
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.0
30
+ description: ! ' Gem which helps to communicate with iv.lt API '
31
+ email:
32
+ - justas@elish.lt
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - .rspec
39
+ - Gemfile
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - ivapi.gemspec
44
+ - lib/ivapi.rb
45
+ - lib/ivapi/account.rb
46
+ - lib/ivapi/base.rb
47
+ - lib/ivapi/server.rb
48
+ - lib/ivapi/version.rb
49
+ - spec/spec_helper.rb
50
+ homepage: https://github.com/jpalumickas/ivapi/
51
+ licenses: []
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 1.8.24
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Gem which helps to communicate with iv.lt API
74
+ test_files:
75
+ - spec/spec_helper.rb