| 1 | package WebService::MyGengo::Feedback; | ||
| 2 | |||
| 3 | use Moose; | ||
| 4 | use Moose::Util::TypeConstraints; | ||
| 5 | use namespace::autoclean; | ||
| 6 | |||
| 7 | BEGIN { extends 'WebService::MyGengo::Base' }; | ||
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | WebService::MyGengo::Feedback - A Feedback entry in the myGengo system. | ||
| 12 | |||
| 13 | =head1 SYNOPSIS | ||
| 14 | |||
| 15 | # Submit feedback | ||
| 16 | $client->approve_job( $job, 5, "Good Job", "Nice xlation", 1 ); | ||
| 17 | |||
| 18 | # Elsewhere... | ||
| 19 | my $fb = $client->get_job_feedback( $job->id ); | ||
| 20 | is( $fb->rating, "5.0" ); | ||
| 21 | is( $fb->for_translator, "Good Job" ); | ||
| 22 | |||
| 23 | =head1 ATTRIBUTES | ||
| 24 | |||
| 25 | =head2 rating (Num) | ||
| 26 | |||
| 27 | A decimal figure representing the rating for the translation between 0.0 and | ||
| 28 | 5.0. | ||
| 29 | |||
| 30 | =cut | ||
| 31 | has 'rating' => ( | ||
| 32 | is => 'ro' | ||
| 33 | , isa => 'WebService::MyGengo::Num' | ||
| 34 | , required => 1 | ||
| 35 | ); | ||
| 36 | |||
| 37 | =head2 for_translator (Str) | ||
| 38 | |||
| 39 | The comment that was left for the translator in UTF-8 encoding. | ||
| 40 | |||
| 41 | Sometimes the API returns 'null' (undef) for this value. In this case | ||
| 42 | the value will be coerced into an empty string. | ||
| 43 | |||
| 44 | =cut | ||
| 45 | subtype 'WebService::MyGengo::Feedback::for_translator' | ||
| 46 | , as 'Str'; | ||
| 47 | coerce 'WebService::MyGengo::Feedback::for_translator' | ||
| 48 | , from 'Undef', via { '' } ; | ||
| 49 | has 'for_translator' => ( | ||
| 50 | is => 'ro' | ||
| 51 | , isa => 'WebService::MyGengo::Feedback::for_translator' | ||
| 52 | , coerce => 1 | ||
| 53 | , required => 0 | ||
| 54 | ); | ||
| 55 | |||
| 56 | =head1 METHODS | ||
| 57 | =cut | ||
| 58 | |||
| 59 | #=head2 around BUILDARGS | ||
| 60 | # | ||
| 61 | #Allow single-argument constructor for `rating` | ||
| 62 | # | ||
| 63 | #=cut | ||
| 64 | around BUILDARGS => sub { | ||
| 65 | my ( $orig, $class, $val ) = ( @_ ); | ||
| 66 | ref($val) eq 'HASH' and return $val; | ||
| 67 | return { rating => $val }; | ||
| 68 | }; | ||
| 69 | |||
| 70 | |||
| 71 | __PACKAGE__->meta->make_immutable(); | ||
| 72 | |||
| 73 | 1; | ||
| 74 | |||
| 75 | =head2 SEE ALSO | ||
| 76 | |||
| 77 | L<WebService::MyGengo::Client> | ||
| 78 | |||
| 79 | L<http://mygengo.com/api/developer-docs/methods/translate-job-id-feedback-get/> | ||
| 80 | |||
| 81 | =head1 AUTHOR | ||
| 82 | |||
| 83 | Nathaniel Heinrichs | ||
| 84 | |||
| 85 | =head1 LICENSE | ||
| 86 | |||
| 87 | Copyright (c) 2011, Nathaniel Heinrichs <nheinric-at-cpan.org>. | ||
| 88 | All rights reserved. | ||
| 89 | |||
| 90 | This library is free software. You can redistribute it and/or modify | ||
| 91 | it under the same terms as Perl itself. | ||
| 92 | |||
| 93 | =cut |