Class: Swiftner::API::Meeting

Inherits:
Service
  • Object
show all
Defined in:
lib/swiftner/API/meeting.rb

Overview

Represents a Meeting service responsible for finding, creating, and deleting spaces. Inherits from the Service class. Provides methods for interacting with meetings.

Constant Summary collapse

REQUIRED_ATTRIBUTES =
%i[space_id language].freeze

Instance Attribute Summary

Attributes inherited from Service

#client, #details, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Service

build, client, #initialize, map_collection, validate_required

Constructor Details

This class inherits a constructor from Swiftner::API::Service

Class Method Details

.create(attributes) ⇒ Swiftner::API::Meeting

Creates a meeting.

Parameters:

  • attributes (Hash)

Options Hash (attributes):

  • :space_id (Integer) — default: required
  • :language (String) — default: required
  • :title (String) — default: optional
  • :description (String) — default: optional
  • :start (String) — default: optional

    eg. “2024-09-06T08:37:45.162Z”

  • :duration (Integer) — default: optional
  • :thumbnail_url (String) — default: optional
  • :state (String) — default: optional

    eg. “not_started”, “ended”

  • :prompt_id (Integer) — default: optional

Returns:



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/swiftner/API/meeting.rb', line 37

def self.create(attributes)
  validate_required(attributes, *REQUIRED_ATTRIBUTES)

  response = client.post(
    "/meeting/create",
    body: attributes.to_json,
    headers: { "Content-Type" => "application/json" }
  )

  build(response.parsed_response)
end

.find(meeting_id) ⇒ Swiftner::API::Meeting

Finds meeting by id

Parameters:

  • meeting_id (Integer)

Returns:



20
21
22
23
# File 'lib/swiftner/API/meeting.rb', line 20

def self.find(meeting_id)
  response = client.get("/meeting/get/#{meeting_id}")
  build(response.parsed_response)
end

.find_meetingsArray<Swiftner::API::Meeting>

Finds all meetings

Returns:



12
13
14
15
# File 'lib/swiftner/API/meeting.rb', line 12

def self.find_meetings
  response = client.get("/meeting/get-meetings")
  map_collection(response)
end

Instance Method Details

#deleteHash

Deletes a meeting.

Returns:

  • (Hash)


122
123
124
# File 'lib/swiftner/API/meeting.rb', line 122

def delete
  client.delete("/meeting/delete/#{id}")
end

#endSwiftner::API::Meeting

Ends a meeting



63
64
65
66
67
68
69
70
# File 'lib/swiftner/API/meeting.rb', line 63

def end
  response = client.post(
    "/meeting/#{id}/end",
    headers: { "Content-Type" => "application/json" }
  )
  @details = response.parsed_response
  self
end

#pauseSwiftner::API::Meeting?

Pauses a meeting

Returns:



74
75
76
77
78
79
80
81
# File 'lib/swiftner/API/meeting.rb', line 74

def pause
  response = client.post(
    "/meeting/#{id}/pause",
    headers: { "Content-Type" => "application/json" }
  )
  @details = response.parsed_response
  self
end

#resumeSwiftner::API::Meeting

Resumes a meeting



85
86
87
88
89
90
91
92
# File 'lib/swiftner/API/meeting.rb', line 85

def resume
  response = client.post(
    "/meeting/#{id}/resume",
    headers: { "Content-Type" => "application/json" }
  )
  @details = response.parsed_response
  self
end

#startSwiftner::API::Meeting

Starts a meeting



51
52
53
54
55
56
57
58
59
# File 'lib/swiftner/API/meeting.rb', line 51

def start
  response = client.post(
    "/meeting/#{id}/start",
    headers: { "Content-Type" => "application/json" }
  )

  @details = response
  self
end

#update(attributes) ⇒ Swiftner::API::Meeting

Updates a meeting.

Parameters:

  • attributes (Hash)

Options Hash (attributes):

  • :space_id (Integer) — default: optional
  • :language (String) — default: optional

    eg. “no”, “en”

  • :title (String) — default: optional
  • :description (String) — default: optional
  • :start (String) — default: optional

    eg. “2024-09-06T08:37:45.162Z”

  • :duration (Integer) — default: optional
  • :thumbnail_url (String) — default: optional
  • :state (String) — default: optional

    eg. “not_started”, “ended”

  • :prompt_id (Integer) — default: optional

Returns:



106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/swiftner/API/meeting.rb', line 106

def update(attributes)
  attributes = attributes.transform_keys(&:to_s)
  @details = @details.merge(attributes)

  self.class.validate_required(@details, :language, :space)

  client.put(
    "/meeting/update/#{id}",
    body: @details.to_json,
    headers: { "Content-Type" => "application/json" }
  )
  self
end