001/* 002 * Copyright (c) 2010-2021 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 DefaultFacebookEndpoints}. 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 enum Endpoint { 069 /** 070 * General Facebook endpoint URL. 071 */ 072 SERVER("https://www.facebook.com"), 073 074 /** 075 * Graph API endpoint URL. 076 */ 077 GRAPH("https://graph.facebook.com"), 078 079 /** 080 * Video Upload API endpoint URL. 081 */ 082 GRAPH_VIDEO("https://graph-video.facebook.com"); 083 084 private String url; 085 086 Endpoint(String url) { 087 this.url = url; 088 } 089 090 public String getUrl() { 091 return url; 092 } 093 } 094}