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, idempotency_key: nil) ⇒ Object
- #delete(id, idempotency_key: nil) ⇒ 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
40 41 42 43 44 45 |
# File 'lib/postproxy/resources/profile_groups.rb', line 40 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.
49 50 51 52 53 54 |
# File 'lib/postproxy/resources/profile_groups.rb', line 49 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, idempotency_key: nil) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/postproxy/resources/profile_groups.rb', line 19 def create(name, idempotency_key: nil) result = @client.request(:post, "/profile_groups", json: { name: name }, idempotency_key: idempotency_key ) ProfileGroup.new(**result) end |
#delete(id, idempotency_key: nil) ⇒ Object
27 28 29 30 |
# File 'lib/postproxy/resources/profile_groups.rb', line 27 def delete(id, idempotency_key: nil) result = @client.request(:delete, "/profile_groups/#{id}", idempotency_key: idempotency_key) 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.
33 34 35 36 37 38 |
# File 'lib/postproxy/resources/profile_groups.rb', line 33 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 |