Class: ET::Constructor

Inherits:
Object
  • Object
show all
Defined in:
lib/exact-target-api/constructor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response = nil, rest = false) ⇒ Constructor

Returns a new instance of Constructor.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/exact-target-api/constructor.rb', line 5

def initialize(response = nil, rest = false)
  @results = []
  if !response.nil? && !rest
    envelope = response.hash[:envelope]
    @body = envelope[:body]

    if !response.soap_fault? || !response.http_error?
      @code = response.http.code
      @status = true
    elsif response.soap_fault?
      @code = response.http.code
      @message = @body[:fault][:faultstring]
      @status = false
    elsif response.http_error?
      @code = response.http.code
      @status = false
    end
  elsif (@code = response.code)

    @status = @code == "200"

    begin
      @results = JSON.parse(response.body)
    rescue
      @message = response.body
    end
  end
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



3
4
5
# File 'lib/exact-target-api/constructor.rb', line 3

def code
  @code
end

#messageObject

Returns the value of attribute message.



3
4
5
# File 'lib/exact-target-api/constructor.rb', line 3

def message
  @message
end

#moreResultsObject

Returns the value of attribute moreResults.



3
4
5
# File 'lib/exact-target-api/constructor.rb', line 3

def moreResults
  @moreResults
end

#request_idObject

Returns the value of attribute request_id.



3
4
5
# File 'lib/exact-target-api/constructor.rb', line 3

def request_id
  @request_id
end

#resultsObject

Returns the value of attribute results.



3
4
5
# File 'lib/exact-target-api/constructor.rb', line 3

def results
  @results
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/exact-target-api/constructor.rb', line 3

def status
  @status
end