Documentation
¶
Overview ¶
Package otp provides primitives to interact with the openapi HTTP API.
Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.8.2 DO NOT EDIT.
Index ¶
- func NewCheckCodeRequest(server string, body CheckCodeJSONRequestBody) (*http.Request, error)
- func NewCheckCodeRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)
- func NewSendCodeRequest(server string, body SendCodeJSONRequestBody) (*http.Request, error)
- func NewSendCodeRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)
- type CheckCodeJSONRequestBody
- type CheckCodeResponse
- type CheckResult
- type Client
- func (c *Client) CheckCode(ctx context.Context, body CheckCodeJSONRequestBody, ...) (*http.Response, error)
- func (c *Client) CheckCodeWithBody(ctx context.Context, contentType string, body io.Reader, ...) (*http.Response, error)
- func (c *Client) SendCode(ctx context.Context, body SendCodeJSONRequestBody, ...) (*http.Response, error)
- func (c *Client) SendCodeWithBody(ctx context.Context, contentType string, body io.Reader, ...) (*http.Response, error)
- type ClientInterface
- type ClientOption
- type ClientWithResponses
- func (c *ClientWithResponses) CheckCodeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, ...) (*CheckCodeResponse, error)
- func (c *ClientWithResponses) CheckCodeWithResponse(ctx context.Context, body CheckCodeJSONRequestBody, ...) (*CheckCodeResponse, error)
- func (c *ClientWithResponses) SendCodeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, ...) (*SendCodeResponse, error)
- func (c *ClientWithResponses) SendCodeWithResponse(ctx context.Context, body SendCodeJSONRequestBody, ...) (*SendCodeResponse, error)
- type ClientWithResponsesInterface
- type CodeCheck
- type Envelope
- type Failure
- type HttpRequestDoer
- type Message
- type NewCode
- type RequestEditorFn
- type SendCodeJSONRequestBody
- type SendCodeResponse
- type SentCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCheckCodeRequest ¶
func NewCheckCodeRequest(server string, body CheckCodeJSONRequestBody) (*http.Request, error)
NewCheckCodeRequest calls the generic CheckCode builder with application/json body
func NewCheckCodeRequestWithBody ¶
func NewCheckCodeRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)
NewCheckCodeRequestWithBody constructs an http.Request for the CheckCode method, with any body, and a specified content type
func NewSendCodeRequest ¶
func NewSendCodeRequest(server string, body SendCodeJSONRequestBody) (*http.Request, error)
NewSendCodeRequest calls the generic SendCode builder with application/json body
Types ¶
type CheckCodeJSONRequestBody ¶
type CheckCodeJSONRequestBody = CodeCheck
CheckCodeJSONRequestBody defines body for CheckCode for application/json ContentType.
type CheckCodeResponse ¶
type CheckCodeResponse struct {
Body []byte
HTTPResponse *http.Response
// JSON200 the response for an HTTP 200 `application/json` response
JSON200 *struct {
Errors []Message `json:"errors"`
Messages []Message `json:"messages"`
Result CheckResult `json:"result"`
Success bool `json:"success"`
}
// JSONDefault the response for an HTTP default `application/json` response
JSONDefault *Failure
}
func ParseCheckCodeResponse ¶
func ParseCheckCodeResponse(rsp *http.Response) (*CheckCodeResponse, error)
ParseCheckCodeResponse parses an HTTP response from a CheckCodeWithResponse call
func (CheckCodeResponse) ContentType ¶
func (r CheckCodeResponse) ContentType() string
ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
func (CheckCodeResponse) GetBody ¶
func (r CheckCodeResponse) GetBody() []byte
GetBody returns the raw response body bytes
func (CheckCodeResponse) GetJSON200 ¶
func (r CheckCodeResponse) GetJSON200() *struct { Errors []Message `json:"errors"` Messages []Message `json:"messages"` Result CheckResult `json:"result"` Success bool `json:"success"` }
GetJSON200 returns the response for an HTTP 200 `application/json` response
func (CheckCodeResponse) GetJSONDefault ¶
func (r CheckCodeResponse) GetJSONDefault() *Failure
GetJSONDefault returns the response for an HTTP default `application/json` response
func (CheckCodeResponse) Status ¶
func (r CheckCodeResponse) Status() string
Status returns HTTPResponse.Status
func (CheckCodeResponse) StatusCode ¶
func (r CheckCodeResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type CheckResult ¶
type CheckResult struct {
Valid bool `json:"valid"`
}
CheckResult defines model for CheckResult.
type Client ¶
type Client struct {
// The endpoint of the server conforming to this interface, with scheme,
// https://api.deepmap.com for example. This can contain a path relative
// to the server, such as https://api.deepmap.com/dev-test, and all the
// paths in the swagger spec will be appended to the server.
Server string
// Doer for performing requests, typically a *http.Client with any
// customized settings, such as certificate chains.
Client HttpRequestDoer
// A list of callbacks for modifying requests which are generated before sending over
// the network.
RequestEditors []RequestEditorFn
}
Client which conforms to the OpenAPI3 specification for this service.
func NewClient ¶
func NewClient(server string, opts ...ClientOption) (*Client, error)
Creates a new Client, with reasonable defaults
func (*Client) CheckCode ¶
func (c *Client) CheckCode(ctx context.Context, body CheckCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
CheckCode Check a code against the phone's open one. A wrong code is `valid` false, not an error. Needs otp write.
Takes a body of the `application/json` content type.
Corresponds with POST /v1/otp/codes/check (the `CheckCode` operationId).
func (*Client) CheckCodeWithBody ¶
func (c *Client) CheckCodeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
CheckCodeWithBody Check a code against the phone's open one. A wrong code is `valid` false, not an error. Needs otp write.
Takes any type of body and a specified content type.
Corresponds with POST /v1/otp/codes/check (the `CheckCode` operationId).
func (*Client) SendCode ¶
func (c *Client) SendCode(ctx context.Context, body SendCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
SendCode Make a code, or take the app's, supersede the phone's open one, and send it. Needs otp write.
`400` is a number outside the project's countries. `409` is a project whose settings were never saved. `429` is over a limit, with `Retry-After`: 1 code a minute and 5 an hour to one number, and the project's daily cap.
Takes a body of the `application/json` content type.
Corresponds with POST /v1/otp/codes (the `SendCode` operationId).
func (*Client) SendCodeWithBody ¶
func (c *Client) SendCodeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
SendCodeWithBody Make a code, or take the app's, supersede the phone's open one, and send it. Needs otp write.
`400` is a number outside the project's countries. `409` is a project whose settings were never saved. `429` is over a limit, with `Retry-After`: 1 code a minute and 5 an hour to one number, and the project's daily cap.
Takes any type of body and a specified content type.
Corresponds with POST /v1/otp/codes (the `SendCode` operationId).
type ClientInterface ¶
type ClientInterface interface {
// SendCodeWithBody Make a code, or take the app's, supersede the phone's open one, and send it. Needs otp write.
//
// `400` is a number outside the project's countries. `409` is a project whose settings were never
// saved. `429` is over a limit, with `Retry-After`: 1 code a minute and 5 an hour to one number, and
// the project's daily cap.
//
// Takes any type of body and a specified content type.
//
// Corresponds with POST /v1/otp/codes (the `SendCode` operationId).
SendCodeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
// SendCode Make a code, or take the app's, supersede the phone's open one, and send it. Needs otp write.
//
// `400` is a number outside the project's countries. `409` is a project whose settings were never
// saved. `429` is over a limit, with `Retry-After`: 1 code a minute and 5 an hour to one number, and
// the project's daily cap.
//
// Takes a body of the `application/json` content type.
//
// Corresponds with POST /v1/otp/codes (the `SendCode` operationId).
SendCode(ctx context.Context, body SendCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// CheckCodeWithBody Check a code against the phone's open one. A wrong code is `valid` false, not an error. Needs otp write.
//
// Takes any type of body and a specified content type.
//
// Corresponds with POST /v1/otp/codes/check (the `CheckCode` operationId).
CheckCodeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
// CheckCode Check a code against the phone's open one. A wrong code is `valid` false, not an error. Needs otp write.
//
// Takes a body of the `application/json` content type.
//
// Corresponds with POST /v1/otp/codes/check (the `CheckCode` operationId).
CheckCode(ctx context.Context, body CheckCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}
The interface specification for the client above.
type ClientOption ¶
ClientOption allows setting custom parameters during construction
func WithHTTPClient ¶
func WithHTTPClient(doer HttpRequestDoer) ClientOption
WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.
func WithRequestEditorFn ¶
func WithRequestEditorFn(fn RequestEditorFn) ClientOption
WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.
type ClientWithResponses ¶
type ClientWithResponses struct {
ClientInterface
}
ClientWithResponses builds on ClientInterface to offer response payloads
func NewClientWithResponses ¶
func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)
NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling
func (*ClientWithResponses) CheckCodeWithBodyWithResponse ¶
func (c *ClientWithResponses) CheckCodeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CheckCodeResponse, error)
CheckCodeWithBodyWithResponse Check a code against the phone's open one. A wrong code is `valid` false, not an error. Needs otp write.
Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).
Corresponds with POST /v1/otp/codes/check (the `CheckCode` operationId).
func (*ClientWithResponses) CheckCodeWithResponse ¶
func (c *ClientWithResponses) CheckCodeWithResponse(ctx context.Context, body CheckCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*CheckCodeResponse, error)
CheckCodeWithResponse Check a code against the phone's open one. A wrong code is `valid` false, not an error. Needs otp write.
Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).
Corresponds with POST /v1/otp/codes/check (the `CheckCode` operationId).
func (*ClientWithResponses) SendCodeWithBodyWithResponse ¶
func (c *ClientWithResponses) SendCodeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SendCodeResponse, error)
SendCodeWithBodyWithResponse Make a code, or take the app's, supersede the phone's open one, and send it. Needs otp write.
`400` is a number outside the project's countries. `409` is a project whose settings were never saved. `429` is over a limit, with `Retry-After`: 1 code a minute and 5 an hour to one number, and the project's daily cap.
Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).
Corresponds with POST /v1/otp/codes (the `SendCode` operationId).
func (*ClientWithResponses) SendCodeWithResponse ¶
func (c *ClientWithResponses) SendCodeWithResponse(ctx context.Context, body SendCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*SendCodeResponse, error)
SendCodeWithResponse Make a code, or take the app's, supersede the phone's open one, and send it. Needs otp write.
`400` is a number outside the project's countries. `409` is a project whose settings were never saved. `429` is over a limit, with `Retry-After`: 1 code a minute and 5 an hour to one number, and the project's daily cap.
Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).
Corresponds with POST /v1/otp/codes (the `SendCode` operationId).
type ClientWithResponsesInterface ¶
type ClientWithResponsesInterface interface {
// SendCodeWithBodyWithResponse Make a code, or take the app's, supersede the phone's open one, and send it. Needs otp write.
//
// `400` is a number outside the project's countries. `409` is a project whose settings were never
// saved. `429` is over a limit, with `Retry-After`: 1 code a minute and 5 an hour to one number, and
// the project's daily cap.
//
// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).
//
// Corresponds with POST /v1/otp/codes (the `SendCode` operationId).
SendCodeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SendCodeResponse, error)
// SendCodeWithResponse Make a code, or take the app's, supersede the phone's open one, and send it. Needs otp write.
//
// `400` is a number outside the project's countries. `409` is a project whose settings were never
// saved. `429` is over a limit, with `Retry-After`: 1 code a minute and 5 an hour to one number, and
// the project's daily cap.
//
// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).
//
// Corresponds with POST /v1/otp/codes (the `SendCode` operationId).
SendCodeWithResponse(ctx context.Context, body SendCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*SendCodeResponse, error)
// CheckCodeWithBodyWithResponse Check a code against the phone's open one. A wrong code is `valid` false, not an error. Needs otp write.
//
// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s).
//
// Corresponds with POST /v1/otp/codes/check (the `CheckCode` operationId).
CheckCodeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CheckCodeResponse, error)
// CheckCodeWithResponse Check a code against the phone's open one. A wrong code is `valid` false, not an error. Needs otp write.
//
// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s).
//
// Corresponds with POST /v1/otp/codes/check (the `CheckCode` operationId).
CheckCodeWithResponse(ctx context.Context, body CheckCodeJSONRequestBody, reqEditors ...RequestEditorFn) (*CheckCodeResponse, error)
}
ClientWithResponsesInterface is the interface specification for the client with responses above.
type Envelope ¶
type Envelope struct {
Errors []Message `json:"errors"`
Messages []Message `json:"messages"`
Success bool `json:"success"`
}
Envelope defines model for Envelope.
type Failure ¶
type Failure struct {
Errors []Message `json:"errors"`
Messages []Message `json:"messages"`
Result interface{} `json:"result"`
Success bool `json:"success"`
}
Failure defines model for Failure.
type HttpRequestDoer ¶
Doer performs HTTP requests.
The standard http.Client implements this interface.
type Message ¶
type Message struct {
Code int `json:"code"`
DocumentationUrl *string `json:"documentation_url,omitempty"`
Message string `json:"message"`
Source *struct {
// Pointer A JSON Pointer to the field at fault.
Pointer *string `json:"pointer,omitempty"`
} `json:"source,omitempty"`
}
Message defines model for Message.
type NewCode ¶
type NewCode struct {
// Code The app's own code, of the settings' code_length digits. Without it, OTP makes one.
Code *string `json:"code,omitempty"`
// ExpiresIn Seconds; the settings' code_expires_in without it.
ExpiresIn *int `json:"expires_in,omitempty"`
// Phone E.164, such as +9647701234567
Phone string `json:"phone"`
// Send False stores the code and sends nothing, for a code the app passes on itself. It isn't counted.
Send *bool `json:"send,omitempty"`
}
NewCode defines model for NewCode.
type RequestEditorFn ¶
RequestEditorFn is the function signature for the RequestEditor callback function
type SendCodeJSONRequestBody ¶
type SendCodeJSONRequestBody = NewCode
SendCodeJSONRequestBody defines body for SendCode for application/json ContentType.
type SendCodeResponse ¶
type SendCodeResponse struct {
Body []byte
HTTPResponse *http.Response
// JSON200 the response for an HTTP 200 `application/json` response
JSON200 *struct {
Errors []Message `json:"errors"`
Messages []Message `json:"messages"`
Result SentCode `json:"result"`
Success bool `json:"success"`
}
// JSONDefault the response for an HTTP default `application/json` response
JSONDefault *Failure
}
func ParseSendCodeResponse ¶
func ParseSendCodeResponse(rsp *http.Response) (*SendCodeResponse, error)
ParseSendCodeResponse parses an HTTP response from a SendCodeWithResponse call
func (SendCodeResponse) ContentType ¶
func (r SendCodeResponse) ContentType() string
ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers
func (SendCodeResponse) GetBody ¶
func (r SendCodeResponse) GetBody() []byte
GetBody returns the raw response body bytes
func (SendCodeResponse) GetJSON200 ¶
func (r SendCodeResponse) GetJSON200() *struct { Errors []Message `json:"errors"` Messages []Message `json:"messages"` Result SentCode `json:"result"` Success bool `json:"success"` }
GetJSON200 returns the response for an HTTP 200 `application/json` response
func (SendCodeResponse) GetJSONDefault ¶
func (r SendCodeResponse) GetJSONDefault() *Failure
GetJSONDefault returns the response for an HTTP default `application/json` response
func (SendCodeResponse) Status ¶
func (r SendCodeResponse) Status() string
Status returns HTTPResponse.Status
func (SendCodeResponse) StatusCode ¶
func (r SendCodeResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode