Skip to content
A Go library for using ApproveAPI
Branch: master
Clone or download
Latest commit d200f4d Mar 7, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.openapi-generator
api
docs regenerate client Feb 26, 2019
.gitignore
.openapi-generator-ignore
.travis.yml initial golang client Feb 15, 2019
README.md
api_approve.go
client.go
configuration.go regenerate client Feb 26, 2019
git_push.sh initial golang client Feb 15, 2019
model_answer_metadata.go regenerate client Feb 26, 2019
model_create_prompt_request.go regenerate client Feb 26, 2019
model_error.go
model_prompt.go regenerate client Feb 26, 2019
model_prompt_answer.go
model_prompt_metadata.go
model_prompt_status.go
response.go regenerate client Feb 26, 2019

README.md

approveapi-go

GoDoc

Go API bindings for the ApproveAPI HTTP API.

ApproveAPI is a simple API to request a user's real-time approval on anything via email, sms + mobile push.

Features

  • Send Prompt
    • web redirect actions (i.e. magic links)
    • custom approve/reject buttons
    • metadata
    • long polling
  • Retrieve Prompt
  • Check Prompt status
  • Futures support
  • Webhook callbacks

Install

Install the dependencies:

go get "github.com/approveapi/approveapi-go"

Import:

import "github.com/approveapi/approveapi-go"

Getting Started

To get started, we create a client:

client := approveapi.CreateClient("sk_test_yourapikeyhere")

Now we can make API calls. For example, let's send an approval prompt to confirm a financial transaction.

longPoll := true
prompt, _, err := client.ApproveApi.CreatePrompt(
    approveapi.CreatePromptRequest {
      User: "alice@approveapi.com",
      Body: `A transfer of $1337.45 from acct 0294 to acct 1045
          has been initiated. Do you want to authorize this transfer?`,
      ApproveText: "Authorize",
      RejectText: "Reject",
      LongPoll: &longPoll,
    },
)
if err != nil {
    fmt.Printf("%#v\n", err)
    return
}
if prompt.Answer != nil {
    if prompt.Answer.Result {
        fmt.Println("Request approved")
    } else {
        fmt.Println("Request rejected")
    }
} else {
    fmt.Println("No response yet")
}

Documentation

Full documentation is available here: approveapi.com/docs.

You can’t perform that action at this time.