Class: IletiMerkezi::Request

Inherits:
Object
  • Object
show all
Includes:
XmlBuilder
Defined in:
lib/ileti_merkezi/utils/request.rb

Overview

Request :reek:TooManyInstanceVariables { max_instance_variables: 6 }

Constant Summary

Constants included from XmlBuilder

XmlBuilder::XML_TAG

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XmlBuilder

#hash_to_xml

Constructor Details

#initialize(body: nil, payload: '', path: '') ⇒ Request

Returns a new instance of Request.



27
28
29
30
31
32
33
# File 'lib/ileti_merkezi/utils/request.rb', line 27

def initialize(body: nil, payload: '', path: '')
  @config  = IletiMerkezi.configuration
  @payload = payload
  @path    = path
  @body    = body
  @uri     = URI.parse(@config.endpoint + @path)
end

Instance Attribute Details

#uri=(value) ⇒ Object

:reek:Attribute



25
26
27
# File 'lib/ileti_merkezi/utils/request.rb', line 25

def uri=(value)
  @uri = value
end

Instance Method Details

#callObject



35
36
37
38
39
# File 'lib/ileti_merkezi/utils/request.rb', line 35

def call
  req      = Net::HTTP::Post.new(@uri.request_uri, DEFAULT_HEADERS)
  req.body = @body || body
  Response.new http.request(req)
end