blib/lib/WebService/Mattermost/V4/API/Object/User.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 10 | 20 | 50.0 |
branch | 0 | 6 | 0.0 |
condition | n/a | ||
subroutine | 3 | 8 | 37.5 |
pod | 0 | 1 | 0.0 |
total | 13 | 35 | 37.1 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package WebService::Mattermost::V4::API::Object::User; 2: 3: # ABSTRACT: A user item. 4: 5: use Moo; 6: use Types::Standard qw(ArrayRef Bool HashRef InstanceOf Int Maybe Str); 7: 8: extends 'WebService::Mattermost::V4::API::Object'; 9: with qw( 10: WebService::Mattermost::V4::API::Object::Role::ID 11: WebService::Mattermost::V4::API::Object::Role::Roles 12: WebService::Mattermost::V4::API::Object::Role::Timestamps 13: WebService::Mattermost::V4::API::Object::Role::APIMethods 14: ); 15: 16: ################################################################################ 17: 18: has [ qw( 19: allow_marketing 20: is_system_admin 21: is_system_user 22: ) ] => (is => 'ro', isa => Bool, lazy => 1, builder => 1); 23: 24: has [ qw( 25: auth_data 26: auth_service 27: email 28: first_name 29: last_name 30: locale 31: nickname 32: position 33: username 34: ) ] => (is => 'ro', isa => Maybe[Str], lazy => 1, builder => 1); 35: 36: has [ qw( 37: password_updated_at 38: picture_updated_at 39: ) ] => (is => 'ro', isa => Maybe[InstanceOf['DateTime']], lazy => 1, builder => 1); 40: 41: ################################################################################ 42: 43: sub BUILD { 44: my $self = shift; 45: 46: $self->api_resource_name('user'); 47: $self->set_available_api_methods([ qw( 48: generate_mfa_secret 49: get_profile_image 50: get_status 51: patch 52: set_profile_image 53: set_status 54: teams 55: update 56: update_active_status 57: update_authentication_method 58: update_mfa 59: update_password 60: update_roles 61: ) ]); 62: 63: return 1; 64: } 65: 66: ################################################################################ 67: 68: sub _build_allow_marketing { 69: my $self = shift; 70: 71: return $self->raw_data->{allow_marketing} ? 1 : 0; 72: } 73: 74: sub _build_is_system_admin { 75: my $self = shift; 76: 77: return $self->roles =~ /system_admin/ ? 1 : 0; 78: } 79: 80: sub _build_is_system_user { 81: my $self = shift; 82: 83: return $self->roles =~ /system_user/ ? 1 : 0; 84: } 85: 86: sub _build_password_updated_at { 87: my $self = shift; 88: 89: return $self->_from_epoch($self->raw_data->{last_password_update}); 90: } 91: 92: sub _build_picture_updated_at { 93: my $self = shift; 94: 95: return $self->_from_epoch($self->raw_data->{last_picture_update}); 96: } 97: 98: ################################################################################ 99: 100: 1; 101: 102: __END__ 103: 104: =pod 105: 106: =encoding UTF-8 107: 108: =head1 NAME 109: 110: WebService::Mattermost::V4::API::Object::User - A user item. 111: 112: =head1 VERSION 113: 114: version 0.28 115: 116: =head1 DESCRIPTION 117: 118: Object version of a Mattermost user. 119: 120: =head2 METHODS 121: 122: See matching methods in L<WebService::Mattermost::V4::API::Resource::User> for 123: full documentation. 124: 125: ID parameters are not required: 126: 127: my $response = $mattermost->api->user->get('ID-HERE')->item->get_status(); 128: 129: Is the same as: 130: 131: my $response = $mattermost->api->user->get_status('ID-HERE'); 132: 133: =over 4 134: 135: =item C<generate_mfa_secret()> 136: 137: =item C<get_profile_image()> 138: 139: =item C<get_status()> 140: 141: =item C<patch()> 142: 143: =item C<set_profile_image()> 144: 145: =item C<set_status()> 146: 147: =item C<teams()> 148: 149: =item C<update()> 150: 151: =item C<update_active_status()> 152: 153: =item C<update_authentication_method()> 154: 155: =item C<update_mfa()> 156: 157: =item C<update_password()> 158: 159: =item C<update_roles()> 160: 161: =back 162: 163: =head1 SEE ALSO 164: 165: =over 4 166: 167: =item L<WebService::Mattermost::V4::API::Resource::User> 168: 169: =item L<WebService::Mattermost::V4::API::Object::Role::ID> 170: 171: =item L<WebService::Mattermost::V4::API::Object::Role::Roles> 172: 173: =item L<WebService::Mattermost::V4::API::Object::Role::Timestamps> 174: 175: =back 176: 177: =head1 AUTHOR 178: 179: Mike Jones <mike@netsplit.org.uk> 180: 181: =head1 COPYRIGHT AND LICENSE 182: 183: This software is Copyright (c) 2020 by Mike Jones. 184: 185: This is free software, licensed under: 186: 187: The MIT (X11) License 188: 189: =cut 190: |