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 ⇒ Object
-
#get_value ⇒ Object
The getter for the parameter’s actual/converted value where applicable.
-
#initialize ⇒ Parameter
constructor
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) ⇒ Object
Template 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
Returns a new instance of Parameter.
4 5 6 7 8 9 10 11 12 |
# File 'lib/apimatic-core/types/parameter.rb', line 4 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.
79 80 81 82 |
# File 'lib/apimatic-core/types/parameter.rb', line 79 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.
86 87 88 |
# File 'lib/apimatic-core/types/parameter.rb', line 86 def get_default_content_type @default_content_type end |
#get_key ⇒ String
The getter for the parameter key.
24 25 26 |
# File 'lib/apimatic-core/types/parameter.rb', line 24 def get_key @key end |
#get_template ⇒ Object
96 97 98 |
# File 'lib/apimatic-core/types/parameter.rb', line 96 def get_template @template end |
#get_value ⇒ Object
The getter for the parameter’s actual/converted value where applicable.
38 39 40 41 42 |
# File 'lib/apimatic-core/types/parameter.rb', line 38 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
48 49 50 51 |
# File 'lib/apimatic-core/types/parameter.rb', line 48 def is_required(is_required) @is_required = is_required self end |
#key(key) ⇒ Parameter
The setter for the parameter key.
17 18 19 20 |
# File 'lib/apimatic-core/types/parameter.rb', line 17 def key(key) @key = key self end |
#need_to_encode ⇒ Boolean
The getter for the flag if the parameter value is to be encoded.
72 73 74 |
# File 'lib/apimatic-core/types/parameter.rb', line 72 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.
57 58 59 60 |
# File 'lib/apimatic-core/types/parameter.rb', line 57 def should_encode(should_encode) @should_encode = should_encode self end |
#template(template) ⇒ Object
Template in case of oneOf or anyOf
91 92 93 94 |
# File 'lib/apimatic-core/types/parameter.rb', line 91 def template(template) @template = template self end |
#validate ⇒ Object
Validates the parameter value to be sent in the request.
102 103 104 |
# File 'lib/apimatic-core/types/parameter.rb', line 102 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
111 112 113 |
# File 'lib/apimatic-core/types/parameter.rb', line 111 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.
31 32 33 34 |
# File 'lib/apimatic-core/types/parameter.rb', line 31 def value(value) @value = value self end |
#value_convertor(value_convertor) ⇒ Parameter
The setter for the function of converting value for form params.
65 66 67 68 |
# File 'lib/apimatic-core/types/parameter.rb', line 65 def value_convertor(value_convertor) @value_convertor = value_convertor self end |