Class: Loopiator::Client
- Inherits:
-
Object
- Object
- Loopiator::Client
- Defined in:
- lib/loopiator/client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #call(rpc_method, *args) ⇒ Object
-
#initialize(connection_options = {}) ⇒ Client
constructor
A new instance of Client.
- #parse_status_response(response) ⇒ Object
- #set_client(connection_options = {}) ⇒ Object
Methods included from Credits
#get_credits_amount, #pay_invoice_using_credits
Methods included from Domains
#domain_is_free, #get_domain, #get_domains, #order_domain, #purchase_domain
Methods included from Logger
Constructor Details
#initialize(connection_options = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 |
# File 'lib/loopiator/client.rb', line 10 def initialize( = {}) .symbolize_keys! set_client() end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/loopiator/client.rb', line 6 def client @client end |
Instance Method Details
#call(rpc_method, *args) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/loopiator/client.rb', line 21 def call(rpc_method, *args) response = nil begin response = self.client.call(rpc_method, Loopiator.configuration.username, Loopiator.configuration.password, *args) rescue EOFError => eof_error raise Loopiator::ConnectionError end return response end |
#parse_status_response(response) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/loopiator/client.rb', line 34 def parse_status_response(response) response = response.downcase.to_sym case response when :ok then return response when :domain_occupied then return response when :auth_error then raise Loopiator::AuthError when :rate_limited then raise Loopiator::RateLimitError when :bad_indata then raise Loopiator::InvalidParameterError when :unknown_error then raise Loopiator::UnknownError else return response end end |
#set_client(connection_options = {}) ⇒ Object
15 16 17 18 19 |
# File 'lib/loopiator/client.rb', line 15 def set_client( = {}) self.client = XMLRPC::Client.new_from_hash(()) enable_debugging if Loopiator.configuration.debug () end |