NAME

Tomba::Client - Base HTTP client for the Tomba.io API

SYNOPSIS

use Tomba::Client;

my $client = Tomba::Client->new("ta_xxxxx", "ts_xxxxx");

# GET request
my $result = $client->call("/me");

# POST request
my $result = $client->post("/leads", { email => "test@example.com" });

DESCRIPTION

This module provides the base HTTP client used by all Tomba service modules. It handles authentication, request construction, and JSON parsing.

Normally you would not use this module directly; instead use Tomba::Finder or the individual service modules (Tomba::Account, Tomba::Domain, etc.) which inherit from this class.

new

my $client = Tomba::Client->new($api_key, $api_secret);
my $client = Tomba::Client->new($api_key, $api_secret, $base_url);

Creates a new Tomba::Client instance.

See https://docs.tomba.io/authentication

call

my $result = $client->call($path, $params);

Makes a GET request to the Tomba API.

Arg 1: Str $path - the path portion of the URL to request
Arg 2: HashRef $params - a hashref of query parameters to include in the URL
Returns: JSON response as a Perl hashref, or undef on error

post

my $result = $client->post($path, $body, $params);

Makes a POST request to the Tomba API with a JSON body.

Arg 1: Str $path - the path portion of the URL
Arg 2: HashRef $body - a hashref to be encoded as JSON in the request body
Arg 3: HashRef $params (optional) - query parameters
Returns: JSON response as a Perl hashref, or undef on error

put

my $result = $client->put($path, $body, $params);

Makes a PUT request to the Tomba API with a JSON body.

Arg 1: Str $path - the path portion of the URL
Arg 2: HashRef $body - a hashref to be encoded as JSON in the request body
Arg 3: HashRef $params (optional) - query parameters
Returns: JSON response as a Perl hashref, or undef on error

delete_request

my $result = $client->delete_request($path, $params);

Makes a DELETE request to the Tomba API.

Arg 1: Str $path - the path portion of the URL
Arg 2: HashRef $params (optional) - query parameters
Returns: JSON response as a Perl hashref, or undef on error

AUTHOR

Mohamed Ben rebia, <b.mohamed@tomba.io>

COPYRIGHT AND LICENSE

Copyright 2023 Mohamed Benrebia <b.mohamed@tomba.io>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.