Class: Inngest::Client
- Inherits:
-
Object
- Object
- Inngest::Client
- Defined in:
- lib/inngest.rb
Constant Summary collapse
- API_ENDPOINT =
"https://inn.gs"- HEADERS =
{ 'Content-Type' => 'application/json', 'User-Agent' => 'inngest-ruby-sdk/0.0.1', }
Instance Method Summary collapse
-
#initialize(inngest_key, endpoint = API_ENDPOINT) ⇒ Client
constructor
A new instance of Client.
- #send(event) ⇒ Object
Constructor Details
#initialize(inngest_key, endpoint = API_ENDPOINT) ⇒ Client
14 15 16 17 18 19 |
# File 'lib/inngest.rb', line 14 def initialize(inngest_key, endpoint = API_ENDPOINT) raise InngestException.new "Inngest Key can't be nil" if inngest_key.nil? @url = "#{endpoint}/e/#{inngest_key}" @http = http_client @url end |
Instance Method Details
#send(event) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/inngest.rb', line 21 def send(event) raise InngestException.new "Event can't be nil" if event.nil? event = Event.new(**event) if event.is_a? Hash raise InngestException.new "Can't construct Event" unless event.is_a? Event event.validate request = Net::HTTP::Post.new(@url, HEADERS) request.body = event.payload.to_json @http.request(request) end |