App-wsgetmail
view release on metacpan or search on metacpan
lib/App/wsgetmail/MS365.pm view on Meta::CPAN
if ($self->_next_fetch_url) {
my $response = $self->_client->get_request_by_url($self->_next_fetch_url);
unless ($response->is_success) {
warn "failed to fetch messages " . $response->status_line;
warn "response from server : " . $response->content if $self->debug;
$self->_have_messages_to_fetch(0);
return 0;
}
$decoded_response = decode_json( $response->content );
} else {
my $fields = [qw(id subject sender isRead sentDateTime toRecipients parentFolderId categories)];
$decoded_response = $self->_get_message_list($fields, $filter);
}
$messages = $decoded_response->{value};
if ($decoded_response->{'@odata.nextLink'}) {
$self->_next_fetch_url($decoded_response->{'@odata.nextLink'});
$self->_have_messages_to_fetch(1);
} else {
$self->_have_messages_to_fetch(0);
}
lib/App/wsgetmail/MS365.pm view on Meta::CPAN
}
$filter ||= $self->_get_message_filters;
#TODO: handle filtering multiple folders using filters
my @path_parts = ($self->global_access) ? ( 'users', $self->username, 'mailFolders', $folder->{id}, 'messages' ) : ( 'me', 'mailFolders', $folder->{id}, 'messages' );
# get oldest first, filter (i.e. unread) if filter provided
my $response = $self->_client->get_request(
[@path_parts],
{
'$count' => 'true', '$orderby' => 'sentDateTime',
( $fields ? ('$select' => join(',',@$fields) ) : ( )),
( $filter ? ('$filter' => $filter ) : ( ))
}
);
unless ($response->is_success) {
warn "failed to fetch messages " . $response->status_line;
warn "response from server : " . $response->content if $self->debug;
return { value => [ ] };
}
t/mock_responses/messages.json view on Meta::CPAN
"ccRecipients": [],
"toRecipients": [
{
"emailAddress": {
"address": "rtdev@example.tld",
"name": "rt dev"
}
}
],
"@odata.etag": "W/xxxx",
"receivedDateTime": "2020-06-01T15:10:57Z",
"id": "xxxxxxxxabc1",
"webLink": "https://outlook.office365.com/owa/?ItemID=zzzzzzzz&exvsurl=1&viewmodel=ReadMessageItem",
"sentDateTime": "2020-06-01T15:10:52Z",
"inferenceClassification": "focused",
"sender": {
"emailAddress": {
"address": "at@example.tlf",
"name": "Aaron Testing"
}
},
"body": {
"contentType": "text",
"content": "this is yet another test ticket again"
},
"createdDateTime": "2020-06-01T15:10:57Z",
"importance": "normal",
"lastModifiedDateTime": "2020-06-02T14:58:25Z",
"parentFolderId": "xxxxxxxxxx",
"bccRecipients": []
},
{
"bodyPreview": "this is a test ticket to test pagination",
"flag": {
"flagStatus": "notFlagged"
},
"from": {
"emailAddress": {
"address": "at@example.tlf",
"name": "Aaron Testing"
}
},
"conversationId": "xxxxxxxxxxxxxxxxxxxxxxxxxx=",
"categories": [],
"replyTo": [],
"conversationIndex": "xxxxxxxxxxxxxxxxx==",
"subject": "a test ticket",
"sentDateTime": "2020-06-01T15:10:27Z",
"inferenceClassification": "focused",
"receivedDateTime": "2020-06-01T15:10:33Z",
"id": "xxxxxxxxxxxxxxxxxxxxabc2=",
"toRecipients": [
{
"emailAddress": {
"name": "rt dev",
"address": "rtdev@example.tld"
}
}
],
"@odata.etag": "W/xxxxxxxxxxxxxxxxxx",
"ccRecipients": [],
"bccRecipients": [],
"parentFolderId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=",
"importance": "normal",
"lastModifiedDateTime": "2020-06-01T15:10:33Z",
"createdDateTime": "2020-06-01T15:10:33Z",
"sender": {
"emailAddress": {
"address": "at@example.tlf",
"name": "Aaron Testing"
}
},
"body": {
"content": "this is a test ticket to test pagination",
"contentType": "text"
}
( run in 0.358 second using v1.01-cache-2.11-cpan-05444aca049 )