Class: Fopost::Resources::Ai
Overview
client.ai — caption assist, per-platform rewriting, and blog fan-out.
Every call spends AI credits. Check the balance with #credits; a PaymentRequiredError means the plan has none left.
Instance Method Summary collapse
-
#credits ⇒ Object
Credits remaining, used, and total for the current billing period.
- #generate_caption(current_caption: nil, image_urls: nil, platforms: nil, char_limit: nil, workspace_id: nil, brand_voice_id: nil) ⇒ Object
-
#repurpose_url(url:, platforms:, workspace_id: nil, brand_voice_id: nil) ⇒ Object
Turn an article URL into a post for each platform, in one call.
-
#rewrite(content:, platforms:, tone: nil, workspace_id: nil, brand_voice_id: nil) ⇒ Object
Rewrite one draft for each target platform.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Fopost::Resources::Base
Instance Method Details
#credits ⇒ Object
Credits remaining, used, and total for the current billing period.
11 12 13 |
# File 'lib/fopost/resources/ai.rb', line 11 def credits AiCreditBalance.new(unwrap(http.get('/ai/credits'))) end |
#generate_caption(current_caption: nil, image_urls: nil, platforms: nil, char_limit: nil, workspace_id: nil, brand_voice_id: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fopost/resources/ai.rb', line 15 def generate_caption(current_caption: nil, image_urls: nil, platforms: nil, char_limit: nil, workspace_id: nil, brand_voice_id: nil) body = compact_nil( 'current_caption' => current_caption, 'image_urls' => image_urls&.to_a, 'platforms' => platforms&.to_a, 'char_limit' => char_limit, 'workspace_id' => workspace_id, 'brand_voice_id' => brand_voice_id ) CaptionResult.new(unwrap(http.post('/ai/generate-caption', body))) end |
#repurpose_url(url:, platforms:, workspace_id: nil, brand_voice_id: nil) ⇒ Object
Turn an article URL into a post for each platform, in one call.
41 42 43 44 45 46 47 48 49 |
# File 'lib/fopost/resources/ai.rb', line 41 def repurpose_url(url:, platforms:, workspace_id: nil, brand_voice_id: nil) body = compact_nil( 'url' => url, 'platforms' => platforms.to_a, 'workspace_id' => workspace_id, 'brand_voice_id' => brand_voice_id ) RepurposeResult.new(unwrap(http.post('/ai/repurpose-url', body))) end |
#rewrite(content:, platforms:, tone: nil, workspace_id: nil, brand_voice_id: nil) ⇒ Object
Rewrite one draft for each target platform. Costs 1 credit per platform.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fopost/resources/ai.rb', line 29 def rewrite(content:, platforms:, tone: nil, workspace_id: nil, brand_voice_id: nil) body = compact_nil( 'content' => content, 'platforms' => platforms.to_a, 'tone' => tone, 'workspace_id' => workspace_id, 'brand_voice_id' => brand_voice_id ) RewriteResult.new(unwrap(http.post('/ai/rewrite', body))) end |