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