001// Generated by delombok at Sun Apr 14 14:59:49 CEST 2024
002/*
003 * Copyright (c) 2010-2024 Mark Allen, Norbert Bartels.
004 *
005 * Permission is hereby granted, free of charge, to any person obtaining a copy
006 * of this software and associated documentation files (the "Software"), to deal
007 * in the Software without restriction, including without limitation the rights
008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
009 * copies of the Software, and to permit persons to whom the Software is
010 * furnished to do so, subject to the following conditions:
011 *
012 * The above copyright notice and this permission notice shall be included in
013 * all copies or substantial portions of the Software.
014 *
015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
021 * THE SOFTWARE.
022 */
023package com.restfb.types.ads;
024
025import com.restfb.Facebook;
026import com.restfb.JsonMapper;
027import com.restfb.json.Json;
028import com.restfb.json.JsonArray;
029import com.restfb.json.JsonValue;
030import com.restfb.types.AbstractFacebookType;
031
032/**
033 * Represents the
034 * <a href="https://developers.facebook.com/docs/marketing-api/reference/ads-image-crops/">AdsImageCrops</a> Marketing
035 * API type
036 *
037 * Every field is following the crops specification, in the format of [[{left},{top}],[{right},{bottom}]].
038 */
039public class AdsImageCrops extends AbstractFacebookType {
040  private AdsImageCropsSpec thumb100x100;
041  @Facebook("100x100")
042  private String thumb100x100String;
043  private AdsImageCropsSpec thumb100x72;
044  @Facebook("100x72")
045  private String thumb100x72String;
046  private AdsImageCropsSpec thumb191x100;
047  @Facebook("191x100")
048  private String thumb191x100String;
049  private AdsImageCropsSpec thumb400x150;
050  @Facebook("400x150")
051  private String thumb400x150String;
052  private AdsImageCropsSpec thumb600x360;
053  @Facebook("600x360")
054  private String thumb600x360String;
055
056
057  public static class AdsImageCropsSpec extends AbstractFacebookType {
058    private Long left;
059    private Long top;
060    private Long right;
061    private Long bottom;
062
063    @java.lang.SuppressWarnings("all")
064    public Long getLeft() {
065      return this.left;
066    }
067
068    @java.lang.SuppressWarnings("all")
069    public void setLeft(final Long left) {
070      this.left = left;
071    }
072
073    @java.lang.SuppressWarnings("all")
074    public Long getTop() {
075      return this.top;
076    }
077
078    @java.lang.SuppressWarnings("all")
079    public void setTop(final Long top) {
080      this.top = top;
081    }
082
083    @java.lang.SuppressWarnings("all")
084    public Long getRight() {
085      return this.right;
086    }
087
088    @java.lang.SuppressWarnings("all")
089    public void setRight(final Long right) {
090      this.right = right;
091    }
092
093    @java.lang.SuppressWarnings("all")
094    public Long getBottom() {
095      return this.bottom;
096    }
097
098    @java.lang.SuppressWarnings("all")
099    public void setBottom(final Long bottom) {
100      this.bottom = bottom;
101    }
102  }
103
104  @JsonMapper.JsonMappingCompleted
105  private void convert() {
106    thumb100x100 = createSpecFromString(thumb100x100String);
107    thumb100x72 = createSpecFromString(thumb100x72String);
108    thumb191x100 = createSpecFromString(thumb191x100String);
109    thumb400x150 = createSpecFromString(thumb400x150String);
110    thumb600x360 = createSpecFromString(thumb600x360String);
111  }
112
113  private AdsImageCropsSpec createSpecFromString(String input) {
114    AdsImageCropsSpec spec = null;
115    if (input != null) {
116      spec = new AdsImageCropsSpec();
117      JsonValue ar = Json.parse(input);
118      JsonArray outerArray = ar.asArray();
119      JsonArray leftTop = outerArray.get(0).asArray();
120      spec.setLeft(leftTop.get(0).asLong());
121      spec.setTop(leftTop.get(1).asLong());
122      JsonArray rightBottom = outerArray.get(1).asArray();
123      spec.setRight(rightBottom.get(0).asLong());
124      spec.setBottom(rightBottom.get(1).asLong());
125    }
126    return spec;
127  }
128
129  @java.lang.SuppressWarnings("all")
130  public AdsImageCropsSpec getThumb100x100() {
131    return this.thumb100x100;
132  }
133
134  @java.lang.SuppressWarnings("all")
135  public void setThumb100x100(final AdsImageCropsSpec thumb100x100) {
136    this.thumb100x100 = thumb100x100;
137  }
138
139  @java.lang.SuppressWarnings("all")
140  public AdsImageCropsSpec getThumb100x72() {
141    return this.thumb100x72;
142  }
143
144  @java.lang.SuppressWarnings("all")
145  public void setThumb100x72(final AdsImageCropsSpec thumb100x72) {
146    this.thumb100x72 = thumb100x72;
147  }
148
149  @java.lang.SuppressWarnings("all")
150  public AdsImageCropsSpec getThumb191x100() {
151    return this.thumb191x100;
152  }
153
154  @java.lang.SuppressWarnings("all")
155  public void setThumb191x100(final AdsImageCropsSpec thumb191x100) {
156    this.thumb191x100 = thumb191x100;
157  }
158
159  @java.lang.SuppressWarnings("all")
160  public AdsImageCropsSpec getThumb400x150() {
161    return this.thumb400x150;
162  }
163
164  @java.lang.SuppressWarnings("all")
165  public void setThumb400x150(final AdsImageCropsSpec thumb400x150) {
166    this.thumb400x150 = thumb400x150;
167  }
168
169  @java.lang.SuppressWarnings("all")
170  public AdsImageCropsSpec getThumb600x360() {
171    return this.thumb600x360;
172  }
173
174  @java.lang.SuppressWarnings("all")
175  public void setThumb600x360(final AdsImageCropsSpec thumb600x360) {
176    this.thumb600x360 = thumb600x360;
177  }
178}