onlinesim 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/onlinesim.rb +40 -0
- data/lib/onlinesim/GetForward.rb +41 -0
- data/lib/onlinesim/GetFree.rb +17 -0
- data/lib/onlinesim/GetNumbers.rb +82 -0
- data/lib/onlinesim/GetProxy.rb +29 -0
- data/lib/onlinesim/GetRent.rb +33 -0
- data/lib/onlinesim/GetUser.rb +13 -0
- data/lib/onlinesim/base.rb +65 -0
- data/lib/onlinesim/cli.rb +7 -0
- data/lib/onlinesim/error.rb +12 -0
- data/lib/onlinesim/version.rb +3 -0
- data/onlinesim.gemspec +30 -0
- data/tester.rb +17 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1de10f58fba254b751530d584415161245930bb0a7cb29386aa78cb077563a32
|
4
|
+
data.tar.gz: 712ebbe852ae2b3ab41667f147967c54dfb662c95f0534830e0729cdd4b80fda
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ec9cd019642cc5032fc86a004b3e05014d9f36dc8bf12943929aa5dba6e6c5dbd112d262f29a56b1ad21e50e94b7a31068395225de7c26c7fc8e0af3ed93f0d1
|
7
|
+
data.tar.gz: b8a1020d2eb8178d8a55cdfe291c549965fb639712da71a37e008e435e30e5ab88000360cb8432131b8c18f3bf04d192dc1b55cd55a58ab3db19fd2b0800eec6
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at Virus191288@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 s00d
|
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
|
+
# Onlinesim Ruby API
|
2
|
+
|
3
|
+
|
4
|
+
Wrapper for automatic reception of SMS-messages by onlinesim.ru
|
5
|
+
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/ribose.svg)](https://badge.fury.io/rb/ribose)
|
7
|
+
|
8
|
+
|
9
|
+
### Installation
|
10
|
+
You can install or upgrade package with:
|
11
|
+
```bash
|
12
|
+
$ gem install onlinesim
|
13
|
+
```
|
14
|
+
### Example
|
15
|
+
```ruby
|
16
|
+
require 'onlinesim'
|
17
|
+
|
18
|
+
module MyModule
|
19
|
+
class Tester
|
20
|
+
def test
|
21
|
+
driver = OnlineSim::Driver.new(:apikey => 'TOKEN').numbers
|
22
|
+
tzid = driver.get('vkcom')
|
23
|
+
puts driver.stateone(tzid)['number']
|
24
|
+
puts driver.wait_code(tzid)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
puts MyModule::Tester.new.test
|
30
|
+
```
|
31
|
+
|
32
|
+
## Documentation
|
33
|
+
|
34
|
+
All documentation is in the wiki of this project - **[Documentation](https://github.com/s00d/onlinesim-python-api/wiki)**
|
35
|
+
|
36
|
+
## Bugs
|
37
|
+
|
38
|
+
If you have any problems, please create Issues here
|
39
|
+
https://github.com/s00d/onlinesim-python-api/issues
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "onlinesim"
|
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/onlinesim.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'onlinesim/GetFree'
|
2
|
+
require 'onlinesim/GetForward'
|
3
|
+
require 'onlinesim/GetNumbers'
|
4
|
+
require 'onlinesim/GetProxy'
|
5
|
+
require 'onlinesim/GetRent'
|
6
|
+
require 'onlinesim/GetUser'
|
7
|
+
|
8
|
+
module OnlineSim
|
9
|
+
class Driver
|
10
|
+
def initialize(apikey: '', lang: 'en', dev_id: str = nil)
|
11
|
+
@apikey = apikey
|
12
|
+
@lang = lang
|
13
|
+
@dev_id = dev_id
|
14
|
+
end
|
15
|
+
|
16
|
+
def numbers
|
17
|
+
OnlineSim::GetNumbers.new(:apikey => @apikey, :lang => @lang, :dev_id => @dev_id)
|
18
|
+
end
|
19
|
+
|
20
|
+
def forward
|
21
|
+
OnlineSim::GetForward.new(:apikey => @apikey, :lang => @lang, :dev_id => @dev_id)
|
22
|
+
end
|
23
|
+
|
24
|
+
def free
|
25
|
+
OnlineSim::GetFree.new(:apikey => @apikey, :lang => @lang, :dev_id => @dev_id)
|
26
|
+
end
|
27
|
+
|
28
|
+
def proxy
|
29
|
+
OnlineSim::GetProxy.new(:apikey => @apikey, :lang => @lang, :dev_id => @dev_id)
|
30
|
+
end
|
31
|
+
|
32
|
+
def rent
|
33
|
+
OnlineSim::GetRent.new(:apikey => @apikey, :lang => @lang, :dev_id => @dev_id)
|
34
|
+
end
|
35
|
+
|
36
|
+
def user
|
37
|
+
OnlineSim::GetUser.new(:apikey => @apikey, :lang => @lang, :dev_id => @dev_id)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'onlinesim/Base'
|
2
|
+
|
3
|
+
module OnlineSim
|
4
|
+
class GetForward < Base
|
5
|
+
def get(forward_numbers: [], service: 'unlimited_sms', region: nil, reject: [])
|
6
|
+
return self ._get(:endpoint => 'getForward', :params => {forward_numbers:forward_numbers, service:service,region:region,reject: reject})['tzid']
|
7
|
+
end
|
8
|
+
|
9
|
+
def state(message_to_code: 1, orderby: 'ASC', msg_list: true, clean: true)
|
10
|
+
return self ._get(:endpoint => 'getState', :params => {message_to_code:message_to_code, orderby:orderby,msg_list:msg_list,clean: clean, type:'forward'})
|
11
|
+
end
|
12
|
+
|
13
|
+
def stateone(tzid, message_to_code: 1, orderby: 'ASC', msg_list: true, clean: true)
|
14
|
+
return self ._get(:endpoint => 'getState', :params => {tzid:tzid,message_to_code:message_to_code, orderby:orderby,msg_list:msg_list,clean: clean, type:'forward'})
|
15
|
+
end
|
16
|
+
|
17
|
+
def close(tzid)
|
18
|
+
return self ._get(:endpoint => 'setOperationOk', :params => {tzid:tzid})
|
19
|
+
end
|
20
|
+
|
21
|
+
def repeat(service, number)
|
22
|
+
return self ._get(:endpoint => 'getNumRepeat', :params => {service:service, number:number})['tzid']
|
23
|
+
end
|
24
|
+
|
25
|
+
def tariffs()
|
26
|
+
return self ._get(:endpoint => 'getNumbersStats', :params => {country:'all'})
|
27
|
+
end
|
28
|
+
|
29
|
+
def tariffsone(country: 7)
|
30
|
+
return self ._get(:endpoint => 'getNumbersStats', :params => {country:country})
|
31
|
+
end
|
32
|
+
|
33
|
+
def service()
|
34
|
+
return self ._get(:endpoint => 'getService')['service']
|
35
|
+
end
|
36
|
+
|
37
|
+
def servicenumber(service)
|
38
|
+
return self ._get(:endpoint => 'getServiceNumber', :params => {service:service})['number']
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'onlinesim/Base'
|
2
|
+
|
3
|
+
module OnlineSim
|
4
|
+
class GetFree < Base
|
5
|
+
def countries
|
6
|
+
return self ._get(:endpoint => 'getFreeCountryList')['countries']
|
7
|
+
end
|
8
|
+
|
9
|
+
def numbers(country: 7)
|
10
|
+
return self ._get(:endpoint => 'getFreePhoneList', :params => {country: country})['numbers']
|
11
|
+
end
|
12
|
+
|
13
|
+
def messages(phone, page: 1)
|
14
|
+
return self ._get(:endpoint => 'getFreeMessageList', :params => {phone: phone, page: page})['messages']['data']
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'onlinesim/Base'
|
2
|
+
|
3
|
+
module OnlineSim
|
4
|
+
class GetNumbers < Base
|
5
|
+
def price(service)
|
6
|
+
return self ._get(:endpoint => 'getPrice', :params => {service:service})['price']
|
7
|
+
end
|
8
|
+
|
9
|
+
def get(service, country: 7, reject: nil, extension: false)
|
10
|
+
return self ._get(:endpoint => 'getNum', :params => {service:service,country:country,reject:reject,extension:extension})['tzid']
|
11
|
+
end
|
12
|
+
|
13
|
+
def state(message_to_code:1, orderby: 'ASC', msg_list:true, clean: false, repeat:false)
|
14
|
+
type = 'index'
|
15
|
+
if repeat
|
16
|
+
type = 'repeat'
|
17
|
+
end
|
18
|
+
return self ._get(:endpoint => 'getState', :params => {message_to_code:message_to_code,orderby:orderby,msg_list:msg_list,clean:clean,type:type})
|
19
|
+
end
|
20
|
+
|
21
|
+
def stateone(tzid, message_to_code = 1, msg_list = true, clean = false, repeat =false)
|
22
|
+
type = 'index'
|
23
|
+
if repeat
|
24
|
+
type = 'repeat'
|
25
|
+
end
|
26
|
+
return self ._get(:endpoint => 'getState', :params => {tzid:tzid,message_to_code:message_to_code,msg_list:msg_list,clean:clean,type:type})[0]
|
27
|
+
end
|
28
|
+
|
29
|
+
def next(tzid)
|
30
|
+
return self ._get(:endpoint => 'setOperationRevise', :params => {tzid:tzid})
|
31
|
+
end
|
32
|
+
|
33
|
+
def close(tzid)
|
34
|
+
return self ._get(:endpoint => 'setOperationOk', :params => {tzid:tzid})
|
35
|
+
end
|
36
|
+
|
37
|
+
def tariffs()
|
38
|
+
return self ._get(:endpoint => 'getNumbersStats', :params => {country:'all'})
|
39
|
+
end
|
40
|
+
|
41
|
+
def tariffsone(country:7)
|
42
|
+
return self ._get(:endpoint => 'getNumbersStats', :params => {country:country})
|
43
|
+
end
|
44
|
+
|
45
|
+
def service()
|
46
|
+
return self ._get(:endpoint => 'getService')['service']
|
47
|
+
end
|
48
|
+
|
49
|
+
def servicenumber(service)
|
50
|
+
return self ._get(:endpoint => 'getServiceNumber', :params => {service:service})['number']
|
51
|
+
end
|
52
|
+
|
53
|
+
def wait_code(tzid, timeout = 10, not_end = false)
|
54
|
+
__last_code = ''
|
55
|
+
counter = 0
|
56
|
+
while true
|
57
|
+
sleep(timeout)
|
58
|
+
counter += 1
|
59
|
+
if counter >= 10
|
60
|
+
raise ApiError, "Timeout error"
|
61
|
+
end
|
62
|
+
response = self.stateone(tzid,1, false)
|
63
|
+
begin # "try" block
|
64
|
+
if !not_end and response['msg'] != __last_code
|
65
|
+
__last_code = response['msg']
|
66
|
+
self.close(tzid)
|
67
|
+
break
|
68
|
+
end
|
69
|
+
if not_end and response['msg'] != __last_code
|
70
|
+
__last_code = response['msg']
|
71
|
+
self.next(tzid)
|
72
|
+
break
|
73
|
+
end
|
74
|
+
rescue
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
return __last_code
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'onlinesim/Base'
|
2
|
+
|
3
|
+
module OnlineSim
|
4
|
+
class GetProxy < Base
|
5
|
+
def get(cl:'days', type:'private', connect:'https', count: 1, operator:nil, country: 7, city: 'any', port_count: 1, session:true )
|
6
|
+
return self ._get(:endpoint => '/proxy/getProxy', :params => {cl: cl,type:type,connect:connect,count:count,operator:operator,country:country,city:city,port_count:port_count,session:session})['item']
|
7
|
+
end
|
8
|
+
|
9
|
+
def state(orderby: "ASC")
|
10
|
+
return self ._get(:endpoint => '/proxy/getState', :params => {orderby: orderby})['list']
|
11
|
+
end
|
12
|
+
|
13
|
+
def stateone(tzid)
|
14
|
+
return self ._get(:endpoint => '/proxy/getState', :params => {tzid: tzid})['list'][0]
|
15
|
+
end
|
16
|
+
|
17
|
+
def changeip(tzid)
|
18
|
+
return self ._get(:endpoint => '/proxy/changeIp', :params => {tzid: tzid})
|
19
|
+
end
|
20
|
+
|
21
|
+
def changetype(tzid)
|
22
|
+
return self ._get(:endpoint => '/proxy/changeType', :params => {tzid: tzid})['connect_type']
|
23
|
+
end
|
24
|
+
|
25
|
+
def setcomment(tzid, comment: '')
|
26
|
+
return self ._get(:endpoint => '/proxy/setComment', :params => {tzid: tzid,comment:comment})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'onlinesim/Base'
|
2
|
+
|
3
|
+
module OnlineSim
|
4
|
+
class GetRent < Base
|
5
|
+
def get(country: 7, days: 1, extension: false)
|
6
|
+
return self._get(:endpoint => '/rent/getRentNum', :params => {country: country,days:days,extension:extension})['item']
|
7
|
+
end
|
8
|
+
|
9
|
+
def state
|
10
|
+
return self._get(:endpoint => '/rent/getRentState', :params => {pagination: false})['list']
|
11
|
+
end
|
12
|
+
|
13
|
+
def stateone(tzid)
|
14
|
+
return self._get(:endpoint => '/rent/getRentState', :params => {tzid:tzid, pagination: false})['list'][0]
|
15
|
+
end
|
16
|
+
|
17
|
+
def extend(tzid)
|
18
|
+
return self._get(:endpoint => '/rent/portReload', :params => {tzid:tzid})
|
19
|
+
end
|
20
|
+
|
21
|
+
def tariffs
|
22
|
+
return self._get(:endpoint => '/rent/tariffsRent')
|
23
|
+
end
|
24
|
+
|
25
|
+
def tariffsone(country: 7)
|
26
|
+
return self._get(:endpoint => '/rent/tariffsRent', :params => {country:country})
|
27
|
+
end
|
28
|
+
|
29
|
+
def close(tzid)
|
30
|
+
return self._get(:endpoint => '/rent/closeRentNum', :params => {tzid:tzid})
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'onlinesim/Base'
|
2
|
+
|
3
|
+
module OnlineSim
|
4
|
+
class GetUser < Base
|
5
|
+
def balance
|
6
|
+
return self ._get(:endpoint => 'getBalance', :params => {income: true})
|
7
|
+
end
|
8
|
+
|
9
|
+
def profile
|
10
|
+
return self ._get(:endpoint => 'getProfile')['profile']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,65 @@
|
|
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
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module OnlineSim
|
14
|
+
class Base
|
15
|
+
HTTP_OK_CODE = 200
|
16
|
+
|
17
|
+
def initialize(apikey: nil, lang: 'en', dev_id: nil)
|
18
|
+
@apikey = apikey
|
19
|
+
@lang = lang
|
20
|
+
@dev_id = dev_id
|
21
|
+
|
22
|
+
Faraday.ignore_env_proxy = true
|
23
|
+
Faraday::Connection.prepend FaradayOverrides
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def client
|
28
|
+
@_client ||= Faraday.new('https://onlinesim.ru', proxy: 'http://127.0.0.1:4034') do |client|
|
29
|
+
client.request :url_encoded
|
30
|
+
client.adapter Faraday.default_adapter
|
31
|
+
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"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
def _get(endpoint: '', params: {})
|
37
|
+
params['apikey'] = @apikey
|
38
|
+
params['lang'] = @lang
|
39
|
+
params['dev_id'] = @dev_id
|
40
|
+
if @dev_id
|
41
|
+
params['dev_id'] = @dev_id
|
42
|
+
end
|
43
|
+
resp = client.public_send("get", '/api/' + endpoint + '.php', params)
|
44
|
+
|
45
|
+
parsed_response = Oj.load(resp.body)
|
46
|
+
|
47
|
+
if resp.status == HTTP_OK_CODE
|
48
|
+
def valid_json?(parsed_response)
|
49
|
+
puts parsed_response['response']
|
50
|
+
if parsed_response.key?('response') and parsed_response['response'].to_s != '1'
|
51
|
+
raise ApiError, parsed_response['response']
|
52
|
+
end
|
53
|
+
if parsed_response.key?('response')
|
54
|
+
parsed_response.delete('response')
|
55
|
+
end
|
56
|
+
rescue JSON::ParserError
|
57
|
+
end
|
58
|
+
return parsed_response
|
59
|
+
end
|
60
|
+
|
61
|
+
raise ApiError, "Code: #{resp.status}, response: #{resp.body}"
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
data/onlinesim.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
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 = 'http://onlinesim.ru'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency 'faraday', '~> 1.0'
|
24
|
+
spec.add_dependency 'oj', '~> 3.10'
|
25
|
+
spec.add_dependency 'thor'
|
26
|
+
spec.add_development_dependency "bundler", "~> 2.1.4"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
30
|
+
end
|
data/tester.rb
ADDED
@@ -0,0 +1,17 @@
|
|
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 => '').numbers
|
9
|
+
# tzid = driver.get('odklru')
|
10
|
+
# puts tzid
|
11
|
+
number = driver.stateone(680506)['number']
|
12
|
+
puts number
|
13
|
+
# puts driver.wait_code(680507)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
puts Tester.new.test
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: onlinesim
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- s00d
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: oj
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.10'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.1.4
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.1.4
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '5.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.2'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.2'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- support@onlinesim.ru
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- CODE_OF_CONDUCT.md
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- bin/console
|
124
|
+
- bin/setup
|
125
|
+
- lib/onlinesim.rb
|
126
|
+
- lib/onlinesim/GetForward.rb
|
127
|
+
- lib/onlinesim/GetFree.rb
|
128
|
+
- lib/onlinesim/GetNumbers.rb
|
129
|
+
- lib/onlinesim/GetProxy.rb
|
130
|
+
- lib/onlinesim/GetRent.rb
|
131
|
+
- lib/onlinesim/GetUser.rb
|
132
|
+
- lib/onlinesim/base.rb
|
133
|
+
- lib/onlinesim/cli.rb
|
134
|
+
- lib/onlinesim/error.rb
|
135
|
+
- lib/onlinesim/version.rb
|
136
|
+
- onlinesim.gemspec
|
137
|
+
- tester.rb
|
138
|
+
homepage: http://onlinesim.ru
|
139
|
+
licenses:
|
140
|
+
- MIT
|
141
|
+
metadata: {}
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubygems_version: 3.1.4
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: onlinesim.ru Ruby API wrapper
|
161
|
+
test_files: []
|