regions_api_service.module in Country codes API 6
The module which exposes services related to regions_api
File
contrib/regions_api_service/regions_api_service.module
View source
<?php
define('REGIONS_API_SERVICE_PERM', 'load raw regions data');
function regions_api_service_help($path, $arg) {
switch ($path) {
case 'admin/help#service_regions_api':
return '<p>' . t('Provides regions api methods to services applications. Requires services.module.') . '</p>';
}
}
function regions_api_service_perm() {
return array(
REGIONS_API_SERVICE_PERM,
);
}
function regions_api_service_access($account) {
return user_access(REGIONS_API_SERVICE_PERM, $account);
}
function regions_api_service_service() {
return array(
array(
'#method' => 'regions_api.load',
'#callback' => 'regions_api_service_load',
'#key' => FALSE,
'#args' => array(
array(
'#name' => 'iso2',
'#type' => 'string',
'#description' => t('An iso2 country code.'),
),
),
'#return' => 'array',
'#help' => t('Returns an array of regions.'),
),
);
}
function regions_api_service_load($iso2) {
$regions = regions_api_iso2_get_options_array($iso2);
if (!$regions) {
return services_error(t('No regions where found with the given argument.'));
}
return $regions;
}