Class: ProxyCheapClient::Proxy

Inherits:
Base
  • Object
show all
Defined in:
lib/proxy_cheap_client/models/proxy.rb

Overview

module Models

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_limitObject (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_usedObject (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

#connObject (readonly)

Returns the value of attribute conn.



4
5
6
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4

def conn
  @conn
end

#countryObject (readonly)

Returns the value of attribute country.



4
5
6
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4

def country
  @country
end

#dataObject (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_atObject (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

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4

def id
  @id
end

#ipObject (readonly)

Returns the value of attribute ip.



4
5
6
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4

def ip
  @ip
end

#ispObject (readonly)

Returns the value of attribute isp.



4
5
6
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4

def isp
  @isp
end

#passwordObject (readonly)

Returns the value of attribute password.



4
5
6
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4

def password
  @password
end

#portObject (readonly)

Returns the value of attribute port.



4
5
6
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4

def port
  @port
end

#protocolObject (readonly)

Returns the value of attribute protocol.



4
5
6
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4

def protocol
  @protocol
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4

def status
  @status
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/proxy_cheap_client/models/proxy.rb', line 4

def type
  @type
end

#usernameObject (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.

Parameters:

  • proxy_id (Integer)

    Proxy ID

Returns:



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_extendHash

Disable auto-extend for a proxy.

Parameters:

  • proxy_id (Integer)

    Proxy ID

Returns:

  • (Hash)

    API response



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_extendHash

Enable auto-extend for a proxy.

Parameters:

  • proxy_id (Integer)

    Proxy ID

Returns:

  • (Hash)

    API response



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_hObject

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