|
| 1 | +/* |
| 2 | + * Copyright 2015 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.springframework.social.facebook.api; |
| 17 | + |
| 18 | +import org.springframework.util.LinkedMultiValueMap; |
| 19 | +import org.springframework.util.MultiValueMap; |
| 20 | + |
| 21 | +/** |
| 22 | + * An object that captures data used to update a Page. |
| 23 | + * @author Craig Walls |
| 24 | + */ |
| 25 | +public class PageUpdate { |
| 26 | + |
| 27 | + private final String pageId; |
| 28 | + |
| 29 | + private String about; |
| 30 | + |
| 31 | + private String bio; |
| 32 | + |
| 33 | + private String cover; |
| 34 | + |
| 35 | + private String name; |
| 36 | + |
| 37 | + private Integer offsetX; |
| 38 | + |
| 39 | + private Integer offsetY; |
| 40 | + |
| 41 | + private Float zoomScaleX; |
| 42 | + |
| 43 | + private Float zoomScaleY; |
| 44 | + |
| 45 | + private Float focusX; |
| 46 | + |
| 47 | + private Float focusY; |
| 48 | + |
| 49 | + /** |
| 50 | + * Creates a new {@link PageUpdate}. |
| 51 | + * @param pageId The ID of the page to update. |
| 52 | + */ |
| 53 | + public PageUpdate(String pageId) { |
| 54 | + this.pageId = pageId; |
| 55 | + } |
| 56 | + |
| 57 | + public String getPageId() { |
| 58 | + return pageId; |
| 59 | + } |
| 60 | + |
| 61 | + public PageUpdate about(String about) { |
| 62 | + this.about = about; |
| 63 | + return this; |
| 64 | + } |
| 65 | + |
| 66 | + public PageUpdate bio(String bio) { |
| 67 | + this.bio = bio; |
| 68 | + return this; |
| 69 | + } |
| 70 | + |
| 71 | + public PageUpdate cover(String cover, Integer offsetX, Integer offsetY, Float zoomScaleX, Float zoomScaleY, Float focusX, Float focusY) { |
| 72 | + this.cover = cover; |
| 73 | + this.offsetX = offsetX; |
| 74 | + this.offsetY = offsetY; |
| 75 | + this.zoomScaleX = zoomScaleX; |
| 76 | + this.zoomScaleY = zoomScaleY; |
| 77 | + this.focusX = focusX; |
| 78 | + this.focusY = focusY; |
| 79 | + return this; |
| 80 | + } |
| 81 | + |
| 82 | + public PageUpdate name(String name) { |
| 83 | + this.name = name; |
| 84 | + return this; |
| 85 | + } |
| 86 | + |
| 87 | + public MultiValueMap<String, Object> toRequestParameters() { |
| 88 | + MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<String, Object>(); |
| 89 | + if (about != null) { parameters.add("about", about); } |
| 90 | + if (bio != null) { parameters.add("bio", bio); } |
| 91 | + if (cover != null) { parameters.add("cover", cover); } |
| 92 | + if (name != null) { parameters.add("name", name); } |
| 93 | + if (offsetX != null) { parameters.add("offset_x", offsetX.toString()); } |
| 94 | + if (offsetY != null) { parameters.add("offset_y", offsetY.toString()); } |
| 95 | + if (zoomScaleX != null) { parameters.add("zoom_scale_x", zoomScaleX.toString()); } |
| 96 | + if (zoomScaleY != null) { parameters.add("zoom_scale_y", zoomScaleY.toString()); } |
| 97 | + if (focusX != null) { parameters.add("focus_x", focusX.toString()); } |
| 98 | + if (focusY != null) { parameters.add("focus_y", focusY.toString()); } |
| 99 | + return parameters; |
| 100 | + } |
| 101 | + |
| 102 | +} |
0 commit comments