Business-CAMT/lib/Business/CAMT/Message.pod
=encoding utf8
=head1 NAME
Business::CAMT::Message - base class for messages
=head1 SYNOPSIS
my $camt = Business::CAMT->new(...);
my $msg = $camt->read(...);
my $msg = $camt->create(...);
$msg->write('file.xml');
print $msg->toPerl;
open my $fh, '>:raw', 'msg.json' and $fh->print($msg->toJSON);
=head1 DESCRIPTION
This module is the base class for objects which are able to interpret
the CAMT messages.
=head1 METHODS
=head2 Constructors
=over 4
=item $class-E<gt>B<fromData>(%options)
This method accepts the same C<%options> as N<new()>. All options
passed in are passed to that constructor.
=item $class-E<gt>B<new>(%options)
The data (probably read from a file) is wrapped into this class. When
C<data> is C<undef>, then C<undef> will be returned.
-Option --Default
camt <required>
data <required>
set <required>
version <required>
=over 2
=item camt => Business::CAMT object
=item data => HASH
=item set => STRING
=item version => STRING
=back
=back
=head2 Accessors
=over 4
=item $obj-E<gt>B<camt>()
Z<>
=item $obj-E<gt>B<set>()
Z<>
=item $obj-E<gt>B<version>()
Z<>
=back
=head2 Other
=over 4
=item $obj-E<gt>B<toJSON>(%options)
Returns JSON raw text (bytes, not characters) for the data. You may
save this to a file (explicitly use encoding ":raw"), or write
it to a database. The keys get sorted, to ensure a reproducable
result for regression tests.
-Option --Default
settings {pretty => 1, canonical => 1}
=over 2
=item settings => HASH
Pass the settings to the JSON generator object, see its manual page.
Provided settings will overrule the defaults.
=encoding utf-8
=back
=item $obj-E<gt>B<toPerl>()
Convert the HASH into Perl code, using Data::Dumper. This is
useful, because you do not want to include the hidden object
attributes in your output: this method hides that administration.
=item $obj-E<gt>B<write>($file, %options)
All C<%options> are passed to L<Business::CAMT::write()|Business::CAMT/"Read and Write messages">.
ยป example: for write
$msg->write($file);
$camt->write($file, $msg); # same
=back
=head1 SEE ALSO
This module is part of Business-CAMT version 0.14,
built on November 06, 2025. Website: F<http://perl.overmeer.net/CPAN/>
=head1 LICENSE
For contributors see file ChangeLog.
This software is copyright (c) 2024-2025 by Mark Overmeer.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.