Business::UPS::Tracking::Role::Builder - Helper role


Business-UPS-Tracking documentation Contained in the Business-UPS-Tracking distribution.

Index


Code Index:

NAME

Top

Business::UPS::Tracking::Role::Builder - Helper role

DESCRIPTION

Top

This role provides methods that construct various objects (eg. Business::UPS::Tracking::Element::Address).

METHODS

Top

build_address

 my $address = $self->build_address($xpath_expression);

Turns an address xml node into a Business::UPS::Tracking::Element::Address object.

build_code

 my $address = $self->build_code($xpath_expression);

Turns an address xml node into a Business::UPS::Tracking::Element::Address object.

build_weight

 my $weight = $self->build_weight($xpath_expression);

Turns an weight xml node into a Business::UPS::Tracking::Element::Weight object.

build_referencenumber

 my $weight = $self->build_referencenumber($xpath_expression);

Turns an weight xml node into a Business::UPS::Tracking::Element::ReferenceNumber object.


Business-UPS-Tracking documentation Contained in the Business-UPS-Tracking distribution.
# ============================================================================
package Business::UPS::Tracking::Role::Builder;
# ============================================================================
use utf8;
use 5.0100;

use Moose::Role;
use strict; # Make cpants happy
#requires('xml');

use Business::UPS::Tracking::Element::Address;
use Business::UPS::Tracking::Element::Weight;
use Business::UPS::Tracking::Element::ReferenceNumber;
use Business::UPS::Tracking::Element::Code;

sub build_address {
    my ($self,$xpath) = @_;
    
    my $node = $self->xml->findnodes($xpath)->get_node(1);
    
    return 
        unless $node && ref $node;
        
    return Business::UPS::Tracking::Element::Address->new(
        xml => $node,
    );
}


sub build_code {
    my ($self,$xpath) = @_;
    
    my $node = $self->xml->findnodes($xpath)->get_node(1);
    
    return 
        unless $node && ref $node;
        
    return Business::UPS::Tracking::Element::Code->new(
        xml => $node,
    );
}

sub build_weight {
    my ($self,$xpath) = @_;
    
    my $node = $self->xml->findnodes($xpath)->get_node(1);
    
    return 
        unless $node && ref $node;
        
    return Business::UPS::Tracking::Element::Weight->new(
        xml => $node,
    );
}

sub build_referencenumber {
    my ($self,$xpath) = @_;
    
    my $node = $self->xml->findnodes($xpath)->get_node(1);
    
    return 
        unless $node && ref $node;
        
    return Business::UPS::Tracking::Element::ReferenceNumber->new(
        xml => $node,
    );
}

no Moose::Role;
1;