Skip to content

Commit

Permalink
Merge pull request #9 from venmo/addCaseFieldAPI
Browse files Browse the repository at this point in the history
Added support to create new CaseField's over the API.
  • Loading branch information
dgallagher-venmo authored Oct 25, 2018
2 parents b9c2552 + a47550f commit 994d813
Show file tree
Hide file tree
Showing 32 changed files with 4,625 additions and 252 deletions.
2 changes: 1 addition & 1 deletion Example/Cartfile.private
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "venmo/QuizTrain" ~> 1.2.0
github "venmo/QuizTrain" ~> 1.2.1
2 changes: 1 addition & 1 deletion Example/Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "venmo/QuizTrain" "v1.2.0"
github "venmo/QuizTrain" "v1.2.1"
192 changes: 186 additions & 6 deletions QuizTrain.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -23,6 +22,41 @@
BlueprintName = "QuizTrainTests-iOS"
ReferencedContainer = "container:QuizTrain.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "ObjectAPITests/testAddCheckboxCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddDateCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddDropdownCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddIntegerCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddMilestoneCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddMultiselectCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddStepsCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddStringCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddTextCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddURLCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddUserCaseField()">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
<AdditionalOptions>
Expand All @@ -32,7 +66,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -23,6 +22,41 @@
BlueprintName = "QuizTrainTests-macOS"
ReferencedContainer = "container:QuizTrain.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "ObjectAPITests/testAddCheckboxCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddDateCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddDropdownCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddIntegerCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddMilestoneCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddMultiselectCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddStepsCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddStringCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddTextCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddURLCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddUserCaseField()">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
<AdditionalOptions>
Expand All @@ -32,7 +66,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -23,6 +22,41 @@
BlueprintName = "QuizTrainTests-tvOS"
ReferencedContainer = "container:QuizTrain.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "ObjectAPITests/testAddCheckboxCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddDateCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddDropdownCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddIntegerCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddMilestoneCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddMultiselectCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddStepsCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddStringCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddTextCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddURLCaseField()">
</Test>
<Test
Identifier = "ObjectAPITests/testAddUserCaseField()">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
<AdditionalOptions>
Expand All @@ -32,7 +66,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion QuizTrain/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.1.1</string>
<string>1.2.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
25 changes: 23 additions & 2 deletions QuizTrain/Models/CaseField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,29 @@ extension CaseField: JSONDeserializable {

init?(json: JSONDictionary) {

guard let configsJson = json[JSONKeys.configs.rawValue] as? [JSONDictionary],
let configs: [Config] = CaseField.deserialized(configsJson),
/*
The formatting of JSONKeys.configs returned by the API differs:

- Get requests return a [JSONDictionary].
- Add requests return a String which can be converted into a
[JSONDictionary].
*/
let configsJson: [JSONDictionary]
if let jsonArray = json[JSONKeys.configs.rawValue] as? [JSONDictionary] {
configsJson = jsonArray
} else if let jsonString = json[JSONKeys.configs.rawValue] as? String {
do {
guard let data = jsonString.data(using: .utf8) else { return nil }
guard let jsonObject = try JSONSerialization.jsonObject(with: data) as? [JSONDictionary] else { return nil }
configsJson = jsonObject
} catch {
return nil
}
} else {
return nil
}

guard let configs: [Config] = CaseField.deserialized(configsJson),
let displayOrder = json[JSONKeys.displayOrder.rawValue] as? Int,
let id = json[JSONKeys.id.rawValue] as? Id,
let includeAll = json[JSONKeys.includeAll.rawValue] as? Bool,
Expand Down
7 changes: 7 additions & 0 deletions QuizTrain/Network/API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ final public class API {

// MARK: - Case Fields

/*
http://docs.gurock.com/testrail-api2/reference-cases-fields#add_case_field
*/
@discardableResult public func addCaseField(data: Data, completionHandler: @escaping (RequestOutcome) -> Void) -> URLSessionDataTask {
return post("add_case_field", data: data, completionHandler: completionHandler)
}

/*
http://docs.gurock.com/testrail-api2/reference-cases-fields#get_case_fields
*/
Expand Down
Loading

0 comments on commit 994d813

Please sign in to comment.