Skip to content

Commit

Permalink
Merge pull request #38 from azgalot/master
Browse files Browse the repository at this point in the history
MoySklad: editing building of query parameters
  • Loading branch information
gwinn authored Jan 25, 2018
2 parents 8753fd6 + 2fff52d commit 2b2ee62
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/SaaS/Service/Moysklad/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Request
/**
* Filters
*/
const FILTER_OPERANDS = array('=', '>', '<', '>=', '<=', '!=');
const FILTER_OPERANDS = array('=', '>', '<', '>=', '<=', '!=', '~', '~=', '=~');

/**
* Restrictions
Expand Down Expand Up @@ -298,9 +298,9 @@ private function httpBuildQuery($parameters)
}

if (is_array($value)) {
$filters[$name] = implode(',', $value);
$filters[$name] = implode(sprintf("&%s=", $name), $value);
} else {
$filters[$name] = $value;
$filters[$name] = urlencode($value);
}
}

Expand All @@ -309,16 +309,16 @@ private function httpBuildQuery($parameters)
}

return trim(('?' . (
!empty($params) ?
(http_build_query($params) . '&') :
!empty($params) ?
urldecode(http_build_query($params) . '&') :
''
) . $filter), '&');
}

/**
* build filter.
*
* @param array $filter
* @param array $filters
* @return string
* @access private
*/
Expand All @@ -330,7 +330,8 @@ private function buildFilter($filters)
if (!in_array($filter['operand'], self::FILTER_OPERANDS)) {
continue;
}
$params .= $filter['name'] . $filter['operand'] . urlencode($filter['value']) . ';';

$params .= $filter['name'] . urlencode($filter['operand']) . urlencode($filter['value']) . ';';
}

unset($filter);
Expand All @@ -342,7 +343,7 @@ private function buildFilter($filters)
/**
* Get error.
*
* @param array
* @param array $result
* @return string
* @access private
*/
Expand Down

0 comments on commit 2b2ee62

Please sign in to comment.