lib/fuelsdk/objects.rb in fuelsdk-0.1.4 vs lib/fuelsdk/objects.rb in fuelsdk-0.1.5
- old
+ new
@@ -2,51 +2,51 @@
module Objects
module Soap
module Read
attr_accessor :filter
def get _id=nil
- client.soap_get _id||id, properties, filter
+ client.soap_get _id||id, Array.wrap(properties), filter
end
def info
client.soap_describe id
end
end
module CUD #create, update, delete
def post
- client.soap_post id, properties
+ client.soap_post id, Array.wrap(properties)
end
def patch
- client.soap_patch id, properties
+ client.soap_patch id, Array.wrap(properties)
end
def delete
- client.soap_delete id, properties
+ client.soap_delete id, Array.wrap(properties)
end
end
end
module Rest
module Read
def get
- client.rest_get id, properties
+ client.rest_get id, Array.wrap(properties)
end
end
module CUD
def post
- client.rest_post id, properties
+ client.rest_post id, Array.wrap(properties)
end
def patch
- client.rest_patch id, properties
+ client.rest_patch id, Array.wrap(properties)
end
def delete
- client.rest_delete id, properties
+ client.rest_delete id, Array.wrap(properties)
end
end
end
class Base
@@ -54,15 +54,10 @@
attr_reader :id
alias props= properties= # backward compatibility
alias authStub= client= # backward compatibility
- def properties
- @properties = [@properties].compact unless @properties.kind_of? Array
- @properties
- end
-
def id
self.class.id
end
class << self
@@ -165,14 +160,10 @@
include Objects::Soap::Read
def id
'DataExtensionField'
end
def get
- if filter and filter.kind_of? Hash and \
- filter.include? 'Property' and filter['Property'] == 'CustomerKey'
- filter['Property'] = 'DataExtension.CustomerKey'
- end
super
end
end
class Row < Objects::Base
@@ -262,11 +253,11 @@
# if they are going to use fields attribute properties should
# be a single DataExtension Defined in a Hash
raise 'Unable to handle muliple DataExtension definitions and a field definition'
end
- d.each do |de|
+ Array.wrap(d).each do |de|
if (explicit_fields(de) and (de['columns'] || de['fields'] || has_fields)) or
(de['columns'] and (de['fields'] || has_fields)) or
(de['fields'] and has_fields)
raise 'Fields are defined in too many ways. Please only define once.' # ahhh what, to do...
@@ -343,6 +334,76 @@
o.send :initialize, client, id, properties, filter
return o.get
end
end
end
+
+ class Post < Objects::Base
+ include Objects::Soap::CUD
+ attr_accessor :id
+
+ def initialize client, id, properties
+ self.properties = properties
+ self.client = client
+ self.id = id
+ end
+
+ def post
+ super
+ end
+
+ class << self
+ def new client, id, properties=nil
+ o = self.allocate
+ o.send :initialize, client, id, properties
+ return o.post
+ end
+ end
+ end
+
+ class Delete < Objects::Base
+ include Objects::Soap::CUD
+ attr_accessor :id
+
+ def initialize client, id, properties
+ self.properties = properties
+ self.client = client
+ self.id = id
+ end
+
+ def delete
+ super
+ end
+
+ class << self
+ def new client, id, properties=nil
+ o = self.allocate
+ o.send :initialize, client, id, properties
+ return o.delete
+ end
+ end
+ end
+
+ class Patch < Objects::Base
+ include Objects::Soap::CUD
+ attr_accessor :id
+
+ def initialize client, id, properties
+ self.properties = properties
+ self.client = client
+ self.id = id
+ end
+
+ def patch
+ super
+ end
+
+ class << self
+ def new client, id, properties=nil
+ o = self.allocate
+ o.send :initialize, client, id, properties
+ return o.patch
+ end
+ end
+ end
+
end