Class: Ubersmith::Client
- Inherits:
-
Object
- Object
- Ubersmith::Client
- Includes:
- UrlMaker
- Defined in:
- lib/ubersmith/client.rb
Constant Summary collapse
- BASE_URL =
"https://ubersmith.twistage.com/api/2.0/"
Instance Method Summary collapse
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
- #method_missing(method, *args) ⇒ Object
Methods included from UrlMaker
#_escape, #append_url_param, #build_query_string, #build_url
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
23 24 25 26 27 |
# File 'lib/ubersmith/client.rb', line 23 def initialize() @config_file_path = [:config_file_path] @debug = [:debug] puts "debug: #{@debug}" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ubersmith/client.rb', line 29 def method_missing(method, *args) components = method.to_s.split('_', 2) raise "invalid method: #{method}" if components.length < 2 raise "invalid category: #{components[0]}" unless %w(uber client device order sales support).include?(components[0]) = args[0] if args ||= {} cache = .delete(:cache) cache = true if cache.nil? ret = do_get(build_url(BASE_URL, { :method => components[0] + '.' + components[1], }.merge()), :cache => cache) JSON.parse(ret)['data'] end |