Class: DistributedPress::V1::Client::Publisher

Inherits:
Object
  • Object
show all
Defined in:
lib/distributed_press/v1/client/publisher.rb

Overview

Publishers can create and update sites

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Publisher

Returns a new instance of Publisher.

Parameters:



16
17
18
# File 'lib/distributed_press/v1/client/publisher.rb', line 16

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientDistributedPress::V1::Client (readonly)

Client instance



13
14
15
# File 'lib/distributed_press/v1/client/publisher.rb', line 13

def client
  @client
end

Instance Method Details

#create(schema) ⇒ DistributedPress::V1::Schemas::Publisher

Creates a Publisher, requires a token with admin capabilities



24
25
26
27
28
29
# File 'lib/distributed_press/v1/client/publisher.rb', line 24

def create(schema)
  validate_schema! schema
  validate_capabilities!

  Schemas::Publisher.new.call(**client.post(endpoint: '/v1/publisher', schema: schema))
end

#delete(schema) ⇒ Boolean

Deletes a Publisher, requires a token with admin capabilities

Parameters:

Returns:

  • (Boolean)


35
36
37
38
39
40
# File 'lib/distributed_press/v1/client/publisher.rb', line 35

def delete(schema)
  validate_schema! schema
  validate_capabilities!

  client.delete(endpoint: "/v1/publisher/#{schema[:id]}")
end