Class: Yandex360::AntispamResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/yandex360/resources/antispam.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Yandex360::Resource

Instance Method Details

#create(org_id, *strings) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/yandex360/resources/antispam.rb', line 10

def create(org_id, *strings)
  validate_required_params({org_id: org_id}, [:org_id])
  raise ArgumentError, "At least one IP address must be provided" if strings.empty?

  # Filter out empty strings
  valid_strings = strings.compact.reject {|s| s.to_s.strip.empty? }
  raise ArgumentError, "At least one valid IP address must be provided" if valid_strings.empty?

  body = {allowList: valid_strings}
  AllowList.new post("/admin/v1/org/#{org_id}/mail/antispam/allowlist/ips", body: body).body
end

#delete(org_id:) ⇒ Object



22
23
24
25
# File 'lib/yandex360/resources/antispam.rb', line 22

def delete(org_id:)
  validate_required_params({org_id: org_id}, [:org_id])
  delete_request("/admin/v1/org/#{org_id}/mail/antispam/allowlist/ips")
end

#list(org_id:) ⇒ Object



5
6
7
8
# File 'lib/yandex360/resources/antispam.rb', line 5

def list(org_id:)
  validate_required_params({org_id: org_id}, [:org_id])
  AllowList.new get("/admin/v1/org/#{org_id}/mail/antispam/allowlist/ips").body
end