{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}

module Hercules.API.Organizations
  ( OrganizationsAPI (..),
  )
where

import Hercules.API.Accounts.Account (Account)
import Hercules.API.Organizations.BillingInfo (BillingInfo)
import Hercules.API.Organizations.CreateOrganization (CreateOrganization)
import Hercules.API.Organizations.Organization (Organization)
import Hercules.API.Organizations.PaymentLink (PaymentLink)
import Hercules.API.Prelude
import Servant.API

data OrganizationsAPI auth f = OrganizationsAPI
  { forall auth f.
OrganizationsAPI auth f
-> f
   :- (Summary "Get all organizations user has admin access to"
       :> (auth
           :> ("api" :> ("organizations" :> Get '[JSON] [Organization]))))
findOrganizations ::
      f
        :- Summary "Get all organizations user has admin access to"
          :> auth
          :> "api"
          :> "organizations"
          :> Get '[JSON] [Organization],
    forall auth f.
OrganizationsAPI auth f
-> f
   :- (Summary "Create a new organization"
       :> (auth
           :> ("api"
               :> ("organizations"
                   :> (ReqBody '[JSON] CreateOrganization
                       :> Post '[JSON] Organization)))))
createOrganization ::
      f
        :- Summary "Create a new organization"
          :> auth
          :> "api"
          :> "organizations"
          :> ReqBody '[JSON] CreateOrganization
          :> Post '[JSON] Organization,
    forall auth f.
OrganizationsAPI auth f
-> f
   :- (Summary "Connect an account to an organization"
       :> (auth
           :> ("api"
               :> ("organizations"
                   :> (Capture "organizationId" (Id Organization)
                       :> ("accounts"
                           :> (Capture "accountId" (Id Account)
                               :> Post '[JSON] NoContent)))))))
connectAccountToOrganization ::
      f
        :- Summary "Connect an account to an organization"
          :> auth
          :> "api"
          :> "organizations"
          :> Capture "organizationId" (Id Organization)
          :> "accounts"
          :> Capture "accountId" (Id Account)
          :> Post '[JSON] NoContent,
    forall auth f.
OrganizationsAPI auth f
-> f
   :- (Summary "Generate payment link for an organization"
       :> (auth
           :> ("api"
               :> ("organizations"
                   :> (Capture "organizationId" (Id Organization)
                       :> ("paymentLink" :> Post '[JSON] PaymentLink))))))
paymentLinkForOrganization ::
      f
        :- Summary "Generate payment link for an organization"
          :> auth
          :> "api"
          :> "organizations"
          :> Capture "organizationId" (Id Organization)
          :> "paymentLink"
          :> Post '[JSON] PaymentLink,
    forall auth f.
OrganizationsAPI auth f
-> f
   :- (Summary "List the active users in an organization's accounts."
       :> (auth
           :> ("api"
               :> ("organizations"
                   :> (Capture "organizationId" (Id Organization)
                       :> ("billing" :> Get '[JSON] BillingInfo))))))
getOrganizationActiveUsers ::
      f
        :- Summary "List the active users in an organization's accounts."
          :> auth
          :> "api"
          :> "organizations"
          :> Capture "organizationId" (Id Organization)
          :> "billing"
          :> Get '[JSON] BillingInfo
  }
  deriving (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall auth f x.
Rep (OrganizationsAPI auth f) x -> OrganizationsAPI auth f
forall auth f x.
OrganizationsAPI auth f -> Rep (OrganizationsAPI auth f) x
$cto :: forall auth f x.
Rep (OrganizationsAPI auth f) x -> OrganizationsAPI auth f
$cfrom :: forall auth f x.
OrganizationsAPI auth f -> Rep (OrganizationsAPI auth f) x
Generic)