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