onlinesim 1.0.11 → 2.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 +4 -4
- data/CHANGELOG.md +48 -0
- data/README.md +16 -21
- data/lib/onlinesim/client.rb +119 -0
- data/lib/onlinesim/errors.rb +67 -0
- data/lib/onlinesim/free.rb +17 -0
- data/lib/onlinesim/normalize.rb +26 -0
- data/lib/onlinesim/numbers.rb +85 -0
- data/lib/onlinesim/rent.rb +69 -0
- data/lib/onlinesim/transport.rb +32 -0
- data/lib/onlinesim/user.rb +48 -0
- data/lib/onlinesim/version.rb +4 -2
- data/lib/onlinesim/wait.rb +38 -0
- data/lib/onlinesim/webhook.rb +45 -0
- data/lib/onlinesim.rb +13 -40
- metadata +25 -87
- data/.gitignore +0 -9
- data/.travis.yml +0 -7
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -6
- data/Gemfile.lock +0 -44
- data/Rakefile +0 -10
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/onlinesim/GetForward.rb +0 -41
- data/lib/onlinesim/GetFree.rb +0 -17
- data/lib/onlinesim/GetNumbers.rb +0 -90
- data/lib/onlinesim/GetProxy.rb +0 -29
- data/lib/onlinesim/GetRent.rb +0 -33
- data/lib/onlinesim/GetUser.rb +0 -13
- data/lib/onlinesim/base.rb +0 -66
- data/lib/onlinesim/cli.rb +0 -7
- data/lib/onlinesim/error.rb +0 -12
- data/onlinesim.gemspec +0 -25
- data/tester.rb +0 -18
data/lib/onlinesim/base.rb
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
require 'faraday'
|
|
2
|
-
require 'oj'
|
|
3
|
-
require 'onlinesim/error'
|
|
4
|
-
|
|
5
|
-
module FaradayOverrides
|
|
6
|
-
def initialize *args
|
|
7
|
-
options = args.last
|
|
8
|
-
options[:ssl] = {verify: false}
|
|
9
|
-
# options[:proxy] = "http://127.0.0.1:4034"
|
|
10
|
-
super
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
module OnlineSim
|
|
15
|
-
class Base
|
|
16
|
-
HTTP_OK_CODE = 200
|
|
17
|
-
|
|
18
|
-
def initialize(apikey: nil, lang: 'en', dev_id: nil)
|
|
19
|
-
@apikey = apikey
|
|
20
|
-
@lang = lang
|
|
21
|
-
@dev_id = dev_id
|
|
22
|
-
|
|
23
|
-
Faraday.ignore_env_proxy = true
|
|
24
|
-
Faraday::Connection.prepend FaradayOverrides
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
private
|
|
28
|
-
def client
|
|
29
|
-
@_client ||= Faraday.new('https://onlinesim.ru') do |client|
|
|
30
|
-
client.request :url_encoded
|
|
31
|
-
client.adapter Faraday.default_adapter
|
|
32
|
-
client.headers['User-agent'] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36"
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
protected
|
|
37
|
-
def _get(endpoint: '', params: {})
|
|
38
|
-
params['apikey'] = @apikey
|
|
39
|
-
params['lang'] = @lang
|
|
40
|
-
params['dev_id'] = @dev_id
|
|
41
|
-
if @dev_id
|
|
42
|
-
params['dev_id'] = @dev_id
|
|
43
|
-
end
|
|
44
|
-
resp = client.public_send("get", '/api/' + endpoint + '.php', params)
|
|
45
|
-
|
|
46
|
-
parsed_response = Oj.load(resp.body)
|
|
47
|
-
|
|
48
|
-
if resp.status == HTTP_OK_CODE
|
|
49
|
-
def valid_json?(parsed_response)
|
|
50
|
-
puts parsed_response['response']
|
|
51
|
-
if parsed_response.key?('response') and parsed_response['response'].to_s != '1'
|
|
52
|
-
raise ApiError, parsed_response['response']
|
|
53
|
-
end
|
|
54
|
-
if parsed_response.key?('response')
|
|
55
|
-
parsed_response.delete('response')
|
|
56
|
-
end
|
|
57
|
-
rescue JSON::ParserError
|
|
58
|
-
end
|
|
59
|
-
return parsed_response
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
raise ApiError, "Code: #{resp.status}, response: #{resp.body}"
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
end
|
|
66
|
-
end
|
data/lib/onlinesim/cli.rb
DELETED
data/lib/onlinesim/error.rb
DELETED
data/onlinesim.gemspec
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require "onlinesim/version"
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name = 'onlinesim'
|
|
8
|
-
spec.version = Onlinesim::VERSION
|
|
9
|
-
spec.authors = ['s00d']
|
|
10
|
-
spec.email = ['support@onlinesim.ru']
|
|
11
|
-
|
|
12
|
-
spec.summary = 'onlinesim.ru Ruby API wrapper'
|
|
13
|
-
spec.homepage = 'https://github.com/s00d/onlinesim-ruby-api'
|
|
14
|
-
spec.license = 'MIT'
|
|
15
|
-
|
|
16
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
17
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
18
|
-
end
|
|
19
|
-
spec.require_paths = ["lib"]
|
|
20
|
-
|
|
21
|
-
spec.add_dependency 'faraday', '~> 1.0'
|
|
22
|
-
spec.add_dependency 'oj', '~> 3.10'
|
|
23
|
-
spec.add_dependency 'thor'
|
|
24
|
-
spec.add_development_dependency "bundler", "~> 2.2.27"
|
|
25
|
-
end
|
data/tester.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'onlinesim'
|
|
5
|
-
|
|
6
|
-
class Tester
|
|
7
|
-
def test
|
|
8
|
-
driver = OnlineSim::Driver.new(:apikey => 'APIKEY').numbers
|
|
9
|
-
tzid = driver.getwithnumber('vkcom')
|
|
10
|
-
puts tzid['number']
|
|
11
|
-
puts tzid['tzid']
|
|
12
|
-
# countries = driver.countries
|
|
13
|
-
# puts countries
|
|
14
|
-
# puts driver.wait_code(680507)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
puts Tester.new.test
|