NAME

WebService::Moodle::Simple - API client for Stripe

VERSION

version 0.06

SYNOPSIS

CLI

./bin/moodlews --help

Example

$ ./bin/moodlews add_user -u freddy -f Fred -l Flintstone -e freddy09@example.com -o 0123456789abcdef -p ff1234 -d moodle.example.com -t local_wssetup

{ id => 57, ok => 1, username => "freddy09" }

API

use WebService::Moodle::Simple;

my $moodle = WebService::Moodle::Simple->new(
  domain   => 'moodle.example.edu',
  port     => 80,                  # default 443
  timeout  => 100,                 # default 1000
  scheme   => 'http',              # default 'https'
  target   => 'example_webservice'
  token    => '0123456789abcdef',
);

DESCRIPTION

WebService::Moodle::Simple is Client API and CLI for Moodle Web Services

__THIS IS A DEVELOPMENT RELEASE. API MAY CHANGE WITHOUT NOTICE__.

NAME

WebService::Moodle::Simple - Client API and CLI for Moodle Web Services

USAGE

CLI

Get instructions on CLI usage

moodlews

Example - Login and Get Users

Retrieve the user list using the token

moodlews get_users -o becac8d120119eb2a312a385644eb709 -d moodle.example.edu -t example_webservice

Unit Tests

prove -rlv t

Full Unit Tests

TEST_WSMS_SCHEME=https \
TEST_WSMS_PORT=443 \
TEST_WSMS_DOMAIN=moodle.example.com \
TEST_WSMS_TARGET=example_webservice \
TEST_WSMS_TOKEN=0123456789abcdef \
TEST_WSMS_COURSE=example-short-course-name \
prove -rlv t/

__NOTE: Full unit tests write to Moodle Database - only run them against a test Moodle server__.

Methods

  • add_user

    $OBJ->add_user(
        firstname => <str>,
        lastname  => <str>,
        email     => <str>,
        username  => <str>,
        password  => <str>,
        token     => <str>,
    );

    On failure, returns a hashref of the form

    {
        ok  => 0,
        msg => <str>,
    }

    or

    {
        ok       => 1,
        id       => <int>,
        username => <str>,
    }
  • check_password

    $OBJ->check_password(
        username => <str>,
        password => <str>,
    )

    Returns

    { msg => <str>, ok => <bool> }
  • set_password

    $OBJ->set_password(
        username => <str>,
        password => <str>,
    )

    Returns

    { ok => <bool> }
  • get_user

    $OBJ->get_user(
        username => <str>,
    )

    Returns

    {
        username  => <str>,
        id        => <int>,
        suspended => <JSON::PP::Boolean>,
        ...
    }
  • enrol_student

    $OBJ->enrol_student(
      username  => <str>,
      course    => <str>,
    )

    Returns

    { ok => <bool>, msg => <str> }
  • get_course_id

    $OBJ->get_course_id(
        short_cname  => <str>,
    )

    Returns an integer

  • suspend_user

    $OBJ->suspend_user(
        username => <str>,
        suspend  => <bool default TRUE>
    )

    Always returns undef

    If suspend is true/nonzero (which is the default) it kills the user's session and suspends their account preventing them from logging in. If suspend is false they are given permission to login.

AUTHOR

Andrew Solomon <andrew@geekuni.com>

COPYRIGHT

Copyright 2014- Andrew Solomon

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

AUTHOR

Andrew Solomon

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Copyright 2014- Andrew Solomon.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.