Module: Crowdin::ApiResources::Notifications

Defined in:
lib/crowdin-api/api_resources/notifications.rb

Instance Method Summary collapse

Instance Method Details

#send_notification_to_authenticated_user(query = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/crowdin-api/api_resources/notifications.rb', line 6

def send_notification_to_authenticated_user(query = {})
  %i[message].each do |param|
    query[param] || raise_parameter_is_required_error(param)
  end

  request = Web::Request.new(
    connection,
    :post,
    "#{config.target_api_url}/notify",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end

#send_notification_to_organization_members(query = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/crowdin-api/api_resources/notifications.rb', line 20

def send_notification_to_organization_members(query = {})
  enterprise_mode? || raise_only_for_enterprise_mode_error

  %i[message].each do |param|
    query[param] || raise_parameter_is_required_error(param)
  end

  request = Web::Request.new(
    connection,
    :post,
    "#{config.target_api_url}/notify",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end

#send_notifications_to_project_members(query = {}, project_id = config.project_id) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/crowdin-api/api_resources/notifications.rb', line 36

def send_notifications_to_project_members(query = {}, project_id = config.project_id)
  project_id || raise_project_id_is_required_error

  %i[message].each do |param|
    query[param] || raise_parameter_is_required_error(param)
  end

  request = Web::Request.new(
    connection,
    :post,
    "#{config.target_api_url}/projects/#{project_id}/notify",
    { params: query }
  )
  Web::SendRequest.new(request).perform
end