Class: DistributedPress::V1::Social::Blocklist
- Inherits:
-
Object
- Object
- DistributedPress::V1::Social::Blocklist
- Defined in:
- lib/distributed_press/v1/social/blocklist.rb
Overview
Manages Social Inbox blocklist
Direct Known Subclasses
Constant Summary collapse
- ACCEPT =
%w[text/plain].freeze
- CONTENT_TYPE =
'text/plain'
- ENDPOINT =
'/blocklist'
Instance Attribute Summary collapse
- #actor ⇒ String? readonly
- #client ⇒ DistributedPress::V1::Social::Client readonly
Instance Method Summary collapse
-
#delete(list:) ⇒ HTTParty::Response
Removes instances and accounts from the blocklist.
- #endpoint ⇒ Object
-
#get ⇒ Array<String>
Obtains the current blocklist.
-
#initialize(client:, actor: nil) ⇒ Blocklist
constructor
A new instance of Blocklist.
-
#post(list:) ⇒ HTTParty::Response
Sends an array of instances and accounts to be blocked.
Constructor Details
#initialize(client:, actor: nil) ⇒ Blocklist
Returns a new instance of Blocklist.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/distributed_press/v1/social/blocklist.rb', line 26 def initialize(client:, actor: nil) @client = client @actor = actor @serializer = proc do |body| body.join("\n") end # @param :body [String,nil] # @return [Array<String>] @parser = proc do |body, _| next [] if body.nil? body.split("\n").map(&:strip).reject(&:empty?) end end |
Instance Attribute Details
#actor ⇒ String? (readonly)
22 23 24 |
# File 'lib/distributed_press/v1/social/blocklist.rb', line 22 def actor @actor end |
#client ⇒ DistributedPress::V1::Social::Client (readonly)
19 20 21 |
# File 'lib/distributed_press/v1/social/blocklist.rb', line 19 def client @client end |
Instance Method Details
#delete(list:) ⇒ HTTParty::Response
Removes instances and accounts from the blocklist
64 65 66 67 |
# File 'lib/distributed_press/v1/social/blocklist.rb', line 64 def delete(list:) client.delete(endpoint: endpoint, body: list, serializer: @serializer, parser: @parser, content_type: CONTENT_TYPE, accept: ACCEPT) end |
#endpoint ⇒ Object
69 70 71 |
# File 'lib/distributed_press/v1/social/blocklist.rb', line 69 def endpoint @endpoint ||= "/v1/#{actor}#{self.class::ENDPOINT}".squeeze('/') end |
#get ⇒ Array<String>
Obtains the current blocklist
47 48 49 |
# File 'lib/distributed_press/v1/social/blocklist.rb', line 47 def get client.get(endpoint: endpoint, parser: @parser, content_type: CONTENT_TYPE, accept: ACCEPT) end |
#post(list:) ⇒ HTTParty::Response
Sends an array of instances and accounts to be blocked
55 56 57 58 |
# File 'lib/distributed_press/v1/social/blocklist.rb', line 55 def post(list:) client.post(endpoint: endpoint, body: list, serializer: @serializer, parser: @parser, content_type: CONTENT_TYPE, accept: ACCEPT) end |