UWAGA: poniższa dokumentacja dotyczy nieakutalnej wersji API (2.0.0). Kliknij aby przejść do aktualnej dokumentacji.

<<

An API introdution for distributors

(This document assumes that you are familiar with the general README. Reading README_Users won't hurt either.)

To start creating new Monit24.pl accounts for your users, you will need a distributor's account. Distributor's account (also called partner's account) is a special account that can be used for creating new user accounts. Distributor accounts are used only to create regular accounts: they cannot have services, groups or any other things that the regular accounts have. Distributors also cannot login to the Administration Panel, they can only access the API.

The Distributor API module can be used to manage distributor accounts.

Creating a distributor account

To create a distributor's account, use the Distributor::Create method. Here is an example of calling this method:

        {
                "module":"Distributor",
                "method":"Create",
                "data":{
                        "login":"my_distributor_account",
                        "email":"test_distributor@monit24.pl",
                        "password":"d1str1_boot0R",
                        "contact_person":"John Smith",
                        "contact_phone":"123456789"
                }
        }

If the API method call succeeds, the response will contain your account's ID:

        {"auth":{},"version":"2.0.0","error":null,"data":{"id":3461}}

To confirm that the account has been created properly, you can fetch the distributor's data with the Distributor::Read method:

        {"module":"Distributor","method":"Read","auth":{"login":"my_distributor_account","password":"d1str1_boot0R"},"data":{"id":3461}}

If the response looks like this (particularly if the error is NULL):

        {
                "auth":{},
                "version":"2.0.0",
                "error":null,
                "data":{
                        "contact_phone":"123456789",
                        "email":"test_distributor@monit24.pl",
                        "tax_id":null,
                        "address":null,
                        "contact_person":"John Smith",
                        "id":3461,
                        "login":"my_distributor_account"
                }
        }

then congratulations - you have successfully created your distributor account.

Creating an user's account

To create a new account, you will need to provide the following information:

Once you have all the required data for the account, you can create it with the Account::Create method:

        {
                "module":"Account",
                "method":"Create",
                "auth":{"login":"my_distributor_account","password":"d1str1_boot0R"},
                "data":{
                        "login":"test_user",
                        "password":"p4ssword",
                        "package_id":632,
                        "name":"Test account",
                        "email":"test_account@monit24.pl",
                        "contact_person":"Test Test",
                        "language":"en"
                }
        }

The response will contain the new account's ID:

        {"auth":{},"version":"2.0.0","error":null,"data":{"id":4844}}

Before the account can be used, it needs to be activated. To do it, use the Account::Activate method:

        {"module":"Account","method":"Activate","auth":{"login":"my_distributor_account","password":"d1str1_boot0R"},"data":{"id":4844}

Now the account is active and the user can login to it:

        {"module":"User","method":"Read","auth":{"login":"test_user","password":"p4ssword}}

        {
                "auth":{},
                "version":"2.0.0",
                "error":null,
                "data":{
                        "contact_phone":"",
                        "language":"en",
                        "contact_person":"Test Test",
                        "last_login_ip":null,
                        "last_login_timestamp":null,
                        "login":"test_user2",
                        "email":"test_account@monit24.pl",
                        "tax_id":null,
                        "address":null,
                        "id":4845
                }
        }

The new account has a default group created. Also, notifications for this group will be sent to the e-mail address specified while creating (in this case test_account@monit24.pl). You can change the notification addresses by using the NotificationAddress API module.

Accessing user's data

Distributors are allowed to call API methods on their users' objects.

For example, to list all services for all your users, call the Service::Find method with the distributor's authentication data.

Almost all calls work the same, but some may impose stricter requirements than they do when called as a regular user. For example, when creating a new group you have to specify the account it will be assigned to (when creating as an user, the user's account is used) and when creating a service you have to specify its group (it defaults to the user's default group when creating as an user).

Blocking, unblocking and deleting accounts

To block an account use the Account::Block method. Blocked accounts cannot be accessed by users, all their services are paused and all objects (services, groups, addresses etc.) become invisible and cannot be modified (even by distributors). However, the blocked accounts will appear in distributor's Account::Find output, with the blocked attribute set to 1.

Blocked accounts can be unblocked by calling the Account::Unblock method. Unblocking restores the access to the account, but the services have to be unpaused separately.

Distributors can delete the accounts with the Account::Delete method. This permanently deletes the account with all its services, groups, addresses etc. Use with caution.

<<