Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Service - optional Configuration to every request #41

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

druzzt
Copy link

@druzzt druzzt commented Nov 7, 2019

The requests are by default using the Configuration, current changes are introducing custom configuration to every request started from API Service Layer.

For example we can now set timeouts to requests from API Service.

Copy link

@MarekKojder MarekKojder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your effort. Couple small issues and this should work.
Because of fact that I have no longer access to this repository I cannot push updates to cocoapods.
Please take a look on my fork: RxSwiftAPI, I've rebuild whole core of library which was causing crashes and memory leaks. Also your changes are already there in APILayer. It's still in development but I'm testing it in my current project and is much more stable than old one.


- Returns: ApiRequest object which allows to follow progress and manage request.
*/
func postFile(from localFileUrl: URL, to destinationUrl: URL, with aditionalHeaders: [ApiHeader]? = nil, inBackground: Bool = true, useProgress: Bool = true, completion: ApiResponseCompletionHandler? = nil) -> ApiRequest {
func postFile(from localFileUrl: URL, to destinationUrl: URL, with aditionalHeaders: [ApiHeader]? = nil, inBackground: Bool = true, useProgress: Bool = true, configuration: ApiService.Configuration = ApiService.Configuration.foreground, completion: ApiResponseCompletionHandler? = nil) -> ApiRequest {
let configuration: Configuration = inBackground ? .background : .foreground

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without removing this line, configuration from method parameter won't be used 😉.
Also inserting configuration as a parameter IMO inBackground is no longer needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true! In real i didn't dig that deep, it was just mechanical expansion of every method that had something to do with ApiRequest. Thank you for noticing! Hours of debugging in the future saved! 🥇

The parameter inBackground indeed is not needed when combined with the other


- Returns: ApiRequest object which allows to follow progress and manage request.
*/
func putFile(from localFileUrl: URL, to destinationUrl: URL, with aditionalHeaders: [ApiHeader]? = nil, inBackground: Bool = true, useProgress: Bool = true, completion: ApiResponseCompletionHandler? = nil) -> ApiRequest {
func putFile(from localFileUrl: URL, to destinationUrl: URL, with aditionalHeaders: [ApiHeader]? = nil, inBackground: Bool = true, useProgress: Bool = true, configuration: ApiService.Configuration = ApiService.Configuration.foreground, completion: ApiResponseCompletionHandler? = nil) -> ApiRequest {
let configuration: Configuration = inBackground ? .background : .foreground

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same, here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏅


- Returns: ApiRequest object which allows to follow progress and manage request.
*/
func patchFile(from localFileUrl: URL, to destinationUrl: URL, with aditionalHeaders: [ApiHeader]? = nil, inBackground: Bool = true, useProgress: Bool = true, completion: ApiResponseCompletionHandler? = nil) -> ApiRequest {
func patchFile(from localFileUrl: URL, to destinationUrl: URL, with aditionalHeaders: [ApiHeader]? = nil, inBackground: Bool = true, useProgress: Bool = true, configuration: ApiService.Configuration = ApiService.Configuration.foreground, completion: ApiResponseCompletionHandler? = nil) -> ApiRequest {
let configuration: Configuration = inBackground ? .background : .foreground

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎖

Copy link
Author

@druzzt druzzt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your effort. Couple small issues and this should work.
Because of fact that I have no longer access to this repository I cannot push updates to cocoapods.
Please take a look on my fork: RxSwiftAPI, I've rebuild whole core of library which was causing crashes and memory leaks. Also your changes are already there in APILayer. It's still in development but I'm testing it in my current project and is much more stable than old one.

Is it possible to reach you somehow? Please check contact info in my bio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants