diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f14b480..aaf968a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.2" + ".": "0.1.0-alpha.3" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 79f3b26..e458891 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 6 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/find-ai%2Ffind-ai-bf9b5b8a950e0a79b0bf1911bf01feb5a3575113be8f5d24f7b487351f3470c5.yml +configured_endpoints: 2 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/find-ai%2Ffind-ai-703a90257c6ec20e6b67cbb97b6699e96ffef05e62249c4d98bd8fb5b197617d.yml diff --git a/Brewfile b/Brewfile new file mode 100644 index 0000000..577e34a --- /dev/null +++ b/Brewfile @@ -0,0 +1 @@ +brew "go" diff --git a/CHANGELOG.md b/CHANGELOG.md index 6faf868..064623c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.1.0-alpha.3 (2024-10-02) + +Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/Find-AI/find-ai-go/compare/v0.1.0-alpha.2...v0.1.0-alpha.3) + +### Features + +* **api:** OpenAPI spec update via Stainless API ([#9](https://github.com/Find-AI/find-ai-go/issues/9)) ([d41d1a8](https://github.com/Find-AI/find-ai-go/commit/d41d1a890eb84119d69adb5dce51956f8aa473ec)) + + +### Chores + +* **internal:** codegen related update ([#11](https://github.com/Find-AI/find-ai-go/issues/11)) ([d0ee6be](https://github.com/Find-AI/find-ai-go/commit/d0ee6be7f1d08ec88d5ac64116dbcb61f8c8716c)) + ## 0.1.0-alpha.2 (2024-09-26) Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/Find-AI/find-ai-go/compare/v0.1.0-alpha.1...v0.1.0-alpha.2) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 273af6f..6884853 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,8 +1,15 @@ ## Setting up the environment -### Install Go 1.18+ +To set up the repository, run: -Install go by following relevant directions [here](https://go.dev/doc/install). +```sh +$ ./scripts/bootstrap +$ ./scripts/build +``` + +This will install all the required dependencies and build the SDK. + +You can also [install go 1.18+ manually](https://go.dev/doc/install). ## Modifying/Adding code @@ -14,7 +21,7 @@ modify the contents of the `lib/` and `examples/` directories. All files in the `examples/` directory are not modified by the generator and can be freely edited or added to. -```bash +```go # add an example to examples//main.go package main @@ -24,8 +31,8 @@ func main() { } ``` -```bash -go run ./examples/ +```sh +$ go run ./examples/ ``` ## Using the repository from source @@ -33,27 +40,27 @@ go run ./examples/ To use a local version of this library from source in another project, edit the `go.mod` with a replace directive. This can be done through the CLI with the following: -```bash -go mod edit -replace github.com/Find-AI/find-ai-go=/path/to/find-ai-go +```sh +$ go mod edit -replace github.com/Find-AI/find-ai-go=/path/to/find-ai-go ``` ## Running tests Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. -```bash +```sh # you will need npm installed -npx prism mock path/to/your/openapi.yml +$ npx prism mock path/to/your/openapi.yml ``` -```bash -go test ./... +```sh +$ ./scripts/test ``` ## Formatting This library uses the standard gofmt code formatter: -```bash -gofmt -s -w . +```sh +$ ./scripts/format ``` diff --git a/README.md b/README.md index c18bddb..99d5569 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Or to pin the version: ```sh -go get -u 'github.com/Find-AI/find-ai-go@v0.1.0-alpha.2' +go get -u 'github.com/Find-AI/find-ai-go@v0.1.0-alpha.3' ``` @@ -336,3 +336,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. We are keen for your feedback; please open an [issue](https://www.github.com/Find-AI/find-ai-go/issues) with questions, bugs, or suggestions. + +## Contributing + +See [the contributing documentation](./CONTRIBUTING.md). diff --git a/api.md b/api.md index 0b32c50..3475963 100644 --- a/api.md +++ b/api.md @@ -2,30 +2,10 @@ ## Enrich -Response Types: - -- findai.CompanyEnrichmentEnrichNewResponse -- findai.CompanyEnrichmentEnrichGetResponse - -Methods: - -- client.CompanyEnrichment.Enrich.New(ctx context.Context, body findai.CompanyEnrichmentEnrichNewParams) (findai.CompanyEnrichmentEnrichNewResponse, error) -- client.CompanyEnrichment.Enrich.Get(ctx context.Context, token string) (findai.CompanyEnrichmentEnrichGetResponse, error) - # PeopleEnrichment ## Enrich -Response Types: - -- findai.PeopleEnrichmentEnrichNewResponse -- findai.PeopleEnrichmentEnrichGetResponse - -Methods: - -- client.PeopleEnrichment.Enrich.New(ctx context.Context, body findai.PeopleEnrichmentEnrichNewParams) (findai.PeopleEnrichmentEnrichNewResponse, error) -- client.PeopleEnrichment.Enrich.Get(ctx context.Context, token string) (findai.PeopleEnrichmentEnrichGetResponse, error) - # Searches Response Types: diff --git a/companyenrichmentenrich.go b/companyenrichmentenrich.go index 5a9d3ad..f07eb3a 100644 --- a/companyenrichmentenrich.go +++ b/companyenrichmentenrich.go @@ -3,14 +3,6 @@ package findai import ( - "context" - "errors" - "fmt" - "net/http" - - "github.com/Find-AI/find-ai-go/internal/apijson" - "github.com/Find-AI/find-ai-go/internal/param" - "github.com/Find-AI/find-ai-go/internal/requestconfig" "github.com/Find-AI/find-ai-go/option" ) @@ -32,103 +24,3 @@ func NewCompanyEnrichmentEnrichService(opts ...option.RequestOption) (r *Company r.Options = opts return } - -// Returns structured data about a company based on a domain input. -func (r *CompanyEnrichmentEnrichService) New(ctx context.Context, body CompanyEnrichmentEnrichNewParams, opts ...option.RequestOption) (res *CompanyEnrichmentEnrichNewResponse, err error) { - opts = append(r.Options[:], opts...) - path := "v1/companies/enrich" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - -// The endpoint to poll to check the latest results when data about a company isn't -// immediately available. -func (r *CompanyEnrichmentEnrichService) Get(ctx context.Context, token string, opts ...option.RequestOption) (res *CompanyEnrichmentEnrichGetResponse, err error) { - opts = append(r.Options[:], opts...) - if token == "" { - err = errors.New("missing required token parameter") - return - } - path := fmt.Sprintf("v1/companies/enrich/%s", token) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -type CompanyEnrichmentEnrichNewResponse struct { - // A list of facts we have on record about the company. - Facts []string `json:"facts,required"` - Name string `json:"name,required"` - // A summary of information about the company. - ShortDescription string `json:"short_description,required"` - Website string `json:"website,required"` - // The URL to the company's LinkedIn profile if one exists. - LinkedinURL string `json:"linkedin_url"` - // A URL to an image of the company's logo. Valid for 10 minutes. - PhotoURL string `json:"photo_url"` - JSON companyEnrichmentEnrichNewResponseJSON `json:"-"` -} - -// companyEnrichmentEnrichNewResponseJSON contains the JSON metadata for the struct -// [CompanyEnrichmentEnrichNewResponse] -type companyEnrichmentEnrichNewResponseJSON struct { - Facts apijson.Field - Name apijson.Field - ShortDescription apijson.Field - Website apijson.Field - LinkedinURL apijson.Field - PhotoURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CompanyEnrichmentEnrichNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r companyEnrichmentEnrichNewResponseJSON) RawJSON() string { - return r.raw -} - -type CompanyEnrichmentEnrichGetResponse struct { - // A list of facts we have on record about the company. - Facts []string `json:"facts,required"` - Name string `json:"name,required"` - // A summary of information about the company. - ShortDescription string `json:"short_description,required"` - Website string `json:"website,required"` - // The URL to the company's LinkedIn profile if one exists. - LinkedinURL string `json:"linkedin_url"` - // A URL to an image of the company's logo. Valid for 10 minutes. - PhotoURL string `json:"photo_url"` - JSON companyEnrichmentEnrichGetResponseJSON `json:"-"` -} - -// companyEnrichmentEnrichGetResponseJSON contains the JSON metadata for the struct -// [CompanyEnrichmentEnrichGetResponse] -type companyEnrichmentEnrichGetResponseJSON struct { - Facts apijson.Field - Name apijson.Field - ShortDescription apijson.Field - Website apijson.Field - LinkedinURL apijson.Field - PhotoURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CompanyEnrichmentEnrichGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r companyEnrichmentEnrichGetResponseJSON) RawJSON() string { - return r.raw -} - -type CompanyEnrichmentEnrichNewParams struct { - // The domain of the company. - Domain param.Field[string] `json:"domain"` -} - -func (r CompanyEnrichmentEnrichNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} diff --git a/companyenrichmentenrich_test.go b/companyenrichmentenrich_test.go deleted file mode 100644 index 0f7f32f..0000000 --- a/companyenrichmentenrich_test.go +++ /dev/null @@ -1,60 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package findai_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/Find-AI/find-ai-go" - "github.com/Find-AI/find-ai-go/internal/testutil" - "github.com/Find-AI/find-ai-go/option" -) - -func TestCompanyEnrichmentEnrichNewWithOptionalParams(t *testing.T) { - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := findai.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("My API Key"), - ) - _, err := client.CompanyEnrichment.Enrich.New(context.TODO(), findai.CompanyEnrichmentEnrichNewParams{ - Domain: findai.F("domain"), - }) - if err != nil { - var apierr *findai.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestCompanyEnrichmentEnrichGet(t *testing.T) { - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := findai.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("My API Key"), - ) - _, err := client.CompanyEnrichment.Enrich.Get(context.TODO(), "token") - if err != nil { - var apierr *findai.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} diff --git a/internal/version.go b/internal/version.go index d6f40b3..2d1d85e 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.1.0-alpha.2" // x-release-please-version +const PackageVersion = "0.1.0-alpha.3" // x-release-please-version diff --git a/peopleenrichmentenrich.go b/peopleenrichmentenrich.go index 7d513b3..7d6fda2 100644 --- a/peopleenrichmentenrich.go +++ b/peopleenrichmentenrich.go @@ -3,14 +3,6 @@ package findai import ( - "context" - "errors" - "fmt" - "net/http" - - "github.com/Find-AI/find-ai-go/internal/apijson" - "github.com/Find-AI/find-ai-go/internal/param" - "github.com/Find-AI/find-ai-go/internal/requestconfig" "github.com/Find-AI/find-ai-go/option" ) @@ -32,118 +24,3 @@ func NewPeopleEnrichmentEnrichService(opts ...option.RequestOption) (r *PeopleEn r.Options = opts return } - -// Returns structured data about a person based on their business email address. -func (r *PeopleEnrichmentEnrichService) New(ctx context.Context, body PeopleEnrichmentEnrichNewParams, opts ...option.RequestOption) (res *PeopleEnrichmentEnrichNewResponse, err error) { - opts = append(r.Options[:], opts...) - path := "v1/people/enrich" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - -// The endpoint to poll to check the latest results when data about a person isn't -// immediately available. -func (r *PeopleEnrichmentEnrichService) Get(ctx context.Context, token string, opts ...option.RequestOption) (res *PeopleEnrichmentEnrichGetResponse, err error) { - opts = append(r.Options[:], opts...) - if token == "" { - err = errors.New("missing required token parameter") - return - } - path := fmt.Sprintf("v1/people/enrich/%s", token) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -type PeopleEnrichmentEnrichNewResponse struct { - Designation string `json:"designation,required"` - Email string `json:"email,required"` - // A list of facts we have on record about the person. - Facts []string `json:"facts,required"` - FirstName string `json:"first_name,required"` - LastName string `json:"last_name,required"` - Name string `json:"name,required"` - // A summary of information about the person. - ShortDescription string `json:"short_description,required"` - // The URL to the person's LinkedIn profile if one exists. - LinkedinURL string `json:"linkedin_url"` - // A URL to the person's profile image obtained from LinkedIn. Valid for 10 - // minutes. - PhotoURL string `json:"photo_url"` - JSON peopleEnrichmentEnrichNewResponseJSON `json:"-"` -} - -// peopleEnrichmentEnrichNewResponseJSON contains the JSON metadata for the struct -// [PeopleEnrichmentEnrichNewResponse] -type peopleEnrichmentEnrichNewResponseJSON struct { - Designation apijson.Field - Email apijson.Field - Facts apijson.Field - FirstName apijson.Field - LastName apijson.Field - Name apijson.Field - ShortDescription apijson.Field - LinkedinURL apijson.Field - PhotoURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PeopleEnrichmentEnrichNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r peopleEnrichmentEnrichNewResponseJSON) RawJSON() string { - return r.raw -} - -type PeopleEnrichmentEnrichGetResponse struct { - Designation string `json:"designation,required"` - Email string `json:"email,required"` - // A list of facts we have on record about the person. - Facts []string `json:"facts,required"` - FirstName string `json:"first_name,required"` - LastName string `json:"last_name,required"` - Name string `json:"name,required"` - // A summary of information about the person. - ShortDescription string `json:"short_description,required"` - // The URL to the person's LinkedIn profile if one exists. - LinkedinURL string `json:"linkedin_url"` - // A URL to the person's profile image obtained from LinkedIn. Valid for 10 - // minutes. - PhotoURL string `json:"photo_url"` - JSON peopleEnrichmentEnrichGetResponseJSON `json:"-"` -} - -// peopleEnrichmentEnrichGetResponseJSON contains the JSON metadata for the struct -// [PeopleEnrichmentEnrichGetResponse] -type peopleEnrichmentEnrichGetResponseJSON struct { - Designation apijson.Field - Email apijson.Field - Facts apijson.Field - FirstName apijson.Field - LastName apijson.Field - Name apijson.Field - ShortDescription apijson.Field - LinkedinURL apijson.Field - PhotoURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PeopleEnrichmentEnrichGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r peopleEnrichmentEnrichGetResponseJSON) RawJSON() string { - return r.raw -} - -type PeopleEnrichmentEnrichNewParams struct { - // The person's business email address. We won't accept personal email address such - // as Gmail, Yahoo etc. - Email param.Field[string] `json:"email"` -} - -func (r PeopleEnrichmentEnrichNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} diff --git a/peopleenrichmentenrich_test.go b/peopleenrichmentenrich_test.go deleted file mode 100644 index 859ca43..0000000 --- a/peopleenrichmentenrich_test.go +++ /dev/null @@ -1,60 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package findai_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/Find-AI/find-ai-go" - "github.com/Find-AI/find-ai-go/internal/testutil" - "github.com/Find-AI/find-ai-go/option" -) - -func TestPeopleEnrichmentEnrichNewWithOptionalParams(t *testing.T) { - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := findai.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("My API Key"), - ) - _, err := client.PeopleEnrichment.Enrich.New(context.TODO(), findai.PeopleEnrichmentEnrichNewParams{ - Email: findai.F("email"), - }) - if err != nil { - var apierr *findai.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestPeopleEnrichmentEnrichGet(t *testing.T) { - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := findai.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("My API Key"), - ) - _, err := client.PeopleEnrichment.Enrich.Get(context.TODO(), "token") - if err != nil { - var apierr *findai.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -}