Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge upstream #2

Merged
merged 17 commits into from
Aug 9, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add lang parameter to APIManager (ArtSabintsev#391)
Co-authored-by: kientux <kiennt@sapo.vn>
  • Loading branch information
kientux and kientux committed Mar 23, 2022
commit 609f1653a400799e0e85d7dd6ec99e9795f9f70a
13 changes: 12 additions & 1 deletion Sources/Managers/APIManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public struct APIManager {
static let bundleID = "bundleId"
/// Constant for the `country` parameter in the iTunes Lookup API request.
static let country = "country"
/// Constant for the `lang` parameter in the iTunes Lookup API request.
static let language = "lang"
/// Constant for the `entity` parameter in the iTunes Lookup API reqeust.
static let entity = "entity"
/// Constant for the `entity` parameter value when performing a tvOS iTunes Lookup API reqeust.
Expand All @@ -27,12 +29,16 @@ public struct APIManager {

/// The region or country of an App Store in which the app is available.
let country: AppStoreCountry

/// The language for the localization of App Store responses.
let language: String?

/// Initializes `APIManager` to the region or country of an App Store in which the app is available.
/// By default, all version check requests are performed against the US App Store.
/// - Parameter country: The country for the App Store in which the app is available.
public init(country: AppStoreCountry = .unitedStates) {
public init(country: AppStoreCountry = .unitedStates, language: String? = nil) {
self.country = country
self.language = language
}

/// The default `APIManager`.
Expand Down Expand Up @@ -111,6 +117,11 @@ extension APIManager {
let item = URLQueryItem(name: Constants.country, value: countryCode)
items.append(item)
}

if let language = language {
let item = URLQueryItem(name: Constants.language, value: language)
items.append(item)
}

components.queryItems = items

Expand Down