|
1 | 1 | package jamfprointegration |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "net/http" |
4 | 5 | "time" |
5 | 6 |
|
6 | | - "github.com/deploymenttheory/go-api-http-client/httpclient" |
7 | 7 | "go.uber.org/zap" |
8 | 8 | ) |
9 | 9 |
|
10 | 10 | // BuildWithOAuth is a helper function allowing the full construct of a Jamf Integration using OAuth2 |
11 | | -func BuildWithOAuth(jamfProFQDN string, Sugar *zap.SugaredLogger, bufferPeriod time.Duration, clientId string, clientSecret string, hideSensitiveData bool, executor httpclient.HTTPExecutor) (*Integration, error) { |
| 11 | +func BuildWithOAuth(jamfProFQDN string, Sugar *zap.SugaredLogger, bufferPeriod time.Duration, clientId string, clientSecret string, hideSensitiveData bool, client http.Client) (*Integration, error) { |
12 | 12 | integration := Integration{ |
13 | 13 | JamfProFQDN: jamfProFQDN, |
14 | 14 | Sugar: Sugar, |
15 | 15 | AuthMethodDescriptor: "oauth2", |
16 | | - httpExecutor: executor, |
| 16 | + http: client, |
17 | 17 | } |
18 | 18 |
|
19 | | - integration.BuildOAuth(clientId, clientSecret, bufferPeriod, hideSensitiveData, executor) |
| 19 | + integration.BuildOAuth(clientId, clientSecret, bufferPeriod, hideSensitiveData, client) |
20 | 20 | err := integration.CheckRefreshToken() |
21 | 21 |
|
22 | 22 | return &integration, err |
23 | 23 | } |
24 | 24 |
|
25 | 25 | // BuildWithBasicAuth is a helper function allowing the full construct of a Jamf Integration using BasicAuth |
26 | | -func BuildWithBasicAuth(jamfProFQDN string, Sugar *zap.SugaredLogger, bufferPeriod time.Duration, username string, password string, hideSensitiveData bool, executor httpclient.HTTPExecutor) (*Integration, error) { |
| 26 | +func BuildWithBasicAuth(jamfProFQDN string, Sugar *zap.SugaredLogger, bufferPeriod time.Duration, username string, password string, hideSensitiveData bool, client http.Client) (*Integration, error) { |
27 | 27 |
|
28 | 28 | integration := Integration{ |
29 | 29 | JamfProFQDN: jamfProFQDN, |
30 | 30 | Sugar: Sugar, |
31 | 31 | AuthMethodDescriptor: "basic", |
32 | | - httpExecutor: executor, |
| 32 | + http: client, |
33 | 33 | } |
34 | 34 |
|
35 | | - integration.BuildBasicAuth(username, password, bufferPeriod, hideSensitiveData, executor) |
| 35 | + integration.BuildBasicAuth(username, password, bufferPeriod, hideSensitiveData, client) |
36 | 36 | err := integration.CheckRefreshToken() |
37 | 37 |
|
38 | 38 | return &integration, err |
39 | 39 | } |
40 | 40 |
|
41 | 41 | // BuildOAuth is a helper which returns just a configured OAuth interface |
42 | | -func (j *Integration) BuildOAuth(clientId string, clientSecret string, bufferPeriod time.Duration, hideSensitiveData bool, executor httpclient.HTTPExecutor) { |
| 42 | +func (j *Integration) BuildOAuth(clientId string, clientSecret string, bufferPeriod time.Duration, hideSensitiveData bool, client http.Client) { |
43 | 43 | authInterface := oauth{ |
44 | 44 | clientId: clientId, |
45 | 45 | clientSecret: clientSecret, |
46 | 46 | bufferPeriod: bufferPeriod, |
47 | 47 | baseDomain: j.JamfProFQDN, |
48 | 48 | Sugar: j.Sugar, |
49 | 49 | hideSensitiveData: hideSensitiveData, |
50 | | - httpExecutor: executor, |
| 50 | + http: client, |
51 | 51 | } |
52 | 52 |
|
53 | 53 | j.auth = &authInterface |
54 | 54 | } |
55 | 55 |
|
56 | 56 | // BuildBasicAuth is a helper which returns just a configured Basic Auth interface/ |
57 | | -func (j *Integration) BuildBasicAuth(username string, password string, bufferPeriod time.Duration, hideSensitiveData bool, executor httpclient.HTTPExecutor) { |
| 57 | +func (j *Integration) BuildBasicAuth(username string, password string, bufferPeriod time.Duration, hideSensitiveData bool, client http.Client) { |
58 | 58 | authInterface := basicAuth{ |
59 | 59 | username: username, |
60 | 60 | password: password, |
61 | 61 | bufferPeriod: bufferPeriod, |
62 | 62 | Sugar: j.Sugar, |
63 | 63 | baseDomain: j.JamfProFQDN, |
64 | 64 | hideSensitiveData: hideSensitiveData, |
65 | | - httpExecutor: executor, |
| 65 | + http: client, |
66 | 66 | } |
67 | 67 |
|
68 | 68 | j.auth = &authInterface |
|
0 commit comments