App-wsgetmail

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

    string in your wsgetmail configuration file.

- user\_password

    Set this to the password string for `username` in your wsgetmail
    configuration file.

### Configuring Microsoft Government Cloud

If you are connecting to a Microsoft Government Cloud tenant (GCC High or
DoD), the default Microsoft Graph API and OAuth endpoints will not work. Use
the following options to point wsgetmail at the correct endpoints.

- resource\_url

    Set this to the Microsoft Graph API base URL for your cloud environment.
    The default is `https://graph.microsoft.com/`. For GCC High, use
    `https://graph.microsoft.us/`. For DoD, use
    `https://dod-graph.microsoft.us/`.

- login\_base\_url

lib/App/wsgetmail.pm  view on Meta::CPAN

=item user_password

Set this to the password string for C<username> in your wsgetmail
configuration file.

=back

=head3 Configuring Microsoft Government Cloud

If you are connecting to a Microsoft Government Cloud tenant (GCC High or
DoD), the default Microsoft Graph API and OAuth endpoints will not work. Use
the following options to point wsgetmail at the correct endpoints.

=over 4

=item resource_url

Set this to the Microsoft Graph API base URL for your cloud environment.
The default is C<https://graph.microsoft.com/>. For GCC High, use
C<https://graph.microsoft.us/>. For DoD, use
C<https://dod-graph.microsoft.us/>.

lib/App/wsgetmail/MS365/Client.pm  view on Meta::CPAN


has global_access => (
    is => 'ro',
    default => sub { return 0 }
);

=back

=head2 resource_url

A string with the URL for the overall API endpoint. Defaults to
C<https://graph.microsoft.com/>. For Microsoft Government Cloud (GCC High),
set this to C<https://graph.microsoft.us/>. For DoD, use
C<https://dod-graph.microsoft.us/>.

=cut

has resource_url => (
    is => 'ro',
    default => sub { return 'https://graph.microsoft.com/' }
);

lib/App/wsgetmail/MS365/Client.pm  view on Meta::CPAN


=cut

has login_base_url => (
    is => 'ro',
    default => sub { return 'https://login.windows.net' }
);

=head2 resource_path

A string with the REST API endpoint URL path.

=cut

has resource_path => (
    is => 'ro',
    default => sub { return 'v1.0' }
);

has debug => (
    is => 'rw',

lib/App/wsgetmail/MS365/Client.pm  view on Meta::CPAN

    else {
        unless ($args->{username} && $args->{user_password}) {
            die "username and user_password are required when not using global_access";
        }
    }
}


=head1 METHODS

=head2 build_rest_uri(@endpoint_parts)

Given a list of URL component strings, returns a complete URL string to
reach that endpoint from this object's C<resource_url> and C<resource_path>.

=cut

sub build_rest_uri {
    my ($self, @endpoint_parts) = @_;
    my $base_url = $self->resource_url . $self->resource_path;
    return join('/', $base_url, @endpoint_parts);
}

=head2 get_request($parts, $params)

Makes a GET request to the API. C<$parts> is an arrayref of URL endpoint
strings with the specific endpoint to request. C<$params> is a hashref of
query parameters to send with the request.

=cut

sub get_request {
    my ($self, $parts, $params) = @_;
    # add error handling!
    my $uri = URI->new($self->build_rest_uri(@$parts));
    warn "making GET request to url $uri" if ($self->debug);
    $uri->query_form($params) if ($params);

lib/App/wsgetmail/MS365/Client.pm  view on Meta::CPAN

=cut

sub get_request_by_url {
    my ($self, $url) = @_;
    warn "making GET request to url $url" if ($self->debug);
    return $self->_ua->get($url);
}

=head2 delete_request($parts, $params)

Makes a DELETE request to the API. C<$parts> is an arrayref of URL endpoint
strings with the specific endpoint to request. C<$params> is unused.

=cut

sub delete_request {
    my ($self, $parts, $params) = @_;
    my $url = $self->build_rest_uri(@$parts);
    warn "making DELETE request to url $url" if ($self->debug);
    return $self->_ua->delete($url);
}

=head2 post_request($path_parts, $post_data)

Makes a POST request to the API. C<$path_parts> is an arrayref of URL
endpoint strings with the specific endpoint to request. C<$post_data> is a
reference to an array or hash of data to include in the POST request body.

=cut

sub post_request {
    my ($self, $path_parts, $post_data) = @_;
    my $url = $self->build_rest_uri(@$path_parts);
    warn "making POST request to url $url" if ($self->debug);
    return $self->_ua->post($url,$post_data);
}

=head2 patch_request($path_parts, $patch_params)

Makes a PATCH request to the API. C<$path_parts> is an arrayref of URL
endpoint strings with the specific endpoint to request. C<$patch_params> is
a hashref of data to include in the PATCH request body.

=cut

sub patch_request {
     my ($self, $path_parts, $patch_params) = @_;
     my $url = $self->build_rest_uri(@$path_parts);
     warn "making PATCH request to url $url" if ($self->debug);
     return $self->_ua->patch($url,%$patch_params);
 }



( run in 1.832 second using v1.01-cache-2.11-cpan-99c4e6809bf )