fix(instagram): read API version from installation config

This commit is contained in:
Pranav
2026-07-05 11:36:15 -07:00
parent 8818d276b9
commit d7a0463008
4 changed files with 11 additions and 4 deletions
+8 -2
View File
@@ -45,7 +45,7 @@ class Channel::Instagram < ApplicationRecord
def subscribe
# ref https://developers.facebook.com/docs/instagram-platform/webhooks#enable-subscriptions
HTTParty.post(
"https://graph.instagram.com/v22.0/#{instagram_id}/subscribed_apps",
"#{base_uri}/#{instagram_id}/subscribed_apps",
query: {
subscribed_fields: %w[messages message_reactions messaging_seen],
access_token: access_token
@@ -58,7 +58,7 @@ class Channel::Instagram < ApplicationRecord
def unsubscribe
HTTParty.delete(
"https://graph.instagram.com/v22.0/#{instagram_id}/subscribed_apps",
"#{base_uri}/#{instagram_id}/subscribed_apps",
query: {
access_token: access_token
}
@@ -72,4 +72,10 @@ class Channel::Instagram < ApplicationRecord
def access_token
Instagram::RefreshOauthTokenService.new(channel: self).access_token
end
private
def base_uri
"https://graph.instagram.com/#{GlobalConfigService.load('INSTAGRAM_API_VERSION', 'v22.0')}"
end
end