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
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
# Ruby client for the OnlineSim API. Entry point: OnlineSim::Client.
|
|
6
|
+
module OnlineSim
|
|
7
|
+
WEBHOOK_TYPES = %w[receiving_sms rent_sms].freeze
|
|
8
|
+
|
|
9
|
+
# Parse an inbound webhook body (`receiving_sms` or `rent_sms`) from a JSON string or an already parsed Hash.
|
|
10
|
+
# Lenient: numeric fields may arrive as strings, missing or malformed fields become nil, unknown fields are dropped.
|
|
11
|
+
# Raises OnlineSim::Error only when the input is not a JSON object at all.
|
|
12
|
+
def self.parse_webhook(payload)
|
|
13
|
+
data = payload
|
|
14
|
+
if payload.is_a?(String)
|
|
15
|
+
begin
|
|
16
|
+
data = JSON.parse(payload)
|
|
17
|
+
rescue JSON::ParserError
|
|
18
|
+
raise Error, "Webhook payload is not valid JSON"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
raise Error, "Webhook payload is not a JSON object" unless data.is_a?(Hash)
|
|
22
|
+
|
|
23
|
+
data = data.transform_keys(&:to_s)
|
|
24
|
+
{
|
|
25
|
+
"webhook_type" => WEBHOOK_TYPES.include?(data["webhook_type"]) ? data["webhook_type"] : nil,
|
|
26
|
+
"operation_id" => Normalize.num(data["operation_id"]),
|
|
27
|
+
"user_id" => Normalize.num(data["user_id"]),
|
|
28
|
+
"country_code" => Normalize.num(data["country_code"]),
|
|
29
|
+
"number" => webhook_str(data["number"]),
|
|
30
|
+
"sender" => webhook_str(data["sender"]),
|
|
31
|
+
"message" => webhook_str(data["message"]),
|
|
32
|
+
"code" => webhook_str(data["code"]),
|
|
33
|
+
"time_start" => webhook_str(data["time_start"]),
|
|
34
|
+
"time_left" => Normalize.num(data["time_left"])
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.webhook_str(value)
|
|
39
|
+
case value
|
|
40
|
+
when String then value
|
|
41
|
+
when Numeric then value.to_s
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
private_class_method :webhook_str
|
|
45
|
+
end
|
data/lib/onlinesim.rb
CHANGED
|
@@ -1,40 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "onlinesim/version"
|
|
4
|
+
require_relative "onlinesim/errors"
|
|
5
|
+
require_relative "onlinesim/normalize"
|
|
6
|
+
require_relative "onlinesim/transport"
|
|
7
|
+
require_relative "onlinesim/numbers"
|
|
8
|
+
require_relative "onlinesim/rent"
|
|
9
|
+
require_relative "onlinesim/user"
|
|
10
|
+
require_relative "onlinesim/free"
|
|
11
|
+
require_relative "onlinesim/wait"
|
|
12
|
+
require_relative "onlinesim/webhook"
|
|
13
|
+
require_relative "onlinesim/client"
|
metadata
CHANGED
|
@@ -1,107 +1,46 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: onlinesim
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- s00d
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
-
|
|
14
|
-
|
|
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.2.27
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: 2.2.27
|
|
69
|
-
description:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: Zero-dependency Ruby client for the OnlineSim API (Net::HTTP + JSON from
|
|
13
|
+
the standard library).
|
|
70
14
|
email:
|
|
71
15
|
- support@onlinesim.ru
|
|
72
16
|
executables: []
|
|
73
17
|
extensions: []
|
|
74
18
|
extra_rdoc_files: []
|
|
75
19
|
files:
|
|
76
|
-
- ".gitignore"
|
|
77
|
-
- ".travis.yml"
|
|
78
20
|
- CHANGELOG.md
|
|
79
|
-
- CODE_OF_CONDUCT.md
|
|
80
|
-
- Gemfile
|
|
81
|
-
- Gemfile.lock
|
|
82
21
|
- LICENSE
|
|
83
22
|
- README.md
|
|
84
|
-
- Rakefile
|
|
85
|
-
- bin/console
|
|
86
|
-
- bin/setup
|
|
87
23
|
- lib/onlinesim.rb
|
|
88
|
-
- lib/onlinesim/
|
|
89
|
-
- lib/onlinesim/
|
|
90
|
-
- lib/onlinesim/
|
|
91
|
-
- lib/onlinesim/
|
|
92
|
-
- lib/onlinesim/
|
|
93
|
-
- lib/onlinesim/
|
|
94
|
-
- lib/onlinesim/
|
|
95
|
-
- lib/onlinesim/
|
|
96
|
-
- lib/onlinesim/error.rb
|
|
24
|
+
- lib/onlinesim/client.rb
|
|
25
|
+
- lib/onlinesim/errors.rb
|
|
26
|
+
- lib/onlinesim/free.rb
|
|
27
|
+
- lib/onlinesim/normalize.rb
|
|
28
|
+
- lib/onlinesim/numbers.rb
|
|
29
|
+
- lib/onlinesim/rent.rb
|
|
30
|
+
- lib/onlinesim/transport.rb
|
|
31
|
+
- lib/onlinesim/user.rb
|
|
97
32
|
- lib/onlinesim/version.rb
|
|
98
|
-
- onlinesim.
|
|
99
|
-
-
|
|
33
|
+
- lib/onlinesim/wait.rb
|
|
34
|
+
- lib/onlinesim/webhook.rb
|
|
100
35
|
homepage: https://github.com/s00d/onlinesim-ruby-api
|
|
101
36
|
licenses:
|
|
102
|
-
-
|
|
103
|
-
metadata:
|
|
104
|
-
|
|
37
|
+
- Apache-2.0
|
|
38
|
+
metadata:
|
|
39
|
+
source_code_uri: https://github.com/s00d/onlinesim-ruby-api
|
|
40
|
+
documentation_uri: https://s00d.github.io/onlinesim-ruby-api/
|
|
41
|
+
changelog_uri: https://github.com/s00d/onlinesim-ruby-api/blob/master/CHANGELOG.md
|
|
42
|
+
bug_tracker_uri: https://github.com/s00d/onlinesim-ruby-api/issues
|
|
43
|
+
rubygems_mfa_required: 'true'
|
|
105
44
|
rdoc_options: []
|
|
106
45
|
require_paths:
|
|
107
46
|
- lib
|
|
@@ -109,15 +48,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
109
48
|
requirements:
|
|
110
49
|
- - ">="
|
|
111
50
|
- !ruby/object:Gem::Version
|
|
112
|
-
version: '0'
|
|
51
|
+
version: '3.0'
|
|
113
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
53
|
requirements:
|
|
115
54
|
- - ">="
|
|
116
55
|
- !ruby/object:Gem::Version
|
|
117
56
|
version: '0'
|
|
118
57
|
requirements: []
|
|
119
|
-
rubygems_version:
|
|
120
|
-
signing_key:
|
|
58
|
+
rubygems_version: 4.0.24
|
|
121
59
|
specification_version: 4
|
|
122
|
-
summary:
|
|
60
|
+
summary: 'Ruby client for the OnlineSim API: SMS numbers, rent, account and free numbers.'
|
|
123
61
|
test_files: []
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
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
DELETED
data/Gemfile.lock
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
onlinesim (1.0.11)
|
|
5
|
-
faraday (~> 1.0)
|
|
6
|
-
oj (~> 3.10)
|
|
7
|
-
thor
|
|
8
|
-
|
|
9
|
-
GEM
|
|
10
|
-
remote: https://rubygems.org/
|
|
11
|
-
specs:
|
|
12
|
-
faraday (1.8.0)
|
|
13
|
-
faraday-em_http (~> 1.0)
|
|
14
|
-
faraday-em_synchrony (~> 1.0)
|
|
15
|
-
faraday-excon (~> 1.1)
|
|
16
|
-
faraday-httpclient (~> 1.0.1)
|
|
17
|
-
faraday-net_http (~> 1.0)
|
|
18
|
-
faraday-net_http_persistent (~> 1.1)
|
|
19
|
-
faraday-patron (~> 1.0)
|
|
20
|
-
faraday-rack (~> 1.0)
|
|
21
|
-
multipart-post (>= 1.2, < 3)
|
|
22
|
-
ruby2_keywords (>= 0.0.4)
|
|
23
|
-
faraday-em_http (1.0.0)
|
|
24
|
-
faraday-em_synchrony (1.0.0)
|
|
25
|
-
faraday-excon (1.1.0)
|
|
26
|
-
faraday-httpclient (1.0.1)
|
|
27
|
-
faraday-net_http (1.0.1)
|
|
28
|
-
faraday-net_http_persistent (1.2.0)
|
|
29
|
-
faraday-patron (1.0.0)
|
|
30
|
-
faraday-rack (1.0.0)
|
|
31
|
-
multipart-post (2.1.1)
|
|
32
|
-
oj (3.13.9)
|
|
33
|
-
ruby2_keywords (0.0.5)
|
|
34
|
-
thor (1.1.0)
|
|
35
|
-
|
|
36
|
-
PLATFORMS
|
|
37
|
-
ruby
|
|
38
|
-
|
|
39
|
-
DEPENDENCIES
|
|
40
|
-
bundler (~> 2.2.27)
|
|
41
|
-
onlinesim!
|
|
42
|
-
|
|
43
|
-
BUNDLED WITH
|
|
44
|
-
2.2.27
|
data/Rakefile
DELETED
data/bin/console
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
DELETED
data/lib/onlinesim/GetForward.rb
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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
|
data/lib/onlinesim/GetFree.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
data/lib/onlinesim/GetNumbers.rb
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
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: {}, extension: false)
|
|
10
|
-
return self ._get(:endpoint => 'getNum', :params => {service:service,country:country,reject:reject,extension:extension})['tzid']
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def getwithnumber(service, country: 7, reject: {}, extension: false)
|
|
14
|
-
return self ._get(:endpoint => 'getNum', :params => {service:service,country:country,reject:reject,extension:extension, number:true})
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def state(message_to_code:1, orderby: 'ASC', msg_list:true, clean: false, repeat:false)
|
|
18
|
-
type = 'index'
|
|
19
|
-
if repeat
|
|
20
|
-
type = 'repeat'
|
|
21
|
-
end
|
|
22
|
-
return self ._get(:endpoint => 'getState', :params => {message_to_code:message_to_code,orderby:orderby,msg_list:msg_list,clean:clean,type:type})
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def stateone(tzid, message_to_code = 1, msg_list = true, clean = false, repeat =false)
|
|
26
|
-
type = 'index'
|
|
27
|
-
if repeat
|
|
28
|
-
type = 'repeat'
|
|
29
|
-
end
|
|
30
|
-
return self ._get(:endpoint => 'getState', :params => {tzid:tzid,message_to_code:message_to_code,msg_list:msg_list,clean:clean,type:type})[0]
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def next(tzid)
|
|
34
|
-
return self ._get(:endpoint => 'setOperationRevise', :params => {tzid:tzid})
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def close(tzid)
|
|
38
|
-
return self ._get(:endpoint => 'setOperationOk', :params => {tzid:tzid})
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def ban(tzid)
|
|
42
|
-
return self ._get(:endpoint => 'setOperationOk', :params => {tzid:tzid, ban: 1})
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def tariffs()
|
|
46
|
-
return self ._get(:endpoint => 'getNumbersStats', :params => {country:'all'})
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def tariffsone(country:7)
|
|
50
|
-
return self ._get(:endpoint => 'getNumbersStats', :params => {country:country})
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def service()
|
|
54
|
-
return self ._get(:endpoint => 'getService')['service']
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def servicenumber(service)
|
|
58
|
-
return self ._get(:endpoint => 'getServiceNumber', :params => {service:service})['number']
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def wait_code(tzid, timeout = 10, not_end = false)
|
|
62
|
-
__last_code = ''
|
|
63
|
-
counter = 0
|
|
64
|
-
while true
|
|
65
|
-
sleep(timeout)
|
|
66
|
-
counter += 1
|
|
67
|
-
if counter >= 10
|
|
68
|
-
raise ApiError, "Timeout error"
|
|
69
|
-
end
|
|
70
|
-
response = self.stateone(tzid,1, false)
|
|
71
|
-
begin # "try" block
|
|
72
|
-
if !not_end and response['msg'] != __last_code
|
|
73
|
-
__last_code = response['msg']
|
|
74
|
-
self.close(tzid)
|
|
75
|
-
break
|
|
76
|
-
end
|
|
77
|
-
if not_end and response['msg'] != __last_code
|
|
78
|
-
__last_code = response['msg']
|
|
79
|
-
self.next(tzid)
|
|
80
|
-
break
|
|
81
|
-
end
|
|
82
|
-
rescue
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
return __last_code
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
data/lib/onlinesim/GetProxy.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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 => {class: 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
|
data/lib/onlinesim/GetRent.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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/extendRentState', :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
|
data/lib/onlinesim/GetUser.rb
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|