Class: PdfServices::Client
- Inherits:
-
Object
- Object
- PdfServices::Client
- Defined in:
- lib/pdfservices/client.rb
Constant Summary collapse
- TOKEN_ENDPOINT =
'https://pdf-services-ue1.adobe.io/token'
- DEFAULT_TOKEN_DURATION =
86_399
Instance Attribute Summary collapse
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
Instance Method Summary collapse
-
#initialize(client_id = nil, client_secret = nil, access_token = nil) ⇒ Client
constructor
A new instance of Client.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(client_id = nil, client_secret = nil, access_token = nil) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 17 |
# File 'lib/pdfservices/client.rb', line 9 def initialize(client_id = nil, client_secret = nil, access_token = nil) @client_id = client_id @client_secret = client_secret @access_token = access_token @expires_at = Time.now + DEFAULT_TOKEN_DURATION valid_access_token? ? access_token : refresh_token validate_client @api = Api.new(@access_token, @client_id) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pdfservices/client.rb', line 19 def method_missing(method_name, *args, &block) operation_class_name = "PdfServices::#{camelize(method_name.to_s)}::Operation" if Object.const_defined? operation_class_name operation_class = Object.const_get operation_class_name operation = operation_class.new @api operation.execute(*args, &block) else super end end |
Instance Attribute Details
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
7 8 9 |
# File 'lib/pdfservices/client.rb', line 7 def expires_at @expires_at end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
30 31 32 33 |
# File 'lib/pdfservices/client.rb', line 30 def respond_to_missing?(method_name, include_private = false) operation_class_name = "PdfServices::#{camelize(method_name.to_s)}::Operation" Object.const_defined?(operation_class_name) || super end |