Class: CoreLibrary::Parameter
- Inherits:
-
Object
- Object
- CoreLibrary::Parameter
- Defined in:
- lib/apimatic-core/types/parameter.rb
Overview
This data class represents the parameter to be sent in the request.
Instance Method Summary collapse
-
#default_content_type(default_content_type) ⇒ Parameter
The setter for the default content type of the multipart request.
-
#get_default_content_type ⇒ String
The getter for the default content type of the multipart request.
-
#get_key ⇒ String
The getter for the parameter key.
-
#get_template ⇒ Parameter
Template getter in case a template is set.
-
#get_value ⇒ Object
The getter for the parameter’s actual/converted value where applicable.
-
#initialize ⇒ Parameter
constructor
Initializes a new instance of Parameter.
-
#is_required(is_required) ⇒ Parameter
The setter for the flag if the parameter is required.
-
#key(key) ⇒ Parameter
The setter for the parameter key.
-
#need_to_encode ⇒ Boolean
The getter for the flag if the parameter value is to be encoded.
-
#should_encode(should_encode) ⇒ Parameter
The setter for the flag if the parameter value is to be encoded.
-
#template(template) ⇒ Parameter
Template setter in case of oneOf or anyOf.
-
#validate ⇒ Object
Validates the parameter value to be sent in the request.
-
#validate_template(sdk_module, should_symbolize_hash = false) ⇒ Object
Validates the oneOf/anyOf parameter value to be sent in the request.
-
#value(value) ⇒ Parameter
The setter for the parameter value.
-
#value_convertor(value_convertor) ⇒ Parameter
The setter for the function of converting value for form params.
Constructor Details
#initialize ⇒ Parameter
Initializes a new instance of Parameter.
5 6 7 8 9 10 11 12 13 |
# File 'lib/apimatic-core/types/parameter.rb', line 5 def initialize @key = nil @value = nil @is_required = false @should_encode = false @default_content_type = nil @value_convertor = nil @template = nil end |
Instance Method Details
#default_content_type(default_content_type) ⇒ Parameter
The setter for the default content type of the multipart request.
80 81 82 83 |
# File 'lib/apimatic-core/types/parameter.rb', line 80 def default_content_type(default_content_type) @default_content_type = default_content_type self end |
#get_default_content_type ⇒ String
The getter for the default content type of the multipart request.
87 88 89 |
# File 'lib/apimatic-core/types/parameter.rb', line 87 def get_default_content_type @default_content_type end |
#get_key ⇒ String
The getter for the parameter key.
25 26 27 |
# File 'lib/apimatic-core/types/parameter.rb', line 25 def get_key @key end |
#get_template ⇒ Parameter
Template getter in case a template is set.
101 102 103 |
# File 'lib/apimatic-core/types/parameter.rb', line 101 def get_template @template end |
#get_value ⇒ Object
The getter for the parameter’s actual/converted value where applicable.
39 40 41 42 43 |
# File 'lib/apimatic-core/types/parameter.rb', line 39 def get_value return @value_convertor.call(@value) unless @value_convertor.nil? @value end |
#is_required(is_required) ⇒ Parameter
The setter for the flag if the parameter is required. rubocop:disable Naming/PredicateName
49 50 51 52 |
# File 'lib/apimatic-core/types/parameter.rb', line 49 def is_required(is_required) @is_required = is_required self end |
#key(key) ⇒ Parameter
The setter for the parameter key.
18 19 20 21 |
# File 'lib/apimatic-core/types/parameter.rb', line 18 def key(key) @key = key self end |
#need_to_encode ⇒ Boolean
The getter for the flag if the parameter value is to be encoded.
73 74 75 |
# File 'lib/apimatic-core/types/parameter.rb', line 73 def need_to_encode @should_encode end |
#should_encode(should_encode) ⇒ Parameter
The setter for the flag if the parameter value is to be encoded.
58 59 60 61 |
# File 'lib/apimatic-core/types/parameter.rb', line 58 def should_encode(should_encode) @should_encode = should_encode self end |
#template(template) ⇒ Parameter
Template setter in case of oneOf or anyOf.
94 95 96 97 |
# File 'lib/apimatic-core/types/parameter.rb', line 94 def template(template) @template = template self end |
#validate ⇒ Object
Validates the parameter value to be sent in the request.
107 108 109 |
# File 'lib/apimatic-core/types/parameter.rb', line 107 def validate raise ArgumentError, "Required parameter #{@key} cannot be nil." if @is_required && @value.nil? end |
#validate_template(sdk_module, should_symbolize_hash = false) ⇒ Object
Validates the oneOf/anyOf parameter value to be sent in the request. rubocop:disable Style/OptionalBooleanParameter
116 117 118 |
# File 'lib/apimatic-core/types/parameter.rb', line 116 def validate_template(sdk_module, should_symbolize_hash = false) ApiHelper.validate_types(@value, @template, sdk_module, should_symbolize_hash) unless @value.nil? end |
#value(value) ⇒ Parameter
The setter for the parameter value.
32 33 34 35 |
# File 'lib/apimatic-core/types/parameter.rb', line 32 def value(value) @value = value self end |
#value_convertor(value_convertor) ⇒ Parameter
The setter for the function of converting value for form params.
66 67 68 69 |
# File 'lib/apimatic-core/types/parameter.rb', line 66 def value_convertor(value_convertor) @value_convertor = value_convertor self end |