package com.sharefile.api;

import java.net.URI;
import java.net.URISyntaxException;

import com.sharefile.api.constants.SFSDK;
import com.sharefile.api.entities.*;
import com.sharefile.api.enumerations.SFProvider;

/** 
 * The entities have non-static get* functions to build the queries. The auto-generated SDK does not want to change this. 
 * lets simplify building the queries with the query builder class which holds static entity references so that the app does 
 * not haver to  create a new entity object every time it needs to build a query.
 */
public class SFQueryBuilder
{
	public static final SFAccessControlsEntity ACCESS_CONTROL = new SFAccessControlsEntity();
	public static final SFAccountsEntity ACCOUNTS = new SFAccountsEntity();
	public static final SFAsyncOperationsEntity ASYNC_OPERATION = new SFAsyncOperationsEntity();
	public static final SFCapabilitiesEntity CAPABILITIES = new SFCapabilitiesEntity();
	public static final SFConfigsEntity CONFIG = new SFConfigsEntity();
	public static final SFFavoriteFoldersEntity FAVORITE_FOLDERS = new SFFavoriteFoldersEntity();
	public static final SFGroupsEntity GROUPS = new SFGroupsEntity();
	public static final SFItemsEntity ITEMS = new SFItemsEntity();
	public static final SFMetadataEntity METADATA = new SFMetadataEntity();	
	public static final SFSessionsEntity SESSIONS = new SFSessionsEntity();
	public static final SFSharesEntity SHARES = new SFSharesEntity();
	public static final SFUsersEntity USERS = new SFUsersEntity();
		
	private static final String FORMAT_GET_TOP_FOLDER = "https://%s.%s"+SFProvider.PROVIDER_TYPE_SF+"Items(%s)";
	
	
	/**
	 *   We need to manually construct the v3 url for the TOP folder. This function provides the helper for the apps
	 *   to build that url.
	 */
	public static final URI getDefaultURL(final String subdomain,String hostname,final String folderID) throws URISyntaxException
    {
          URI uri = null;
          
          String urlSpec = String.format(FORMAT_GET_TOP_FOLDER, subdomain,SFSDK.getApiServer(hostname),folderID);
          
          uri = new URI(urlSpec);
                      
          return uri;
    }
}
@@ -1608,16 +1608,125 @@
 s(%25s)%22;%0A
+%09private static final String FORMAT_GET_DEVICES = %22https://%25s.%25s%22+SFProvider.PROVIDER_TYPE_SF+%22Devices(%25s)%22;%0A
 %09%0A%09%0A%09/**
@@ -2250,9 +2250,363 @@
 ;%0A    %7D%0A
+%09%0A%09public static final URI getDeviceURL(final String subdomain, String hostname, final String deviceID) throws URISyntaxException%0A%09%7B%0A%09%09URI uri = null;%0A        %0A        String urlSpec = String.format(FORMAT_GET_DEVICES, subdomain,SFSDK.getApiServer(hostname),deviceID);%0A        %0A        uri = new URI(urlSpec);%0A                    %0A        return uri;%0A%09%7D%0A
 %7D

add URL builder for device URI