lib/Net/Async/Spotify/API/Generated/Search.pm

filter: Statementstmt 73.0% 19 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 75.7% 25 / 33 SCAR 0.2
CC
1
Cov
73%
search
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/Net/Async/Spotify/API/Generated/Personalization.pm ↑ Summary lib/Net/Async/Spotify/Object/General.pm »
1 package Net::Async::Spotify::API::Generated::Search;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '0.001'; # VERSION
7 2 our $AUTHORITY = 'cpan:VNEALV'; # AUTHORITY
8  
9 2 ▶use mro;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use parent qw(Net::Async::Spotify::API::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use Future::AsyncAwait;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 =encoding utf8
15  
16 =head1 NAME
17  
18 Net::Async::Spotify::API::Generated::Search - Package representing Spotify Search API
19  
20 =head1 DESCRIPTION
21  
22 Autogenerated module.
23 Based on https://developer.spotify.com/documentation/web-api/reference/#reference-index
24 Check C<crawl-api-doc.pl> for more information.
25  
26 =head1 METHODS
27  
28 =cut
29  
30 =head2 search
31  
32 search - Search for an Item
33  
34 Get Spotify Catalog information about albums, artists, playlists, tracks, shows or episodes
35 that match a keyword string.
36  
37 with Request details being:
38  
39 =head3 header
40  
41 =over 4
42  
43 =item Authorization
44  
45 Type: string | Required: required
46 A valid access token from the Spotify Accounts service: see the Web API Authorization Guide for details.
47  
48 =back
49  
50 =head3 query_parameter
51  
52 =over 4
53  
54 =item include_external
55  
56 Type: string | Required: optional
57 Possible values: audio If include_external=audio
58 is specified the response will include any relevant audio content that is
59 hosted externally. By default external content is filtered out from responses.
60  
61 =item limit
62  
63 Type: integer | Required: optional
64 Maximum number of results to return. Default:
65 20 Minimum: 1 Maximum: 50 Note: The limit is applied within
66 each type, not on the total response. For example, if the limit value
67 is 3 and the type is artist,album, the response contains 3 artists and 3
68 albums.
69  
70 =item market
71  
72 Type: string | Required: optional
73 An ISO 3166-1 alpha-2 country code
74 or the string from_token. If a country code is specified, only content that is playable in that market is returned.
75 Note: - Playlist results are not affected by the market parameter.
76 - If market is set to from_token, and a valid access token is specified
77 in the request header, only content playable in the country associated with
78 the user account, is returned. - Users can view the country that is associated
79 with their account in the account settings.
80 A user must grant access to the user-read-private scope prior to when the
81 access token is issued.
82  
83 =item offset
84  
85 Type: integer | Required: optional
86 The index of the first result to return. Default:
87 0 (the first result). Maximum offset (including limit): 1,000. Use
88 with limit to get the next page of search results.
89  
90 =item q
91  
92 Type: string | Required: required
93 Search query
94 keywords and optional field filters and operators. For example: q=roadhouse%20blues.
95  
96 =item type
97  
98 Type: string | Required: required
99 A comma-separated list of item types to search
100 across. Valid types are: album , artist, playlist, track, show and episode.
101 Search results include hits from all the specified item types. For
102 example: q=name:abacab&type=album,track returns both albums and tracks
103 with “abacab” included in their name.
104  
105 =back
106  
107 and Response Objects being:
108  
109 - artist object
110 - error object
111 - target object
112 - on object
113  
114  
115 On success: In the response header the HTTP status code is 200 OK.
116 For each type provided in the type parameter, the response body contains an array of
117 artist objects /
118 simplified album objects /
119 track objects /
120 simplified show objects /
121 simplified episode objects
122 wrapped in a paging object in JSON.On error: The header status code is an error code.
123 The response body contains an error object.NotesWriting a Query - GuidelinesEncode spaces with the hex code %20 or +.Keyword matching: Matching of search keywords is not case-sensitive. Operators, however, should be specified in uppercase.
124 Unless surrounded by double quotation marks, keywords are matched in any order. For example:
125 q=roadhouse&20blues matches both “Blues Roadhouse” and “Roadhouse of the Blues”.
126 q="roadhouse&20blues" matches “My Roadhouse Blues” but not “Roadhouse of the Blues”.Searching for playlists returns results where the query keyword(s) match any part of the playlist’s name or description. Only popular public playlists are returned.Operator: The operator NOT can be used to exclude results.For example: q=roadhouse%20NOT%20blues returns items that match “roadhouse” but excludes those that also contain the keyword “blues”.Note: The operator must be specified in uppercase. Otherwise, they are handled as normal keywords to be matched.Field filters: By default, results are returned when a match is found in any field of the target object type. Searches can be made more specific by specifying an album, artist or track field filter.For example: The query q=album:gold%20artist:abba&type=album returns only albums with the text “gold” in the album name and the text “abba” in the artist name.To limit the results to a particular year, use the field filter year with album, artist, and track searches.For example: q=bob%20year:2014Or with a date range. For example: q=bob%20year:1980-2020To retrieve only albums released in the last two weeks, use the field filter tag:new in album searches.To retrieve only albums with the lowest 10% popularity, use the field filter tag:hipster in album searches.
127 Note: This field filter only works with album searches.Depending on object types being searched for, other field filters, include genre (applicable to tracks and artists), upc, and isrc.
128 For example: q=lil%20genre:%22southern%20hip%20hop%22&type=artist.
129 Use double quotation marks around the genre keyword string if it contains spaces.Notes Currently, you cannot fetch sorted results.
130 You cannot search for playlists that contain a certain track.
131 You can search only one genre at a time.
132 You cannot search for playlists within a user’s library.
133 In an effort to keep the response small, but include as much information as possible, Spotify has expanded the response and intends to continue and improve the Search endpoint.
134  
135 To query based on a release date query at a year level using the year scope. For example: The query https://api.spotify.com/v1/search?q=bob%20year:2014&type=album Returns albums released in 2014 with their names or artist names containing “bob”. You can also use the tag:new field filter to get just these albums, as well as compilations and singles, released in the last 2 weeks.Try in our Web Console
136  
137 =cut
138  
139 0 ▶async sub search {
Subroutine search: not called CC=1 SCAR=6.9
Pod documented
140 0 my ($self, %args) = @_;
141  
142 0 my $request->{method} = 'GET';
143 0 $request->{uri} = 'https://api.spotify.com/v1/search';
144 $request->{param} = {
145 0 header => {
146 'Authorization' => {
147 type => 'string',
148 required => 'required',
149 },
150 },
151 query_parameter => {
152 'include_external' => {
153 type => 'string',
154 required => 'optional',
155 },
156 'limit' => {
157 type => 'integer',
158 required => 'optional',
159 },
160 'market' => {
161 type => 'string',
162 required => 'optional',
163 },
164 'offset' => {
165 type => 'integer',
166 required => 'optional',
167 },
168 'q' => {
169 type => 'string',
170 required => 'required',
171 },
172 'type' => {
173 type => 'string',
174 required => 'required',
175 },
176 },
177 };
178 0 my $response_objs = [
179 'artist object',
180 'error object',
181 'target object',
182 'on object',
183  
184 ];
185  
186 0 await $self->call_api($request, $response_objs, %args);
187 2 }
188  
189 2 1;
« lib/Net/Async/Spotify/API/Generated/Personalization.pm ↑ Summary lib/Net/Async/Spotify/Object/General.pm »