36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/cf/input_format.rb', line 36
def initialize(options={})
@station = options[:station]
@line = options[:line]
@name = options[:name]
@required = options[:required]
@valid_type = options[:valid_type].nil? ? nil : options[:valid_type]
if !@station.nil? or !@line.nil?
line_title = @station.nil? ? @line.title : @station.line_title
if @valid_type
@resp = self.class.post("/lines/#{CF.account_name}/#{@line.title.downcase}/input_formats.json", :input_format => {:name => @name, :required => @required, :valid_type => @valid_type})
else
@resp = self.class.post("/lines/#{CF.account_name}/#{@line.title.downcase}/input_formats.json", :input_format => {:name => @name, :required => @required})
end
@resp.to_hash.each_pair do |k,v|
self.send("#{k}=",v) if self.respond_to?(k)
end
self.errors = @resp['error']['message'] if @resp['code'] != 200
@line_title = line_title
if !@station.nil? && @station.except.nil? && @station..nil?
@station.input_formats = self
else
@line.input_formats = self
end
end
end
|