Class: Karaden::RequestOptions
- Inherits:
-
Object
- Object
- Karaden::RequestOptions
- Defined in:
- lib/cpaas_test_ruby/request_options.rb
Instance Attribute Summary collapse
-
#api_base ⇒ Object
Returns the value of attribute api_base.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#connection_timeout ⇒ Object
Returns the value of attribute connection_timeout.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#tenant_id ⇒ Object
Returns the value of attribute tenant_id.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Class Method Summary collapse
Instance Method Summary collapse
- #base_uri ⇒ Object
-
#initialize ⇒ RequestOptions
constructor
A new instance of RequestOptions.
- #merge(source) ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize ⇒ RequestOptions
Returns a new instance of RequestOptions.
5 6 7 8 9 10 11 12 13 |
# File 'lib/cpaas_test_ruby/request_options.rb', line 5 def initialize @api_base = nil @api_key = nil @api_version = nil @tenant_id = nil @user_agent = nil @connection_timeout = nil @read_timeout = nil end |
Instance Attribute Details
#api_base ⇒ Object
Returns the value of attribute api_base.
3 4 5 |
# File 'lib/cpaas_test_ruby/request_options.rb', line 3 def api_base @api_base end |
#api_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/cpaas_test_ruby/request_options.rb', line 3 def api_key @api_key end |
#api_version ⇒ Object
Returns the value of attribute api_version.
3 4 5 |
# File 'lib/cpaas_test_ruby/request_options.rb', line 3 def api_version @api_version end |
#connection_timeout ⇒ Object
Returns the value of attribute connection_timeout.
3 4 5 |
# File 'lib/cpaas_test_ruby/request_options.rb', line 3 def connection_timeout @connection_timeout end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
3 4 5 |
# File 'lib/cpaas_test_ruby/request_options.rb', line 3 def read_timeout @read_timeout end |
#tenant_id ⇒ Object
Returns the value of attribute tenant_id.
3 4 5 |
# File 'lib/cpaas_test_ruby/request_options.rb', line 3 def tenant_id @tenant_id end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
3 4 5 |
# File 'lib/cpaas_test_ruby/request_options.rb', line 3 def user_agent @user_agent end |
Class Method Details
.new_builder ⇒ Object
55 56 57 |
# File 'lib/cpaas_test_ruby/request_options.rb', line 55 def self.new_builder RequestOptionsBuilder.new end |
Instance Method Details
#base_uri ⇒ Object
15 16 17 |
# File 'lib/cpaas_test_ruby/request_options.rb', line 15 def base_uri "#{@api_base}/#{@tenant_id}" end |
#merge(source) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/cpaas_test_ruby/request_options.rb', line 19 def merge(source) clone.tap do |obj| i[api_base api_key api_version tenant_id user_agent].each do |prop| val = source.send(prop) obj.send("#{prop}=", val) unless val.nil? end end end |
#validate ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cpaas_test_ruby/request_options.rb', line 28 def validate errors = Karaden::Model::KaradenObject.new = validate_api_base errors.set_property('api_base', ) unless .empty? = validate_api_key errors.set_property('api_key', ) unless .empty? = validate_api_version errors.set_property('api_version', ) unless .empty? = validate_tenant_id errors.set_property('tenant_id', ) unless .empty? unless errors.property_keys.filter { |key| !errors.property(key).nil? }.empty? e = Karaden::Exception::InvalidRequestOptionsException.new error = Karaden::Model::Error.new error.set_property('object', Karaden::Model::Error::OBJECT_NAME) error.set_property('errors', errors) e.error = error raise e end self end |