Skip to content

Commit

Permalink
feat(nodejs): add applicationName parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierapivideo authored Jan 25, 2022
1 parent 192c525 commit 4f8237f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ApiVideoClient.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Pod::Spec.new do |s|
s.osx.deployment_target = '10.12'
s.tvos.deployment_target = '10.0'
s.watchos.deployment_target = '3.0'
s.version = '1.0.0'
s.source = { :git => 'https://github.com/apivideo/api.video-ios-client', :tag => 'v1.0.0' }
s.version = '1.0.1'
s.source = { :git => 'https://github.com/apivideo/api.video-ios-client', :tag => 'v1.0.1' }
s.authors = { 'Ecosystem Team' => 'ecosystem@api.video' }
s.license = { :type => 'MIT' }
s.homepage = 'https://docs.api.video'
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All changes to this project will be documented in this file.

## [1.0.1] - 2022-01-24
- Add applicationName parameter (to allow user agent extension)

## [1.0.0] - 2022-01-07
- Add watermark endpoints
- Add video clips
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ api.video's iOS client streamlines the coding process. Chunking files is handled
Specify it in your `Cartfile`:

```
github "apivideo/api.video-ios-client" ~> 1.0.0
github "apivideo/api.video-ios-client" ~> 1.0.1
```

Run `carthage update`

### CocoaPods

Add `pod 'ApiVideoClient', '1.0.0'` in your `Podfile`
Add `pod 'ApiVideoClient', '1.0.1'` in your `Podfile`

Run `pod install`

Expand Down
19 changes: 18 additions & 1 deletion Sources/APIs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
//

import Foundation
enum ApiVideoClientError: Error {
case invalidApplicationName
}

public class ApiVideoClient {
private static let DEFAULT_USER_AGENT = "api.video client (iOS; v:1.0.1; )";

public static var apiKey: String? = nil
public static var basePath = "https://ws.api.video"
internal static var customHeaders: [String: String] = ["User-Agent": "api.video client (iOS; v:; )"]
internal static var customHeaders:[String: String] = ["User-Agent": ApiVideoClient.DEFAULT_USER_AGENT]
private static var chunkSize: Int = 50 * 1024 * 1024
internal static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
internal static var credential = ApiVideoCredential()
Expand All @@ -27,6 +33,17 @@ public class ApiVideoClient {
public static func getChunkSize() -> Int {
return ApiVideoClient.chunkSize
}

public static func setApplicationName(applicationName: String) throws {
let pattern = #"^[\w\-.\/]{1,50}$"#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let stringRange = NSRange(location: 0, length: applicationName.utf16.count)
let matches = regex.matches(in: applicationName, range: stringRange)
if(matches.isEmpty) {
throw ApiVideoClientError.invalidApplicationName
}
ApiVideoClient.customHeaders["User-Agent"] = ApiVideoClient.DEFAULT_USER_AGENT + " " + applicationName
}
}

open class RequestBuilder<T> {
Expand Down
1 change: 1 addition & 0 deletions Tests/ApiVideoClient/Integration/VideosApiTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ internal class UploadTestCase: XCTestCase {
try XCTSkipIf(Parameters.apiKey == "INTEGRATION_TESTS_API_TOKEN", "Can't get API key")
ApiVideoClient.apiKey = Parameters.apiKey
ApiVideoClient.basePath = Environment.sandbox.rawValue
try? ApiVideoClient.setApplicationName(applicationName: "client-integration-tests")

continueAfterFailure = false
}
Expand Down
2 changes: 1 addition & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ targets:
sources: [Sources]
info:
path: ./Info.plist
version: 1.0.0
version: 1.0.1
settings:
APPLICATION_EXTENSION_API_ONLY: true
scheme: {}
Expand Down

0 comments on commit 4f8237f

Please sign in to comment.