Class: MarketingCloudSDK::ET_Patch

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_Patch

Returns a new instance of ET_Patch.



445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/new.rb', line 445

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(:update, :message => obj)

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