-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
183 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module Equinox.Cli.Clients | ||
module Equinox.Cli.StoreClient | ||
|
||
open Domain | ||
open Equinox.Cli.Infrastructure | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module Equinox.Cli.TodoClient | ||
|
||
open Domain | ||
open Equinox.Cli.Infrastructure | ||
open System.Net | ||
open System.Net.Http | ||
open System | ||
|
||
type Todo = { id: int; url: string; order: int; title: string; completed: bool } | ||
|
||
type Session(client: HttpClient, clientId: ClientId) = | ||
|
||
member __.Send(req : HttpRequestMessage) : Async<HttpResponseMessage> = | ||
let req = req |> HttpReq.withHeader "COMPLETELY_INSECURE_CLIENT_ID" clientId.Value | ||
client.Send(req) | ||
|
||
type TodosClient(session: Session) = | ||
|
||
let basePath = "/todos" | ||
|
||
member __.List() : Async<Todo[]> = async { | ||
let request = HttpReq.get () |> HttpReq.withPath basePath | ||
let! response = session.Send request | ||
return! response |> HttpRes.deserializeOkJsonNet<Todo[]> | ||
} | ||
|
||
member __.Add(x: Todo) = async { | ||
let request = HttpReq.post () |> HttpReq.withPath basePath |> HttpReq.withJsonNet x | ||
let! response = session.Send request | ||
return! response |> HttpRes.deserializeOkJsonNet<Todo> | ||
} | ||
|
||
member __.Update(x: Todo)= async { | ||
let request = HttpReq.patch () |> HttpReq.withUri (Uri x.url) |> HttpReq.withJsonNet x | ||
let! response = session.Send request | ||
return! response |> HttpRes.deserializeOkJsonNet<Todo> | ||
} | ||
|
||
member __.Clear() : Async<unit> = async { | ||
let request = HttpReq.delete () |> HttpReq.withPath basePath | ||
let! response = session.Send request | ||
return! response.EnsureStatusCode(HttpStatusCode.NoContent) | ||
} | ||
|
||
type Session with | ||
|
||
member session.Todos = TodosClient session |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.