-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fef83d3
commit f8a7e75
Showing
8 changed files
with
313 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// File generated from our OpenAPI spec by Stainless. | ||
|
||
import * as Core from 'cloudflare/core'; | ||
import { APIResource } from 'cloudflare/resource'; | ||
import { isRequestOptions } from 'cloudflare/core'; | ||
import * as DomainAPI from 'cloudflare/resources/radar/ranking/domain'; | ||
|
||
export class Domain extends APIResource { | ||
/** | ||
* Gets Domains Rank details. Cloudflare provides an ordered rank for the top 100 | ||
* domains, but for the remainder it only provides ranking buckets like top 200 | ||
* thousand, top one million, etc.. These are available through Radar datasets | ||
* endpoints. | ||
*/ | ||
get( | ||
domain: string, | ||
query?: DomainGetParams, | ||
options?: Core.RequestOptions, | ||
): Core.APIPromise<DomainGetResponse>; | ||
get(domain: string, options?: Core.RequestOptions): Core.APIPromise<DomainGetResponse>; | ||
get( | ||
domain: string, | ||
query: DomainGetParams | Core.RequestOptions = {}, | ||
options?: Core.RequestOptions, | ||
): Core.APIPromise<DomainGetResponse> { | ||
if (isRequestOptions(query)) { | ||
return this.get(domain, {}, query); | ||
} | ||
return ( | ||
this._client.get(`/radar/ranking/domain/${domain}`, { query, ...options }) as Core.APIPromise<{ | ||
result: DomainGetResponse; | ||
}> | ||
)._thenUnwrap((obj) => obj.result); | ||
} | ||
} | ||
|
||
export interface DomainGetResponse { | ||
details_0: DomainGetResponse.Details0; | ||
} | ||
|
||
export namespace DomainGetResponse { | ||
export interface Details0 { | ||
categories: Array<Details0.Category>; | ||
|
||
top_locations: Array<Details0.TopLocation>; | ||
|
||
/** | ||
* Only available in POPULAR ranking for the most recent ranking. | ||
*/ | ||
bucket?: string; | ||
|
||
rank?: number; | ||
} | ||
|
||
export namespace Details0 { | ||
export interface Category { | ||
id: number; | ||
|
||
name: string; | ||
|
||
superCategoryId: number; | ||
} | ||
|
||
export interface TopLocation { | ||
locationCode: string; | ||
|
||
locationName: string; | ||
|
||
rank: number; | ||
} | ||
} | ||
} | ||
|
||
export interface DomainGetParams { | ||
/** | ||
* Array of dates to filter the ranking. | ||
*/ | ||
date?: Array<string | null>; | ||
|
||
/** | ||
* Format results are returned in. | ||
*/ | ||
format?: 'JSON' | 'CSV'; | ||
|
||
/** | ||
* Limit the number of objects in the response. | ||
*/ | ||
limit?: number; | ||
|
||
/** | ||
* Array of names that will be used to name the series in responses. | ||
*/ | ||
name?: Array<string>; | ||
|
||
/** | ||
* The ranking type. | ||
*/ | ||
rankingType?: 'POPULAR' | 'TRENDING_RISE' | 'TRENDING_STEADY'; | ||
} | ||
|
||
export namespace Domain { | ||
export import DomainGetResponse = DomainAPI.DomainGetResponse; | ||
export import DomainGetParams = DomainAPI.DomainGetParams; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
// File generated from our OpenAPI spec by Stainless. | ||
|
||
export { DomainGetResponse, DomainGetParams, Domain } from './domain'; | ||
export { | ||
RankingGetResponse, | ||
RankingTimeseriesGroupsResponse, | ||
RankingTopResponse, | ||
RankingGetParams, | ||
RankingTimeseriesGroupsParams, | ||
RankingTopParams, | ||
Ranking, | ||
} from './ranking'; | ||
export { RankingTimeseriesGroupsResponse, RankingTimeseriesGroupsParams, Ranking } from './ranking'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// File generated from our OpenAPI spec by Stainless. | ||
|
||
import Cloudflare from 'cloudflare'; | ||
import { Response } from 'node-fetch'; | ||
|
||
const cloudflare = new Cloudflare({ | ||
apiKey: '144c9defac04969c7bfad8efaa8ea194', | ||
apiEmail: 'user@example.com', | ||
apiToken: 'Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY', | ||
userServiceKey: | ||
'v1.0-144c9defac04969c7bfad8ef-631a41d003a32d25fe878081ef365c49503f7fada600da935e2851a1c7326084b85cbf6429c4b859de8475731dc92a9c329631e6d59e6c73da7b198497172b4cefe071d90d0f5d2719', | ||
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', | ||
}); | ||
|
||
describe('resource domain', () => { | ||
// skipped: tests are disabled for the time being | ||
test.skip('get', async () => { | ||
const responsePromise = cloudflare.radar.ranking.domain.get('google.com'); | ||
const rawResponse = await responsePromise.asResponse(); | ||
expect(rawResponse).toBeInstanceOf(Response); | ||
const response = await responsePromise; | ||
expect(response).not.toBeInstanceOf(Response); | ||
const dataAndResponse = await responsePromise.withResponse(); | ||
expect(dataAndResponse.data).toBe(response); | ||
expect(dataAndResponse.response).toBe(rawResponse); | ||
}); | ||
|
||
// skipped: tests are disabled for the time being | ||
test.skip('get: request options instead of params are passed correctly', async () => { | ||
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error | ||
await expect( | ||
cloudflare.radar.ranking.domain.get('google.com', { path: '/_stainless_unknown_path' }), | ||
).rejects.toThrow(Cloudflare.NotFoundError); | ||
}); | ||
|
||
// skipped: tests are disabled for the time being | ||
test.skip('get: request options and params are passed correctly', async () => { | ||
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error | ||
await expect( | ||
cloudflare.radar.ranking.domain.get( | ||
'google.com', | ||
{ | ||
date: ['string', 'string', 'string'], | ||
format: 'JSON', | ||
limit: 5, | ||
name: ['string', 'string', 'string'], | ||
rankingType: 'POPULAR', | ||
}, | ||
{ path: '/_stainless_unknown_path' }, | ||
), | ||
).rejects.toThrow(Cloudflare.NotFoundError); | ||
}); | ||
}); |
Oops, something went wrong.