-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstages.go
More file actions
91 lines (69 loc) · 1.92 KB
/
stages.go
File metadata and controls
91 lines (69 loc) · 1.92 KB
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 lever
import (
"context"
"fmt"
"net/url"
"github.com/corbaltcode/lever-data-api-go/model"
)
// Lever stages client interface.
type StagesClientInterface interface {
ClientInterface
// Retrieve a single stage.
GetStage(ctx context.Context, req *GetStageRequest) (*GetStageResponse, error)
// Lists all pipeline stages in your Lever account.
ListStages(ctx context.Context, req *ListStagesRequest) (*ListStagesResponse, error)
}
// Parameters for retrieving a single stage.
type GetStageRequest struct {
BaseRequest
// The ID of the stage to retrieve.
ID string
}
// Create a new get stage request with the required fields.
func NewGetStageRequest(id string) *GetStageRequest {
return &GetStageRequest{
ID: id,
}
}
func (r *GetStageRequest) GetPath() string {
return fmt.Sprintf("stages/%s", url.PathEscape(r.ID))
}
// Response for retrieving a single stage.
type GetStageResponse struct {
BaseResponse
// The stage.
Stage model.Stage `json:"data"`
}
// Parameters for listing stages.
type ListStagesRequest struct {
BaseListRequest
}
// Create a new list stages request with the required fields.
func NewListStagesRequest() *ListStagesRequest {
return &ListStagesRequest{}
}
func (r *ListStagesRequest) GetPath() string {
return "stages"
}
// Response for listing stages.
type ListStagesResponse struct {
BaseListResponse
// The stages in your Lever account.
Stages []model.Stage `json:"data"`
}
// Retrieve a single stage.
func (c *Client) GetStage(ctx context.Context, req *GetStageRequest) (*GetStageResponse, error) {
var resp GetStageResponse
if err := c.exec(ctx, req, &resp); err != nil {
return nil, err
}
return &resp, nil
}
// Lists all pipeline stages in your Lever account.
func (c *Client) ListStages(ctx context.Context, req *ListStagesRequest) (*ListStagesResponse, error) {
var resp ListStagesResponse
if err := c.exec(ctx, req, &resp); err != nil {
return nil, err
}
return &resp, nil
}