Class: DistributedPress::V1::Client::Publisher
- Inherits:
-
Object
- Object
- DistributedPress::V1::Client::Publisher
- Defined in:
- lib/distributed_press/v1/client/publisher.rb
Overview
Publishers can create and update sites
Instance Attribute Summary collapse
-
#client ⇒ DistributedPress::V1::Client
readonly
Client instance.
Instance Method Summary collapse
-
#create(schema) ⇒ DistributedPress::V1::Schemas::Publisher
Creates a Publisher, requires a token with admin capabilities.
-
#delete(schema) ⇒ Boolean
Deletes a Publisher, requires a token with admin capabilities.
-
#initialize(client) ⇒ Publisher
constructor
A new instance of Publisher.
Constructor Details
#initialize(client) ⇒ Publisher
Returns a new instance of Publisher.
16 17 18 |
# File 'lib/distributed_press/v1/client/publisher.rb', line 16 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ DistributedPress::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
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 |