Class: Ribose::Message

Inherits:
Object
  • Object
show all
Includes:
Actions::All, Actions::Create, Actions::Delete, Actions::Update, ResourceHelper
Defined in:
lib/ribose/message.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Actions::Delete

#delete

Methods included from Actions::Base

#included

Methods included from Actions::Update

#update

Methods included from Actions::Create

#create

Methods included from Actions::All

#all

Methods included from ResourceHelper

#resource_key, #resource_path, #resources

Constructor Details

#initialize(space_id, conversation_id, attributes = {}) ⇒ Ribose::Message

Message initilaiztion

Parameters:

  • space_id (String)

    The Space UUID

  • conversation_id (String)

    The Conversation UUID

  • attributes (Hash) (defaults to: {})

    The Message related attributes



17
18
19
20
21
22
# File 'lib/ribose/message.rb', line 17

def initialize(space_id, conversation_id, attributes = {})
  @space_id = space_id
  @attributes = attributes
  @conversation_id = conversation_id
  @message_id = attributes.delete(:message_id)
end

Class Method Details

.all(space_id:, conversation_id:, **options) ⇒ Array<Sawyer::Resource>

Listing Conversation Messages

Parameters:

  • space_id (String)

    The Space UUID

  • conversation_id (String)

    The Conversation UUID

  • options (Hash)

    The Query parameters as a Hash

Returns:

  • (Array<Sawyer::Resource>)


31
32
33
# File 'lib/ribose/message.rb', line 31

def self.all(space_id:, conversation_id:, **options)
  new(space_id, conversation_id, **options).all
end

.create(space_id:, conversation_id:, **attributes) ⇒ Sawyer::Resource

Create A New Message

Parameters:

  • space_id (String)

    The Space UUID

  • conversation_id (String)

    The Conversation UUID

  • attributes (Hash)

    The message attributes

Returns:

  • (Sawyer::Resource)


42
43
44
# File 'lib/ribose/message.rb', line 42

def self.create(space_id:, conversation_id:, **attributes)
  new(space_id, conversation_id, attributes).create
end

.remove(space_id:, message_id:, conversation_id:, **options) ⇒ Sawyer::Resource

Remove A Message

Parameters:

  • space_id (String)

    The Space UUID

  • message_id (String)

    The Message UUID

  • conversation_id (String)

    The Conversation UUID

Returns:

  • (Sawyer::Resource)


65
66
67
# File 'lib/ribose/message.rb', line 65

def self.remove(space_id:, message_id:, conversation_id:, **options)
  new(space_id, conversation_id, message_id: message_id, **options).delete
end

.update(space_id:, message_id:, conversation_id:, **attrs) ⇒ Sawyer::Resource

Update A Messsage

Parameters:

  • space_id (String)

    The Space UUID

  • message_id (String)

    The Message UUID

  • conversation_id (String)

    The Conversation UUID

  • attributes (Hash)

    The message attributes

Returns:

  • (Sawyer::Resource)


54
55
56
# File 'lib/ribose/message.rb', line 54

def self.update(space_id:, message_id:, conversation_id:, **attrs)
  new(space_id, conversation_id, attrs.merge(message_id: message_id)).update
end