Class: OpenPayU::Configuration
- Inherits:
-
Object
- Object
- OpenPayU::Configuration
- Includes:
- Singleton
- Defined in:
- lib/openpayu/configuration.rb
Class Attribute Summary collapse
-
.algorithm ⇒ Object
Returns the value of attribute algorithm.
-
.client_id ⇒ Object
Returns the value of attribute client_id.
-
.client_secret ⇒ Object
Returns the value of attribute client_secret.
-
.continue_url ⇒ Object
Returns the value of attribute continue_url.
-
.country ⇒ Object
Returns the value of attribute country.
-
.data_format ⇒ Object
Returns the value of attribute data_format.
-
.env ⇒ Object
Returns the value of attribute env.
-
.merchant_pos_id ⇒ Object
Returns the value of attribute merchant_pos_id.
-
.notify_url ⇒ Object
Returns the value of attribute notify_url.
-
.order_url ⇒ Object
Returns the value of attribute order_url.
-
.pos_auth_key ⇒ Object
Returns the value of attribute pos_auth_key.
-
.protocol ⇒ Object
Returns the value of attribute protocol.
-
.service_domain ⇒ Object
Returns the value of attribute service_domain.
-
.signature_key ⇒ Object
Returns the value of attribute signature_key.
Class Method Summary collapse
- .configure(file_path = nil) ⇒ Object
- .get_base_url ⇒ Object
- .required_parameters ⇒ Object
- .set_defaults ⇒ Object
- .use_ssl? ⇒ Boolean
- .valid? ⇒ Boolean
Class Attribute Details
.algorithm ⇒ Object
Returns the value of attribute algorithm.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def algorithm @algorithm end |
.client_id ⇒ Object
Returns the value of attribute client_id.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def client_id @client_id end |
.client_secret ⇒ Object
Returns the value of attribute client_secret.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def client_secret @client_secret end |
.continue_url ⇒ Object
Returns the value of attribute continue_url.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def continue_url @continue_url end |
.country ⇒ Object
Returns the value of attribute country.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def country @country end |
.data_format ⇒ Object
Returns the value of attribute data_format.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def data_format @data_format end |
.env ⇒ Object
Returns the value of attribute env.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def env @env end |
.merchant_pos_id ⇒ Object
Returns the value of attribute merchant_pos_id.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def merchant_pos_id @merchant_pos_id end |
.notify_url ⇒ Object
Returns the value of attribute notify_url.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def notify_url @notify_url end |
.order_url ⇒ Object
Returns the value of attribute order_url.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def order_url @order_url end |
.pos_auth_key ⇒ Object
Returns the value of attribute pos_auth_key.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def pos_auth_key @pos_auth_key end |
.protocol ⇒ Object
Returns the value of attribute protocol.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def protocol @protocol end |
.service_domain ⇒ Object
Returns the value of attribute service_domain.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def service_domain @service_domain end |
.signature_key ⇒ Object
Returns the value of attribute signature_key.
11 12 13 |
# File 'lib/openpayu/configuration.rb', line 11 def signature_key @signature_key end |
Class Method Details
.configure(file_path = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/openpayu/configuration.rb', line 15 def configure(file_path = nil) set_defaults if block_given? yield self else file = File.open(file_path) if file_path && File.exists?(file_path) env = defined?(Rails) ? Rails.env : ENV['RACK_ENV'] config = YAML.load(file)[env] if config.present? config.each_pair do |key, value| send("#{key}=", value) end end end valid? end |
.get_base_url ⇒ Object
53 54 55 |
# File 'lib/openpayu/configuration.rb', line 53 def get_base_url "#{@protocol}://#{@env}.#{@service_domain}/api/v2/" end |
.required_parameters ⇒ Object
40 41 42 |
# File 'lib/openpayu/configuration.rb', line 40 def required_parameters [:merchant_pos_id, :signature_key] end |
.set_defaults ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/openpayu/configuration.rb', line 32 def set_defaults @service_domain = 'payu.com' @env = 'sandbox' @country = 'pl' @algorithm = 'MD5' @data_format = 'json' end |
.use_ssl? ⇒ Boolean
57 58 59 |
# File 'lib/openpayu/configuration.rb', line 57 def use_ssl? @protocol == 'https' end |
.valid? ⇒ Boolean
44 45 46 47 48 49 50 51 |
# File 'lib/openpayu/configuration.rb', line 44 def valid? required_parameters.each do |parameter| if send(parameter).nil? || send(parameter).blank? raise WrongConfigurationError, "Parameter #{parameter} is invalid." end end true end |