Rishwanth Yeddula > WWW-Weebly-0.03 > WWW::Weebly

Download:
WWW-Weebly-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

WWW::Weebly - Perl interface to interact with the Weebly API.

VERSION ^

Version 0.03

SYNOPSIS ^

This module provides you with an perl interface to interact with the Weebly API.

        use WWW::Weebly;
        my $api = WWW::Weebly->new(
                {
                        'tid_seed'      => $seed_value_for_generating_tids,
                        'weebly_secret' => $weebly_secret,
                        'weebly_url'    => $weebly_baseurl,
                }
        );
        $api->new_user();
        $api->login($params_for_login);
        $api->enable_account($params_for_enable_account);
        $api->disable_account($params_for_disable_account);
        $api->delete_account($params_for_delete_account);
        $api->undelete_account($params_for_undelete_account);
        $api->upgrade_account($params_for_upgrade_account);
        $api->downgrade_account($params_for_downgrade_account);
        $api->has_service($params_for_has_service);

SUBROUTINES/METHODS ^

new()

Croaks on errors.

Input takes a hashref that contains:

        weebly_secret => The secret key that is used to generate auth tokens.
        weebly_url    => Specify the base URL that we should be querying.

        One of the following:

        tid_seed      => The value that will be appended to the current time() value to generate a transaction id.
        tid_sub       => If you wish to generate transaction ids in a different way, you can pass the coderef to the sub you wish to use here.

        Optional:
        http_opts     => Hashref of options that are passed on to the HTTP::Tiny object that is used internally.
                         Example value: { 'agent' => 'WWW-Weebly', 'timeout' => 20, 'verify_SSL' => 'false', 'SSL_options' => {'SSL_verify_mode' => '0x00'} }

new_user()

Dispatches a newuser call to the URL specified in $self->{weebly_url}.

Croaks on errors.

Input: None.

Returns a hashref with the following keys otherwise:

        success => 1 or 0.
        new_id  => ID associated with the new account (only present on success).
        reason  => If the request fails, this will contain a text explanation of the failure as returned by Weebly.

login()

Dispatches a login call to the URL specified in $self->{weebly_url}.

Passes critical user account information to Weebly, such as the FTP info, account type (Basic/Premium), widget type, etc.

Generates a one-time use login url that allows the client to log-in to the Weebly editor.

Croaks on errors.

Input: hashref that contains the following information:

        user_id        => the user_id of the account.
        ftp_url        => FTP URL
        ftp_username   => FTP username
        ftp_password   => FTP password
        ftp_path       => FTP publish path
        property_name  => Property name used for the creating the website's foooter. Should be of the form: <a href='URL' target='_blank'>SITE_NAME</a>
        upgrade_url    => URL of the purchase manager
        publish_domain => Published site's FQDN (ie www.domain.com)
        platform       => 'Windows' or 'Unix'
        publish_upsell => Publish upsell URL (optional, placed in an 640px wide by 200px tall iframe on publish)

Returns a hashref with the following keys otherwise:

        success   => 1 or 0.
        login_url => one-time login url for the account.
        reason    => If the request fails, this will contain a text explanation of the failure as returned by Weebly.

enable_account()

Dispatches a enableaccount call to the URL specified in $self->{weebly_url}.

This call enables a user account that has been previously disabled.

Croaks on errors.

Input: hashref that contains the following information:

        user_id     => the user_id of the account.

Returns a hashref with the following keys:

        success => 1 or 0.
        reason  => If the request fails, this will contain a text explanation of the failure as returned by Weebly.

disable_account()

Dispatches a disableaccount call to the URL specified in $self->{weebly_url}.

This call disables login to a user account. This account will be accounted for in user quota numbers.

It is possible to restore login capabilities to this account using enable_account().

Croaks on errors.

Input: hashref that contains the following information:

        user_id => the user_id of the account.

Returns a hashref with the following keys:

        success => 1 or 0.
        reason  => If the request fails, this will contain a text explanation of the failure as returned by Weebly.

delete_account()

Dispatches a deleteaccount call to the URL specified in $self->{weebly_url}.

This call deletes a user account. This account will not be accounted for in user quota numbers.

It is possible to restore this account using the Admin interface or via the undelete_account() call.

Croaks on errors.

Input: hashref that contains the following information:

        user_id => the user_id of the account.

Returns a hashref with the following keys:

        success => 1 or 0.
        reason  => If the request fails, this will contain a text explanation of the failure as returned by Weebly.

undelete_account()

Dispatches a undeleteaccount call to the URL specified in $self->{weebly_url}.

This call restores a deleted user account.

Croaks on errors.

Input: hashref that contains the following information:

        user_id => the user_id of the account.

Returns a hashref with the following keys:

        success => 1 or 0.
        reason  => If the request fails, this will contain a text explanation of the failure as returned by Weebly.

upgrade_account()

Dispatches a upgradeaccount call to the URL specified in $self->{weebly_url}.

This call upgrades a user account with a given service.

Croaks on errors.

Input: hashref that contains the following information:

        user_id     => the user_id of the account.
        service_id  => the server_id to be added to the account.
                       Current service_ids that Weebly responds are: 'Weebly.proAccount', 'Weebly.eCommerce'
        term        => duration of the service in months.
        price       => price paid for the service.

Returns a hashref with the following keys:

        success => 1 or 0.
        reason  => If the request fails, this will contain a text explanation of the failure as returned by Weebly.

downgrade_account()

Dispatches a downgradeaccount call to the URL specified in $self->{weebly_url}.

This call can be used to check if the specified user_id has Pro or Ecommerce features enabled.

Croaks on errors.

Input: hashref that contains the following information:

        user_id     => the user_id of the account.
        service_id  => the server_id to be removed from the account.
                       Current service_ids that Weebly responds are: 'Weebly.proAccount', 'Weebly.eCommerce'

Returns a hashref with the following key:

        success => 1 or 0.

has_service()

Dispatches a hasservice call to the URL specified in $self->{weebly_url}.

This call can be used to check if the specified user_id has Pro or Ecommerce features enabled.

Croaks on errors.

Input: hashref that contains the following information: user_id => the user_id of the account. service_id => the server_id to check. Current service_ids that Weebly responds are: 'Weebly.proAccount', 'Weebly.eCommerce'

Returns a hashref with the following key:

        success => 1 or 0.

get_auth_token()

Input: transaction id, action param, and userid param.

Returns the md5_hex hash of the input params concatenated with $self->{weebly_secret}, to be used as the auth token in the API calls.

get_weebly_url()

Returns the base url that will be queried, which is stored in $self->{weebly_url}.

get_weebly_secret()

Returns $self->{weebly_secret}.

get_error()

Returns $self->{'error'}

Internal Subroutines ^

The following are not meant to be used directly, but are available if 'finer' control is required.

_do_request()

Wraps the call to _make_request and handles error checks.

INPUT

        Takes the 'action' and sanitized paramaters hashref as input.

Output

        Returns undef on failure (sets $self->{error} with the proper error).
        Returns a hashref with the parsed data from the API server if successful.

_parse_output()

Parses the output from Weebly's API call, and returns it as a hash.

_get_url()

Depending on the action passed, it will return part of the URL that you can use along with the _stringify_params method to generate the full GET url.

Input: action param

Returns: get_weebly_url().'/weebly/api.php?action='.$action

_add_auth()

Adds the neccessary transaction id (tid) and authentication tokens to the URI

_get_tid()

Input: None.

Returns the tid value generated by the sub referenced in $self->{tid_sub}.

If a 'tid_seed' value was specified when the object was created, then the value returned is the md5_hex hash of the tid_seed value concatenated with time().

_make_request()

Makes the HTTP request.

Input The full uri to perform the HTTP request on.

Output Returns an array containing the http response, and error.

If the HTTP request was successful, then the error is blank.

If the HTTP request failed, then the response is blank and the error is the status line from the HTTP response.

_sanitize_params()

Sanitizes the data in the hashref passed for the action specified.

Input The 'action', and a hashref that has the data that will be sanitized.

Output Boolean value indicating success. The hash is altered in place as needed.

_stringify_params()

Stringifies the content of a hash such that the output can be used as the URI body of a GET request.

Input A hashref containing the sanatizied parameters for an API call.

Output String with the keys and values stringified as so '&key1=value1&key2=value2'

_check_required_keys()

Input

        First arg: Hashref that contains the data to be checked.
        Second arg: Hashref that holds the keys to check for.

Output

A hash containing the 'missing_params' and 'blank_params', if any are found to be missing.

        If a required key is missing, it will be present in the missing_params array.
        If a required key has a blank value, it will be present in the blank_params array.

Returns undef, if no issues are found.

_remove_unwanted_keys()

Deletes keys from the provided params hashref, if they are not listed in the hash for wanted keys.

Input

        First arg: Hashref that contains the data to be checked. 
        Second arg: Hashref that holds the keys to check for.

Output

        undef

_get_error()

Returns $self->{'error'}

_error()

Internal method that is used to report and set $self->{'error'}.

It will croak if called with a true second argument. Such as:

        $self->_error($msg, 1);

AUTHOR ^

Rishwanth Yeddula, <ryeddula at cpan.org>

ACKNOWLEDGMENTS ^

Thanks to Hostgator.com for funding the development of this module and providing test resources.

BUGS ^

Please report any bugs or feature requests to bug-www-weebly at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Weebly. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc WWW::Weebly

You can also look for information at:

ACKNOWLEDGEMENTS ^

LICENSE AND COPYRIGHT ^

Copyright 2013 Rishwanth Yeddula.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

syntax highlighting: