Class: Posthubify::ToolsResource

Inherits:
Object
  • Object
show all
Defined in:
lib/posthubify/resources/posts.rb

Overview

Validation tools — post-length/media/subreddit pre-checks (Node sdk .tools).

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ ToolsResource

Returns a new instance of ToolsResource.



83
84
85
# File 'lib/posthubify/resources/posts.rb', line 83

def initialize(http)
  @http = http
end

Instance Method Details

#validate_media(url) ⇒ Object

Media URL pre-check (accessibility/type/size; private network addresses are rejected).



93
94
95
# File 'lib/posthubify/resources/posts.rb', line 93

def validate_media(url)
  @http.data('POST', '/tools/validate/media', body: { 'url' => url })
end

#validate_post_length(text) ⇒ Object

Per-platform weighted character report (X: URL=23).



88
89
90
# File 'lib/posthubify/resources/posts.rb', line 88

def validate_post_length(text)
  @http.data('POST', '/tools/validate/post-length', body: { 'text' => text })
end

#validate_subreddit(subreddit) ⇒ Object

Whether the subreddit exists + basic info (subscriber count, NSFW, post type).



98
99
100
# File 'lib/posthubify/resources/posts.rb', line 98

def validate_subreddit(subreddit)
  @http.data('GET', '/tools/validate/subreddit', query: { 'subreddit' => subreddit })
end