{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Snowball.Types.Address
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Snowball.Types.Address where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The address that you want the Snow device(s) associated with a specific
-- job to be shipped to. Addresses are validated at the time of creation.
-- The address you provide must be located within the serviceable area of
-- your region. Although no individual elements of the @Address@ are
-- required, if the address is invalid or unsupported, then an exception is
-- thrown.
--
-- /See:/ 'newAddress' smart constructor.
data Address = Address'
  { -- | If the address you are creating is a primary address, then set this
    -- option to true. This field is not supported in most regions.
    Address -> Maybe Bool
isRestricted :: Prelude.Maybe Prelude.Bool,
    -- | The third line in a street address that a Snow device is to be delivered
    -- to.
    Address -> Maybe Text
street3 :: Prelude.Maybe Prelude.Text,
    -- | This field is no longer used and the value is ignored.
    Address -> Maybe Text
landmark :: Prelude.Maybe Prelude.Text,
    -- | The postal code in an address that a Snow device is to be delivered to.
    Address -> Maybe Text
postalCode :: Prelude.Maybe Prelude.Text,
    -- | The country in an address that a Snow device is to be delivered to.
    Address -> Maybe Text
country :: Prelude.Maybe Prelude.Text,
    -- | The state or province in an address that a Snow device is to be
    -- delivered to.
    Address -> Maybe Text
stateOrProvince :: Prelude.Maybe Prelude.Text,
    -- | The second line in a street address that a Snow device is to be
    -- delivered to.
    Address -> Maybe Text
street2 :: Prelude.Maybe Prelude.Text,
    -- | The unique ID for an address.
    Address -> Maybe Text
addressId :: Prelude.Maybe Prelude.Text,
    -- | The city in an address that a Snow device is to be delivered to.
    Address -> Maybe Text
city :: Prelude.Maybe Prelude.Text,
    -- | The phone number associated with an address that a Snow device is to be
    -- delivered to.
    Address -> Maybe Text
phoneNumber :: Prelude.Maybe Prelude.Text,
    -- | The name of the company to receive a Snow device at an address.
    Address -> Maybe Text
company :: Prelude.Maybe Prelude.Text,
    -- | The name of a person to receive a Snow device at an address.
    Address -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | This field is no longer used and the value is ignored.
    Address -> Maybe Text
prefectureOrDistrict :: Prelude.Maybe Prelude.Text,
    -- | The first line in a street address that a Snow device is to be delivered
    -- to.
    Address -> Maybe Text
street1 :: Prelude.Maybe Prelude.Text
  }
  deriving (Address -> Address -> Bool
(Address -> Address -> Bool)
-> (Address -> Address -> Bool) -> Eq Address
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Address -> Address -> Bool
$c/= :: Address -> Address -> Bool
== :: Address -> Address -> Bool
$c== :: Address -> Address -> Bool
Prelude.Eq, ReadPrec [Address]
ReadPrec Address
Int -> ReadS Address
ReadS [Address]
(Int -> ReadS Address)
-> ReadS [Address]
-> ReadPrec Address
-> ReadPrec [Address]
-> Read Address
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Address]
$creadListPrec :: ReadPrec [Address]
readPrec :: ReadPrec Address
$creadPrec :: ReadPrec Address
readList :: ReadS [Address]
$creadList :: ReadS [Address]
readsPrec :: Int -> ReadS Address
$creadsPrec :: Int -> ReadS Address
Prelude.Read, Int -> Address -> ShowS
[Address] -> ShowS
Address -> String
(Int -> Address -> ShowS)
-> (Address -> String) -> ([Address] -> ShowS) -> Show Address
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Address] -> ShowS
$cshowList :: [Address] -> ShowS
show :: Address -> String
$cshow :: Address -> String
showsPrec :: Int -> Address -> ShowS
$cshowsPrec :: Int -> Address -> ShowS
Prelude.Show, (forall x. Address -> Rep Address x)
-> (forall x. Rep Address x -> Address) -> Generic Address
forall x. Rep Address x -> Address
forall x. Address -> Rep Address x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Address x -> Address
$cfrom :: forall x. Address -> Rep Address x
Prelude.Generic)

-- |
-- Create a value of 'Address' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'isRestricted', 'address_isRestricted' - If the address you are creating is a primary address, then set this
-- option to true. This field is not supported in most regions.
--
-- 'street3', 'address_street3' - The third line in a street address that a Snow device is to be delivered
-- to.
--
-- 'landmark', 'address_landmark' - This field is no longer used and the value is ignored.
--
-- 'postalCode', 'address_postalCode' - The postal code in an address that a Snow device is to be delivered to.
--
-- 'country', 'address_country' - The country in an address that a Snow device is to be delivered to.
--
-- 'stateOrProvince', 'address_stateOrProvince' - The state or province in an address that a Snow device is to be
-- delivered to.
--
-- 'street2', 'address_street2' - The second line in a street address that a Snow device is to be
-- delivered to.
--
-- 'addressId', 'address_addressId' - The unique ID for an address.
--
-- 'city', 'address_city' - The city in an address that a Snow device is to be delivered to.
--
-- 'phoneNumber', 'address_phoneNumber' - The phone number associated with an address that a Snow device is to be
-- delivered to.
--
-- 'company', 'address_company' - The name of the company to receive a Snow device at an address.
--
-- 'name', 'address_name' - The name of a person to receive a Snow device at an address.
--
-- 'prefectureOrDistrict', 'address_prefectureOrDistrict' - This field is no longer used and the value is ignored.
--
-- 'street1', 'address_street1' - The first line in a street address that a Snow device is to be delivered
-- to.
newAddress ::
  Address
newAddress :: Address
newAddress =
  Address' :: Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Address
Address'
    { $sel:isRestricted:Address' :: Maybe Bool
isRestricted = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:street3:Address' :: Maybe Text
street3 = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:landmark:Address' :: Maybe Text
landmark = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:postalCode:Address' :: Maybe Text
postalCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:country:Address' :: Maybe Text
country = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:stateOrProvince:Address' :: Maybe Text
stateOrProvince = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:street2:Address' :: Maybe Text
street2 = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:addressId:Address' :: Maybe Text
addressId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:city:Address' :: Maybe Text
city = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:phoneNumber:Address' :: Maybe Text
phoneNumber = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:company:Address' :: Maybe Text
company = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Address' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:prefectureOrDistrict:Address' :: Maybe Text
prefectureOrDistrict = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:street1:Address' :: Maybe Text
street1 = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | If the address you are creating is a primary address, then set this
-- option to true. This field is not supported in most regions.
address_isRestricted :: Lens.Lens' Address (Prelude.Maybe Prelude.Bool)
address_isRestricted :: (Maybe Bool -> f (Maybe Bool)) -> Address -> f Address
address_isRestricted = (Address -> Maybe Bool)
-> (Address -> Maybe Bool -> Address)
-> Lens Address Address (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Bool
isRestricted :: Maybe Bool
$sel:isRestricted:Address' :: Address -> Maybe Bool
isRestricted} -> Maybe Bool
isRestricted) (\s :: Address
s@Address' {} Maybe Bool
a -> Address
s {$sel:isRestricted:Address' :: Maybe Bool
isRestricted = Maybe Bool
a} :: Address)

-- | The third line in a street address that a Snow device is to be delivered
-- to.
address_street3 :: Lens.Lens' Address (Prelude.Maybe Prelude.Text)
address_street3 :: (Maybe Text -> f (Maybe Text)) -> Address -> f Address
address_street3 = (Address -> Maybe Text)
-> (Address -> Maybe Text -> Address)
-> Lens Address Address (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Text
street3 :: Maybe Text
$sel:street3:Address' :: Address -> Maybe Text
street3} -> Maybe Text
street3) (\s :: Address
s@Address' {} Maybe Text
a -> Address
s {$sel:street3:Address' :: Maybe Text
street3 = Maybe Text
a} :: Address)

-- | This field is no longer used and the value is ignored.
address_landmark :: Lens.Lens' Address (Prelude.Maybe Prelude.Text)
address_landmark :: (Maybe Text -> f (Maybe Text)) -> Address -> f Address
address_landmark = (Address -> Maybe Text)
-> (Address -> Maybe Text -> Address)
-> Lens Address Address (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Text
landmark :: Maybe Text
$sel:landmark:Address' :: Address -> Maybe Text
landmark} -> Maybe Text
landmark) (\s :: Address
s@Address' {} Maybe Text
a -> Address
s {$sel:landmark:Address' :: Maybe Text
landmark = Maybe Text
a} :: Address)

-- | The postal code in an address that a Snow device is to be delivered to.
address_postalCode :: Lens.Lens' Address (Prelude.Maybe Prelude.Text)
address_postalCode :: (Maybe Text -> f (Maybe Text)) -> Address -> f Address
address_postalCode = (Address -> Maybe Text)
-> (Address -> Maybe Text -> Address)
-> Lens Address Address (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Text
postalCode :: Maybe Text
$sel:postalCode:Address' :: Address -> Maybe Text
postalCode} -> Maybe Text
postalCode) (\s :: Address
s@Address' {} Maybe Text
a -> Address
s {$sel:postalCode:Address' :: Maybe Text
postalCode = Maybe Text
a} :: Address)

-- | The country in an address that a Snow device is to be delivered to.
address_country :: Lens.Lens' Address (Prelude.Maybe Prelude.Text)
address_country :: (Maybe Text -> f (Maybe Text)) -> Address -> f Address
address_country = (Address -> Maybe Text)
-> (Address -> Maybe Text -> Address)
-> Lens Address Address (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Text
country :: Maybe Text
$sel:country:Address' :: Address -> Maybe Text
country} -> Maybe Text
country) (\s :: Address
s@Address' {} Maybe Text
a -> Address
s {$sel:country:Address' :: Maybe Text
country = Maybe Text
a} :: Address)

-- | The state or province in an address that a Snow device is to be
-- delivered to.
address_stateOrProvince :: Lens.Lens' Address (Prelude.Maybe Prelude.Text)
address_stateOrProvince :: (Maybe Text -> f (Maybe Text)) -> Address -> f Address
address_stateOrProvince = (Address -> Maybe Text)
-> (Address -> Maybe Text -> Address)
-> Lens Address Address (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Text
stateOrProvince :: Maybe Text
$sel:stateOrProvince:Address' :: Address -> Maybe Text
stateOrProvince} -> Maybe Text
stateOrProvince) (\s :: Address
s@Address' {} Maybe Text
a -> Address
s {$sel:stateOrProvince:Address' :: Maybe Text
stateOrProvince = Maybe Text
a} :: Address)

-- | The second line in a street address that a Snow device is to be
-- delivered to.
address_street2 :: Lens.Lens' Address (Prelude.Maybe Prelude.Text)
address_street2 :: (Maybe Text -> f (Maybe Text)) -> Address -> f Address
address_street2 = (Address -> Maybe Text)
-> (Address -> Maybe Text -> Address)
-> Lens Address Address (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Text
street2 :: Maybe Text
$sel:street2:Address' :: Address -> Maybe Text
street2} -> Maybe Text
street2) (\s :: Address
s@Address' {} Maybe Text
a -> Address
s {$sel:street2:Address' :: Maybe Text
street2 = Maybe Text
a} :: Address)

-- | The unique ID for an address.
address_addressId :: Lens.Lens' Address (Prelude.Maybe Prelude.Text)
address_addressId :: (Maybe Text -> f (Maybe Text)) -> Address -> f Address
address_addressId = (Address -> Maybe Text)
-> (Address -> Maybe Text -> Address)
-> Lens Address Address (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Text
addressId :: Maybe Text
$sel:addressId:Address' :: Address -> Maybe Text
addressId} -> Maybe Text
addressId) (\s :: Address
s@Address' {} Maybe Text
a -> Address
s {$sel:addressId:Address' :: Maybe Text
addressId = Maybe Text
a} :: Address)

-- | The city in an address that a Snow device is to be delivered to.
address_city :: Lens.Lens' Address (Prelude.Maybe Prelude.Text)
address_city :: (Maybe Text -> f (Maybe Text)) -> Address -> f Address
address_city = (Address -> Maybe Text)
-> (Address -> Maybe Text -> Address)
-> Lens Address Address (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Text
city :: Maybe Text
$sel:city:Address' :: Address -> Maybe Text
city} -> Maybe Text
city) (\s :: Address
s@Address' {} Maybe Text
a -> Address
s {$sel:city:Address' :: Maybe Text
city = Maybe Text
a} :: Address)

-- | The phone number associated with an address that a Snow device is to be
-- delivered to.
address_phoneNumber :: Lens.Lens' Address (Prelude.Maybe Prelude.Text)
address_phoneNumber :: (Maybe Text -> f (Maybe Text)) -> Address -> f Address
address_phoneNumber = (Address -> Maybe Text)
-> (Address -> Maybe Text -> Address)
-> Lens Address Address (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Text
phoneNumber :: Maybe Text
$sel:phoneNumber:Address' :: Address -> Maybe Text
phoneNumber} -> Maybe Text
phoneNumber) (\s :: Address
s@Address' {} Maybe Text
a -> Address
s {$sel:phoneNumber:Address' :: Maybe Text
phoneNumber = Maybe Text
a} :: Address)

-- | The name of the company to receive a Snow device at an address.
address_company :: Lens.Lens' Address (Prelude.Maybe Prelude.Text)
address_company :: (Maybe Text -> f (Maybe Text)) -> Address -> f Address
address_company = (Address -> Maybe Text)
-> (Address -> Maybe Text -> Address)
-> Lens Address Address (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Text
company :: Maybe Text
$sel:company:Address' :: Address -> Maybe Text
company} -> Maybe Text
company) (\s :: Address
s@Address' {} Maybe Text
a -> Address
s {$sel:company:Address' :: Maybe Text
company = Maybe Text
a} :: Address)

-- | The name of a person to receive a Snow device at an address.
address_name :: Lens.Lens' Address (Prelude.Maybe Prelude.Text)
address_name :: (Maybe Text -> f (Maybe Text)) -> Address -> f Address
address_name = (Address -> Maybe Text)
-> (Address -> Maybe Text -> Address)
-> Lens Address Address (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Text
name :: Maybe Text
$sel:name:Address' :: Address -> Maybe Text
name} -> Maybe Text
name) (\s :: Address
s@Address' {} Maybe Text
a -> Address
s {$sel:name:Address' :: Maybe Text
name = Maybe Text
a} :: Address)

-- | This field is no longer used and the value is ignored.
address_prefectureOrDistrict :: Lens.Lens' Address (Prelude.Maybe Prelude.Text)
address_prefectureOrDistrict :: (Maybe Text -> f (Maybe Text)) -> Address -> f Address
address_prefectureOrDistrict = (Address -> Maybe Text)
-> (Address -> Maybe Text -> Address)
-> Lens Address Address (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Text
prefectureOrDistrict :: Maybe Text
$sel:prefectureOrDistrict:Address' :: Address -> Maybe Text
prefectureOrDistrict} -> Maybe Text
prefectureOrDistrict) (\s :: Address
s@Address' {} Maybe Text
a -> Address
s {$sel:prefectureOrDistrict:Address' :: Maybe Text
prefectureOrDistrict = Maybe Text
a} :: Address)

-- | The first line in a street address that a Snow device is to be delivered
-- to.
address_street1 :: Lens.Lens' Address (Prelude.Maybe Prelude.Text)
address_street1 :: (Maybe Text -> f (Maybe Text)) -> Address -> f Address
address_street1 = (Address -> Maybe Text)
-> (Address -> Maybe Text -> Address)
-> Lens Address Address (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Address' {Maybe Text
street1 :: Maybe Text
$sel:street1:Address' :: Address -> Maybe Text
street1} -> Maybe Text
street1) (\s :: Address
s@Address' {} Maybe Text
a -> Address
s {$sel:street1:Address' :: Maybe Text
street1 = Maybe Text
a} :: Address)

instance Core.FromJSON Address where
  parseJSON :: Value -> Parser Address
parseJSON =
    String -> (Object -> Parser Address) -> Value -> Parser Address
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Address"
      ( \Object
x ->
          Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Address
Address'
            (Maybe Bool
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Address)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Address)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IsRestricted")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Address)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Address)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Street3")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Address)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Address)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Landmark")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Address)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Address)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PostalCode")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Address)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Address)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Country")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Address)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Address)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StateOrProvince")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Address)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Address)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Street2")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Address)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Address)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AddressId")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Address)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Address)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"City")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Address)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Address)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PhoneNumber")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Address)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Address)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Company")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Address)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Address)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
            Parser (Maybe Text -> Maybe Text -> Address)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Address)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PrefectureOrDistrict")
            Parser (Maybe Text -> Address)
-> Parser (Maybe Text) -> Parser Address
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Street1")
      )

instance Prelude.Hashable Address

instance Prelude.NFData Address

instance Core.ToJSON Address where
  toJSON :: Address -> Value
toJSON Address' {Maybe Bool
Maybe Text
street1 :: Maybe Text
prefectureOrDistrict :: Maybe Text
name :: Maybe Text
company :: Maybe Text
phoneNumber :: Maybe Text
city :: Maybe Text
addressId :: Maybe Text
street2 :: Maybe Text
stateOrProvince :: Maybe Text
country :: Maybe Text
postalCode :: Maybe Text
landmark :: Maybe Text
street3 :: Maybe Text
isRestricted :: Maybe Bool
$sel:street1:Address' :: Address -> Maybe Text
$sel:prefectureOrDistrict:Address' :: Address -> Maybe Text
$sel:name:Address' :: Address -> Maybe Text
$sel:company:Address' :: Address -> Maybe Text
$sel:phoneNumber:Address' :: Address -> Maybe Text
$sel:city:Address' :: Address -> Maybe Text
$sel:addressId:Address' :: Address -> Maybe Text
$sel:street2:Address' :: Address -> Maybe Text
$sel:stateOrProvince:Address' :: Address -> Maybe Text
$sel:country:Address' :: Address -> Maybe Text
$sel:postalCode:Address' :: Address -> Maybe Text
$sel:landmark:Address' :: Address -> Maybe Text
$sel:street3:Address' :: Address -> Maybe Text
$sel:isRestricted:Address' :: Address -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"IsRestricted" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
isRestricted,
            (Text
"Street3" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
street3,
            (Text
"Landmark" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
landmark,
            (Text
"PostalCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
postalCode,
            (Text
"Country" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
country,
            (Text
"StateOrProvince" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
stateOrProvince,
            (Text
"Street2" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
street2,
            (Text
"AddressId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
addressId,
            (Text
"City" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
city,
            (Text
"PhoneNumber" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
phoneNumber,
            (Text
"Company" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
company,
            (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Text
"PrefectureOrDistrict" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
prefectureOrDistrict,
            (Text
"Street1" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
street1
          ]
      )