Class: ET::CreateWSDL

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

Direct Known Subclasses

Client

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ CreateWSDL

Returns a new instance of CreateWSDL.



3
4
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
33
# File 'lib/exact-target-api/create_wsdl.rb', line 3

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

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

    if createIt
      res = open(@wsdl).read
      File.open(p, 'w+') do |f|
        f.write(res)
      end
    end

    @status = response.code
  else
    @status = response.code
  end

end

Instance Method Details

#stringify_keys!(params) ⇒ Object



39
40
41
42
43
44
# File 'lib/exact-target-api/create_wsdl.rb', line 39

def stringify_keys!(params)
  params.keys.each do |key|
    params[key.to_s] = params.delete(key)
  end
  params
end

#symbolize_keys!(params) ⇒ Object



46
47
48
49
50
51
# File 'lib/exact-target-api/create_wsdl.rb', line 46

def symbolize_keys!(params)
  params.keys.each do |key|
    params[key.to_sym] = params.delete(key)
  end
  params
end

#wsdl_file(path) ⇒ Object



35
36
37
# File 'lib/exact-target-api/create_wsdl.rb', line 35

def wsdl_file(path)
  path + '/ExactTargetWSDL.xml'
end