=encoding utf8

=for comment POD_DERIVED_INDEX_GENERATED
The following documentation is automatically generated.  Please do not edit
this file, but rather the original, inline with WebService::Async::Segment
at lib/WebService/Async/Segment.pm
(on the system that originally ran this).
If you do edit this file, and don't want your changes to be removed, make
sure you change the first line.

=cut

=head1 NAME

WebService::Async::Segment - Unofficial support for the Segment service

=head1 DESCRIPTION

This class acts as a L<Future>-based async Perl wrapper for segment HTTP API.

=head1 METHODS

=head2 configure

Overrides the same method of the parent class L<IO::Async::Notifier>; required for object initialization.

parameters:

=over 4

=item * C<write_key> - the API token of a Segment source.

=item * C<base_uri> - the base uri of the Segment host, primarily useful for setting up test mock servers.

=back

=head2 write_key

API token of the intended Segment source

=head2 base_uri

Server endpoint. Defaults to C<https://api.segment.io/v1/>.

Returns a L<URI> instance.

=head2 ua

A L<Net::Async::HTTP> object acting as HTTP user agent

=head2 basic_authentication

Settings required for basic HTTP authentication

=head2 method_call

Makes a Segment method call. It automatically defaults C<sent_at> to the current time and C<< context->{library} >> to the current module.

It takes the following named parameters:

=over 4

=item * C<method> - required. Segment method name (such as B<identify> and B<track>).

=item * C<args> - optional. Method arguments represented as a dictionary. This may include either common, method-specific or custom fields.

=back

Please refer to L<https://segment.com/docs/spec/common/> for a full list of common fields supported by Segment.

It returns a L<Future> object.

=head2 new_customer

Creates a new C<WebService::Async::Segment::Customer> object as the starting point of making B<identify> and B<track> calls.
It may takes the following named standard arguments to populate the customer onject with:

=over 4

=item * C<user_id> or  C<userId> - Unique identifier of a user.

=item * C<anonymous_id> or C<anonymousId>- A pseudo-unique substitute for a User ID, for cases when you don't have an absolutely unique identifier.

=item * C<traits> - Free-form dictionary of traits of the user, like email or name.

=back

=head2 _snake_case_to_camelCase

Creates a deep copy of API call args, replacing the standard snake_case keys with equivalent camelCases, necessary to keep consistent with Segment HTTP API.
It doesn't automatically alter any non-standard custom keys even they are snake_case.

=over 4

=item * C<$args> - call args as a hash reference.

=item * C<$snake_fields> - a hash ref representing mapping from snake_case to camelCase.

=back

Returns a hash reference of args with altered keys.

=head1 INHERITED METHODS

=over 4

=item L<IO::Async::Notifier>

L<add_child|IO::Async::Notifier/add_child>, L<adopt_future|IO::Async::Notifier/adopt_future>, L<adopted_futures|IO::Async::Notifier/adopted_futures>, L<can_event|IO::Async::Notifier/can_event>, L<children|IO::Async::Notifier/children>, L<configure_unknown|IO::Async::Notifier/configure_unknown>, L<debug_printf|IO::Async::Notifier/debug_printf>, L<get_loop|IO::Async::Notifier/get_loop>, L<invoke_error|IO::Async::Notifier/invoke_error>, L<invoke_event|IO::Async::Notifier/invoke_event>, L<loop|IO::Async::Notifier/loop>, L<make_event_cb|IO::Async::Notifier/make_event_cb>, L<maybe_invoke_event|IO::Async::Notifier/maybe_invoke_event>, L<maybe_make_event_cb|IO::Async::Notifier/maybe_make_event_cb>, L<new|IO::Async::Notifier/new>, L<notifier_name|IO::Async::Notifier/notifier_name>, L<parent|IO::Async::Notifier/parent>, L<remove_child|IO::Async::Notifier/remove_child>, L<remove_from_parent|IO::Async::Notifier/remove_from_parent>

=back

=head1 AUTHOR

deriv.com C<DERIV@cpan.org>

=head1 LICENSE

Copyright deriv.com 2019. Licensed under the same terms as Perl itself.

