# Reference

### Overview

`ABTastyProvider` is an implementation of OpenFeature's `FeatureProvider` protocol that integrates with AB Tasty's feature flag management system through the Flagship SDK. It provides a bridge between OpenFeature's standardized API and AB Tasty's functionality.

### Class Definition

```swift

public class ABTastyProvider: FeatureProvider
```

### Metadata

The provider uses custom metadata structure:

```swift
public struct ABTastyMetadata: ProviderMetadata {
    public var name: String? = "FlagshipProvider"
}
```

### Initialization

```swift
public init(
    envId: String,
    apiKey: String,
    configurator: FlagshipConfig
)
```

###

| Parameter    | Type           | Description                                                                                                                               |
| ------------ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| envId        | String         | Environment ID provided by Flagship                                                                                                       |
| apiKey       | String         | Api authentication key provided by Flagship.                                                                                              |
| configurator | FlagshipConfig | Custom flagship configuration. [see SDK configuration](https://docs.abtasty.com/server-side/sdks/ios/ios-1/swift-reference#configuration) |

### Core Methods

#### Initialize

Initializes the provider with optional context data. This method:

\- Processes the initial context into Flagship format

\- Extracts consent information

\- Creates an AB Tasty client instance

```swift
public func initialize(
    initialContext: (any OpenFeature.EvaluationContext)?
) async throws
```

#### Context Management

Updates the provider context with new evaluation context data. This method:

\- Converts OpenFeature context to Flagship format

\- Updates consent status

\- Updates visitor ID

\- Updates ABTasty client with new context

```swift
public func onContextSet(
    oldContext: (any OpenFeature.EvaluationContext)?, 
    newContext: any OpenFeature.EvaluationContext
) async throws
```

### Feature Flag Evaluation Methods

#### Boolean Evaluation

```swift
public func getBooleanEvaluation(
    key: String,
    defaultValue: Bool,
    context: (any OpenFeature.EvaluationContext)?
) throws -> OpenFeature.ProviderEvaluation<Bool>
```

#### String Evaluation

```swift
public func getStringEvaluation(
    key: String,
    defaultValue: String,
    context: (any OpenFeature.EvaluationContext)?
) throws -> OpenFeature.ProviderEvaluation<String>
```

#### Integer Evaluation

```swift
public func getIntegerEvaluation(
    key: String,
    defaultValue: Int64,
    context: (any OpenFeature.EvaluationContext)?
) throws -> OpenFeature.ProviderEvaluation<Int64>
```

#### Double Evaluation

```swift
public func getDoubleEvaluation(
    key: String,
    defaultValue: Double,
    context: (any OpenFeature.EvaluationContext)?
) throws -> OpenFeature.ProviderEvaluation<Double>
```

#### Object Evaluation

```swift
public func getObjectEvaluation(
    key: String,
    defaultValue: OpenFeature.Value,
    context: (any OpenFeature.EvaluationContext)?
) throws -> OpenFeature.ProviderEvaluation<OpenFeature.Value>
```
