Class: MarketingCloudSDK::ET_CreateWSDL

Inherits:
Object
  • Object
show all
Defined in:
lib/new.rb

Direct Known Subclasses

ET_Client

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ET_CreateWSDL

Returns a new instance of ET_CreateWSDL.



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/new.rb', line 128

def initialize(path)
  # Get the header info for the correct wsdl
  response = HTTPI.head(@wsdl)
  if response and (response.code >= 200 and response.code <= 400) then
    header = response.headers
    # Check when the WSDL was last modified
    modifiedTime = Date.parse(header['last-modified'])
    p = path + '/ExactTargetWSDL.xml'
    # Check if a local file already exists
    if (File.file?(p) and File.readable?(p) and !File.zero?(p)) then
      createdTime = File.new(p).mtime.to_date

      # Check if the locally created WSDL older than the production WSDL
      if createdTime < modifiedTime then
        createIt = true
      else
        createIt = false
      end
    else
      createIt = true
    end

    if createIt then
      res = open(@wsdl).read
      File.open(p, 'w+') { |f|
        f.write(res)
      }
    end
    @status = response.code
  else
    @status = response.code
  end
end