Class: Pushover::Teams

Inherits:
Object
  • Object
show all
Defined in:
lib/pushover/teams.rb

Overview

Teams provides operations for the Pushover for Teams API.

Constant Summary collapse

TEXT_FIELDS =
%i[name password group].freeze
FLAGS =
%i[instant admin].freeze

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Teams

Returns a new instance of Teams.



7
8
9
# File 'lib/pushover/teams.rb', line 7

def initialize(client)
  @client = client
end

Instance Method Details

#add_user(email:, **fields) ⇒ Response

Add a user or send an invitation to the team.

Returns:

  • (Response)

    the Pushover API response



23
24
25
26
27
28
29
30
# File 'lib/pushover/teams.rb', line 23

def add_user(email:, **fields)
  validate_email!(email)
  validate_add_user_fields!(fields)

  body = { 'email' => email }.merge(fields.slice(*TEXT_FIELDS).compact.transform_keys(&:to_s))
  add_flags!(body, **fields.slice(*FLAGS))
  post_action('add_user', body)
end

#getResponse

Retrieve the team and its users and devices.

Returns:

  • (Response)

    the Pushover API response



13
14
15
16
17
18
19
# File 'lib/pushover/teams.rb', line 13

def get
  response = @client.connection.get(
    path:  '/1/teams.json',
    query: { token: @client.token }
  )
  Response.create_from_excon_response(response)
end

#remove_user(email:) ⇒ Response

Remove a user from the team and its delivery groups.

Returns:

  • (Response)

    the Pushover API response



40
41
42
# File 'lib/pushover/teams.rb', line 40

def remove_user(email:)
  post_email_action('remove_user', email)
end

#revoke_invitation(email:) ⇒ Response

Revoke a pending team invitation.

Returns:

  • (Response)

    the Pushover API response



34
35
36
# File 'lib/pushover/teams.rb', line 34

def revoke_invitation(email:)
  post_email_action('revoke_invitation', email)
end