approveapi-go: Index | Files

package approveapi

import ""


Package Files

api_approve.go client.go configuration.go model_answer_metadata.go model_create_prompt_request.go model_error.go model_prompt.go model_prompt_answer.go model_prompt_metadata.go model_prompt_status.go response.go


var (
    // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
    ContextOAuth2 = contextKey("token")

    // ContextBasicAuth takes BasicAuth as authentication for the request.
    ContextBasicAuth = contextKey("basic")

    // ContextAccessToken takes a string oauth2 access token as authentication for the request.
    ContextAccessToken = contextKey("accesstoken")

    // ContextAPIKey takes an APIKey as authentication for the request
    ContextAPIKey = contextKey("apikey")

func CacheExpires Uses

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

type APIClient Uses

type APIClient struct {
    ApproveApi *ApproveApiService
    // contains filtered or unexported fields

APIClient manages communication with the ApproveAPISwagger API v1.0.1 In most cases there should be only one, shared, APIClient.

func NewAPIClient Uses

func NewAPIClient(cfg *Configuration, ctx context.Context) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) ChangeBasePath Uses

func (c *APIClient) ChangeBasePath(path string)

Change base path to allow switching to mocks

type APIKey Uses

type APIKey struct {
    Key    string
    Prefix string

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse Uses

type APIResponse struct {
    *http.Response `json:"-"`
    Message        string `json:"message,omitempty"`
    // Operation is the name of the OpenAPI operation.
    Operation string `json:"operation,omitempty"`
    // RequestURL is the request URL. This value is always available, even if the
    // embedded *http.Response is nil.
    RequestURL string `json:"url,omitempty"`
    // Method is the HTTP method used for the request.  This value is always
    // available, even if the embedded *http.Response is nil.
    Method string `json:"method,omitempty"`
    // Payload holds the contents of the response body (which may be nil or empty).
    // This is provided here as the raw response.Body() reader will have already
    // been drained.
    Payload []byte `json:"-"`

func NewAPIResponse Uses

func NewAPIResponse(r *http.Response) *APIResponse

func NewAPIResponseWithError Uses

func NewAPIResponseWithError(errorMessage string) *APIResponse

type AnswerMetadata Uses

type AnswerMetadata struct {
    IpAddress       *string `json:"ip_address,omitempty"`
    Browser         *string `json:"browser,omitempty"`
    OperatingSystem *string `json:"operating_system,omitempty"`

type ApproveApiService Uses

type ApproveApiService service

func (*ApproveApiService) CreatePrompt Uses

func (a *ApproveApiService) CreatePrompt(createPromptRequest CreatePromptRequest) (Prompt, *http.Response, error)

ApproveApiService Sending a prompt Creates a prompt and pushes it to the user (sends via email, sms, or other supported protocols).

* @param createPromptRequest

@return Prompt

func (*ApproveApiService) GetPrompt Uses

func (a *ApproveApiService) GetPrompt(id string, localVarOptionals *GetPromptOpts) (Prompt, *http.Response, error)

func (*ApproveApiService) GetPromptStatus Uses

func (a *ApproveApiService) GetPromptStatus(id string) (PromptStatus, *http.Response, error)

ApproveApiService Check prompt status Returns whether a prompt has been completed by the user. This request does not require authentication, and so can be used client-side without sharing API credentials.

* @param id The prompt identifier.

@return PromptStatus

type BasicAuth Uses

type BasicAuth struct {
    UserName string `json:"userName,omitempty"`
    Password string `json:"password,omitempty"`

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type Configuration Uses

type Configuration struct {
    BasePath      string            `json:"basePath,omitempty"`
    Host          string            `json:"host,omitempty"`
    Scheme        string            `json:"scheme,omitempty"`
    DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
    UserAgent     string            `json:"userAgent,omitempty"`
    HTTPClient    *http.Client

func NewConfiguration Uses

func NewConfiguration() *Configuration

func (*Configuration) AddDefaultHeader Uses

func (c *Configuration) AddDefaultHeader(key string, value string)

type CreatePromptRequest Uses

type CreatePromptRequest struct {
    // The user to send the approval request to. Can be either an email address or a phone number.
    User string `json:"user"`
    // The body of the approval request to show the user.
    Body string `json:"body"`
    // The title of an approval request. Defaults to an empty string.
    Title *string `json:"title,omitempty"`
    // The approve action text. Defaults to 'Approve'.
    ApproveText *string `json:"approve_text,omitempty"`
    // An HTTPS URL to redirect the user to if the prompt is approved. This URL is kept secret until the user is redirected to it.
    ApproveRedirectUrl *string `json:"approve_redirect_url,omitempty"`
    // The reject action text. If not specified the reject button will NOT be rendered, and the user will only see an approve action button.
    RejectText *string `json:"reject_text,omitempty"`
    // An HTTPS URL to redirect the user to if the prompt is rejected. This URL is kept secret until the user is redirected to it.
    RejectRedirectUrl *string `json:"reject_redirect_url,omitempty"`
    // If true, the request waits (long-polls) until the user responds to the prompt or more than 10 minutes pass. Defaults to false.
    LongPoll *bool `json:"long_poll,omitempty"`
    // The number of seconds until this request can no longer be answered.
    ExpiresIn    *float32           `json:"expires_in,omitempty"`
    Metadata     *PromptMetadata    `json:"metadata,omitempty"`
    InternalData *map[string]string `json:"internal_data,omitempty"`
    // Allows calling `create_prompt` multiple times idempotently, such that a prompt is sent at-most once. This key should contain sufficient randomness. Idempotent requests are stored for 24 hours. After that time, the same key will create a new request.
    IdempotencyKey *string `json:"idempotency_key,omitempty"`

type Error Uses

type Error struct {
    // A human readable API error message.
    Error string `json:"error"`

type GenericOpenAPIError Uses

type GenericOpenAPIError struct {
    // contains filtered or unexported fields

GenericOpenAPIError Provides access to the body, error and model on returned errors.

func (GenericOpenAPIError) Body Uses

func (e GenericOpenAPIError) Body() []byte

Body returns the raw bytes of the response

func (GenericOpenAPIError) Error Uses

func (e GenericOpenAPIError) Error() string

Error returns non-empty string if there was an error.

func (GenericOpenAPIError) Model Uses

func (e GenericOpenAPIError) Model() interface{}

Model returns the unpacked model of the error

type GetPromptOpts Uses

type GetPromptOpts struct {
    LongPoll optional.Bool

type Prompt Uses

type Prompt struct {
    // A unique id for this prompt.
    Id  string `json:"id"`
    // The unix timestamp when this prompt was sent.
    SentAt float32 `json:"sent_at"`
    // Whether the prompt can still be answered.
    IsExpired bool                `json:"is_expired"`
    Request   CreatePromptRequest `json:"request"`
    Answer    *PromptAnswer       `json:"answer,omitempty"`
    Metadata  *PromptMetadata     `json:"metadata,omitempty"`

type PromptAnswer Uses

type PromptAnswer struct {
    // The user's answer to whether or not they approve this prompt.
    Result bool `json:"result"`
    // The unix timestamp when the user answered the prompt.
    Time     float32         `json:"time"`
    Metadata *AnswerMetadata `json:"metadata,omitempty"`

type PromptMetadata Uses

type PromptMetadata struct {
    // The physical location, like Oakland, CA, of the action.
    Location *string `json:"location,omitempty"`
    // The date/time of the action.
    Time *string `json:"time,omitempty"`
    // The IP address of the computer initiating the action.
    IpAddress *string `json:"ip_address,omitempty"`
    // The web browser initiating the action, i.e. Chrome.
    Browser *string `json:"browser,omitempty"`
    // The operating system initiating the action, i.e. Mac OS X.
    OperatingSystem *string `json:"operating_system,omitempty"`

type PromptStatus Uses

type PromptStatus struct {
    // Whether the prompt has been answered or not.
    IsAnswered bool `json:"is_answered"`
    // Whether the prompt can still be answered.
    IsExpired bool `json:"is_expired"`

Package approveapi imports 21 packages (graph). Updated 2019-04-19. Refresh now. Tools for package owners.