From 3566d985f3b7ba57da13ce09adce91e6f53325c1 Mon Sep 17 00:00:00 2001 From: Maxime Mangel Date: Thu, 16 May 2019 13:22:58 +0200 Subject: [PATCH] Fix #1 Rename parameter to --- CHANGELOG.md | 6 +++++ src/Fetch.fs | 76 ++++++++++++++++++++++++++-------------------------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 598dec1..ca64795 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased +### Changed + +* Fix #1: Rename `init` parameter to `properties` + + ## 1.0.0-beta-001 - 2019-04-15 ### Added diff --git a/src/Fetch.fs b/src/Fetch.fs index 9fe940a..74cd2a2 100644 --- a/src/Fetch.fs +++ b/src/Fetch.fs @@ -23,7 +23,7 @@ type Fetch = /// **Parameters** /// * `url` - parameter of type `string` - URL to be request /// * `decoder` - parameter of type `Decoder<'Response>` - Decoder applied to the server response - /// * `init` - parameter of type `RequestProperties list option` - Parameters passed to fetch + /// * `properties` - parameter of type `RequestProperties list option` - Parameters passed to fetch /// /// **Output Type** /// * `JS.Promise<'Response>` @@ -33,12 +33,12 @@ type Fetch = /// static member fetchAs<'Response>(url : string, decoder : Decoder<'Response>, - ?init : RequestProperties list) = + ?properties : RequestProperties list) = promise { - let init = defaultArg init [] + let properties = defaultArg properties [] // TODO: Rewrite our own version of `Fetch.fetch` to give better error // ATM, when an error occured we are loosing information like status code, etc. - let! response = Fetch.fetch url init + let! response = Fetch.fetch url properties let! body = response.text() return Decode.unsafeFromString decoder body } @@ -51,7 +51,7 @@ type Fetch = /// /// **Parameters** /// * `url` - parameter of type `string` - URL to be request - /// * `init` - parameter of type `RequestProperties list option` - Parameters passed to fetch + /// * `properties` - parameter of type `RequestProperties list option` - Parameters passed to fetch /// * `isCamelCase` - parameter of type `bool option` - Options passed to Thoth.Json to control JSON keys representation /// * `extra` - parameter of type `ExtraCoders option` - Options passed to Thoth.Json to extends the known coders /// * `responseResolver` - parameter of type `ITypeResolver<'Response> option` - Used by Fable to provide generic type info @@ -63,12 +63,12 @@ type Fetch = /// * `System.Exception` - Contains information explaining why the decoder failed /// static member fetchAs<'Response>(url : string, - ?init : RequestProperties list, + ?properties : RequestProperties list, ?isCamelCase : bool, ?extra: ExtraCoders, [] ?responseResolver: ITypeResolver<'Response>) = let decoder = Decode.Auto.generateDecoderCached<'Response>(?isCamelCase = isCamelCase, ?extra = extra, ?resolver = responseResolver) - Fetch.fetchAs(url, decoder, ?init = init) + Fetch.fetchAs(url, decoder, ?properties = properties) /// **Description** /// @@ -80,7 +80,7 @@ type Fetch = /// **Parameters** /// * `url` - parameter of type `string` - URL to be request /// * `decoder` - parameter of type `Decoder<'Response>` - Decoder applied to the server response - /// * `init` - parameter of type `RequestProperties list option` - Parameters passed to fetch + /// * `properties` - parameter of type `RequestProperties list option` - Parameters passed to fetch /// /// **Output Type** /// * `JS.Promise>` @@ -89,12 +89,12 @@ type Fetch = /// static member tryFetchAs<'Response>(url : string, decoder : Decoder<'Response>, - ?init : RequestProperties list) = + ?properties : RequestProperties list) = promise { - let init = defaultArg init [] + let properties = defaultArg properties [] // TODO: Rewrite our own version of `Fetch.fetch` to give better error // ATM, when an error occured we are loosing information like status code, etc. - let! response = Fetch.fetch url init + let! response = Fetch.fetch url properties let! body = response.text() return Decode.fromString decoder body } @@ -109,7 +109,7 @@ type Fetch = /// /// **Parameters** /// * `url` - parameter of type `string` - URL to be request - /// * `init` - parameter of type `RequestProperties list option` - Parameters passed to fetch + /// * `properties` - parameter of type `RequestProperties list option` - Parameters passed to fetch /// * `isCamelCase` - parameter of type `bool option` - Options passed to Thoth.Json to control JSON keys representation /// * `extra` - parameter of type `ExtraCoders option` - Options passed to Thoth.Json to extends the known coders /// * `responseResolver` - parameter of type `ITypeResolver<'Response> option` - Used by Fable to provide generic type info @@ -120,40 +120,40 @@ type Fetch = /// **Exceptions** /// static member tryFetchAs<'Response>(url : string, - ?init : RequestProperties list, + ?properties : RequestProperties list, ?isCamelCase : bool, ?extra: ExtraCoders, [] ?responseResolver: ITypeResolver<'Response>) = let decoder = Decode.Auto.generateDecoderCached<'Response>(?isCamelCase = isCamelCase, ?extra = extra, ?resolver = responseResolver) - Fetch.tryFetchAs(url, decoder, ?init = init) + Fetch.tryFetchAs(url, decoder, ?properties = properties) /// Alias to `Fetch.fetchAs` static member get<'Response>(url : string, decoder : Decoder<'Response>, - ?init : RequestProperties list) = - Fetch.fetchAs(url, decoder, ?init = init) + ?properties : RequestProperties list) = + Fetch.fetchAs(url, decoder, ?properties = properties) /// Alias to `Fetch.tryFetchAs` static member tryGet<'Response>(url : string, decoder : Decoder<'Response>, - ?init : RequestProperties list) = - Fetch.tryFetchAs(url, decoder, ?init = init) + ?properties : RequestProperties list) = + Fetch.tryFetchAs(url, decoder, ?properties = properties) /// Alias to `Fetch.fetchAs` static member get<'Response>(url : string, - ?init : RequestProperties list, + ?properties : RequestProperties list, ?isCamelCase : bool, ?extra: ExtraCoders, [] ?responseResolver: ITypeResolver<'Response>) = - Fetch.fetchAs(url, ?init = init, ?isCamelCase = isCamelCase, ?extra = extra, ?responseResolver = responseResolver) + Fetch.fetchAs(url, ?properties = properties, ?isCamelCase = isCamelCase, ?extra = extra, ?responseResolver = responseResolver) /// Alias to `Fetch.tryFetchAs` static member tryGet<'Response>(url : string, - ?init : RequestProperties list, + ?properties : RequestProperties list, ?isCamelCase : bool, ?extra: ExtraCoders, [] ?responseResolver: ITypeResolver<'Response>) = - Fetch.tryFetchAs(url, ?init = init, ?isCamelCase = isCamelCase, ?extra = extra, ?responseResolver = responseResolver) + Fetch.tryFetchAs(url, ?properties = properties, ?isCamelCase = isCamelCase, ?extra = extra, ?responseResolver = responseResolver) static member post<'Response>(url : string, data : JsonValue, @@ -165,7 +165,7 @@ type Fetch = RequestProperties.Body (toJsonBody data) ] @ defaultArg properties [] - Fetch.fetchAs(url, decoder, init = properties) + Fetch.fetchAs(url, decoder, properties = properties) static member post<'Data, 'Response>(url : string, data : 'Data, @@ -189,7 +189,7 @@ type Fetch = RequestProperties.Body body ] @ defaultArg properties [] - Fetch.fetchAs(url, responseDecoder, init = properties) + Fetch.fetchAs(url, responseDecoder, properties = properties) static member tryPost<'Response>(url : string, data : JsonValue, @@ -201,7 +201,7 @@ type Fetch = RequestProperties.Body (toJsonBody data) ] @ defaultArg properties [] - Fetch.tryFetchAs(url, decoder, init = properties) + Fetch.tryFetchAs(url, decoder, properties = properties) static member tryPost<'Data, 'Response>(url : string, data : 'Data, @@ -225,7 +225,7 @@ type Fetch = RequestProperties.Body body ] @ defaultArg properties [] - Fetch.tryFetchAs(url, responseDecoder, init = properties) + Fetch.tryFetchAs(url, responseDecoder, properties = properties) static member put<'Response>(url : string, data : JsonValue, @@ -237,7 +237,7 @@ type Fetch = RequestProperties.Body (toJsonBody data) ] @ defaultArg properties [] - Fetch.fetchAs(url, decoder, init = properties) + Fetch.fetchAs(url, decoder, properties = properties) static member put<'Data, 'Response>(url : string, data : 'Data, @@ -261,7 +261,7 @@ type Fetch = RequestProperties.Body body ] @ defaultArg properties [] - Fetch.fetchAs(url, responseDecoder, init = properties) + Fetch.fetchAs(url, responseDecoder, properties = properties) static member tryPut<'Response>(url : string, data : JsonValue, @@ -273,7 +273,7 @@ type Fetch = RequestProperties.Body (toJsonBody data) ] @ defaultArg properties [] - Fetch.tryFetchAs(url, decoder, init = properties) + Fetch.tryFetchAs(url, decoder, properties = properties) static member tryPut<'Data, 'Response>(url : string, data : 'Data, @@ -297,7 +297,7 @@ type Fetch = RequestProperties.Body body ] @ defaultArg properties [] - Fetch.tryFetchAs(url, responseDecoder, init = properties) + Fetch.tryFetchAs(url, responseDecoder, properties = properties) static member patch<'Response>(url : string, data : JsonValue, @@ -309,7 +309,7 @@ type Fetch = RequestProperties.Body (toJsonBody data) ] @ defaultArg properties [] - Fetch.fetchAs(url, decoder, init = properties) + Fetch.fetchAs(url, decoder, properties = properties) static member patch<'Data, 'Response>(url : string, data : 'Data, @@ -333,7 +333,7 @@ type Fetch = RequestProperties.Body body ] @ defaultArg properties [] - Fetch.fetchAs(url, responseDecoder, init = properties) + Fetch.fetchAs(url, responseDecoder, properties = properties) static member tryPatch<'Response>(url : string, data : JsonValue, @@ -345,7 +345,7 @@ type Fetch = RequestProperties.Body (toJsonBody data) ] @ defaultArg properties [] - Fetch.tryFetchAs(url, decoder, init = properties) + Fetch.tryFetchAs(url, decoder, properties = properties) static member tryPatch<'Data, 'Response>(url : string, data : 'Data, @@ -369,7 +369,7 @@ type Fetch = RequestProperties.Body body ] @ defaultArg properties [] - Fetch.tryFetchAs(url, responseDecoder, init = properties) + Fetch.tryFetchAs(url, responseDecoder, properties = properties) static member delete<'Response>(url : string, data : JsonValue, @@ -381,7 +381,7 @@ type Fetch = RequestProperties.Body (toJsonBody data) ] @ defaultArg properties [] - Fetch.fetchAs(url, decoder, init = properties) + Fetch.fetchAs(url, decoder, properties = properties) static member delete<'Data, 'Response>(url : string, data : 'Data, @@ -405,7 +405,7 @@ type Fetch = RequestProperties.Body body ] @ defaultArg properties [] - Fetch.fetchAs(url, responseDecoder, init = properties) + Fetch.fetchAs(url, responseDecoder, properties = properties) static member tryDelete<'Response>(url : string, data : JsonValue, @@ -417,7 +417,7 @@ type Fetch = RequestProperties.Body (toJsonBody data) ] @ defaultArg properties [] - Fetch.tryFetchAs(url, decoder, init = properties) + Fetch.tryFetchAs(url, decoder, properties = properties) static member tryDelete<'Data, 'Response>(url : string, data : 'Data, @@ -441,4 +441,4 @@ type Fetch = RequestProperties.Body body ] @ defaultArg properties [] - Fetch.tryFetchAs(url, responseDecoder, init = properties) + Fetch.tryFetchAs(url, responseDecoder, properties = properties)