• Stars
    star
    31
  • Rank 820,005 (Top 17 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ“ก GoodNetworking is an iOS library written in Swift that simplifies HTTP networking by using GRSession and Encodable/DataRequest extensions. It supports latest Swift and all iOS devices, making it a powerful solution for managing network interactions and data encoding/decoding. The library is easy to install with SPM.

Logo

GoodNetworking

iOS Version Swift Version Supported devices Contains Test Dependency Manager

Handles Swift HTTP networking with the use of various tools such as GRSession, as well as extensions of Encodable and DataRequest. The GRSession provides a powerful and flexible mechanism for managing HTTP sessions, enabling developers to easily handle complex network interactions. Extensions of Encodable and DataRequest provide added functionality for encoding and decoding data, making it easier to handle data transfer between the application and remote servers.

Documentation

Check out GoodNetworking documentation here

Installation

Swift Package Manager

Create a Package.swift file and add the package dependency into the dependencies list. Or to integrate without package.swift add it through the Xcode add package interface.

import PackageDescription

let package = Package(
    name: "SampleProject",
    dependencies: [
        .package(url: "https://github.com/GoodRequest/GoodNetworking" from: "addVersion")
    ]
)

Usage

Define two enums:

  • one for the base API address called ApiServer
  • one that follows the Endpoint protocol, more information here

Create a RequestManager using GRSession

import GoodNetworking
import Combine

enum ApiServer: String {

    case baseURL = "https://api.users.com"

}

enum RequestEndpoint: GREndpointManager {

    // MARK: - User Profile
    
    case userProfile
    
    var path: String { "/user/details/profile" }
    
    var method: HTTPMethod { .get }
    
    var parameters: EndpointParameters? { nil }
    
    var headers: HTTPHeaders? { nil }
    
    var encoding: ParameterEncoding { JSONEncoding.default }

    func asURL(baseURL: String) throws -> URL {
        var url = try baseURL.asURL()
        url.appendPathComponent(path)
        return url
    }

}


class UserRequestManager: UserRequestManagerType {

    // MARK: - Constants

    internal let session: GRSession<RequestEndpoint, ApiServer>

    // MARK: - Initialization

    init(baseURL: String) {
        session = GRSession(
            configuration: .default,
            baseURL: baseURL
        )
    }

    // MARK: - User Profile

    func fetchUserProfile() -> AnyPublisher<ProfileResponse, AFError> {
        return session.request(endpoint: .userProfile)
            .validateToCustomError()
            .goodify()
    }

}

Then inside your viewModel just call

fetchUserProfile()

The result is a publisher so you can continue chaining Combine functions.

License

GoodNetworking is released under the MIT license. See LICENSE for details.

More Repositories

1

GoodPersistence

๐Ÿ’พ GoodPersistence is an iOS library that simplifies caching data in keychain and UserDefaults. Using a property wrapper, it reduces the complexity of implementing caching mechanisms, making it easier for developers to focus on app functionality. Compatible with latest Swift and supports all iOS devices. Easy to install with SPM.
Swift
33
star
2

Temple

๐Ÿ—‚๏ธ This repository provides a guide to creating Xcode templates for iOS boilerplate code to save time and increase creativity in development. It simplifies the process and helps new team members get up to speed. A solution to Xcode's poorly documented templates.
Swift
32
star
3

GoodReactor

โš›๏ธ GoodReactor is a Redux-inspired Reactor framework for iOS developed using Swift. It enables seamless communication between the View Model, View Controller, and Coordinator through state and navigation functions. It ensures no side-effects by interacting with dependencies outside of the Reduce function. Integrate it with using SPM!
Swift
32
star
4

GoodUIKit

๐Ÿ“‘ GoodUIKit is a UIKit extensions library filled with reusable UI snippets for faster and more efficient iOS development. Boost productivity and streamline your workflow with ready-to-use UI components.
Swift
30
star
5

GRProvider

๐Ÿš€UITableView and UICollectionView provider to simplify basic scenarios of showing the data.
Swift
28
star
6

GoodExtensions-iOS

๐Ÿ“‘ GoodExtensions is a collection of useful and frequently used Swift extensions for iOS development, designed to simplify and streamline common tasks.It helps developers write clean and concise code, saving time and effort while boosting productivity. Get access to a wealth of essential tools for iOS development in one convenient library.
Swift
28
star
7

express-joi-to-swagger

Simple tool for generating swagger API documentation from source code.
TypeScript
19
star
8

GoodIOSExtensions

๐Ÿงพ GoodIOSExtensions is a collection of modules extending different aspects of your swift xcode project
Swift
18
star
9

GoodSwiftUI

๐Ÿ“‘ GoodSwiftUI is a comprehensive library filled with reusable SwiftUI snippets for faster and more efficient iOS development. This library offers a wide range of customizable UI components, designed to boost your productivity and streamline your development workflow. Save time and effort by leveraging pre-made, tested, and ready-to-use code.
Swift
17
star
10

AppDebugMode-iOS

๐Ÿ› App Debug Mode ๐Ÿž for iOS. Allows special debug privileges.
Swift
16
star
11

GoodSwift

Some good swift extensions, handfully crafted by GoodRequest team.
Swift
9
star
12

spongly-dapp-public

TypeScript
3
star
13

GoodPagerIndicator

Kotlin
2
star
14

joi-type-extract

Extract type from Joi schema
2
star
15

spongly-contracts

๐Ÿชธ Smart contracts for spongly protocol
TypeScript
2
star
16

BackupBuddy

Simple Bash app for backing up your database or filesystem data.
Shell
2
star
17

GoodCoordinator-iOS

๐Ÿงญ Simplified programmatic navigation in SwiftUI
Swift
2
star
18

Safe

Safe enables sharing confidential information with a limited number of views and overall lifetime.
HTML
2
star
19

test-coverage-push-script

JavaScript
1
star
20

internship_ios

HTML
1
star
21

Zoom

Kotlin optics library for immutable data manipulation
Kotlin
1
star
22

GoodLogger

Swift
1
star
23

joi-messages-extractor

Script for extracting joi messages. Useful for translations.
TypeScript
1
star
24

BackendAssignment-Fitness

TypeScript
1
star
25

clean-s3

snippet for S3 cleaner integrated with bullMQ
TypeScript
1
star