| 1 | =encoding utf-8 | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Business::cXML::Characteristic - cXML product item characteristic | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use Business::cXML::Characteristic; | ||
| 10 | |||
| 11 | =head1 DESCRIPTION | ||
| 12 | |||
| 13 | Object representation of a cXML C<Characteristic>. | ||
| 14 | |||
| 15 | A group of one or more characteristics would specify a configurable product | ||
| 16 | item (for example with colors, sizes, etc.) | ||
| 17 | |||
| 18 | =head1 METHODS | ||
| 19 | |||
| 20 | See L<Business::cXML::Object/COMMON METHODS>. | ||
| 21 | |||
| 22 | =head1 PROPERTY METHODS | ||
| 23 | |||
| 24 | See L<Business::cXML::Object/PROPERTY METHODS> for how the following operate. | ||
| 25 | |||
| 26 | =over | ||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | use 5.014; | ||
| 31 | use strict; | ||
| 32 | |||
| 33 | package Business::cXML::Characteristic; | ||
| 34 | use base qw(Business::cXML::Object); | ||
| 35 | |||
| 36 | use constant NODENAME => 'Characteristic'; | ||
| 37 | use constant PROPERTIES => ( | ||
| 38 | domain => 'size', | ||
| 39 | value => '', | ||
| 40 | code => undef, | ||
| 41 | ); | ||
| 42 | |||
| 43 | use XML::LibXML::Ferry; | ||
| 44 | |||
| 45 | sub from_node { | ||
| 46 | my ($self, $el) = @_; | ||
| 47 | $el->ferry($self); | ||
| 48 | } | ||
| 49 | |||
| 50 | sub to_node { | ||
| 51 | my ($self, $doc) = @_; | ||
| 52 | return $doc->create($self->{_nodeName}, undef, | ||
| 53 | domain => $self->{domain}, | ||
| 54 | value => $self->{value}, | ||
| 55 | code => $self->{code}, | ||
| 56 | ); | ||
| 57 | } | ||
| 58 | |||
| 59 | =item C<B<domain>> | ||
| 60 | |||
| 61 | Mandatory, type of characteristic. For example: C<size> (default), | ||
| 62 | C<sizeCode>, C<color>, C<colorCode>, C<grade>, etc. | ||
| 63 | |||
| 64 | =item C<B<value>> | ||
| 65 | |||
| 66 | Mandatory, value for the domain. For example: a size C<70>. | ||
| 67 | |||
| 68 | =item C<B<code>> | ||
| 69 | |||
| 70 | Optional, additional information such as currency code or unit of measure. | ||
| 71 | For example, size 70 C<cm>. | ||
| 72 | |||
| 73 | =back | ||
| 74 | |||
| 75 | =head1 AUTHOR | ||
| 76 | |||
| 77 | Stéphane Lavergne L<https://github.com/vphantom> | ||
| 78 | |||
| 79 | =head1 ACKNOWLEDGEMENTS | ||
| 80 | |||
| 81 | Graph X Design Inc. L<https://www.gxd.ca/> sponsored this project. | ||
| 82 | |||
| 83 | =head1 COPYRIGHT & LICENSE | ||
| 84 | |||
| 85 | Copyright (c) 2017-2018 Stéphane Lavergne L<https://github.com/vphantom> | ||
| 86 | |||
| 87 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 88 | of this software and associated documentation files (the "Software"), to deal | ||
| 89 | in the Software without restriction, including without limitation the rights | ||
| 90 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 91 | copies of the Software, and to permit persons to whom the Software is | ||
| 92 | furnished to do so, subject to the following conditions: | ||
| 93 | |||
| 94 | The above copyright notice and this permission notice shall be included in all | ||
| 95 | copies or substantial portions of the Software. | ||
| 96 | |||
| 97 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 98 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 99 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 100 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 101 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 102 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 103 | SOFTWARE. | ||
| 104 | |||
| 105 | =cut | ||
| 106 | |||
| 107 | 1; |