Class: DistributedPress::V1::Social::Outbox

Inherits:
Object
  • Object
show all
Defined in:
lib/distributed_press/v1/social/outbox.rb

Overview

Manages the actor’s outbox on the Social Inbox

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, actor:) ⇒ Outbox

Returns a new instance of Outbox.

Parameters:



19
20
21
22
# File 'lib/distributed_press/v1/social/outbox.rb', line 19

def initialize(client:, actor:)
  @client = client
  @actor = actor
end

Instance Attribute Details

#actorString (readonly)

Returns:

  • (String)


15
16
17
# File 'lib/distributed_press/v1/social/outbox.rb', line 15

def actor
  @actor
end

#clientDistributedPress::V1::Social::Client (readonly)



12
13
14
# File 'lib/distributed_press/v1/social/outbox.rb', line 12

def client
  @client
end

Instance Method Details

#endpointString

Outbox

Returns:

  • (String)


44
45
46
# File 'lib/distributed_press/v1/social/outbox.rb', line 44

def endpoint
  @endpoint ||= "/v1/#{actor}/outbox"
end

#get(id:) ⇒ HTTParty::Response

Get an activity queued on the outbox

Parameters:

  • :id (String)

    Activity ID

Returns:

  • (HTTParty::Response)


37
38
39
# File 'lib/distributed_press/v1/social/outbox.rb', line 37

def get(id:)
  client.get(endpoint: "#{endpoint}/#{URI.encode_uri_component(id)}")
end

#post(activity:) ⇒ HTTParty::Response

Send an activity to the actor’s outbox. The Social Inbox will take care of sending it to the audiences.

Parameters:

  • :activity (Hash)

Returns:

  • (HTTParty::Response)


29
30
31
# File 'lib/distributed_press/v1/social/outbox.rb', line 29

def post(activity:)
  client.post(endpoint: endpoint, body: activity)
end