yandexads-flutter

Форк
0
275 строк · 9.2 Кб
1
// Autogenerated from Pigeon (v14.0.0), do not edit directly.
2
// See also: https://pub.dev/packages/pigeon
3

4
import Foundation
5
#if os(iOS)
6
import Flutter
7
#elseif os(macOS)
8
import FlutterMacOS
9
#else
10
#error("Unsupported platform.")
11
#endif
12

13
private func wrapResult(_ result: Any?) -> [Any?] {
14
  return [result]
15
}
16

17
private func wrapError(_ error: Any) -> [Any?] {
18
  if let flutterError = error as? FlutterError {
19
    return [
20
      flutterError.code,
21
      flutterError.message,
22
      flutterError.details
23
    ]
24
  }
25
  return [
26
    "\(error)",
27
    "\(type(of: error))",
28
    "Stacktrace: \(Thread.callStackSymbols)"
29
  ]
30
}
31

32
private func isNullish(_ value: Any?) -> Bool {
33
  return value is NSNull || value == nil
34
}
35

36
private func nilOrValue<T>(_ value: Any?) -> T? {
37
  if value is NSNull { return nil }
38
  return value as! T?
39
}
40

41
/// Generated class from Pigeon that represents data sent in messages.
42
struct NativeError {
43
  var code: Int64
44
  var description: String
45

46
  static func fromList(_ list: [Any?]) -> NativeError? {
47
    let code = list[0] is Int64 ? list[0] as! Int64 : Int64(list[0] as! Int32)
48
    let description = list[1] as! String
49

50
    return NativeError(
51
      code: code,
52
      description: description
53
    )
54
  }
55
  func toList() -> [Any?] {
56
    return [
57
      code,
58
      description,
59
    ]
60
  }
61
}
62

63
/// Generated class from Pigeon that represents data sent in messages.
64
struct NativeImpression {
65
  var data: String
66

67
  static func fromList(_ list: [Any?]) -> NativeImpression? {
68
    let data = list[0] as! String
69

70
    return NativeImpression(
71
      data: data
72
    )
73
  }
74
  func toList() -> [Any?] {
75
    return [
76
      data,
77
    ]
78
  }
79
}
80

81
private class YandexAdsNativeCodecReader: FlutterStandardReader {
82
  override func readValue(ofType type: UInt8) -> Any? {
83
    switch type {
84
      case 128:
85
        return NativeError.fromList(self.readValue() as! [Any?])
86
      case 129:
87
        return NativeImpression.fromList(self.readValue() as! [Any?])
88
      default:
89
        return super.readValue(ofType: type)
90
    }
91
  }
92
}
93

94
private class YandexAdsNativeCodecWriter: FlutterStandardWriter {
95
  override func writeValue(_ value: Any) {
96
    if let value = value as? NativeError {
97
      super.writeByte(128)
98
      super.writeValue(value.toList())
99
    } else if let value = value as? NativeImpression {
100
      super.writeByte(129)
101
      super.writeValue(value.toList())
102
    } else {
103
      super.writeValue(value)
104
    }
105
  }
106
}
107

108
private class YandexAdsNativeCodecReaderWriter: FlutterStandardReaderWriter {
109
  override func reader(with data: Data) -> FlutterStandardReader {
110
    return YandexAdsNativeCodecReader(data: data)
111
  }
112

113
  override func writer(with data: NSMutableData) -> FlutterStandardWriter {
114
    return YandexAdsNativeCodecWriter(data: data)
115
  }
116
}
117

118
class YandexAdsNativeCodec: FlutterStandardMessageCodec {
119
  static let shared = YandexAdsNativeCodec(readerWriter: YandexAdsNativeCodecReaderWriter())
120
}
121

122
/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
123
protocol YandexAdsNative {
124
  func make(id: String) throws
125
  func load(id: String, width: Int64, height: Int64) throws
126
  func onAdLoaded(id: String, completion: @escaping (Result<Void, Error>) -> Void)
127
  func onAdFailedToLoad(id: String, completion: @escaping (Result<NativeError, Error>) -> Void)
128
  func onAdClicked(id: String, completion: @escaping (Result<Void, Error>) -> Void)
129
  func onLeftApplication(id: String, completion: @escaping (Result<Void, Error>) -> Void)
130
  func onReturnedToApplication(id: String, completion: @escaping (Result<Void, Error>) -> Void)
131
  func onImpression(id: String, completion: @escaping (Result<NativeImpression, Error>) -> Void)
132
}
133

134
/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
135
class YandexAdsNativeSetup {
136
  /// The codec used by YandexAdsNative.
137
  static var codec: FlutterStandardMessageCodec { YandexAdsNativeCodec.shared }
138
  /// Sets up an instance of `YandexAdsNative` to handle messages through the `binaryMessenger`.
139
  static func setUp(binaryMessenger: FlutterBinaryMessenger, api: YandexAdsNative?) {
140
    let makeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_yandex_ads.YandexAdsNative.make", binaryMessenger: binaryMessenger, codec: codec)
141
    if let api = api {
142
      makeChannel.setMessageHandler { message, reply in
143
        let args = message as! [Any?]
144
        let idArg = args[0] as! String
145
        do {
146
          try api.make(id: idArg)
147
          reply(wrapResult(nil))
148
        } catch {
149
          reply(wrapError(error))
150
        }
151
      }
152
    } else {
153
      makeChannel.setMessageHandler(nil)
154
    }
155
    let loadChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_yandex_ads.YandexAdsNative.load", binaryMessenger: binaryMessenger, codec: codec)
156
    if let api = api {
157
      loadChannel.setMessageHandler { message, reply in
158
        let args = message as! [Any?]
159
        let idArg = args[0] as! String
160
        let widthArg = args[1] is Int64 ? args[1] as! Int64 : Int64(args[1] as! Int32)
161
        let heightArg = args[2] is Int64 ? args[2] as! Int64 : Int64(args[2] as! Int32)
162
        do {
163
          try api.load(id: idArg, width: widthArg, height: heightArg)
164
          reply(wrapResult(nil))
165
        } catch {
166
          reply(wrapError(error))
167
        }
168
      }
169
    } else {
170
      loadChannel.setMessageHandler(nil)
171
    }
172
    let onAdLoadedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_yandex_ads.YandexAdsNative.onAdLoaded", binaryMessenger: binaryMessenger, codec: codec)
173
    if let api = api {
174
      onAdLoadedChannel.setMessageHandler { message, reply in
175
        let args = message as! [Any?]
176
        let idArg = args[0] as! String
177
        api.onAdLoaded(id: idArg) { result in
178
          switch result {
179
            case .success:
180
              reply(wrapResult(nil))
181
            case .failure(let error):
182
              reply(wrapError(error))
183
          }
184
        }
185
      }
186
    } else {
187
      onAdLoadedChannel.setMessageHandler(nil)
188
    }
189
    let onAdFailedToLoadChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_yandex_ads.YandexAdsNative.onAdFailedToLoad", binaryMessenger: binaryMessenger, codec: codec)
190
    if let api = api {
191
      onAdFailedToLoadChannel.setMessageHandler { message, reply in
192
        let args = message as! [Any?]
193
        let idArg = args[0] as! String
194
        api.onAdFailedToLoad(id: idArg) { result in
195
          switch result {
196
            case .success(let res):
197
              reply(wrapResult(res))
198
            case .failure(let error):
199
              reply(wrapError(error))
200
          }
201
        }
202
      }
203
    } else {
204
      onAdFailedToLoadChannel.setMessageHandler(nil)
205
    }
206
    let onAdClickedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_yandex_ads.YandexAdsNative.onAdClicked", binaryMessenger: binaryMessenger, codec: codec)
207
    if let api = api {
208
      onAdClickedChannel.setMessageHandler { message, reply in
209
        let args = message as! [Any?]
210
        let idArg = args[0] as! String
211
        api.onAdClicked(id: idArg) { result in
212
          switch result {
213
            case .success:
214
              reply(wrapResult(nil))
215
            case .failure(let error):
216
              reply(wrapError(error))
217
          }
218
        }
219
      }
220
    } else {
221
      onAdClickedChannel.setMessageHandler(nil)
222
    }
223
    let onLeftApplicationChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_yandex_ads.YandexAdsNative.onLeftApplication", binaryMessenger: binaryMessenger, codec: codec)
224
    if let api = api {
225
      onLeftApplicationChannel.setMessageHandler { message, reply in
226
        let args = message as! [Any?]
227
        let idArg = args[0] as! String
228
        api.onLeftApplication(id: idArg) { result in
229
          switch result {
230
            case .success:
231
              reply(wrapResult(nil))
232
            case .failure(let error):
233
              reply(wrapError(error))
234
          }
235
        }
236
      }
237
    } else {
238
      onLeftApplicationChannel.setMessageHandler(nil)
239
    }
240
    let onReturnedToApplicationChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_yandex_ads.YandexAdsNative.onReturnedToApplication", binaryMessenger: binaryMessenger, codec: codec)
241
    if let api = api {
242
      onReturnedToApplicationChannel.setMessageHandler { message, reply in
243
        let args = message as! [Any?]
244
        let idArg = args[0] as! String
245
        api.onReturnedToApplication(id: idArg) { result in
246
          switch result {
247
            case .success:
248
              reply(wrapResult(nil))
249
            case .failure(let error):
250
              reply(wrapError(error))
251
          }
252
        }
253
      }
254
    } else {
255
      onReturnedToApplicationChannel.setMessageHandler(nil)
256
    }
257
    let onImpressionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_yandex_ads.YandexAdsNative.onImpression", binaryMessenger: binaryMessenger, codec: codec)
258
    if let api = api {
259
      onImpressionChannel.setMessageHandler { message, reply in
260
        let args = message as! [Any?]
261
        let idArg = args[0] as! String
262
        api.onImpression(id: idArg) { result in
263
          switch result {
264
            case .success(let res):
265
              reply(wrapResult(res))
266
            case .failure(let error):
267
              reply(wrapError(error))
268
          }
269
        }
270
      }
271
    } else {
272
      onImpressionChannel.setMessageHandler(nil)
273
    }
274
  }
275
}
276

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.