Code Monkey home page Code Monkey logo

whmcsapi's Introduction

WHMCSAPI - The WHMCS, PHP API Wrapper

Build Status Mergify Status

This project is simple. It is an object-oriented library of the WHMCS API functions. To use this wrapper is simple.

Requirements

  • PHP 7.3 (It may work on lower. I only test on PHP 7.3 due to dev-dependencies)
  • Composer
  • WHMCS Installation (and License!) - Buy Here

Usage

First, import the library. As WHMCSAPI is currently in alpha/beta status, set the minimum version to 1.0@alpha:

composer require PeteBishwhip/WHMCSAPI:"^1.0@alpha"

After you have imported the library, initialize the wrapper by providing three values.

Variable Description
$apiIdentifier Your API Identifier
$apiSecret Your API Secret
$whmcsUrl Your WHMCS URL (e.g. https://example.com/whmcs/)
use WHMCSAPI\WHMCSAPI;

// $whmcsApi = new WHMCSAPI('abc123', '123cba', 'https://example.com/whmcs/');
$whmcsApi = new WHMCSAPI($apiIdentifier, $apiSecret, $whmcsUrl);

After initializing the library, use command to set the API command you want to use:

try {
    $whmcsApi->command('AcceptOrder');
} catch (\WHMCSAPI\Exception\FunctionNotFound $e) {
    // Perform error handling here
    // You can retrieve the error with
    // $e->getMessage();
}

If the command is not available, a \WHMCSAPI\Exception\FunctionNotFound exception will be thrown to allow for catching errors. If you want to perform all actions in the same try/catch, catch WHMCSAPI\Exception\Exception. All exceptions extend from this.

From there, you can set any variables as documented in the WHMCS Developer Documentation:

$whmcsApi->orderid = 25;

When ready, you can finally execute the command:

$result = $whmcsApi->execute();

Contributing

Please see CONTRIBUTING.md for advice and guidance.

whmcsapi's People

Contributors

mergify[bot] avatar odsmarcus avatar petebishwhip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

whmcsapi's Issues

Write unit tests

Require a unit test for each API function available.

Should be in PHPUnit -> testing environment for connections to be established.

Improve validation procedure for "ADDITIONAL_REQUIREMENTS"

Currently, there's an if statement for each validation type. This is less than ideal and was created in a hurry.

This can be improved with the validateInput method. We just need to pass the type of validation as well as the data. I just don't have time yet to do this.

e.g.:

$this->validateData($validationType, $data);

Add a debug method

This would likely be a boolean which defaults to false.

Before making an API call, a user could run

$whmcsApi->debug(true);

This would remain persistent for as long as the object does, or is set back to false.

Need to determine:

  • Where to log
  • Format to log
  • Exactly what data to log

Add Support for Default Values

In the AddCredit PR (incoming), I'll be adding support for default values.

The following files will need defaults added retrospectively

-rw-r--r--   1 peterbishop  staff  392  6 Mar 14:49 AcceptOrder.php
-rw-r--r--   1 peterbishop  staff  278  6 Mar 14:49 AcceptQuote.php
-rw-r--r--   1 peterbishop  staff  437  6 Mar 14:49 ActivateModule.php
-rw-r--r--   1 peterbishop  staff  378  6 Mar 14:49 AddAnnouncement.php
-rw-r--r--   1 peterbishop  staff  380  6 Mar 14:49 AddBannedIp.php
-rw-r--r--   1 peterbishop  staff  653  6 Mar 14:49 AddBillableItem.php
-rw-r--r--   1 peterbishop  staff  429  6 Mar 18:58 AddCancelRequest.php
-rw-r--r--   1 peterbishop  staff  768  6 Mar 20:05 AddClient.php
-rw-r--r--   1 peterbishop  staff  344  6 Mar 22:00 AddClientNote.php
-rw-r--r--   1 peterbishop  staff  571  7 Mar 18:46 AddContact.php

Create documentation on GH Wiki

Need to make time, or get some help to write the documentation in the readme in more detail on a GH pages page, maybe with links and docs for each API function too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.