Class: Chronicle::ETL::RestLoader
- Defined in:
- lib/chronicle/etl/loaders/rest_loader.rb
Instance Attribute Summary
Attributes included from Chronicle::ETL::Registry::SelfRegistering
Instance Method Summary collapse
Methods inherited from Loader
Methods included from Chronicle::ETL::Registry::SelfRegistering
Methods included from Loaders::Helpers::EncodingHelper
Methods included from Configurable
Constructor Details
This class inherits a constructor from Chronicle::ETL::Loader
Instance Method Details
#load(payload) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/chronicle/etl/loaders/rest_loader.rb', line 20 def load(payload) uri = URI.parse("#{@config.hostname}#{@config.endpoint}") header = { 'Authorization' => "Bearer #{@config.access_token}", 'Content-Type': 'application/json' } use_ssl = uri.scheme == 'https' Net::HTTP.start(uri.host, uri.port, use_ssl: use_ssl) do |http| request = Net::HTTP::Post.new(uri.request_uri, header) request.body = payload.to_json http.request(request) end end |