{-# LANGUAGE DataKinds          #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric      #-}
{-# LANGUAGE FlexibleInstances  #-}
{-# LANGUAGE NoImplicitPrelude  #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE RecordWildCards    #-}
{-# LANGUAGE TypeFamilies       #-}
{-# LANGUAGE TypeOperators      #-}

{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds      #-}
{-# OPTIONS_GHC -fno-warn-unused-imports    #-}

-- |
-- Module      : Network.Google.Resource.Content.Datafeeds.Insert
-- Copyright   : (c) 2015-2016 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Registers a datafeed configuration with your Merchant Center account.
--
-- /See:/ <https://developers.google.com/shopping-content Content API for Shopping Reference> for @content.datafeeds.insert@.
module Network.Google.Resource.Content.Datafeeds.Insert
    (
    -- * REST Resource
      DatafeedsInsertResource

    -- * Creating a Request
    , datafeedsInsert
    , DatafeedsInsert

    -- * Request Lenses
    , diMerchantId
    , diPayload
    ) where

import           Network.Google.Prelude
import           Network.Google.ShoppingContent.Types

-- | A resource alias for @content.datafeeds.insert@ method which the
-- 'DatafeedsInsert' request conforms to.
type DatafeedsInsertResource =
     "content" :>
       "v2.1" :>
         Capture "merchantId" (Textual Word64) :>
           "datafeeds" :>
             QueryParam "alt" AltJSON :>
               ReqBody '[JSON] Datafeed :> Post '[JSON] Datafeed

-- | Registers a datafeed configuration with your Merchant Center account.
--
-- /See:/ 'datafeedsInsert' smart constructor.
data DatafeedsInsert = DatafeedsInsert'
    { _diMerchantId :: !(Textual Word64)
    , _diPayload    :: !Datafeed
    } deriving (Eq,Show,Data,Typeable,Generic)

-- | Creates a value of 'DatafeedsInsert' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'diMerchantId'
--
-- * 'diPayload'
datafeedsInsert
    :: Word64 -- ^ 'diMerchantId'
    -> Datafeed -- ^ 'diPayload'
    -> DatafeedsInsert
datafeedsInsert pDiMerchantId_ pDiPayload_ =
    DatafeedsInsert'
    { _diMerchantId = _Coerce # pDiMerchantId_
    , _diPayload = pDiPayload_
    }

-- | The ID of the account that manages the datafeed. This account cannot be
-- a multi-client account.
diMerchantId :: Lens' DatafeedsInsert Word64
diMerchantId
  = lens _diMerchantId (\ s a -> s{_diMerchantId = a})
      . _Coerce

-- | Multipart request metadata.
diPayload :: Lens' DatafeedsInsert Datafeed
diPayload
  = lens _diPayload (\ s a -> s{_diPayload = a})

instance GoogleRequest DatafeedsInsert where
        type Rs DatafeedsInsert = Datafeed
        type Scopes DatafeedsInsert =
             '["https://www.googleapis.com/auth/content"]
        requestClient DatafeedsInsert'{..}
          = go _diMerchantId (Just AltJSON) _diPayload
              shoppingContentService
          where go
                  = buildClient
                      (Proxy :: Proxy DatafeedsInsertResource)
                      mempty