Skip to content

jorjuela33/NGeen

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NGeen

NGeen is a delightful library for swift. It's built based on factory design pattern, extending the powerful high-level networking and database abstractions built into Cocoa.

Choose NGeen for your next project, or migrate over your existing projects—you'll be happy you did!

How To Get Started

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Architecture

Base

  • Constants
    • Constants
  • DataTypes
    • DataTypes
  • Protocols
    • Protocols

Cache

  • DiskCache
    • DiskCache
  • Entity
    • Entity
  • Cache

Model

  • Model

Network

  • Request
    • Request

Query

  • Api
    • ApiQuery
  • DataBase
    • DataBaseQuery

Store

  • Api
    • Config
      • ApiStoreConfiguration
    • Endpoint
      • ApiEndpoint
    • ApiStore
  • DataBase
    • DataBaseStore

Usage

HTTP Request Operation

GET Request

var endPoint: ApiEndpoint = ApiEndpoint(contentType: ContentType.json, httpMethod: HttpMethod.get, path: "resources.json")
ApiStore.defaultStore().setEndpoint(endPoint)
var apiQuery: ApiQuery = ApiStore.defaultStore().createQuery()
apiQuery.read(completionHandler: {(object, error) in
	println("RESPONSE: ", object)
})

POST URL-Form-Encoded Request

var endPoint: ApiEndpoint = ApiEndpoint(contentType: ContentType.urlEnconded, httpMethod: HttpMethod.post, path: "resources.json")
ApiStore.defaultStore().setBodyItem("foo", forKey: "bar")
ApiStore.defaultStore().setEndpoint(endPoint)
var apiQuery: ApiQuery = ApiStore.defaultStore().createQuery()
apiQuery.create(completionHandler: {(object, error) in
	println("RESPONSE: ", object)
})

POST Multi-Part Request

ApiStore.defaultStore().setBodyItem("foo", forKey: "bar")
ApiStore.defaultStore().setFileData(data, forName: "image", fileName: "image.jpg", mimeType: "image/jpg")
var apiQuery: ApiQuery = ApiStore.defaultStore().createQuery()
apiQuery.create(completionHandler: {(object, error) in
	println("RESPONSE: ", object)
})

Request Serialization

var apiStoreConfiguration: ApiStoreConfiguration = ApiStoreConfiguration(headers: headers, host: "example.com", httpProtocol: "http")
var parameters: Dictionary<String, String> = ["foo": "bar", "baz1": "1", "baz2": "2", "baz3": "3"]

Query String Parameter Encoding

Using the Api Store adding a dictionary of items
ApiStore.defaultStore().setPathItems(parameters)
Using the Api Store adding item by item
ApiStore.defaultStore().setQueryItem("foo", forKey: "bar")
ApiStore.defaultStore().setQueryItem("1", forKey: "baz1")
ApiStore.defaultStore().setQueryItem("2", forKey: "baz2")
ApiStore.defaultStore().setQueryItem("3", forKey: "baz3") 
Using the Api Query adding a dictionary of items
apiQuery.setQueryItems(parameters)
Using the Api Query adding item by item
apiQuery.setQueryItem("foo", forKey: "bar")
apiQuery.setQueryItem("1", forKey: "baz1")
apiQuery.setQueryItem("2", forKey: "baz2")
apiQuery.setQueryItem("3", forKey: "baz3")
GET http://example.com?foo=bar&baz1=1&baz2=2&baz3=3

URL Form Parameter Encoding

ApiStore.defaultStore().setBodyItems(parameters)
apiQuery.create(completionHandler: {(object, error) in
	println("RESPONSE: ", object)
})
POST http://example.com/
Content-Type: application/x-www-form-urlencoded

foo=bar&baz1=1&baz2=2&baz3=3

JSON Parameter Encoding

var endPoint: ApiEndpoint =  ApiEndpoint(contentType: ContentType.json, httpMethod: HttpMethod.post, path: "resources.json")
ApiStore.defaultStore().setEndpoint(endPoint)
ApiStore.defaultStore().setBodyItems(parameters)
apiQuery.create(completionHandler: {(object, error) in
	println("RESPONSE: ", object)
})
POST http://example.com/
Content-Type: application/json

{"foo": "bar", "baz": [1,2,3]}

License

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 99.1%
  • Objective-C 0.9%