Class: Courier::Audiences::SingleFilterConfig
- Inherits:
-
Object
- Object
- Courier::Audiences::SingleFilterConfig
- Defined in:
- lib/trycourier/audiences/types/single_filter_config.rb
Overview
A single filter 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.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Audiences::SingleFilterConfig
Deserialize a JSON object to an instance of SingleFilterConfig.
-
.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(value:, path:, operator:, additional_properties: nil) ⇒ Audiences::SingleFilterConfig constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of SingleFilterConfig to a JSON object.
Constructor Details
#initialize(value:, path:, operator:, additional_properties: nil) ⇒ Audiences::SingleFilterConfig
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/trycourier/audiences/types/single_filter_config.rb', line 17 def initialize(value:, path:, operator:, additional_properties: nil) # @type [String] The value to use for filtering @value = value # @type [String] The attribe name from profile whose value will be operated against the filter value @path = path # @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.
10 11 12 |
# File 'lib/trycourier/audiences/types/single_filter_config.rb', line 10 def additional_properties @additional_properties end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
10 11 12 |
# File 'lib/trycourier/audiences/types/single_filter_config.rb', line 10 def operator @operator end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/trycourier/audiences/types/single_filter_config.rb', line 10 def path @path end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/trycourier/audiences/types/single_filter_config.rb', line 10 def value @value end |
Class Method Details
.from_json(json_object:) ⇒ Audiences::SingleFilterConfig
Deserialize a JSON object to an instance of SingleFilterConfig
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/trycourier/audiences/types/single_filter_config.rb', line 32 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) value = struct.value path = struct.path if parsed_json["operator"].nil? operator = nil else operator = parsed_json["operator"].to_json operator = Audiences::Operator.from_json(json_object: operator) end new(value: value, path: path, 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 61 |
# File 'lib/trycourier/audiences/types/single_filter_config.rb', line 57 def self.validate_raw(obj:) obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") obj.path.is_a?(String) != false || raise("Passed value for field obj.path 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 SingleFilterConfig to a JSON object
49 50 51 |
# File 'lib/trycourier/audiences/types/single_filter_config.rb', line 49 def to_json(*_args) { "value": @value, "path": @path, "operator": @operator }.to_json end |