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

#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

#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



75
76
77
# File 'lib/pheenix.rb', line 75

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

#list_current_marketplaceObject



91
92
93
# File 'lib/pheenix.rb', line 91

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



87
88
89
# File 'lib/pheenix.rb', line 87

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

#list_marketplaceObject



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

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

#list_won_marketplaceObject



79
80
81
# File 'lib/pheenix.rb', line 79

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