Class: Posthubify::Client
- Inherits:
-
Object
- Object
- Posthubify::Client
- Defined in:
- lib/posthubify/client.rb
Overview
PostHubify /v1 API client. All resource groups are exposed as snake_case readers.
Instance Attribute Summary collapse
-
#account_groups ⇒ Object
readonly
Returns the value of attribute account_groups.
-
#accounts ⇒ Object
readonly
Returns the value of attribute accounts.
-
#ads ⇒ Object
readonly
Returns the value of attribute ads.
-
#api_keys ⇒ Object
readonly
Returns the value of attribute api_keys.
-
#automations ⇒ Object
readonly
Returns the value of attribute automations.
-
#broadcasts ⇒ Object
readonly
Returns the value of attribute broadcasts.
-
#comment_automations ⇒ Object
readonly
Returns the value of attribute comment_automations.
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#contacts ⇒ Object
readonly
Returns the value of attribute contacts.
-
#custom_fields ⇒ Object
readonly
Returns the value of attribute custom_fields.
-
#discord ⇒ Object
readonly
Returns the value of attribute discord.
-
#discovery ⇒ Object
readonly
Returns the value of attribute discovery.
-
#engagement ⇒ Object
readonly
Returns the value of attribute engagement.
-
#gmb ⇒ Object
readonly
Returns the value of attribute gmb.
-
#inbox ⇒ Object
readonly
Returns the value of attribute inbox.
-
#inbox_analytics ⇒ Object
readonly
Returns the value of attribute inbox_analytics.
-
#insights ⇒ Object
readonly
Returns the value of attribute insights.
-
#invite_tokens ⇒ Object
readonly
Returns the value of attribute invite_tokens.
-
#media ⇒ Object
readonly
Returns the value of attribute media.
-
#numbers ⇒ Object
readonly
Returns the value of attribute numbers.
-
#otp ⇒ Object
readonly
Returns the value of attribute otp.
-
#platform_analytics ⇒ Object
readonly
Returns the value of attribute platform_analytics.
-
#posts ⇒ Object
readonly
Returns the value of attribute posts.
-
#profiles ⇒ Object
readonly
Returns the value of attribute profiles.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#reviews ⇒ Object
readonly
Returns the value of attribute reviews.
-
#senders ⇒ Object
readonly
Returns the value of attribute senders.
-
#sequences ⇒ Object
readonly
Returns the value of attribute sequences.
-
#sms ⇒ Object
readonly
Returns the value of attribute sms.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
-
#webhooks ⇒ Object
readonly
Returns the value of attribute webhooks.
-
#whatsapp ⇒ Object
readonly
Returns the value of attribute whatsapp.
-
#workflows ⇒ Object
readonly
Returns the value of attribute workflows.
Instance Method Summary collapse
- #analytics ⇒ Object
-
#analytics_posts(platform: nil, account_id: nil, source: nil, limit: nil, cursor: nil) ⇒ Object
Post analytics list — source: ‘external’ is synced from the platform, not PostHubify (B5).
-
#analytics_timeseries(days: nil, platform: nil, account_id: nil, from_date: nil, to_date: nil, source: nil) ⇒ Object
Stored daily metric time series (account/post/inbox aggregates).
-
#generate(command, platforms, variants: nil, context: nil, max_chars: nil) ⇒ Object
AI content generation (F1) — command → per-platform draft + variants (multi-language).
-
#initialize(api_key: nil, base_url: Transport::DEFAULT_BASE, timeout: 30, transport: nil) ⇒ Client
constructor
transport: injectable for tests (Node opts.fetch equivalent).
- #logs(limit: nil, category: nil, status: nil, platform: nil, days: nil) ⇒ Object
- #me ⇒ Object
-
#openapi ⇒ Object
— top-level endpoints —.
- #ping ⇒ Object
-
#subtitles(text, format: 'srt', duration_sec: nil, max_chars_per_line: nil, max_lines_per_cue: nil, chars_per_sec: nil, gap_ms: nil) ⇒ Object
Subtitle generation (F4) — text → timed SRT/VTT (pure conversion, no AI/charge; a read key is enough).
- #usage ⇒ Object
-
#videos(image_url, format, audio_url: nil, subtitle_text: nil, subtitle_rtl: nil, bumper_duration_sec: nil, main_duration_sec: nil) ⇒ Object
Promo video render (F4) — remote image (+optional audio/subtitle) → branded video (ffmpeg) → R2 URL.
Constructor Details
#initialize(api_key: nil, base_url: Transport::DEFAULT_BASE, timeout: 30, transport: nil) ⇒ Client
transport: injectable for tests (Node opts.fetch equivalent).
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/posthubify/client.rb', line 14 def initialize(api_key: nil, base_url: Transport::DEFAULT_BASE, timeout: 30, transport: nil) @http = transport || Transport.new(api_key: api_key, base_url: base_url, timeout: timeout) @profiles = ProfilesResource.new(@http) @accounts = AccountsResource.new(@http) @posts = PostsResource.new(@http) @media = MediaResource.new(@http) @tools = ToolsResource.new(@http) @ads = AdsResource.new(@http) @insights = InsightsResource.new(@http) @platform_analytics = PlatformAnalyticsResource.new(@http) @inbox_analytics = InboxAnalyticsResource.new(@http) @inbox = InboxResource.new(@http) @comments = CommentsResource.new(@http) @reviews = ReviewsResource.new(@http) @contacts = ContactsResource.new(@http) @automations = AutomationsResource.new(@http) @comment_automations = CommentAutomationsResource.new(@http) @workflows = WorkflowsResource.new(@http) @broadcasts = BroadcastsResource.new(@http) @sequences = SequencesResource.new(@http) @webhooks = WebhooksResource.new(@http) @api_keys = ApiKeysResource.new(@http) @queue = QueueResource.new(@http) @account_groups = AccountGroupsResource.new(@http) @engagement = EngagementResource.new(@http) @users = UsersResource.new(@http) @invite_tokens = InviteTokensResource.new(@http) @numbers = NumbersResource.new(@http) @senders = SendersResource.new(@http) @sms = SmsResource.new(@http) @otp = OtpResource.new(@http) @custom_fields = CustomFieldsResource.new(@http) @whatsapp = WhatsAppResource.new(@http) @gmb = GmbResource.new(@http) @discord = DiscordResource.new(@http) @discovery = DiscoveryResource.new(@http) end |
Instance Attribute Details
#account_groups ⇒ Object (readonly)
Returns the value of attribute account_groups.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def account_groups @account_groups end |
#accounts ⇒ Object (readonly)
Returns the value of attribute accounts.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def accounts @accounts end |
#ads ⇒ Object (readonly)
Returns the value of attribute ads.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def ads @ads end |
#api_keys ⇒ Object (readonly)
Returns the value of attribute api_keys.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def api_keys @api_keys end |
#automations ⇒ Object (readonly)
Returns the value of attribute automations.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def automations @automations end |
#broadcasts ⇒ Object (readonly)
Returns the value of attribute broadcasts.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def broadcasts @broadcasts end |
#comment_automations ⇒ Object (readonly)
Returns the value of attribute comment_automations.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def comment_automations @comment_automations end |
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def comments @comments end |
#contacts ⇒ Object (readonly)
Returns the value of attribute contacts.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def contacts @contacts end |
#custom_fields ⇒ Object (readonly)
Returns the value of attribute custom_fields.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def custom_fields @custom_fields end |
#discord ⇒ Object (readonly)
Returns the value of attribute discord.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def discord @discord end |
#discovery ⇒ Object (readonly)
Returns the value of attribute discovery.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def discovery @discovery end |
#engagement ⇒ Object (readonly)
Returns the value of attribute engagement.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def engagement @engagement end |
#gmb ⇒ Object (readonly)
Returns the value of attribute gmb.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def gmb @gmb end |
#inbox ⇒ Object (readonly)
Returns the value of attribute inbox.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def inbox @inbox end |
#inbox_analytics ⇒ Object (readonly)
Returns the value of attribute inbox_analytics.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def inbox_analytics @inbox_analytics end |
#insights ⇒ Object (readonly)
Returns the value of attribute insights.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def insights @insights end |
#invite_tokens ⇒ Object (readonly)
Returns the value of attribute invite_tokens.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def invite_tokens @invite_tokens end |
#media ⇒ Object (readonly)
Returns the value of attribute media.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def media @media end |
#numbers ⇒ Object (readonly)
Returns the value of attribute numbers.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def numbers @numbers end |
#otp ⇒ Object (readonly)
Returns the value of attribute otp.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def otp @otp end |
#platform_analytics ⇒ Object (readonly)
Returns the value of attribute platform_analytics.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def platform_analytics @platform_analytics end |
#posts ⇒ Object (readonly)
Returns the value of attribute posts.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def posts @posts end |
#profiles ⇒ Object (readonly)
Returns the value of attribute profiles.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def profiles @profiles end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def queue @queue end |
#reviews ⇒ Object (readonly)
Returns the value of attribute reviews.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def reviews @reviews end |
#senders ⇒ Object (readonly)
Returns the value of attribute senders.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def senders @senders end |
#sequences ⇒ Object (readonly)
Returns the value of attribute sequences.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def sequences @sequences end |
#sms ⇒ Object (readonly)
Returns the value of attribute sms.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def sms @sms end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def tools @tools end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def users @users end |
#webhooks ⇒ Object (readonly)
Returns the value of attribute webhooks.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def webhooks @webhooks end |
#whatsapp ⇒ Object (readonly)
Returns the value of attribute whatsapp.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def whatsapp @whatsapp end |
#workflows ⇒ Object (readonly)
Returns the value of attribute workflows.
6 7 8 |
# File 'lib/posthubify/client.rb', line 6 def workflows @workflows end |
Instance Method Details
#analytics ⇒ Object
107 108 109 |
# File 'lib/posthubify/client.rb', line 107 def analytics @http.data('GET', '/analytics') end |
#analytics_posts(platform: nil, account_id: nil, source: nil, limit: nil, cursor: nil) ⇒ Object
Post analytics list — source: ‘external’ is synced from the platform, not PostHubify (B5).
112 113 114 115 116 117 |
# File 'lib/posthubify/client.rb', line 112 def analytics_posts(platform: nil, account_id: nil, source: nil, limit: nil, cursor: nil) @http.req('GET', '/analytics/posts', query: { 'platform' => platform, 'accountId' => account_id, 'source' => source, 'limit' => limit, 'cursor' => cursor }) end |
#analytics_timeseries(days: nil, platform: nil, account_id: nil, from_date: nil, to_date: nil, source: nil) ⇒ Object
Stored daily metric time series (account/post/inbox aggregates).
120 121 122 123 124 125 |
# File 'lib/posthubify/client.rb', line 120 def analytics_timeseries(days: nil, platform: nil, account_id: nil, from_date: nil, to_date: nil, source: nil) @http.data('GET', '/analytics/timeseries', query: { 'days' => days, 'platform' => platform, 'accountId' => account_id, 'fromDate' => from_date, 'toDate' => to_date, 'source' => source }) end |
#generate(command, platforms, variants: nil, context: nil, max_chars: nil) ⇒ Object
AI content generation (F1) — command → per-platform draft + variants (multi-language).
67 68 69 70 71 72 |
# File 'lib/posthubify/client.rb', line 67 def generate(command, platforms, variants: nil, context: nil, max_chars: nil) @http.data('POST', '/generate', body: { 'command' => command, 'platforms' => platforms, 'variants' => variants, 'context' => context, 'maxChars' => max_chars, }) end |
#logs(limit: nil, category: nil, status: nil, platform: nil, days: nil) ⇒ Object
131 132 133 134 135 136 |
# File 'lib/posthubify/client.rb', line 131 def logs(limit: nil, category: nil, status: nil, platform: nil, days: nil) @http.data('GET', '/logs', query: { 'limit' => limit, 'category' => category, 'status' => status, 'platform' => platform, 'days' => days }) end |
#me ⇒ Object
62 63 64 |
# File 'lib/posthubify/client.rb', line 62 def me @http.data('GET', '/me') end |
#openapi ⇒ Object
— top-level endpoints —
54 55 56 |
# File 'lib/posthubify/client.rb', line 54 def openapi @http.req('GET', '/openapi.json') end |
#ping ⇒ Object
58 59 60 |
# File 'lib/posthubify/client.rb', line 58 def ping @http.data('GET', '/ping') end |
#subtitles(text, format: 'srt', duration_sec: nil, max_chars_per_line: nil, max_lines_per_cue: nil, chars_per_sec: nil, gap_ms: nil) ⇒ Object
Subtitle generation (F4) — text → timed SRT/VTT (pure conversion, no AI/charge; a read key is enough).
82 83 84 85 86 87 88 89 |
# File 'lib/posthubify/client.rb', line 82 def subtitles(text, format: 'srt', duration_sec: nil, max_chars_per_line: nil, max_lines_per_cue: nil, chars_per_sec: nil, gap_ms: nil) @http.data('POST', '/subtitles', body: { 'text' => text, 'format' => format, 'durationSec' => duration_sec, 'maxCharsPerLine' => max_chars_per_line, 'maxLinesPerCue' => max_lines_per_cue, 'charsPerSec' => chars_per_sec, 'gapMs' => gap_ms, }) end |
#usage ⇒ Object
127 128 129 |
# File 'lib/posthubify/client.rb', line 127 def usage @http.data('GET', '/usage') end |
#videos(image_url, format, audio_url: nil, subtitle_text: nil, subtitle_rtl: nil, bumper_duration_sec: nil, main_duration_sec: nil) ⇒ Object
Promo video render (F4) — remote image (+optional audio/subtitle) → branded video (ffmpeg) → R2 URL. HEAVY operation (write permission + low rate limit). Media is downloaded SSRF-protected (https + type + ≤25MB).
98 99 100 101 102 103 104 105 |
# File 'lib/posthubify/client.rb', line 98 def videos(image_url, format, audio_url: nil, subtitle_text: nil, subtitle_rtl: nil, bumper_duration_sec: nil, main_duration_sec: nil) @http.data('POST', '/videos', body: { 'imageUrl' => image_url, 'format' => format, 'audioUrl' => audio_url, 'subtitleText' => subtitle_text, 'subtitleRtl' => subtitle_rtl, 'bumperDurationSec' => bumper_duration_sec, 'mainDurationSec' => main_duration_sec, }) end |