Class: Rddd::Services::Transports::HttpJson

Inherits:
Object
  • Object
show all
Defined in:
lib/rddd/services/transports/http_json.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ HttpJson

Returns a new instance of HttpJson.



7
8
9
# File 'lib/rddd/services/transports/http_json.rb', line 7

def initialize(attributes)
  @endpoint = attributes[:endpoint]
end

Instance Method Details

#call(service_name, attributes) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/rddd/services/transports/http_json.rb', line 11

def call(service_name, attributes)
  JSON.parse(
    HTTPClient.new.post("#{@endpoint}#{service_name}", 
      :body => JSON.unparse(attributes), 
      :header => {'Content-Type' => 'application/json'}
    ).body
  )
end