Class: Alula::Client
Constant Summary collapse
- DEFAULT_CUSTOM_OPTIONS =
{ omitRelationships: true }.freeze
Class Method Summary collapse
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
- .request(http_method, resource_path, filters = {}, opts = {}) ⇒ Object
Class Method Details
.config ⇒ Object
12 13 14 |
# File 'lib/alula/client.rb', line 12 def config @_config ||= Alula::ClientConfiguration.new end |
.configure {|config| ... } ⇒ Object
16 17 18 |
# File 'lib/alula/client.rb', line 16 def configure yield config if block_given? end |
.request(http_method, resource_path, filters = {}, opts = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/alula/client.rb', line 20 def request(http_method, resource_path, filters = {}, opts = {}) validate_request!(http_method, resource_path) unless resource_path.match(%r{^/public/v1}) request_opts = (http_method, resource_path, filters, opts) api_url = video_request?(resource_path) ? config.video_api_url : config.api_url request_resource_path = video_request?(resource_path) ? resource_path.gsub(%r{^/video}, '') : resource_path # TODO: Handle network failures response = make_request(http_method, api_url + request_resource_path, request_opts) begin resp = AlulaResponse.from_httparty_response(response) rescue JSON::ParserError # TODO: Should be able to send better info up with this raise 'Unable to decode JSON' end resp end |