Sha256: 420b23a67ea35e4a5cbeafc96e9702031e85c3b35d97d23fbcb2cf62b71fd58d
Contents?: true
Size: 1004 Bytes
Versions: 6
Compression:
Stored size: 1004 Bytes
Contents
module PartyBus class Client def self.post( entity_id: PartyBus.configuration.entity_id, path:, body: ) return { success: true } unless PartyBus.configuration.enabled response = HTTParty.post( "#{PartyBus.configuration.api_url}#{path}", body: body.to_json, default_timeout: 10, headers: headers, query: { entity_id: entity_id } ) parse_response(response) end def self.parse_response(response) if response.success? { success: true, serialized_result: response.parsed_response } else { success: false, errors: [response.parsed_response] } end end def self.headers { 'Accept': 'application/json', 'Authorization': authorization, 'Content-Type': 'application/json' } end def self.authorization "Bearer #{PartyBus.configuration.api_key}" end end end
Version data entries
6 entries across 6 versions & 1 rubygems