fix Data.GetStampRallyResponse

fix Data.GetStampRallyResponse

module Data.GetStampRallyResponse (GetStampRallyResponse) where

import Data.Foreign (F, Foreign, readString)
import Data.Foreign.Class (class IsForeign, readProp)
import Data.Foreign.Index (prop)
import Data.Foreign.Null (readNull, unNull)
import Data.Maybe (fromMaybe)
import Data.Show (class Show, show)
import Prelude (($), (<>), bind, pure)

data Detail = Detail { id :: Int
                     , name :: String
                     , value :: String
                     }

instance detailShow :: Show Detail where
  show (Detail { id
               , name
               , value
               }) =
    "(Detail { "
    <> "id: " <> show id <> ", "
    <> "name: " <> show name <> ", "
    <> "value: " <> show value <> " "
    <> "})"

instance detailIsForeign :: IsForeign Detail where
  read v = do
    id <- readProp "id" v
    name <- readProp "name" v
    value <- readProp "value" v
    pure $ Detail { id
                  , name
                  , value
                  }

data GetStampRallyResponse = GetStampRallyResponse
  { id :: String
  , description :: String
  , details :: Array Detail
  , display :: Boolean
  , displayEndDatetime :: String -- DateTimeString
  , displayName :: String
  , displayStartDatetime :: String -- DateTimeString
  , endDatetime :: String -- DateTimeString
  -- , images :: [] -- TODO
  , mapVisible :: Boolean
  , open :: Boolean
  , spotRadiusDefault :: String
  , spotStampByLocationDefault :: Boolean
  , spotStampByQrCodeDefault :: Boolean
  , startDatetime :: String -- DateTimeString
  , tagline :: String
  , themeBackgroundPattern :: Int
  , themeRewardPattern :: Int
  , themeSpotPattern :: Int
  }

instance getStampRallyResponseShow :: Show GetStampRallyResponse where
  show (GetStampRallyResponse { id
                              , details
                              , description
                              , display
                              , displayEndDatetime
                              , displayName
                              , displayStartDatetime
                              , endDatetime
                              , mapVisible
                              , open
                              , spotRadiusDefault
                              , spotStampByLocationDefault
                              , spotStampByQrCodeDefault
                              , startDatetime
                              , tagline
                              , themeBackgroundPattern
                              , themeRewardPattern
                              , themeSpotPattern
                              }) =
    "(GetStampRallyResponse { "
    <> "id: " <> show id <> ", "
    <> "details: " <> show details <> ", "
    <> "description: " <> show description <> ", "
    <> "display: " <> show display <> ", "
    <> "displayEndDatetime: " <> show displayEndDatetime <> ", "
    <> "displayName: " <> show displayName <> ", "
    <> "displayStartDatetime: " <> show displayStartDatetime <> ", "
    <> "endDatetime: " <> show endDatetime <> ", "
    <> "mapVisible: " <> show mapVisible <> ", "
    <> "open: " <> show open <> ", "
    <> "spotRadiusDefault: " <> show spotRadiusDefault <> ", "
    <> "spotStampByLocationDefault: "
      <> show spotStampByLocationDefault
      <> ", "
    <> "spotStampByQrCodeDefault: " <> show spotStampByQrCodeDefault <> ", "
    <> "startDatetime: " <> show startDatetime <> ", "
    <> "tagline: " <> show tagline <> ", "
    <> "themeBackgroundPattern: " <> show themeBackgroundPattern <> ", "
    <> "themeRewardPattern: " <> show themeRewardPattern <> ", "
    <> "themeSpotPattern: " <> show themeSpotPattern <> " "
    <> "})"

readNullProp :: String -> String -> Foreign -> F String
readNullProp p defaultValue o = do
  pv <- prop p o
  ns <- readNull readString pv
  pure $ fromMaybe defaultValue $ unNull ns

instance getStampRallyResponseIsForeign :: IsForeign GetStampRallyResponse where
  read value = do
    id <- readProp "id" value
    details <- readProp "details" value
    description <- readNullProp "description" "" value
    display <- readProp "display" value
    displayEndDatetime <- readProp "displayEndDatetime" value
    displayName <- readProp "displayName" value
    displayStartDatetime <- readProp "displayStartDatetime" value
    endDatetime <- readProp "endDatetime" value
    mapVisible <- readProp "mapVisible" value
    open <- readProp "open" value
    -- TODO: String | Number
    spotRadiusDefault <- readProp "spotRadiusDefault" value
    spotStampByLocationDefault <- readProp "spotStampByLocationDefault" value
    spotStampByQrCodeDefault <- readProp "spotStampByQrCodeDefault" value
    startDatetime <- readProp "startDatetime" value
    tagline <- readNullProp "tagline" "" value
    themeBackgroundPattern <- readProp "themeBackgroundPattern" value
    themeRewardPattern <- readProp "themeRewardPattern" value
    themeSpotPattern <- readProp "themeSpotPattern" value
    pure $ GetStampRallyResponse { id
                                 , details
                                 , description
                                 , display
                                 , displayEndDatetime
                                 , displayName
                                 , displayStartDatetime
                                 , endDatetime
                                 , mapVisible
                                 , open
                                 , spotRadiusDefault
                                 , spotStampByLocationDefault
                                 , spotStampByQrCodeDefault
                                 , startDatetime
                                 , tagline
                                 , themeBackgroundPattern
                                 , themeRewardPattern
                                 , themeSpotPattern
                                 }

module Data.GetStampRallyResponse where

import Data.Foreign (F, Foreign, readString)
import Data.Foreign.Class (class IsForeign, readProp)
import Data.Foreign.Index (prop)
import Data.Foreign.Null (readNull, unNull)
import Data.Maybe (fromMaybe)
import Data.Show (class Show, show)
import Prelude (($), (<>), bind, pure)

data Detail = Detail { id :: Int
                     , name :: String
                     , value :: String
                     }

instance detailShow :: Show Detail where
  show (Detail { id
               , name
               , value
               }) =
    "(Detail { "
    <> "id: " <> show id <> ", "
    <> "name: " <> show name <> ", "
    <> "value: " <> show value <> " "
    <> "})"

instance detailIsForeign :: IsForeign Detail where
  read v = do
    id <- readProp "id" v
    name <- readProp "name" v
    value <- readProp "value" v
    pure $ Detail { id
                  , name
                  , value
                  }

data GetStampRallyResponse = GetStampRallyResponse
  { id :: String
  , description :: String
  , details :: Array Detail
  , display :: Boolean
  , displayEndDatetime :: String -- DateTimeString
  , displayName :: String
  , displayStartDatetime :: String -- DateTimeString
  , endDatetime :: String -- DateTimeString
  -- , images :: [] -- TODO
  , mapVisible :: Boolean
  , open :: Boolean
  , spotRadiusDefault :: Number
  , spotStampByLocationDefault :: Boolean
  , spotStampByQrCodeDefault :: Boolean
  , startDatetime :: String -- DateTimeString
  , tagline :: String
  , themeBackgroundPattern :: Int
  , themeRewardPattern :: Int
  , themeSpotPattern :: Int
  }

instance getStampRallyResponseShow :: Show GetStampRallyResponse where
  show (GetStampRallyResponse { id
                              , details
                              , description
                              , display
                              , displayEndDatetime
                              , displayName
                              , displayStartDatetime
                              , endDatetime
                              , mapVisible
                              , open
                              , spotRadiusDefault
                              , spotStampByLocationDefault
                              , spotStampByQrCodeDefault
                              , startDatetime
                              , tagline
                              , themeBackgroundPattern
                              , themeRewardPattern
                              , themeSpotPattern
                              }) =
    "(GetStampRallyResponse { "
    <> "id: " <> show id <> ", "
    <> "details: " <> show details <> ", "
    <> "description: " <> show description <> ", "
    <> "display: " <> show display <> ", "
    <> "displayEndDatetime: " <> show displayEndDatetime <> ", "
    <> "displayName: " <> show displayName <> ", "
    <> "displayStartDatetime: " <> show displayStartDatetime <> ", "
    <> "endDatetime: " <> show endDatetime <> ", "
    <> "mapVisible: " <> show mapVisible <> ", "
    <> "open: " <> show open <> ", "
    <> "spotRadiusDefault: " <> show spotRadiusDefault <> ", "
    <> "spotStampByLocationDefault: "
      <> show spotStampByLocationDefault
      <> ", "
    <> "spotStampByQrCodeDefault: " <> show spotStampByQrCodeDefault <> ", "
    <> "startDatetime: " <> show startDatetime <> ", "
    <> "tagline: " <> show tagline <> ", "
    <> "themeBackgroundPattern: " <> show themeBackgroundPattern <> ", "
    <> "themeRewardPattern: " <> show themeRewardPattern <> ", "
    <> "themeSpotPattern: " <> show themeSpotPattern <> " "
    <> "})"

readNullProp :: String -> String -> Foreign -> F String
readNullProp p defaultValue o = do
  pv <- prop p o
  ns <- readNull readString pv
  pure $ fromMaybe defaultValue $ unNull ns

instance getStampRallyResponseIsForeign :: IsForeign GetStampRallyResponse where
  read value = do
    id <- readProp "id" value
    details <- readProp "details" value
    description <- readNullProp "description" "" value
    display <- readProp "display" value
    displayEndDatetime <- readProp "displayEndDatetime" value
    displayName <- readProp "displayName" value
    displayStartDatetime <- readProp "displayStartDatetime" value
    endDatetime <- readProp "endDatetime" value
    mapVisible <- readProp "mapVisible" value
    open <- readProp "open" value
    spotRadiusDefault <- readProp "spotRadiusDefault" value
    spotStampByLocationDefault <- readProp "spotStampByLocationDefault" value
    spotStampByQrCodeDefault <- readProp "spotStampByQrCodeDefault" value
    startDatetime <- readProp "startDatetime" value
    tagline <- readNullProp "tagline" "" value
    themeBackgroundPattern <- readProp "themeBackgroundPattern" value
    themeRewardPattern <- readProp "themeRewardPattern" value
    themeSpotPattern <- readProp "themeSpotPattern" value
    pure $ GetStampRallyResponse { id
                                 , details
                                 , description
                                 , display
                                 , displayEndDatetime
                                 , displayName
                                 , displayStartDatetime
                                 , endDatetime
                                 , mapVisible
                                 , open
                                 , spotRadiusDefault
                                 , spotStampByLocationDefault
                                 , spotStampByQrCodeDefault
                                 , startDatetime
                                 , tagline
                                 , themeBackgroundPattern
                                 , themeRewardPattern
                                 , themeSpotPattern
                                 }


Add charCodeAt

Add charCodeAt

module Data.String where

foreign import charAt
  "function charAt(i) {\
  \  return function(s) {\
  \    return s.charAt(i); \
  \  };\
  \}" :: Number -> String -> String

foreign import charCodeAt
  "function charCodeAt(i) {\
  \  return function(s) {\
  \    return s.charCodeAt(i); \
  \  };\
  \}" :: Number -> String -> Number

foreign import fromCharCode
  "function fromCharCode(n) {\
  \  return String.fromCharCode(n);\
  \}" :: Number -> String

foreign import indexOf
  "function indexOf(s1) {\
  \  return function(s2) {\
  \    return s1.indexOf(s2);\
  \  }; \
  \}" :: String -> String -> Number

foreign import lastIndexOf
  "function lastIndexOf(s1) {\
  \  return function(s2) {\
  \    return s1.lastIndexOf(s2);\
  \  };\
  \}" :: String -> String -> Number

foreign import length
  "function length(s) {\
  \  return s.length;\
  \}" :: String -> Number

foreign import localeCompare
  "function localeCompare(s1) {\
  \  return function(s2) {\
  \    return s1.localeCompare(s2);\
  \  };\
  \}" :: String -> String -> Number

foreign import replace
  "function replace(s1) {\
  \  return function(s2) {\
  \    return function(s3) {\
  \      return s3.replace(s1, s2);\
  \    };\
  \  };\
  \}" :: String -> String -> String -> String

foreign import slice
  "function slice(st) {\
  \  return function(e) {\
  \    return function(s) {\
  \      return s.slice(st, e);\
  \    };\
  \  };\
  \}" :: Number -> Number -> String -> String

foreign import split
  "function split(sep) {\
  \  return function(s) {\
  \    return s.split(sep);\
  \  };\
  \}" :: String -> String -> [String]

foreign import substr
  "function substr(n1) {\
  \  return function(n2) {\
  \    return function(s) {\
  \      return s.substr(n1, n2);\
  \    };\
  \  };\
  \}" :: Number -> Number -> String -> String

foreign import substring
  "function substring(n1) {\
  \  return function(n2) {\
  \    return function(s) {\
  \      return s.substring(n1, n2);\
  \    };\
  \  };\
  \}" :: Number -> Number -> String -> String

foreign import toLower
  "function toLower(s) {\
  \  return s.toLowerCase();\
  \}" :: String -> String

foreign import toUpper
  "function toUpper(s) {\
  \  return s.toUpperCase();\
  \}" :: String -> String

foreign import trim
  "function trim(s) {\
  \  return s.trim();\
  \}" :: String -> String

foreign import joinWith
  "function joinWith (l) {\
  \  return function (s) {\
  \    return l.join(s);\
  \  };\
  \}" :: [String] -> String -> String

module Data.String where

foreign import charAt
  "function charAt(i) {\
  \  return function(s) {\
  \    return s.charAt(i); \
  \  };\
  \}" :: Number -> String -> String

foreign import fromCharCode
  "function fromCharCode(n) {\
  \  return String.fromCharCode(n);\
  \}" :: Number -> String

foreign import indexOf
  "function indexOf(s1) {\
  \  return function(s2) {\
  \    return s1.indexOf(s2);\
  \  }; \
  \}" :: String -> String -> Number

foreign import lastIndexOf
  "function lastIndexOf(s1) {\
  \  return function(s2) {\
  \    return s1.lastIndexOf(s2);\
  \  };\
  \}" :: String -> String -> Number

foreign import length
  "function length(s) {\
  \  return s.length;\
  \}" :: String -> Number

foreign import localeCompare
  "function localeCompare(s1) {\
  \  return function(s2) {\
  \    return s1.localeCompare(s2);\
  \  };\
  \}" :: String -> String -> Number

foreign import replace
  "function replace(s1) {\
  \  return function(s2) {\
  \    return function(s3) {\
  \      return s3.replace(s1, s2);\
  \    };\
  \  };\
  \}" :: String -> String -> String -> String

foreign import slice
  "function slice(st) {\
  \  return function(e) {\
  \    return function(s) {\
  \      return s.slice(st, e);\
  \    };\
  \  };\
  \}" :: Number -> Number -> String -> String

foreign import split
  "function split(sep) {\
  \  return function(s) {\
  \    return s.split(sep);\
  \  };\
  \}" :: String -> String -> [String]

foreign import substr
  "function substr(n1) {\
  \  return function(n2) {\
  \    return function(s) {\
  \      return s.substr(n1, n2);\
  \    };\
  \  };\
  \}" :: Number -> Number -> String -> String

foreign import substring
  "function substring(n1) {\
  \  return function(n2) {\
  \    return function(s) {\
  \      return s.substring(n1, n2);\
  \    };\
  \  };\
  \}" :: Number -> Number -> String -> String

foreign import toLower
  "function toLower(s) {\
  \  return s.toLowerCase();\
  \}" :: String -> String

foreign import toUpper
  "function toUpper(s) {\
  \  return s.toUpperCase();\
  \}" :: String -> String

foreign import trim
  "function trim(s) {\
  \  return s.trim();\
  \}" :: String -> String

foreign import joinWith
  "function joinWith (l) {\
  \  return function (s) {\
  \    return l.join(s);\
  \  };\
  \}" :: [String] -> String -> String