/// <summary> /// Create a composed interface, containing a collection of the more fine-grained /// LevelUp client interfaces. /// </summary> /// <typeparam name="T">The type of composed interface to generate.</typeparam> /// <param name="identifier">An object that retains data about the caller /// (company name, etc.) as an informational and diagnostic tool for the /// LevelUp backend.</param> /// <param name="enviornment">The target enviornment (sandbox, production, etc.)</param> /// <returns>The LevelUp client interface of the specified type T.</returns> public static T CreateComposedInterface <T>(AgentIdentifier identifier, LevelUpEnvironment enviornment) where T : IComposedInterface { IRestfulService httpRestService = new LevelUpHttpRestfulService(); var client = new LevelUpClient(GetDefaultLevelUpRequestEngine(identifier, enviornment, httpRestService)); return((T)(object)client); }
/// <summary> /// Create a LevelUp client interface with a set timeout value /// </summary> /// <typeparam name="T">The type of LevelUp client interface to generate.</typeparam> /// <param name="identifier">An object that retains data about the caller /// (company name, etc.) as an informational and diagnostic tool for the /// LevelUp backend.</param> /// <param name="enviornment">The target enviornment (sandbox, production, etc.)</param> /// <param name="timeoutInMs">Time out value in milliseconds</param> /// <returns>The LevelUp client interface of the specified type T.</returns> public static T Create <T>(AgentIdentifier identifier, LevelUpEnvironment enviornment, int timeoutInMs) where T : ILevelUpClientModule { IRestfulService httpRestService = new LevelUpHttpRestfulService(timeoutInMs); var client = new LevelUpClient(httpRestService, identifier, enviornment); return((T)(object)client); }
public void PutShouldSucceed() { var service = new LevelUpHttpRestfulService((url, request, userAgent) => { CheckUrlAndAgent(url, MyUrl, userAgent, UAgent); CheckHeaders(request, Method.PUT, AccessTokenHeader); return(new RestResponse()); }); service.Put(MyUrl, Body, AccessTokenHeader, UAgent); }
public void GetShouldNotHaveAnIssueWithNullParams() { var service = new LevelUpHttpRestfulService((url, request, userAgent) => { CheckUrlAndAgent(url, null, userAgent, null); Assert.AreEqual(request.Method, Method.GET); Assert.AreEqual(request.Parameters.Count(x => x.Name == "Authorization"), 0); return(new RestResponse()); }); service.Get(null, null, null); }
public void PostShouldSucceed() { var service = new LevelUpHttpRestfulService((url, request, userAgent) => { CheckUrlAndAgent(url, MyUrl, userAgent, UAgent); CheckHeaders(request, Method.POST, AccessTokenHeader); Assert.AreEqual(request.Parameters.First(x => x.Name == "application/json").Value, Body); return(new RestResponse()); }); service.Post(MyUrl, Body, AccessTokenHeader, UAgent); }