Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SeamHttpRequest #67

Merged
merged 33 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8446bfe
Add SeamApiRequest
phpnode Mar 25, 2024
d61f528
Use SeamApiRequest for api responses
phpnode Mar 25, 2024
38c760a
ci: Format code
seambot Mar 25, 2024
05df01d
Lint fixes
phpnode Mar 25, 2024
f491eec
Merge branch 'seam-api-request' of github.com:seamapi/javascript-http…
phpnode Mar 25, 2024
c65c834
SeamApiRequest -> SeamHttpRequest
phpnode Mar 26, 2024
4ba810d
Make url, method, data properties of SeamHttpRequest
phpnode Mar 26, 2024
bc1340c
Fix generate-routes
phpnode Mar 26, 2024
5a75eae
Move test for SeamHttpRequest into its own file
phpnode Mar 26, 2024
d8d3722
ci: Format code
seambot Mar 26, 2024
5b49368
ci: Format code
seambot Mar 26, 2024
28589a3
Add 'Inspecting The Request' to the README
phpnode Mar 26, 2024
9633c14
Fix whitespace in README
phpnode Mar 26, 2024
724ad99
Consolidate config into SeamHttpRequestConfig
phpnode Mar 26, 2024
d8863db
Move ResponseFromSeamHttpRequest to test
phpnode Mar 26, 2024
955ae8e
Align request properties with URL spec
phpnode Mar 26, 2024
c265dfb
Add url property to SeamHttpRequest
phpnode Mar 26, 2024
93eb85e
Rename data -> body
phpnode Mar 26, 2024
a4c3266
Method is not nullable
phpnode Mar 26, 2024
af32603
Update README after Evan's suggestion
phpnode Mar 26, 2024
d5de77d
Update README.md
phpnode Mar 26, 2024
f963b61
Rename query -> params because it's more inline with our naming
phpnode Mar 26, 2024
56f04b7
Merge branch 'seam-api-request' of github.com:seamapi/javascript-http…
phpnode Mar 26, 2024
088414a
Update src/lib/seam/connect/seam-http-request.ts
phpnode Mar 26, 2024
951856e
Use client.defaults.paramsSerializer if possible
phpnode Mar 26, 2024
f38c34d
Merge branch 'seam-api-request' of github.com:seamapi/javascript-http…
phpnode Mar 26, 2024
c157717
Test for URL object property matches
razor-x Mar 26, 2024
b3de0cd
Add tests for endpoints with and without origins
razor-x Mar 26, 2024
871474a
Use template literal over join
razor-x Mar 27, 2024
4da3af6
ci: Format code
seambot Mar 27, 2024
34efe7d
Use URL.canParse
razor-x Mar 27, 2024
0f96c30
Merge pull request #69 from seamapi/seam-api-request-url
phpnode Mar 27, 2024
65021e4
Remove TBody type parameter
phpnode Mar 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions generate-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ import {
import {
resolveActionAttempt,
} from 'lib/seam/connect/resolve-action-attempt.js'
import { SeamApiRequest } from 'lib/seam/connect/seam-api-request.js'

${
namespace === 'client_sessions'
Expand Down Expand Up @@ -354,41 +355,28 @@ const renderClassMethod = ({
path,
isRequestParamOptional,
}: Endpoint): string => `
async ${camelCase(name)}(
${camelCase(name)}(
${requestFormat}${isRequestParamOptional ? '?' : ''}: ${renderRequestType({
name,
namespace,
})},
${renderClassMethodOptions({ resource })}
): Promise<${
resource === null
? 'void'
: `${renderResponseType({ name, namespace })}['${resource}']`
}> {
${
resource === null ? '' : 'const { data } = '
}await this.client.request<${renderResponseType({
): SeamApiRequest<${isRequestParamOptional ? 'undefined | ' : ''}${renderRequestType(
{
name,
namespace,
})}>({
},
)}, ${
resource === null
? 'void, undefined'
: `${renderResponseType({ name, namespace })}, '${resource}'`
}> {
return new SeamApiRequest(this, {
url: '${path}',
method: '${snakeCase(method)}', ${
requestFormat === 'params' ? 'params,' : ''
} ${requestFormat === 'body' ? 'data: body,' : ''}
})
${
resource === 'action_attempt'
? `const waitForActionAttempt = options.waitForActionAttempt ?? this.defaults.waitForActionAttempt
if (waitForActionAttempt !== false) {
return resolveActionAttempt(
data.${resource},
SeamHttpActionAttempts.fromClient(this.client, { ...this.defaults, waitForActionAttempt: false }),
typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt,
)
}`
: ''
}
${resource === null ? '' : `return data.${resource}`}
}, ${resource === null ? 'undefined' : `'${resource}'`}${resource === 'action_attempt' ? ', options' : ''})
}
`

Expand Down
100 changes: 69 additions & 31 deletions src/lib/seam/connect/routes/access-codes-unmanaged.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading