Skip to content

Commit e415046

Browse files
algolia-botfebeckmillotp
committed
feat(specs): add /schedule endpoint (generated)
algolia/api-clients-automation#3350 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Fernando Beck <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent cbe090f commit e415046

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed

Sources/Abtesting/AbtestingClient.swift

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,52 @@ open class AbtestingClient {
495495
)
496496
}
497497

498+
/// - parameter scheduleABTestsRequest: (body)
499+
/// - returns: ScheduleABTestResponse
500+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
501+
open func scheduleABTest(
502+
scheduleABTestsRequest: ScheduleABTestsRequest,
503+
requestOptions: RequestOptions? = nil
504+
) async throws -> ScheduleABTestResponse {
505+
let response: Response<ScheduleABTestResponse> = try await scheduleABTestWithHTTPInfo(
506+
scheduleABTestsRequest: scheduleABTestsRequest,
507+
requestOptions: requestOptions
508+
)
509+
510+
guard let body = response.body else {
511+
throw AlgoliaError.missingData
512+
}
513+
514+
return body
515+
}
516+
517+
// Schedule an A/B test to be started at a later time.
518+
// Required API Key ACLs:
519+
// - editSettings
520+
//
521+
// - parameter scheduleABTestsRequest: (body)
522+
// - returns: RequestBuilder<ScheduleABTestResponse>
523+
524+
open func scheduleABTestWithHTTPInfo(
525+
scheduleABTestsRequest: ScheduleABTestsRequest,
526+
requestOptions userRequestOptions: RequestOptions? = nil
527+
) async throws -> Response<ScheduleABTestResponse> {
528+
let resourcePath = "/2/abtests/schedule"
529+
let body = scheduleABTestsRequest
530+
let queryParameters: [String: Any?]? = nil
531+
532+
let nillableHeaders: [String: Any?]? = nil
533+
534+
let headers = APIHelper.rejectNilHeaders(nillableHeaders)
535+
536+
return try await self.transporter.send(
537+
method: "POST",
538+
path: resourcePath,
539+
data: body,
540+
requestOptions: RequestOptions(headers: headers, queryParameters: queryParameters) + userRequestOptions
541+
)
542+
}
543+
498544
/// - parameter id: (path) Unique A/B test identifier.
499545
/// - returns: ABTestResponse
500546
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on
2+
// https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
import Foundation
5+
#if canImport(Core)
6+
import Core
7+
#endif
8+
9+
public struct ScheduleABTestResponse: Codable, JSONEncodable {
10+
/// Unique scheduled A/B test identifier.
11+
public var abTestScheduleID: Int
12+
13+
public init(abTestScheduleID: Int) {
14+
self.abTestScheduleID = abTestScheduleID
15+
}
16+
17+
public enum CodingKeys: String, CodingKey, CaseIterable {
18+
case abTestScheduleID
19+
}
20+
21+
// Encodable protocol methods
22+
23+
public func encode(to encoder: Encoder) throws {
24+
var container = encoder.container(keyedBy: CodingKeys.self)
25+
try container.encode(self.abTestScheduleID, forKey: .abTestScheduleID)
26+
}
27+
}
28+
29+
extension ScheduleABTestResponse: Equatable {
30+
public static func ==(lhs: ScheduleABTestResponse, rhs: ScheduleABTestResponse) -> Bool {
31+
lhs.abTestScheduleID == rhs.abTestScheduleID
32+
}
33+
}
34+
35+
extension ScheduleABTestResponse: Hashable {
36+
public func hash(into hasher: inout Hasher) {
37+
hasher.combine(self.abTestScheduleID.hashValue)
38+
}
39+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on
2+
// https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
import Foundation
5+
#if canImport(Core)
6+
import Core
7+
#endif
8+
9+
public struct ScheduleABTestsRequest: Codable, JSONEncodable {
10+
/// A/B test name.
11+
public var name: String
12+
/// A/B test variants.
13+
public var variants: [AddABTestsVariant]
14+
/// Date and time when the A/B test is scheduled to start, in RFC 3339 format.
15+
public var scheduledAt: String
16+
/// End date and time of the A/B test, in RFC 3339 format.
17+
public var endAt: String
18+
19+
public init(name: String, variants: [AddABTestsVariant], scheduledAt: String, endAt: String) {
20+
self.name = name
21+
self.variants = variants
22+
self.scheduledAt = scheduledAt
23+
self.endAt = endAt
24+
}
25+
26+
public enum CodingKeys: String, CodingKey, CaseIterable {
27+
case name
28+
case variants
29+
case scheduledAt
30+
case endAt
31+
}
32+
33+
// Encodable protocol methods
34+
35+
public func encode(to encoder: Encoder) throws {
36+
var container = encoder.container(keyedBy: CodingKeys.self)
37+
try container.encode(self.name, forKey: .name)
38+
try container.encode(self.variants, forKey: .variants)
39+
try container.encode(self.scheduledAt, forKey: .scheduledAt)
40+
try container.encode(self.endAt, forKey: .endAt)
41+
}
42+
}
43+
44+
extension ScheduleABTestsRequest: Equatable {
45+
public static func ==(lhs: ScheduleABTestsRequest, rhs: ScheduleABTestsRequest) -> Bool {
46+
lhs.name == rhs.name &&
47+
lhs.variants == rhs.variants &&
48+
lhs.scheduledAt == rhs.scheduledAt &&
49+
lhs.endAt == rhs.endAt
50+
}
51+
}
52+
53+
extension ScheduleABTestsRequest: Hashable {
54+
public func hash(into hasher: inout Hasher) {
55+
hasher.combine(self.name.hashValue)
56+
hasher.combine(self.variants.hashValue)
57+
hasher.combine(self.scheduledAt.hashValue)
58+
hasher.combine(self.endAt.hashValue)
59+
}
60+
}

0 commit comments

Comments
 (0)