lib/braintree/configuration.rb in braintree-4.15.0 vs lib/braintree/configuration.rb in braintree-4.16.0
- old
+ new
@@ -1,10 +1,11 @@
module Braintree
class Configuration
- API_VERSION = "6" # :nodoc:
- DEFAULT_ENDPOINT = "api" # :nodoc:
- GRAPHQL_API_VERSION = "2018-09-10" # :nodoc:
+ API_VERSION = "6"
+ DEFAULT_ENDPOINT = "api"
+ # NEXT_MAJOR_VERSION update to the latest version of GraphQL API
+ GRAPHQL_API_VERSION = "2018-09-10"
READABLE_ATTRIBUTES = [
:merchant_id,
:public_key,
:private_key,
@@ -45,35 +46,34 @@
end
attr_reader(*READABLE_ATTRIBUTES)
attr_reader(*NON_REQUIRED_READABLE_ATTRIBUTES)
attr_writer(*WRITABLE_ATTRIBUTES)
- def self.expectant_reader(*attributes) # :nodoc:
+ def self.expectant_reader(*attributes)
attributes.each do |attribute|
(class << self; self; end).send(:define_method, attribute) do
attribute_value = instance_variable_get("@#{attribute}")
- raise ConfigurationError.new("Braintree::Configuration.#{attribute.to_s} needs to be set") if attribute_value.nil? || attribute_value.to_s.empty?
+ raise ConfigurationError.new("Braintree::Configuration.#{attribute} needs to be set") if attribute_value.nil? || attribute_value.to_s.empty?
attribute_value
end
end
end
expectant_reader(*READABLE_ATTRIBUTES)
- # Sets the Braintree environment to use. Valid values are <tt>:sandbox</tt> and <tt>:production</tt>
def self.environment=(env)
env = env.to_sym
unless [:development, :qa, :sandbox, :production].include?(env)
raise ArgumentError, "#{env.inspect} is not a valid environment"
end
@environment = env
end
- def self.gateway # :nodoc:
+ def self.gateway
Braintree::Gateway.new(instantiate)
end
- def self.instantiate # :nodoc:
+ def self.instantiate
config = new(
:custom_user_agent => @custom_user_agent,
:endpoint => @endpoint,
:environment => environment,
:http_open_timeout => http_open_timeout,
@@ -156,19 +156,19 @@
if options_environment && options_environment.to_sym != token_environment.to_sym
warn "Braintree::Gateway should not be initialized with mixed environments: environment parameter and access_token do not match, environment from access_token is used."
end
end
- def api_version # :nodoc:
+ def api_version
API_VERSION
end
- def graphql_api_version # :nodoc:
+ def graphql_api_version
GRAPHQL_API_VERSION
end
- def base_merchant_path # :nodoc:
+ def base_merchant_path
"/merchants/#{merchant_id}"
end
def base_url
"#{protocol}://#{server}:#{port}"
@@ -176,23 +176,23 @@
def graphql_base_url
"#{protocol}://#{graphql_server}:#{graphql_port}/graphql"
end
- def base_merchant_url # :nodoc:
+ def base_merchant_url
"#{base_url}#{base_merchant_path}"
end
- def ca_file # :nodoc:
+ def ca_file
File.expand_path(File.join(File.dirname(__FILE__), "..", "ssl", "api_braintreegateway_com.ca.crt"))
end
def endpoint
@endpoint || DEFAULT_ENDPOINT
end
- def http # :nodoc:
+ def http
Http.new(self)
end
def graphql_client
GraphQLClient.new(self)
@@ -200,29 +200,29 @@
def logger
@logger ||= self.class._default_logger
end
- def port # :nodoc:
+ def port
case @environment
when :development, :integration
ENV["GATEWAY_PORT"] || 3000
when :production, :qa, :sandbox
443
end
end
- def graphql_port # :nodoc:
+ def graphql_port
case @environment
when :development, :integration
ENV["GRAPHQL_PORT"] || 8080
when :production, :qa, :sandbox
443
end
end
- def protocol # :nodoc:
+ def protocol
ssl? ? "https" : "http"
end
def http_open_timeout
@http_open_timeout
@@ -230,11 +230,11 @@
def http_read_timeout
@http_read_timeout
end
- def server # :nodoc:
+ def server
case @environment
when :development, :integration
ENV["GATEWAY_HOST"] || "localhost"
when :production
"#{endpoint}.braintreegateway.com"
@@ -243,11 +243,11 @@
when :sandbox
"api.sandbox.braintreegateway.com"
end
end
- def graphql_server # :nodoc:
+ def graphql_server
case @environment
when :development, :integration
ENV["GRAPHQL_HOST"] || "graphql.bt.local"
when :production
"payments.braintree-api.com"
@@ -269,24 +269,24 @@
when :sandbox
"https://auth.venmo.sandbox.braintreegateway.com"
end
end
- def ssl? # :nodoc:
+ def ssl?
case @environment
when :development, :integration
false
when :production, :qa, :sandbox
true
end
end
- def user_agent # :nodoc:
+ def user_agent
base_user_agent = "Braintree Ruby Gem #{Braintree::Version::String}"
@custom_user_agent ? "#{base_user_agent} (#{@custom_user_agent})" : base_user_agent
end
- def self._default_logger # :nodoc:
+ def self._default_logger
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
logger
end