File Coverage

blib/lib/Business/Mondo/Merchant.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 27 27 100.0


line stmt bran cond sub pod time code
1             package Business::Mondo::Merchant;
2              
3             =head1 NAME
4              
5             Business::Mondo::Merchant
6              
7             =head1 DESCRIPTION
8              
9             A class for a Mondo merchant, extends L<Business::Mondo::Resource>
10              
11             =cut
12              
13 10     10   42 use strict;
  10         14  
  10         257  
14 10     10   35 use warnings;
  10         10  
  10         206  
15              
16 10     10   29 use Moo;
  10         10  
  10         58  
17             extends 'Business::Mondo::Resource';
18             with 'Business::Mondo::Utils';
19              
20 10     10   2520 use Types::Standard qw/ :all /;
  10         13  
  10         47  
21 10     10   243097 use Business::Mondo::Address;
  10         25  
  10         316  
22 10     10   49 use Business::Mondo::Exception;
  10         8  
  10         2195  
23              
24             =head1 ATTRIBUTES
25              
26             The Merchant class has the following attributes (with their type).
27              
28             id (Str)
29             group_id (Str)
30             logo (Str)
31             emoji (Str)
32             name (Str)
33             category (Str)
34             online (Bool)
35             atm (Bool)
36             disable_feedback (Bool)
37             address (Business::Mondo::Address)
38             created (DateTime)
39             updated (DateTime)
40             metadata (HashRef)
41              
42             Note that if a HashRef or Str is passed to ->address it will be coerced
43             into a Business::Mondo::Address object. When a Str is passed to ->created
44             or ->updated these will be coerced to a DateTime object.
45              
46             =cut
47              
48             has [ qw/ id group_id logo emoji name category / ] => (
49             is => 'ro',
50             isa => Str,
51             );
52              
53             has [ qw/ metadata / ] => (
54             is => 'ro',
55             isa => HashRef,
56             );
57              
58             has [ qw/ online atm disable_feedback / ] => (
59             is => 'ro',
60             isa => Any,
61             );
62              
63             has address => (
64             is => 'ro',
65             isa => Maybe[InstanceOf['Business::Mondo::Address']],
66             coerce => sub {
67              
68             my ( $args ) = @_;
69              
70             if ( ref ( $args ) eq 'HASH' ) {
71             $args = Business::Mondo::Address->new(
72             client => $Business::Mondo::Resource::client,
73             %{ $args },
74             );
75             }
76              
77             return $args;
78             },
79             );
80              
81             has [ qw/ created updated / ] => (
82             is => 'ro',
83             isa => Maybe[InstanceOf['DateTime']],
84             coerce => sub {
85             my ( $args ) = @_;
86              
87             if ( ! ref( $args ) ) {
88             $args = DateTime::Format::DateParse->parse_datetime( $args );
89             }
90              
91             return $args;
92             },
93             );
94              
95             =head1 Operations on an merchant
96              
97             None at present
98              
99             =cut
100              
101             sub get {
102 1     1 1 54 Business::Mondo::Exception->throw({
103             message => "Mondo API does not currently support getting merchant data",
104             });
105             }
106              
107             =head1 SEE ALSO
108              
109             L<Business::Mondo>
110              
111             L<Business::Mondo::Resource>
112              
113             =head1 AUTHOR
114              
115             Lee Johnson - C<leejo@cpan.org>
116              
117             =head1 LICENSE
118              
119             This library is free software; you can redistribute it and/or modify it under
120             the same terms as Perl itself. If you would like to contribute documentation,
121             features, bug fixes, or anything else then please raise an issue / pull request:
122              
123             https://github.com/leejo/business-mondo
124              
125             =cut
126              
127             1;
128              
129             # vim: ts=4:sw=4:et