Skip to content

Instantly share code, notes, and snippets.

@zkessin
Created January 11, 2016 12:40
Show Gist options
  • Save zkessin/9658e2e4091db66d466a to your computer and use it in GitHub Desktop.
Save zkessin/9658e2e4091db66d466a to your computer and use it in GitHub Desktop.
loadData : CRMBox.Crm -> ModelEnc -> ( CrmData, Effects.Effects Action )
loadData crm data =
case crm of
CRMBox.Streak ->
let
streak =
Result.withDefault { apiKey = "", currentCrmAction = "", pipeline = "" }
<| Json.Decode.decodeValue loadStreakData data.crmData
( sdata, action ) =
Streak.init streak.currentCrmAction streak.apiKey streak.pipeline
in
( StreakModel sdata
, Effects.map CrmDispatch.StreakAction action
)
CRMBox.Zoho ->
let
zoho =
Result.withDefault { token = "", currentCrmAction = "" }
<| Json.Decode.decodeValue loadZohoData data.crmData
( zdata, action ) =
Zoho.init zoho.currentCrmAction zoho.token
in
( ZohoModel zdata
, Effects.map CrmDispatch.ZohoAction action
)
loadStreakData : Json.Decode.Decoder StreakRawModel
loadStreakData =
object3
StreakRawModel
("currentCrmAction" := string)
("apiKey" := string)
("pipeline" := string)
loadZohoData : Json.Decode.Decoder ZohoRawModel
loadZohoData =
object2
ZohoRawModel
("currentCrmAction" := string)
("token" := string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment