Skip to content

binary-com/perl-WebService-Async-Segment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

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

DESCRIPTION

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

METHODS

configure

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

parameters:

  • write_key - the API token of a Segment source.
  • base_uri - the base uri of the Segment host, primarily useful for setting up test mock servers.

write_key

API token of the intended Segment source

base_uri

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

Returns a URI instance.

ua

A Net::Async::HTTP object acting as HTTP user agent

basic_authentication

Settings required for basic HTTP authentication

method_call

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

It takes the following named parameters:

  • method - required. Segment method name (such as identify and track).
  • args - optional. Method arguments represented as a dictionary. This may include either common, method-specific or custom fields.

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

It returns a Future object.

new_customer

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

  • user_id or userId - Unique identifier of a user.
  • anonymous_id or anonymousId- A pseudo-unique substitute for a User ID, for cases when you don't have an absolutely unique identifier.
  • traits - Free-form dictionary of traits of the user, like email or name.

_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.

  • $args - call args as a hash reference.
  • $snake_fields - a hash ref representing mapping from snake_case to camelCase.

Returns a hash reference of args with altered keys.

AUTHOR

deriv.com DERIV@cpan.org

LICENSE

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

About

Unofficial support for segment.com API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages