// Path: src/main/java/com/sonoport/freesound/query/HTTPRequestMethod.java
// public enum HTTPRequestMethod {
// 
// 	/** HTTP GET. */
// 	GET,
// 
// 	/** HTTP POST. */
// 	POST,
// 
// 	/** HTTP PUT. */
// 	PUT,
// 
// 	/** HTTP DELETE. */
// 	DELETE,
// 
// 	/** HTTP PATCH. */
// 	PATCH,
// 
// 	/** HTTP HEAD. */
// 	HEAD,
// 
// 	/** HTTP OPTIONS. */
// 	OPTIONS;
// }
// 
// Path: src/main/java/com/sonoport/freesound/query/JSONResponseQuery.java
// public abstract class JSONResponseQuery<R extends Object> extends Query<JSONObject, R> {
// 
// 	/**
// 	 * @param httpRequestMethod HTTP method to use for query
// 	 * @param path Endpoint to submit the query to
// 	 * @param resultsMapper {@link Mapper} to convert results
// 	 */
// 	protected JSONResponseQuery(
// 			final HTTPRequestMethod httpRequestMethod, final String path, final Mapper<JSONObject, R> resultsMapper) {
// 		super(httpRequestMethod, path, resultsMapper);
// 	}
// 
// 	@Override
// 	protected String extractErrorMessage(final JSONObject freesoundResponse) {
// 		return freesoundResponse.getString("detail");
// 	}
// 
// }
// 
// Path: src/main/java/com/sonoport/freesound/query/OAuthQuery.java
// public interface OAuthQuery {
// 
// 	/**
// 	 * @return The oauthToken to be presented with the request
// 	 */
// 	String getOauthToken();
// 
// }
// 
// Path: src/main/java/com/sonoport/freesound/response/mapping/DetailStringMapper.java
// public class DetailStringMapper extends Mapper<JSONObject, String> {
// 
// 	@Override
// 	public String map(final JSONObject source) {
// 		return extractFieldValue(source, "detail", String.class);
// 	}
// 
// }


import java.util.HashMap;
import java.util.Map;
import com.sonoport.freesound.query.HTTPRequestMethod;
import com.sonoport.freesound.query.JSONResponseQuery;
import com.sonoport.freesound.query.OAuthQuery;
import com.sonoport.freesound.response.mapping.DetailStringMapper;
/*
 * Copyright 2014 Sonoport (Asia) Pte Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.sonoport.freesound.query.sound;



/**
 * Class that allows the currently authorised user to bookmark a sound. By default the bookmark will use the name of the
 * sound and be uncategorised - this can be overridden by using the {@link #name(String)} and {@link #category(String)}
 * methods.
 *
 * API documentation: http://www.freesound.org/docs/api/resources_apiv2.html#bookmark-sound-oauth2-required
 *
 * Note that there is currently a bug in the Freesound API that means both name and category of the bookmark must be
 * specified at present (despite the documentation stating they are optional). A bug has been raised on GitHub covering
 * this issue: https://github.com/MTG/freesound/issues/642.
 */
public class BookmarkSound extends JSONResponseQuery<String> implements OAuthQuery {

	/** Route parameter to be replaced with the identifier of the sound to be bookmarked. */
	protected static final String SOUND_ID_ROUTE_PARAMETER = "sound_id";

	/** Path to the API endpoint. */
	private static final String PATH = String.format("/sounds/{%s}/bookmark/", SOUND_ID_ROUTE_PARAMETER);

	/** Parameter to pass the (optional) name of the bookmark on as. */
	protected static final String BOOKMARK_NAME_PARAMETER = "name";

	/** Parameter to pass the (optional) category of the bookmark on as. */
	protected static final String BOOKMARK_CATEGORY_PARAMETER = "category";

	/** Identifier of the sound to bookmark. */
	private final int soundId;

	/** Name to give the bookmark. */
	private String bookmarkName;

	/** Category to group the bookmark under. */
	private String bookmarkCategory;

	/** OAuth2 bearer token to present with request. */
	private final String oauthToken;

	/**
	 * @param soundId Identifier of sound to bookmark
	 * @param oauthToken OAuth token to present with request
	 */
	public BookmarkSound(final int soundId, final String oauthToken) {
		this(soundId, oauthToken, null, null);
	}

	/**
	 * @param soundId Identifier of sound to bookmark
	 * @param oauthToken OAuth token to present with request
	 * @param bookmarkName Name to give the bookmark
	 * @param bookmarkCategory Category to assign the bookmark to
	 */
	public BookmarkSound(
			final int soundId, final String oauthToken, final String bookmarkName, final String bookmarkCategory) {
// Path: src/main/java/com/sonoport/freesound/query/HTTPRequestMethod.java
// public enum HTTPRequestMethod {
// 
// 	/** HTTP GET. */
// 	GET,
// 
// 	/** HTTP POST. */
// 	POST,
// 
// 	/** HTTP PUT. */
// 	PUT,
// 
// 	/** HTTP DELETE. */
// 	DELETE,
// 
// 	/** HTTP PATCH. */
// 	PATCH,
// 
// 	/** HTTP HEAD. */
// 	HEAD,
// 
// 	/** HTTP OPTIONS. */
// 	OPTIONS;
// }
// 
// Path: src/main/java/com/sonoport/freesound/query/JSONResponseQuery.java
// public abstract class JSONResponseQuery<R extends Object> extends Query<JSONObject, R> {
// 
// 	/**
// 	 * @param httpRequestMethod HTTP method to use for query
// 	 * @param path Endpoint to submit the query to
// 	 * @param resultsMapper {@link Mapper} to convert results
// 	 */
// 	protected JSONResponseQuery(
// 			final HTTPRequestMethod httpRequestMethod, final String path, final Mapper<JSONObject, R> resultsMapper) {
// 		super(httpRequestMethod, path, resultsMapper);
// 	}
// 
// 	@Override
// 	protected String extractErrorMessage(final JSONObject freesoundResponse) {
// 		return freesoundResponse.getString("detail");
// 	}
// 
// }
// 
// Path: src/main/java/com/sonoport/freesound/query/OAuthQuery.java
// public interface OAuthQuery {
// 
// 	/**
// 	 * @return The oauthToken to be presented with the request
// 	 */
// 	String getOauthToken();
// 
// }
// 
// Path: src/main/java/com/sonoport/freesound/response/mapping/DetailStringMapper.java
// public class DetailStringMapper extends Mapper<JSONObject, String> {
// 
// 	@Override
// 	public String map(final JSONObject source) {
// 		return extractFieldValue(source, "detail", String.class);
// 	}
// 
// }


// Path: src/main/java/com/sonoport/freesound/query/sound/BookmarkSound.java
import java.util.HashMap;
import java.util.Map;
import com.sonoport.freesound.query.HTTPRequestMethod;
import com.sonoport.freesound.query.JSONResponseQuery;
import com.sonoport.freesound.query.OAuthQuery;
import com.sonoport.freesound.response.mapping.DetailStringMapper;

/*
 * Copyright 2014 Sonoport (Asia) Pte Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.sonoport.freesound.query.sound;



/**
 * Class that allows the currently authorised user to bookmark a sound. By default the bookmark will use the name of the
 * sound and be uncategorised - this can be overridden by using the {@link #name(String)} and {@link #category(String)}
 * methods.
 *
 * API documentation: http://www.freesound.org/docs/api/resources_apiv2.html#bookmark-sound-oauth2-required
 *
 * Note that there is currently a bug in the Freesound API that means both name and category of the bookmark must be
 * specified at present (despite the documentation stating they are optional). A bug has been raised on GitHub covering
 * this issue: https://github.com/MTG/freesound/issues/642.
 */
public class BookmarkSound extends JSONResponseQuery<String> implements OAuthQuery {

	/** Route parameter to be replaced with the identifier of the sound to be bookmarked. */
	protected static final String SOUND_ID_ROUTE_PARAMETER = "sound_id";

	/** Path to the API endpoint. */
	private static final String PATH = String.format("/sounds/{%s}/bookmark/", SOUND_ID_ROUTE_PARAMETER);

	/** Parameter to pass the (optional) name of the bookmark on as. */
	protected static final String BOOKMARK_NAME_PARAMETER = "name";

	/** Parameter to pass the (optional) category of the bookmark on as. */
	protected static final String BOOKMARK_CATEGORY_PARAMETER = "category";

	/** Identifier of the sound to bookmark. */
	private final int soundId;

	/** Name to give the bookmark. */
	private String bookmarkName;

	/** Category to group the bookmark under. */
	private String bookmarkCategory;

	/** OAuth2 bearer token to present with request. */
	private final String oauthToken;

	/**
	 * @param soundId Identifier of sound to bookmark
	 * @param oauthToken OAuth token to present with request
	 */
	public BookmarkSound(final int soundId, final String oauthToken) {
		this(soundId, oauthToken, null, null);
	}

	/**
	 * @param soundId Identifier of sound to bookmark
	 * @param oauthToken OAuth token to present with request
	 * @param bookmarkName Name to give the bookmark
	 * @param bookmarkCategory Category to assign the bookmark to
	 */
	public BookmarkSound(
			final int soundId, final String oauthToken, final String bookmarkName, final String bookmarkCategory) {
		super(HTTPRequestMethod.POST, PATH, new DetailStringMapper());