Skip to content

An iOS library written as part of the interview process with Entersekt. The library provides API's to easily pull in city, mall, and shop info into an app.

Notifications You must be signed in to change notification settings

ryanbrear/GoShoppingSwiftLibrary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

GoShoppingSwift

An iOS library written in Swift 4.2 as part of the interview process with Entersekt. The library provides an easy way to pull in city, mall, and shop info into an iOS app.

Here are some screen shots of a demo app that uses the library.

Simulator Screen Shot - iPhone XR - 2019-04-20 at 07 44 43Simulator Screen Shot - iPhone XR - 2019-04-20 at 07 44 47

Features

  • Written in Swift 4.2
  • Easily pull in info on shopping opportunities in South Africa into your app.
  • Info is grouped by city, mall, and shop.

Requirements

  • iOS 9.0+
  • XCode 9.0+

Installation

  • Download the repo and add it to your project as an embedded binary.

Demo

Usage

  • To use GoShoppingSwift in a file, begin by importing it.
import GoShoppingSwift
  • Utilising the shopping data involves two steps: 1) fetching the latest data from the server, and 2) using the methods outlined below to access subsets of the returned data. While GoShoppingSwift does save the data for offline use, to ensure your app has the latest info you should call the below method when the app comes in the foreground.
  • To fetch the latest data from the server:
GoShoppingDataManager().getLatestData { result in
  switch result {
  case .success
    // use API methods to access updated info here 
  case .error
    // handle failure here
  case .noInternet
    // handle no internet here
  }
}
  • If you are offline you can call this method to loaded the last saved data.
GoShoppingDataManager().getLastSavedDataForOfflineUse()
  • Once you have fetched the latest data you can then call the methods below to access subsets of that data.

  • GoShoppingSwift makes three types available to you: City, Mall, Shop

  • Request a list of all cities. Returns an array of type City:

let allCities = GoShoppingDataManager().allCities()
  • Request a particular city by pasing in the id of that city:
let city = GoShoppingDataManager().cityWithId(10)
let cityName = city.name
  • Request all malls in a city:
// 1st approach
let dataManager = GoShoppingDataManager()
let capeTown = dataManager.cityWithId(10)
var allMallsInCity = dataManager.allMallsIn(capeTown)
// 2nd approach
allMallsInCity = capeTown.allMallsInCity()
  • Request a particular mall in a city:
let mall = GoShoppingDataManager().mallWithId(20)
  • Request a list of all shops in a mall:
// 1st approach
let dataManager = GoShoppingDataManager()
let mall = dataManager.getMallWithId(20)
var allShopsInMall = dataManager.allShopsIn(mall)
// 2nd approach
allShopsInMall = mall.allShopsInMall()
  • Request a particular shop in a mall:
let shop = GoShoppingDataManager().shopWithId(2)
  • Request all the shops in a city:
// 1st approach
let dataManager = GoShoppingDataManager()
let city = dataManager.getCityWithId(10)
var allShopsInCity = dataManager.allShopsIn(city)
// 2nd approach
allShopsInCity = city.allShopsInCity()

Author

Ryan Brear, [email protected]

About

An iOS library written as part of the interview process with Entersekt. The library provides API's to easily pull in city, mall, and shop info into an app.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published