Module: MangoPay
- Defined in:
- lib/mangopay.rb,
lib/mangopay/environment.rb,
lib/mangopay/configuration.rb,
lib/mangopay/common/jsonifier.rb,
lib/mangopay/common/sort_field.rb,
lib/mangopay/common/log_provider.rb,
lib/mangopay/common/response_error.rb,
lib/mangopay/common/sort_direction.rb,
lib/mangopay/common/read_only_fields.rb,
lib/mangopay/common/json_tag_converter.rb,
lib/mangopay/common/rate_limit_interval.rb
Overview
Holds top-level configuration.
Defined Under Namespace
Modules: JsonTagConverter, Jsonifier, ReadOnlyFields Classes: Configuration, Environment, LogProvider, RateLimitInterval, ResponseError, SortDirection, SortField
Constant Summary collapse
- LOG =
LogProvider.provide(self)
- VERSION =
'4.1.0'.freeze
- SANDBOX_API_URL =
'https://api.sandbox.mangopay.com'.freeze
- MAIN_API_URL =
'https://api.mangopay.com'.freeze
Class Method Summary collapse
-
.configuration ⇒ Object
Provides MangoPay configuration object for current environment.
-
.configure {|config| ... } ⇒ Object
Allows configuration of the current MangoPay environment.
-
.environment ⇒ Object
Returns the environment currently being used.
-
.use_default ⇒ Object
Sets MangoPay to run under the default environment.
-
.use_environment(env_id) ⇒ Object
Allows to specify environment in which to run MangoPay operations.
Class Method Details
.configuration ⇒ Object
Provides MangoPay configuration object for current environment.
noinspection RubyResolve
100 101 102 103 104 |
# File 'lib/mangopay.rb', line 100 def configuration env = environment env.configuration || raise("MangoPay.configure() was not called for environment #{env.id}") end |
.configure {|config| ... } ⇒ Object
Allows configuration of the current MangoPay environment. Yields configuration object to a provided block.
noinspection RubyResolve
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/mangopay.rb', line 110 def configure env = environment LOG.info 'Configuring environment :{}', env.id config = env.configuration || MangoPay::Configuration.new yield config validate config LOG.info 'Successfully configured environment :{} for client {}', env.id, config.client_id env.configuration = config end |
.environment ⇒ Object
Returns the environment currently being used.
noinspection RubyResolve
52 53 54 |
# File 'lib/mangopay.rb', line 52 def environment @environments[thread_local_env_id] end |
.use_default ⇒ Object
Sets MangoPay to run under the default environment.
45 46 47 |
# File 'lib/mangopay.rb', line 45 def use_default use_environment :default end |
.use_environment(env_id) ⇒ Object
Allows to specify environment in which to run MangoPay operations. All subsequent threads will automatically run in that environment.
noinspection RubyResolve
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mangopay.rb', line 33 def use_environment(env_id) @global_env_id = env_id || :default unless @environments[@global_env_id] LOG.debug 'Creating new environment :{}', env_id env = MangoPay::Environment.new(@global_env_id) @environments[@global_env_id] = env end LOG.info 'Using environment :{}', env_id put_thread_local_environment end |