public void CreateClientWithIdSecretCtor() { GfycatClient client = new GfycatClient(ClientId, ClientSecret); Assert.Equal(ClientId, client.ClientId); Assert.Equal(ClientSecret, client.ClientSecret); }
public void CreateClientWithConfigCtor() { GfycatClientConfig clientConfig = new GfycatClientConfig(ClientId, ClientSecret); GfycatClient client = new GfycatClient(clientConfig); Assert.Equal(ClientId, client.ClientId); Assert.Equal(ClientSecret, client.ClientSecret); }
public void CreateClientWithDefaultConfig() { GfycatClientConfig clientConfig = new GfycatClientConfig(ClientId, ClientSecret); GfycatClient client = new GfycatClient(clientConfig); Assert.Equal(client.ApiClient.Config.DefaultRetryMode, RetryMode.RetryFirst401); Assert.Equal(client.ApiClient.Config.DefaultTimeout, -1); Assert.Equal(client.ApiClient.Config.RestClient.GetType(), typeof(Rest.DefaultRestClient)); }
public GfycatConversionService(ConfigModel config, LoggingService loggingService, DiscordSocketClient discordClient, ICoreRepository coreSettings) { if (string.IsNullOrWhiteSpace(config.Credentials.Gfycat.ClientId) || string.IsNullOrWhiteSpace(config.Credentials.Gfycat.Secret)) { throw new ArgumentNullException(nameof(config)); } _loggingService = loggingService; _coreSettings = coreSettings; discordClient.MessageReceived += FileUploadHandlerAsync; _gfycatClient = new GfycatClient(config.Credentials.Gfycat.ClientId, config.Credentials.Gfycat.Secret); }
public void CreateClientWithModifiedConfig() { GfycatClientConfig clientConfig = new GfycatClientConfig(ClientId, ClientSecret) { DefaultRetryMode = RetryMode.AlwaysRetry, DefaultTimeout = 3000, RestClient = new MockRestClient(new Uri(GfycatClientConfig.BaseUrl)) }; GfycatClient client = new GfycatClient(clientConfig); Assert.Equal(client.ApiClient.Config.DefaultRetryMode, RetryMode.AlwaysRetry); Assert.Equal(client.ApiClient.Config.DefaultTimeout, 3000); Assert.Equal(client.ApiClient.Config.RestClient.GetType(), typeof(MockRestClient)); }
public void CreateClientWithModifiedConfig() { GfycatClientConfig clientConfig = new GfycatClientConfig(ClientId, ClientSecret) { DefaultRetryMode = RetryMode.AlwaysRetry, DefaultTimeout = 3000, RestClient = new MockMessageClient(new MockHttpMessageHandler()) }; GfycatClient client = new GfycatClient(clientConfig); Assert.Equal(RetryMode.AlwaysRetry, client.ApiClient.Config.DefaultRetryMode); Assert.Equal(3000, client.ApiClient.Config.DefaultTimeout); Assert.Equal(typeof(MockMessageClient), client.ApiClient.Config.RestClient.GetType()); }
internal GfycatApiClient(GfycatClient client, GfycatClientConfig config) { Client = client; Config = config; }
public async void PasswordGrant() { var mockHttp = new MockHttpMessageHandler(); mockHttp.When(HttpMethod.Post, "https://api.gfycat.com/v1/oauth/token") .WithJsonContent( new { grant_type = "password", client_id, client_secret, username, password }) .Respond( new { token_type = "bearer", refresh_token_expires_in = 5184000, refresh_token, scope = "", resource_owner = username, expires_in = 3600, access_token }); mockHttp.When(HttpMethod.Get, "https://api.gfycat.com/v1/me") .WithHeaders("Authorization: Bearer " + access_token) .Respond( new { userid = "", username, email = "*****@*****.**", description = "description", profileUrl = "https://github.com/username", name = "username", views = 9001, uploadNotices = true, emailVerified = true, url = "https://gfycat.com/@username", createDate = 0, profileImageUrl = "http://cdn.edgecast.steamstatic.com/steamcommunity/public/images/avatars/c9/c9c3bbe7ffb21f9b0ae54c1d48c8a42257b7b621_full.jpg", verified = true, followers = 0, following = 1, geoWhitelist = new[] { "us" }, domainWhitelist = new[] { "reddit.com" }, associatedProviders = new[] { "facebook" }, iframeProfileImageVisible = true }); var config = new GfycatClientConfig(client_id, client_secret) { RestClient = new MockMessageClient(mockHttp) }; var client = new GfycatClient(config); await client.AuthenticateAsync(username, password); Assert.Equal(access_token, client.AccessToken); Assert.Equal(refresh_token, client.RefreshToken); Assert.Equal(username, client.CurrentUser.Username); }
public GfyModule(PaginationService paginationService, GfycatClientConfig configService) { paginator = paginationService; gfyClient = new GfycatClient(configService); }