/
bridges.go
40 lines (35 loc) · 1.27 KB
/
bridges.go
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
package presenters
import (
"time"
"github.com/GoPlugin/Plugin/core/assets"
"github.com/GoPlugin/Plugin/core/store/models"
)
// BridgeResource represents a Bridge JSONAPI resource.
type BridgeResource struct {
JAID
Name string `json:"name"`
URL string `json:"url"`
Confirmations uint32 `json:"confirmations"`
// The IncomingToken is only provided when creating a Bridge
IncomingToken string `json:"incomingToken,omitempty"`
OutgoingToken string `json:"outgoingToken"`
MinimumContractPayment *assets.Link `json:"minimumContractPayment"`
CreatedAt time.Time `json:"createdAt"`
}
// GetName implements the api2go EntityNamer interface
func (r BridgeResource) GetName() string {
return "bridges"
}
// NewBridgeResource constructs a new BridgeResource
func NewBridgeResource(b models.BridgeType) *BridgeResource {
return &BridgeResource{
// Uses the name as the id...Should change this to the id
JAID: NewJAID(b.Name.String()),
Name: b.Name.String(),
URL: b.URL.String(),
Confirmations: b.Confirmations,
OutgoingToken: b.OutgoingToken,
MinimumContractPayment: b.MinimumContractPayment,
CreatedAt: b.CreatedAt,
}
}