Skip to content

Commit

Permalink
Merge pull request #9 from MetalheadSanya/user_agent
Browse files Browse the repository at this point in the history
Add correct user-agent header
  • Loading branch information
MetalheadSanya authored Aug 16, 2018
2 parents c60373f + 6e53de9 commit 762914f
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 45 deletions.
5 changes: 3 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
github "MetalheadSanya/When" "8bfe92be1a00a44ef26fa13669d25a21b2d92a98"
github "card-io/card.io-iOS-source" "iOS_5.4.1"
github "yandex-money/core-api-swift" "1.0.1"
github "yandex-money/core-api-swift" "1.1.0"
github "yandex-money/functional-swift" "1.0.5"
github "yandex-money/yandex-checkout-payments-api-swift" "1.0.1"
github "yandex-money/yandex-checkout-showcase-api-swift" "1.0.0"
github "yandex-money/yandex-checkout-wallet-api-swift" "1.0.2"
github "yandexmobile/metrica-sdk-ios" "3.1.2"
github "yandexmobile/metrica-sdk-ios" "3.2.0"
github "yandexmobile/yandex-login-sdk-ios" "2.0.2"
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PODS:
- When (3.0.2):
- When/Core (= 3.0.2)
- When/Core (3.0.2)
- YandexCheckoutPayments (1.3.3):
- YandexCheckoutPayments (1.3.4):
- FunctionalSwift
- When
- YandexCheckoutPaymentsApi
Expand Down Expand Up @@ -52,7 +52,7 @@ SPEC CHECKSUMS:
CardIO: 56983b39b62f495fc6dae9ad7cf875143df06443
FunctionalSwift: 89cef31016cbc9fcdd49ec04e5831ed5f51244bb
When: 4e5fda6952dd6e2714bafc329cb288b4637b6cc9
YandexCheckoutPayments: a5b6fbb02872699ce50e10d3ba408ee712fedd05
YandexCheckoutPayments: fd4785ee501434528310c7683821544ff3822dcb
YandexCheckoutPaymentsApi: 83564a6dae2c74f942cbfcec84afa45b1230872b
YandexCheckoutShowcaseApi: c7fda3e27adf4f73fb14c1d6d4b9077703313405
YandexCheckoutWalletApi: 304601e48205c4dc0568a1018134eed3bb47547c
Expand Down
2 changes: 1 addition & 1 deletion YandexCheckoutPayments.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'YandexCheckoutPayments'
s.version = '1.3.3'
s.version = '1.3.4'
s.homepage = 'https://github.com/yandex-money/yandex-checkout-payments-swift'
s.license = {
:type => "MIT",
Expand Down
110 changes: 71 additions & 39 deletions YandexCheckoutPayments.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions YandexCheckoutPayments/Factory/ApiSessionAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import YandexMoneyCoreApi

enum ApiSessionAssembly {
static func makeApiSession() -> ApiSession {
let configuration: URLSessionConfiguration = .default
configuration.httpAdditionalHeaders = [
"User-Agent": UserAgentFactory.makeHeaderValue(),
]
let session = ApiSession(hostProvider: HostProviderAssembly.makeHostProvider(),
configuration: configuration,
logger: nil)
return session
}
Expand Down
23 changes: 23 additions & 0 deletions YandexCheckoutPayments/Factory/UserAgentFactory.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Foundation
import UIKit

private class Class { }

enum UserAgentFactory {
static func makeHeaderValue() -> String {
let frameworkVersion = Bundle(for: Class.self).infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown"
let osVersion = UIDevice.current.systemVersion
let deviceClass: String

switch UIDevice.current.userInterfaceIdiom {
case .phone:
deviceClass = "Phone"
case .pad:
deviceClass = "Tablet"
default:
deviceClass = "Unknown"
}

return ["Yandex.Checkout.SDK.iOS/", frameworkVersion, " iOS/", osVersion, " ", deviceClass].joined()
}
}
2 changes: 1 addition & 1 deletion YandexCheckoutPayments/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.3.4</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down

0 comments on commit 762914f

Please sign in to comment.