-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from czechboy0/hd/bitbucket_entities
Most BitBucket entities
- Loading branch information
Showing
13 changed files
with
938 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// BitBucketComment.swift | ||
// Buildasaur | ||
// | ||
// Created by Honza Dvorsky on 1/27/16. | ||
// Copyright © 2016 Honza Dvorsky. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class BitBucketComment: BitBucketEntity, CommentType { | ||
|
||
let body: String | ||
|
||
required init(json: NSDictionary) { | ||
|
||
self.body = json | ||
.dictionaryForKey("content") | ||
.stringForKey("raw") | ||
|
||
super.init(json: json) | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// | ||
// BitBucketStatus.swift | ||
// Buildasaur | ||
// | ||
// Created by Honza Dvorsky on 1/27/16. | ||
// Copyright © 2016 Honza Dvorsky. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class BitBucketStatus: BitBucketEntity, StatusType { | ||
|
||
enum BitBucketState: String { | ||
case InProgress = "INPROGRESS" | ||
case Success = "SUCCESSFUL" | ||
case Failed = "FAILED" | ||
} | ||
|
||
let bbState: BitBucketState | ||
let key: String | ||
let name: String? | ||
let description: String? | ||
let targetUrl: String? | ||
|
||
required init(json: NSDictionary) { | ||
|
||
self.bbState = BitBucketState(rawValue: json.stringForKey("state"))! | ||
self.key = json.stringForKey("key") | ||
self.name = json.optionalStringForKey("name") | ||
self.description = json.optionalStringForKey("description") | ||
self.targetUrl = json.stringForKey("url") | ||
|
||
super.init(json: json) | ||
} | ||
|
||
init(state: BitBucketState, key: String, name: String?, description: String?, url: String) { | ||
|
||
self.bbState = state | ||
self.key = key | ||
self.name = name | ||
self.description = description | ||
self.targetUrl = url | ||
|
||
super.init() | ||
} | ||
|
||
var state: BuildState { | ||
return self.bbState.toBuildState() | ||
} | ||
|
||
override func dictionarify() -> NSDictionary { | ||
|
||
let dictionary = NSMutableDictionary() | ||
|
||
dictionary["state"] = self.bbState.rawValue | ||
dictionary["key"] = self.key | ||
dictionary.optionallyAddValueForKey(self.description, key: "description") | ||
dictionary.optionallyAddValueForKey(self.name, key: "name") | ||
dictionary.optionallyAddValueForKey(self.targetUrl, key: "url") | ||
|
||
return dictionary.copy() as! NSDictionary | ||
} | ||
} | ||
|
||
extension BitBucketStatus.BitBucketState { | ||
|
||
static func fromBuildState(state: BuildState) -> BitBucketStatus.BitBucketState { | ||
switch state { | ||
case .Success, .NoState: return .Success | ||
case .Pending: return .InProgress | ||
case .Error, .Failure: return .Failed | ||
} | ||
} | ||
|
||
func toBuildState() -> BuildState { | ||
switch self { | ||
case .Success: return .Success | ||
case .InProgress: return .Pending | ||
case .Failed: return .Failure | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.