Class: Calendlyr::Client
- Inherits:
-
Object
- Object
- Calendlyr::Client
- Defined in:
- lib/calendlyr/client.rb
Constant Summary collapse
- BASE_URL =
"https://api.calendly.com"
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(token:) ⇒ Client
constructor
A new instance of Client.
-
#inspect ⇒ Object
Avoid returning #<Calendlyr::Client @token=“token” …>.
- #me(force_reload: false) ⇒ Object
-
#method_missing(method_name, *args, &block) ⇒ Object
Given a client.users, method_missing behaves like this: def users UsersResource.new(self) end.
- #organization ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(token:) ⇒ Client
Returns a new instance of Client.
7 8 9 |
# File 'lib/calendlyr/client.rb', line 7 def initialize(token:) @token = token end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/calendlyr/client.rb', line 24 def method_missing(method_name, *args, &block) resource_name = method_name.to_s.split("_").collect(&:capitalize).join + "Resource" if Calendlyr.const_defined?(resource_name) Calendlyr.const_get(resource_name).new(self) else super end end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
5 6 7 |
# File 'lib/calendlyr/client.rb', line 5 def token @token end |
Instance Method Details
#inspect ⇒ Object
Avoid returning #<Calendlyr::Client @token=“token” …>
40 41 42 |
# File 'lib/calendlyr/client.rb', line 40 def inspect "#<Calendlyr::Client>" end |
#me(force_reload: false) ⇒ Object
11 12 13 14 |
# File 'lib/calendlyr/client.rb', line 11 def me(force_reload: false) @me = nil if force_reload @me ||= users.me end |
#organization ⇒ Object
16 17 18 |
# File 'lib/calendlyr/client.rb', line 16 def organization me.organization end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
33 34 35 36 37 |
# File 'lib/calendlyr/client.rb', line 33 def respond_to_missing?(method_name, include_private = false) resource_name = method_name.to_s.split("_").collect(&:capitalize).join + "Resource" Calendlyr.const_defined?(resource_name) || super end |