Sha256: cab2f8bb6e4196314e3134a53a13beddf03c5e6f9b37140727f1e299b8fee5e2

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

module Crowdin
  module ApiResources
    module Notifications
      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

      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

      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
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
crowdin-api-1.12.0 lib/crowdin-api/api_resources/notifications.rb
crowdin-api-1.10.0 lib/crowdin-api/api_resources/notifications.rb
crowdin-api-1.9.0 lib/crowdin-api/api_resources/notifications.rb
crowdin-api-1.8.1 lib/crowdin-api/api_resources/notifications.rb
crowdin-api-1.8.0 lib/crowdin-api/api_resources/notifications.rb
crowdin-api-1.7.0 lib/crowdin-api/api_resources/notifications.rb