# Class: Backend::Api::Server

Inherits:
  Object
  - Object
  - Backend::Api::Server
  show all

Extended by:
  ConnectionHelper

Defined in:
  api/server.rb

## Overview

Class that connect to global endpoints of the OBS Backend server

## Class Method Summary collapse

- .delete_notification_payload(notification_id) ⇒ String

  Deletes the payload of the notification by Id.

- .last_notifications(starting_point) ⇒ String

  Latest notifications specifying a starting point.

- .notification_payload(notification_id) ⇒ String

  JSON payload of a notification by Id.

- .notify_plugin(plugin_id, payload) ⇒ String

  Notifies a certain plugin with the payload.

- .root ⇒ String

  Pings the root of the source repository server.

- .write_configuration(configuration) ⇒ String

  It writes the configuration of the server.

## Class Method Details

### .delete_notification_payload(notification_id) ⇒ `String`

Deletes the payload of the notification by Id.

Returns:

- (`String`)

    16
    17
    18
    # File 'api/server.rb', line 16

    def self.delete_notification_payload(notification_id)
      http_delete(['/notificationpayload/:notification', notification_id])
    end

### .last_notifications(starting_point) ⇒ `String`

Latest notifications specifying a starting point

Parameters:

- starting_point (`Integer`)

Returns:

- (`String`) —

  Last notifications

    29
    30
    31
    # File 'api/server.rb', line 29

    def self.last_notifications(starting_point)
      http_get('/lastnotifications', params: { start: starting_point, block: 1 })
    end

### .notification_payload(notification_id) ⇒ `String`

JSON payload of a notification by Id.

Returns:

- (`String`)

    10
    11
    12
    # File 'api/server.rb', line 10

    def self.notification_payload(notification_id)
      http_get(['/notificationpayload/:notification', notification_id])
    end

### .notify_plugin(plugin_id, payload) ⇒ `String`

Notifies a certain plugin with the payload

Parameters:

- plugin_id (`String`)

Returns:

- (`String`)

    36
    37
    38
    39
    # File 'api/server.rb', line 36

    def self.notify_plugin(plugin_id, payload)
      http_post(['/notify_plugins/:plugin', plugin_id],
                data: ActiveSupport::JSON.encode(payload), headers: { 'Content-Type' => 'application/json' })
    end

### .root ⇒ `String`

Pings the root of the source repository server

Returns:

- (`String`) —

  Hello message from the server

    43
    44
    45
    # File 'api/server.rb', line 43

    def self.root
      http_get('/')
    end

### .write_configuration(configuration) ⇒ `String`

It writes the configuration of the server

Returns:

- (`String`)

    22
    23
    24
    # File 'api/server.rb', line 22

    def self.write_configuration(configuration)
      http_put('/configuration', data: configuration)
    end