Documentation ¶
Overview ¶
Package v1 provides API functionality for the version:
1.x
Index ¶
- Constants
- Variables
- type AdminAPI
- func (a *AdminAPI) AuthHandler(success, failed http.Handler) http.Handler
- func (a *AdminAPI) AuthRequiredHandler(parent http.Handler) http.Handler
- func (a *AdminAPI) AuthorizationHandler() http.Handler
- func (a *AdminAPI) AuthorizeHandler() http.Handler
- func (a *AdminAPI) CurrencyGetAllRequest() http.Handler
- func (a *AdminAPI) CurrencyGetRequest() http.Handler
- func (a *AdminAPI) GetUserID() http.Handler
- func (a *AdminAPI) PaymentMethodGetRequest() http.Handler
- func (a *AdminAPI) PaymentMethodRequest() http.Handler
- func (a *AdminAPI) PrincipalNameRequest() http.Handler
- func (a *AdminAPI) PrincipalRequest() http.Handler
- func (a *AdminAPI) ProjectGetRequest() http.Handler
- func (a *AdminAPI) ProjectRequest() http.Handler
- func (a *AdminAPI) ProviderGetAllRequest() http.Handler
- func (a *AdminAPI) ProviderGetRequest() http.Handler
- type AdminAPIResponse
- type CurrencyAdminAPIResponse
- type GetCredentialsResponse
- type GetPaymentRequest
- func (r *GetPaymentRequest) HashFunc() func() hash.Hash
- func (r *GetPaymentRequest) Message() ([]byte, error)
- func (r *GetPaymentRequest) ReadFromRequest(req *http.Request) error
- func (r *GetPaymentRequest) RequestProjectKey() string
- func (r *GetPaymentRequest) Signature() ([]byte, error)
- func (r *GetPaymentRequest) Time() time.Time
- type InitPaymentRequest
- func (r *InitPaymentRequest) HashFunc() func() hash.Hash
- func (r *InitPaymentRequest) Message() ([]byte, error)
- func (r *InitPaymentRequest) PopulatePaymentFields(p *payment.Payment)
- func (r *InitPaymentRequest) ReadJSON(rd io.Reader) error
- func (r *InitPaymentRequest) RequestProjectKey() string
- func (r *InitPaymentRequest) Signature() ([]byte, error)
- func (r *InitPaymentRequest) Time() time.Time
- func (r *InitPaymentRequest) Validate() error
- type InitPaymentResponse
- type PaymentAPI
- type PaymentMethodRequest
- type PrincipalAdminAPIResponse
- type ProjectAdminAPIResponse
- type ProjectKeyRequester
- type ProviderAdminAPIResponse
- type Service
- type ServiceResponse
- type UserAdminAPIResponse
Constants ¶
const ( // AuthLifetime is the duration for which an authorization is considered valid // TODO @configure AuthLifetime = 15 * time.Minute // AuthUserIDKey is the key for the user ID entry in the authorization container AuthUserIDKey = "userID" // AuthCookieName is the cookie name for cookie-based authentication AuthCookieName = "auth" )
const ( StatusImplementationError = "implementationError" StatusError = "error" StatusSuccess = "success" )
const ( // APIVersion is the current version of the API // // Version history: // // - 1.2: Deprecating "Error" field. Will be removed in version 2 // // - 1.1: Include version number in service response APIVersion = "1.2" )
const Debug = false
Debug flag whether debugging is turned on
const (
// ServicePath is the (sub-)path under which the API service v1.x resides in
ServicePath = "/" + serviceVersion
)
Variables ¶
var ( ErrReadJson = ServiceResponse{ http.StatusBadRequest, APIVersion, StatusImplementationError, "could not read request", nil, nil, } http.StatusUnauthorized, APIVersion, StatusUnauthorized, "unauthorized", nil, nil, } ErrDatabase = ServiceResponse{ http.StatusInternalServerError, APIVersion, StatusError, "database error", nil, nil, } ErrSystem = ServiceResponse{ http.StatusInternalServerError, APIVersion, StatusError, "internal error", nil, nil, } ErrInval = ServiceResponse{ http.StatusBadRequest, APIVersion, StatusImplementationError, "invalid value", nil, nil, } ErrNotFound = ServiceResponse{ http.StatusNotFound, APIVersion, StatusError, "resource not found", nil, nil, } ErrConflict = ServiceResponse{ http.StatusConflict, APIVersion, StatusError, "resource already exits", nil, nil, } ErrReadParam = ServiceResponse{ http.StatusBadRequest, APIVersion, StatusError, "parameter malformed", nil, nil, } ErrMethod = ServiceResponse{ http.StatusMethodNotAllowed, APIVersion, StatusError, "method not allowed", nil, nil, } )
default service responses
var Log log15.Logger
Log is the default logger for the API service v1
Functions ¶
This section is empty.
Types ¶
type AdminAPI ¶
type AdminAPI struct {
// contains filtered or unexported fields
}
API represents the admin API in version 1.x
func (*AdminAPI) AuthHandler ¶
AuthHandler wraps the given handler with an authorization method using the Authorization Header and the authorization container
When the request can be authorized, the success handler will be called, otherwise the failed handler will be called
func (*AdminAPI) AuthRequiredHandler ¶
AuthRequiredHandler wraps the given handler with an authorization method using the Authorization Header and the authorization container
A failed authorization will lead to a http.StatusUnauthorized header
func (*AdminAPI) AuthorizationHandler ¶
AuthorizationHandler implements /authorization requests
func (*AdminAPI) AuthorizeHandler ¶
AuthorizeHandler handles new authorizations
func (*AdminAPI) CurrencyGetAllRequest ¶
return a handler brokering get a currency
func (*AdminAPI) CurrencyGetRequest ¶
return a handler brokering get all currencies
func (*AdminAPI) GetUserID ¶
GetUserID returns a utility handler. This endpoint displays the user ID, which is stored in the authorization container
func (*AdminAPI) PaymentMethodGetRequest ¶
func (*AdminAPI) PaymentMethodRequest ¶
handler to create or change a principal
PUT creates new principal POST can be used to change the principals metadata
func (*AdminAPI) PrincipalNameRequest ¶
func (*AdminAPI) PrincipalRequest ¶
handler to create or change a principal
PUT creates new principal POST can be used to change the principals metadata
func (*AdminAPI) ProjectGetRequest ¶
return a hanlder to get project items
func (*AdminAPI) ProjectRequest ¶
return a handler to add and manipulate projects
func (*AdminAPI) ProviderGetAllRequest ¶
return a handler brokering get a provider
func (*AdminAPI) ProviderGetRequest ¶
return a handler brokering get provider by give id
type AdminAPIResponse ¶
type AdminAPIResponse struct {
ServiceResponse
}
type used for formated AdminAPI Responses
type CurrencyAdminAPIResponse ¶
type CurrencyAdminAPIResponse struct {
AdminAPIResponse
}
type GetCredentialsResponse ¶
type GetCredentialsResponse struct {
Authorization string
}
GetCredentialsResponse is the response for all GET /user/credentials requests ready to be JSON-encoded
type GetPaymentRequest ¶
type GetPaymentRequest struct { ProjectKey string PaymentId string Ident string Timestamp int64 Nonce string // contains filtered or unexported fields }
GetPaymentRequest represents a get payment request
func (*GetPaymentRequest) HashFunc ¶
func (r *GetPaymentRequest) HashFunc() func() hash.Hash
func (*GetPaymentRequest) Message ¶
func (r *GetPaymentRequest) Message() ([]byte, error)
func (*GetPaymentRequest) ReadFromRequest ¶
func (r *GetPaymentRequest) ReadFromRequest(req *http.Request) error
func (*GetPaymentRequest) RequestProjectKey ¶
func (r *GetPaymentRequest) RequestProjectKey() string
func (*GetPaymentRequest) Signature ¶
func (r *GetPaymentRequest) Signature() ([]byte, error)
func (*GetPaymentRequest) Time ¶
func (r *GetPaymentRequest) Time() time.Time
type InitPaymentRequest ¶
type InitPaymentRequest struct { ProjectKey string Ident string Amount jsonutil.RequiredInt64 Subunits jsonutil.RequiredInt8 Currency string Country string PaymentMethodID int64 `json:"PaymentMethodId,string"` Locale string `json:",omitempty"` CallbackURL string `json:",omitempty"` CallbackAPIVersion string `json:",omitempty"` CallbackProjectKey string `json:",omitempty"` ReturnURL string `json:",omitempty"` Expires int64 `json:",string,omitempty"` Metadata map[string]string Timestamp int64 `json:",string"` Nonce string HexSignature string `json:"Signature"` // contains filtered or unexported fields }
InitPaymentRequest is the request JSON struct for POST /payment
func (*InitPaymentRequest) HashFunc ¶
func (r *InitPaymentRequest) HashFunc() func() hash.Hash
HashFunc returns the hash function used to generate a signature
func (*InitPaymentRequest) Message ¶
func (r *InitPaymentRequest) Message() ([]byte, error)
Return the signature base string (msg)
func (*InitPaymentRequest) PopulatePaymentFields ¶
func (r *InitPaymentRequest) PopulatePaymentFields(p *payment.Payment)
func (*InitPaymentRequest) RequestProjectKey ¶
func (r *InitPaymentRequest) RequestProjectKey() string
func (*InitPaymentRequest) Signature ¶
func (r *InitPaymentRequest) Signature() ([]byte, error)
Return the (binary) signature from the request
implementing AuthenticatedRequest
func (*InitPaymentRequest) Time ¶
func (r *InitPaymentRequest) Time() time.Time
type InitPaymentResponse ¶
type InitPaymentResponse struct { Confirmation struct { Ident string Amount int64 `json:",string"` Subunits int8 `json:",string"` Currency string Country string PaymentMethodID int64 `json:"PaymentMethodId,string,omitempty"` Locale string `json:",omitempty"` CallbackURL string `json:",omitempty"` CallbackAPIVersion string `json:",omitempty"` CallbackProjectKey string `json:",omitempty"` ReturnURL string `json:",omitempty"` Expires int64 `json:",string,omitempty"` Metadata map[string]string `json:",omitempty"` } Payment struct { PaymentId payment.PaymentID // RFC3339 date/time string Created string Token string RedirectURL string `json:",omitempty"` } Timestamp int64 `json:",string"` Nonce string Signature string }
InitPaymentResponse is the JSON response struct for POST /payment
func (*InitPaymentResponse) ConfirmationFromPayment ¶
func (r *InitPaymentResponse) ConfirmationFromPayment(p *payment.Payment)
ConfirmationFromPayment populates the response "Confirmation" object with the fields from the given payment
func (*InitPaymentResponse) HashFunc ¶
func (r *InitPaymentResponse) HashFunc() func() hash.Hash
HashFunc returns the hash function for signing an init payment response
func (*InitPaymentResponse) Message ¶
func (r *InitPaymentResponse) Message() ([]byte, error)
Returns the signature base string
implementing SignableMessage
type PaymentAPI ¶
type PaymentAPI struct {
// contains filtered or unexported fields
}
API represents the payment API in the version 1.x
func NewPaymentAPI ¶
func NewPaymentAPI(ctx *service.Context) (*PaymentAPI, error)
NewAPI creates a new payment API
func (*PaymentAPI) GetPayment ¶
func (a *PaymentAPI) GetPayment() http.Handler
func (*PaymentAPI) InitPayment ¶
func (a *PaymentAPI) InitPayment() http.Handler
type PaymentMethodRequest ¶
type PaymentMethodRequest struct { MethodKey string Provider string Status string CreatedBy string Metadata map[string]string }
PaymentMethodRequest is the request JSON struct for POST - PUT project/(id)/method/
type PrincipalAdminAPIResponse ¶
type PrincipalAdminAPIResponse struct {
AdminAPIResponse
}
type ProjectAdminAPIResponse ¶
type ProjectAdminAPIResponse struct {
AdminAPIResponse
}
type ProjectKeyRequester ¶
type ProviderAdminAPIResponse ¶
type ProviderAdminAPIResponse struct {
AdminAPIResponse
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service represents the API service version 1.x
type ServiceResponse ¶
type ServiceResponse struct { HttpStatus int `json:"-"` Version string Status string Info string Response interface{} Error interface{} }
ServiceResponse represents a general response container for (payment-related) API requests
func (*ServiceResponse) Write ¶
func (sr *ServiceResponse) Write(w http.ResponseWriter) error
type UserAdminAPIResponse ¶
type UserAdminAPIResponse struct {
AdminAPIResponse
}