| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # Licensed under the Upwork's API Terms of Use; | 
| 2 |  |  |  |  |  |  | # you may not use this file except in compliance with the Terms. | 
| 3 |  |  |  |  |  |  | # | 
| 4 |  |  |  |  |  |  | # Unless required by applicable law or agreed to in writing, software | 
| 5 |  |  |  |  |  |  | # distributed under the License is distributed on an "AS IS" BASIS, | 
| 6 |  |  |  |  |  |  | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
| 7 |  |  |  |  |  |  | # See the License for the specific language governing permissions and | 
| 8 |  |  |  |  |  |  | # limitations under the License. | 
| 9 |  |  |  |  |  |  | # | 
| 10 |  |  |  |  |  |  | # Author::    Maksym Novozhylov (mnovozhilov@upwork.com) | 
| 11 |  |  |  |  |  |  | # Copyright:: Copyright 2016(c) Upwork.com | 
| 12 |  |  |  |  |  |  | # License::   See LICENSE.txt and TOS - https://developers.upwork.com/api-tos.html | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | package Net::Upwork::API::Routers::Messages; | 
| 15 |  |  |  |  |  |  |  | 
| 16 | 2 |  |  | 2 |  | 70004 | use strict; | 
|  | 2 |  |  |  |  | 12 |  | 
|  | 2 |  |  |  |  | 61 |  | 
| 17 | 2 |  |  | 2 |  | 9 | use warnings; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 50 |  | 
| 18 | 2 |  |  | 2 |  | 422 | use parent "Net::Upwork::API"; | 
|  | 2 |  |  |  |  | 311 |  | 
|  | 2 |  |  |  |  | 9 |  | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 2 |  |  | 2 |  | 120 | use constant ENTRY_POINT => Net::Upwork::API::Client::ENTRY_POINT_API; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 1536 |  | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | =pod | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | =head1 NAME | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | Auth | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | =head1 FUNCTIONS | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | =over 4 | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | =item new($api) | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | Create a new object for accessing Auth API | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | B | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | $api | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | API object | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =cut | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | sub new { | 
| 45 | 0 |  |  | 0 | 1 |  | my ($class, $api) = @_; | 
| 46 | 0 |  |  |  |  |  | return Net::Upwork::API::init_router($class, $api, ENTRY_POINT); | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | =item get_rooms | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | Retrive rooms information | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | B | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | JSON response as a string | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | =cut | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | sub get_rooms { | 
| 60 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 61 | 0 |  |  |  |  |  | my $company = shift; | 
| 62 | 0 |  |  |  |  |  | my %params = @_; | 
| 63 |  |  |  |  |  |  |  | 
| 64 | 0 |  |  |  |  |  | return $self->client()->get("/messages/v3/" . $company . "/rooms", %params); | 
| 65 |  |  |  |  |  |  | } | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | =item get_room_details | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | Get a specific room information | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | B | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | JSON response as a string | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | =cut | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | sub get_room_details { | 
| 78 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 79 | 0 |  |  |  |  |  | my $company = shift; | 
| 80 | 0 |  |  |  |  |  | my $room_id = shift; | 
| 81 | 0 |  |  |  |  |  | my %params = @_; | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 0 |  |  |  |  |  | return $self->client()->get("/messages/v3/" . $company . "/rooms/" . $room_id, %params); | 
| 84 |  |  |  |  |  |  | } | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | =item get_room_messages | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | Get messages from a specific room | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | B | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | JSON response as a string | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | =cut | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | sub get_room_messages { | 
| 97 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 98 | 0 |  |  |  |  |  | my $company = shift; | 
| 99 | 0 |  |  |  |  |  | my $room_id = shift; | 
| 100 | 0 |  |  |  |  |  | my %params = @_; | 
| 101 |  |  |  |  |  |  |  | 
| 102 | 0 |  |  |  |  |  | return $self->client()->get("/messages/v3/" . $company . "/rooms/" . $room_id . "/stories", %params); | 
| 103 |  |  |  |  |  |  | } | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | =item get_room_by_offer | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | Get a specific room by offer ID | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | B | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | JSON response as a string | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | =cut | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | sub get_room_by_offer { | 
| 116 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 117 | 0 |  |  |  |  |  | my $company = shift; | 
| 118 | 0 |  |  |  |  |  | my $offer_id = shift; | 
| 119 | 0 |  |  |  |  |  | my %params = @_; | 
| 120 |  |  |  |  |  |  |  | 
| 121 | 0 |  |  |  |  |  | return $self->client()->get("/messages/v3/" . $company . "/rooms/offers/" + $offer_id, %params); | 
| 122 |  |  |  |  |  |  | } | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | =item get_room_by_application | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | Get a specific room by application ID | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | B | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | JSON response as a string | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | =cut | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | sub get_room_by_application { | 
| 135 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 136 | 0 |  |  |  |  |  | my $company = shift; | 
| 137 | 0 |  |  |  |  |  | my $application_id = shift; | 
| 138 | 0 |  |  |  |  |  | my %params = @_; | 
| 139 |  |  |  |  |  |  |  | 
| 140 | 0 |  |  |  |  |  | return $self->client()->get("/messages/v3/" . $company . "/rooms/applications/" + $application_id, %params); | 
| 141 |  |  |  |  |  |  | } | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | =item get_room_by_contract | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | Get a specific room by contract ID | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | B | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | JSON response as a string | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | =cut | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  | sub get_room_by_contract { | 
| 154 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 155 | 0 |  |  |  |  |  | my $company = shift; | 
| 156 | 0 |  |  |  |  |  | my $contract_id = shift; | 
| 157 | 0 |  |  |  |  |  | my %params = @_; | 
| 158 |  |  |  |  |  |  |  | 
| 159 | 0 |  |  |  |  |  | return $self->client()->get("/messages/v3/" . $company . "/rooms/contracts/" + $contract_id, %params); | 
| 160 |  |  |  |  |  |  | } | 
| 161 |  |  |  |  |  |  |  | 
| 162 |  |  |  |  |  |  | =item create_room | 
| 163 |  |  |  |  |  |  |  | 
| 164 |  |  |  |  |  |  | Create a new room | 
| 165 |  |  |  |  |  |  |  | 
| 166 |  |  |  |  |  |  | B | 
| 167 |  |  |  |  |  |  |  | 
| 168 |  |  |  |  |  |  | JSON response as a string | 
| 169 |  |  |  |  |  |  |  | 
| 170 |  |  |  |  |  |  | =cut | 
| 171 |  |  |  |  |  |  |  | 
| 172 |  |  |  |  |  |  | sub create_room { | 
| 173 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 174 | 0 |  |  |  |  |  | my $company = shift; | 
| 175 | 0 |  |  |  |  |  | my %params = @_; | 
| 176 |  |  |  |  |  |  |  | 
| 177 | 0 |  |  |  |  |  | return $self->client()->post("/messages/v3/" . $company . "/rooms", %params); | 
| 178 |  |  |  |  |  |  | } | 
| 179 |  |  |  |  |  |  |  | 
| 180 |  |  |  |  |  |  | =item send_message_to_room | 
| 181 |  |  |  |  |  |  |  | 
| 182 |  |  |  |  |  |  | Send a message to a room | 
| 183 |  |  |  |  |  |  |  | 
| 184 |  |  |  |  |  |  | B | 
| 185 |  |  |  |  |  |  |  | 
| 186 |  |  |  |  |  |  | JSON response as a string | 
| 187 |  |  |  |  |  |  |  | 
| 188 |  |  |  |  |  |  | =cut | 
| 189 |  |  |  |  |  |  |  | 
| 190 |  |  |  |  |  |  | sub send_message_to_room { | 
| 191 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 192 | 0 |  |  |  |  |  | my $company = shift; | 
| 193 | 0 |  |  |  |  |  | my $room_id = shift; | 
| 194 | 0 |  |  |  |  |  | my %params = @_; | 
| 195 |  |  |  |  |  |  |  | 
| 196 | 0 |  |  |  |  |  | return $self->client()->post("/messages/v3/" . $company . "/rooms/" . $room_id . '/stories', %params); | 
| 197 |  |  |  |  |  |  | } | 
| 198 |  |  |  |  |  |  |  | 
| 199 |  |  |  |  |  |  | =item send_message_to_rooms | 
| 200 |  |  |  |  |  |  |  | 
| 201 |  |  |  |  |  |  | Send a message to a batch of rooms | 
| 202 |  |  |  |  |  |  |  | 
| 203 |  |  |  |  |  |  | B | 
| 204 |  |  |  |  |  |  |  | 
| 205 |  |  |  |  |  |  | JSON response as a string | 
| 206 |  |  |  |  |  |  |  | 
| 207 |  |  |  |  |  |  | =cut | 
| 208 |  |  |  |  |  |  |  | 
| 209 |  |  |  |  |  |  | sub send_message_to_rooms { | 
| 210 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 211 | 0 |  |  |  |  |  | my $company = shift; | 
| 212 | 0 |  |  |  |  |  | my %params = @_; | 
| 213 |  |  |  |  |  |  |  | 
| 214 | 0 |  |  |  |  |  | return $self->client()->post("/messages/v3/" . $company . '/stories/batch', %params); | 
| 215 |  |  |  |  |  |  | } | 
| 216 |  |  |  |  |  |  |  | 
| 217 |  |  |  |  |  |  | =item update_room_settings | 
| 218 |  |  |  |  |  |  |  | 
| 219 |  |  |  |  |  |  | Update a room settings | 
| 220 |  |  |  |  |  |  |  | 
| 221 |  |  |  |  |  |  | B | 
| 222 |  |  |  |  |  |  |  | 
| 223 |  |  |  |  |  |  | JSON response as a string | 
| 224 |  |  |  |  |  |  |  | 
| 225 |  |  |  |  |  |  | =cut | 
| 226 |  |  |  |  |  |  |  | 
| 227 |  |  |  |  |  |  | sub update_room_settings { | 
| 228 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 229 | 0 |  |  |  |  |  | my $company = shift; | 
| 230 | 0 |  |  |  |  |  | my $room_id = shift; | 
| 231 | 0 |  |  |  |  |  | my $username = shift; | 
| 232 | 0 |  |  |  |  |  | my %params = @_; | 
| 233 |  |  |  |  |  |  |  | 
| 234 | 0 |  |  |  |  |  | return $self->client()->put("/messages/v3/" . $company . "/rooms/" . $room_id . "/users/" . $username, %params); | 
| 235 |  |  |  |  |  |  | } | 
| 236 |  |  |  |  |  |  |  | 
| 237 |  |  |  |  |  |  | =item update_room_metadata | 
| 238 |  |  |  |  |  |  |  | 
| 239 |  |  |  |  |  |  | Update the metadata of a room | 
| 240 |  |  |  |  |  |  |  | 
| 241 |  |  |  |  |  |  | B | 
| 242 |  |  |  |  |  |  |  | 
| 243 |  |  |  |  |  |  | JSON response as a string | 
| 244 |  |  |  |  |  |  |  | 
| 245 |  |  |  |  |  |  | =cut | 
| 246 |  |  |  |  |  |  |  | 
| 247 |  |  |  |  |  |  | sub update_room_metadata { | 
| 248 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 249 | 0 |  |  |  |  |  | my $company = shift; | 
| 250 | 0 |  |  |  |  |  | my $room_id = shift; | 
| 251 | 0 |  |  |  |  |  | my %params = @_; | 
| 252 |  |  |  |  |  |  |  | 
| 253 | 0 |  |  |  |  |  | return $self->client()->put("/messages/v3/" . $company . "/rooms/" . $room_id, %params); | 
| 254 |  |  |  |  |  |  | } | 
| 255 |  |  |  |  |  |  |  | 
| 256 |  |  |  |  |  |  | =back | 
| 257 |  |  |  |  |  |  |  | 
| 258 |  |  |  |  |  |  | =head1 AUTHOR | 
| 259 |  |  |  |  |  |  |  | 
| 260 |  |  |  |  |  |  | Maksym Novozhylov C<<  >> | 
| 261 |  |  |  |  |  |  |  | 
| 262 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 263 |  |  |  |  |  |  |  | 
| 264 |  |  |  |  |  |  | Copyright E Upwork Global Corp., 2016 | 
| 265 |  |  |  |  |  |  |  | 
| 266 |  |  |  |  |  |  | =cut | 
| 267 |  |  |  |  |  |  |  | 
| 268 |  |  |  |  |  |  | 1; |