001// Generated by delombok at Sun Sep 26 16:30:34 CEST 2021
002/*
003 * Copyright (c) 2010-2021 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;
024
025import java.util.ArrayList;
026import java.util.List;
027import java.util.stream.Collectors;
028import com.restfb.Facebook;
029import com.restfb.JsonMapper;
030import com.restfb.Version;
031
032/**
033 * Represents the <a href="https://developers.facebook.com/docs/graph-api/reference/app/subscriptions">App Subscription
034 * type</a>.
035 * 
036 * @author <a href="http://restfb.com">Norbert Bartels</a>
037 * @since 1.5
038 */
039public class Subscription extends AbstractFacebookType {
040  private static final long serialVersionUID = 1L;
041  /**
042   * Indicates the object type that this subscription applies to.
043   * 
044   * type: user, page, permissions, payments
045   * 
046   */
047  @Facebook
048  private String object;
049  /**
050   * The URL that will receive the POST request when an update is triggered.
051   * 
052   */
053  @Facebook("callback_url")
054  private String callbackUrl;
055  /**
056   * One or more of the set of valid fields in this object to subscribe to.
057   * 
058   * The set of valid fields is defined here:
059   * https://developers.facebook.com/docs/graph-api/real-time-updates/v2.3#subscribefields
060   * 
061   */
062  @Facebook
063  private List<SubscriptionField> fields;
064  @Facebook("fields")
065  private List<String> compatFields;
066  /**
067   * Indicates whether or not the subscription is active.
068   * 
069   */
070  @Facebook
071  private Boolean active;
072
073  @JsonMapper.JsonMappingCompleted
074  private void convertCompatFields() {
075    if (compatFields != null && fields == null) {
076      fields = compatFields.stream().map(SubscriptionField::new).collect(Collectors.toList());
077    }
078  }
079
080
081  public static class SubscriptionField extends AbstractFacebookType {
082    public SubscriptionField() {
083      // nothing to do
084    }
085
086    private SubscriptionField(String name) {
087      this.name = name;
088      this.version = Version.UNVERSIONED;
089    }
090
091    private static final long serialVersionUID = 1L;
092    @Facebook
093    private String name;
094    private Version version;
095    @Facebook("version")
096    private String versionAsString;
097
098    @JsonMapper.JsonMappingCompleted
099    public void convertVersion() {
100      version = Version.getVersionFromString(versionAsString);
101    }
102
103    @java.lang.SuppressWarnings("all")
104    public String getName() {
105      return this.name;
106    }
107
108    @java.lang.SuppressWarnings("all")
109    public void setName(final String name) {
110      this.name = name;
111    }
112
113    @java.lang.SuppressWarnings("all")
114    public Version getVersion() {
115      return this.version;
116    }
117
118    @java.lang.SuppressWarnings("all")
119    public void setVersion(final Version version) {
120      this.version = version;
121    }
122  }
123
124  /**
125   * Indicates the object type that this subscription applies to.
126   * 
127   * type: user, page, permissions, payments
128   * 
129   * @return the object type that this subscription applies to
130   */
131  @java.lang.SuppressWarnings("all")
132  public String getObject() {
133    return this.object;
134  }
135
136  /**
137   * Indicates the object type that this subscription applies to.
138   * 
139   * type: user, page, permissions, payments
140   * 
141   */
142  @java.lang.SuppressWarnings("all")
143  public void setObject(final String object) {
144    this.object = object;
145  }
146
147  /**
148   * The URL that will receive the POST request when an update is triggered.
149   * 
150   * @return the URL that will receive the POST request
151   */
152  @java.lang.SuppressWarnings("all")
153  public String getCallbackUrl() {
154    return this.callbackUrl;
155  }
156
157  /**
158   * The URL that will receive the POST request when an update is triggered.
159   * 
160   */
161  @java.lang.SuppressWarnings("all")
162  public void setCallbackUrl(final String callbackUrl) {
163    this.callbackUrl = callbackUrl;
164  }
165
166  /**
167   * One or more of the set of valid fields in this object to subscribe to.
168   * 
169   * The set of valid fields is defined here:
170   * https://developers.facebook.com/docs/graph-api/real-time-updates/v2.3#subscribefields
171   * 
172   * @return set of fields
173   */
174  @java.lang.SuppressWarnings("all")
175  public List<SubscriptionField> getFields() {
176    return this.fields;
177  }
178
179  /**
180   * One or more of the set of valid fields in this object to subscribe to.
181   * 
182   * The set of valid fields is defined here:
183   * https://developers.facebook.com/docs/graph-api/real-time-updates/v2.3#subscribefields
184   * 
185   */
186  @java.lang.SuppressWarnings("all")
187  public void setFields(final List<SubscriptionField> fields) {
188    this.fields = fields;
189  }
190
191  /**
192   * Indicates whether or not the subscription is active.
193   * 
194   * @return if the subscription is active
195   */
196  @java.lang.SuppressWarnings("all")
197  public Boolean getActive() {
198    return this.active;
199  }
200
201  /**
202   * Indicates whether or not the subscription is active.
203   * 
204   */
205  @java.lang.SuppressWarnings("all")
206  public void setActive(final Boolean active) {
207    this.active = active;
208  }
209}