Sha256: ecc0ce64192eb7980c3c7404016b0a2ba7b5e509c5602966e1cd911f46e10f24
Contents?: true
Size: 762 Bytes
Versions: 2
Compression:
Stored size: 762 Bytes
Contents
module RDStation class Events include HTTParty EVENTS_ENDPOINT = 'https://api.rd.services/platform/events'.freeze def initialize(auth_token) @auth_token = auth_token end def create(payload) response = self.class.post(EVENTS_ENDPOINT, headers: required_headers, body: payload.to_json) response_body = JSON.parse(response.body) return response_body unless errors?(response_body) RDStation::ErrorHandler.new(response).raise_errors end private def errors?(response_body) response_body.is_a?(Array) || response_body['errors'] end def required_headers { 'Authorization' => "Bearer #{@auth_token}", 'Content-Type' => 'application/json' } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rdstation-ruby-client-1.2.1 | lib/rdstation/events.rb |
rdstation-ruby-client-1.2.0 | lib/rdstation/events.rb |