File Coverage

blib/lib/Business/Monzo/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::Monzo::Merchant;
2              
3             =head1 NAME
4              
5             Business::Monzo::Merchant
6              
7             =head1 DESCRIPTION
8              
9             A class for a Monzo merchant, extends L<Business::Monzo::Resource>
10              
11             =cut
12              
13 10     10   91 use strict;
  10         31  
  10         488  
14 10     10   79 use warnings;
  10         28  
  10         421  
15              
16 10     10   80 use Moo;
  10         31  
  10         105  
17             extends 'Business::Monzo::Resource';
18             with 'Business::Monzo::Utils';
19              
20 10     10   5339 use Types::Standard qw/ :all /;
  10         30  
  10         82  
21 10     10   688778 use Business::Monzo::Address;
  10         54  
  10         516  
22 10     10   113 use Business::Monzo::Exception;
  10         27  
  10         3215  
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::Monzo::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::Monzo::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::Monzo::Address']],
66             coerce => sub {
67              
68             my ( $args ) = @_;
69              
70             if ( ref ( $args ) eq 'HASH' ) {
71             $args = Business::Monzo::Address->new(
72             client => $Business::Monzo::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 94 Business::Monzo::Exception->throw({
103             message => "Monzo API does not currently support getting merchant data",
104             });
105             }
106              
107             =head1 SEE ALSO
108              
109             L<Business::Monzo>
110              
111             L<Business::Monzo::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-monzo
124              
125             =cut
126              
127             1;
128              
129             # vim: ts=4:sw=4:et