You need to sign in to do that
Don't have an account?
Sfdc::Serializer
The guts of my sforce perl class is the serializer , it's sublcassed from XMLRPC which does most of the work, however the array,value,dateTime and hash need to be formed slightly different to pass to sforce.
here is the serializer package
#####################################
package Sfdc::Serializer;
@Sfdc::Serializer::ISA = qw(XMLRPC::Serializer) ;
sub new {
my $self = shift;
unless (ref $self) {
my $class = ref($self) || $self;
$self = $class->SUPER::new(
typelookup => {
base64 => [10, sub {$_[0] =~ /[^\x09\x0a\x0d\x20-\x7f]/}, 'as_base64'],
int => [20, sub {$_[0] =~ /^[+-]?\d+$/}, 'as_int'],
double => [30, sub {$_[0] =~ /^(-?(?:\d+(?:\.\d*)?|\.\d+|NaN|INF)|([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?)$/}, 'as_double'],
dateTime => [35, sub {$_[0] =~ /^\d{8}T\d\d:\d\d:\d\d$/}, 'as_dateTime1'],
string => [40, sub {1}, 'as_value'],
},
attr => {},
namespaces => {},
@_,
);
}
return $self;
}
sub as_value {
my $self = shift;
my($value, $name, $type, $attr) = @_;
return ['value', {}, $value];
}
sub encode_array {
my($self, $array) = @_;
return ['array', {},
[map {$self->encode_object($_)} @$array]
];
}
sub as_dateTime1 { my $self = shift;
my($value, $name, $type, $attr) = @_;
return ['dateTime.iso8601', {}, $value];
}
sub encode_hash {
my($self, $hash) = @_;
return ['struct', {}, [
map {
['member', {}, [['name', {}, $_], $self->encode_object($hash->{$_})]]
} keys %$hash
]];
}
1;
Thank you for providing this code!
My company has me working on an Sfdc module, which we're planning to release as open source. I've based my module on the code you posted here, some of which I also reused. Before I post my initial code here, I wanted to find out if the code you posted is under a license. Please email me at rjk-sforce@focalex.com and let me know.
Of course, I'd be happy to collaborate with other developers on writing a Perl implementation for Sforce.
thanks!
Ronald
This code is free to use and not covered under any license, or warrantee. Open source is nice...
post away !