Class: FuelSDK::ET_PostRest

Inherits:
ET_Constructor show all
Defined in:
lib/new.rb

Instance Attribute Summary

Attributes inherited from ET_Constructor

#code, #message, #moreResults, #request_id, #results, #status

Instance Method Summary collapse

Constructor Details

#initialize(authStub, endpoint, payload) ⇒ ET_PostRest

Returns a new instance of ET_PostRest.



855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
# File 'lib/new.rb', line 855

def initialize(authStub, endpoint, payload)
  authStub.refreshToken

  qs = {"access_token" => authStub.authToken}
  uri = URI.parse(endpoint)
  uri.query = URI.encode_www_form(qs)
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  request = Net::HTTP::Post.new(uri.request_uri)
  request.body =  payload.to_json
  request.add_field "Content-Type", "application/json"
  requestResponse = http.request(request)

  super(requestResponse, true)

end