Skip to content

Auto generated Swift Package to consume Ecobee content

Notifications You must be signed in to change notification settings

ThumbWorks/VaporEcobee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VaporEcobee

This is an api generated from a OpenAPI 3.0 spec with SwagGen using a Vapor specific template.

Operation

Each operation is an extension on Vapor's Client object.

Model

Models that are sent and returned from the API are mutable classes. Each model conforms to Vapor's Content protocol.

Required properties are non optional and non-required are optional

All properties can be passed into the initializer, with required properties being mandatory.

If a model has additionalProperties it will have a subscript to access these by string

Request template

The extension is used to encode, send, and decode the requests. There is a Server.main that uses the default base URL:

func getObject(headers:  HTTPHeaders) -> EventLoopFuture<SomeResponseType> 

The name of the func will be defined by the spec and is a combination of [get|post|put|delete]<pathName>. The return type is an EventLoopFuture<T> where T is the model defined in the Response on the spec.

Making a request

To make a request first initialize a Request and then pass it to makeRequest. The complete closure will be called with an APIResponse

func makeRequest<T>(_ request: APIRequest<T>, behaviours: [RequestBehaviour] = [], queue: DispatchQueue = DispatchQueue.main, complete: @escaping (APIResponse<T>) -> Void) -> Request? {

Example request (that is not neccessarily in this api):

let client: Client
let headers: HTTPHeaders
client.getMyObject(headers)
      .flatMap { object in
         print(object.someCoolObjectProperty)
      }

Encoding and Decoding

Only JSON requests and responses are supported. These are encoded and decoded by JSONEncoder and JSONDecoder respectively, using Swift's Codable apis. There are some options to control how invalid JSON is handled when decoding and these are available as static properties on VaporEcobee:

  • safeOptionalDecoding: Whether to discard any errors when decoding optional properties. Defaults to true.
  • safeArrayDecoding: Whether to remove invalid elements instead of throwing when decoding arrays. Defaults to true.

Dates are encoded and decoded differently according to the swagger date format. They use different DateFormatter's that you can set.

  • date-time
    • DateTime.dateEncodingFormatter: defaults to yyyy-MM-dd'T'HH:mm:ss.Z
    • DateTime.dateDecodingFormatters: an array of date formatters. The first one to decode successfully will be used
  • date
    • DateDay.dateFormatter: defaults to yyyy-MM-dd

Models

  • AccessTokenRequest
  • AccessTokenResponse
  • Runtime
  • Thermostat
  • ThermostatPage
  • ThermostatResponse

Requests

  • VaporEcobee.GetThermostatSummary: GET /thermostatsummary
  • VaporEcobee.Developers
    • RefreshToken: POST /token

About

Auto generated Swift Package to consume Ecobee content

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages