forked from checkout/checkout-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conditions.go
89 lines (70 loc) · 2.11 KB
/
conditions.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
83
84
85
86
87
88
89
package conditions
import "github.com/PaddleHQ/checkout-sdk-go/common"
type WorkflowConditionType string
const (
Event WorkflowConditionType = "event"
Entity WorkflowConditionType = "entity"
ProcessingChannel WorkflowConditionType = "processing_channel"
)
// Requests
type (
ConditionsRequest interface {
GetType() WorkflowConditionType
}
WorkflowConditions struct {
Type WorkflowConditionType `json:"type,omitempty"`
}
entityConditionRequest struct {
WorkflowConditions
Entities []string `json:"entities,omitempty"`
}
eventConditionRequest struct {
WorkflowConditions
Events map[string][]string `json:"events,omitempty"`
}
processingChannelConditionRequest struct {
WorkflowConditions
ProcessingChannels []string `json:"processing_channels,omitempty"`
}
)
func NewEntityConditionRequest() *entityConditionRequest {
return &entityConditionRequest{WorkflowConditions: WorkflowConditions{Type: Entity}}
}
func NewEventConditionRequest() *eventConditionRequest {
return &eventConditionRequest{WorkflowConditions: WorkflowConditions{Type: Event}}
}
func NewProcessingChannelConditionRequest() *processingChannelConditionRequest {
return &processingChannelConditionRequest{WorkflowConditions: WorkflowConditions{Type: ProcessingChannel}}
}
func (c *entityConditionRequest) GetType() WorkflowConditionType {
return c.Type
}
func (c *eventConditionRequest) GetType() WorkflowConditionType {
return c.Type
}
func (c *processingChannelConditionRequest) GetType() WorkflowConditionType {
return c.Type
}
// Responses
type (
ConditionsResponse struct {
Id string `json:"id,omitempty"`
Type WorkflowConditionType `json:"type,omitempty"`
Conditions
Links map[string]common.Link `json:"_links,omitempty"`
}
Conditions struct {
*EntitiesCondition
*EventsCondition
*ProcessingChannelCondition
}
EntitiesCondition struct {
Entities []string `json:"entities,omitempty"`
}
EventsCondition struct {
Events map[string][]string `json:"events,omitempty"`
}
ProcessingChannelCondition struct {
ProcessingChannels []string `json:"processing_channels,omitempty"`
}
)