{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- |
-- Module      : Gogol.URLShortener.Url.Get
-- Copyright   : (c) 2015-2025 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+gogol@gmail.com>
--               Toni Cebrián <toni@tonicebrian.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Expands a short URL or gets creation time and analytics.
--
-- /See:/ <https://developers.google.com/url-shortener/v1/getting_started URL Shortener API Reference> for @urlshortener.url.get@.
module Gogol.URLShortener.Url.Get
  ( -- * Resource
    URLShortenerUrlGetResource,

    -- ** Constructing a Request
    URLShortenerUrlGet (..),
    newURLShortenerUrlGet,
  )
where

import Gogol.Prelude qualified as Core
import Gogol.URLShortener.Types

-- | A resource alias for @urlshortener.url.get@ method which the
-- 'URLShortenerUrlGet' request conforms to.
type URLShortenerUrlGetResource =
  "urlshortener"
    Core.:> "v1"
    Core.:> "url"
    Core.:> Core.QueryParam "shortUrl" Core.Text
    Core.:> Core.QueryParam "projection" UrlGetProjection
    Core.:> Core.QueryParam "alt" Core.AltJSON
    Core.:> Core.Get '[Core.JSON] Url

-- | Expands a short URL or gets creation time and analytics.
--
-- /See:/ 'newURLShortenerUrlGet' smart constructor.
data URLShortenerUrlGet = URLShortenerUrlGet
  { -- | Additional information to return.
    URLShortenerUrlGet -> Maybe UrlGetProjection
projection :: (Core.Maybe UrlGetProjection),
    -- | The short URL, including the protocol.
    URLShortenerUrlGet -> Text
shortUrl :: Core.Text
  }
  deriving (URLShortenerUrlGet -> URLShortenerUrlGet -> Bool
(URLShortenerUrlGet -> URLShortenerUrlGet -> Bool)
-> (URLShortenerUrlGet -> URLShortenerUrlGet -> Bool)
-> Eq URLShortenerUrlGet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: URLShortenerUrlGet -> URLShortenerUrlGet -> Bool
== :: URLShortenerUrlGet -> URLShortenerUrlGet -> Bool
$c/= :: URLShortenerUrlGet -> URLShortenerUrlGet -> Bool
/= :: URLShortenerUrlGet -> URLShortenerUrlGet -> Bool
Core.Eq, Int -> URLShortenerUrlGet -> ShowS
[URLShortenerUrlGet] -> ShowS
URLShortenerUrlGet -> String
(Int -> URLShortenerUrlGet -> ShowS)
-> (URLShortenerUrlGet -> String)
-> ([URLShortenerUrlGet] -> ShowS)
-> Show URLShortenerUrlGet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> URLShortenerUrlGet -> ShowS
showsPrec :: Int -> URLShortenerUrlGet -> ShowS
$cshow :: URLShortenerUrlGet -> String
show :: URLShortenerUrlGet -> String
$cshowList :: [URLShortenerUrlGet] -> ShowS
showList :: [URLShortenerUrlGet] -> ShowS
Core.Show, (forall x. URLShortenerUrlGet -> Rep URLShortenerUrlGet x)
-> (forall x. Rep URLShortenerUrlGet x -> URLShortenerUrlGet)
-> Generic URLShortenerUrlGet
forall x. Rep URLShortenerUrlGet x -> URLShortenerUrlGet
forall x. URLShortenerUrlGet -> Rep URLShortenerUrlGet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. URLShortenerUrlGet -> Rep URLShortenerUrlGet x
from :: forall x. URLShortenerUrlGet -> Rep URLShortenerUrlGet x
$cto :: forall x. Rep URLShortenerUrlGet x -> URLShortenerUrlGet
to :: forall x. Rep URLShortenerUrlGet x -> URLShortenerUrlGet
Core.Generic)

-- | Creates a value of 'URLShortenerUrlGet' with the minimum fields required to make a request.
newURLShortenerUrlGet ::
  -- |  The short URL, including the protocol. See 'shortUrl'.
  Core.Text ->
  URLShortenerUrlGet
newURLShortenerUrlGet :: Text -> URLShortenerUrlGet
newURLShortenerUrlGet Text
shortUrl =
  URLShortenerUrlGet
    { projection :: Maybe UrlGetProjection
projection = Maybe UrlGetProjection
forall a. Maybe a
Core.Nothing,
      shortUrl :: Text
shortUrl = Text
shortUrl
    }

instance Core.GoogleRequest URLShortenerUrlGet where
  type Rs URLShortenerUrlGet = Url
  type Scopes URLShortenerUrlGet = '[Urlshortener'FullControl]
  requestClient :: URLShortenerUrlGet -> GClient (Rs URLShortenerUrlGet)
requestClient URLShortenerUrlGet {Maybe UrlGetProjection
Text
projection :: URLShortenerUrlGet -> Maybe UrlGetProjection
shortUrl :: URLShortenerUrlGet -> Text
projection :: Maybe UrlGetProjection
shortUrl :: Text
..} =
    Maybe Text
-> Maybe UrlGetProjection
-> Maybe AltJSON
-> ServiceConfig
-> GClient Url
go
      (Text -> Maybe Text
forall a. a -> Maybe a
Core.Just Text
shortUrl)
      Maybe UrlGetProjection
projection
      (AltJSON -> Maybe AltJSON
forall a. a -> Maybe a
Core.Just AltJSON
Core.AltJSON)
      ServiceConfig
uRLShortenerService
    where
      go :: Fn URLShortenerUrlGetResource
go =
        Proxy URLShortenerUrlGetResource
-> Request -> Fn URLShortenerUrlGetResource
forall {k} (fn :: k).
GoogleClient fn =>
Proxy fn -> Request -> Fn fn
Core.buildClient
          (Proxy URLShortenerUrlGetResource
forall {k} (t :: k). Proxy t
Core.Proxy :: Core.Proxy URLShortenerUrlGetResource)
          Request
forall a. Monoid a => a
Core.mempty