proxy-cheap-client 1.0.7 → 1.0.8
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/README.md +70 -16
- data/lib/proxy_cheap_client/client.rb +24 -9
- data/lib/proxy_cheap_client/models/balance.rb +2 -3
- data/lib/proxy_cheap_client/models/base.rb +27 -11
- data/lib/proxy_cheap_client/models/configuration.rb +2 -3
- data/lib/proxy_cheap_client/models/order.rb +2 -4
- data/lib/proxy_cheap_client/models/proxy.rb +3 -53
- data/lib/proxy_cheap_client/version.rb +1 -1
- 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: 6c5ac4012c4d9c09bbeffcbb708a9e0621303fd375cbe2de06c9956809def96e
|
|
4
|
+
data.tar.gz: 537ad65c4a55cce1e07f10006b728f2b7c0830cda33d23cc467d69d39b5b0a13
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1b030162bf6fd28039d83ebfe134d7cc6cfe4ca345d56adf46faf3dd1ea0aac045b5ce9ac5e63d199a09c0fb4366d10e5039ad69a34a96c34de86b9c7289fb1
|
|
7
|
+
data.tar.gz: 7cfbe3a80af18ba15f5b13f3605fd00544e45796b8a090ec71636199681a4fb530b7fde25fad9f2bf4530882de6ac8b557eca481cb2e60e1f6163fd1ee419c8f
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Ruby client for the Proxy-Cheap.com API.
|
|
|
4
4
|
|
|
5
5
|
[](https://rubygems.org/gems/proxy-cheap-client) [](./LICENSE.txt)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**Features:**
|
|
8
8
|
|
|
9
9
|
* Retrieve account balance
|
|
10
10
|
* List proxies
|
|
@@ -12,19 +12,39 @@ Ruby client for the Proxy-Cheap.com API.
|
|
|
12
12
|
* Get list of supported countries
|
|
13
13
|
* Order new residential proxies
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
**Requirements:**
|
|
16
16
|
|
|
17
17
|
* Ruby 2.7+
|
|
18
18
|
* Internet access to Proxy-Cheap.com API
|
|
19
19
|
* API key and API secret from Proxy-Cheap.com
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
**Outlook:**
|
|
22
|
+
|
|
23
|
+
- [1. Installation](#1-installation)
|
|
24
|
+
- [2. Configuration](#2-configuration)
|
|
25
|
+
- [3. Usage Example](#3-usage-example)
|
|
26
|
+
- [4. Load Proxies](#4-load-proxies)
|
|
27
|
+
- [5. Load Specific Proxy](#5-load-specific-proxy)
|
|
28
|
+
- [6. Enable auto-extend for a proxy](#6-enable-auto-extend-for-a-proxy)
|
|
29
|
+
- [7. Disable auto-extend](#7-disable-auto-extend)
|
|
30
|
+
- [8. Supported Countries](#8-supported-countries)
|
|
31
|
+
- [9. Order Residential Proxies](#9-order-residential-proxies)
|
|
32
|
+
- [10. Order Proxies](#10-order-proxies)
|
|
33
|
+
- [11. Order Expenses](#11-order-expenses)
|
|
34
|
+
- [12. Proxies of an Old Order](#12-proxies-of-an-old-order)
|
|
35
|
+
- [13. Using Multiple Credentials](#13-using-multiple-credentials)
|
|
36
|
+
- [14. Error Handling](#14-error-handling)
|
|
37
|
+
- [15. Publishing](#15-publishing)
|
|
38
|
+
- [16. Contributing](#16-contributing)
|
|
39
|
+
- [17. License](#17-license)
|
|
40
|
+
|
|
41
|
+
## 1. Installation
|
|
22
42
|
|
|
23
43
|
```bash
|
|
24
44
|
gem install proxy-cheap-client
|
|
25
45
|
```
|
|
26
46
|
|
|
27
|
-
|
|
47
|
+
## 2. Configuration
|
|
28
48
|
|
|
29
49
|
The client requires both an API key and API secret.
|
|
30
50
|
|
|
@@ -37,7 +57,7 @@ client = ProxyCheapClient::Client.new(
|
|
|
37
57
|
)
|
|
38
58
|
```
|
|
39
59
|
|
|
40
|
-
|
|
60
|
+
## 3. Usage Example
|
|
41
61
|
|
|
42
62
|
```ruby
|
|
43
63
|
require "proxy-cheap-client"
|
|
@@ -52,7 +72,7 @@ balance = client.balance
|
|
|
52
72
|
puts "Balance: #{balance.amount} #{balance.currency}"
|
|
53
73
|
```
|
|
54
74
|
|
|
55
|
-
|
|
75
|
+
## 4. Load Proxies
|
|
56
76
|
|
|
57
77
|
```ruby
|
|
58
78
|
proxies = client.proxies
|
|
@@ -61,35 +81,35 @@ proxies.each do |p|
|
|
|
61
81
|
end
|
|
62
82
|
```
|
|
63
83
|
|
|
64
|
-
|
|
84
|
+
## 5. Load Specific Proxy
|
|
65
85
|
|
|
66
86
|
```ruby
|
|
67
87
|
proxy = ProxyCheapClient::Proxy.load('12345')
|
|
68
88
|
puts "Proxy details: #{proxy.to_h}"
|
|
69
89
|
```
|
|
70
90
|
|
|
71
|
-
|
|
91
|
+
## 6. Enable auto-extend for a proxy
|
|
72
92
|
|
|
73
93
|
```ruby
|
|
74
94
|
proxy.enable_auto_extend
|
|
75
95
|
puts "Auto-extend enabled"
|
|
76
96
|
```
|
|
77
97
|
|
|
78
|
-
|
|
98
|
+
## 7. Disable auto-extend
|
|
79
99
|
|
|
80
100
|
```ruby
|
|
81
101
|
proxy.disable_auto_extend
|
|
82
102
|
puts "Auto-extend disabled"
|
|
83
103
|
```
|
|
84
104
|
|
|
85
|
-
|
|
105
|
+
## 8. Supported Countries
|
|
86
106
|
|
|
87
107
|
```ruby
|
|
88
108
|
arr = client.countries
|
|
89
109
|
puts "Supported Countries: #{arr}"
|
|
90
110
|
```
|
|
91
111
|
|
|
92
|
-
|
|
112
|
+
## 9. Order Residential Proxies
|
|
93
113
|
|
|
94
114
|
```ruby
|
|
95
115
|
order = client.order_static_residential_proxy(
|
|
@@ -99,13 +119,47 @@ order = client.order_static_residential_proxy(
|
|
|
99
119
|
)
|
|
100
120
|
```
|
|
101
121
|
|
|
102
|
-
|
|
122
|
+
## 10. Order Proxies
|
|
103
123
|
|
|
104
124
|
```ruby
|
|
105
125
|
order.proxies
|
|
106
126
|
```
|
|
107
127
|
|
|
108
|
-
|
|
128
|
+
## 11. Order Expenses
|
|
129
|
+
|
|
130
|
+
```ruby
|
|
131
|
+
puts "Total Price: #{order.total_price} USD"
|
|
132
|
+
# => "Total Price: 3.39 USD"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 12. Proxies of an Old Order
|
|
136
|
+
|
|
137
|
+
```ruby
|
|
138
|
+
# Get proxies for an order by Order ID
|
|
139
|
+
proxies = client.order_proxies("019b85aa-7e12-7b10-a26e-46fc5adfdcf4")
|
|
140
|
+
proxies.each do |p|
|
|
141
|
+
puts "Proxy #{p.id}: #{p.ip}:#{p.port}"
|
|
142
|
+
end
|
|
143
|
+
# => Proxy 1742085: 176.46.143.42:45842
|
|
144
|
+
# => ...
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 13. Using Multiple Credentials
|
|
148
|
+
|
|
149
|
+
```ruby
|
|
150
|
+
...
|
|
151
|
+
|
|
152
|
+
# Reset the client connection
|
|
153
|
+
ProxyCheapClient::Client.reset_connection
|
|
154
|
+
|
|
155
|
+
# Initialize the client with other API credentials.
|
|
156
|
+
client = ProxyCheapClient::Client.new(
|
|
157
|
+
api_key: PROXY_CHEAP_API_KEY,
|
|
158
|
+
api_secret: PROXY_CHEAP_API_SECRET
|
|
159
|
+
)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## 14. Error Handling
|
|
109
163
|
|
|
110
164
|
The client raises specific exceptions for failure modes:
|
|
111
165
|
|
|
@@ -130,7 +184,7 @@ rescue ProxyCheapClient::Error => e
|
|
|
130
184
|
end
|
|
131
185
|
```
|
|
132
186
|
|
|
133
|
-
|
|
187
|
+
## 15. Publishing
|
|
134
188
|
|
|
135
189
|
Build and push to RubyGems:
|
|
136
190
|
|
|
@@ -141,13 +195,13 @@ gem push proxy-cheap-client-#{ProxyCheapClient::VERSION}.gem
|
|
|
141
195
|
|
|
142
196
|
Make sure you have an account on RubyGems.org and appropriate credentials configured in `~/.gem/credentials`.
|
|
143
197
|
|
|
144
|
-
|
|
198
|
+
## 16. Contributing
|
|
145
199
|
|
|
146
200
|
1. Fork the repository.
|
|
147
201
|
2. Create a feature branch: `git checkout -b feature/xyz`
|
|
148
202
|
3. Run tests (add test suite if missing).
|
|
149
203
|
4. Open a pull request with a clear description.
|
|
150
204
|
|
|
151
|
-
|
|
205
|
+
## 17. License
|
|
152
206
|
|
|
153
207
|
This project is licensed under the MIT License. See `LICENSE.txt` for details.
|
|
@@ -12,6 +12,10 @@ module ProxyCheapClient
|
|
|
12
12
|
class Client < Base
|
|
13
13
|
API_BASE = "https://api.proxy-cheap.com"
|
|
14
14
|
|
|
15
|
+
def self.reset_connection
|
|
16
|
+
@@conn = nil
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
# Initialize the client with API credentials.
|
|
16
20
|
# @param api_key [String] API key (or set PROXY_CHEAP_API_KEY env var)
|
|
17
21
|
# @param api_secret [String] API secret (or set PROXY_CHEAP_API_SECRET env var)
|
|
@@ -21,13 +25,15 @@ module ProxyCheapClient
|
|
|
21
25
|
api_secret:,
|
|
22
26
|
timeout: 10
|
|
23
27
|
)
|
|
28
|
+
raise "Client already initialized" if defined?(@@conn) && @@conn
|
|
29
|
+
|
|
24
30
|
@api_key = api_key
|
|
25
31
|
@api_secret = api_secret
|
|
26
32
|
|
|
27
33
|
raise AuthenticationError, "API key missing" unless @api_key && !@api_key.strip.empty?
|
|
28
34
|
raise AuthenticationError, "API secret missing" unless @api_secret && !@api_secret.strip.empty?
|
|
29
35
|
|
|
30
|
-
|
|
36
|
+
@@conn = Faraday.new(url: API_BASE) do |f|
|
|
31
37
|
f.request :json
|
|
32
38
|
f.response :raise_error
|
|
33
39
|
f.options.timeout = timeout
|
|
@@ -40,10 +46,6 @@ module ProxyCheapClient
|
|
|
40
46
|
raise RequestError, "Connection failure: #{e.message}"
|
|
41
47
|
end
|
|
42
48
|
|
|
43
|
-
def conn
|
|
44
|
-
@conn
|
|
45
|
-
end
|
|
46
|
-
|
|
47
49
|
# retrieve the array of countries with number of available proxies per country
|
|
48
50
|
def countries
|
|
49
51
|
config = self.configuration(
|
|
@@ -61,7 +63,19 @@ module ProxyCheapClient
|
|
|
61
63
|
# @return [Balance]
|
|
62
64
|
def balance
|
|
63
65
|
resp = request(:get, "account/balance")
|
|
64
|
-
Balance.new(resp
|
|
66
|
+
Balance.new(resp)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Get order proxies by order ID.
|
|
70
|
+
# @param order_id [String] Order ID
|
|
71
|
+
# @return [Array<Proxy>]
|
|
72
|
+
def order_proxies(order_id)
|
|
73
|
+
resp = request(:get, "orders/#{order_id}/proxies")
|
|
74
|
+
arr = []
|
|
75
|
+
resp.each do |p|
|
|
76
|
+
arr << ProxyCheapClient::Proxy.new(p)
|
|
77
|
+
end
|
|
78
|
+
arr
|
|
65
79
|
end
|
|
66
80
|
|
|
67
81
|
# Get all user proxies.
|
|
@@ -71,7 +85,8 @@ module ProxyCheapClient
|
|
|
71
85
|
# API may return proxies directly as an array or wrapped in a "data" key
|
|
72
86
|
proxy_list = resp.is_a?(Hash) && resp.key?("data") ? resp["data"] : resp
|
|
73
87
|
proxy_list = resp.is_a?(Hash) && resp.key?("proxies") ? resp["proxies"] : resp
|
|
74
|
-
|
|
88
|
+
proxy_list.select! { |h| h["connection"] && h["connection"]["publicIp"] } # static residential proxies always have publicIp
|
|
89
|
+
Array(proxy_list).map { |p| Proxy.new(p) }
|
|
75
90
|
end
|
|
76
91
|
|
|
77
92
|
# Convenience method to order a static residential proxy.
|
|
@@ -112,7 +127,7 @@ module ProxyCheapClient
|
|
|
112
127
|
# @return [Configuration]
|
|
113
128
|
def configuration(params = {})
|
|
114
129
|
resp = request(:post, "order/configuration", params)
|
|
115
|
-
Configuration.new(resp
|
|
130
|
+
Configuration.new(resp)
|
|
116
131
|
end # def configuration
|
|
117
132
|
|
|
118
133
|
# Execute an order with the given configuration.
|
|
@@ -126,7 +141,7 @@ module ProxyCheapClient
|
|
|
126
141
|
# "totalPrice"=>"3.39"}
|
|
127
142
|
|
|
128
143
|
# Return order model (API returns order descriptor including id/status)
|
|
129
|
-
Order.new(resp
|
|
144
|
+
Order.new(resp)
|
|
130
145
|
end # def order
|
|
131
146
|
end # class Client
|
|
132
147
|
end # module ProxyCheapClient
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
module ProxyCheapClient
|
|
2
2
|
#module Models
|
|
3
3
|
class Balance < Base
|
|
4
|
-
attr_reader :amount, :currency
|
|
4
|
+
attr_reader :amount, :currency
|
|
5
5
|
|
|
6
|
-
def initialize(attrs
|
|
6
|
+
def initialize(attrs)
|
|
7
7
|
@amount = attrs["balance"] || attrs["amount"]
|
|
8
8
|
@currency = attrs["currency"] || "USD"
|
|
9
|
-
@conn = client.conn
|
|
10
9
|
end
|
|
11
10
|
|
|
12
11
|
def to_h
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
module ProxyCheapClient
|
|
2
2
|
class Base
|
|
3
|
+
# Define a static class attribute `conn`
|
|
4
|
+
@@conn = nil
|
|
5
|
+
|
|
6
|
+
def conn
|
|
7
|
+
@@conn
|
|
8
|
+
end
|
|
9
|
+
|
|
3
10
|
# Make an HTTP request to the API.
|
|
4
11
|
# @note Some API endpoints (whitelist, extend-period, buy-bandwidth) use GET
|
|
5
12
|
# requests with JSON body, which is non-standard but matches the official API behavior.
|
|
6
|
-
def request(method, path, body = nil)
|
|
13
|
+
def self.request(method, path, body = nil)
|
|
7
14
|
response = case method.to_s.downcase.to_sym
|
|
8
15
|
when :get
|
|
9
16
|
if body
|
|
10
|
-
|
|
17
|
+
@@conn.get(path) { |r| r.body = body.to_json }
|
|
11
18
|
else
|
|
12
|
-
|
|
19
|
+
@@conn.get(path)
|
|
13
20
|
end
|
|
14
21
|
when :post
|
|
15
|
-
|
|
22
|
+
@@conn.post(path) { |r| r.body = body.to_json if body }
|
|
16
23
|
when :patch
|
|
17
|
-
|
|
24
|
+
@@conn.patch(path) { |r| r.body = body.to_json if body }
|
|
18
25
|
else
|
|
19
26
|
raise RequestError, "Unsupported HTTP method: #{method}"
|
|
20
27
|
end
|
|
@@ -50,13 +57,22 @@ module ProxyCheapClient
|
|
|
50
57
|
status_code: e.response&.dig(:status),
|
|
51
58
|
response_body: extract_error_body(e)
|
|
52
59
|
)
|
|
60
|
+
end # self.request
|
|
61
|
+
|
|
62
|
+
# Make an HTTP request to the API.
|
|
63
|
+
# @note Some API endpoints (whitelist, extend-period, buy-bandwidth) use GET
|
|
64
|
+
# requests with JSON body, which is non-standard but matches the official API behavior.
|
|
65
|
+
def request(method, path, body = nil)
|
|
66
|
+
self.class.request(method, path, body)
|
|
53
67
|
end # request
|
|
54
68
|
|
|
55
|
-
|
|
69
|
+
private
|
|
70
|
+
|
|
71
|
+
def self.extract_error_body(error)
|
|
56
72
|
error.response&.dig(:body)
|
|
57
|
-
end # extract_error_body
|
|
73
|
+
end # self.extract_error_body
|
|
58
74
|
|
|
59
|
-
def extract_error_message(error)
|
|
75
|
+
def self.extract_error_message(error)
|
|
60
76
|
body = extract_error_body(error)
|
|
61
77
|
return error.message unless body
|
|
62
78
|
|
|
@@ -66,9 +82,9 @@ module ProxyCheapClient
|
|
|
66
82
|
rescue JSON::ParserError
|
|
67
83
|
body
|
|
68
84
|
end
|
|
69
|
-
end # extract_error_message
|
|
85
|
+
end # self.extract_error_message
|
|
70
86
|
|
|
71
|
-
def parse_response(response)
|
|
87
|
+
def self.parse_response(response)
|
|
72
88
|
return {} if response.body.nil? || response.body.empty?
|
|
73
89
|
|
|
74
90
|
begin
|
|
@@ -82,6 +98,6 @@ module ProxyCheapClient
|
|
|
82
98
|
end
|
|
83
99
|
|
|
84
100
|
data
|
|
85
|
-
end # parse_response
|
|
101
|
+
end # self.parse_response
|
|
86
102
|
end # class Base
|
|
87
103
|
end # module ProxyCheapClient
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
module ProxyCheapClient
|
|
2
2
|
#module Models
|
|
3
3
|
class Configuration < Base
|
|
4
|
-
attr_reader :data, :price, :currency, :packages, :available
|
|
4
|
+
attr_reader :data, :price, :currency, :packages, :available
|
|
5
5
|
|
|
6
|
-
def initialize(attrs
|
|
6
|
+
def initialize(attrs)
|
|
7
7
|
@data = attrs
|
|
8
8
|
@price = attrs["price"] || attrs["totalPrice"]
|
|
9
9
|
@currency = attrs["currency"] || "USD"
|
|
10
10
|
@packages = attrs["packages"]
|
|
11
11
|
@available = attrs["available"]
|
|
12
|
-
@conn = client.conn
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
def to_h
|
|
@@ -6,11 +6,10 @@ module ProxyCheapClient
|
|
|
6
6
|
#:status,
|
|
7
7
|
#:proxies,
|
|
8
8
|
#:created_at,
|
|
9
|
-
:total_price
|
|
9
|
+
:total_price
|
|
10
10
|
#:currency,
|
|
11
|
-
:conn
|
|
12
11
|
|
|
13
|
-
def initialize(attrs
|
|
12
|
+
def initialize(attrs)
|
|
14
13
|
@data = attrs
|
|
15
14
|
@id = attrs["id"] || attrs["orderId"]
|
|
16
15
|
#@status = attrs["status"]
|
|
@@ -18,7 +17,6 @@ module ProxyCheapClient
|
|
|
18
17
|
#@created_at = attrs["createdAt"] || attrs["created_at"]
|
|
19
18
|
@total_price = attrs["totalPrice"] || attrs["total_price"]
|
|
20
19
|
#@currency = attrs["currency"]
|
|
21
|
-
@conn = client.conn
|
|
22
20
|
end # initialize
|
|
23
21
|
|
|
24
22
|
def to_h
|
|
@@ -4,9 +4,9 @@ module ProxyCheapClient
|
|
|
4
4
|
attr_reader :data, :id, :ip, :port, :type, :expires_at,
|
|
5
5
|
#:auto_renew, :auto_extend,
|
|
6
6
|
:country, :isp, :username, :password, :protocol, :bandwidth_limit,
|
|
7
|
-
:bandwidth_used, :status
|
|
7
|
+
:bandwidth_used, :status
|
|
8
8
|
|
|
9
|
-
def initialize(attrs
|
|
9
|
+
def initialize(attrs)
|
|
10
10
|
@data = attrs
|
|
11
11
|
@id = attrs["id"]
|
|
12
12
|
@ip = attrs["ip"] || attrs["host"] || (attrs["connection"] && attrs["connection"]['connectIp'])
|
|
@@ -16,14 +16,13 @@ module ProxyCheapClient
|
|
|
16
16
|
#@auto_renew = attrs["autoRenew"] || attrs["auto_renew"] || attrs["isAutoExtendEnabled"]
|
|
17
17
|
#@auto_extend = attrs["isAutoExtendEnabled"] || attrs["autoExtend"]
|
|
18
18
|
@country = attrs["countryCode"]
|
|
19
|
-
isp = attrs["metadata"]['ispName']
|
|
19
|
+
@isp = attrs["metadata"]['ispName']
|
|
20
20
|
@username = attrs["username"] || (attrs["authentication"] && attrs["authentication"]['username'])
|
|
21
21
|
@password = attrs["password"] || (attrs["authentication"] && attrs["authentication"]['password'])
|
|
22
22
|
@protocol = attrs["protocol"] || attrs["proxyProtocol"] || attrs["proxyType"]
|
|
23
23
|
@bandwidth_limit = attrs["bandwidthLimit"] || attrs["bandwidth_limit"] || (attrs["bandwidth"] && attrs["bandwidth"]['total'])
|
|
24
24
|
@bandwidth_used = attrs["bandwidthUsed"] || attrs["bandwidth_used"] || (attrs["bandwidth"] && attrs["bandwidth"]['used'])
|
|
25
25
|
@status = attrs["status"]
|
|
26
|
-
@conn = client.conn
|
|
27
26
|
end # def initialize
|
|
28
27
|
|
|
29
28
|
def to_h
|
|
@@ -45,36 +44,7 @@ module ProxyCheapClient
|
|
|
45
44
|
status: status
|
|
46
45
|
}
|
|
47
46
|
end # to_h
|
|
48
|
-
=begin
|
|
49
|
-
# Change whitelisted IPs for a proxy.
|
|
50
|
-
# @note The official API uses GET with request body for this operation.
|
|
51
|
-
# @param proxy_id [Integer] Proxy ID
|
|
52
|
-
# @param ips [Array<String>] List of IPs to whitelist
|
|
53
|
-
# @return [Hash] API response
|
|
54
|
-
def whitelist(proxy_id, ips = [])
|
|
55
|
-
request(:get, "proxies/#{proxy_id}/whitelist-ip", { ips: ips })
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# Extend a proxy period.
|
|
59
|
-
# @note The official API uses GET with request body for this operation.
|
|
60
|
-
# @param proxy_id [Integer] Proxy ID
|
|
61
|
-
# @param months [Integer] Number of months to extend (minimum 1)
|
|
62
|
-
# @return [Hash] API response
|
|
63
|
-
def extend_period(proxy_id, months)
|
|
64
|
-
raise ArgumentError, "You must extend for at least 1 month" unless months && months >= 1
|
|
65
|
-
request(:get, "proxies/#{proxy_id}/extend-period", { periodInMonths: months })
|
|
66
|
-
end
|
|
67
47
|
|
|
68
|
-
# Buy additional bandwidth for a proxy.
|
|
69
|
-
# @note The official API uses GET with request body for this operation.
|
|
70
|
-
# @param proxy_id [Integer] Proxy ID
|
|
71
|
-
# @param bandwidth_gb [Integer] Amount of bandwidth in GB (minimum 1)
|
|
72
|
-
# @return [Hash] API response
|
|
73
|
-
def buy_bandwidth(proxy_id, bandwidth_gb)
|
|
74
|
-
raise ArgumentError, "You must buy at least 1 GB" unless bandwidth_gb && bandwidth_gb >= 1
|
|
75
|
-
request(:get, "proxies/#{proxy_id}/buy-bandwidth", { bandwidth: bandwidth_gb })
|
|
76
|
-
end
|
|
77
|
-
=end
|
|
78
48
|
# Get info on a specific proxy.
|
|
79
49
|
# @param proxy_id [Integer] Proxy ID
|
|
80
50
|
# @return [Proxy]
|
|
@@ -82,27 +52,7 @@ module ProxyCheapClient
|
|
|
82
52
|
resp = request(:get, "proxies/#{proxy_id}")
|
|
83
53
|
Proxy.new(resp)
|
|
84
54
|
end # proxy
|
|
85
|
-
=begin
|
|
86
|
-
def auto_extend?
|
|
87
|
-
!!@data.dig("autoExtend", "isEnabled")
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def get_name
|
|
91
|
-
@data["name"]
|
|
92
|
-
end
|
|
93
55
|
|
|
94
|
-
def set_name(name)
|
|
95
|
-
response = @conn.patch("proxies/#{@data['id']}") do |req|
|
|
96
|
-
req.headers['Content-Type'] = 'application/json'
|
|
97
|
-
req.body = { name: name }.to_json
|
|
98
|
-
end
|
|
99
|
-
if response.success?
|
|
100
|
-
@data["name"] = name
|
|
101
|
-
else
|
|
102
|
-
raise "Failed to set proxy name (HTTP #{response.status})"
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
=end
|
|
106
56
|
# Enable auto-extend for a proxy.
|
|
107
57
|
# @param proxy_id [Integer] Proxy ID
|
|
108
58
|
# @return [Hash] API response
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: proxy-cheap-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Leandro Sardi
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|