Class: Courier::Audiences::NestedFilterConfig
- Inherits:
-
Object
- Object
- Courier::Audiences::NestedFilterConfig
- Defined in:
- lib/trycourier/audiences/types/nested_filter_config.rb
Overview
The operator to use for filtering
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Audiences::NestedFilterConfig
Deserialize a JSON object to an instance of NestedFilterConfig.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(rules:, operator:, additional_properties: nil) ⇒ Audiences::NestedFilterConfig constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of NestedFilterConfig to a JSON object.
Constructor Details
#initialize(rules:, operator:, additional_properties: nil) ⇒ Audiences::NestedFilterConfig
17 18 19 20 21 22 23 24 |
# File 'lib/trycourier/audiences/types/nested_filter_config.rb', line 17 def initialize(rules:, operator:, additional_properties: nil) # @type [Array<Audiences::FilterConfig>] @rules = rules # @type [Audiences::Operator] The operator to use for filtering @operator = operator # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
11 12 13 |
# File 'lib/trycourier/audiences/types/nested_filter_config.rb', line 11 def additional_properties @additional_properties end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
11 12 13 |
# File 'lib/trycourier/audiences/types/nested_filter_config.rb', line 11 def operator @operator end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
11 12 13 |
# File 'lib/trycourier/audiences/types/nested_filter_config.rb', line 11 def rules @rules end |
Class Method Details
.from_json(json_object:) ⇒ Audiences::NestedFilterConfig
Deserialize a JSON object to an instance of NestedFilterConfig
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/trycourier/audiences/types/nested_filter_config.rb', line 30 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) rules = parsed_json["rules"]&.map do |v| v = v.to_json Audiences::FilterConfig.from_json(json_object: v) end if parsed_json["operator"].nil? operator = nil else operator = parsed_json["operator"].to_json operator = Audiences::Operator.from_json(json_object: operator) end new(rules: rules, operator: operator, additional_properties: struct) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
57 58 59 60 |
# File 'lib/trycourier/audiences/types/nested_filter_config.rb', line 57 def self.validate_raw(obj:) obj.rules.is_a?(Array) != false || raise("Passed value for field obj.rules is not the expected type, validation failed.") Audiences::Operator.validate_raw(obj: obj.operator) end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of NestedFilterConfig to a JSON object
49 50 51 |
# File 'lib/trycourier/audiences/types/nested_filter_config.rb', line 49 def to_json(*_args) { "rules": @rules, "operator": @operator }.to_json end |