Sha256: 99135e84bd686c93d700a56d7ed05d0797b887bf89ba4c43d8b0e96a0cc8f12f
Contents?: true
Size: 992 Bytes
Versions: 50
Compression:
Stored size: 992 Bytes
Contents
# frozen_string_literal: true module PlatformSdk module Events # Event Platform Client class Client def initialize(base_url, auth_client, conn: nil) @auth_client = auth_client @base_url = base_url @conn = conn || build_connection end def send_event(event) send_message(event) end private def build_connection Faraday.new(@base_url) do |faraday| faraday.headers = headers faraday.adapter Faraday.default_adapter faraday.response :json, content_type: /\bjson$/, parser_options: { symbolize_names: true } faraday.response :raise_error end end def headers { 'Authorization': "Bearer #{@auth_client.auth_token}", 'Content-Type': "application/cloudevents+json; charset=utf-8" } end def send_message(message, path: 'events/v1/') @conn.post(path, message.to_json) end end end end
Version data entries
50 entries across 50 versions & 1 rubygems