diff --git a/cloudflare.go b/cloudflare.go index c26bb04bd7..b54c24abe4 100644 --- a/cloudflare.go +++ b/cloudflare.go @@ -32,7 +32,7 @@ type API struct { APIEmail string APIUserServiceKey string BaseURL string - organizationID string + OrganizationID string headers http.Header httpClient *http.Client authType int @@ -239,8 +239,8 @@ func (api *API) request(method, uri string, reqBody io.Reader, authType int) (*h // accountBase is the base URL for endpoints referring to the current user. It exists as a // parameter because it is not consistent across APIs. func (api *API) userBaseURL(accountBase string) string { - if api.organizationID != "" { - return "/accounts/" + api.organizationID + if api.OrganizationID != "" { + return "/accounts/" + api.OrganizationID } return accountBase } diff --git a/options.go b/options.go index 18c5ecd053..e2bdbf2edf 100644 --- a/options.go +++ b/options.go @@ -32,7 +32,7 @@ func Headers(headers http.Header) Option { // Railguns) to an organization instead. func UsingOrganization(orgID string) Option { return func(api *API) error { - api.organizationID = orgID + api.OrganizationID = orgID return nil } } diff --git a/workers.go b/workers.go index 5b3c9c3cfc..adcc74981a 100644 --- a/workers.go +++ b/workers.go @@ -89,10 +89,10 @@ func (api *API) DeleteWorker(requestParams *WorkerRequestParams) (WorkerScriptRe // // API reference: https://api.cloudflare.com/#worker-script-delete-worker func (api *API) deleteWorkerWithName(scriptName string) (WorkerScriptResponse, error) { - if api.organizationID == "" { + if api.OrganizationID == "" { return WorkerScriptResponse{}, errors.New("organization ID required for enterprise only request") } - uri := "/accounts/" + api.organizationID + "/workers/scripts/" + scriptName + uri := "/accounts/" + api.OrganizationID + "/workers/scripts/" + scriptName res, err := api.makeRequest("DELETE", uri, nil) var r WorkerScriptResponse if err != nil { @@ -128,10 +128,10 @@ func (api *API) DownloadWorker(requestParams *WorkerRequestParams) (WorkerScript // // API reference: https://api.cloudflare.com/#worker-script-download-worker func (api *API) downloadWorkerWithName(scriptName string) (WorkerScriptResponse, error) { - if api.organizationID == "" { + if api.OrganizationID == "" { return WorkerScriptResponse{}, errors.New("organization ID required for enterprise only request") } - uri := "/accounts/" + api.organizationID + "/workers/scripts/" + scriptName + uri := "/accounts/" + api.OrganizationID + "/workers/scripts/" + scriptName res, err := api.makeRequest("GET", uri, nil) var r WorkerScriptResponse if err != nil { @@ -147,10 +147,10 @@ func (api *API) downloadWorkerWithName(scriptName string) (WorkerScriptResponse, // // API reference: https://developers.cloudflare.com/workers/api/config-api-for-enterprise/ func (api *API) ListWorkerScripts() (WorkerListResponse, error) { - if api.organizationID == "" { + if api.OrganizationID == "" { return WorkerListResponse{}, errors.New("organization ID required for enterprise only request") } - uri := "/accounts/" + api.organizationID + "/workers/scripts" + uri := "/accounts/" + api.OrganizationID + "/workers/scripts" res, err := api.makeRequest("GET", uri, nil) if err != nil { return WorkerListResponse{}, errors.Wrap(err, errMakeRequestError) @@ -189,10 +189,10 @@ func (api *API) UploadWorker(requestParams *WorkerRequestParams, data string) (W // // API reference: https://api.cloudflare.com/#worker-script-upload-worker func (api *API) uploadWorkerWithName(scriptName string, data string) (WorkerScriptResponse, error) { - if api.organizationID == "" { + if api.OrganizationID == "" { return WorkerScriptResponse{}, errors.New("organization ID required for enterprise only request") } - uri := "/accounts/" + api.organizationID + "/workers/scripts/" + scriptName + uri := "/accounts/" + api.OrganizationID + "/workers/scripts/" + scriptName api.headers.Add("Content-Type", "application/javascript") res, err := api.makeRequest("PUT", uri, []byte(data)) var r WorkerScriptResponse @@ -207,7 +207,7 @@ func (api *API) uploadWorkerWithName(scriptName string, data string) (WorkerScri } func getRoutesPathComponent(api *API) string { - if api.organizationID == "" { + if api.OrganizationID == "" { return "filters" } return "routes"