summaryrefslogtreecommitdiff
path: root/c2ec/model.go
blob: 9057241716f1215499628aca0915548efc3d151d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main

import (
	"fmt"
)

// https://docs.taler.net/core/api-common.html#hash-codes
type WithdrawalIdentifier string

// https://docs.taler.net/core/api-common.html#cryptographic-primitives
type EddsaPublicKey string

// https://docs.taler.net/core/api-common.html#hash-codes
type HashCode string

// https://docs.taler.net/core/api-common.html#hash-codes
type ShortHashCode string

// https://docs.taler.net/core/api-common.html#timestamps
type Timestamp struct {
	Ts int `json:"t_s"`
}

// https://docs.taler.net/core/api-common.html#wadid
type WadId [6]uint32

// according to https://docs.taler.net/core/api-bank-integration.html#tsref-type-BankWithdrawalOperationStatus
type WithdrawalOperationStatus string

const (
	PENDING   WithdrawalOperationStatus = "pending"
	SELECTED  WithdrawalOperationStatus = "selected"
	ABORTED   WithdrawalOperationStatus = "aborted"
	CONFIRMED WithdrawalOperationStatus = "confirmed"
)

func ToWithdrawalOpStatus(s string) (WithdrawalOperationStatus, error) {
	switch s {
	case string(PENDING):
		return PENDING, nil
	case string(SELECTED):
		return SELECTED, nil
	case string(ABORTED):
		return ABORTED, nil
	case string(CONFIRMED):
		return CONFIRMED, nil
	default:
		return "", fmt.Errorf("unknown withdrawal operation status '%s'", s)
	}
}

type ErrorDetail struct {

	// Numeric error code unique to the condition.
	// The other arguments are specific to the error value reported here.
	Code int `json:"code"`

	// Human-readable description of the error, i.e. "missing parameter", "commitment violation", ...
	// Should give a human-readable hint about the error's nature. Optional, may change without notice!
	Hint string `json:"hint"`

	// Optional detail about the specific input value that failed. May change without notice!
	Detail string `json:"detail"`

	// Name of the parameter that was bogus (if applicable).
	Parameter string `json:"parameter"`

	// Path to the argument that was bogus (if applicable).
	Path string `json:"path"`

	// Offset of the argument that was bogus (if applicable).
	Offset string `json:"offset"`

	// Index of the argument that was bogus (if applicable).
	Index string `json:"index"`

	// Name of the object that was bogus (if applicable).
	Object string `json:"object"`

	// Name of the currency that was problematic (if applicable).
	Currency string `json:"currency"`

	// Expected type (if applicable).
	TypeExpected string `json:"type_expected"`

	// Type that was provided instead (if applicable).
	TypeActual string `json:"type_actual"`

	// Extra information that doesn't fit into the above (if applicable).
	Extra []byte `json:"extra"`
}