├── .gitignore
├── LICENSE
├── README.md
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── me
│ │ └── siegenthaler
│ │ └── spotify
│ │ └── webapi
│ │ └── android
│ │ └── example
│ │ └── ExampleActivity.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_launcher.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ ├── layout
│ └── activity_main.xml
│ ├── menu
│ └── home_menu.xml
│ ├── values
│ ├── strings.xml
│ └── styles.xml
│ └── xml
│ └── my_searchable.xml
├── build.gradle
├── gradle.properties
├── gradle
├── scripts
│ └── gradle-mvn-push.gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── gradle.properties
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── me
│ └── siegenthaler
│ └── spotify
│ └── webapi
│ └── android
│ ├── ClientRestAPI.java
│ ├── model
│ ├── Album.java
│ ├── Artist.java
│ ├── Followers.java
│ ├── Image.java
│ ├── Page.java
│ ├── Playlist.java
│ ├── SimpleAlbum.java
│ ├── SimpleArtist.java
│ ├── SimplePlaylist.java
│ ├── SimplePlaylistBase.java
│ ├── SimpleTrack.java
│ ├── SimpleUser.java
│ ├── Snapshot.java
│ ├── Token.java
│ ├── Track.java
│ └── User.java
│ └── request
│ ├── AbstractPageRequest.java
│ ├── AbstractRequest.java
│ ├── AlbumListRequest.java
│ ├── AlbumRequest.java
│ ├── AlbumTracksRequest.java
│ ├── ArtistAlbumsRequest.java
│ ├── ArtistListRequest.java
│ ├── ArtistRelatedRequest.java
│ ├── ArtistRequest.java
│ ├── ArtistTopTrackRequest.java
│ ├── AuthoriseClientFlowRequest.java
│ ├── AuthoriseRefreshRequest.java
│ ├── PlaylistAddTracksRequest.java
│ ├── PlaylistChangeDetailsRequest.java
│ ├── PlaylistCreateRequest.java
│ ├── PlaylistListRequest.java
│ ├── PlaylistReplaceTracksRequest.java
│ ├── PlaylistRequest.java
│ ├── PlaylistTrackRequest.java
│ ├── SearchAlbumRequest.java
│ ├── SearchArtistRequest.java
│ ├── SearchPlaylistRequest.java
│ ├── SearchRequest.java
│ ├── SearchTrackRequest.java
│ ├── TrackListRequest.java
│ ├── TrackRequest.java
│ ├── browse
│ ├── BrowseAlbumRequest.java
│ └── BrowsePlaylistRequest.java
│ ├── follow
│ ├── FollowAddRequest.java
│ ├── FollowCheckRequest.java
│ └── FollowRemoveRequest.java
│ ├── music
│ ├── MusicAddRequest.java
│ ├── MusicRemoveRequest.java
│ ├── MusicTrackCheckRequest.java
│ └── MusicTrackRequest.java
│ └── profile
│ ├── UserElseRequest.java
│ └── UserRequest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | /.gradle
2 | /local.properties
3 | /.idea
4 | /build
5 | /*.iml
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TODO
2 |
3 | 1. Add missing request.
4 | 2. Add missing JavaDoc.
5 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | ///
2 | /// Apply executable plug-in to build the application
3 | ///
4 | apply plugin: 'com.android.application'
5 |
6 | ///
7 | /// Android information
8 | ///
9 | android {
10 | ///
11 | /// Use API 21 for compiling and building
12 | ///
13 | compileSdkVersion 21
14 | buildToolsVersion "21.1.2"
15 |
16 | ///
17 | /// Application configuration targeting Android 14+
18 | ///
19 | defaultConfig {
20 | applicationId "me.siegenthaler.spotify.webapi.android.example"
21 | minSdkVersion 14
22 | targetSdkVersion 21
23 | versionCode 1
24 | versionName "1.0"
25 | }
26 |
27 | ///
28 | /// Use Java7
29 | ///
30 | compileOptions {
31 | sourceCompatibility JavaVersion.VERSION_1_7
32 | targetCompatibility JavaVersion.VERSION_1_7
33 | }
34 | }
35 |
36 | ///
37 | /// Dependencies
38 | ///
39 | dependencies {
40 | compile 'com.android.support:appcompat-v7:21.0.3'
41 | compile project(':library');
42 | }
43 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/wolftein/Applications/android/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
11 |
14 |
15 |
16 |
19 |
24 |
25 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/java/me/siegenthaler/spotify/webapi/android/example/ExampleActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.example;
17 |
18 | import android.app.SearchManager;
19 | import android.content.Context;
20 | import android.os.Bundle;
21 | import android.support.v7.app.ActionBarActivity;
22 | import android.support.v7.widget.SearchView;
23 | import android.support.v7.widget.Toolbar;
24 | import android.util.Log;
25 | import android.view.Menu;
26 | import android.view.MenuItem;
27 | import android.view.View;
28 |
29 | import com.android.volley.Response;
30 | import com.android.volley.error.VolleyError;
31 | import com.android.volley.toolbox.Volley;
32 |
33 | import java.util.List;
34 |
35 | import me.siegenthaler.spotify.webapi.android.ClientRestAPI;
36 | import me.siegenthaler.spotify.webapi.android.model.Album;
37 | import me.siegenthaler.spotify.webapi.android.model.Page;
38 | import me.siegenthaler.spotify.webapi.android.model.Track;
39 |
40 | /**
41 | *
42 | */
43 | public class ExampleActivity extends ActionBarActivity {
44 | private ClientRestAPI mClient;
45 |
46 | /**
47 | * {@inheritDoc}
48 | */
49 | @Override
50 | public void onCreate(Bundle instance) {
51 | super.onCreate(instance);
52 | setContentView(R.layout.activity_main);
53 |
54 | final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
55 | setSupportActionBar(toolbar);
56 |
57 | mClient = new ClientRestAPI(Volley.newRequestQueue(getApplicationContext()));
58 |
59 | findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
60 | @Override
61 | public void onClick(View v) {
62 | Log.d("XXX", "Click");
63 | mClient.getAlbum("2dIGnmEIy1WZIcZCFSj6i8").setListener(new Response.Listener() {
64 | @Override
65 | public void onResponse(Album o) {
66 | Log.d("XXX", o.getName());
67 | }
68 | }).setErrorListener(new Response.ErrorListener() {
69 | @Override
70 | public void onErrorResponse(VolleyError volleyError) {
71 | Log.d("XXX", "ERROR:" + volleyError.getMessage());
72 | }
73 | }).build();
74 | }
75 | });
76 | }
77 |
78 | /**
79 | * {@inheritDoc}
80 | */
81 | @Override
82 | public boolean onCreateOptionsMenu(Menu menu) {
83 | super.onCreateOptionsMenu(menu);
84 | getMenuInflater().inflate(R.menu.home_menu, menu);
85 |
86 | final MenuItem item
87 | = menu.findItem(R.id.search);
88 | final SearchView view
89 | = (SearchView) item.getActionView();
90 | final SearchManager manager
91 | = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
92 | view.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
93 | @Override
94 | public boolean onQueryTextSubmit(String s) {
95 | return false;
96 | }
97 |
98 | @Override
99 | public boolean onQueryTextChange(String s) {
100 | onTextChange(s);
101 | return true;
102 | }
103 | });
104 | view.setSearchableInfo(manager.getSearchableInfo(getComponentName()));
105 | return true;
106 | }
107 |
108 | /**
109 | * (non-doc)
110 | */
111 | private void onTextChange(String query) {
112 | mClient.getRequestQueue().cancelAll("SEARCH");
113 | mClient.searchTrack(query).setListener(new Response.Listener>() {
114 | @Override
115 | public void onResponse(Page tracks) {
116 | final List items = tracks.getItems();
117 | for (Track item : items) {
118 | Log.d("Track", item.getArtist(0).getName() + " - " + item.getName());
119 | }
120 | }
121 | }).setErrorListener(new Response.ErrorListener() {
122 | @Override
123 | public void onErrorResponse(VolleyError volleyError) {
124 | volleyError.printStackTrace();
125 | }
126 | }).setLimit(25).setTag("SEARCH").build();
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SiegenthalerSolutions/spotify-web-api-android/cd16fa94e428391963c7d7e2592b9423c3437d8c/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SiegenthalerSolutions/spotify-web-api-android/cd16fa94e428391963c7d7e2592b9423c3437d8c/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SiegenthalerSolutions/spotify-web-api-android/cd16fa94e428391963c7d7e2592b9423c3437d8c/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SiegenthalerSolutions/spotify-web-api-android/cd16fa94e428391963c7d7e2592b9423c3437d8c/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
12 |
17 |
18 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/home_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
11 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | spotify-web-api-example
10 | Search for a track
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/my_searchable.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.0.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/scripts/gradle-mvn-push.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Chris Banes
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | apply plugin: 'maven'
17 | apply plugin: 'signing'
18 |
19 | def getRepositoryUrl() {
20 | return hasProperty('NEXUS_REPOSITORY') ? NEXUS_REPOSITORY
21 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
22 | }
23 |
24 | def getRepositoryUsername() {
25 | return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
26 | }
27 |
28 | def getRepositoryPassword() {
29 | return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
30 | }
31 |
32 | afterEvaluate { project ->
33 | uploadArchives {
34 | repositories {
35 | mavenDeployer {
36 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
37 |
38 | pom.groupId = POM_GROUP
39 | pom.artifactId = POM_ARTIFACT_ID
40 | pom.version = POM_VERSION_NAME
41 |
42 | repository(url: getRepositoryUrl()) {
43 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
44 | }
45 |
46 | pom.project {
47 | name POM_NAME
48 | packaging POM_PACKAGING
49 | }
50 | }
51 | }
52 | }
53 |
54 | signing {
55 | required { gradle.taskGraph.hasTask("uploadArchives") }
56 | sign configurations.archives
57 | }
58 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SiegenthalerSolutions/spotify-web-api-android/cd16fa94e428391963c7d7e2592b9423c3437d8c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /*.iml
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | ///
2 | /// Apply executable plug-in to build the library
3 | ///
4 | apply plugin: 'com.android.library'
5 |
6 | ///
7 | /// Android information
8 | ///
9 | android {
10 | ///
11 | /// Use API 21 for compiling and building
12 | ///
13 | compileSdkVersion 21
14 | buildToolsVersion "21.1.2"
15 |
16 | ///
17 | /// Application configuration targeting Android 14+
18 | ///
19 | defaultConfig {
20 | minSdkVersion 10
21 | targetSdkVersion 21
22 | }
23 |
24 | ///
25 | /// Use Java7
26 | ///
27 | compileOptions {
28 | sourceCompatibility JavaVersion.VERSION_1_7
29 | targetCompatibility JavaVersion.VERSION_1_7
30 | }
31 | }
32 |
33 | ///
34 | /// Dependencies
35 | ///
36 | dependencies {
37 | compile 'com.google.code.gson:gson:2.3.1' // Service-JSON
38 | compile 'dev.dworks.libs:volleyplus:+' // Service-Threading
39 | }
40 |
41 | ///
42 | /// Apply Gradle-Maven-Plug-in
43 | ///
44 | apply from: "${rootDir}/gradle/scripts/gradle-mvn-push.gradle"
--------------------------------------------------------------------------------
/library/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_GROUP = me.siegenthaler
2 | POM_NAME = spotify-web-api
3 | POM_VERSION_NAME = 1.0.0
4 | POM_ARTIFACT_ID = spotify-web-api
5 | POM_PACKAGING = aar
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/ClientRestAPI.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android;
17 |
18 | import com.android.volley.RequestQueue;
19 |
20 | import me.siegenthaler.spotify.webapi.android.model.Token;
21 | import me.siegenthaler.spotify.webapi.android.request.AbstractRequest;
22 | import me.siegenthaler.spotify.webapi.android.request.AlbumListRequest;
23 | import me.siegenthaler.spotify.webapi.android.request.AlbumRequest;
24 | import me.siegenthaler.spotify.webapi.android.request.AlbumTracksRequest;
25 | import me.siegenthaler.spotify.webapi.android.request.ArtistAlbumsRequest;
26 | import me.siegenthaler.spotify.webapi.android.request.ArtistListRequest;
27 | import me.siegenthaler.spotify.webapi.android.request.ArtistRelatedRequest;
28 | import me.siegenthaler.spotify.webapi.android.request.ArtistRequest;
29 | import me.siegenthaler.spotify.webapi.android.request.ArtistTopTrackRequest;
30 | import me.siegenthaler.spotify.webapi.android.request.AuthoriseClientFlowRequest;
31 | import me.siegenthaler.spotify.webapi.android.request.AuthoriseRefreshRequest;
32 | import me.siegenthaler.spotify.webapi.android.request.PlaylistAddTracksRequest;
33 | import me.siegenthaler.spotify.webapi.android.request.PlaylistChangeDetailsRequest;
34 | import me.siegenthaler.spotify.webapi.android.request.PlaylistCreateRequest;
35 | import me.siegenthaler.spotify.webapi.android.request.PlaylistListRequest;
36 | import me.siegenthaler.spotify.webapi.android.request.PlaylistReplaceTracksRequest;
37 | import me.siegenthaler.spotify.webapi.android.request.PlaylistRequest;
38 | import me.siegenthaler.spotify.webapi.android.request.PlaylistTrackRequest;
39 | import me.siegenthaler.spotify.webapi.android.request.SearchAlbumRequest;
40 | import me.siegenthaler.spotify.webapi.android.request.SearchArtistRequest;
41 | import me.siegenthaler.spotify.webapi.android.request.SearchPlaylistRequest;
42 | import me.siegenthaler.spotify.webapi.android.request.SearchTrackRequest;
43 | import me.siegenthaler.spotify.webapi.android.request.TrackListRequest;
44 | import me.siegenthaler.spotify.webapi.android.request.TrackRequest;
45 | import me.siegenthaler.spotify.webapi.android.request.browse.BrowseAlbumRequest;
46 | import me.siegenthaler.spotify.webapi.android.request.browse.BrowsePlaylistRequest;
47 | import me.siegenthaler.spotify.webapi.android.request.follow.FollowAddRequest;
48 | import me.siegenthaler.spotify.webapi.android.request.follow.FollowCheckRequest;
49 | import me.siegenthaler.spotify.webapi.android.request.follow.FollowRemoveRequest;
50 | import me.siegenthaler.spotify.webapi.android.request.music.MusicAddRequest;
51 | import me.siegenthaler.spotify.webapi.android.request.music.MusicRemoveRequest;
52 | import me.siegenthaler.spotify.webapi.android.request.music.MusicTrackCheckRequest;
53 | import me.siegenthaler.spotify.webapi.android.request.music.MusicTrackRequest;
54 | import me.siegenthaler.spotify.webapi.android.request.profile.UserElseRequest;
55 | import me.siegenthaler.spotify.webapi.android.request.profile.UserRequest;
56 |
57 | /**
58 | * (non-doc)
59 | */
60 | public class ClientRestAPI {
61 | /**
62 | * Default port of Spotify API calls.
63 | */
64 | private static final int DEFAULT_PORT = 443;
65 |
66 | /**
67 | * Default http scheme of Spotify API calls.
68 | */
69 | private static final String DEFAULT_SCHEME = "https";
70 |
71 | /**
72 | * Default host of Spotify API calls.
73 | */
74 | private static final String DEFAULT_HOST = "api.spotify.com";
75 |
76 | /**
77 | * Default host of Spotify authentication API calls.
78 | */
79 | private static final String DEFAULT_AUTHENTICATION_HOST = "accounts.spotify.com";
80 |
81 | private final RequestQueue mRequestQueue;
82 | private Token mToken = null;
83 |
84 | /**
85 | * (non-doc)
86 | */
87 | public ClientRestAPI(RequestQueue queue) {
88 | this.mRequestQueue = queue;
89 | }
90 |
91 | /**
92 | * (non-doc)
93 | */
94 | public RequestQueue getRequestQueue() {
95 | return mRequestQueue;
96 | }
97 |
98 | /**
99 | * (non-doc)
100 | */
101 | public void setToken(Token token) {
102 | mToken = token;
103 | }
104 |
105 | /**
106 | * (non-doc)
107 | */
108 | public AuthoriseClientFlowRequest authorise(String clientId, String clientSecret) {
109 | return addAuthenticationHeader(new AuthoriseClientFlowRequest())
110 | .setAuthorisation(clientId, clientSecret)
111 | .setType("client_credentials");
112 | }
113 |
114 | /**
115 | * (non-doc)
116 | */
117 | public AuthoriseRefreshRequest refresh(String clientId, String clientSecret, String code, String redirectUri) {
118 | return addAuthenticationHeader(new AuthoriseRefreshRequest())
119 | .setAuthorisation(clientId, clientSecret)
120 | .setCode(code)
121 | .setRedirectUri(redirectUri);
122 | }
123 |
124 | /**
125 | * (non-doc)
126 | */
127 | public AlbumRequest getAlbum(String id) {
128 | return addDefaultHeader(new AlbumRequest()).setAlbum(id);
129 | }
130 |
131 | /**
132 | * (non-doc)
133 | */
134 | public AlbumListRequest getAlbums(String... id) {
135 | return addDefaultHeader(new AlbumListRequest()).setAlbums(id);
136 | }
137 |
138 | /**
139 | * (non-doc)
140 | */
141 | public AlbumTracksRequest getAlbumTracks(String id) {
142 | return addDefaultHeader(new AlbumTracksRequest()).setAlbum(id);
143 | }
144 |
145 | /**
146 | * (non-doc)
147 | */
148 | public ArtistRequest getArtist(String id) {
149 | return addDefaultHeader(new ArtistRequest()).setArtist(id);
150 | }
151 |
152 | /**
153 | * (non-doc)
154 | */
155 | public ArtistListRequest getArtists(String... id) {
156 | return addDefaultHeader(new ArtistListRequest()).setArtists(id);
157 | }
158 |
159 | /**
160 | * (non-doc)
161 | */
162 | public ArtistAlbumsRequest getArtistAlbums(String id) {
163 | return addDefaultHeader(new ArtistAlbumsRequest()).setArtist(id);
164 | }
165 |
166 | /**
167 | * (non-doc)
168 | */
169 | public ArtistRelatedRequest getArtistsRelated(String id) {
170 | return addDefaultHeader(new ArtistRelatedRequest()).setArtist(id);
171 | }
172 |
173 | /**
174 | * (non-doc)
175 | */
176 | public ArtistTopTrackRequest getArtistTopTracks(String id) {
177 | return addDefaultHeader(new ArtistTopTrackRequest()).setArtist(id);
178 | }
179 |
180 | /**
181 | * (non-doc)
182 | */
183 | public BrowsePlaylistRequest browsePlaylists() {
184 | return addDefaultHeader(new BrowsePlaylistRequest());
185 | }
186 |
187 | /**
188 | * (non-doc)
189 | */
190 | public BrowseAlbumRequest browseAlbums() {
191 | return addDefaultHeader(new BrowseAlbumRequest());
192 | }
193 |
194 |
195 | /**
196 | * (non-doc)
197 | */
198 | public MusicTrackCheckRequest containsInMusic(String... ids) {
199 | return addDefaultHeader(new MusicTrackCheckRequest()).setIds(ids);
200 | }
201 |
202 | /**
203 | * (non-doc)
204 | */
205 | public MusicAddRequest addToMusic(String... ids) {
206 | return addDefaultHeader(new MusicAddRequest()).setTracks(ids);
207 | }
208 |
209 | /**
210 | * (non-doc)
211 | */
212 | public MusicRemoveRequest removeFromMusic(String... ids) {
213 | return addDefaultHeader(new MusicRemoveRequest()).setTracks(ids);
214 | }
215 |
216 | /**
217 | * (non-doc)
218 | */
219 | public MusicTrackRequest getMusicTracks() {
220 | return addDefaultHeader(new MusicTrackRequest());
221 | }
222 |
223 | /**
224 | * (non-doc)
225 | */
226 | public FollowAddRequest addFollower(String type, String... ids) {
227 | return addDefaultHeader(new FollowAddRequest().setType(type).setIds(ids));
228 | }
229 |
230 | /**
231 | * (non-doc)
232 | */
233 | public FollowRemoveRequest removeFollower(String type, String... ids) {
234 | return addDefaultHeader(new FollowRemoveRequest().setType(type).setIds(ids));
235 | }
236 |
237 | /**
238 | * (non-doc)
239 | */
240 | public FollowCheckRequest isFollowing(String type, String... ids) {
241 | return addDefaultHeader(new FollowCheckRequest().setType(type).setIds(ids));
242 | }
243 |
244 | /**
245 | * (non-doc)
246 | */
247 | public PlaylistAddTracksRequest addTrackToPlaylist(String user, String playlist) {
248 | return addDefaultHeader(new PlaylistAddTracksRequest().setPlaylist(user, playlist));
249 | }
250 |
251 | /**
252 | * (non-doc)
253 | */
254 | public PlaylistChangeDetailsRequest changePlaylistDetail(String user, String playlist) {
255 | return addDefaultHeader(new PlaylistChangeDetailsRequest().setPlaylist(user, playlist));
256 | }
257 |
258 | /**
259 | * (non-doc)
260 | */
261 | public PlaylistCreateRequest createPlaylist(String user, String playlist) {
262 | return addDefaultHeader(new PlaylistCreateRequest().setUser(user).serName(playlist));
263 | }
264 |
265 | /**
266 | * (non-doc)
267 | */
268 | public PlaylistReplaceTracksRequest replacePlaylistTracks(String user, String playlist) {
269 | return addDefaultHeader(new PlaylistReplaceTracksRequest().setPlaylist(user, playlist));
270 | }
271 |
272 | /**
273 | * (non-doc)
274 | */
275 | public PlaylistRequest getPlaylist(String user, String id) {
276 | return addDefaultHeader(new PlaylistRequest()).setPlaylist(user, id);
277 | }
278 |
279 | /**
280 | * (non-doc)
281 | */
282 | public PlaylistTrackRequest getPlaylistTracks(String user, String id) {
283 | return addDefaultHeader(new PlaylistTrackRequest()).setPlaylist(user, id);
284 | }
285 |
286 | /**
287 | * (non-doc)
288 | */
289 | public PlaylistListRequest getPlaylists(String user) {
290 | return addDefaultHeader(new PlaylistListRequest()).setUser(user);
291 | }
292 |
293 | /**
294 | * (non-doc)
295 | */
296 | public SearchAlbumRequest searchAlbum(String query) {
297 | return addDefaultHeader(new SearchAlbumRequest()).setQuery(query);
298 | }
299 |
300 | /**
301 | * (non-doc)
302 | */
303 | public SearchArtistRequest searchArtist(String query) {
304 | return addDefaultHeader(new SearchArtistRequest()).setQuery(query);
305 | }
306 |
307 | /**
308 | * (non-doc)
309 | */
310 | public SearchPlaylistRequest searchPlaylist(String query) {
311 | return addDefaultHeader(new SearchPlaylistRequest()).setQuery(query);
312 | }
313 |
314 | /**
315 | * (non-doc)
316 | */
317 | public SearchTrackRequest searchTrack(String query) {
318 | return addDefaultHeader(new SearchTrackRequest()).setQuery(query);
319 | }
320 |
321 | /**
322 | * (non-doc)
323 | */
324 | public TrackRequest getTrack(String id) {
325 | return addDefaultHeader(new TrackRequest()).setTrack(id);
326 | }
327 |
328 | /**
329 | * (non-doc)
330 | */
331 | public TrackListRequest getTracks(String... id) {
332 | return addDefaultHeader(new TrackListRequest()).setTracks(id);
333 | }
334 |
335 | /**
336 | * (non-doc)
337 | */
338 | public UserRequest getUser() {
339 | return addDefaultHeader(new UserRequest());
340 | }
341 |
342 | /**
343 | * (non-doc)
344 | */
345 | public UserElseRequest getUser(String id) {
346 | return addDefaultHeader(new UserElseRequest().setUser(id));
347 | }
348 |
349 | /**
350 | * (non-doc)
351 | */
352 | protected > T addAuthenticationHeader(T request) {
353 | return request.setClient(mRequestQueue).setHost(DEFAULT_AUTHENTICATION_HOST);
354 | }
355 |
356 | /**
357 | * (non-doc)
358 | */
359 | protected > T addDefaultHeader(T request) {
360 | if (mToken != null) {
361 | request.addHeader("Authorization", "Bearer " + mToken.getToken());
362 | }
363 | return request.setClient(mRequestQueue).setHost(DEFAULT_HOST);
364 | }
365 | }
366 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/Album.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | import java.util.List;
21 | import java.util.Map;
22 |
23 | /**
24 | * (non-doc)
25 | */
26 | public class Album extends SimpleAlbum {
27 | @SerializedName("artists")
28 | private List mArtists;
29 |
30 | @SerializedName("copyrights")
31 | private List mCopyrights;
32 |
33 | @SerializedName("external_ids")
34 | private Map mExternalIds;
35 |
36 | @SerializedName("genres")
37 | private List mGenres;
38 |
39 | @SerializedName("popularity")
40 | private int mPopularity;
41 |
42 | @SerializedName("release_date")
43 | private String mReleaseDate;
44 |
45 | @SerializedName("release_date_precision")
46 | private String mReleasePrecision;
47 |
48 | @SerializedName("tracks")
49 | private Page mTracks;
50 |
51 | /**
52 | * (non-doc)
53 | */
54 | final public SimpleArtist getArtist(int index) {
55 | if (index < 0 || index >= mArtists.size()) {
56 | throw new IllegalArgumentException();
57 | }
58 | return mArtists.get(index);
59 | }
60 |
61 | /**
62 | * (non-doc)
63 | */
64 | final public List getArtists() {
65 | return mArtists;
66 | }
67 |
68 | /**
69 | * (non-doc)
70 | */
71 | final public Copyright getCopyright(int index) {
72 | if (index < 0 || index >= mArtists.size()) {
73 | throw new IllegalArgumentException();
74 | }
75 | return mCopyrights.get(index);
76 | }
77 |
78 | /**
79 | * (non-doc)
80 | */
81 | final public List getCopyrights() {
82 | return mCopyrights;
83 | }
84 |
85 | /**
86 | * (non-doc)
87 | */
88 | final public Map getExternalIds() {
89 | return mExternalIds;
90 | }
91 |
92 | /**
93 | * (non-doc)
94 | */
95 | final public String getGenre(int index) {
96 | if (index < 0 || index >= mGenres.size()) {
97 | throw new IllegalArgumentException();
98 | }
99 | return mGenres.get(index);
100 | }
101 |
102 | /**
103 | * (non-doc)
104 | */
105 | final public List getGenres() {
106 | return mGenres;
107 | }
108 |
109 | /**
110 | * (non-doc)
111 | */
112 | final public int getPopularity() {
113 | return mPopularity;
114 | }
115 |
116 | /**
117 | * (non-doc)
118 | */
119 | final public String getReleaseData() {
120 | return mReleaseDate;
121 | }
122 |
123 | /**
124 | * (non-doc)
125 | */
126 | final public String getReleaseDatePrecision() {
127 | return mReleasePrecision;
128 | }
129 |
130 | /**
131 | * (non-doc)
132 | */
133 | final public Page getTracks() {
134 | return mTracks;
135 | }
136 |
137 | /**
138 | * (non-doc)
139 | */
140 | public final static class Copyright {
141 | @SerializedName("text")
142 | private String mText;
143 |
144 | @SerializedName("type")
145 | private String mType;
146 |
147 | /**
148 | * (non-doc)
149 | */
150 | public String getText() {
151 | return mText;
152 | }
153 |
154 | /**
155 | * (non-doc)
156 | */
157 | public String getType() {
158 | return mType;
159 | }
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/Artist.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public class Artist extends SimpleArtist {
26 | @SerializedName("followers")
27 | private Followers mFollowers;
28 |
29 | @SerializedName("genres")
30 | private List mGenres;
31 |
32 | @SerializedName("images")
33 | private List mImages;
34 |
35 | @SerializedName("popularity")
36 | private int mPopularity;
37 |
38 | /**
39 | * (non-doc)
40 | */
41 | final public Followers getFollowers() {
42 | return mFollowers;
43 | }
44 |
45 | /**
46 | * (non-doc)
47 | */
48 | final public Image getImage(int index) {
49 | if (index < 0 || index >= mImages.size()) {
50 | throw new IllegalArgumentException();
51 | }
52 | return mImages.get(index);
53 | }
54 |
55 | /**
56 | * (non-doc)
57 | */
58 | final public List getImages() {
59 | return mImages;
60 | }
61 |
62 | /**
63 | * (non-doc)
64 | */
65 | final public String getGenre(int index) {
66 | if (index < 0 || index >= mGenres.size()) {
67 | throw new IllegalArgumentException();
68 | }
69 | return mGenres.get(index);
70 | }
71 |
72 | /**
73 | * (non-doc)
74 | */
75 | final public List getGenres() {
76 | return mGenres;
77 | }
78 |
79 | /**
80 | * (non-doc)
81 | */
82 | final public int getPopularity() {
83 | return mPopularity;
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/Followers.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | /**
21 | * (non-doc)
22 | */
23 | public class Followers {
24 | @SerializedName("href")
25 | private String mHref;
26 |
27 | @SerializedName("total")
28 | private int mTotal;
29 |
30 | /**
31 | * (non-doc)
32 | */
33 | final public String getHref() {
34 | return mHref;
35 | }
36 |
37 | /**
38 | * (non-doc)
39 | */
40 | final public int getTotal() {
41 | return mTotal;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/Image.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | /**
21 | * (non-doc)
22 | */
23 | public class Image {
24 | @SerializedName("link")
25 | private String mLink;
26 |
27 | @SerializedName("width")
28 | private int mWidth;
29 |
30 | @SerializedName("height")
31 | private int mHeight;
32 |
33 | /**
34 | * (non-doc)
35 | */
36 | final public String getLink() {
37 | return mLink;
38 | }
39 |
40 | /**
41 | * (non-doc)
42 | */
43 | final public int getWidth() {
44 | return mWidth;
45 | }
46 |
47 | /**
48 | * (non-doc)
49 | */
50 | final public int getHeight() {
51 | return mHeight;
52 | }
53 | }
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/Page.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | import org.json.JSONException;
21 | import org.json.JSONObject;
22 |
23 | import java.util.List;
24 |
25 | /**
26 | * (non-doc)
27 | */
28 | public class Page {
29 | @SerializedName("href")
30 | private String mHref;
31 |
32 | @SerializedName("items")
33 | private List mItems;
34 |
35 | @SerializedName("limit")
36 | private int mLimit;
37 |
38 | @SerializedName("next")
39 | private String mNext;
40 |
41 | @SerializedName("offset")
42 | private int mOffset;
43 |
44 | @SerializedName("previous")
45 | private String mPrevious;
46 |
47 | @SerializedName("total")
48 | private int mTotal;
49 |
50 | /**
51 | * (non-doc)
52 | */
53 | final public String getHref() {
54 | return mHref;
55 | }
56 |
57 | /**
58 | * (non-doc)
59 | */
60 | final public List getItems() {
61 | return mItems;
62 | }
63 |
64 | /**
65 | * (non-doc)
66 | */
67 | final public int getLimit() {
68 | return mLimit;
69 | }
70 |
71 | /**
72 | * (non-doc)
73 | */
74 | final public String getNext() {
75 | return mNext;
76 | }
77 |
78 | /**
79 | * (non-doc)
80 | */
81 | final public int getOffset() {
82 | return mOffset;
83 | }
84 |
85 | /**
86 | * (non-doc)
87 | */
88 | final public String getPrevious() {
89 | return mPrevious;
90 | }
91 |
92 | /**
93 | * (non-doc)
94 | */
95 | final public int getTotal() {
96 | return mTotal;
97 | }
98 | }
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/Playlist.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | /**
21 | * (non-doc)
22 | */
23 | public class Playlist extends SimplePlaylistBase {
24 | @SerializedName("description")
25 | private String mDescription;
26 |
27 | @SerializedName("followers")
28 | private Followers mFollowers;
29 |
30 | @SerializedName("snapshot_id")
31 | private String mSnapshotId;
32 |
33 | @SerializedName("tracks")
34 | private Page mTracks;
35 |
36 | /**
37 | * (non-doc)
38 | */
39 | final public String getDescription() {
40 | return mDescription;
41 | }
42 |
43 | /**
44 | * (non-doc)
45 | */
46 | final public Followers getFollowers() {
47 | return mFollowers;
48 | }
49 |
50 | /**
51 | * (non-doc)
52 | */
53 | final public String getSnapshotId() {
54 | return mSnapshotId;
55 | }
56 |
57 | /**
58 | * (non-doc)
59 | */
60 | final public Page getTracks() {
61 | return mTracks;
62 | }
63 |
64 | /**
65 | * (non-doc)
66 | */
67 | public static final class Information {
68 | @SerializedName("added_at")
69 | private String mAddedAt;
70 |
71 | @SerializedName("added_by")
72 | private SimpleUser mAddedBy;
73 |
74 | @SerializedName("track")
75 | private Track mTrack;
76 |
77 | /**
78 | * (non-doc)
79 | */
80 | public String getAddedAt() {
81 | return mAddedAt;
82 | }
83 |
84 | /**
85 | * (non-doc)
86 | */
87 | public SimpleUser getAddedBy() {
88 | return mAddedBy;
89 | }
90 |
91 | /**
92 | * (non-doc)
93 | */
94 | public Track getTrack() {
95 | return mTrack;
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/SimpleAlbum.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | import java.util.List;
21 | import java.util.Map;
22 |
23 | /**
24 | * (non-doc)
25 | */
26 | public class SimpleAlbum {
27 | @SerializedName("album_type")
28 | private String mAlbumType;
29 |
30 | @SerializedName("available_markets")
31 | private List mAvailableMarkets;
32 |
33 | @SerializedName("external_urls")
34 | private Map mExternalUrls;
35 |
36 | @SerializedName("href")
37 | private String mHref;
38 |
39 | @SerializedName("id")
40 | private String mId;
41 |
42 | @SerializedName("images")
43 | private List mImages;
44 |
45 | @SerializedName("name")
46 | private String mName;
47 |
48 | @SerializedName("type")
49 | private String mType;
50 |
51 | @SerializedName("uri")
52 | private String mUri;
53 |
54 | /**
55 | * (non-doc)
56 | */
57 | final public String getAlbumType() {
58 | return mAlbumType;
59 | }
60 |
61 | /**
62 | * (non-doc)
63 | */
64 | final public boolean isAvailable(String market) {
65 | return mAvailableMarkets.contains(market);
66 | }
67 |
68 | /**
69 | * (non-doc)
70 | */
71 | final public List getAvailableMarkets() {
72 | return mAvailableMarkets;
73 | }
74 |
75 | /**
76 | * (non-doc)
77 | */
78 | final public Map getExternalUrls() {
79 | return mExternalUrls;
80 | }
81 |
82 | /**
83 | * (non-doc)
84 | */
85 | final public String getHref() {
86 | return mHref;
87 | }
88 |
89 | /**
90 | * (non-doc)
91 | */
92 | final public String getId() {
93 | return mId;
94 | }
95 |
96 | /**
97 | * (non-doc)
98 | */
99 | final public Image getImage(int index) {
100 | if (index < 0 || index >= mImages.size()) {
101 | throw new IllegalArgumentException();
102 | }
103 | return mImages.get(index);
104 | }
105 |
106 | /**
107 | * (non-doc)
108 | */
109 | final public List getImages() {
110 | return mImages;
111 | }
112 |
113 | /**
114 | * (non-doc)
115 | */
116 | final public String getName() {
117 | return mName;
118 | }
119 |
120 | /**
121 | * (non-doc)
122 | */
123 | final public String getType() {
124 | return mType;
125 | }
126 |
127 | /**
128 | * (non-doc)
129 | */
130 | final public String getUri() {
131 | return mUri;
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/SimpleArtist.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | import java.util.Map;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public class SimpleArtist {
26 | @SerializedName("external_urls")
27 | private Map mExternalUrls;
28 |
29 | @SerializedName("href")
30 | private String mHref;
31 |
32 | @SerializedName("id")
33 | private String mId;
34 |
35 | @SerializedName("name")
36 | private String mName;
37 |
38 | @SerializedName("type")
39 | private String mType;
40 |
41 | @SerializedName("uri")
42 | private String mUri;
43 |
44 | /**
45 | * (non-doc)
46 | */
47 | final public Map getExternalUrls() {
48 | return mExternalUrls;
49 | }
50 |
51 | /**
52 | * (non-doc)
53 | */
54 | final public String getHref() {
55 | return mHref;
56 | }
57 |
58 | /**
59 | * (non-doc)
60 | */
61 | final public String getId() {
62 | return mId;
63 | }
64 |
65 | /**
66 | * (non-doc)
67 | */
68 | final public String getName() {
69 | return mName;
70 | }
71 |
72 | /**
73 | * (non-doc)
74 | */
75 | final public String getType() {
76 | return mType;
77 | }
78 |
79 | /**
80 | * (non-doc)
81 | */
82 | final public String getUri() {
83 | return mUri;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/SimplePlaylist.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | /**
21 | * (non-doc)
22 | */
23 | public class SimplePlaylist extends SimplePlaylistBase {
24 | @SerializedName("tracks")
25 | private Information mTracks;
26 |
27 | /**
28 | * (non-doc)
29 | */
30 | final public Information getTracks() {
31 | return mTracks;
32 | }
33 |
34 | /**
35 | * (non-doc)
36 | */
37 | public static final class Information {
38 | @SerializedName("href")
39 | private String mHref;
40 |
41 | @SerializedName("total")
42 | private int mTotal;
43 |
44 | /**
45 | * (non-doc)
46 | */
47 | public String getHref() {
48 | return mHref;
49 | }
50 |
51 | /**
52 | * (non-doc)
53 | */
54 | public int getTotal() {
55 | return mTotal;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/SimplePlaylistBase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | import java.util.List;
21 | import java.util.Map;
22 |
23 | /**
24 | * (non-doc)
25 | */
26 | public class SimplePlaylistBase {
27 | @SerializedName("collaborative")
28 | private boolean mCollaborative;
29 |
30 | @SerializedName("external_urls")
31 | private Map mExternalUrls;
32 |
33 | @SerializedName("href")
34 | private String mHref;
35 |
36 | @SerializedName("id")
37 | private String mId;
38 |
39 | @SerializedName("images")
40 | private List mImages;
41 |
42 | @SerializedName("name")
43 | private String mName;
44 |
45 | @SerializedName("owner")
46 | private SimpleUser mOwner;
47 |
48 | @SerializedName("public")
49 | private boolean mPublic;
50 |
51 | @SerializedName("type")
52 | private String mType;
53 |
54 | @SerializedName("uri")
55 | private String mUri;
56 |
57 | /**
58 | * (non-doc)
59 | */
60 | final public boolean isCollaborative() {
61 | return mCollaborative;
62 | }
63 |
64 | /**
65 | * (non-doc)
66 | */
67 | final public Map getExternalUrls() {
68 | return mExternalUrls;
69 | }
70 |
71 | /**
72 | * (non-doc)
73 | */
74 | final public String getHref() {
75 | return mHref;
76 | }
77 |
78 | /**
79 | * (non-doc)
80 | */
81 | final public String getId() {
82 | return mId;
83 | }
84 |
85 | /**
86 | * (non-doc)
87 | */
88 | final public Image getImage(int index) {
89 | if (mImages == null) {
90 | return null;
91 | } else if (index < 0 || index >= mImages.size()) {
92 | throw new IllegalArgumentException();
93 | }
94 | return mImages.get(index);
95 | }
96 |
97 | /**
98 | * (non-doc)
99 | */
100 | final public List getImages() {
101 | return mImages;
102 | }
103 |
104 | /**
105 | * (non-doc)
106 | */
107 | final public String getName() {
108 | return mName;
109 | }
110 |
111 | /**
112 | * (non-doc)
113 | */
114 | final public SimpleUser getOwner() {
115 | return mOwner;
116 | }
117 |
118 | /**
119 | * (non-doc)
120 | */
121 | final public boolean isPublic() {
122 | return mPublic;
123 | }
124 |
125 | /**
126 | * (non-doc)
127 | */
128 | final public String getType() {
129 | return mType;
130 | }
131 |
132 | /**
133 | * (non-doc)
134 | */
135 | final public String getUri() {
136 | return mUri;
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/SimpleTrack.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | import java.util.Collections;
21 | import java.util.List;
22 | import java.util.Map;
23 |
24 | /**
25 | * (non-doc)
26 | */
27 | public class SimpleTrack {
28 | @SerializedName("artists")
29 | private List mArtists;
30 |
31 | @SerializedName("available_markets")
32 | private List mAvailableMarkets;
33 |
34 | @SerializedName("disc_number")
35 | private int mDiscNumber;
36 |
37 | @SerializedName("duration")
38 | private long mDuration;
39 |
40 | @SerializedName("explicit")
41 | private boolean mExplicit;
42 |
43 | @SerializedName("external_urls")
44 | private Map mExternalUrls;
45 |
46 | @SerializedName("href")
47 | private String mHref;
48 |
49 | @SerializedName("id")
50 | private String mId;
51 |
52 | @SerializedName("name")
53 | private String mName;
54 |
55 | @SerializedName("preview_url")
56 | private String mPreviewUrl;
57 |
58 | @SerializedName("track_number")
59 | private int mTrackNumber;
60 |
61 | @SerializedName("type")
62 | private String mType;
63 |
64 | @SerializedName("uri")
65 | private String mUri;
66 |
67 | /**
68 | * (non-doc)
69 | */
70 | final public SimpleArtist getArtist(int index) {
71 | if (index < 0 || index >= mArtists.size()) {
72 | throw new IllegalArgumentException();
73 | }
74 | return mArtists.get(index);
75 | }
76 |
77 | /**
78 | * (non-doc)
79 | */
80 | final public List getArtists() {
81 | return Collections.unmodifiableList(mArtists);
82 | }
83 |
84 | /**
85 | * (non-doc)
86 | */
87 | final public boolean isAvailable(String market) {
88 | return mAvailableMarkets.contains(market);
89 | }
90 |
91 | /**
92 | * (non-doc)
93 | */
94 | final public List getAvailableMarkets() {
95 | return Collections.unmodifiableList(mAvailableMarkets);
96 | }
97 |
98 | /**
99 | * (non-doc)
100 | */
101 | final public int getDiscNumber() {
102 | return mDiscNumber;
103 | }
104 |
105 | /**
106 | * (non-doc)
107 | */
108 | final public long getDuration() {
109 | return mDuration;
110 | }
111 |
112 | /**
113 | * (non-doc)
114 | */
115 | final public boolean isExplicit() {
116 | return mExplicit;
117 | }
118 |
119 | /**
120 | * (non-doc)
121 | */
122 | final public Map getExternalUrls() {
123 | return Collections.unmodifiableMap(mExternalUrls);
124 | }
125 |
126 | /**
127 | * (non-doc)
128 | */
129 | final public String getHref() {
130 | return mHref;
131 | }
132 |
133 | /**
134 | * (non-doc)
135 | */
136 | final public String getId() {
137 | return mId;
138 | }
139 |
140 | /**
141 | * (non-doc)
142 | */
143 | final public String getName() {
144 | return mName;
145 | }
146 |
147 | /**
148 | * (non-doc)
149 | */
150 | final public String getPreviewUrl() {
151 | return mPreviewUrl;
152 | }
153 |
154 | /**
155 | * (non-doc)
156 | */
157 | final public int getTrackNumber() {
158 | return mTrackNumber;
159 | }
160 |
161 | /**
162 | * (non-doc)
163 | */
164 | final public String getType() {
165 | return mType;
166 | }
167 |
168 | /**
169 | * (non-doc)
170 | */
171 | final public String getUri() {
172 | return mUri;
173 | }
174 | }
175 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/SimpleUser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | import java.util.List;
21 | import java.util.Map;
22 |
23 | /**
24 | * (non-doc)
25 | */
26 | public class SimpleUser {
27 | @SerializedName("display-name")
28 | private String mDisplayName;
29 |
30 | @SerializedName("external_urls")
31 | private Map mExternalUrls;
32 |
33 | @SerializedName("followers")
34 | private Followers mFollowers;
35 |
36 | @SerializedName("href")
37 | private String mHref;
38 |
39 | @SerializedName("id")
40 | private String mId;
41 |
42 | @SerializedName("images")
43 | private List mImages;
44 |
45 | @SerializedName("type")
46 | private String mType;
47 |
48 | @SerializedName("uri")
49 | private String mUri;
50 |
51 | /**
52 | * (non-doc)
53 | */
54 | final public String getDisplayName() {
55 | return mDisplayName;
56 | }
57 |
58 | /**
59 | * (non-doc)
60 | */
61 | final public Map getExternalUrls() {
62 | return mExternalUrls;
63 | }
64 |
65 | /**
66 | * (non-doc)
67 | */
68 | final public Followers getFollowers() {
69 | return mFollowers;
70 | }
71 |
72 | /**
73 | * (non-doc)
74 | */
75 | final public String getHref() {
76 | return mHref;
77 | }
78 |
79 | /**
80 | * (non-doc)
81 | */
82 | final public String getId() {
83 | return mId;
84 | }
85 |
86 | /**
87 | * (non-doc)
88 | */
89 | final public Image getImage(int index) {
90 | if (mImages == null) {
91 | return null;
92 | } else if (index < 0 || index >= mImages.size()) {
93 | throw new IllegalArgumentException();
94 | }
95 | return mImages.get(index);
96 | }
97 |
98 | /**
99 | * (non-doc)
100 | */
101 | final public List getImages() {
102 | return mImages;
103 | }
104 |
105 | /**
106 | * (non-doc)
107 | */
108 | final public String getType() {
109 | return mType;
110 | }
111 |
112 | /**
113 | * (non-doc)
114 | */
115 | final public String getUri() {
116 | return mUri;
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/Snapshot.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | /**
21 | * (non-doc)
22 | */
23 | public class Snapshot {
24 | @SerializedName("snapshot_id")
25 | private String mId;
26 |
27 | /**
28 | * (non-doc)
29 | */
30 | final public String getId() {
31 | return mId;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/Token.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | /**
21 | * (non-doc)
22 | */
23 | public class Token {
24 | @SerializedName("access_token")
25 | private String mToken;
26 |
27 | @SerializedName("token_type")
28 | private String mType;
29 |
30 | @SerializedName("expires_in")
31 | private int mExpiresTime;
32 |
33 | /**
34 | * Retrieve the access token.
35 | *
36 | * @return the access token that will be used for authentication.
37 | */
38 | final public String getToken() {
39 | return mToken;
40 | }
41 |
42 | /**
43 | * Retrieves the type of the token.
44 | *
45 | * @return a representation string of the privilege of the current session.
46 | */
47 | final public String getType() {
48 | return mType;
49 | }
50 |
51 | /**
52 | * Retrieves the expires time of the token.
53 | *
54 | * @return a millisecond representation of the expiration time.
55 | */
56 | final public int getExpirationTime() {
57 | return mExpiresTime;
58 | }
59 | }
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/Track.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | import java.util.Map;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public class Track extends SimpleTrack {
26 | @SerializedName("album")
27 | private SimpleAlbum mAlbum;
28 |
29 | @SerializedName("external_ids")
30 | private Map mExternalIds;
31 |
32 | @SerializedName("popularity")
33 | private int mPopularity;
34 |
35 | /**
36 | * (non-doc)
37 | */
38 | final public SimpleAlbum getAlbum() {
39 | return mAlbum;
40 | }
41 |
42 | /**
43 | * (non-doc)
44 | */
45 | final public Map getExternalIds() {
46 | return mExternalIds;
47 | }
48 |
49 | /**
50 | * (non-doc)
51 | */
52 | final public int getPopularity() {
53 | return mPopularity;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/model/User.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.model;
17 |
18 | import com.google.gson.annotations.SerializedName;
19 |
20 | /**
21 | * (non-doc)
22 | */
23 | public class User extends SimpleUser {
24 | @SerializedName("country")
25 | private String mCountry;
26 |
27 | @SerializedName("email")
28 | private String mEmail;
29 |
30 | @SerializedName("product")
31 | private String mProduct;
32 |
33 | /**
34 | * (non-doc)
35 | */
36 | final public String getCountry() {
37 | return mCountry;
38 | }
39 |
40 | /**
41 | * (non-doc)
42 | */
43 | final public String getEmail() {
44 | return mEmail;
45 | }
46 |
47 | /**
48 | * (non-doc)
49 | */
50 | final public String getProduct() {
51 | return mProduct;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/AbstractPageRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import com.android.volley.Request;
19 |
20 | import java.lang.reflect.Type;
21 |
22 | import me.siegenthaler.spotify.webapi.android.model.Page;
23 |
24 | /**
25 | * (non-doc)
26 | */
27 | public abstract class AbstractPageRequest, T> extends AbstractRequest.Builder> {
28 | /**
29 | * (non-doc)
30 | */
31 | public AbstractPageRequest(Type type) {
32 | this(type, null);
33 | }
34 |
35 | /**
36 | * (non-doc)
37 | */
38 | public AbstractPageRequest(Type type, String parent) {
39 | super(type, Request.Method.GET, parent);
40 | }
41 |
42 | /**
43 | * (non-doc)
44 | */
45 | final public AbstractPageRequest setLimit(int limit) {
46 | return addParameter("limit", String.valueOf(limit));
47 | }
48 |
49 | /**
50 | * (non-doc)
51 | */
52 | final public AbstractPageRequest setOffset(int offset) {
53 | return addParameter("offset", String.valueOf(offset));
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/AbstractRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import com.android.volley.NetworkResponse;
19 | import com.android.volley.Request;
20 | import com.android.volley.RequestQueue;
21 | import com.android.volley.Response;
22 | import com.android.volley.error.ParseError;
23 | import com.android.volley.toolbox.HttpHeaderParser;
24 | import com.google.gson.Gson;
25 | import com.google.gson.JsonElement;
26 | import com.google.gson.JsonObject;
27 | import com.google.gson.JsonSyntaxException;
28 |
29 | import java.io.UnsupportedEncodingException;
30 | import java.lang.reflect.ParameterizedType;
31 | import java.lang.reflect.Type;
32 | import java.util.ArrayList;
33 | import java.util.HashMap;
34 | import java.util.Map;
35 |
36 | import me.siegenthaler.spotify.webapi.android.model.Page;
37 |
38 | /**
39 | * (non-doc)
40 | */
41 | @SuppressWarnings("unchecked")
42 | public final class AbstractRequest extends Request {
43 | private final Gson mReader = new Gson();
44 | private final Map mParameters;
45 | private final Map mHeaders;
46 | private final Type mType;
47 | private final String mParent;
48 | private final Response.Listener mListener;
49 | private final boolean mJsonBody;
50 |
51 | /**
52 | * (non-doc)
53 | */
54 | public AbstractRequest(Builder, T> builder) {
55 | super(builder.mMethod, "https://" + builder.mHost + ":443" + builder.mPath, builder.mErrorListener);
56 | this.mType = builder.mType;
57 | this.mParameters = builder.mParameters;
58 | this.mHeaders = builder.mHeaders;
59 | this.mParent = builder.mParent;
60 | this.mListener = builder.mListener;
61 | this.mJsonBody = builder.mJsonBody;
62 | setTag(builder.mIdentifier);
63 | }
64 |
65 | /**
66 | * {@inheritDoc}
67 | */
68 | @Override
69 | final public String getBodyContentType() {
70 | return mJsonBody
71 | ? "application/json; charset=UTF-8"
72 | : "application/x-www-form-urlencoded; charset=UTF-8";
73 | }
74 |
75 | /**
76 | * {@inheritDoc}
77 | */
78 | @Override
79 | final protected Map getParams() {
80 | return mParameters;
81 | }
82 |
83 | /**
84 | * {@inheritDoc}
85 | */
86 | @Override
87 | final public Map getHeaders() {
88 | return mHeaders;
89 | }
90 |
91 | /**
92 | * {@inheritDoc}
93 | */
94 | @Override
95 | final protected void deliverResponse(T response) {
96 | if (mListener != null) {
97 | mListener.onResponse(response);
98 | }
99 | }
100 |
101 | /**
102 | * {@inheritDoc}
103 | */
104 | @Override
105 | final protected Response parseNetworkResponse(NetworkResponse response) {
106 | try {
107 | final String json =
108 | new String(response.data, HttpHeaderParser.parseCharset(response.headers));
109 |
110 | final JsonElement element = mParent != null
111 | ? mReader.fromJson(json, JsonObject.class).get(mParent)
112 | : mReader.fromJson(json, JsonObject.class);
113 | return Response.success(
114 | (T) mReader.fromJson(element, mType), HttpHeaderParser.parseCacheHeaders(response));
115 | } catch (UnsupportedEncodingException e) {
116 | return Response.error(new ParseError(e));
117 | } catch (JsonSyntaxException e) {
118 | return Response.error(new ParseError(e));
119 | }
120 | }
121 |
122 | /**
123 | * (non-doc)
124 | */
125 | public static class Builder {
126 | protected final Map mParameters = new HashMap<>();
127 | protected final Map mHeaders = new HashMap<>();
128 | protected final Type mType;
129 | protected final int mMethod;
130 | protected String mParent;
131 | protected String mPath;
132 | protected String mHost;
133 | protected Response.ErrorListener mErrorListener;
134 | protected Response.Listener mListener;
135 | protected String mIdentifier;
136 | protected RequestQueue mClient;
137 | protected boolean mJsonBody;
138 |
139 | /**
140 | * (non-doc)
141 | */
142 | public Builder(Type type) {
143 | this(type, Method.GET);
144 | }
145 |
146 | /**
147 | * (non-doc)
148 | */
149 | public Builder(Type type, int method) {
150 | this(type, method, null);
151 | }
152 |
153 | /**
154 | * (non-doc)
155 | */
156 | public Builder(Type type, int method, String parent) {
157 | this.mType = type;
158 | this.mMethod = method;
159 | this.mParent = parent;
160 | }
161 |
162 | /**
163 | * (non-doc)
164 | */
165 | final protected J setJsonBody(boolean isJsonBody) {
166 | mJsonBody = isJsonBody;
167 | return (J) this;
168 | }
169 |
170 | /**
171 | * (non-doc)
172 | */
173 | final public J setClient(RequestQueue client) {
174 | mClient = client;
175 | return (J) this;
176 | }
177 |
178 | /**
179 | * (non-doc)
180 | */
181 | final public J setPath(String path) {
182 | mPath = path;
183 | return (J) this;
184 | }
185 |
186 | /**
187 | * (non-doc)
188 | */
189 | final public J setHost(String host) {
190 | mHost = host;
191 | return (J) this;
192 | }
193 |
194 | /**
195 | * (non-doc)
196 | */
197 | final public J addParameter(String name, String value) {
198 | mParameters.put(name, value);
199 | return (J) this;
200 | }
201 |
202 | /**
203 | * (non-doc)
204 | */
205 | final public J addHeader(String name, String value) {
206 | mHeaders.put(name, value);
207 | return (J) this;
208 | }
209 |
210 | /**
211 | * (non-doc)
212 | */
213 | final public J setListener(Response.Listener listener) {
214 | mListener = listener;
215 | return (J) this;
216 | }
217 |
218 | /**
219 | * (non-doc)
220 | */
221 | final public J setErrorListener(Response.ErrorListener listener) {
222 | mErrorListener = listener;
223 | return (J) this;
224 | }
225 |
226 | /**
227 | * (non-doc)
228 | */
229 | final public J setTag(String tag) {
230 | mIdentifier = tag;
231 | return (J) this;
232 | }
233 |
234 | /**
235 | * (non-doc)
236 | */
237 | final public AbstractRequest build() {
238 | final AbstractRequest request = new AbstractRequest<>(this);
239 | mClient.add(request);
240 | return request;
241 | }
242 | }
243 |
244 | /**
245 | * (non-doc)
246 | */
247 | public static class ListType implements ParameterizedType {
248 | private final Type mType;
249 |
250 | /**
251 | * Constructor.
252 | */
253 | public ListType(Type type) {
254 | this.mType = type;
255 | }
256 |
257 | /**
258 | * {@inheritDoc}
259 | */
260 | @Override
261 | public Type[] getActualTypeArguments() {
262 | return new Type[]{mType};
263 | }
264 |
265 | /**
266 | * {@inheritDoc}
267 | */
268 | @Override
269 | public Type getRawType() {
270 | return ArrayList.class;
271 | }
272 |
273 | /**
274 | * {@inheritDoc}
275 | */
276 | @Override
277 | public Type getOwnerType() {
278 | return null;
279 | }
280 | }
281 |
282 | /**
283 | * (non-doc)
284 | */
285 | public static class PageType implements ParameterizedType {
286 | private final Type mType;
287 |
288 | /**
289 | * Constructor.
290 | */
291 | public PageType(Type type) {
292 | this.mType = type;
293 | }
294 |
295 | /**
296 | * {@inheritDoc}
297 | */
298 | @Override
299 | public Type[] getActualTypeArguments() {
300 | return new Type[]{mType};
301 | }
302 |
303 | /**
304 | * {@inheritDoc}
305 | */
306 | @Override
307 | public Type getRawType() {
308 | return Page.class;
309 | }
310 |
311 | /**
312 | * {@inheritDoc}
313 | */
314 | @Override
315 | public Type getOwnerType() {
316 | return null;
317 | }
318 | }
319 | }
320 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/AlbumListRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import android.text.TextUtils;
19 |
20 | import com.android.volley.Request;
21 |
22 | import java.util.List;
23 |
24 | import me.siegenthaler.spotify.webapi.android.model.Album;
25 |
26 | /**
27 | * (non-doc)
28 | */
29 | public final class AlbumListRequest extends AbstractRequest.Builder> {
30 | private final static AbstractRequest.ListType PARAMETER_TYPE = new AbstractRequest.ListType(Album.class);
31 |
32 | /**
33 | * (non-doc)
34 | */
35 | public AlbumListRequest() {
36 | super(PARAMETER_TYPE, Request.Method.GET, "albums");
37 | }
38 |
39 | /**
40 | * (non-doc)
41 | */
42 | public AlbumListRequest setAlbums(String... id) {
43 | setPath("/v1/albums");
44 | return addParameter("ids", TextUtils.join(",", id));
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/AlbumRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import java.util.Locale;
19 |
20 | import me.siegenthaler.spotify.webapi.android.model.Album;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public final class AlbumRequest extends AbstractRequest.Builder {
26 | /**
27 | * (non-doc)
28 | */
29 | public AlbumRequest() {
30 | super(Album.class);
31 | }
32 |
33 | /**
34 | * (non-doc)
35 | */
36 | public AlbumRequest setAlbum(String album) {
37 | return setPath(String.format(Locale.ENGLISH, "/v1/albums/%s", album));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/AlbumTracksRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import java.util.Locale;
19 |
20 | import me.siegenthaler.spotify.webapi.android.model.SimpleTrack;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public final class AlbumTracksRequest extends AbstractPageRequest {
26 | private final static AbstractRequest.PageType PARAMETER_TYPE = new AbstractRequest.PageType(SimpleTrack.class);
27 |
28 | /**
29 | * (non-doc)
30 | */
31 | public AlbumTracksRequest() {
32 | super(PARAMETER_TYPE, "tracks");
33 | }
34 |
35 | /**
36 | * (non-doc)
37 | */
38 | public AlbumTracksRequest setAlbum(String id) {
39 | return setPath(String.format(Locale.ENGLISH, "/v1/albums/%s/tracks", id));
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/ArtistAlbumsRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import android.text.TextUtils;
19 |
20 | import java.util.Locale;
21 |
22 | import me.siegenthaler.spotify.webapi.android.model.SimpleAlbum;
23 |
24 | /**
25 | * (non-doc)
26 | */
27 | public final class ArtistAlbumsRequest extends AbstractPageRequest {
28 | private final static AbstractRequest.PageType PARAMETER_TYPE = new AbstractRequest.PageType(SimpleAlbum.class);
29 |
30 | /**
31 | * (non-doc)
32 | */
33 | public ArtistAlbumsRequest() {
34 | super(PARAMETER_TYPE, "albums");
35 | }
36 |
37 | /**
38 | * (non-doc)
39 | */
40 | public ArtistAlbumsRequest setArtist(String id) {
41 | return setPath(String.format(Locale.ENGLISH, "/v1/artists/%s/albums", id));
42 | }
43 |
44 | /**
45 | * (non-doc)
46 | */
47 | public ArtistAlbumsRequest setAlbumType(String... type) {
48 | return addParameter("album_type", TextUtils.join(",", type));
49 | }
50 |
51 | /**
52 | * (non-doc)
53 | */
54 | public ArtistAlbumsRequest setMarket(String market) {
55 | return addParameter("market", market);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/ArtistListRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import android.text.TextUtils;
19 |
20 | import com.android.volley.Request;
21 |
22 | import java.util.List;
23 |
24 | import me.siegenthaler.spotify.webapi.android.model.Artist;
25 |
26 | /**
27 | * (non-doc)
28 | */
29 | public final class ArtistListRequest extends AbstractRequest.Builder> {
30 | private final static AbstractRequest.ListType PARAMETER_TYPE = new AbstractRequest.ListType(Artist.class);
31 |
32 | /**
33 | * (non-doc)
34 | */
35 | public ArtistListRequest() {
36 | super(PARAMETER_TYPE, Request.Method.GET, "artists");
37 | }
38 |
39 | /**
40 | * (non-doc)
41 | */
42 | public ArtistListRequest setArtists(String... id) {
43 | setPath("/v1/artists");
44 | return addParameter("ids", TextUtils.join(",", id));
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/ArtistRelatedRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import com.android.volley.Request;
19 |
20 | import java.util.List;
21 | import java.util.Locale;
22 |
23 | import me.siegenthaler.spotify.webapi.android.model.Artist;
24 |
25 | /**
26 | * (non-doc)
27 | */
28 | public final class ArtistRelatedRequest extends AbstractRequest.Builder> {
29 | private final static AbstractRequest.ListType PARAMETER_TYPE = new AbstractRequest.ListType(Artist.class);
30 |
31 | /**
32 | * (non-doc)
33 | */
34 | public ArtistRelatedRequest() {
35 | super(PARAMETER_TYPE, Request.Method.GET, "artists");
36 | }
37 |
38 | /**
39 | * (non-doc)
40 | */
41 | public ArtistRelatedRequest setArtist(String id) {
42 | return setPath(String.format(Locale.ENGLISH, "/v1/artists/%s/related-artists", id));
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/ArtistRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import java.util.Locale;
19 |
20 | import me.siegenthaler.spotify.webapi.android.model.Artist;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public final class ArtistRequest extends AbstractRequest.Builder {
26 | /**
27 | * (non-doc)
28 | */
29 | public ArtistRequest() {
30 | super(Artist.class);
31 | }
32 |
33 | /**
34 | * (non-doc)
35 | */
36 | public ArtistRequest setArtist(String artist) {
37 | return setPath(String.format(Locale.ENGLISH, "/v1/artists/%s", artist));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/ArtistTopTrackRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import com.android.volley.Request;
19 |
20 | import java.util.List;
21 | import java.util.Locale;
22 |
23 | import me.siegenthaler.spotify.webapi.android.model.Track;
24 |
25 | /**
26 | * (non-doc)
27 | */
28 | public final class ArtistTopTrackRequest extends AbstractRequest.Builder> {
29 | private final static AbstractRequest.ListType PARAMETER_TYPE = new AbstractRequest.ListType(Track.class);
30 |
31 | /**
32 | * (non-doc)
33 | */
34 | public ArtistTopTrackRequest() {
35 | super(PARAMETER_TYPE, Request.Method.GET, "tracks");
36 | }
37 |
38 | /**
39 | * (non-doc)
40 | */
41 | public ArtistTopTrackRequest setArtist(String id) {
42 | return setPath(String.format(Locale.ENGLISH, "/v1/artists/%s/top-tracks", id));
43 | }
44 |
45 | /**
46 | * (non-doc)
47 | */
48 | public ArtistTopTrackRequest setCountry(String market) {
49 | return addParameter("country", market);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/AuthoriseClientFlowRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import android.text.TextUtils;
19 | import android.util.Base64;
20 |
21 | import com.android.volley.Request;
22 |
23 | import me.siegenthaler.spotify.webapi.android.model.Token;
24 |
25 | /**
26 | * (non-doc)
27 | */
28 | public final class AuthoriseClientFlowRequest extends AbstractRequest.Builder {
29 | /**
30 | * (non-doc)
31 | */
32 | public AuthoriseClientFlowRequest() {
33 | super(Token.class, Request.Method.POST, null);
34 | setPath("/api/token");
35 | }
36 |
37 | /**
38 | * (non-doc)
39 | */
40 | public AuthoriseClientFlowRequest setAuthorisation(String id, String secret) {
41 | return addHeader(
42 | "Authorization",
43 | "Basic " + Base64.encodeToString((id + ":" + secret).getBytes(), Base64.NO_WRAP));
44 | }
45 |
46 | /**
47 | * (non-doc)
48 | */
49 | public AuthoriseClientFlowRequest setType(String type) {
50 | return addParameter("grant_type", type);
51 | }
52 |
53 | /**
54 | * (non-doc)
55 | */
56 | public AuthoriseClientFlowRequest setScopes(String... scopes) {
57 | return addParameter("scope", TextUtils.join(" ", scopes));
58 | }
59 |
60 | /**
61 | * (non-doc)
62 | */
63 | public AuthoriseClientFlowRequest setRedirectUrl(String url) {
64 | return addParameter("redirect_uri", url);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/AuthoriseRefreshRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import android.util.Base64;
19 |
20 | import com.android.volley.Request;
21 |
22 | import me.siegenthaler.spotify.webapi.android.model.Token;
23 |
24 | /**
25 | * (non-doc)
26 | */
27 | public final class AuthoriseRefreshRequest extends AbstractRequest.Builder {
28 | /**
29 | * (non-doc)
30 | */
31 | public AuthoriseRefreshRequest() {
32 | super(Token.class, Request.Method.POST, null);
33 | setPath("/api/token");
34 | addParameter("grant_type", "authorization_code");
35 | }
36 |
37 | /**
38 | * (non-doc)
39 | */
40 | public AuthoriseRefreshRequest setAuthorisation(String id, String secret) {
41 | return addHeader(
42 | "Authorization",
43 | "Basic " + Base64.encodeToString((id + ":" + secret).getBytes(), Base64.NO_WRAP));
44 | }
45 |
46 | /**
47 | * (non-doc)
48 | */
49 | public AuthoriseRefreshRequest setCode(String code) {
50 | return addParameter("code", code);
51 | }
52 |
53 | /**
54 | * (non-doc)
55 | */
56 | public AuthoriseRefreshRequest setRedirectUri(String uri) {
57 | return addParameter("redirect_uri", uri);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/PlaylistAddTracksRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import android.text.TextUtils;
19 |
20 | import com.android.volley.Request;
21 |
22 | import java.util.Locale;
23 |
24 | import me.siegenthaler.spotify.webapi.android.model.Snapshot;
25 |
26 | /**
27 | * (non-doc)
28 | */
29 | public class PlaylistAddTracksRequest extends AbstractRequest.Builder {
30 | /**
31 | * (non-doc)
32 | */
33 | public PlaylistAddTracksRequest() {
34 | super(Snapshot.class, Request.Method.POST);
35 | }
36 |
37 | /**
38 | * (non-doc)
39 | */
40 | final public PlaylistAddTracksRequest setPlaylist(String user, String playlist) {
41 | return setPath(String.format(Locale.ENGLISH, "/v1/users/%s/playlists/%s/tracks", user, playlist));
42 | }
43 |
44 | /**
45 | * (non-doc)
46 | */
47 | final public PlaylistAddTracksRequest setTracks(int position, String... ids) {
48 | addParameter("position", String.valueOf(position));
49 | return addParameter("uris", TextUtils.join(",", ids));
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/PlaylistChangeDetailsRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import com.android.volley.Request;
19 |
20 | import java.util.Locale;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public class PlaylistChangeDetailsRequest extends AbstractRequest.Builder {
26 | /**
27 | * (non-doc)
28 | */
29 | public PlaylistChangeDetailsRequest() {
30 | super(Void.class, Request.Method.PUT);
31 | setJsonBody(true);
32 | }
33 |
34 | /**
35 | * (non-doc)
36 | */
37 | final public PlaylistChangeDetailsRequest setPlaylist(String user, String playlist) {
38 | return setPath(String.format(Locale.ENGLISH, "/v1/users/%s/playlists/%s", user, playlist));
39 | }
40 |
41 | /**
42 | * (non-doc)
43 | */
44 | final public PlaylistChangeDetailsRequest serName(String name) {
45 | return addParameter("name", name);
46 | }
47 |
48 | /**
49 | * (non-doc)
50 | */
51 | final public PlaylistChangeDetailsRequest setPublic(boolean isPublic) {
52 | return addParameter("public", isPublic ? "true" : "false");
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/PlaylistCreateRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import com.android.volley.Request;
19 |
20 | import java.util.Locale;
21 |
22 | import me.siegenthaler.spotify.webapi.android.model.Playlist;
23 |
24 | /**
25 | * (non-doc)
26 | */
27 | public class PlaylistCreateRequest extends AbstractRequest.Builder {
28 | /**
29 | * (non-doc)
30 | */
31 | public PlaylistCreateRequest() {
32 | super(Playlist.class, Request.Method.POST);
33 | setJsonBody(true);
34 | }
35 |
36 | /**
37 | * (non-doc)
38 | */
39 | final public PlaylistCreateRequest setUser(String user) {
40 | return setPath(String.format(Locale.ENGLISH, "/v1/users/%s/playlists", user));
41 | }
42 |
43 | /**
44 | * (non-doc)
45 | */
46 | final public PlaylistCreateRequest serName(String name) {
47 | return addParameter("name", name);
48 | }
49 |
50 | /**
51 | * (non-doc)
52 | */
53 | final public PlaylistCreateRequest setPublic(boolean isPublic) {
54 | return addParameter("public", isPublic ? "true" : "false");
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/PlaylistListRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import java.util.Locale;
19 |
20 | import me.siegenthaler.spotify.webapi.android.model.SimplePlaylist;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public final class PlaylistListRequest extends AbstractPageRequest {
26 | private final static AbstractRequest.PageType PARAMETER_TYPE = new AbstractRequest.PageType(SimplePlaylist.class);
27 |
28 | /**
29 | * (non-doc)
30 | */
31 | public PlaylistListRequest() {
32 | super(PARAMETER_TYPE);
33 | }
34 |
35 | /**
36 | * (non-doc)
37 | */
38 | final public PlaylistListRequest setUser(String user) {
39 | return setPath(String.format(Locale.ENGLISH, "/v1/users/%s/playlists", user));
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/PlaylistReplaceTracksRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import android.text.TextUtils;
19 |
20 | import com.android.volley.Request;
21 |
22 | import java.util.Locale;
23 |
24 | import me.siegenthaler.spotify.webapi.android.model.Snapshot;
25 |
26 | /**
27 | * (non-doc)
28 | */
29 | public class PlaylistReplaceTracksRequest extends AbstractRequest.Builder {
30 | /**
31 | * (non-doc)
32 | */
33 | public PlaylistReplaceTracksRequest() {
34 | super(Snapshot.class, Request.Method.PUT);
35 | }
36 |
37 | /**
38 | * (non-doc)
39 | */
40 | final public PlaylistReplaceTracksRequest setPlaylist(String user, String playlist) {
41 | return setPath(String.format(Locale.ENGLISH, "/v1/users/%s/playlists/%s/tracks", user, playlist));
42 | }
43 |
44 | /**
45 | * (non-doc)
46 | */
47 | final public PlaylistReplaceTracksRequest setTracks(String... ids) {
48 | return addParameter("uris", TextUtils.join(",", ids));
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/PlaylistRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import java.util.Locale;
19 |
20 | import me.siegenthaler.spotify.webapi.android.model.Playlist;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public final class PlaylistRequest extends AbstractRequest.Builder {
26 | /**
27 | * (non-doc)
28 | */
29 | public PlaylistRequest() {
30 | super(Playlist.class);
31 | }
32 |
33 | /**
34 | * (non-doc)
35 | */
36 | public PlaylistRequest setPlaylist(String user, String id) {
37 | return setPath(String.format(Locale.ENGLISH, "/v1/users/%s/playlists/%s", user, id));
38 | }
39 |
40 | /**
41 | * (non-doc)
42 | */
43 | public PlaylistRequest setFields(String field) {
44 | return addParameter("fields", field);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/PlaylistTrackRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import java.util.Locale;
19 |
20 | import me.siegenthaler.spotify.webapi.android.model.Playlist;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public final class PlaylistTrackRequest extends AbstractPageRequest {
26 | private final static AbstractRequest.PageType PARAMETER_TYPE = new AbstractRequest.PageType(Playlist.Information.class);
27 |
28 | /**
29 | * (non-doc)
30 | */
31 | public PlaylistTrackRequest() {
32 | super(PARAMETER_TYPE);
33 | }
34 |
35 | /**
36 | * (non-doc)
37 | */
38 | public PlaylistTrackRequest setPlaylist(String user, String id) {
39 | return setPath(String.format(Locale.ENGLISH, "/v1/users/%s/playlists/%s/tracks", user, id));
40 | }
41 |
42 | /**
43 | * (non-doc)
44 | */
45 | public PlaylistTrackRequest setFields(String field) {
46 | return addParameter("fields", field);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/SearchAlbumRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import me.siegenthaler.spotify.webapi.android.model.SimpleAlbum;
19 |
20 | /**
21 | * (non-doc)
22 | */
23 | public final class SearchAlbumRequest extends SearchRequest {
24 | private final static AbstractRequest.PageType PARAMETER_TYPE = new AbstractRequest.PageType(SimpleAlbum.class);
25 |
26 | /**
27 | * (non-doc)
28 | */
29 | public SearchAlbumRequest() {
30 | super(PARAMETER_TYPE, "album");
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/SearchArtistRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import me.siegenthaler.spotify.webapi.android.model.Artist;
19 |
20 | /**
21 | * (non-doc)
22 | */
23 | public final class SearchArtistRequest extends SearchRequest {
24 | private final static AbstractRequest.PageType PARAMETER_TYPE = new AbstractRequest.PageType(Artist.class);
25 |
26 | /**
27 | * (non-doc)
28 | */
29 | public SearchArtistRequest() {
30 | super(PARAMETER_TYPE, "artist");
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/SearchPlaylistRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import me.siegenthaler.spotify.webapi.android.model.SimplePlaylist;
19 |
20 | /**
21 | * (non-doc)
22 | */
23 | public final class SearchPlaylistRequest extends SearchRequest {
24 | private final static AbstractRequest.PageType PARAMETER_TYPE = new AbstractRequest.PageType(SimplePlaylist.class);
25 |
26 | /**
27 | * (non-doc)
28 | */
29 | public SearchPlaylistRequest() {
30 | super(PARAMETER_TYPE, "playlist");
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/SearchRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import java.lang.reflect.Type;
19 |
20 | /**
21 | * (non-doc)
22 | */
23 | public abstract class SearchRequest, T> extends AbstractPageRequest {
24 | /**
25 | * (non-doc)
26 | */
27 | public SearchRequest(Type type, String searchType) {
28 | super(type, searchType + "s");
29 | setPath("/v1/search");
30 | setType(searchType);
31 | }
32 |
33 | /**
34 | * (non-doc)
35 | */
36 | final public J setQuery(String query) {
37 | return addParameter("q", query);
38 | }
39 |
40 | /**
41 | * (non-doc)
42 | */
43 | final public J setMarket(String market) {
44 | return addParameter("market", market);
45 | }
46 |
47 | /**
48 | * (non-doc)
49 | */
50 | final public J setType(String type) {
51 | return addParameter("type", type);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/SearchTrackRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import me.siegenthaler.spotify.webapi.android.model.Track;
19 |
20 | /**
21 | * (non-doc)
22 | */
23 | public final class SearchTrackRequest extends SearchRequest {
24 | private final static AbstractRequest.PageType PARAMETER_TYPE = new AbstractRequest.PageType(Track.class);
25 |
26 | /**
27 | * (non-doc)
28 | */
29 | public SearchTrackRequest() {
30 | super(PARAMETER_TYPE, "track");
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/TrackListRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import android.text.TextUtils;
19 |
20 | import com.android.volley.Request;
21 |
22 | import java.util.List;
23 |
24 | import me.siegenthaler.spotify.webapi.android.model.Track;
25 |
26 | /**
27 | * (non-doc)
28 | */
29 | public final class TrackListRequest extends AbstractRequest.Builder> {
30 | private final static AbstractRequest.ListType PARAMETER_TYPE = new AbstractRequest.ListType(Track.class);
31 |
32 | /**
33 | * (non-doc)
34 | */
35 | public TrackListRequest() {
36 | super(PARAMETER_TYPE, Request.Method.GET, "tracks");
37 | }
38 |
39 | /**
40 | * (non-doc)
41 | */
42 | public TrackListRequest setTracks(String... id) {
43 | setPath("/v1/tracks");
44 | return addParameter("ids", TextUtils.join(",", id));
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/TrackRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request;
17 |
18 | import java.util.Locale;
19 |
20 | import me.siegenthaler.spotify.webapi.android.model.Track;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public final class TrackRequest extends AbstractRequest.Builder {
26 | /**
27 | * (non-doc)
28 | */
29 | public TrackRequest() {
30 | super(Track.class);
31 | }
32 |
33 | /**
34 | * (non-doc)
35 | */
36 | public TrackRequest setTrack(String track) {
37 | return setPath(String.format(Locale.ENGLISH, "/v1/track/%s", track));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/browse/BrowseAlbumRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request.browse;
17 |
18 | import me.siegenthaler.spotify.webapi.android.model.SimpleAlbum;
19 | import me.siegenthaler.spotify.webapi.android.request.AbstractPageRequest;
20 | import me.siegenthaler.spotify.webapi.android.request.AbstractRequest;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public final class BrowseAlbumRequest extends AbstractPageRequest {
26 | private final static AbstractRequest.PageType PARAMETER_TYPE = new AbstractRequest.PageType(SimpleAlbum.class);
27 |
28 | /**
29 | * (non-doc)
30 | */
31 | public BrowseAlbumRequest() {
32 | super(PARAMETER_TYPE, "albums");
33 | setPath("/v1/browse/new-releases");
34 | }
35 |
36 | /**
37 | * (non-doc)
38 | */
39 | public BrowseAlbumRequest setMarket(String market) {
40 | return addParameter("market", market);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/browse/BrowsePlaylistRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request.browse;
17 |
18 | import me.siegenthaler.spotify.webapi.android.model.SimplePlaylist;
19 | import me.siegenthaler.spotify.webapi.android.request.AbstractPageRequest;
20 | import me.siegenthaler.spotify.webapi.android.request.AbstractRequest;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public final class BrowsePlaylistRequest extends AbstractPageRequest {
26 | private final static AbstractRequest.PageType PARAMETER_TYPE = new AbstractRequest.PageType(SimplePlaylist.class);
27 |
28 | /**
29 | * (non-doc)
30 | */
31 | public BrowsePlaylistRequest() {
32 | super(PARAMETER_TYPE, "playlists");
33 | setPath("/v1/browse/featured-playlists");
34 | }
35 |
36 | /**
37 | * (non-doc)
38 | */
39 | public BrowsePlaylistRequest setCountry(String country) {
40 | return addParameter("country", country);
41 | }
42 |
43 | /**
44 | * (non-doc)
45 | */
46 | public BrowsePlaylistRequest setLocale(String locale) {
47 | return addParameter("locale", locale);
48 | }
49 |
50 | /**
51 | * (non-doc)
52 | */
53 | public BrowsePlaylistRequest setTimestamp(String timestamp) {
54 | return addParameter("timestamp", timestamp);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/follow/FollowAddRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request.follow;
17 |
18 | import android.text.TextUtils;
19 |
20 | import com.android.volley.Request;
21 |
22 | import me.siegenthaler.spotify.webapi.android.request.AbstractRequest;
23 |
24 | /**
25 | * (non-doc)
26 | */
27 | public final class FollowAddRequest extends AbstractRequest.Builder {
28 | public final static String TYPE_ARTIST = "artist";
29 | public final static String TYPE_USER = "user";
30 |
31 | /**
32 | * (non-doc)
33 | */
34 | public FollowAddRequest() {
35 | super(Void.class, Request.Method.PUT);
36 | setPath("/v1/me/following");
37 | }
38 |
39 | /**
40 | * (non-doc)
41 | */
42 | public FollowAddRequest setIds(String... ids) {
43 | return addParameter("ids", TextUtils.join(",", ids));
44 | }
45 |
46 | /**
47 | * (non-doc)
48 | */
49 | public FollowAddRequest setType(String type) {
50 | return addParameter("type", type);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/follow/FollowCheckRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request.follow;
17 |
18 | import android.text.TextUtils;
19 |
20 | import java.util.List;
21 |
22 | import me.siegenthaler.spotify.webapi.android.request.AbstractRequest;
23 |
24 | /**
25 | * (non-doc)
26 | */
27 | public final class FollowCheckRequest extends AbstractRequest.Builder> {
28 | private final static AbstractRequest.ListType PARAMETER_TYPE = new AbstractRequest.ListType(Boolean.class);
29 |
30 | public final static String TYPE_ARTIST = "artist";
31 | public final static String TYPE_USER = "user";
32 |
33 | /**
34 | * (non-doc)
35 | */
36 | public FollowCheckRequest() {
37 | super(PARAMETER_TYPE);
38 | setPath("/v1/me/following");
39 | }
40 |
41 | /**
42 | * (non-doc)
43 | */
44 | public FollowCheckRequest setIds(String... ids) {
45 | return addParameter("ids", TextUtils.join(",", ids));
46 | }
47 |
48 | /**
49 | * (non-doc)
50 | */
51 | public FollowCheckRequest setType(String type) {
52 | return addParameter("type", type);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/follow/FollowRemoveRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request.follow;
17 |
18 | import android.text.TextUtils;
19 |
20 | import com.android.volley.Request;
21 |
22 | import me.siegenthaler.spotify.webapi.android.request.AbstractRequest;
23 |
24 | /**
25 | * (non-doc)
26 | */
27 | public final class FollowRemoveRequest extends AbstractRequest.Builder {
28 | public final static String TYPE_ARTIST = "artist";
29 | public final static String TYPE_USER = "user";
30 |
31 | /**
32 | * (non-doc)
33 | */
34 | public FollowRemoveRequest() {
35 | super(Void.class, Request.Method.DELETE);
36 | setPath("/v1/me/following");
37 | }
38 |
39 | /**
40 | * (non-doc)
41 | */
42 | public FollowRemoveRequest setIds(String... ids) {
43 | return addParameter("ids", TextUtils.join(",", ids));
44 | }
45 |
46 | /**
47 | * (non-doc)
48 | */
49 | public FollowRemoveRequest setType(String type) {
50 | return addParameter("type", type);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/music/MusicAddRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request.music;
17 |
18 | import android.text.TextUtils;
19 |
20 | import com.android.volley.Request;
21 |
22 | import me.siegenthaler.spotify.webapi.android.request.AbstractRequest;
23 |
24 | /**
25 | * (non-doc)
26 | */
27 | public final class MusicAddRequest extends AbstractRequest.Builder {
28 | /**
29 | * (non-doc)
30 | */
31 | public MusicAddRequest() {
32 | super(Void.class, Request.Method.PUT, null);
33 | }
34 |
35 | /**
36 | * (non-doc)
37 | */
38 | public MusicAddRequest setTracks(String... ids) {
39 | setPath("/v1/me/tracks");
40 | return addParameter("ids", TextUtils.join(",", ids));
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/music/MusicRemoveRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request.music;
17 |
18 | import android.text.TextUtils;
19 |
20 | import com.android.volley.Request;
21 |
22 | import me.siegenthaler.spotify.webapi.android.request.AbstractRequest;
23 |
24 | /**
25 | * (non-doc)
26 | */
27 | public final class MusicRemoveRequest extends AbstractRequest.Builder {
28 | /**
29 | * (non-doc)
30 | */
31 | public MusicRemoveRequest() {
32 | super(Void.class, Request.Method.DELETE, null);
33 | }
34 |
35 | /**
36 | * (non-doc)
37 | */
38 | public MusicRemoveRequest setTracks(String... ids) {
39 | setPath("/v1/me/tracks");
40 | return addParameter("ids", TextUtils.join(",", ids));
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/music/MusicTrackCheckRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request.music;
17 |
18 | import android.text.TextUtils;
19 |
20 | import com.android.volley.Request;
21 |
22 | import java.util.List;
23 |
24 | import me.siegenthaler.spotify.webapi.android.request.AbstractRequest;
25 |
26 | /**
27 | * (non-doc)
28 | */
29 | public final class MusicTrackCheckRequest extends AbstractRequest.Builder> {
30 | private final static AbstractRequest.ListType PARAMETER_TYPE = new AbstractRequest.ListType(Boolean.class);
31 |
32 | /**
33 | * (non-doc)
34 | */
35 | public MusicTrackCheckRequest() {
36 | super(PARAMETER_TYPE, Request.Method.GET, null);
37 | }
38 |
39 | /**
40 | * (non-doc)
41 | */
42 | public MusicTrackCheckRequest setIds(String... ids) {
43 | setPath("v1/me/tracks/contains");
44 | return addParameter("ids", TextUtils.join(",", ids));
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/music/MusicTrackRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request.music;
17 |
18 | import me.siegenthaler.spotify.webapi.android.model.Track;
19 | import me.siegenthaler.spotify.webapi.android.request.AbstractPageRequest;
20 | import me.siegenthaler.spotify.webapi.android.request.AbstractRequest;
21 |
22 | /**
23 | * (non-doc)
24 | */
25 | public final class MusicTrackRequest extends AbstractPageRequest {
26 | private final static AbstractRequest.PageType PARAMETER_TYPE = new AbstractRequest.PageType(Track.class);
27 |
28 | /**
29 | * (non-doc)
30 | */
31 | public MusicTrackRequest() {
32 | super(PARAMETER_TYPE, null);
33 | setPath("/v1/me/tracks");
34 | }
35 | }
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/profile/UserElseRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request.profile;
17 |
18 | import java.util.Locale;
19 |
20 | import me.siegenthaler.spotify.webapi.android.model.SimpleUser;
21 | import me.siegenthaler.spotify.webapi.android.request.AbstractRequest;
22 |
23 | /**
24 | * (non-doc)
25 | */
26 | public final class UserElseRequest extends AbstractRequest.Builder {
27 | /**
28 | * (non-doc)
29 | */
30 | public UserElseRequest() {
31 | super(SimpleUser.class);
32 | }
33 |
34 | /**
35 | * (non-doc)
36 | */
37 | public UserElseRequest setUser(String id) {
38 | return setPath(String.format(Locale.ENGLISH, "/v1/users/%s", id));
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/library/src/main/java/me/siegenthaler/spotify/webapi/android/request/profile/UserRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 Siegenthaler Solutions.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package me.siegenthaler.spotify.webapi.android.request.profile;
17 |
18 | import me.siegenthaler.spotify.webapi.android.model.User;
19 | import me.siegenthaler.spotify.webapi.android.request.AbstractRequest;
20 |
21 | /**
22 | * (non-doc)
23 | */
24 | public final class UserRequest extends AbstractRequest.Builder {
25 | /**
26 | * (non-doc)
27 | */
28 | public UserRequest() {
29 | super(User.class);
30 | setPath("/v1/me");
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':library', ':app'
2 |
--------------------------------------------------------------------------------