001/* 002 * Copyright (c) 2010-2024 Mark Allen, Norbert Bartels. 003 * 004 * Permission is hereby granted, free of charge, to any person obtaining a copy 005 * of this software and associated documentation files (the "Software"), to deal 006 * in the Software without restriction, including without limitation the rights 007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 008 * copies of the Software, and to permit persons to whom the Software is 009 * furnished to do so, subject to the following conditions: 010 * 011 * The above copyright notice and this permission notice shall be included in 012 * all copies or substantial portions of the Software. 013 * 014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 020 * THE SOFTWARE. 021 */ 022package com.restfb; 023 024/** 025 * Interface for accessing the Facebook Endpoints. 026 * 027 * Facebook provides several endpoints that are used for working with the Graph API and working with Facebook in 028 * general. This interface provides methods to access the different urls. 029 * 030 * The default implementation is {@link FacebookEndpoints}. That class provides the access to Facebook and should 031 * be used in productive environments. 032 * 033 * This interface provides some fields with the default URLs so custom implementation can diretly use these or modify 034 * the url or provide a completly custom one. This is possible without extending our default implementation. 035 * 036 * In tests, a custom implementation can be used to mock the Facebook service. The implementing class only needs to 037 * provide urls to the mock service and the custom class is set in the {@link DefaultFacebookClient}. 038 */ 039public interface FacebookEndpoints { 040 041 /** 042 * returns the Facebook URL 043 * 044 * @return the Facebook URL 045 */ 046 default String getFacebookEndpoint() { 047 return Endpoint.SERVER.getUrl(); 048 } 049 050 /** 051 * returns the Facebook Graph API endpoint URL 052 * 053 * @return the Facebook Graph API endpoint URL 054 */ 055 default String getGraphEndpoint() { 056 return Endpoint.GRAPH.getUrl(); 057 } 058 059 /** 060 * returns the Facebook Graph API Video endpoint URL 061 * 062 * @return the Facebook Graph API Video endpoint URL 063 */ 064 default String getGraphVideoEndpoint() { 065 return Endpoint.GRAPH_VIDEO.getUrl(); 066 } 067 068 /** 069 * returns the Facebook Reel Upload endpoint URL 070 * 071 * @return the Facebook Reel Upload endpoint URL 072 */ 073 default String getReelUploadEndpoint() { 074 return Endpoint.RUPLOAD.getUrl(); 075 } 076 077 enum Endpoint { 078 /** 079 * General Facebook endpoint URL. 080 */ 081 SERVER("https://www.facebook.com"), 082 083 /** 084 * Graph API endpoint URL. 085 */ 086 GRAPH("https://graph.facebook.com"), 087 088 /** 089 * Video Upload API endpoint URL. 090 */ 091 GRAPH_VIDEO("https://graph-video.facebook.com"), 092 093 /** 094 * Reels Upload endpont URL. 095 */ 096 RUPLOAD("https://rupload.facebook.com/video-upload"); 097 098 private String url; 099 100 Endpoint(String url) { 101 this.url = url; 102 } 103 104 public String getUrl() { 105 return url; 106 } 107 } 108}