Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 402] [Versions 400 and 403]

Represent the url for each method and the encoding of the parameters and response. The code is based on badges/classes/backpack_api_mapping.php by Yuliya Bozhko <yuliya.bozhko@totaralms.com>.

Author: Tung Thai <Tung.ThaiDuc@nashtechglobal.com>
Copyright: 2020 Tung Thai
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 178 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

backpack_api2p1_mapping:: (5 methods):
  __construct()
  is_match()
  get_url()
  get_curl_options()
  request()


Class: backpack_api2p1_mapping  - X-Ref

Represent a single method for the remote api and this class using for Open Badge API v2.1 methods.

__construct($action, $url, $postparams,$multiple, $method, $json, $authrequired, $isuserbackpack, $backpackapiversion)   X-Ref
Create a mapping.

param: string $action The action of this method.
param: string $url The base url of this backpack.
param: mixed $postparams List of parameters for this method.
param: boolean $multiple This method returns an array of responses.
param: string $method get or post methods.
param: boolean $json json decode the response.
param: boolean $authrequired Authentication is required for this request.
param: boolean $isuserbackpack user backpack or a site backpack.
param: integer $backpackapiversion OpenBadges version 1 or 2.

is_match($action)   X-Ref
Does the action match this mapping?

return: boolean
param: string $action The action.

get_url($apiurl)   X-Ref
Parse the method url and insert parameters.

return: string
param: string $apiurl The raw apiurl.

get_curl_options()   X-Ref
Standard options used for all curl requests.

return: array

request($apiurl, $tokenkey, $post = [])   X-Ref
Make an api request and parse the response.

return: bool|mixed
param: string $apiurl Raw request url.
param: string $tokenkey to verify authorization.
param: array $post request method.