adspower-client 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/adspower-client.gemspec +2 -2
- data/lib/adspower-client.rb +32 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1289e195355621cc166ac8cb97668015390fa31b5bb0db7579c7b397bad31fcf
|
4
|
+
data.tar.gz: b467fd3a6e5bbbcec7ddf207b1ce2909e480db5fc66849548be27154414bac32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9ae982a04c8e734bf33bb2864ae247c8ce180b136c79e290d6dadabd0957b0ca33b1b2f62cff06fef5fcd12b4f4f9f5eb61fe24eed489d562210cdbc1c9cf84
|
7
|
+
data.tar.gz: 72a3f7138ee351ee425ca9aa7243a70e8951f5a04df357257734e991a180dc2e207782fd9d858f61462747d4576eee05820c9adb4dc685c35f5a74cbf7f280b4
|
data/adspower-client.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'adspower-client'
|
3
|
-
s.version = '1.0.
|
4
|
-
s.date = '2023-12-
|
3
|
+
s.version = '1.0.4'
|
4
|
+
s.date = '2023-12-31'
|
5
5
|
s.summary = "Ruby library for operating AdsPower API."
|
6
6
|
s.description = "Ruby library for operating AdsPower API."
|
7
7
|
s.authors = ["Leandro Daniel Sardi"]
|
data/lib/adspower-client.rb
CHANGED
@@ -18,17 +18,21 @@ class AdsPowerClient
|
|
18
18
|
# self.profiles_created = []
|
19
19
|
end
|
20
20
|
|
21
|
-
# send an GET request to "#{url}/status"
|
22
|
-
#
|
21
|
+
# send an GET request to "#{url}/status".
|
22
|
+
# Return true if it responded successfully.
|
23
23
|
#
|
24
24
|
# reference: https://localapi-doc-en.adspower.com/docs/6DSiws
|
25
25
|
#
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
def online?
|
27
|
+
begin
|
28
|
+
url = "#{self.adspower_listener}/status"
|
29
|
+
uri = URI.parse(url)
|
30
|
+
res = Net::HTTP.get(uri)
|
31
|
+
# show respose body
|
32
|
+
return JSON.parse(res)['msg'] == 'success'
|
33
|
+
rescue => e
|
34
|
+
return false
|
35
|
+
end
|
32
36
|
end
|
33
37
|
|
34
38
|
# send a post request to "#{url}/api/v1/user/create"
|
@@ -80,8 +84,8 @@ class AdsPowerClient
|
|
80
84
|
#
|
81
85
|
# reference: https://localapi-doc-en.adspower.com/docs/FFMFMf
|
82
86
|
#
|
83
|
-
def start(id)
|
84
|
-
uri = URI.parse("#{self.adspower_listener}/api/v1/browser/start?user_id=#{id}&headless
|
87
|
+
def start(id, headless=false)
|
88
|
+
uri = URI.parse("#{self.adspower_listener}/api/v1/browser/start?user_id=#{id}&headless=#{headless ? '1' : '0'}'}")
|
85
89
|
res = Net::HTTP.get(uri)
|
86
90
|
# show respose bo
|
87
91
|
ret = JSON.parse(res)
|
@@ -105,9 +109,25 @@ class AdsPowerClient
|
|
105
109
|
ret
|
106
110
|
end
|
107
111
|
|
112
|
+
# send an GET request to "#{url}/status"
|
113
|
+
# and return if I get the json response['data']['status'] == 'Active'.
|
114
|
+
# Otherwise, return false.
|
115
|
+
#
|
116
|
+
# reference: https://localapi-doc-en.adspower.com/docs/YjFggL
|
117
|
+
#
|
118
|
+
def check(id)
|
119
|
+
url = "#{self.adspower_listener}/api/v1/browser/active?user_id=#{id}"
|
120
|
+
uri = URI.parse(url)
|
121
|
+
res = Net::HTTP.get(uri)
|
122
|
+
# show respose body
|
123
|
+
return false if JSON.parse(res)['msg'] != 'success'
|
124
|
+
# return
|
125
|
+
JSON.parse(res)['data']['status'] == 'Active'
|
126
|
+
end
|
127
|
+
|
108
128
|
#
|
109
|
-
def driver(id)
|
110
|
-
ret = self.start(id)
|
129
|
+
def driver(id, headless=false)
|
130
|
+
ret = self.start(id, headless)
|
111
131
|
|
112
132
|
# Attach test execution to the existing browser
|
113
133
|
# reference: https://zhiminzhan.medium.com/my-innovative-solution-to-test-automation-attach-test-execution-to-the-existing-browser-b90cda3b7d4a
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adspower-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uri
|