// Code generated by Fern. DO NOT EDIT.

package blobstorageintegrations

import (
    internal "pentagi/pkg/observability/langfuse/api/internal"
    core "pentagi/pkg/observability/langfuse/api/core"
    context "context"
    option "pentagi/pkg/observability/langfuse/api/option"
    api "pentagi/pkg/observability/langfuse/api"
    http "net/http"
)


type RawClient struct {
    baseURL string
    caller *internal.Caller
    options *core.RequestOptions
}

func NewRawClient(options *core.RequestOptions) *RawClient {
    return &RawClient{
        options: options,
        baseURL: options.BaseURL,
        caller: internal.NewCaller(
            &internal.CallerParams{
                Client: options.HTTPClient,
                MaxAttempts: options.MaxAttempts,
            },
        ),
    }
}

func (r *RawClient) Getblobstorageintegrations(
    ctx context.Context,
    opts ...option.RequestOption,
) (*core.Response[*api.BlobStorageIntegrationsResponse], error){
    options := core.NewRequestOptions(opts...)
    baseURL := internal.ResolveBaseURL(
        options.BaseURL,
        r.baseURL,
        "",
    )
    endpointURL := baseURL + "/api/public/integrations/blob-storage"
    headers := internal.MergeHeaders(
        r.options.ToHeader(),
        options.ToHeader(),
    )
    var response *api.BlobStorageIntegrationsResponse
    raw, err := r.caller.Call(
        ctx,
        &internal.CallParams{
            URL: endpointURL,
            Method: http.MethodGet,
            Headers: headers,
            MaxAttempts: options.MaxAttempts,
            BodyProperties: options.BodyProperties,
            QueryParameters: options.QueryParameters,
            Client: options.HTTPClient,
            Response: &response,
            ErrorDecoder: internal.NewErrorDecoder(api.ErrorCodes),
        },
    )
    if err != nil {
        return nil, err
    }
    return &core.Response[*api.BlobStorageIntegrationsResponse]{
        StatusCode: raw.StatusCode,
        Header: raw.Header,
        Body: response,
    }, nil
}

func (r *RawClient) Upsertblobstorageintegration(
    ctx context.Context,
    request *api.CreateBlobStorageIntegrationRequest,
    opts ...option.RequestOption,
) (*core.Response[*api.BlobStorageIntegrationResponse], error){
    options := core.NewRequestOptions(opts...)
    baseURL := internal.ResolveBaseURL(
        options.BaseURL,
        r.baseURL,
        "",
    )
    endpointURL := baseURL + "/api/public/integrations/blob-storage"
    headers := internal.MergeHeaders(
        r.options.ToHeader(),
        options.ToHeader(),
    )
    headers.Add("Content-Type", "application/json")
    var response *api.BlobStorageIntegrationResponse
    raw, err := r.caller.Call(
        ctx,
        &internal.CallParams{
            URL: endpointURL,
            Method: http.MethodPut,
            Headers: headers,
            MaxAttempts: options.MaxAttempts,
            BodyProperties: options.BodyProperties,
            QueryParameters: options.QueryParameters,
            Client: options.HTTPClient,
            Request: request,
            Response: &response,
            ErrorDecoder: internal.NewErrorDecoder(api.ErrorCodes),
        },
    )
    if err != nil {
        return nil, err
    }
    return &core.Response[*api.BlobStorageIntegrationResponse]{
        StatusCode: raw.StatusCode,
        Header: raw.Header,
        Body: response,
    }, nil
}

func (r *RawClient) Deleteblobstorageintegration(
    ctx context.Context,
    request *api.BlobStorageIntegrationsDeleteBlobStorageIntegrationRequest,
    opts ...option.RequestOption,
) (*core.Response[*api.BlobStorageIntegrationDeletionResponse], error){
    options := core.NewRequestOptions(opts...)
    baseURL := internal.ResolveBaseURL(
        options.BaseURL,
        r.baseURL,
        "",
    )
    endpointURL := internal.EncodeURL(
        baseURL + "/api/public/integrations/blob-storage/%v",
        request.ID,
    )
    headers := internal.MergeHeaders(
        r.options.ToHeader(),
        options.ToHeader(),
    )
    var response *api.BlobStorageIntegrationDeletionResponse
    raw, err := r.caller.Call(
        ctx,
        &internal.CallParams{
            URL: endpointURL,
            Method: http.MethodDelete,
            Headers: headers,
            MaxAttempts: options.MaxAttempts,
            BodyProperties: options.BodyProperties,
            QueryParameters: options.QueryParameters,
            Client: options.HTTPClient,
            Response: &response,
            ErrorDecoder: internal.NewErrorDecoder(api.ErrorCodes),
        },
    )
    if err != nil {
        return nil, err
    }
    return &core.Response[*api.BlobStorageIntegrationDeletionResponse]{
        StatusCode: raw.StatusCode,
        Header: raw.Header,
        Body: response,
    }, nil
}

