source: extensions/PiwigoLib/PiwigoLib/Proxy/PwgAlbumsProxy.cs @ 12336

Last change on this file since 12336 was 12336, checked in by bayral, 13 years ago

rename category to Albums

File size: 12.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using Com.Piwigo.Lib.DTO;
6using System.Web;
7using Com.Piwigo.Lib.Proxy.Response;
8using Com.Piwigo.Lib.Proxy.Helper;
9
10namespace Com.Piwigo.Lib.Proxy
11{
12    /// <summary>
13    /// pwg.categories.add              pwg_albums_add
14    /// pwg.categories.delete           pwg_albums_delete
15    /// pwg.categories.getAdminList     pwg_albums_getAdminList
16    /// pwg.categories.getImages        pwg_albums_getImages
17    /// pwg.categories.getList          pwg_albums_getList
18    /// pwg.categories.move             pwg_albums_move
19    /// pwg.categories.setInfo          pwg_albums_setInfo
20    /// </summary>
21    static internal class PwgAlbumsProxy
22    {
23        /// <summary>
24        /// pwg.Albums.getList
25        /// </summary>
26        /// <param name="AlbumId"></param>
27        /// <param name="Recursive"></param>
28        /// <param name="PublicOnly"></param>
29        /// <returns></returns>
30        static internal PwgAlbumsProxyResponse pwg_albums_getList(Int32? AlbumId, 
31            Boolean? Recursive, Boolean? PublicOnly)
32        {
33            PwgAlbumsProxyResponse response = null;
34            try
35            {
36                StringBuilder data = new StringBuilder();
37                Boolean firstOcc = true;
38
39                PwgProxyReponseHelper.buildQueryFromValue<Int32>(AlbumId, "cat_id", ref firstOcc, data);
40                PwgProxyReponseHelper.buildQueryFromValue<Boolean>(Recursive, "recursive", ref firstOcc, data);
41                PwgProxyReponseHelper.buildQueryFromValue<Boolean>(PublicOnly, "public", ref firstOcc, data);
42
43                response = PwgGenericProxy<PwgAlbumsProxyResponse>.Get(
44                                PwgConfigProxy.PwgServeurUri,
45                                "pwg.categories.getList", data.ToString());
46            }
47            catch (Exception ex)
48            {
49                throw new PwgProxyException("pwg_albums_getList", ex);
50            }
51            return response;
52
53        }
54
55        /// <summary>
56        /// pwg.Albums.getAdminList
57        /// </summary>
58        /// <returns></returns>
59        static internal PwgAlbumsProxyResponse pwg_albums_getAdminList()
60        {
61            PwgAlbumsProxyResponse response = null;
62            try
63            {
64                response = PwgGenericProxy<PwgAlbumsProxyResponse>.Get(
65                                PwgConfigProxy.PwgServeurUri,
66                                "pwg.categories.getAdminList", null);
67            }
68            catch (Exception ex)
69            {
70                throw new PwgProxyException("pwg_albums_getAdminList", ex);
71            }
72            return response;
73
74        }
75
76        /// <summary>
77        /// pwg.Albums.add
78        /// </summary>
79        /// <param name="AlbumName"></param>
80        /// <param name="IdUpperCat"></param>
81        /// <returns></returns>
82        static internal PwgAddRequestProxyResponse pwg_albums_add(String AlbumName, Int32? IdUpperCat)
83        {
84            PwgAddRequestProxyResponse response = null;
85            try
86            {
87                StringBuilder data = new StringBuilder();
88                data.Append("method=pwg.categories.add");
89                Boolean firstOcc = false;
90                PwgProxyReponseHelper.buildQueryFromValue<String>(AlbumName, "name", ref firstOcc, data);
91                PwgProxyReponseHelper.buildQueryFromValue<Int32>(IdUpperCat, "parent", ref firstOcc, data);
92
93                response = PwgGenericProxy<PwgAddRequestProxyResponse>.Post(
94                    PwgConfigProxy.PwgServeurUri,
95                    data.ToString());
96            }
97            catch (Exception ex)
98            {
99                throw new PwgProxyException("pwg_albums_add", ex);
100            }
101
102            return response;
103        }
104
105        /// <summary>
106        /// pwg.Albums.setInfo
107        /// </summary>
108        /// <param name="IdCat"></param>
109        /// <param name="AlbumName"></param>
110        /// <param name="AlbumComment"></param>
111        /// <returns></returns>
112        static internal PwgBaseProxyReponse pwg_albums_setInfo(Int32 IdCat, String AlbumName, String AlbumComment)
113        {
114            PwgBaseProxyReponse response = null;
115            try
116            {
117                StringBuilder data = new StringBuilder();
118                data.Append("method=pwg.categories.setInfo");
119                Boolean firstOcc = false;
120                PwgProxyReponseHelper.buildQueryFromValue<Int32>(IdCat, "category_id", ref firstOcc, data);
121                PwgProxyReponseHelper.buildQueryFromValue<String>(AlbumName, "name", ref firstOcc, data);
122                PwgProxyReponseHelper.buildQueryFromValue<String>(AlbumComment, "comment", ref firstOcc, data);
123
124                response = PwgGenericProxy<PwgAddRequestProxyResponse>.Post(
125                    PwgConfigProxy.PwgServeurUri,
126                    data.ToString());
127            }
128            catch (Exception ex)
129            {
130                throw new PwgProxyException("pwg_albums_setInfo", ex);
131            }
132
133            return response;
134        }
135
136        /// <summary>
137        /// pwg.Albums.getImages
138        /// </summary>
139        /// <param name="catId"></param>
140        /// <param name="recursive"></param>
141        /// <param name="perPage"></param>
142        /// <param name="Page"></param>
143        /// <param name="Order"></param>
144        /// <param name="minRate"></param>
145        /// <param name="maxRate"></param>
146        /// <param name="minHit"></param>
147        /// <param name="maxHit"></param>
148        /// <param name="minDateAvailable"></param>
149        /// <param name="maxDateAvailable"></param>
150        /// <param name="minDateCreated"></param>
151        /// <param name="maxDateCreated"></param>
152        /// <param name="minRatio"></param>
153        /// <param name="maxRatio"></param>
154        /// <param name="withThumbnail"></param>
155        /// <returns></returns>
156        static internal PwgImagesProxyResponse pwg_albums_getImages(Int32 catId,
157                                                            Boolean? recursive,
158                                                            Int32? perPage,
159                                                            Int32? Page,
160                                                            Int32? Order,
161                                                            Int32? minRate,
162                                                            Int32? maxRate,
163                                                            Int32? minHit,
164                                                            Int32? maxHit,
165                                                            DateTime? minDateAvailable,
166                                                            DateTime? maxDateAvailable,
167                                                            DateTime? minDateCreated,
168                                                            DateTime? maxDateCreated,
169                                                            Int32? minRatio,
170                                                            Int32? maxRatio,
171                                                            Boolean? withThumbnail)
172        {
173            PwgImagesProxyResponse response = null;
174            try
175            {
176                StringBuilder data = new StringBuilder();
177                Boolean firstOcc = true;
178                data.AppendFormat("method={0}", "pwg.categories.getImages");
179                firstOcc = false;
180                PwgProxyReponseHelper.buildQueryFromValue<Int32>(catId, "cat_id", ref firstOcc, data);
181
182                PwgProxyReponseHelper.buildQueryFromValue<Boolean>(recursive, "recursive", ref firstOcc, data);
183                PwgProxyReponseHelper.buildQueryFromValue<Int32>(perPage, "per_page", ref firstOcc, data);
184                PwgProxyReponseHelper.buildQueryFromValue<Int32>(Page, "page", ref firstOcc, data);
185                PwgProxyReponseHelper.buildQueryFromValue<Int32>(Order, "order", ref firstOcc, data);
186                PwgProxyReponseHelper.buildQueryFromValue<Int32>(minRate, "f_min_rate", ref firstOcc, data);
187                PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxRate, "f_max_rate", ref firstOcc, data);
188                PwgProxyReponseHelper.buildQueryFromValue<Int32>(minHit, "f_min_hit", ref firstOcc, data);
189                PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxHit, "f_max_hit", ref firstOcc, data);
190                PwgProxyReponseHelper.buildQueryFromValue<DateTime>(minDateAvailable, "f_min_date_available", ref firstOcc, data);
191                PwgProxyReponseHelper.buildQueryFromValue<DateTime>(maxDateAvailable, "f_max_date_available", ref firstOcc, data);
192                PwgProxyReponseHelper.buildQueryFromValue<DateTime>(minDateCreated, "f_min_date_created", ref firstOcc, data);
193                PwgProxyReponseHelper.buildQueryFromValue<DateTime>(maxDateCreated, "f_max_date_created", ref firstOcc, data);
194                PwgProxyReponseHelper.buildQueryFromValue<Int32>(minRatio, "f_min_ratio", ref firstOcc, data);
195                PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxRatio, "f_max_ratio", ref firstOcc, data);
196                PwgProxyReponseHelper.buildQueryFromValue<Boolean>(withThumbnail, "f_with_thumbnail", ref firstOcc, data);
197
198                response = PwgGenericProxy<PwgImagesProxyResponse>.Post(
199                                PwgConfigProxy.PwgServeurUri,
200                                data.ToString());
201            }
202            catch (Exception ex)
203            {
204                throw new PwgProxyException("pwg_albums_getImages", ex);
205            }
206            return response;
207
208        }
209
210        /// <summary>
211        /// pwg.Albums.delete
212        /// </summary>
213        /// <param name="AlbumsId"></param>
214        /// <param name="SecurityToken"></param>
215        /// <param name="PhotoDeletionMode"></param>
216        /// <returns></returns>
217        static internal PwgBaseProxyReponse pwg_albums_delete(Int32 AlbumId,
218                                                                  String SecurityToken,
219                                                                  PwgAlbumPhotoDeletionModeEnum PhotoDeletionMode)
220        {
221            PwgBaseProxyReponse response = null;
222            try
223            {
224                StringBuilder data = new StringBuilder();
225                Boolean firstOcc = true;
226                data.Append("method=pwg.categories.delete");
227                firstOcc = false;
228                PwgProxyReponseHelper.buildQueryFromValue<Int32>(AlbumId, "category_id", ref firstOcc, data);
229                PwgProxyReponseHelper.buildQueryFromValue<String>(SecurityToken, "pwg_token", ref firstOcc, data);
230                PwgProxyReponseHelper.buildQueryFromValue<PwgAlbumPhotoDeletionModeEnum>(PhotoDeletionMode, "photo_deletion_mode", ref firstOcc, data);
231
232                response = PwgGenericProxy<PwgBaseProxyReponse>.Post(
233                                PwgConfigProxy.PwgServeurUri,
234                                data.ToString());
235            }
236            catch (Exception ex)
237            {
238                throw new PwgProxyException("pwg_albums_delete", ex);
239            }
240
241            return response;
242        }
243
244        static internal PwgBaseProxyReponse pwg_albums_move(List<Int32> AlbumsId,
245                                                                Int32 ParentAlbumId,
246                                                                String SecurityToken)
247        {
248            PwgBaseProxyReponse response = null;
249            try
250            {
251                StringBuilder data = new StringBuilder();
252                Boolean firstOcc = true;
253                data.Append("method=pwg.categories.move");
254                firstOcc = false;
255                PwgProxyReponseHelper.buildQueryFromArray<Int32>(AlbumsId, "category_id", ref firstOcc, data);
256                PwgProxyReponseHelper.buildQueryFromValue<Int32>(ParentAlbumId, "parent", ref firstOcc, data);
257                PwgProxyReponseHelper.buildQueryFromValue<String>(SecurityToken, "pwg_token", ref firstOcc, data);
258
259                response = PwgGenericProxy<PwgBaseProxyReponse>.Post(
260                                PwgConfigProxy.PwgServeurUri,
261                                data.ToString());
262            }
263            catch (Exception ex)
264            {
265                throw new PwgProxyException("pwg_albums_delete", ex);
266            }
267
268            return response;
269        }
270    }
271
272}
273
Note: See TracBrowser for help on using the repository browser.