Skip to content

Commit

Permalink
feat(specs): add /schedule endpoint (generated)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
3 people committed Aug 20, 2024
1 parent cbe090f commit e415046
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Sources/Abtesting/AbtestingClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,52 @@ open class AbtestingClient {
)
}

/// - parameter scheduleABTestsRequest: (body)
/// - returns: ScheduleABTestResponse
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
open func scheduleABTest(
scheduleABTestsRequest: ScheduleABTestsRequest,
requestOptions: RequestOptions? = nil
) async throws -> ScheduleABTestResponse {
let response: Response<ScheduleABTestResponse> = try await scheduleABTestWithHTTPInfo(
scheduleABTestsRequest: scheduleABTestsRequest,
requestOptions: requestOptions
)

guard let body = response.body else {
throw AlgoliaError.missingData
}

return body
}

// Schedule an A/B test to be started at a later time.
// Required API Key ACLs:
// - editSettings
//
// - parameter scheduleABTestsRequest: (body)
// - returns: RequestBuilder<ScheduleABTestResponse>

open func scheduleABTestWithHTTPInfo(
scheduleABTestsRequest: ScheduleABTestsRequest,
requestOptions userRequestOptions: RequestOptions? = nil
) async throws -> Response<ScheduleABTestResponse> {
let resourcePath = "/2/abtests/schedule"
let body = scheduleABTestsRequest
let queryParameters: [String: Any?]? = nil

let nillableHeaders: [String: Any?]? = nil

let headers = APIHelper.rejectNilHeaders(nillableHeaders)

return try await self.transporter.send(
method: "POST",
path: resourcePath,
data: body,
requestOptions: RequestOptions(headers: headers, queryParameters: queryParameters) + userRequestOptions
)
}

/// - parameter id: (path) Unique A/B test identifier.
/// - returns: ABTestResponse
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
Expand Down
39 changes: 39 additions & 0 deletions Sources/Abtesting/Models/ScheduleABTestResponse.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on
// https://github.com/algolia/api-clients-automation. DO NOT EDIT.

import Foundation
#if canImport(Core)
import Core
#endif

public struct ScheduleABTestResponse: Codable, JSONEncodable {
/// Unique scheduled A/B test identifier.
public var abTestScheduleID: Int

public init(abTestScheduleID: Int) {
self.abTestScheduleID = abTestScheduleID
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case abTestScheduleID
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.abTestScheduleID, forKey: .abTestScheduleID)
}
}

extension ScheduleABTestResponse: Equatable {
public static func ==(lhs: ScheduleABTestResponse, rhs: ScheduleABTestResponse) -> Bool {
lhs.abTestScheduleID == rhs.abTestScheduleID
}
}

extension ScheduleABTestResponse: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(self.abTestScheduleID.hashValue)
}
}
60 changes: 60 additions & 0 deletions Sources/Abtesting/Models/ScheduleABTestsRequest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on
// https://github.com/algolia/api-clients-automation. DO NOT EDIT.

import Foundation
#if canImport(Core)
import Core
#endif

public struct ScheduleABTestsRequest: Codable, JSONEncodable {
/// A/B test name.
public var name: String
/// A/B test variants.
public var variants: [AddABTestsVariant]
/// Date and time when the A/B test is scheduled to start, in RFC 3339 format.
public var scheduledAt: String
/// End date and time of the A/B test, in RFC 3339 format.
public var endAt: String

public init(name: String, variants: [AddABTestsVariant], scheduledAt: String, endAt: String) {
self.name = name
self.variants = variants
self.scheduledAt = scheduledAt
self.endAt = endAt
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case name
case variants
case scheduledAt
case endAt
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.name, forKey: .name)
try container.encode(self.variants, forKey: .variants)
try container.encode(self.scheduledAt, forKey: .scheduledAt)
try container.encode(self.endAt, forKey: .endAt)
}
}

extension ScheduleABTestsRequest: Equatable {
public static func ==(lhs: ScheduleABTestsRequest, rhs: ScheduleABTestsRequest) -> Bool {
lhs.name == rhs.name &&
lhs.variants == rhs.variants &&
lhs.scheduledAt == rhs.scheduledAt &&
lhs.endAt == rhs.endAt
}
}

extension ScheduleABTestsRequest: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(self.name.hashValue)
hasher.combine(self.variants.hashValue)
hasher.combine(self.scheduledAt.hashValue)
hasher.combine(self.endAt.hashValue)
}
}

0 comments on commit e415046

Please sign in to comment.