Skip to content

Commit

Permalink
Added Model info to README.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoMachorro authored Jul 22, 2023
1 parent 7a501f7 commit a06b7ee
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*.
Expand Down

0 comments on commit a06b7ee

Please sign in to comment.