Class: ProxyCheapClient::Proxy
- Defined in:
- lib/proxy_cheap_client/models/proxy.rb
Overview
module Models
Instance Attribute Summary collapse
-
#bandwidth_limit ⇒ Object
readonly
Returns the value of attribute bandwidth_limit.
-
#bandwidth_used ⇒ Object
readonly
Returns the value of attribute bandwidth_used.
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#isp ⇒ Object
readonly
Returns the value of attribute isp.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
-
.load(proxy_id) ⇒ Proxy
Get info on a specific proxy.
Instance Method Summary collapse
-
#disable_auto_extend ⇒ Hash
Disable auto-extend for a proxy.
-
#enable_auto_extend ⇒ Hash
Enable auto-extend for a proxy.
-
#initialize(attrs = {}, client) ⇒ Proxy
constructor
A new instance of Proxy.
-
#to_h ⇒ Object
def initialize.
Methods inherited from Base
#extract_error_body, #extract_error_message, #parse_response, #request
Constructor Details
#initialize(attrs = {}, client) ⇒ Proxy
Returns a new instance of Proxy.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 9 def initialize(attrs = {}, client) @data = attrs @id = attrs["id"] @ip = attrs["ip"] || attrs["host"] || (attrs["connection"] && attrs["connection"]['connectIp']) @port = attrs["port"] || (attrs["connection"] && attrs["connection"]['httpPort']) @type = attrs["type"] || attrs["networkType"] || (attrs["connection"] && attrs["connection"]['ipVersion']) @expires_at = attrs["expiresAt"] || attrs["expires_at"] #@auto_renew = attrs["autoRenew"] || attrs["auto_renew"] || attrs["isAutoExtendEnabled"] #@auto_extend = attrs["isAutoExtendEnabled"] || attrs["autoExtend"] @country = attrs["countryCode"] isp = attrs["metadata"]['ispName'] @username = attrs["username"] || (attrs["authentication"] && attrs["authentication"]['username']) @password = attrs["password"] || (attrs["authentication"] && attrs["authentication"]['password']) @protocol = attrs["protocol"] || attrs["proxyProtocol"] || attrs["proxyType"] @bandwidth_limit = attrs["bandwidthLimit"] || attrs["bandwidth_limit"] || (attrs["bandwidth"] && attrs["bandwidth"]['total']) @bandwidth_used = attrs["bandwidthUsed"] || attrs["bandwidth_used"] || (attrs["bandwidth"] && attrs["bandwidth"]['used']) @status = attrs["status"] @conn = client.conn end |
Instance Attribute Details
#bandwidth_limit ⇒ Object (readonly)
Returns the value of attribute bandwidth_limit.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def bandwidth_limit @bandwidth_limit end |
#bandwidth_used ⇒ Object (readonly)
Returns the value of attribute bandwidth_used.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def bandwidth_used @bandwidth_used end |
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def conn @conn end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def country @country end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def data @data end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def expires_at @expires_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def id @id end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def ip @ip end |
#isp ⇒ Object (readonly)
Returns the value of attribute isp.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def isp @isp end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def password @password end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def port @port end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def protocol @protocol end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def status @status end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def type @type end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
4 5 6 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4 def username @username end |
Class Method Details
.load(proxy_id) ⇒ Proxy
Get info on a specific proxy.
81 82 83 84 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 81 def self.load(proxy_id) resp = request(:get, "proxies/#{proxy_id}") Proxy.new(resp) end |
Instance Method Details
#disable_auto_extend ⇒ Hash
Disable auto-extend for a proxy.
117 118 119 120 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 117 def disable_auto_extend() proxy_id = self.id request(:post, "proxies/#{proxy_id}/auto-extend/disable") end |
#enable_auto_extend ⇒ Hash
Enable auto-extend for a proxy.
109 110 111 112 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 109 def enable_auto_extend() proxy_id = self.id request(:post, "proxies/#{proxy_id}/auto-extend/enable") end |
#to_h ⇒ Object
def initialize
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/proxy_cheap_client/models/proxy.rb', line 29 def to_h { id: id, ip: ip, port: port, type: type, expires_at: expires_at, #auto_renew: auto_renew, #auto_extend: auto_extend, country: country, isp: isp, username: username, password: password, protocol: protocol, bandwidth_limit: bandwidth_limit, bandwidth_used: bandwidth_used, status: status } end |