-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcost_provider_tests.go
More file actions
41 lines (34 loc) · 1.15 KB
/
cost_provider_tests.go
File metadata and controls
41 lines (34 loc) · 1.15 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
package api
import (
"context"
"encoding/json"
"fmt"
"net/http"
"gopkg.in/nullstone-io/go-api-client.v0/response"
)
type CostProviderTests struct {
Client *Client
}
func (s CostProviderTests) testExistingPath(costProviderId int64) string {
return fmt.Sprintf("orgs/%s/cost_providers/%d/test", s.Client.Config.OrgName, costProviderId)
}
func (s CostProviderTests) testNewPath() string {
return fmt.Sprintf("orgs/%s/cost_provider_tests", s.Client.Config.OrgName)
}
// TestExisting - GET /orgs/:orgName/cost_providers/:costProviderId/test
func (s CostProviderTests) TestExisting(ctx context.Context, costProviderId int64) error {
res, err := s.Client.Do(ctx, http.MethodGet, s.testExistingPath(costProviderId), nil, nil, nil)
if err != nil {
return err
}
return response.Verify(res)
}
// TestNew - POST /orgs/:orgName/cost_provider_tests
func (s CostProviderTests) TestNew(ctx context.Context, providerId int64) error {
rawPayload, _ := json.Marshal(map[string]any{"providerId": providerId})
res, err := s.Client.Do(ctx, http.MethodPost, s.testNewPath(), nil, nil, json.RawMessage(rawPayload))
if err != nil {
return err
}
return response.Verify(res)
}