GithubHelp home page GithubHelp logo

mpashnyov / swift-api-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from schedjoules/swift-api-client

0.0 0.0 0.0 202 KB

An client for the SchedJoules API in Swift

License: MIT License

Swift 99.22% Ruby 0.78%

swift-api-client's Introduction

Swift API Client

This repository contains the API client written in Swift, which is also used by our Swift SDK. Versions 0.8.0+ don't use any external libraries, in order to give our users complete freedom on their pick for Networking solutions.

Usage

Currently, we support queries to retrieve a single page by an identifer, a localized home page and to search pages.

Making a request

To send a request (query in our case), first initialize an instance of SchedJoulesApiClient with your API access token.

let apiClient = SchedJoulesApiClient(accessToken: "YOUR_API_ACCESS_TOKEN")

After you have an instance, use the execute function to execute a query.

apiClient.execute(query: HomePageQuery(), completion: { result in
            switch result {
            case let .success(page):
                // Do something with the retreived page object
            case let .failure(apiError):
                print(apiError)
            }
        })

The execute function uses a completion handler which returns a [Result] type. Use a switch statement to deconstruct the result.

Models

The Api Client also includes model classes. These all conform to the Decodable protocol and can be decoded from JSON data.

Legacy

If you want to use the latest version supported that includes Alamofire and Result you can point your pod file to the legacy-0.7.8 branch. ``pod 'SchedJoulesApiClient', :git => 'https://github.com/schedjoules/swift-api-client.git', :branch => 'legacy-0.7.8'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.