Class: GodaddyApi::Client
- Inherits:
-
Object
- Object
- GodaddyApi::Client
- Defined in:
- lib/GodaddyApi/client.rb
Constant Summary collapse
- API_URL =
'https://api.godaddy.com'
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
-
#method_missing(name, *args, &block) ⇒ Object
This attaches resources to the client Resources map to a specific model.
- #resources ⇒ Object
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 |
# File 'lib/GodaddyApi/client.rb', line 9 def initialize() @key = [:key] @secret = [:secret] @resources = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
This attaches resources to the client Resources map to a specific model
37 38 39 40 41 42 43 44 |
# File 'lib/GodaddyApi/client.rb', line 37 def method_missing(name, *args, &block) if self.class.resources.keys.include?(name) resources[name] ||= self.class.resources[name].new(connection: connection) resources[name] else super end end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/GodaddyApi/client.rb', line 7 def key @key end |
Class Method Details
.resources ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/GodaddyApi/client.rb', line 21 def self.resources { images: ImageResource, keys: KeyResource, servers: ServerResource, limits: LimitResource, specs: SpecResource } end |
Instance Method Details
#connection ⇒ Object
15 16 17 18 19 |
# File 'lib/GodaddyApi/client.rb', line 15 def connection Faraday.new() do |req| req.adapter :net_http end end |
#resources ⇒ Object
31 32 33 |
# File 'lib/GodaddyApi/client.rb', line 31 def resources @resources ||= {} end |