Skip to content

Commit f32fe83

Browse files
authored
Update openapi spec (#791)
1 parent a5df3e5 commit f32fe83

File tree

9 files changed

+320
-6
lines changed

9 files changed

+320
-6
lines changed

Demo/Demo/Gravatar-Demo/DemoFetchProfileViewController.swift

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import UIKit
22
import Gravatar
33

44
class DemoFetchProfileViewController: UIViewController {
5+
@StoredValue(keyName: "QEEmailKey", defaultValue: "")
6+
var savedEmail: String
7+
8+
@StoredValue(keyName: "QETokenKey", defaultValue: "")
9+
var savedToken: String
10+
511
let rootStackView: UIStackView = {
612
let stack = UIStackView()
713
stack.translatesAutoresizingMaskIntoConstraints = false
@@ -19,15 +25,25 @@ class DemoFetchProfileViewController: UIViewController {
1925
control.selectedSegmentIndex = 0
2026
return control
2127
}()
22-
23-
let emailField: UITextField = {
28+
29+
lazy var tokenField: UITextField = {
30+
let textField = UITextField()
31+
textField.translatesAutoresizingMaskIntoConstraints = false
32+
textField.placeholder = "OAuth Token (Optional)"
33+
textField.isSecureTextEntry = true
34+
textField.text = savedToken
35+
return textField
36+
}()
37+
38+
lazy var emailField: UITextField = {
2439
let textField = UITextField()
2540
textField.translatesAutoresizingMaskIntoConstraints = false
2641
textField.placeholder = "Email"
2742
textField.keyboardType = .emailAddress
2843
textField.autocapitalizationType = .none
2944
textField.textContentType = .emailAddress
3045
textField.textAlignment = .center
46+
textField.text = savedEmail
3147
return textField
3248
}()
3349

@@ -64,7 +80,7 @@ class DemoFetchProfileViewController: UIViewController {
6480
title = "Fetch Profile"
6581
view.backgroundColor = .systemBackground
6682

67-
for view in [segmentedControl, emailField, fetchProfileButton, activityIndicator, profileTextView] {
83+
for view in [segmentedControl, tokenField, emailField, fetchProfileButton, activityIndicator, profileTextView] {
6884
rootStackView.addArrangedSubview(view)
6985
}
7086
view.addSubview(rootStackView)
@@ -83,7 +99,14 @@ class DemoFetchProfileViewController: UIViewController {
8399
var identifier: ProfileIdentifier
84100

85101
guard activityIndicator.isAnimating == false else { return }
86-
102+
103+
if let tokenString = tokenField.text, tokenString.isEmpty == false {
104+
Task {
105+
await fetchOwnProfile(with: tokenString)
106+
}
107+
return
108+
}
109+
87110
if segmentedControl.selectedSegmentIndex == 0 {
88111
guard let email = emailField.text, email.isEmpty == false else { return }
89112
identifier = .email(email)
@@ -109,11 +132,23 @@ class DemoFetchProfileViewController: UIViewController {
109132
}
110133
}
111134

135+
func fetchOwnProfile(with token: String) async {
136+
let service = ProfileService()
137+
do {
138+
let profile = try await service.fetchOwnProfile(token: token)
139+
setProfile(with: profile)
140+
} catch {
141+
showError(error)
142+
}
143+
}
144+
112145
func setProfile(with profile: Profile) {
113146
activityIndicator.stopAnimating()
114147
profileTextView.text = """
115148
Profile URL: \(profile.profileUrl)
116149
Display name: \(profile.displayName)
150+
User login (authenticated): \(profile.userLogin ?? "nil")
151+
User ID (authenticated): \(String(describing: profile.userId))
117152
Preferred User Name: \(profile.displayName)
118153
Thumbnail URL: \(profile.avatarUrl)
119154
Verified accounts (\(profile.numberVerifiedAccounts ?? 0)): \(profile.verifiedAccounts)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Foundation
2+
3+
struct GetVerifiedAccountServices200Response: Codable, Hashable, Sendable {
4+
/// List of supported verified account services.
5+
private(set) var services: [GetVerifiedAccountServices200ResponseServicesInner]
6+
7+
init(services: [GetVerifiedAccountServices200ResponseServicesInner]) {
8+
self.services = services
9+
}
10+
11+
enum CodingKeys: String, CodingKey, CaseIterable {
12+
case services
13+
}
14+
15+
// Encodable protocol methods
16+
17+
func encode(to encoder: Encoder) throws {
18+
var container = encoder.container(keyedBy: CodingKeys.self)
19+
try container.encode(services, forKey: .services)
20+
}
21+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Foundation
2+
3+
struct GetVerifiedAccountServices200ResponseServicesInner: Codable, Hashable, Sendable {
4+
/// The identifier for the service.
5+
private(set) var id: String
6+
/// The human-readable label for the service.
7+
private(set) var label: String
8+
9+
init(id: String, label: String) {
10+
self.id = id
11+
self.label = label
12+
}
13+
14+
enum CodingKeys: String, CodingKey, CaseIterable {
15+
case id
16+
case label
17+
}
18+
19+
// Encodable protocol methods
20+
21+
func encode(to encoder: Encoder) throws {
22+
var container = encoder.container(keyedBy: CodingKeys.self)
23+
try container.encode(id, forKey: .id)
24+
try container.encode(label, forKey: .label)
25+
}
26+
}

Sources/Gravatar/OpenApi/Generated/Profile.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import Foundation
33
/// A user's profile information.
44
///
55
public struct Profile: Codable, Hashable, Sendable {
6+
/// The unique user ID. NOTE: This is only provided in OAuth2 authenticated requests.
7+
public private(set) var userId: Int?
8+
/// The user's login name. NOTE: This is only provided in OAuth2 authenticated requests.
9+
public private(set) var userLogin: String?
610
/// The SHA256 hash of the user's primary email address.
711
public private(set) var hash: String
812
/// The user's display name. This is the name that is displayed on their profile.
@@ -58,6 +62,8 @@ public struct Profile: Codable, Hashable, Sendable {
5862
public private(set) var registrationDate: Date?
5963

6064
init(
65+
userId: Int? = nil,
66+
userLogin: String? = nil,
6167
hash: String,
6268
displayName: String,
6369
profileUrl: String,
@@ -86,6 +92,8 @@ public struct Profile: Codable, Hashable, Sendable {
8692
lastProfileEdit: Date? = nil,
8793
registrationDate: Date? = nil
8894
) {
95+
self.userId = userId
96+
self.userLogin = userLogin
8997
self.hash = hash
9098
self.displayName = displayName
9199
self.profileUrl = profileUrl
@@ -116,6 +124,8 @@ public struct Profile: Codable, Hashable, Sendable {
116124
}
117125

118126
enum CodingKeys: String, CodingKey, CaseIterable {
127+
case userId = "user_id"
128+
case userLogin = "user_login"
119129
case hash
120130
case displayName = "display_name"
121131
case profileUrl = "profile_url"
@@ -149,6 +159,8 @@ public struct Profile: Codable, Hashable, Sendable {
149159

150160
public func encode(to encoder: Encoder) throws {
151161
var container = encoder.container(keyedBy: CodingKeys.self)
162+
try container.encodeIfPresent(userId, forKey: .userId)
163+
try container.encodeIfPresent(userLogin, forKey: .userLogin)
152164
try container.encode(hash, forKey: .hash)
153165
try container.encode(displayName, forKey: .displayName)
154166
try container.encode(profileUrl, forKey: .profileUrl)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Foundation
2+
3+
struct SearchProfilesByVerifiedAccount200Response: Codable, Hashable, Sendable {
4+
private(set) var profiles: [Profile]
5+
/// Total number of pages available.
6+
private(set) var totalPages: Int
7+
8+
init(profiles: [Profile], totalPages: Int) {
9+
self.profiles = profiles
10+
self.totalPages = totalPages
11+
}
12+
13+
enum CodingKeys: String, CodingKey, CaseIterable {
14+
case profiles
15+
case totalPages = "total_pages"
16+
}
17+
18+
// Encodable protocol methods
19+
20+
func encode(to encoder: Encoder) throws {
21+
var container = encoder.container(keyedBy: CodingKeys.self)
22+
try container.encode(profiles, forKey: .profiles)
23+
try container.encode(totalPages, forKey: .totalPages)
24+
}
25+
}

Sources/Gravatar/OpenApi/Generated/UpdateProfileRequest.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ public struct UpdateProfileRequest: Codable, Hashable, Sendable {
2121
public private(set) var jobTitle: String?
2222
/// The user's current company's name.
2323
public private(set) var company: String?
24+
/// The user's cell phone number.
25+
public private(set) var cellPhone: String?
26+
/// The user's contact email address.
27+
public private(set) var contactEmail: String?
28+
/// Whether the user's contact information is hidden on their profile.
29+
public private(set) var hiddenContactInfo: Bool?
2430

2531
public init(
2632
firstName: String? = nil,
@@ -31,7 +37,10 @@ public struct UpdateProfileRequest: Codable, Hashable, Sendable {
3137
pronouns: String? = nil,
3238
location: String? = nil,
3339
jobTitle: String? = nil,
34-
company: String? = nil
40+
company: String? = nil,
41+
cellPhone: String? = nil,
42+
contactEmail: String? = nil,
43+
hiddenContactInfo: Bool? = nil
3544
) {
3645
self.firstName = firstName
3746
self.lastName = lastName
@@ -42,6 +51,9 @@ public struct UpdateProfileRequest: Codable, Hashable, Sendable {
4251
self.location = location
4352
self.jobTitle = jobTitle
4453
self.company = company
54+
self.cellPhone = cellPhone
55+
self.contactEmail = contactEmail
56+
self.hiddenContactInfo = hiddenContactInfo
4557
}
4658

4759
enum CodingKeys: String, CodingKey, CaseIterable {
@@ -54,6 +66,9 @@ public struct UpdateProfileRequest: Codable, Hashable, Sendable {
5466
case location
5567
case jobTitle = "job_title"
5668
case company
69+
case cellPhone = "cell_phone"
70+
case contactEmail = "contact_email"
71+
case hiddenContactInfo = "hidden_contact_info"
5772
}
5873

5974
// Encodable protocol methods
@@ -69,5 +84,8 @@ public struct UpdateProfileRequest: Codable, Hashable, Sendable {
6984
try container.encodeIfPresent(location, forKey: .location)
7085
try container.encodeIfPresent(jobTitle, forKey: .jobTitle)
7186
try container.encodeIfPresent(company, forKey: .company)
87+
try container.encodeIfPresent(cellPhone, forKey: .cellPhone)
88+
try container.encodeIfPresent(contactEmail, forKey: .contactEmail)
89+
try container.encodeIfPresent(hiddenContactInfo, forKey: .hiddenContactInfo)
7290
}
7391
}

access-control-modifier.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ let internalTypes: [String] = [
88
"AssociatedResponse",
99
"Avatar",
1010
"AvatarRating",
11-
"UpdateAvatarRequest"
11+
"UpdateAvatarRequest",
12+
"GetVerifiedAccountServices200Response",
13+
"GetVerifiedAccountServices200ResponseServicesInner",
14+
"SearchProfilesByVerifiedAccount200Response"
1215
]
1316

1417
let packageTypes: [String] = [

openapi/GravatarOpenAPIClient/.openapi-generator/FILES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ Sources/GravatarOpenAPIClient/Models/Avatar.swift
33
Sources/GravatarOpenAPIClient/Models/AvatarRating.swift
44
Sources/GravatarOpenAPIClient/Models/CryptoWalletAddress.swift
55
Sources/GravatarOpenAPIClient/Models/GalleryImage.swift
6+
Sources/GravatarOpenAPIClient/Models/GetVerifiedAccountServices200Response.swift
7+
Sources/GravatarOpenAPIClient/Models/GetVerifiedAccountServices200ResponseServicesInner.swift
68
Sources/GravatarOpenAPIClient/Models/Interest.swift
79
Sources/GravatarOpenAPIClient/Models/Language.swift
810
Sources/GravatarOpenAPIClient/Models/Link.swift
911
Sources/GravatarOpenAPIClient/Models/ModelError.swift
1012
Sources/GravatarOpenAPIClient/Models/Profile.swift
1113
Sources/GravatarOpenAPIClient/Models/ProfileContactInfo.swift
1214
Sources/GravatarOpenAPIClient/Models/ProfilePayments.swift
15+
Sources/GravatarOpenAPIClient/Models/SearchProfilesByVerifiedAccount200Response.swift
1316
Sources/GravatarOpenAPIClient/Models/SetEmailAvatarRequest.swift
1417
Sources/GravatarOpenAPIClient/Models/UpdateAvatarRequest.swift
1518
Sources/GravatarOpenAPIClient/Models/UpdateProfileRequest.swift

0 commit comments

Comments
 (0)