-
Notifications
You must be signed in to change notification settings - Fork 2
/
model.go
69 lines (55 loc) · 1.27 KB
/
model.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
package client
type Request struct {
URLPath string `json:"urlPath"`
Method string `json:"method"`
}
type Accept struct {
Contains string `json:"contains"`
}
type Response struct {
Status int `json:"status"`
Body string `json:"body"`
Headers Headers `json:"headers"`
}
type Headers struct {
ContentType string `json:"Content-Type"`
}
type Metadata struct {
Description string `json:"description"`
}
type Mock struct {
Name string `json:"name"`
Request Request `json:"request"`
Response Response `json:"response"`
Metadata Metadata `json:"metadata"`
}
func DefaultMock() Mock {
return Mock{
Request: Request{},
Response: Response{Headers: Headers{ContentType: "application/json"}},
}
}
func (m *Mock) WithName(name string) *Mock {
m.Name = name
return m
}
func (m *Mock) WithDescription(description string) *Mock {
m.Metadata.Description = description
return m
}
func (m *Mock) WithRequestUrlPath(urlPath string) *Mock {
m.Request.URLPath = urlPath
return m
}
func (m *Mock) WithRequestMethod(method string) *Mock {
m.Request.Method = method
return m
}
func (m *Mock) WithResponseStatusCode(statusCode int) *Mock {
m.Response.Status = statusCode
return m
}
func (m *Mock) WithResponseBody(body string) *Mock {
m.Response.Body = body
return m
}