View source
<?php
define('COUNTRIES_API_SERVICE_PERM', 'load raw regions data');
function countries_api_service_help($section) {
switch ($section) {
case 'admin/help#service_countries_api':
return '<p>' . t('Provides countries api methods to services applications. Requires services.module.</p>') . '<p>';
}
}
function countries_api_service_perm() {
return array(
COUNTRIES_API_SERVICE_PERM,
);
}
function countries_api_service_access() {
return user_access(COUNTRIES_API_SERVICE_PERM);
}
function countries_api_service_service() {
return array(
array(
'#method' => 'countries_api.countries_api_get_country',
'#callback' => 'countries_api_service_get_country',
'#key' => FALSE,
'#args' => array(
array(
'#name' => 'code',
'#type' => 'string',
'#description' => t('An iso3 country code.'),
),
),
'#return' => 'array',
'#help' => t('Returns an array of country fields.'),
),
array(
'#method' => 'countries_api.countries_api_service_iso2_get_country',
'#callback' => 'countries_api_service_iso2_get_country',
'#key' => FALSE,
'#args' => array(
array(
'#name' => 'code',
'#type' => 'string',
'#description' => t('An iso2 country code.'),
),
),
'#return' => 'array',
'#help' => t('Returns an array of country fields.'),
),
array(
'#method' => 'countries_api.countries_api_service_iso3_get_country',
'#callback' => 'countries_api_service_iso3_get_country',
'#key' => FALSE,
'#args' => array(
array(
'#name' => 'code',
'#type' => 'string',
'#description' => t('An iso3 country code.'),
),
),
'#return' => 'array',
'#help' => t('Returns an array of country fields.'),
),
);
}
function countries_api_service_get_country($code) {
$countries = countries_api_service_get_country($code);
if (!$countries) {
return services_error(t('No countries where found with the given argument.'));
}
return $countries;
}
function countries_api_service_iso2_get_country($code) {
$countries = countries_api_iso2_get_country($code);
if (!$countries) {
return services_error(t('No countries where found with the given argument.'));
}
return $countries;
}
function countries_api_service_iso3_get_country($code) {
$countries = countries_api_iso3_get_country($code);
if (!$countries) {
return services_error(t('No countries where found with the given argument.'));
}
return $countries;
}