View Javadoc

1   /*
2    * Copyright (c) 2010 Commsen International. All rights reserved.
3    * 
4    * This file is part of JWebThumb library.
5    *	
6    * JWebThumb library is free software: you can redistribute it and/or modify 
7    * it under the terms of the GNU Lesser General Public License as published by
8    * the Free Software Foundation, either version 2 of the License, or
9    * (at your option) any later version.
10   * 
11   * JWebThumb library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Lesser General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Lesser General Public License
17   * along with JWebThumb library.  If not, see <http://www.gnu.org/licenses/lgpl.html>.
18   */
19  
20  package com.commsen.jwebthumb;
21  
22  import java.util.List;
23  
24  import org.simpleframework.xml.Element;
25  import org.simpleframework.xml.ElementList;
26  import org.simpleframework.xml.Root;
27  
28  /***
29   * This class represents the xml payload of all webthumb requests. See <a
30   * href="http://webthumb.bluga.net/apidoc">http://webthumb.bluga.net/apidoc</a> for details.
31   * 
32   * @author <a href="mailto:MilenDyankov@gmail.com">Milen Dyankov</a>
33   * @see http://webthumb.bluga.net/apidoc
34   */
35  @Root(name = "webthumb")
36  public class WebThumb {
37  
38  	@Element
39  	private String apikey;
40  
41  	@Element
42  	private int version = 3;
43  
44  	@ElementList(required = false, inline = true, entry = "request")
45  	private List<WebThumbRequest> requests;
46  
47  	@Element(required = false, name = "fetch")
48  	private WebThumbFetchRequest fetchRequest;
49  
50  	@Element(required = false, name = "status")
51  	private WebThumbStatusRequest statusRequest;
52  
53  	@Element(required = false)
54  	private WebThumbCredits credits;
55  
56  
57  	/***
58  	 * Returns new credits request.
59  	 * 
60  	 * @param apikey the WebThumb's API key to use
61  	 * @return WebThumb credits object
62  	 */
63  	public static WebThumb creditsRequest(String apikey) {
64  		WebThumb webThumb = new WebThumb(apikey);
65  		webThumb.credits = new WebThumbCredits();
66  		return webThumb;
67  	}
68  
69  
70  	/***
71  	 * Creates new empty WebThumb object
72  	 * 
73  	 * @param apikey the WebThumb's API key to use
74  	 */
75  	private WebThumb(String apikey) {
76  		this.apikey = apikey;
77  	}
78  
79  
80  	/***
81  	 * Creates new WebThumb object from provided {@link WebThumbRequest} requests
82  	 * 
83  	 * @param apikey the WebThumb's API key to use
84  	 * @param requests
85  	 */
86  	public WebThumb(String apikey, List<WebThumbRequest> requests) {
87  		this.apikey = apikey;
88  		this.requests = requests;
89  	}
90  
91  
92  	/***
93  	 * Creates new WebThumb object from provided {@link WebThumbFetchRequest} request
94  	 * 
95  	 * @param apikey the WebThumb's API key to use
96  	 * @param fetchRequest
97  	 */
98  	public WebThumb(String apikey, WebThumbFetchRequest fetchRequest) {
99  		this.apikey = apikey;
100 		this.fetchRequest = fetchRequest;
101 	}
102 
103 
104 	/***
105 	 * Creates new WebThumb object from provided {@link WebThumbStatusRequest} request
106 	 * 
107 	 * @param apikey the WebThumb's API key to use
108 	 * @param statusRequest
109 	 */
110 	public WebThumb(String apikey, WebThumbStatusRequest statusRequest) {
111 		this.apikey = apikey;
112 		this.statusRequest = statusRequest;
113 	}
114 }