PrePAN

Sign in to PrePAN

HEXONET::Apiconnector Connector Library for the insanely fast HEXONET Backend API

Author
papakai@github
Date
URL
https://github.com/hexonet/perl-sdk
Status
In Review
Good

Synopsis

        ###############################
        # How to use this Library?
        ###############################

        # Install our module by
        cpan HEXONET::Apiconnector
        # or
        cpanm HEXONET::Apiconnector
        # NOTE: We suggest to use cpanm (App::cpanminus) for several reasons.

        # Import the HEXONET package
        use HEXONET::Apiconnector;

        # Create a connection with the URL, entity, login and password
        # Use "1234" as entity for the OT&E, and "54cd" for productive use
        # Don't have a HEXONET Account yet? Get one here: www.hexonet.net/sign-up
        my $api = HEXONET::Apiconnector::connect(
                url => 'https://coreapi.1api.net/api/call.cgi',
                entity => '1234',
                login => 'test.user',
                password => 'test.passw0rd',
        );

        # Call a command
        my $response = $api->call({
                COMMAND => "querydomainlist",
                LIMIT => 5
        });

        # Display the result in the format you want
        my $res = $response->as_list();
        my $res = $response->as_list_hash();
        my $res = $response->as_hash();

        # Get the response code and the response description
        my $code = $response->code();
        my $description = $response->description();

Description

This module allows to query the HEXONET Backend API and to deal with different response formats (list, list_hash, hash). It provides a short hand method (HEXONET::Apiconnector::connect) to instantiate API clients.

A helper utility module is also included for tasks like date handling and string encoding.

Comments

This is our 1st published perl module, please let us know if something needs a review or if we can publish it to PAUSE/CPAN without worries.

TIA
Kai
WebService::Hexonet would probably be a better name:
https://pause.perl.org/pause/query?ACTION=pause_namingmodules#Avoid_API_Interface_and_the_like

also, it would make sense to use consistent capitalization in the keys in subroutine calls. from your doc, connect() expects lowercase, and call() expects uppercase. lowercase is more perlish.
hmm, also connect() expects a list of key/vals, and call() expects a hashref of key/vals. any reason that is also not consistent?
I agree that WebService::Hexonet would be a preferable name.
@automatonical@twitter

I agree concerning the key nomenclature, that's only a documentation issue that I'll have to fix. we do not care about upper or lower case on that point. So we will change this accordingly. ty for pointing on this.

@automatonical@twitter and @openstrike@github
Concerning your module name suggestion "WebService::Hexonet", here my concerns:
a) we would love to use HEXONET in upper case letters - is this still allowed?
b) as we might plan further perl modules, we would love to use HEXONET as first part of the package name as currently suggested
c) HEXONET::Connector might be an option if you worry about the API. I have my concerns that WebService itself targets what we want to cover. Requests to our backend api could technically also be made using other protocols than http or https.
@automatonical@twitter I will care about aligning connect and call method to both use the same parameter type. ty for pointing on that too.
there are no enforced standards, so you could upload anything you want. you could search metacpan.org for similar modules and take your cue from them. but you're here asking for guidance about what the community expects...

from the link above: "Modules that interact with websites use the network, but they aren't about the network, and they have much better homes in WWW or WebService." WebService doesn't necessarily imply the http/s protocol. you could still use WebService::Hexonet::NewDooDad, etc.

HEXONET is a lot of cap letters for people to type. it doesn't look like you even enforce all caps for your python sdk. i'm assuming that's because python packages are usually all lowercase. perl modules are usually camelcase.
@automatonical@twitter
Ah I think I got this now. So WebService::Hexonet::Connector would be ok right? Your target was just to point us to the WebService namespace. I'll care about camelcasing HEXONET, makes sense as this is the perl way.
I've uploaded our package to CPAN successfully, but the installation instructions presented there are wrong.
See here: https://metacpan.org/release/HEXONET/WebService-Hexonet-Connector-1.05

No idea why it generates the installation instructions to use the WebService::Hexonet::Connector::Util package...
Anyone an idea? Any help very appreciated!

Please sign up to post a review.