Sha256: a3c5662111294aceef56b673cdcfc98629622b673c6082110e11b95e54194597
Contents?: true
Size: 1.26 KB
Versions: 56
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module PlatformSdk module DataPipeline # DataPipeline::Client class Client attr_reader :credentials, :conn def initialize(credentials) @credentials = credentials raise ArgumentError, "pipeline_host is required" if @credentials[:pipeline_host].nil? raise ArgumentError, "pipeline_username is required" if @credentials[:pipeline_username].nil? raise ArgumentError, "pipeline_password is required" if @credentials[:pipeline_password].nil? @conn = Faraday.new(url: "https://#{@credentials[:pipeline_host]}") do |faraday| faraday.request(:retry, retry_options) faraday.request(:authorization, :basic, @credentials[:pipeline_username], @credentials[:pipeline_password]) faraday.headers = headers faraday.response :raise_error faraday.adapter(:net_http) end end private def headers { "Content-Type" => "application/json" } end def retry_options { max: 3, interval: 0.05, interval_randomness: 0.5, backoff_factor: 2 } end public def post(message) @conn.post("messages", message.to_json) end end end end
Version data entries
56 entries across 56 versions & 1 rubygems