Class: RDStation::Events

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/rdstation/events.rb

Constant Summary collapse

EVENTS_ENDPOINT =
'https://api.rd.services/platform/events'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(authorization_header:) ⇒ Events



7
8
9
# File 'lib/rdstation/events.rb', line 7

def initialize(authorization_header:)
  @authorization_header = authorization_header
end

Instance Method Details

#create(payload) ⇒ Object



11
12
13
14
15
16
# File 'lib/rdstation/events.rb', line 11

def create(payload)
  response = self.class.post(EVENTS_ENDPOINT, headers: @authorization_header.to_h, body: payload.to_json)
  response_body = JSON.parse(response.body)
  return response_body unless errors?(response_body)
  RDStation::ErrorHandler.new(response).raise_error
end