/// <summary> /// Creates the client using builder. /// </summary> /// <returns> SquareClient.</returns> internal static SquareClient CreateFromEnvironment() { var builder = new Builder(); string squareVersion = System.Environment.GetEnvironmentVariable("SQUARE_SQUARE_VERSION"); string environment = System.Environment.GetEnvironmentVariable("SQUARE_ENVIRONMENT"); string customUrl = System.Environment.GetEnvironmentVariable("SQUARE_CUSTOM_URL"); string accessToken = System.Environment.GetEnvironmentVariable("SQUARE_ACCESS_TOKEN"); if (squareVersion != null) { builder.SquareVersion(squareVersion); } if (environment != null) { builder.Environment(ApiHelper.JsonDeserialize <Environment>($"\"{environment}\"")); } if (customUrl != null) { builder.CustomUrl(customUrl); } if (accessToken != null) { builder.AccessToken(accessToken); } return(builder.Build()); }
internal static SquareClient CreateFromEnvironment() { var builder = new Builder(); string timeout = System.Environment.GetEnvironmentVariable("SQUARE_TIMEOUT"); string squareVersion = System.Environment.GetEnvironmentVariable("SQUARE_SQUARE_VERSION"); string accessToken = System.Environment.GetEnvironmentVariable("SQUARE_ACCESS_TOKEN"); string environment = System.Environment.GetEnvironmentVariable("SQUARE_ENVIRONMENT"); if (timeout != null) { builder.Timeout(TimeSpan.Parse(timeout)); } if (squareVersion != null) { builder.SquareVersion(squareVersion); } if (accessToken != null) { builder.AccessToken(accessToken); } if (environment != null) { builder.Environment(EnvironmentHelper.ParseString(environment)); } return(builder.Build()); }
public Builder ToBuilder() { Builder builder = new Builder(); builder.Timeout(Timeout); builder.AccessToken(AccessToken); builder.Environment(Environment); builder.AdditionalHeaders(additionalHeaders); builder.HttpCallBack(httpCallBack); builder.HttpClient(httpClient); builder.AuthManagers(authManagers); return(builder); }