| 1 | package Marketplace::Rakuten::Order::Item; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | Marketplace::Rakuten::Order::Item. | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | =head1 DESCRIPTION | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | Class to handle the xml structures representing a orderline item. | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | This modules doesn't do much, it just provides an uniform iterface | ||||||||||||||||||||
| 12 | with other Marketplace modules. | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | All Markteplace::<provider>::Order::Item classes implement the | ||||||||||||||||||||
| 15 | following methods: | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | =over 4 | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | =item sku | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | =item quantity | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | =item price | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | =item subtotal | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | =item remote_shop_order_item | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | =item merchant_order_item | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | This one should be a read-write accessor, because usually Ebay doesn't | ||||||||||||||||||||
| 32 | know about it. | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | =back | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | =head1 ACCESSORS | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | =head2 struct | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | This hashref must be passed to the constructor, containing the XML | ||||||||||||||||||||
| 41 | structure. | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | =head2 order_number | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | The remote_shop_order_item is returned as the concatenation of the | ||||||||||||||||||||
| 46 | Rakuten's order number, a dash, and the item id. | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | Defaults to 'unknown'. | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =head1 OTHER SHORTCUTS | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | =cut | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 55 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 3 | ▶ | use Moo; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 58 | 3 | ▶ | use MooX::Types::MooseLike::Base qw(HashRef Str); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 59 | 3 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 60 | 3 | ▶ | use namespace::clean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 3 | has struct => (is => 'ro', isa => HashRef); | |||||||||||||||||||
| 63 | 3 | has merchant_order_item => (is => 'rw', isa => Str); | |||||||||||||||||||
| 64 | 0 | ▶ | has order_number => (is => 'ro', default => sub { 'unknown' }); | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | sub quantity { | ||||||||||||||||||||
| 67 | 0 | ▶ | return shift->struct->{qty} || 0; | ||||||||||||||||||
|
Subroutine
quantity: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/2
+(shift())->struct->{'qty'} || 0
MC/DC0%0/1
+(shift())->struct->{'qty'} || 0
+(shift())->struct->{'qty'}
Truth table0%0/2
A
A= +(shift())->struct->{'qty'}
| |||||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | =head2 remote_shop_order_item | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | It looks like the API just passes an id with the position: | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | item_id Integer ID der Bestell-Position | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | To be meaningful, the class will concatenate the order number with | ||||||||||||||||||||
| 77 | this. | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | =cut | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | sub remote_shop_order_item { | ||||||||||||||||||||
| 83 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
remote_shop_order_item: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 84 | 0 | return $self->order_number . '-' . $self->struct->{item_id}; | |||||||||||||||||||
| 85 | } | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | sub price { | ||||||||||||||||||||
| 88 | 0 | ▶ | return shift->struct->{price}; | ||||||||||||||||||
|
Subroutine
price: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | sub subtotal { | ||||||||||||||||||||
| 92 | 0 | ▶ | return shift->struct->{price_sum}; | ||||||||||||||||||
|
Subroutine
subtotal: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | =head2 rakuten_id | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | Either the variant id or the product id. You should have store the ids | ||||||||||||||||||||
| 98 | when uploading them, so you can use this id to look the real sku up | ||||||||||||||||||||
| 99 | and store it in the accessor. | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | =head2 variant_id | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | The rakuten variant id | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | =head2 product_id | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | The rakuten product id | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | =head2 sku | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | Rakuten's product_art_no. This appears to map to the actual variant's sku. | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | =cut | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | sub rakuten_id { | ||||||||||||||||||||
| 116 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
rakuten_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 117 | 0 | ▶ | return $self->variant_id || $self->product_id; | ||||||||||||||||||
|
Condition0%0/3
$self->variant_id || $self->product_id
MC/DC0%0/2
$self->variant_id || $self->product_id
$self->variant_id
$self->product_id
Truth table0%0/3
A || B
A= $self->variant_idB= $self->product_id
| |||||||||||||||||||||
| 118 | } | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | sub variant_id { | ||||||||||||||||||||
| 121 | 0 | ▶ | return shift->struct->{variant_id}; | ||||||||||||||||||
|
Subroutine
variant_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 122 | } | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | sub product_id { | ||||||||||||||||||||
| 125 | 0 | ▶ | return shift->struct->{product_id}; | ||||||||||||||||||
|
Subroutine
product_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 126 | } | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | sub sku { | ||||||||||||||||||||
| 129 | 0 | ▶ | return shift->struct->{product_art_no}; | ||||||||||||||||||
|
Subroutine
sku: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 130 | } | ||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | 3 | 1; | |||||||||||||||||||