-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
external_initiators.go
82 lines (72 loc) · 2.46 KB
/
external_initiators.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
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
package presenters
import (
"fmt"
"time"
"github.com/smartcontractkit/chainlink/v2/core/auth"
"github.com/smartcontractkit/chainlink/v2/core/bridges"
"github.com/smartcontractkit/chainlink/v2/core/store/models"
)
// ExternalInitiatorAuthentication includes initiator and authentication details.
type ExternalInitiatorAuthentication struct {
Name string `json:"name,omitempty"`
URL models.WebURL `json:"url,omitempty"`
AccessKey string `json:"incomingAccessKey,omitempty"`
Secret string `json:"incomingSecret,omitempty"`
OutgoingToken string `json:"outgoingToken,omitempty"`
OutgoingSecret string `json:"outgoingSecret,omitempty"`
}
// NewExternalInitiatorAuthentication creates an instance of ExternalInitiatorAuthentication.
func NewExternalInitiatorAuthentication(
ei bridges.ExternalInitiator,
eia auth.Token,
) *ExternalInitiatorAuthentication {
var result = &ExternalInitiatorAuthentication{
Name: ei.Name,
AccessKey: ei.AccessKey,
Secret: eia.Secret,
OutgoingToken: ei.OutgoingToken,
OutgoingSecret: ei.OutgoingSecret,
}
if ei.URL != nil {
result.URL = *ei.URL
}
return result
}
// GetID returns the jsonapi ID.
func (ei *ExternalInitiatorAuthentication) GetID() string {
return ei.Name
}
// GetName returns the collection name for jsonapi.
func (*ExternalInitiatorAuthentication) GetName() string {
return "external initiators"
}
// SetID is used to conform to the UnmarshallIdentifier interface for
// deserializing from jsonapi documents.
func (ei *ExternalInitiatorAuthentication) SetID(name string) error {
ei.Name = name
return nil
}
type ExternalInitiatorResource struct {
JAID
Name string `json:"name"`
URL *models.WebURL `json:"url"`
AccessKey string `json:"accessKey"`
OutgoingToken string `json:"outgoingToken"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func NewExternalInitiatorResource(ei bridges.ExternalInitiator) ExternalInitiatorResource {
return ExternalInitiatorResource{
JAID: NewJAID(fmt.Sprintf("%d", ei.ID)),
Name: ei.Name,
URL: ei.URL,
AccessKey: ei.AccessKey,
OutgoingToken: ei.OutgoingToken,
CreatedAt: ei.CreatedAt,
UpdatedAt: ei.UpdatedAt,
}
}
// GetName returns the collection name for jsonapi.
func (ExternalInitiatorResource) GetName() string {
return "externalInitiators"
}