-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a501f7
commit a06b7ee
Showing
1 changed file
with
30 additions
and
0 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 |
---|---|---|
|
@@ -44,13 +44,43 @@ let (data, _) = try await URLSession.shared.data(from: url) | |
let profile = try JSONDecoder().decode(GravatarProfile.self, from: data) | ||
``` | ||
|
||
The data will be stored in the GravatarProfile model: | ||
|
||
```swift | ||
public struct GravatarProfile: Decodable { | ||
public let entry: [Entry] | ||
|
||
public struct Entry: Decodable { | ||
public let id: String? | ||
public let hash: String | ||
public let requestHash: String | ||
public let profileUrl: String? | ||
public let preferredUsername: String? | ||
public let thumbnailUrl: String? | ||
public let photos: [Photo]? | ||
public let name: Name? | ||
public let displayName: String? | ||
public let pronouns: String? | ||
public let aboutMe: String? | ||
public let currentLocation: String? | ||
public let emails: [Email]? | ||
public let ims: [InstantMessenger]? | ||
public let accounts: [Account]? | ||
public let urls: [Websites]? | ||
} | ||
// ... truncated ... | ||
} | ||
``` | ||
|
||
An easy converter from e-mail to Gravatar URL can be accessed as follows: | ||
|
||
```swift | ||
let myemailaddress = GravatarProfile.getProfileAddress(using: "[email protected]") | ||
// "https://en.gravatar.com/0bc83cb571cd1c50ba6f3e8a78ef1346.json" | ||
``` | ||
|
||
Feel free to peek into the code to see the whole Model as well as check the tests for usage options. | ||
|
||
# Contributing | ||
|
||
Contributions are very welcome. Fork the repo, make your changes, test with SwiftLint and Unit tests, commit and do a *pull request*. | ||
|