Skip to content

Commit

Permalink
NetSuite: more fields nullable for inserts and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
achlipala committed Jul 25, 2022
1 parent cc21cae commit d71cfa8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
6 changes: 4 additions & 2 deletions examples/netSuiteDemo.ur
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ structure C' = N.Table(struct
val rjsons = {}
end)

val optionify = @@mp [ident] [option] (fn [t] => Some)

fun create r =
C'.insert (NetSuite.values r);
C'.insert (NetSuite.values (optionify r));
return <xml><body>OK.</body></xml>

fun update id r =
C'.update id (NetSuite.values r);
C'.update id (NetSuite.values (optionify r));
return <xml><body>OK.</body></xml>

fun edit id =
Expand Down
16 changes: 5 additions & 11 deletions src/ur/netSuite.ur
Original file line number Diff line number Diff line change
Expand Up @@ -208,22 +208,16 @@ fun vproj2 [t1 ::: Type] [t ::: Type] [r ::: {{Type}}] (fl : folder r) (fls : $(
fl fls r)

type values (ts :: {Type}) = {
Basic : $(map (fn _ => string) ts) -> $(map json ts) -> string,
Composite : [[Attributes] ~ ts] => $(map (fn _ => string) ts) -> $(map json ts) -> string (* type *) -> string
Basic : $(map (fn _ => string) ts) -> $(map json ts) -> string
}

fun values [chosen ::: {Type}] [unchosen ::: {Type}] [chosen ~ unchosen]
(fl : folder chosen) (r : $chosen) = {
(fl : folder chosen) (r : $(map option chosen)) = {
Basic = fn (labels : $(map (fn _ => string) (chosen ++ unchosen)))
(jsons : $(map json (chosen ++ unchosen))) =>
@toJson (@json_record fl (jsons --- _) (labels --- _)) r,
Composite = fn [[Attributes] ~ (chosen ++ unchosen)]
(labels : $(map (fn _ => string) (chosen ++ unchosen)))
(jsons : $(map json (chosen ++ unchosen))) ty =>
@toJson (@json_record (@Folder.cons [#Attributes] [_] ! fl)
(jsons --- _ ++ {Attributes = json_record {Typ = "type"}})
(labels --- _ ++ {Attributes = "attributes"}))
(r ++ {Attributes = {Typ = ty}})
@toJson (@json_record (@Folder.mp fl)
(@mp [json] [fn t => json (option t)] (fn [t] => @json_option) fl (jsons --- _))
(labels --- _)) (r --- _)
}

type query_request = {
Expand Down
2 changes: 1 addition & 1 deletion src/ur/netSuite.urs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ val orderByDesc : nm :: Name -> t ::: Type -> r ::: {Type} -> rts ::: {{Type}} -

con values :: {Type} -> Type
val values : chosen ::: {Type} -> unchosen ::: {Type} -> [chosen ~ unchosen]
=> folder chosen -> $chosen -> values (chosen ++ unchosen)
=> folder chosen -> $(map option chosen) -> values (chosen ++ unchosen)

functor Make(M : sig
val token : transaction (option string)
Expand Down

0 comments on commit d71cfa8

Please sign in to comment.