Skip to content

Commit

Permalink
Fix #1 Rename parameter to
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Mangel committed May 16, 2019
1 parent c453c18 commit 3566d98
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 38 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
76 changes: 38 additions & 38 deletions src/Fetch.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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>`
Expand All @@ -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
}
Expand All @@ -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
Expand All @@ -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,
[<Inject>] ?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**
///
Expand All @@ -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<Result<'Response,string>>`
Expand All @@ -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
}
Expand All @@ -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
Expand All @@ -120,40 +120,40 @@ type Fetch =
/// **Exceptions**
///
static member tryFetchAs<'Response>(url : string,
?init : RequestProperties list,
?properties : RequestProperties list,
?isCamelCase : bool,
?extra: ExtraCoders,
[<Inject>] ?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,
[<Inject>] ?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,
[<Inject>] ?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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -441,4 +441,4 @@ type Fetch =
RequestProperties.Body body ]
@ defaultArg properties []

Fetch.tryFetchAs(url, responseDecoder, init = properties)
Fetch.tryFetchAs(url, responseDecoder, properties = properties)

0 comments on commit 3566d98

Please sign in to comment.