Class: PostProxy::Resources::ProfileGroups
- Inherits:
-
Object
- Object
- PostProxy::Resources::ProfileGroups
- Defined in:
- lib/postproxy/resources/profile_groups.rb
Instance Method Summary collapse
- #connect_bluesky(id, identifier:, app_password:) ⇒ Object
-
#connect_telegram(id, bot_token:) ⇒ Object
After this call, poll ‘client.profiles.placements(profile.id)` until non-empty — the bot must be added as administrator to a channel in Telegram first.
- #create(name) ⇒ Object
- #delete(id) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(client) ⇒ ProfileGroups
constructor
A new instance of ProfileGroups.
-
#initialize_connection(id, platform:, redirect_url: nil) ⇒ Object
OAuth flow.
- #list ⇒ Object
Constructor Details
#initialize(client) ⇒ ProfileGroups
Returns a new instance of ProfileGroups.
4 5 6 |
# File 'lib/postproxy/resources/profile_groups.rb', line 4 def initialize(client) @client = client end |
Instance Method Details
#connect_bluesky(id, identifier:, app_password:) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/postproxy/resources/profile_groups.rb', line 37 def connect_bluesky(id, identifier:, app_password:) result = @client.request(:post, "/profile_groups/#{id}/initialize_connection", json: { platform: "bluesky", identifier: identifier, app_password: app_password } ) BlueskyConnectionResponse.new(**result) end |
#connect_telegram(id, bot_token:) ⇒ Object
After this call, poll ‘client.profiles.placements(profile.id)` until non-empty —the bot must be added as administrator to a channel in Telegram first.
46 47 48 49 50 51 |
# File 'lib/postproxy/resources/profile_groups.rb', line 46 def connect_telegram(id, bot_token:) result = @client.request(:post, "/profile_groups/#{id}/initialize_connection", json: { platform: "telegram", bot_token: bot_token } ) TelegramConnectionResponse.new(**result) end |
#create(name) ⇒ Object
19 20 21 22 |
# File 'lib/postproxy/resources/profile_groups.rb', line 19 def create(name) result = @client.request(:post, "/profile_groups", json: { name: name }) ProfileGroup.new(**result) end |
#delete(id) ⇒ Object
24 25 26 27 |
# File 'lib/postproxy/resources/profile_groups.rb', line 24 def delete(id) result = @client.request(:delete, "/profile_groups/#{id}") DeleteResponse.new(**result) end |
#get(id) ⇒ Object
14 15 16 17 |
# File 'lib/postproxy/resources/profile_groups.rb', line 14 def get(id) result = @client.request(:get, "/profile_groups/#{id}") ProfileGroup.new(**result) end |
#initialize_connection(id, platform:, redirect_url: nil) ⇒ Object
OAuth flow. BlueSky and Telegram use their dedicated helpers below.
30 31 32 33 34 35 |
# File 'lib/postproxy/resources/profile_groups.rb', line 30 def initialize_connection(id, platform:, redirect_url: nil) body = { platform: platform } body[:redirect_url] = redirect_url if redirect_url result = @client.request(:post, "/profile_groups/#{id}/initialize_connection", json: body) ConnectionResponse.new(**result) end |
#list ⇒ Object
8 9 10 11 12 |
# File 'lib/postproxy/resources/profile_groups.rb', line 8 def list result = @client.request(:get, "/profile_groups") groups = (result[:data] || []).map { |g| ProfileGroup.new(**g) } ListResponse.new(data: groups) end |