wispro 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +35 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/wispro.rb +6 -0
- data/lib/wispro/client.rb +91 -0
- data/lib/wispro/logger.rb +9 -0
- data/lib/wispro/version.rb +3 -0
- data/wispro.gemspec +35 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0cfe52e8488105cb88dc510dede415b54bdebed471825344e3c3edfd6ac26ea7
|
4
|
+
data.tar.gz: 27c23bb4dbfccc99878bc3501cfeac95490f32f4f6778a4b50ef5e73adf514a4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4f381db1b7d09392339045ca3ad9bf2ecb5c3697f8b06921a9846850e2e1c444557fcee635ce16bd5b8dac503ad77b0831558b63fe2a5ebce70a0578cd01860a
|
7
|
+
data.tar.gz: 8617725ffc37fc8cb180dc5e59c900fe0641010f00d9622dd4fa468f4c84af92d3ea9516decd88b1391375254962f0816b28de71d48e6ad55c2971dcf13cbafe
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.5
|
3
|
+
|
4
|
+
Exclude:
|
5
|
+
- 'db/**/*'
|
6
|
+
- 'log/**/*'
|
7
|
+
- 'tmp/**/*'
|
8
|
+
|
9
|
+
Documentation:
|
10
|
+
# Skips checking to make sure top level modules / classes have a comment.
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Style/FrozenStringLiteralComment:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/ClassAndModuleChildren:
|
17
|
+
# Skips checking the style of children definitions at classes and modules.
|
18
|
+
#
|
19
|
+
# Basically there are two different styles:
|
20
|
+
#
|
21
|
+
# `nested` - have each child on a separate line
|
22
|
+
# class Foo
|
23
|
+
# class Bar
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# `compact` - combine definitions as much as possible
|
28
|
+
# class Foo::Bar
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# With it disabled, either or is valid.
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Style/MixinUsage:
|
35
|
+
Enabled: false
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Pablo Gutiérrez del Castillo
|
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,39 @@
|
|
1
|
+
# Wispro
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/wispro`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'wispro'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install wispro
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/wispro.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'wispro'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require 'pry'
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/wispro.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
module Wispro
|
2
|
+
class Client
|
3
|
+
include HTTParty
|
4
|
+
base_uri 'https://www.cloud.wispro.co/api/v1'
|
5
|
+
|
6
|
+
def initialize(token)
|
7
|
+
@options = { headers: { 'Authorization' => token } }
|
8
|
+
end
|
9
|
+
|
10
|
+
def clients
|
11
|
+
fetch_paginated_data('/clients')
|
12
|
+
end
|
13
|
+
|
14
|
+
def client(id)
|
15
|
+
req = fetch_data("/clients/#{id}")
|
16
|
+
return false unless req.parsed_response['status'] == 200
|
17
|
+
|
18
|
+
req.parsed_response['data']
|
19
|
+
end
|
20
|
+
|
21
|
+
def contracts
|
22
|
+
fetch_paginated_data('/contracts')
|
23
|
+
end
|
24
|
+
|
25
|
+
def contract(id)
|
26
|
+
req = fetch_data("/contracts/#{id}")
|
27
|
+
return false unless req.parsed_response['status'] == 200
|
28
|
+
|
29
|
+
req.parsed_response['data']
|
30
|
+
end
|
31
|
+
|
32
|
+
def plans
|
33
|
+
fetch_paginated_data('/plans')
|
34
|
+
end
|
35
|
+
|
36
|
+
def plan(id)
|
37
|
+
req = fetch_data("/plans/#{id}")
|
38
|
+
return false unless req.parsed_response['status'] == 200
|
39
|
+
|
40
|
+
req.parsed_response['data']
|
41
|
+
end
|
42
|
+
|
43
|
+
def bmus
|
44
|
+
fetch_paginated_data('/bmus')
|
45
|
+
end
|
46
|
+
|
47
|
+
def bmu(id)
|
48
|
+
req = fetch_data("/bmus/#{id}")
|
49
|
+
return false unless req.parsed_response['status'] == 200
|
50
|
+
|
51
|
+
req.parsed_response['data']
|
52
|
+
end
|
53
|
+
|
54
|
+
def mikrotiks
|
55
|
+
fetch_paginated_data('/mikrotiks')
|
56
|
+
end
|
57
|
+
|
58
|
+
def mikrotik(id)
|
59
|
+
req = fetch_data("/mikrotiks/#{id}")
|
60
|
+
return false unless req.parsed_response['status'] == 200
|
61
|
+
|
62
|
+
req.parsed_response['data']
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def fetch_data(path, parameters = {})
|
68
|
+
Wispro.logger.debug "GET - #{path} - #{parameters}"
|
69
|
+
parameters.merge!(@options)
|
70
|
+
self.class.get(path, parameters)
|
71
|
+
end
|
72
|
+
|
73
|
+
def fetch_paginated_data(path)
|
74
|
+
page = 1
|
75
|
+
results = []
|
76
|
+
|
77
|
+
loop do
|
78
|
+
req = fetch_data(path, query: { page: page }).parsed_response
|
79
|
+
break unless req['status'] == 200
|
80
|
+
|
81
|
+
results.concat(req['data'])
|
82
|
+
|
83
|
+
break if page == req['meta']['pagination']['total_pages']
|
84
|
+
|
85
|
+
page += 1
|
86
|
+
end
|
87
|
+
|
88
|
+
results
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/wispro.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'wispro/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'wispro'
|
7
|
+
spec.version = Wispro::VERSION
|
8
|
+
spec.authors = ['Pablo Gutiérrez del Castillo']
|
9
|
+
spec.email = ['pablogutierrezdelc@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'Wispro Cloud API Client'
|
12
|
+
spec.description = 'Wispro Cloud API Client'
|
13
|
+
spec.homepage = 'https://github.com/mool/wispro'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
|
17
|
+
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
spec.metadata['source_code_uri'] = 'https://github.com/mool/wispro'
|
20
|
+
spec.metadata['changelog_uri'] = 'https://github.com/mool/wispro'
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_dependency 'httparty', '~> 0.17'
|
32
|
+
|
33
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
34
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wispro
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pablo Gutiérrez del Castillo
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-07-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.17'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Wispro Cloud API Client
|
56
|
+
email:
|
57
|
+
- pablogutierrezdelc@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rubocop.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- lib/wispro.rb
|
71
|
+
- lib/wispro/client.rb
|
72
|
+
- lib/wispro/logger.rb
|
73
|
+
- lib/wispro/version.rb
|
74
|
+
- wispro.gemspec
|
75
|
+
homepage: https://github.com/mool/wispro
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata:
|
79
|
+
allowed_push_host: https://rubygems.org/
|
80
|
+
homepage_uri: https://github.com/mool/wispro
|
81
|
+
source_code_uri: https://github.com/mool/wispro
|
82
|
+
changelog_uri: https://github.com/mool/wispro
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.7.6
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Wispro Cloud API Client
|
103
|
+
test_files: []
|