class Osso::GraphQL::Mutations::CreateIdentityProvider

Public Instance Methods

domain(enterprise_account_id:, **_args) click to toggle source
# File lib/osso/graphql/mutations/create_identity_provider.rb, line 35
def domain(enterprise_account_id:, **_args)
  enterprise_account(enterprise_account_id: enterprise_account_id)&.domain
end
enterprise_account(enterprise_account_id:) click to toggle source
# File lib/osso/graphql/mutations/create_identity_provider.rb, line 39
def enterprise_account(enterprise_account_id:)
  @enterprise_account ||= Osso::Models::EnterpriseAccount.find(enterprise_account_id)
end
resolve(enterprise_account_id:, oauth_client_id:, service: nil) click to toggle source
# File lib/osso/graphql/mutations/create_identity_provider.rb, line 16
def resolve(enterprise_account_id:, oauth_client_id:, service: nil)
  customer = enterprise_account(enterprise_account_id: enterprise_account_id)

  identity_provider = customer.identity_providers.build(
    service: service,
    domain: customer.domain,
    oauth_client_id: oauth_client_id,
  )

  if identity_provider.save
    Osso::Analytics.capture(email: context[:email], event: self.class.name.demodulize, properties: {
      service: service, enterprise_account_id: enterprise_account_id, oauth_client_id: oauth_client_id
    })
    return response_data(identity_provider: identity_provider)
  end

  response_error(identity_provider.errors)
end