// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package abuse_reports_test

import (
	"context"
	"errors"
	"os"
	"testing"

	"github.com/cloudflare/cloudflare-go/v6"
	"github.com/cloudflare/cloudflare-go/v6/abuse_reports"
	"github.com/cloudflare/cloudflare-go/v6/internal/testutil"
	"github.com/cloudflare/cloudflare-go/v6/option"
)

func TestAbuseReportNewWithOptionalParams(t *testing.T) {
	t.Skip("TODO: investigate unauthorized HTTP response")
	baseURL := "http://localhost:4010"
	if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
		baseURL = envURL
	}
	if !testutil.CheckTestServer(t, baseURL) {
		return
	}
	client := cloudflare.NewClient(
		option.WithBaseURL(baseURL),
		option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
		option.WithAPIEmail("user@example.com"),
	)
	_, err := client.AbuseReports.New(
		context.TODO(),
		"report_param",
		abuse_reports.AbuseReportNewParams{
			AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
			Body: abuse_reports.AbuseReportNewParamsBodyAbuseReportsDmcaReport{
				Act:               cloudflare.F(abuse_reports.AbuseReportNewParamsBodyAbuseReportsDmcaReportActAbuseDmca),
				Address1:          cloudflare.F("x"),
				AgentName:         cloudflare.F("x"),
				Agree:             cloudflare.F(abuse_reports.AbuseReportNewParamsBodyAbuseReportsDmcaReportAgree1),
				City:              cloudflare.F("x"),
				Country:           cloudflare.F("x"),
				Email:             cloudflare.F("email"),
				Email2:            cloudflare.F("email2"),
				HostNotification:  cloudflare.F(abuse_reports.AbuseReportNewParamsBodyAbuseReportsDmcaReportHostNotificationSend),
				Name:              cloudflare.F("x"),
				OriginalWork:      cloudflare.F("x"),
				OwnerNotification: cloudflare.F(abuse_reports.AbuseReportNewParamsBodyAbuseReportsDmcaReportOwnerNotificationSend),
				Signature:         cloudflare.F("signature"),
				State:             cloudflare.F("x"),
				URLs:              cloudflare.F("urls"),
				Comments:          cloudflare.F("x"),
				Company:           cloudflare.F("x"),
				ReportedCountry:   cloudflare.F("xx"),
				ReportedUserAgent: cloudflare.F("x"),
				Tele:              cloudflare.F("x"),
				Title:             cloudflare.F("x"),
			},
		},
	)
	if err != nil {
		var apierr *cloudflare.Error
		if errors.As(err, &apierr) {
			t.Log(string(apierr.DumpRequest(true)))
		}
		t.Fatalf("err should be nil: %s", err.Error())
	}
}

func TestAbuseReportListWithOptionalParams(t *testing.T) {
	t.Skip("TODO: support api token auth scheme")
	baseURL := "http://localhost:4010"
	if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
		baseURL = envURL
	}
	if !testutil.CheckTestServer(t, baseURL) {
		return
	}
	client := cloudflare.NewClient(
		option.WithBaseURL(baseURL),
		option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
		option.WithAPIEmail("user@example.com"),
	)
	_, err := client.AbuseReports.List(context.TODO(), abuse_reports.AbuseReportListParams{
		AccountID:        cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
		CreatedAfter:     cloudflare.F("2009-11-10T23:00:00Z"),
		CreatedBefore:    cloudflare.F("2009-11-10T23:00:00Z"),
		Domain:           cloudflare.F("domain"),
		MitigationStatus: cloudflare.F(abuse_reports.AbuseReportListParamsMitigationStatusPending),
		Page:             cloudflare.F(int64(0)),
		PerPage:          cloudflare.F(int64(0)),
		Sort:             cloudflare.F("sort"),
		Status:           cloudflare.F(abuse_reports.AbuseReportListParamsStatusAccepted),
		Type:             cloudflare.F(abuse_reports.AbuseReportListParamsTypePhish),
	})
	if err != nil {
		var apierr *cloudflare.Error
		if errors.As(err, &apierr) {
			t.Log(string(apierr.DumpRequest(true)))
		}
		t.Fatalf("err should be nil: %s", err.Error())
	}
}

func TestAbuseReportGet(t *testing.T) {
	t.Skip("TODO: support api token auth scheme")
	baseURL := "http://localhost:4010"
	if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
		baseURL = envURL
	}
	if !testutil.CheckTestServer(t, baseURL) {
		return
	}
	client := cloudflare.NewClient(
		option.WithBaseURL(baseURL),
		option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
		option.WithAPIEmail("user@example.com"),
	)
	_, err := client.AbuseReports.Get(
		context.TODO(),
		"report_param",
		abuse_reports.AbuseReportGetParams{
			AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
		},
	)
	if err != nil {
		var apierr *cloudflare.Error
		if errors.As(err, &apierr) {
			t.Log(string(apierr.DumpRequest(true)))
		}
		t.Fatalf("err should be nil: %s", err.Error())
	}
}
