org.codeforamerica.open311.internals.network
Class URLBuilder

java.lang.Object
  extended by org.codeforamerica.open311.internals.network.URLBuilder

public class URLBuilder
extends Object

Builds the necessary URLs to communicate with the endpoints.

Author:
Santiago MunĂ­n

Constructor Summary
URLBuilder(String baseUrl, String jurisdictionId, String format)
           
 
Method Summary
 URL buildGetServiceDefinitionUrl(String serviceCode)
          Builds a GET Service Definition URL.
 URL buildGetServiceListUrl()
          Builds a GET Service List URL.
 URL buildGetServiceRequest(String serviceId)
          Builds a GET Service Request URL.
 URL buildGetServiceRequestIdFromATokenUrl(String token)
          Builds a GET Service Request ID From Token URL.
 URL buildGetServiceRequests(Map<String,String> arguments)
          Builds a GET Service Requests URL.
 Map<String,String> buildPostServiceRequestBody(Map<String,String> arguments, List<Attribute> attributes)
          Builds the list of arguments of a POST service request.
 URL buildPostServiceRequestUrl()
          Builds a POST Service Request URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URLBuilder

public URLBuilder(String baseUrl,
                  String jurisdictionId,
                  String format)
Method Detail

buildGetServiceListUrl

public URL buildGetServiceListUrl()
                           throws MalformedURLException
Builds a GET Service List URL.

Returns:
An URL ready to be accessed.
Throws:
MalformedURLException - If one of the parts of the url (endpoint's base url, format...) is not correct.

buildGetServiceDefinitionUrl

public URL buildGetServiceDefinitionUrl(String serviceCode)
                                 throws MalformedURLException
Builds a GET Service Definition URL.

Parameters:
serviceCode - Code of the service to find the definition.
Returns:
An URL ready to be accessed.
Throws:
MalformedURLException - If one of the parts of the url (endpoint's base url, format...) is not correct.

buildPostServiceRequestUrl

public URL buildPostServiceRequestUrl()
                               throws MalformedURLException
Builds a POST Service Request URL.

Returns:
An URL ready to be accessed.
Throws:
MalformedURLException - If one of the parts of the url (endpoint's base url, format...) is not correct.

buildGetServiceRequestIdFromATokenUrl

public URL buildGetServiceRequestIdFromATokenUrl(String token)
                                          throws MalformedURLException
Builds a GET Service Request ID From Token URL.

Parameters:
token - Token associated to a service request.
Returns:
An URL ready to be accessed.
Throws:
MalformedURLException - If one of the parts of the url (endpoint's base url, format...) is not correct.

buildGetServiceRequests

public URL buildGetServiceRequests(Map<String,String> arguments)
                            throws MalformedURLException
Builds a GET Service Requests URL.

Parameters:
arguments - Pairs (key, value) of optional arguments
Returns:
An URL ready to be accessed.
Throws:
MalformedURLException - If one of the parts of the url (endpoint's base url, format...) is not correct.

buildGetServiceRequest

public URL buildGetServiceRequest(String serviceId)
                           throws MalformedURLException
Builds a GET Service Request URL.

Parameters:
serviceId - Id of the service.
Returns:
An URL ready to be accessed.
Throws:
MalformedURLException - If one of the parts of the url (endpoint's base url, format...) is not correct.

buildPostServiceRequestBody

public Map<String,String> buildPostServiceRequestBody(Map<String,String> arguments,
                                                      List<Attribute> attributes)
                                               throws MalformedURLException
Builds the list of arguments of a POST service request.

Parameters:
arguments - List of (key, value) pairs.
attributes - List of attributes.
Returns:
A list of (key, value) pairs with all the given data (arguments and attributes).
Throws:
MalformedURLException - If any of the arguments given is not allowed.


Copyright © 2013 Code for America. All Rights Reserved.