Class: Pheenix::Client
- Inherits:
-
Object
- Object
- Pheenix::Client
- Defined in:
- lib/pheenix.rb
Instance Attribute Summary collapse
-
#curl_cookie ⇒ Object
Returns the value of attribute curl_cookie.
-
#curl_verbose ⇒ Object
Returns the value of attribute curl_verbose.
-
#login ⇒ Object
Returns the value of attribute login.
-
#pheenix_host ⇒ Object
Returns the value of attribute pheenix_host.
Instance Method Summary collapse
- #args(name, args) ⇒ Object
-
#curl(url) ⇒ Object
Return: array.
-
#initialize(login = {}) ⇒ Client
constructor
A new instance of Client.
- #list_backorders ⇒ Object
- #list_current_marketplace ⇒ Object
- #list_domains(config = {}) ⇒ Object
- #list_lost_marketplace ⇒ Object
- #list_marketplace ⇒ Object
- #list_won_marketplace ⇒ Object
- #pheenix_login ⇒ Object
- #reseller_check_domains_availability(config = {}) ⇒ Object
- #reseller_register_domains(config = {}) ⇒ Object
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 = {}) @login = login @pheenix_host = "https://api.pheenix.com/" @curl_cookie = "/tmp/px_cookie" @curl_verbose = false pheenix_login self end |
Instance Attribute Details
#curl_cookie ⇒ Object
Returns the value of attribute curl_cookie.
6 7 8 |
# File 'lib/pheenix.rb', line 6 def @curl_cookie end |
#curl_verbose ⇒ Object
Returns the value of attribute curl_verbose.
6 7 8 |
# File 'lib/pheenix.rb', line 6 def curl_verbose @curl_verbose end |
#login ⇒ Object
Returns the value of attribute login.
6 7 8 |
# File 'lib/pheenix.rb', line 6 def login @login end |
#pheenix_host ⇒ Object
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. = true curl.verbose = curl_verbose curl. = curl. = #curl.perform curl.http_get JSON.parse(curl.body_str) end |
#list_backorders ⇒ Object
75 76 77 |
# File 'lib/pheenix.rb', line 75 def list_backorders curl("#{pheenix_host}list_backorders") end |
#list_current_marketplace ⇒ Object
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_marketplace ⇒ Object
87 88 89 |
# File 'lib/pheenix.rb', line 87 def list_lost_marketplace curl("#{pheenix_host}list_lost_marketplace") end |
#list_marketplace ⇒ Object
83 84 85 |
# File 'lib/pheenix.rb', line 83 def list_marketplace curl("#{pheenix_host}list_marketplace") end |
#list_won_marketplace ⇒ Object
79 80 81 |
# File 'lib/pheenix.rb', line 79 def list_won_marketplace curl("#{pheenix_host}list_won_marketplace") end |
#pheenix_login ⇒ Object
17 18 19 |
# File 'lib/pheenix.rb', line 17 def pheenix_login curl("#{pheenix_host}login/login=#{login[:username]}&api_key=#{login[: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 |