Class: MT::DataAPI::Client
- Inherits:
-
Object
- Object
- MT::DataAPI::Client
- Defined in:
- lib/mt/data_api/client.rb,
lib/mt/data_api/client/version.rb,
lib/mt/data_api/client/endpoint.rb,
lib/mt/data_api/client/api_request.rb,
lib/mt/data_api/client/endpoint_manager.rb
Overview
Movable Type Data API client for Ruby.
Defined Under Namespace
Classes: APIRequest, Endpoint, EndpointManager
Constant Summary collapse
- VERSION =
'0.0.3'.freeze
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
Instance Method Summary collapse
- #call(id, args = {}) ⇒ Object
- #endpoints ⇒ Object
-
#initialize(opts) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(opts) ⇒ Client
12 13 14 15 16 |
# File 'lib/mt/data_api/client.rb', line 12 def initialize(opts) opts = opts.symbolize_keys @access_token = opts.delete(:access_token) @endpoint_manager = EndpointManager.new(opts) end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
10 11 12 |
# File 'lib/mt/data_api/client.rb', line 10 def access_token @access_token end |
Instance Method Details
#call(id, args = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/mt/data_api/client.rb', line 18 def call(id, args = {}) id = id.to_s endpoint = @endpoint_manager.find_endpoint(id) return nil unless endpoint res = endpoint.call(@access_token, args) @access_token = res['accessToken'] if id == 'authenticate' @endpoint_manager.endpoints = res['items'] if id == 'list_endpoints' res end |
#endpoints ⇒ Object
28 29 30 |
# File 'lib/mt/data_api/client.rb', line 28 def endpoints @endpoint_manager.endpoints end |