Class: Webhookdb::Oauth::IntercomProvider
- Includes:
- Appydays::Loggable
- Defined in:
- lib/webhookdb/oauth/intercom_provider.rb
Instance Method Summary collapse
- #app_name ⇒ Object
- #authorization_url(state:) ⇒ Object
- #build_marketplace_integrations(organization:, tokens:) ⇒ Object
- #exchange_authorization_code(code:) ⇒ Object
- #key ⇒ Object
- #supports_webhooks? ⇒ Boolean
Instance Method Details
#app_name ⇒ Object
9 |
# File 'lib/webhookdb/oauth/intercom_provider.rb', line 9 def app_name = "Intercom" |
#authorization_url(state:) ⇒ Object
12 13 14 |
# File 'lib/webhookdb/oauth/intercom_provider.rb', line 12 def (state:) return "https://app.intercom.com/oauth?client_id=#{Webhookdb::Intercom.client_id}&state=#{state}" end |
#build_marketplace_integrations(organization:, tokens:) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/webhookdb/oauth/intercom_provider.rb', line 30 def build_marketplace_integrations(organization:, tokens:) intercom_user_resp = Webhookdb::Http.get( "https://api.intercom.io/me", headers: Webhookdb::Intercom.auth_headers(tokens.access_token), logger: self.logger, timeout: Webhookdb::Intercom.http_timeout, ) # The intercom workspace id is used in the intercom webhook endpoint to identify which # service integration to delegate requests to. intercom_workspace_id = intercom_user_resp.parsed_response.dig("app", "id_code") root_sint = Webhookdb::ServiceIntegration.create_disambiguated( "intercom_marketplace_root_v1", organization:, api_url: intercom_workspace_id, backfill_key: tokens.access_token, ) root_sint.replicator.build_dependents return root_sint end |
#exchange_authorization_code(code:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/webhookdb/oauth/intercom_provider.rb', line 16 def (code:) token_resp = Webhookdb::Http.post( "https://api.intercom.io/auth/eagle/token", { "client_id" => Webhookdb::Intercom.client_id, "client_secret" => Webhookdb::Intercom.client_secret, "code" => code, }, logger: self.logger, timeout: Webhookdb::Intercom.http_timeout, ) return Webhookdb::Oauth::Tokens.new(access_token: token_resp.parsed_response["token"]) end |
#key ⇒ Object
8 |
# File 'lib/webhookdb/oauth/intercom_provider.rb', line 8 def key = "intercom" |
#supports_webhooks? ⇒ Boolean
10 |
# File 'lib/webhookdb/oauth/intercom_provider.rb', line 10 def supports_webhooks? = false |