Skip to content

Commit

Permalink
Merge pull request #6 from IanKeen/Models-cleanup
Browse files Browse the repository at this point in the history
Models cleanup
  • Loading branch information
IanKeen committed Jun 18, 2016
2 parents be8669f + 348ebc3 commit bb1fc07
Show file tree
Hide file tree
Showing 80 changed files with 621 additions and 314 deletions.
2 changes: 1 addition & 1 deletion Sources/App/Services/HelloBot.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// HelloBot.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 4/06/2016.
//
Expand Down
2 changes: 1 addition & 1 deletion Sources/App/Services/KarmaBot.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// KarmaBot.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 21/05/2016.
// Copyright © 2016 Mustard. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Sources/App/main.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// main.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 28/05/2016.
// Copyright © 2016 Mustard. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bot/Adaptors/MessageAdaptor.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// MessageAdaptor.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 21/05/2016.
// Copyright © 2016 Mustard. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bot/Builders/SlackMessageBuilder+Operators.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SlackMessageBuilder+Operators.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 6/06/2016.
//
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bot/Builders/SlackMessageBuilder.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SlackMessageBuilder.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 6/06/2016.
//
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bot/Services/Storage/MemoryStorage.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// MemoryStorage.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 24/05/2016.
// Copyright © 2016 Mustard. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bot/Services/Storage/PlistStorage.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// PlistStorage.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 23/05/2016.
// Copyright © 2016 Mustard. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bot/Services/Storage/Storage.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Storage.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 23/05/2016.
// Copyright © 2016 Mustard. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bot/SlackBot+API.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SlackBot+API.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 19/05/2016.
// Copyright © 2016 Mustard. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bot/SlackBot+Config.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SlackBot+Config.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 19/05/2016.
// Copyright © 2016 Mustard. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bot/SlackBot+Convenience.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SlackBot+Convenience.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 7/06/2016.
//
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bot/SlackBot+Interaction.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SlackBot+Interaction.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 21/05/2016.
// Copyright © 2016 Mustard. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bot/SlackBot.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SlackBot.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 19/05/2016.
// Copyright © 2016 Mustard. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Common/Box.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Box.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 22/05/2016.
// Copyright © 2016 Mustard. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Common/Dictionary+Extensions.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Dictionary+Extensions.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 11/05/2016.
// Copyright © 2016 Mustard. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Common/Int+Extensions.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Int+Extensions.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 8/06/2016.
//
Expand Down
2 changes: 1 addition & 1 deletion Sources/Common/JSON+KeyPath.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// JSON+KeyPath.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 8/06/2016.
//
Expand Down
2 changes: 1 addition & 1 deletion Sources/Common/Sequence+Extensions.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Sequence+Extensions.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 10/06/2016.
//
Expand Down
12 changes: 1 addition & 11 deletions Sources/Models/BotUser.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// BotUser.swift
// Chameleon
// Chameleon
//
// Created by Ian Keen on 20/05/2016.
// Copyright © 2016 Mustard. All rights reserved.
Expand All @@ -10,13 +10,3 @@ public struct BotUser {
public let id: String
public let name: String
}

extension BotUser: SlackModelType {
public static func make(builder: SlackModelBuilder) throws -> BotUser {
return try tryMake(BotUser(
id: try builder.property("id"),
name: try builder.property("name")
)
)
}
}
17 changes: 17 additions & 0 deletions Sources/Models/Builders/BotUser+Builder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// BotUser+Builder.swift
// Chameleon
//
// Created by Ian Keen on 15/06/2016.
//
//

extension BotUser: SlackModelType {
public static func make(builder: SlackModelBuilder) throws -> BotUser {
return try tryMake(BotUser(
id: try builder.property("id"),
name: try builder.property("name")
)
)
}
}
31 changes: 31 additions & 0 deletions Sources/Models/Builders/Channel+Builder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Channel+Builder.swift
// Chameleon
//
// Created by Ian Keen on 15/06/2016.
//
//

extension Channel: SlackModelType {
public static func make(builder: SlackModelBuilder) throws -> Channel {
return try tryMake(Channel(
id: try builder.property("id"),
name: try builder.property("name"),
created: try builder.property("created"),
creator: try builder.slackModel("creator"),
is_channel: builder.property("is_channel"),
is_general: builder.property("is_general"),
is_archived: builder.property("is_archived"),
is_member: builder.property("is_member"),
members: try builder.optionalSlackModels("members"),
topic: try builder.optionalProperty("topic"),
purpose: try builder.optionalProperty("purpose"),
last_read: builder.optionalProperty("last_read"),
latest: try builder.optionalProperty("latest"),
unread_count: builder.optionalProperty("unread_count"),
unread_count_display: builder.optionalProperty("unread_count_display")
)
)

}
}
29 changes: 29 additions & 0 deletions Sources/Models/Builders/Group+Builder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Group+Builder.swift
// Chameleon
//
// Created by Ian Keen on 15/06/2016.
//
//

extension Group: SlackModelType {
public static func make(builder: SlackModelBuilder) throws -> Group {
return try tryMake(Group(
id: try builder.property("id"),
name: try builder.property("name"),
created: try builder.property("created"),
creator: try builder.slackModel("creator"),
is_group: builder.property("is_group"),
is_archived: builder.property("is_archived"),
is_mpim: builder.property("is_mpim"),
members: try builder.optionalSlackModels("members"),
topic: try builder.optionalProperty("topic"),
purpose: try builder.optionalProperty("purpose"),
last_read: builder.optionalProperty("last_read"),
latest: try builder.optionalProperty("latest"),
unread_count: builder.optionalProperty("unread_count"),
unread_count_display: builder.optionalProperty("unread_count_display")
)
)
}
}
24 changes: 24 additions & 0 deletions Sources/Models/Builders/IM+Builder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// IM+Builder.swift
// Chameleon
//
// Created by Ian Keen on 15/06/2016.
//
//

extension IM: SlackModelType {
public static func make(builder: SlackModelBuilder) throws -> IM {
return try tryMake(IM(
id: try builder.property("id"),
is_im: builder.property("is_im"),
is_open: builder.property("is_open"),
has_pins: builder.property("has_pins"),
user: try builder.slackModel("user"),
created: builder.property("created"),
is_user_deleted: builder.property("is_user_deleted"),
last_read: builder.property("last_read"),
latest: try builder.optionalProperty("latest")
)
)
}
}
43 changes: 43 additions & 0 deletions Sources/Models/Builders/Message+Builder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// Message+Builder.swift
// Chameleon
//
// Created by Ian Keen on 15/06/2016.
//
//

import Common

extension Message: SlackModelType {
public static func make(builder: SlackModelBuilder) throws -> Message {
return try tryMake(Message(
subtype: builder.optionalProperty("subtype"),
timestamp: try builder.property("ts"),
text: builder.optionalProperty("text"),
channel: FailableBox(try builder.optionalSlackModel("channel")),
user: try builder.optionalSlackModel("user"),
inviter: try builder.optionalSlackModel("inviter"),
bot: try builder.optionalSlackModel("bot_id"),
username: builder.optionalProperty("username"),
icons: builder.optionalProperty("icons"),
hidden: builder.property("hidden"),
deleted_ts: builder.optionalProperty("deleted_ts"),
topic: builder.optionalProperty("topic"),
purpose: builder.optionalProperty("purpose"),
old_name: builder.optionalProperty("old_name"),
name: builder.optionalProperty("name"),
members: try builder.optionalSlackModels("members"),
file: builder.optionalProperty("file"),
upload: builder.property("upload"),
comment: builder.optionalProperty("comment"),
item_type: builder.optionalProperty("item_type"),
item: builder.optionalProperty("item"),
is_starred: builder.property("is_starred"),
pinned_to: FailableBox(try builder.optionalSlackModels("pinned_to")),
reactions: try builder.optionalCollection("reactions"),
edited: try builder.optionalProperty("edited"),
attachments: try builder.optionalCollection("attachments")
)
)
}
}
39 changes: 39 additions & 0 deletions Sources/Models/Builders/Message_Attachment+Builder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Message_Attachment+Builder.swift
// Chameleon
//
// Created by Ian Keen on 15/06/2016.
//
//

extension Message.Attachment: SlackModelType {
public static func make(builder: SlackModelBuilder) throws -> Message.Attachment {
return try tryMake(Message.Attachment(
fallback: try builder.property("fallback"),
color: builder.optionalProperty("color"),
pretext: builder.optionalProperty("pretext"),
author_name: builder.optionalProperty("author_name"),
author_link: builder.optionalProperty("author_link"),
author_icon: builder.optionalProperty("author_icon"),
title: builder.optionalProperty("title"),
title_link: builder.optionalProperty("title_link"),
text: try builder.property("text"),
fields: try builder.optionalCollection("fields"),
from_url: builder.optionalProperty("from_url"),
image_url: builder.optionalProperty("image_url"),
thumb_url: builder.optionalProperty("thumb_url")
)
)
}
}

extension Message.Attachment.Field: SlackModelType {
public static func make(builder: SlackModelBuilder) throws -> Message.Attachment.Field {
return try tryMake(Message.Attachment.Field(
title: try builder.property("title"),
value: try builder.property("value"),
short: builder.property("short")
)
)
}
}
17 changes: 17 additions & 0 deletions Sources/Models/Builders/Message_Edit+Builder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Message_Edit+Builder.swift
// Chameleon
//
// Created by Ian Keen on 15/06/2016.
//
//

extension Message.Edit: SlackModelType {
public static func make(builder: SlackModelBuilder) throws -> Message.Edit {
return try tryMake(Message.Edit(
user: try builder.slackModel("user"),
timestamp: try builder.property("ts")
)
)
}
}

0 comments on commit bb1fc07

Please sign in to comment.