// Code generated by Fern. DO NOT EDIT.

package organizations

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) Getorganizationmemberships(
    ctx context.Context,
    opts ...option.RequestOption,
) (*core.Response[*api.MembershipsResponse], error){
    options := core.NewRequestOptions(opts...)
    baseURL := internal.ResolveBaseURL(
        options.BaseURL,
        r.baseURL,
        "",
    )
    endpointURL := baseURL + "/api/public/organizations/memberships"
    headers := internal.MergeHeaders(
        r.options.ToHeader(),
        options.ToHeader(),
    )
    var response *api.MembershipsResponse
    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.MembershipsResponse]{
        StatusCode: raw.StatusCode,
        Header: raw.Header,
        Body: response,
    }, nil
}

func (r *RawClient) Updateorganizationmembership(
    ctx context.Context,
    request *api.MembershipRequest,
    opts ...option.RequestOption,
) (*core.Response[*api.MembershipResponse], error){
    options := core.NewRequestOptions(opts...)
    baseURL := internal.ResolveBaseURL(
        options.BaseURL,
        r.baseURL,
        "",
    )
    endpointURL := baseURL + "/api/public/organizations/memberships"
    headers := internal.MergeHeaders(
        r.options.ToHeader(),
        options.ToHeader(),
    )
    var response *api.MembershipResponse
    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.MembershipResponse]{
        StatusCode: raw.StatusCode,
        Header: raw.Header,
        Body: response,
    }, nil
}

func (r *RawClient) Deleteorganizationmembership(
    ctx context.Context,
    request *api.DeleteMembershipRequest,
    opts ...option.RequestOption,
) (*core.Response[*api.MembershipDeletionResponse], error){
    options := core.NewRequestOptions(opts...)
    baseURL := internal.ResolveBaseURL(
        options.BaseURL,
        r.baseURL,
        "",
    )
    endpointURL := baseURL + "/api/public/organizations/memberships"
    headers := internal.MergeHeaders(
        r.options.ToHeader(),
        options.ToHeader(),
    )
    var response *api.MembershipDeletionResponse
    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,
            Request: request,
            Response: &response,
            ErrorDecoder: internal.NewErrorDecoder(api.ErrorCodes),
        },
    )
    if err != nil {
        return nil, err
    }
    return &core.Response[*api.MembershipDeletionResponse]{
        StatusCode: raw.StatusCode,
        Header: raw.Header,
        Body: response,
    }, nil
}

func (r *RawClient) Getprojectmemberships(
    ctx context.Context,
    request *api.OrganizationsGetProjectMembershipsRequest,
    opts ...option.RequestOption,
) (*core.Response[*api.MembershipsResponse], error){
    options := core.NewRequestOptions(opts...)
    baseURL := internal.ResolveBaseURL(
        options.BaseURL,
        r.baseURL,
        "",
    )
    endpointURL := internal.EncodeURL(
        baseURL + "/api/public/projects/%v/memberships",
        request.ProjectID,
    )
    headers := internal.MergeHeaders(
        r.options.ToHeader(),
        options.ToHeader(),
    )
    var response *api.MembershipsResponse
    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.MembershipsResponse]{
        StatusCode: raw.StatusCode,
        Header: raw.Header,
        Body: response,
    }, nil
}

func (r *RawClient) Updateprojectmembership(
    ctx context.Context,
    request *api.OrganizationsUpdateProjectMembershipRequest,
    opts ...option.RequestOption,
) (*core.Response[*api.MembershipResponse], error){
    options := core.NewRequestOptions(opts...)
    baseURL := internal.ResolveBaseURL(
        options.BaseURL,
        r.baseURL,
        "",
    )
    endpointURL := internal.EncodeURL(
        baseURL + "/api/public/projects/%v/memberships",
        request.ProjectID,
    )
    headers := internal.MergeHeaders(
        r.options.ToHeader(),
        options.ToHeader(),
    )
    headers.Add("Content-Type", "application/json")
    var response *api.MembershipResponse
    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.MembershipResponse]{
        StatusCode: raw.StatusCode,
        Header: raw.Header,
        Body: response,
    }, nil
}

func (r *RawClient) Deleteprojectmembership(
    ctx context.Context,
    request *api.OrganizationsDeleteProjectMembershipRequest,
    opts ...option.RequestOption,
) (*core.Response[*api.MembershipDeletionResponse], error){
    options := core.NewRequestOptions(opts...)
    baseURL := internal.ResolveBaseURL(
        options.BaseURL,
        r.baseURL,
        "",
    )
    endpointURL := internal.EncodeURL(
        baseURL + "/api/public/projects/%v/memberships",
        request.ProjectID,
    )
    headers := internal.MergeHeaders(
        r.options.ToHeader(),
        options.ToHeader(),
    )
    headers.Add("Content-Type", "application/json")
    var response *api.MembershipDeletionResponse
    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,
            Request: request,
            Response: &response,
            ErrorDecoder: internal.NewErrorDecoder(api.ErrorCodes),
        },
    )
    if err != nil {
        return nil, err
    }
    return &core.Response[*api.MembershipDeletionResponse]{
        StatusCode: raw.StatusCode,
        Header: raw.Header,
        Body: response,
    }, nil
}

func (r *RawClient) Getorganizationprojects(
    ctx context.Context,
    opts ...option.RequestOption,
) (*core.Response[*api.OrganizationProjectsResponse], error){
    options := core.NewRequestOptions(opts...)
    baseURL := internal.ResolveBaseURL(
        options.BaseURL,
        r.baseURL,
        "",
    )
    endpointURL := baseURL + "/api/public/organizations/projects"
    headers := internal.MergeHeaders(
        r.options.ToHeader(),
        options.ToHeader(),
    )
    var response *api.OrganizationProjectsResponse
    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.OrganizationProjectsResponse]{
        StatusCode: raw.StatusCode,
        Header: raw.Header,
        Body: response,
    }, nil
}

func (r *RawClient) Getorganizationapikeys(
    ctx context.Context,
    opts ...option.RequestOption,
) (*core.Response[*api.OrganizationAPIKeysResponse], error){
    options := core.NewRequestOptions(opts...)
    baseURL := internal.ResolveBaseURL(
        options.BaseURL,
        r.baseURL,
        "",
    )
    endpointURL := baseURL + "/api/public/organizations/apiKeys"
    headers := internal.MergeHeaders(
        r.options.ToHeader(),
        options.ToHeader(),
    )
    var response *api.OrganizationAPIKeysResponse
    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.OrganizationAPIKeysResponse]{
        StatusCode: raw.StatusCode,
        Header: raw.Header,
        Body: response,
    }, nil
}

