Class: FuelSDK::ET_Post

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, objType, props = nil) ⇒ ET_Post

Returns a new instance of ET_Post.



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/new.rb', line 365

def initialize(authStub, objType, props = nil)
  @results = []

  begin
    authStub.refreshToken
    if props.is_a? Array then
      obj = {
        'Objects' => [],
        :attributes! => { 'Objects' => { 'xsi:type' => ('tns:' + objType) } }
      }
      props.each{ |p|
        obj['Objects'] << p
      }
    else
      obj = {
        'Objects' => props,
        :attributes! => { 'Objects' => { 'xsi:type' => ('tns:' + objType) } }
      }
    end

    response = authStub.auth.call(:create, :message => obj)

  ensure
    super(response)
    if @status then
      if @@body[:create_response][:overall_status] != "OK"
        @status = false
      end
      #@results = @@body[:create_response][:results]
      if !@@body[:create_response][:results].nil? then
        if !@@body[:create_response][:results].is_a? Hash then
          @results = @results + @@body[:create_response][:results]
        else
          @results.push(@@body[:create_response][:results])
        end
      end
    end
  end
end