Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/Filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
| ---- | ---- | ----------- | ----- |
| **field** | **String** | Required. Name of the field to use as the first operand in the filter expression. | [optional] |
| **key** | **String** | If `field` is `tag`, this field is *required* to specify `key` inside the tags. | [optional] |
| **value** | **String** | Constant value to use as the second operand in the filter expression. This value is *required* when the relation operator is a binary operator. | [optional] |
| **value** | **String** | Constant value to use as the second operand in the filter expression. This value is *required* when the relation operator is a binary operator. For `in_array` and `not_in_array` relations, provide a comma-separated list of up to 20 values. | [optional] |
| **hours_ago** | **String** | If `field` is session-related, this is *required* to specify the number of hours before or after the user's session. | [optional] |
| **radius** | **Float** | If `field` is `location`, this will specify the radius in meters from a provided location point. Use with `lat` and `long`. | [optional] |
| **lat** | **Float** | If `field` is `location`, this is *required* to specify the user's latitude. | [optional] |
Expand Down
6 changes: 3 additions & 3 deletions lib/onesignal/models/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Filter
# If `field` is `tag`, this field is *required* to specify `key` inside the tags.
attr_accessor :key

# Constant value to use as the second operand in the filter expression. This value is *required* when the relation operator is a binary operator.
# Constant value to use as the second operand in the filter expression. This value is *required* when the relation operator is a binary operator. For `in_array` and `not_in_array` relations, provide a comma-separated list of up to 20 values.
attr_accessor :value

# If `field` is session-related, this is *required* to specify the number of hours before or after the user's session.
Expand Down Expand Up @@ -158,15 +158,15 @@ def list_invalid_properties
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
relation_validator = EnumAttributeValidator.new('String', [">", "<", "=", "!=", "exists", "not_exists", "time_elapsed_gt", "time_elapsed_lt"])
relation_validator = EnumAttributeValidator.new('String', [">", "<", "=", "!=", "exists", "not_exists", "time_elapsed_gt", "time_elapsed_lt", "in_array", "not_in_array"])
return false unless relation_validator.valid?(@relation)
true
end

# Custom attribute writer method checking allowed values (enum).
# @param [Object] relation Object to be assigned
def relation=(relation)
validator = EnumAttributeValidator.new('String', [">", "<", "=", "!=", "exists", "not_exists", "time_elapsed_gt", "time_elapsed_lt"])
validator = EnumAttributeValidator.new('String', [">", "<", "=", "!=", "exists", "not_exists", "time_elapsed_gt", "time_elapsed_lt", "in_array", "not_in_array"])
unless validator.valid?(relation)
fail ArgumentError, "invalid value for \"relation\", must be one of #{validator.allowable_values}."
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
describe 'test attribute "relation"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# validator = Petstore::EnumTest::EnumAttributeValidator.new('String', [">", "<", "=", "!=", "exists", "not_exists", "time_elapsed_gt", "time_elapsed_lt"])
# validator = Petstore::EnumTest::EnumAttributeValidator.new('String', [">", "<", "=", "!=", "exists", "not_exists", "time_elapsed_gt", "time_elapsed_lt", "in_array", "not_in_array"])
# validator.allowable_values.each do |value|
# expect { instance.relation = value }.not_to raise_error
# end
Expand Down