Class: Payoneer::Configuration::Config
- Inherits:
-
Object
- Object
- Payoneer::Configuration::Config
- Defined in:
- lib/payoneer/configuration.rb
Constant Summary collapse
- SANDBOX_API_URL =
'https://api.sandbox.payoneer.com/Payouts/HttpApi/API.aspx'
- PRODUCTION_API_URL =
'https://api.payoneer.com/Payouts/HttpApi/API.aspx'
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
-
#partner_api_password ⇒ Object
Returns the value of attribute partner_api_password.
-
#partner_id ⇒ Object
Returns the value of attribute partner_id.
-
#partner_username ⇒ Object
Returns the value of attribute partner_username.
-
#program_id ⇒ Object
Returns the value of attribute program_id.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#proxy_index ⇒ Object
Returns the value of attribute proxy_index.
Instance Method Summary collapse
- #api_url ⇒ Object
-
#initialize(options) ⇒ Config
constructor
A new instance of Config.
- #normalize_proxies ⇒ Object
- #production? ⇒ Boolean
- #rotate_proxy ⇒ Object
- #setup_proxy_if_set ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(options) ⇒ Config
Returns a new instance of Config.
27 28 29 30 31 32 |
# File 'lib/payoneer/configuration.rb', line 27 def initialize() .each do |key, value| send("#{key}=", value) end self.normalize_proxies end |
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
25 26 27 |
# File 'lib/payoneer/configuration.rb', line 25 def env @env end |
#partner_api_password ⇒ Object
Returns the value of attribute partner_api_password.
25 26 27 |
# File 'lib/payoneer/configuration.rb', line 25 def partner_api_password @partner_api_password end |
#partner_id ⇒ Object
Returns the value of attribute partner_id.
25 26 27 |
# File 'lib/payoneer/configuration.rb', line 25 def partner_id @partner_id end |
#partner_username ⇒ Object
Returns the value of attribute partner_username.
25 26 27 |
# File 'lib/payoneer/configuration.rb', line 25 def partner_username @partner_username end |
#program_id ⇒ Object
Returns the value of attribute program_id.
25 26 27 |
# File 'lib/payoneer/configuration.rb', line 25 def program_id @program_id end |
#proxy ⇒ Object
Returns the value of attribute proxy.
25 26 27 |
# File 'lib/payoneer/configuration.rb', line 25 def proxy @proxy end |
#proxy_index ⇒ Object
Returns the value of attribute proxy_index.
25 26 27 |
# File 'lib/payoneer/configuration.rb', line 25 def proxy_index @proxy_index end |
Instance Method Details
#api_url ⇒ Object
47 48 49 |
# File 'lib/payoneer/configuration.rb', line 47 def api_url production? ? PRODUCTION_API_URL : SANDBOX_API_URL end |
#normalize_proxies ⇒ Object
34 35 36 37 |
# File 'lib/payoneer/configuration.rb', line 34 def normalize_proxies self.proxy = self.proxy ? Array(proxy) : [] self.proxy_index = 0 end |
#production? ⇒ Boolean
43 44 45 |
# File 'lib/payoneer/configuration.rb', line 43 def production? self.env == 'production' end |
#rotate_proxy ⇒ Object
57 58 59 |
# File 'lib/payoneer/configuration.rb', line 57 def rotate_proxy self.proxy_index = (self.proxy_index + 1) % self.proxy.size end |
#setup_proxy_if_set ⇒ Object
51 52 53 54 55 |
# File 'lib/payoneer/configuration.rb', line 51 def setup_proxy_if_set return if self.proxy.size == 0 # TODO New in 2.0: Specify a per-request proxy https://github.com/rest-client/rest-client#proxy RestClient.proxy = self.proxy[self.proxy_index] end |
#validate! ⇒ Object
39 40 41 |
# File 'lib/payoneer/configuration.rb', line 39 def validate! raise ConfigurationError.new unless %w(partner_username partner_api_password partner_id program_id env).all?{|k| self.send(k).present? } end |