private function searchTidal($query) { $session = $this->session->get('tidal.session'); $query = ['query' => $query, 'sessionId' => $session['sessionId'], 'countryCode' => $session['countryCode'], 'limit' => 10, 'types' => 'ALBUMS,TRACKS']; $response = $this->tidal->body($this->tidal->get('search', compact('query'))); return JmesPath\search('albums.items[*].{id:id,name:title,artist:artists[0].name}', $response); }
/** * Apply processing to a single node * * @param Node $node */ public function applyToNode(Node $node) { $path = $node->getInstruction($this); $input = $node->getResult(); $result = jmespath_search($path, $input); static::objectivy($result); $node->setResult($result); }
private function createMeta(array $data, $service) { $meta = jp\search('{' . '"actions": keys(actions||`[]`),' . '"belongsTo": keys(belongsTo||`[]`),' . '"collections": keys(hasMany||`[]`),' . '"subResources": subResources.resources||`[]`,' . '"waiters": keys(waiters||`[]`)' . '}', $data); $methods = []; foreach ($meta as $key => $items) { foreach ($items as $item) { if ($key === 'waiters') { $methods["waitUntil{$item}"] = $key; } else { $methods[lcfirst($item)] = $key; } } } $meta['methods'] = $methods; $meta['serviceName'] = $service; $meta['identifiers'] = jp\search('identifiers[].name', $data) ?: []; return $meta; }
private function createMeta(array $data, $service) { $meta = jp\search('{' . '"actions": keys(actions||`[]`),' . '"related": keys(has||`[]`),' . '"collections": keys(hasMany||`[]`),' . '"waiters": keys(waiters||`[]`)' . '}', $data); $methods = []; foreach ($meta as $key => $items) { foreach ($items as $item) { if ($key === 'waiters') { $methods["waitUntil{$item}"] = $key; if ($item === 'Exists') { $methods['exists'] = 'exists'; } } else { $methods[lcfirst($item)] = $key; } } } $meta['methods'] = $methods; $meta['serviceName'] = $service; return $meta; }
private function resolveValue(array $param, Resource $resource, Command $command = null, ResultInterface $result = null) { switch ($param['source']) { // Source is pulled from the resource's identifier. case 'identifier': $id = $resource->getIdentity(); return isset($id[$param['name']]) ? $id[$param['name']] : null; // Source is pulled from the resource's data. // Source is pulled from the resource's data. case 'data': return jp\search($param['path'], $resource); // Source is pulled from the command parameters. // Source is pulled from the command parameters. case 'requestParameter': return $command[$param['path']]; // Source is pulled from the result. // Source is pulled from the result. case 'response': return $result ? $result->search($param['path']) : null; // Source is a literal value from the resource model. // Source is a literal value from the resource model. case 'string': case 'integer': case 'boolean': return $param['value']; // Invalid source type. // Invalid source type. default: throw new \InvalidArgumentException('The value "' . $param['source'] . '" is an invalid for source.'); } }