10000 GitHub - MIAkbari/MAFetch
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

MIAkbari/MAFetch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MAFetch

Build iOS GitHub license Platform

  • one
  • Example

    To run the example project, clone the repo, and run Code from the Example directory first.

    Usage

    MAFetch is compatible with the following platforms:

    • iOS
    • AF
    • FetchSettings
    • reachability
    • FetchSession
    • propertyWrapper - Fetch

    Below you can find a sample code of the api usage.

    // MARK: - Welcome
    struct Welcome: Codable {
        let message: Message
        let data: [String]
    }
    
    // MARK: - Message
    struct Message: Codable {
        let status: Int
        let text: String
    }
    
    
    extension APIClient {
        
        @Fetch<Welcome>(BaseURL.defults.base,method:.get)
        static var fetchState: Service<Welcome>
        
        @Fetch<Welcome>(BaseURL.defults.base,method:.post)
        static var fetchStatePost: Service<Welcome>
        
    }

    Simple Add....

    • set Method with Parameters
    • usage set
    extension APIClient {
        
        
        func state(complation:@escaping (Welcome)->Void) {
            APIClient.$fetchState
                .set(path: "/cities/state")
            
            APIClient.fetchState { model in
                complation(model)
            }
        }
        
        
        func postState(id:Int,complation:@escaping (Welcome)->Void) {
            APIClient.$fetchStatePost
                .set(path: "/cities/post/state")
                .set(headers: ["ApplicationJson":"ContentType"])
                .set(parameters: .body(["id":id])) // with URL and Form
            
            APIClient.fetchStatePost { model in
                complation(model)
            }
        }
        
       
        
    }

    ***** Simple *****

    class ViewController: UIViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
            
            self.fetchData()
        }
          
        func fetchData() {
            
            APIClient.share.state { model in
                print(model.data)
            }
            
        }   
    }

    Installation

    MAFetch is available easy use ....

    Author

    MIAkbari, akbari4mb@gmail.com

    License

    MAFetch is available under the MIT license. See the LICENSE file for more info.

    About

    No description or website provided.

    Topics

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published
    0