Class: Posthubify::AccountsResource
- Inherits:
-
Object
- Object
- Posthubify::AccountsResource
- Defined in:
- lib/posthubify/resources/accounts.rb
Overview
Connected platform accounts (Node sdk .accounts) — health, follower stats, OAuth linking.
Instance Method Summary collapse
-
#boards(id) ⇒ Object
Pinterest boards (for posts.create options.board).
-
#bot_commands(id, scope: nil, language_code: nil) ⇒ Object
── Bot command menu (A1) — Telegram bot “/” commands (per account).
-
#connect_bluesky(handle, app_password, profile_id: nil, label: nil) ⇒ Object
── Headless credential connect (D8 cp2) — linking without OAuth.
- #connect_line(channel_access_token, channel_secret, profile_id: nil, label: nil) ⇒ Object
-
#connect_oauth_start(platform, profile_id: nil, label: nil) ⇒ Object
── Headless OAuth connect (D8 cp3) — tempToken start/status.
-
#connect_oauth_status(temp_token) ⇒ Object
Headless OAuth status (poll): pending | connected (+account) | error.
- #connect_telegram(bot_token, chat_id, profile_id: nil, label: nil) ⇒ Object
-
#connect_url(platform, profile_id: nil) ⇒ Object
OAuth connect URL — the user visits it in a browser (query: profile_id).
- #connect_whatsapp(access_token, phone_number_id, recipients, waba_id: nil, profile_id: nil, label: nil) ⇒ Object
-
#delete(id) ⇒ Object
Delete an account.
-
#delete_bot_commands(id, scope: nil, language_code: nil) ⇒ Object
Clear the bot command menu (Telegram deleteMyCommands).
-
#flairs(id) ⇒ Object
Reddit subreddit flairs (for posts.create options.flairId).
-
#follower_stats(id, days: nil, granularity: nil) ⇒ Object
Follower history + change for a single account (granularity: daily|weekly|monthly).
-
#follower_stats_all(days: nil, granularity: nil) ⇒ Object
Follower history + growth across all accounts (granularity: daily|weekly|monthly).
-
#health ⇒ Object
Health of all accounts + summary (token expiry, reconnection needs).
-
#health_of(id) ⇒ Object
Health report for a single account.
-
#initialize(http) ⇒ AccountsResource
constructor
A new instance of AccountsResource.
- #linkedin_organizations(id) ⇒ Object
-
#list(profile_id: nil, platform: nil, is_active: nil) ⇒ Object
List accounts (filter: profile_id/platform/is_active).
- #pinterest_boards(id) ⇒ Object
-
#reddit_subreddits(id) ⇒ Object
── Entity pickers + publishing defaults (D8) ──.
-
#set_bot_commands(id, commands, scope: nil, language_code: nil) ⇒ Object
Set the bot command menu (Telegram setMyCommands).
- #set_default_board(id, board_id) ⇒ Object
- #set_default_playlist(id, playlist_id) ⇒ Object
- #set_default_subreddit(id, subreddit) ⇒ Object
-
#update(id, input) ⇒ Object
Update an account (input: label/profileId/isActive).
- #youtube_playlists(id) ⇒ Object
Constructor Details
#initialize(http) ⇒ AccountsResource
Returns a new instance of AccountsResource.
38 39 40 |
# File 'lib/posthubify/resources/accounts.rb', line 38 def initialize(http) @http = http end |
Instance Method Details
#boards(id) ⇒ Object
Pinterest boards (for posts.create options.board). 400 on an unsupported platform.
67 68 69 |
# File 'lib/posthubify/resources/accounts.rb', line 67 def boards(id) @http.data('GET', "/accounts/#{id}/boards") end |
#bot_commands(id, scope: nil, language_code: nil) ⇒ Object
── Bot command menu (A1) — Telegram bot “/” commands (per account). ──Get the bot command menu (Telegram getMyCommands). scope/language_code optional.
107 108 109 110 111 112 |
# File 'lib/posthubify/resources/accounts.rb', line 107 def bot_commands(id, scope: nil, language_code: nil) @http.data('GET', "/accounts/#{id}/bot-commands", query: { 'scope' => scope, 'languageCode' => language_code }) end |
#connect_bluesky(handle, app_password, profile_id: nil, label: nil) ⇒ Object
── Headless credential connect (D8 cp2) — linking without OAuth. ──
158 159 160 |
# File 'lib/posthubify/resources/accounts.rb', line 158 def connect_bluesky(handle, app_password, profile_id: nil, label: nil) @http.data('POST', '/connect/bluesky/credentials', body: { 'handle' => handle, 'appPassword' => app_password, 'profileId' => profile_id, 'label' => label }) end |
#connect_line(channel_access_token, channel_secret, profile_id: nil, label: nil) ⇒ Object
170 171 172 |
# File 'lib/posthubify/resources/accounts.rb', line 170 def connect_line(channel_access_token, channel_secret, profile_id: nil, label: nil) @http.data('POST', '/connect/line/credentials', body: { 'channelAccessToken' => channel_access_token, 'channelSecret' => channel_secret, 'profileId' => profile_id, 'label' => label }) end |
#connect_oauth_start(platform, profile_id: nil, label: nil) ⇒ Object
── Headless OAuth connect (D8 cp3) — tempToken start/status. ──Start headless OAuth → authUrl: open authUrl in a browser, then poll status.
176 177 178 |
# File 'lib/posthubify/resources/accounts.rb', line 176 def connect_oauth_start(platform, profile_id: nil, label: nil) @http.data('POST', '/connect/oauth/start', body: { 'platform' => platform, 'profileId' => profile_id, 'label' => label }) end |
#connect_oauth_status(temp_token) ⇒ Object
Headless OAuth status (poll): pending | connected (+account) | error.
181 182 183 |
# File 'lib/posthubify/resources/accounts.rb', line 181 def connect_oauth_status(temp_token) @http.data('GET', '/connect/oauth/status', query: { 'tempToken' => temp_token }) end |
#connect_telegram(bot_token, chat_id, profile_id: nil, label: nil) ⇒ Object
162 163 164 |
# File 'lib/posthubify/resources/accounts.rb', line 162 def connect_telegram(bot_token, chat_id, profile_id: nil, label: nil) @http.data('POST', '/connect/telegram', body: { 'botToken' => bot_token, 'chatId' => chat_id, 'profileId' => profile_id, 'label' => label }) end |
#connect_url(platform, profile_id: nil) ⇒ Object
OAuth connect URL — the user visits it in a browser (query: profile_id).
153 154 155 |
# File 'lib/posthubify/resources/accounts.rb', line 153 def connect_url(platform, profile_id: nil) @http.data('GET', "/connect/#{platform}", query: { 'profileId' => profile_id }) end |
#connect_whatsapp(access_token, phone_number_id, recipients, waba_id: nil, profile_id: nil, label: nil) ⇒ Object
166 167 168 |
# File 'lib/posthubify/resources/accounts.rb', line 166 def connect_whatsapp(access_token, phone_number_id, recipients, waba_id: nil, profile_id: nil, label: nil) @http.data('POST', '/connect/whatsapp/credentials', body: { 'accessToken' => access_token, 'phoneNumberId' => phone_number_id, 'recipients' => recipients, 'wabaId' => waba_id, 'profileId' => profile_id, 'label' => label }) end |
#delete(id) ⇒ Object
Delete an account.
148 149 150 |
# File 'lib/posthubify/resources/accounts.rb', line 148 def delete(id) @http.data('DELETE', "/accounts/#{id}") end |
#delete_bot_commands(id, scope: nil, language_code: nil) ⇒ Object
Clear the bot command menu (Telegram deleteMyCommands).
124 125 126 127 128 129 |
# File 'lib/posthubify/resources/accounts.rb', line 124 def delete_bot_commands(id, scope: nil, language_code: nil) @http.data('DELETE', "/accounts/#{id}/bot-commands", query: { 'scope' => scope, 'languageCode' => language_code }) end |
#flairs(id) ⇒ Object
Reddit subreddit flairs (for posts.create options.flairId). 400 on an unsupported platform.
72 73 74 |
# File 'lib/posthubify/resources/accounts.rb', line 72 def flairs(id) @http.data('GET', "/accounts/#{id}/flairs") end |
#follower_stats(id, days: nil, granularity: nil) ⇒ Object
Follower history + change for a single account (granularity: daily|weekly|monthly).
140 141 142 143 144 145 |
# File 'lib/posthubify/resources/accounts.rb', line 140 def follower_stats(id, days: nil, granularity: nil) @http.data('GET', "/accounts/#{id}/follower-stats", query: { 'days' => days, 'granularity' => granularity }) end |
#follower_stats_all(days: nil, granularity: nil) ⇒ Object
Follower history + growth across all accounts (granularity: daily|weekly|monthly).
132 133 134 135 136 137 |
# File 'lib/posthubify/resources/accounts.rb', line 132 def follower_stats_all(days: nil, granularity: nil) @http.data('GET', '/accounts/follower-stats', query: { 'days' => days, 'granularity' => granularity }) end |
#health ⇒ Object
Health of all accounts + summary (token expiry, reconnection needs).
57 58 59 |
# File 'lib/posthubify/resources/accounts.rb', line 57 def health @http.data('GET', '/accounts/health') end |
#health_of(id) ⇒ Object
Health report for a single account.
62 63 64 |
# File 'lib/posthubify/resources/accounts.rb', line 62 def health_of(id) @http.data('GET', "/accounts/#{id}/health") end |
#linkedin_organizations(id) ⇒ Object
93 94 95 |
# File 'lib/posthubify/resources/accounts.rb', line 93 def linkedin_organizations(id) @http.data('GET', "/accounts/#{id}/linkedin-organizations") end |
#list(profile_id: nil, platform: nil, is_active: nil) ⇒ Object
List accounts (filter: profile_id/platform/is_active).
43 44 45 46 47 48 49 |
# File 'lib/posthubify/resources/accounts.rb', line 43 def list(profile_id: nil, platform: nil, is_active: nil) @http.data('GET', '/accounts', query: { 'profileId' => profile_id, 'platform' => platform, 'isActive' => is_active }) end |
#pinterest_boards(id) ⇒ Object
97 98 99 |
# File 'lib/posthubify/resources/accounts.rb', line 97 def pinterest_boards(id) @http.data('GET', "/accounts/#{id}/pinterest-boards") end |
#reddit_subreddits(id) ⇒ Object
── Entity pickers + publishing defaults (D8) ──
77 78 79 |
# File 'lib/posthubify/resources/accounts.rb', line 77 def reddit_subreddits(id) @http.data('GET', "/accounts/#{id}/reddit-subreddits") end |
#set_bot_commands(id, commands, scope: nil, language_code: nil) ⇒ Object
Set the bot command menu (Telegram setMyCommands).
115 116 117 118 119 120 121 |
# File 'lib/posthubify/resources/accounts.rb', line 115 def set_bot_commands(id, commands, scope: nil, language_code: nil) @http.data('PUT', "/accounts/#{id}/bot-commands", body: { 'commands' => commands, 'scope' => scope, 'languageCode' => language_code }) end |
#set_default_board(id, board_id) ⇒ Object
101 102 103 |
# File 'lib/posthubify/resources/accounts.rb', line 101 def set_default_board(id, board_id) @http.data('PUT', "/accounts/#{id}/pinterest-boards", body: { 'boardId' => board_id }) end |
#set_default_playlist(id, playlist_id) ⇒ Object
89 90 91 |
# File 'lib/posthubify/resources/accounts.rb', line 89 def set_default_playlist(id, playlist_id) @http.data('PUT', "/accounts/#{id}/youtube-playlists", body: { 'playlistId' => playlist_id }) end |
#set_default_subreddit(id, subreddit) ⇒ Object
81 82 83 |
# File 'lib/posthubify/resources/accounts.rb', line 81 def set_default_subreddit(id, subreddit) @http.data('PUT', "/accounts/#{id}/reddit-subreddits", body: { 'subreddit' => subreddit }) end |
#update(id, input) ⇒ Object
Update an account (input: label/profileId/isActive).
52 53 54 |
# File 'lib/posthubify/resources/accounts.rb', line 52 def update(id, input) @http.data('PATCH', "/accounts/#{id}", body: input) end |
#youtube_playlists(id) ⇒ Object
85 86 87 |
# File 'lib/posthubify/resources/accounts.rb', line 85 def youtube_playlists(id) @http.data('GET', "/accounts/#{id}/youtube-playlists") end |