Class: Pheenix::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/pheenix.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(login = {}) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
15
# File 'lib/pheenix.rb', line 8

def initialize( = {}) 
  @login = 
  @pheenix_host = "https://api.pheenix.com/"
  @curl_cookie = "/tmp/px_cookie" 
  @curl_verbose = false
  
  self
end

Instance Attribute Details

Returns the value of attribute curl_cookie.



6
7
8
# File 'lib/pheenix.rb', line 6

def curl_cookie
  @curl_cookie
end

#curl_verboseObject

Returns the value of attribute curl_verbose.



6
7
8
# File 'lib/pheenix.rb', line 6

def curl_verbose
  @curl_verbose
end

#loginObject

Returns the value of attribute login.



6
7
8
# File 'lib/pheenix.rb', line 6

def 
  @login
end

#pheenix_hostObject

Returns the value of attribute pheenix_host.



6
7
8
# File 'lib/pheenix.rb', line 6

def pheenix_host
  @pheenix_host
end

Instance Method Details

#add_backorders(config = {}) ⇒ Object



75
76
77
78
79
80
81
# File 'lib/pheenix.rb', line 75

def add_backorders(config = {}) 
   str = args("domains",config[:domains])
   if !config[:type].nil?
   		str = "#{str}&type=super_saver"
   end
   curl("#{pheenix_host}add_backorders/#{str}")  	
end

#args(name, args) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/pheenix.rb', line 40

def args(name, args ) 
	if args.class == Array
  args.each do |item|
     	i = 0 
			if i == 0
					str = "#{name}[0]=#{item}"
				else
					str = "#{str}&#{name}[#{i}]=#{item}"
			end
			i = i + 1
		end  
	else
		str = "#{name}=#{args}"
	end
end

#cancel_backorders(config = {}) ⇒ Object



83
84
85
86
# File 'lib/pheenix.rb', line 83

def cancel_backorders(config = {}) 
   str = args("domains",config[:domains])
   curl("#{pheenix_host}cancel_backorders/#{str}")  	
end

#curl(url) ⇒ Object

Return: array

Arguments:

string - url



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pheenix.rb', line 26

def curl(url)
  curl = Curl::Easy.new(url)
		  curl.follow_location = true
		  curl.enable_cookies = true
		  curl.verbose = curl_verbose
		  curl.cookiefile = curl_cookie
		  curl.cookiejar = curl_cookie
  #curl.perform 
  curl.http_get
  JSON.parse(curl.body_str)
end

#list_backordersObject



96
97
98
# File 'lib/pheenix.rb', line 96

def list_backorders
	curl("#{pheenix_host}list_backorders") 
end

#list_current_marketplaceObject



112
113
114
# File 'lib/pheenix.rb', line 112

def list_current_marketplace
	curl("#{pheenix_host}list_current_marketplace") 
end

#list_domains(config = {}) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/pheenix.rb', line 56

def list_domains(config = {}) 
	if !config[:all].nil? || config[:domains].nil?
		curl("#{pheenix_host}list_domains")
	else
		str = args("domains",config[:domains])
	end 
   	curl("#{pheenix_host}list_domains/#{str}")  
end

#list_lost_marketplaceObject



108
109
110
# File 'lib/pheenix.rb', line 108

def list_lost_marketplace
	curl("#{pheenix_host}list_lost_marketplace") 
end

#list_marketplaceObject



104
105
106
# File 'lib/pheenix.rb', line 104

def list_marketplace
	curl("#{pheenix_host}list_marketplace") 
end

#list_pending_deletes(config = {}) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/pheenix.rb', line 88

def list_pending_deletes(config = {}) 
	str = ''
	if !config[:day].nil?
		str = "/day=#{config[:day]}"
	end
	curl("#{pheenix_host}list_pending_deletes#{str}")
end

#list_won_marketplaceObject



100
101
102
# File 'lib/pheenix.rb', line 100

def list_won_marketplace
	curl("#{pheenix_host}list_won_marketplace") 
end

#pheenix_loginObject



17
18
19
# File 'lib/pheenix.rb', line 17

def 
	curl("#{pheenix_host}login/login=#{[:username]}&api_key=#{[:api_key]}")
end

#reseller_check_domains_availability(config = {}) ⇒ Object



65
66
67
68
# File 'lib/pheenix.rb', line 65

def reseller_check_domains_availability(config = {}) 
   str = args("domains",config[:domains])
   curl("#{pheenix_host}reseller_check_domains_availability/#{str}")  	
end

#reseller_register_domains(config = {}) ⇒ Object



70
71
72
73
# File 'lib/pheenix.rb', line 70

def reseller_register_domains(config = {}) 
   str = args("domains",config[:domains])
   curl("#{pheenix_host}reseller_register_domains/#{str}")  	
end